Repository navigation
Benchmark fast_float with and without FASTFLOAT_ROUNDS_TO_NEAREST - #433
Merged
Merged
Conversation
realbenchmark now also times the parsing loops compiled with FASTFLOAT_ROUNDS_TO_NEAREST (benchmark_rtn.cpp). That file renames the fast_float namespace so that both configurations coexist in one binary without an ODR violation.
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.
Stacked on #432. This PR targets its branch and should be merged after it.
realbenchmarknow times each parsing loop twice: once with the default fast_float, and once compiled withFASTFLOAT_ROUNDS_TO_NEAREST. The second set of lines is labeledassume nearest.The macro version lives in a separate file,
benchmarks/benchmark_rtn.cpp. That file renames the namespace (#define fast_float fast_float_rtn) before including fast_float. Without the rename, the two configurations would define the same inline functions differently in one binary, which is an ODR violation: the linker could silently keep either version. With it,nmshows separatefast_float::andfast_float_rtn::symbols, and the rounding-mode probe (rounds_to_nearest()::fmin) exists only in the default one. The timed loops are in the same file as the parsing, so both versions are inlined the same way.Results on an Intel Xeon Gold 6548N (Emerald Rapids)
Linux (RHEL 10), pinned to one core, ASCII inputs. Each cell shows Mfloat/s, then instructions and cycles per float.
GCC 14.3
Clang 21
The macro always saves instructions: up to 6% on mesh, where most numbers take the fast path, and less than 1% on canada, where most do not. Speed changes by a few percent at most, in either direction. The one slowdown is with Clang on mesh (64-bit): 9 fewer instructions per float, but 1.2 more cycles.