Optimize multiplication for Normed#213
Merged
kimikage merged 1 commit intoJuliaMath:masterfrom Aug 24, 2020
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## master #213 +/- ##
==========================================
+ Coverage 90.39% 91.01% +0.61%
==========================================
Files 6 6
Lines 510 534 +24
==========================================
+ Hits 461 486 +25
+ Misses 49 48 -1
Continue to review full report at Codecov.
|
Collaborator
Author
Benchmarkx_n0f8 = collect(rand(N0f8, 1000, 1000)); y_n0f8 = collect(rand(N0f8, 1000, 1000));
x_n0f16 = collect(rand(N0f16, 1000, 1000)); y_n0f16 = collect(rand(N0f16, 1000, 1000));
x_n4f4 = collect(rand(N4f4, 1000, 1000)); y_n4f4 = collect(rand(N4f4, 1000, 1000));
x_n4f12 = collect(rand(N4f12, 1000, 1000)); y_n4f12 = collect(rand(N4f12, 1000, 1000));
z_n4f4 = N4f4.( rand(1000, 1000));
z_n4f12 = N4f12.(rand(1000, 1000));
@btime $x_n0f8 .* $y_n0f8;
@btime $x_n0f16 .* $y_n0f16;
@btime saturating_mul.($x_n4f4, $y_n4f4);
@btime saturating_mul.($x_n4f12, $y_n4f12);
@btime $x_n4f4 .* $z_n4f4;
@btime $x_n4f12 .* $z_n4f12;
|
e330f1d to
817f18f
Compare
This was referenced Aug 20, 2020
This adds `wrapping_mul`, `saturating_mul` and `checked_mul` binary operations. However, this does not specialize them for `Fixed` and does not change `*` for `Fixed`. This replaces most of Normed's implementation of multiplication with integer operations. This improves the speed in many cases and the accuracy in some cases.
Collaborator
Author
|
Thank you for all your reviews. |
kimikage
added a commit
to kimikage/FixedPointNumbers.jl
that referenced
this pull request
May 1, 2024
This adds `wrapping_mul` and `checked_mul` binary operations for `Normed`. This replaces most of Normed's implementation of multiplication with integer operations. This improves the speed in many cases and the accuracy in some cases.
kimikage
added a commit
to kimikage/FixedPointNumbers.jl
that referenced
this pull request
May 1, 2024
This adds `wrapping_mul` and `checked_mul` binary operations for `Normed`. This replaces most of Normed's implementation of multiplication with integer operations. This improves the speed in many cases and the accuracy in some cases.
kimikage
added a commit
to kimikage/FixedPointNumbers.jl
that referenced
this pull request
May 1, 2024
This adds `wrapping_mul` and `checked_mul` binary operations for `Normed`. This replaces most of Normed's implementation of multiplication with integer operations. This improves the speed in many cases and the accuracy in some cases.
kimikage
added a commit
to kimikage/FixedPointNumbers.jl
that referenced
this pull request
May 1, 2024
This adds `wrapping_mul` and `checked_mul` binary operations for `Normed`. This replaces most of Normed's implementation of multiplication with integer operations. This improves the speed in many cases and the accuracy in some cases.
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.
This adds
wrapping_mul,saturating_mulandchecked_mulbinary operations. However, this does not specialize them forFixedand does not change*forFixed.This applies the wrapping arithmetic as the default arithmetic of
*for the abstractFixedPoint, but as mentioned above, the*forFixedis not affected by the default arithmetic. Furthermore,*forNormedoverrides the default arithmetic with the "checked" arithmetic for backward compatibility. (Strictly speaking, the error type is changed fromArgumentErrortoOverflowError.)This replaces most of Normed's implementation of multiplication with integer operations. This improves the speed in many cases and the accuracy in some cases.
Fixes #174