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

Changed precondition for edge case in serial_merge to prevent assertion error #622

Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Documentation for rocPRIM is available at
* device merge,
* device partial sort, and/or
* device sort (merge sort).
* Fixed an issue where on certain inputs to block_sort_merge, device_merge_sort_merge_path, device_merge, and warp_sort_stable would cause an assertion error during its call to serial_merge

### Deprecations

Expand Down
8 changes: 4 additions & 4 deletions rocprim/include/rocprim/block/detail/block_sort_merge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ class block_sort_merge
compare_function);
const unsigned int keys2_beg_local = diag0_local - keys1_beg_local;

range_t<> range_local{keys1_beg_local + keys1_beg,
range_t<> range_local{std::min(keys1_beg_local + keys1_beg, keys1_end),
keys1_end,
keys2_beg_local + keys1_end,
std::min(keys2_beg_local + keys1_end, keys2_end),
keys2_end};

serial_merge<false>(keys_shared, thread_keys, range_local, compare_function);
Expand Down Expand Up @@ -430,9 +430,9 @@ class block_sort_merge
compare_function);
const unsigned int keys2_beg_local = diag0_local - keys1_beg_local;

range_t<> range_local{keys1_beg_local + keys1_beg,
range_t<> range_local{std::min(keys1_beg_local + keys1_beg, keys1_end),
keys1_end,
keys2_beg_local + keys1_end,
std::min(keys2_beg_local + keys1_end, keys2_end),
keys2_end};

serial_merge<false>(keys_shared,
Expand Down
4 changes: 2 additions & 2 deletions rocprim/include/rocprim/device/detail/device_merge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ void merge_keys(unsigned int flat_id,
compare_function
);

range_t<> range_partition{range_local.begin1 + partition,
range_t<> range_partition{std::min(range_local.begin1 + partition, range_local.end1),
range_local.end1,
range_local.begin2 + diag - partition,
std::min(range_local.begin2 + diag - partition, range_local.end2),
range_local.end2};

serial_merge<false>(keys_shared, key_inputs, index, range_partition, compare_function);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ namespace detail
const unsigned int keys2_beg_local = diag0_local - keys1_beg_local;
const unsigned int keys2_end_local = num_keys2;

range_t<> range_local{keys1_beg_local,
range_t<> range_local{std::min(keys1_beg_local, keys1_end_local),
keys1_end_local,
keys2_beg_local + keys1_end_local,
std::min(keys2_beg_local + keys1_end_local, keys2_end_local + keys1_end_local),
keys2_end_local + keys1_end_local};

unsigned int indices[ItemsPerThread];
Expand Down Expand Up @@ -329,9 +329,9 @@ namespace detail
const unsigned int keys2_beg_local = diag0_local - keys1_beg_local;
const unsigned int keys2_end_local = num_keys2;

range_t<> range_local{keys1_beg_local,
range_t<> range_local{std::min(keys1_beg_local, keys1_end_local),
keys1_end_local,
keys2_beg_local + keys1_end_local,
std::min(keys2_beg_local + keys1_end_local, keys2_end_local + keys1_end_local),
keys2_end_local + keys1_end_local};

unsigned int indices[ItemsPerThread];
Expand Down
8 changes: 4 additions & 4 deletions rocprim/include/rocprim/warp/detail/warp_sort_stable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ class warp_sort_stable
const auto keys2_merge_begin = keys2_begin + diag - partition;

const range_t<> range{
keys1_merge_begin,
std::min(keys1_merge_begin, keys1_end),
keys1_end,
keys2_merge_begin,
std::min(keys2_merge_begin, keys2_end),
keys2_end,
};

Expand Down Expand Up @@ -217,9 +217,9 @@ class warp_sort_stable
const auto keys2_merge_begin = keys2_begin + diag - partition;

const range_t<> range{
keys1_merge_begin,
std::min(keys1_merge_begin, keys1_end),
keys1_end,
keys2_merge_begin,
std::min(keys2_merge_begin, keys2_end),
keys2_end,
};

Expand Down