Skip to content

Commit

Permalink
Kokkos: fix Sort bug with empty bins
Browse files Browse the repository at this point in the history
See #2471 and kokkos/kokkos#1503
Out-of-bounds access when sorting
an empty bin.
  • Loading branch information
ibaned committed Mar 29, 2018
1 parent d4aa58e commit 2305cfe
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/kokkos/algorithms/src/Kokkos_Sort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,10 @@ class BinSort {

KOKKOS_INLINE_FUNCTION
void operator() (const bin_sort_bins_tag& tag, const int&i ) const {
auto bin_size = bin_count_const(i);
if (bin_size <= 1) return;
int upper_bound = bin_offsets(i)+bin_size;
bool sorted = false;
int upper_bound = bin_offsets(i)+bin_count_const(i);
while(!sorted) {
sorted = true;
int old_idx = sort_order(bin_offsets(i));
Expand Down

0 comments on commit 2305cfe

Please sign in to comment.