Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

roundup_power_of_two performance #10634

Open
SiarheiVolkau opened this issue Dec 13, 2024 · 0 comments
Open

roundup_power_of_two performance #10634

SiarheiVolkau opened this issue Dec 13, 2024 · 0 comments

Comments

@SiarheiVolkau
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant