You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that roundup_power_of_two is over-engineered.
Boiling down such thing leads to typical count leading zeros (clz) problem.
Modern CPUs will do it in a few cycles via special instruction(s),
we just need to use __builtin_clz for suitable compiler or rewrite it
in a way that allow compilers detect clz pattern in the code.
In current implementation no one compiler detects clz pattern thus it is just slow.
The text was updated successfully, but these errors were encountered:
It seems that
roundup_power_of_two
is over-engineered.Boiling down such thing leads to typical
count leading zeros
(clz) problem.Modern CPUs will do it in a few cycles via special instruction(s),
we just need to use
__builtin_clz
for suitable compiler or rewrite itin a way that allow compilers detect
clz
pattern in the code.In current implementation no one compiler detects
clz
pattern thus it is just slow.The text was updated successfully, but these errors were encountered: