Repository navigation
Use the optimized multiply path for decimal32_t - #1465
Merged
Merged
Conversation
- decimal32_t * decimal32_t gave the raw product to the constructor, and did not use the faster path of the other types. - That path rounds to 7 digits before pack_in_range, and the constructor then rounds a subnormal result again. Thus a product with an exponent below etiny still goes to the constructor unrounded. Above etiny, the rounded result has 7 digits or is at least 1e-94, so one rounding is correct. - decimal32_t * Integer keeps the constructor path, because the optimized path gives a zero product a different exponent. - The results are bit-identical to the old path in all five rounding modes.
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.
decimal32_t * decimal32_tgave the raw product to the constructor. Theother types take the path through
mul_finalize_u64, which is faster.A comment said that the hardware divide of the constructor was cheap
enough, but on the machine below the constructor path is slower.
decimal32_tnow takes the same path as the other types, except for onecase. That path rounds the product to 7 digits before
pack_in_range,and the constructor then rounds a subnormal result a second time.
etinystill goes tothe constructor unrounded. Above
etiny, the rounded result has 7 digitsor is at least 1e-94, so one rounding is correct.
decimal32_t * Integerkeeps the constructor path. The optimized pathgives a zero product a different quantum exponent there.
The results are bit-identical to develop. I compared 100 million random
products in each of the five rounding modes, with subnormal operands, short
significands and integer right operands.
test/benchmarks.cpp, multiplication, median of 6 runs (Ryzen 9 3900X,GCC 16,
-O3):decimal32_tdecimal_fast32_tThe checksum
sof the benchmark is the same before and after.