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

Avoid slowpath in pow #373

Merged
merged 1 commit into from
Jun 25, 2023
Merged

Avoid slowpath in pow #373

merged 1 commit into from
Jun 25, 2023

Conversation

charleskawczynski
Copy link
Member

Based on the flame graphs, we seem to be hitting this slow path (https://stackoverflow.com/questions/14687665/very-slow-stdpow-for-bases-very-close-to-1), same as what we hit in thermodynamics.

This PR adds pow_fast(x, y) = exp(y * log(x)) to avoid the slow path.

@charleskawczynski
Copy link
Member Author

bors try

bors bot added a commit that referenced this pull request Jun 25, 2023
@bors
Copy link
Contributor

bors bot commented Jun 25, 2023

try

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@charleskawczynski
Copy link
Member Author

This is a nice speedup.

@charleskawczynski
Copy link
Member Author

bors r+

@bors
Copy link
Contributor

bors bot commented Jun 25, 2023

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot merged commit 999d3a2 into main Jun 25, 2023
@bors bors bot deleted the ck/pow branch June 25, 2023 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant