-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
math/big: better multiply primitives #9245
Comments
See also https://go-review.googlesource.com/c/go/+/76270 (for arm64) where it is reported: The lack of proper addMulVVW implementation for arm64 hurts RSA This is an optimized implementation, it improves RSA2048 performance |
/cc @ericlagergren |
Pushing to next release. There are some discussions about other math/bits primitive operations; maybe we can write some of this code in Go rather than assembly at some point. |
Has this potentially been solved by https://go-review.googlesource.com/c/go/+/74851/ mentioned in #20058 (comment)? Sorry if OT, I was researching around Go performance topics and stumbled here. |
I believe this was for ARMv8; there's more to do here. The Go team is pre-occupied with generics for 1.18, so this is unlikely to happen for 1.18 unless somebody else wants to step in, preferably with experience in performance-critical arithmetic routines. |
CL mentioned is after issue was raised, fixes amd64 and has been merged ;) |
Indeed, I misread, my apologies. So what's left to do is porting this to other architectures? |
I read the issue as related to x86. |
Suggestions from Torbjörn Granlund (personal e-mail):
"
The multiply primitives, in particular addMulVVW surely deserves more
attention:
Offset the pointers so that you can index with a counter register
which goes from -n to 0, saving the CMPQ.
Unroll. You can save most of the ADCQ $0, R that way. Basically,
do one run with just MULQ where you sum the old highpart (DX) with
the new lowpart (AX). You will need some MOVQ to move DX
out-of-the-way too. Then do a new run over these sums where you
bring in the memory addend. This should double the speed on some
newer CPUs.
A good addMulVVW is probably really the first thing to write in
assembly; addition and subtraction is much less important, usually.
"
The text was updated successfully, but these errors were encountered: