Skip to content
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 possible int overflow in compute_mixed_join_output_size #17633

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cpp/src/join/mixed_join_size_kernel.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ CUDF_KERNEL void __launch_bounds__(block_size)
intermediate_storage + (threadIdx.x * device_expression_data.num_intermediates);

std::size_t thread_counter{0};
cudf::size_type const start_idx = threadIdx.x + blockIdx.x * block_size;
cudf::size_type const stride = block_size * gridDim.x;
auto const start_idx = cudf::detail::grid_1d::global_thread_id();
auto const stride = cudf::detail::grid_1d::grid_stride();
cudf::size_type const left_num_rows = left_table.num_rows();
cudf::size_type const right_num_rows = right_table.num_rows();
auto const outer_num_rows = (swap_tables ? right_num_rows : left_num_rows);
Expand All @@ -80,7 +80,7 @@ CUDF_KERNEL void __launch_bounds__(block_size)
auto count_equality = pair_expression_equality<has_nulls>{
evaluator, thread_intermediate_storage, swap_tables, equality_probe};

for (cudf::size_type outer_row_index = start_idx; outer_row_index < outer_num_rows;
for (auto outer_row_index = start_idx; outer_row_index < outer_num_rows;
outer_row_index += stride) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding stride to outer_row_index when start_index (thread-index) is within block-size of max int32 will cause it to overflow.

auto query_pair = pair_func(outer_row_index);
if (join_type == join_kind::LEFT_JOIN || join_type == join_kind::FULL_JOIN) {
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/json/json_path.cu
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ __launch_bounds__(block_size) CUDF_KERNEL
get_json_object_options options)
{
auto tid = cudf::detail::grid_1d::global_thread_id();
auto const stride = cudf::thread_index_type{blockDim.x} * cudf::thread_index_type{gridDim.x};
auto const stride = cudf::detail::grid_1d::grid_stride();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a cleanup included here for convenience.


size_type warp_valid_count{0};

Expand Down
Loading