Skip to content

Commit

Permalink
Add comment to explain ceil_log2 algo
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandr-pavlyk authored and ndgrigorian committed Dec 28, 2024
1 parent eedce4e commit 11cdf06
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dpctl/tensor/libtensor/include/kernels/sorting/radix_sort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ std::uint32_t ceil_log2(SizeT n)

std::uint32_t exp{1};
--n;
// if n > 2^b, n = q * 2^b + r for q > 0 and 0 <= r < 2^b
// ceil_log2(q * 2^b + r) == ceil_log2(q * 2^b) == q + ceil_log2(n1)
if (n >= (SizeT{1} << 32)) {
n >>= 32;
exp += 32;
Expand Down

0 comments on commit 11cdf06

Please sign in to comment.