Fix grid_dim_x calculations - #2980
Merged
Merged
Conversation
Member
|
Looks good but is there a test case for this? Or do we only launch 2D grids for very large inputs (which we can't really test in CI)? |
Contributor
Author
Yeah, I think it would be too big. bool large = w.size() > UINT_MAX;
------
std::tuple<dim3, uint> get_launch_args(
size_t size,
const Shape& shape,
const Strides& strides,
bool large,
int work_per_thread /* = 1 */,
uint max_block_dim /* = 1024 */) {
size_t nthreads = cuda::ceil_div(size, work_per_thread);
uint block_dim = max_block_dim < nthreads ? max_block_dim : nthreads;
dim3 num_blocks;
if (large) {
num_blocks = get_2d_grid_dims(shape, strides, work_per_thread);
num_blocks.x = cuda::ceil_div(num_blocks.x, block_dim);
} else {
num_blocks.x = cuda::ceil_div(nthreads, block_dim);
}
return std::make_tuple(num_blocks, block_dim);
} |
Member
|
@nastya236 do you mind double checking this? I thought you changed it recently to fix a bug I had written but maybe the change was also not exact? |
Member
|
Do you mind rebasing to resolve the conflict, then we can run tests + merge? |
CC-Yeh
force-pushed
the
fix_affine_cuda_kernel
branch
from
January 11, 2026 20:09
bfb7afe to
9ecb97a
Compare
Contributor
Author
Done! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Fix
grid_dim_xcalculations which only shows error when launching 2D grids.Checklist
pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes