RFR: 8u backport of JDK-8243114 Implement montgomery{Multiply,Square}intrinsics on Windows
Simon Tooke
stooke at redhat.com
Wed Jan 13 13:45:53 UTC 2021
Hello, Bernd, and thanks for taking a look at this.
On 2021-01-12 7:24 p.m., Bernd Eckenfels wrote:
> The patch does not touch the flag processing, will PrintFlagsFinal be able to tell if the version, compiler and os supports it?
The original patch did not touch the flag processing either, so I would
not have included it in this patch.
Currently the flag processing only emits an error if a 32-bit VM is used.
For 64 bit VMs on all platforms and compilers (if I read the code
correctly), the flag is valid, but implementation of the intrinsic
varies (by nature; it is an intrinsic). So it's slower on some platforms
and faster on others; this patch merely speeds up the implementation
when built with the correct compiler. The defaults for the flag are
unchanged.
Thanks,
-Simon
>
> Gruss
> Bernd
> --
> http://bernd.eckenfels.net
> ________________________________
> Von: jdk8u-dev <jdk8u-dev-retn at openjdk.java.net> im Auftrag von Simon Tooke <stooke at redhat.com>
> Gesendet: Monday, January 11, 2021 10:08:38 PM
> An: jdk8u-dev at openjdk.java.net <jdk8u-dev at openjdk.java.net>
> Betreff: RFR: 8u backport of JDK-8243114 Implement montgomery{Multiply,Square}intrinsics on Windows
>
> Backport of JDK-8243114 Implement montgomery{Multiply,Square} intrinsics
> on Windows
>
> JBS: https://bugs.openjdk.java.net/browse/JDK-8243114
> <https://bugs.openjdk.java.net/browse/JDK-8243114>
>
> Webrev:
> http://cr.openjdk.java.net/~stooke/webrevs/jdk-8243114-jdk8u/hotspot.01/
> <http://cr.openjdk.java.net/~stooke/webrevs/jdk-8243114-jdk8u/hotspot.01/>
>
> I would like to backport this performance enhancement to 8u, for
> performance and for Oracle parity.
>
> The backport is trivial, with one exception: Visual Studio 2010 does not
> implement a required compiler intrinsic used by this backport.
>
> Accordingly, the backport is #ifdef'ed to only apply on Windows if
> Visual Studio 2017 (or higher) is used as the build compiler.
>
> I do not have (so was not able to test this backport with) intermediate
> versions of VS; if someone were to grep for _addcarry_u64 in intrin.h,
> perhaps earlier versions can be supported.
>
> Visual Studio 2010 is still supported as a build compiler, but will not
> reap the benefit of this backport.
>
> In addition, MontgomeryMultiplyTest is no longer omitted on Windows
> platforms, and I made sure to apply 8248347 (the follow-up build fix patch).
>
> Using the program below, speedups were observed:
>
> >openjdk-8u282-b04-vs2010\bin\java MMTest
> elapsed time 58220 ms
>
> >openjdk-8u282-b04-vs2017\bin\java -XX:+UseMontgomeryMultiplyIntrinsic
> -XX:+UseMontgomerySquareIntrinsic MMTest (this is the default)
> elapsed time 25471 ms
>
> >openjdk-8u282-b04-vs2017\bin\java -XX:-UseMontgomeryMultiplyIntrinsic
> -XX:-UseMontgomerySquareIntrinsic MMTest
> elapsed time 58980 ms
>
> Test code:
>
> class MMTest {
>
> public static void main(String[] args) {
> Instant start = Instant.now();
> BigInteger base = BigInteger.ONE.shiftLeft(1024);
> long count = LongStream.rangeClosed(2, 100_000)
> .mapToObj(n -> BigInteger.valueOf(n).add(base))
> .filter(i -> i.isProbablePrime(50))
> .count();
> Instant finish = Instant.now();
> long timeElapsed = Duration.between(start, finish).toMillis();
> System.out.format("elapsed time %d ms\n", timeElapsed);
> }
> }
>
>
> Thanks,
>
> -simon
>
>
>
>
More information about the jdk8u-dev
mailing list