[Benchmarks] Fast Inverse Square Root - #362
Open
mt-xing wants to merge 10 commits into
Open
Conversation
Owner
|
Sorry to be a stickler on a language thing here, but could you please rename "lame*" to something like "slow*" or "iterative*"? |
Contributor
Author
Sure! It's now called |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please note that this PR includes benchmarks that depend on an extension which provides
bits2floatandfloat2bits, which has not yet been merged.This PR adds two benchmarks, called
fastinvsqrtanditerativefastinvsqrtrespectively. Both will compute1/sqrt(x)using fast methods. The primary inspiration was the legendary Quake 3 Fast Inverse Square Root Algorithm, which computes the value extremely fast, using some bit magic to get a logarithmic approximation and then uses a single iteration of Newton's method to refine the estimate. Unfortunately, this requiresbits2floatandfloat2bits, which a peer has submitted a PR to add to bril that has not yet been merged.As an alternative,
iterativefastinvsqrtuses the much less interesting Newton's method, starting at1/xand iterating until the step size becomes smaller than a user-defined precision. This benchmark runs fine even on bril as it exists today. The TOML test case is thus provided foriterativefastinvsqrtonly.It may be wise to hold off on merging this benchmark until the bit casting extension is merged.