RFR: 8279508: Auto-vectorize Math.round API [v12]
Andrew Haley
aph at openjdk.java.net
Thu Mar 10 14:05:49 UTC 2022
On Wed, 9 Mar 2022 11:38:34 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:
>> Summary of changes:
>> - Intrinsify Math.round(float) and Math.round(double) APIs.
>> - Extend auto-vectorizer to infer vector operations on encountering scalar IR nodes for above intrinsics.
>> - Test creation using new IR testing framework.
>>
>> Following are the performance number of a JMH micro included with the patch
>>
>> Test System: Intel(R) Xeon(R) Platinum 8380 CPU @ 2.30GHz (Icelake Server)
>>
>>
>> Benchmark | TESTSIZE | Baseline AVX3 (ops/ms) | Withopt AVX3 (ops/ms) | Gain ratio | Baseline AVX2 (ops/ms) | Withopt AVX2 (ops/ms) | Gain ratio
>> -- | -- | -- | -- | -- | -- | -- | --
>> FpRoundingBenchmark.test_round_double | 1024.00 | 504.15 | 2209.54 | 4.38 | 510.36 | 548.39 | 1.07
>> FpRoundingBenchmark.test_round_double | 2048.00 | 293.64 | 1271.98 | 4.33 | 293.48 | 274.01 | 0.93
>> FpRoundingBenchmark.test_round_float | 1024.00 | 825.99 | 4754.66 | 5.76 | 751.83 | 2274.13 | 3.02
>> FpRoundingBenchmark.test_round_float | 2048.00 | 412.22 | 2490.09 | 6.04 | 388.52 | 1334.18 | 3.43
>>
>>
>> Kindly review and share your feedback.
>>
>> Best Regards,
>> Jatin
>
> Jatin Bhateja has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 15 commits:
>
> - 8279508: Preventing domain switch-over penalty for Math.round(float) and constraining unrolling to prevent code bloating.
> - Merge branch 'master' of http://github.com/openjdk/jdk into JDK-8279508
> - 8279508: Removing +LogCompilation flag.
> - 8279508: Review comments resolved.`
> - 8279508: Adding descriptive comments.
> - 8279508: Review comments resolved.
> - 8279508: Review comments resolved.
> - 8279508: Fixing for windows failure.
> - 8279508: Adding few descriptive comments.
> - Merge branch 'master' of http://github.com/openjdk/jdk into JDK-8279508
> - ... and 5 more: https://git.openjdk.java.net/jdk/compare/d07f7c76...547f4e31
test/micro/org/openjdk/bench/java/math/FpRoundingBenchmark.java line 114:
> 112: for (int i = 0; i < TESTSIZE; i++) {
> 113: ResF[i] = Math.round(FargV1[i]);
> 114: }
I think that this is wrong: you should not be storing the result into a float array because it requires an extra integer->float conversion, which distorts the timings. You need `resI` and `resL` for the results of `Math.round`.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7094
More information about the hotspot-compiler-dev
mailing list