-
Notifications
You must be signed in to change notification settings - Fork 914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix some possible thread-id overflow calculations #17473
Conversation
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
/ok to test |
@@ -413,7 +413,7 @@ CUDF_KERNEL void compute_segment_sizes(device_span<column_device_view const> col | |||
size_type max_branch_depth) | |||
{ | |||
extern __shared__ row_span thread_branch_stacks[]; | |||
int const tid = threadIdx.x + blockIdx.x * blockDim.x; | |||
auto const tid = static_cast<size_type>(cudf::detail::grid_1d::global_thread_id()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merely for clarity. Prefer the type be size_type
rather than int
.
thread_index_type const stride = blockDim.x * gridDim.x; | ||
auto const block_size = static_cast<thread_index_type>(blockDim.x); | ||
thread_index_type const start = threadIdx.x + blockIdx.x * block_size; | ||
thread_index_type const stride = block_size * gridDim.x; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is explicit up-casting for multiplication.
@@ -138,7 +138,7 @@ CUDF_KERNEL void compute_row_partition_numbers(row_hasher_t the_hasher, | |||
auto const stride = cudf::detail::grid_1d::grid_stride(); | |||
|
|||
// Initialize local histogram | |||
size_type partition_number = threadIdx.x; | |||
thread_index_type partition_number = threadIdx.x; | |||
while (partition_number < num_partitions) { | |||
shared_partition_sizes[partition_number] = 0; | |||
partition_number += blockDim.x; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If num_partitions
is close to max<size_type>
then partition_number += blockDim.x
could overlfow size_type
.
/ok to test |
/ok to test |
/ok to test |
/ok to test |
/ok to test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
/merge |
Description
Fixes some possible thread-id calculations or usages that may possibly overflow
int32
type orsize_type
.Reference #10368
Checklist