Skip to content

Commit 7ebd7d0

Browse files
author
kevyuu
committed
Fix wrong iteration order
1 parent 60ec970 commit 7ebd7d0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

include/nbl/core/algorithm/radix_sort.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,18 @@ struct RadixLsbSorter
8484

8585
// count
8686
constexpr histogram_t shift = static_cast<histogram_t>(radix_bits*pass_ix);
87-
for (histogram_t i = 0u; i < rangeSize; i++)
87+
for (histogram_t i = rangeSize; i != 0;)
88+
{
89+
i--;
8890
++m_histogram[comp.template operator()<shift,radix_mask>(input[i])];
91+
}
8992

9093
// prefix sum
9194
std::exclusive_scan(m_histogram, m_histogram + histogram_size, m_histogram, 0);
9295

9396
// scatter. After scatter m_histogram now become a skiplist
94-
for (histogram_t i = rangeSize; i != 0;)
97+
for (histogram_t i = 0; i < rangeSize; i++)
9598
{
96-
i--;
9799
const auto& val = input[i];
98100
const auto& histogramIx = comp.template operator()<shift,radix_mask>(val);
99101
output[m_histogram[histogramIx]++] = val;

0 commit comments

Comments
 (0)