Skip to content

Commit 1699120

Browse files
oleksandr-pavlykndgrigorian
authored andcommitted
Add comment to explain ceil_log2 algo
1 parent 6e50fde commit 1699120

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

dpctl/tensor/libtensor/include/kernels/sorting/radix_sort.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ std::uint32_t ceil_log2(SizeT n)
7575

7676
std::uint32_t exp{1};
7777
--n;
78+
// if n > 2^b, n = q * 2^b + r for q > 0 and 0 <= r < 2^b
79+
// ceil_log2(q * 2^b + r) == ceil_log2(q * 2^b) == q + ceil_log2(n1)
7880
if (n >= (SizeT{1} << 32)) {
7981
n >>= 32;
8082
exp += 32;

0 commit comments

Comments
 (0)