RFR: 8282711: Accelerate Math.signum function for AVX and AVX512 target.

Quan Anh Mai duke at openjdk.java.net
Tue Mar 8 07:00:08 UTC 2022


On Mon, 7 Mar 2022 02:01:55 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:

> - Patch auto-vectorizes Math.signum operation for floating point types.
> - Efficient JIT sequence is being generated for AVX512 and legacy X86 targets.
> - Following is the performance data for include JMH micro.
> 
> System : Intel(R) Xeon(R) Platinum 8380 CPU @ 2.30GHz  (40C 2S Icelake Server) 
> 
> Benchmark | (SIZE) | Baseline AVX (ns/op) | Withopt AVX (ns/op) | Gain Ratio | Basline AVX512 (ns/op) | Withopt AVX512 (ns/op) | Gain Ratio
> -- | -- | -- | -- | -- | -- | -- | --
> VectorSignum.doubleSignum | 256 | 174.357 | 68.374 | 2.550048264 | 173.679 | 31.013 | 5.600199916
> VectorSignum.doubleSignum | 512 | 334.231 | 128.762 | 2.595727 | 334.625 | 59.377 | 5.635599643
> VectorSignum.doubleSignum | 1024 | 655.679 | 251.566 | 2.606389576 | 655.267 | 116.736 | 5.613238418
> VectorSignum.doubleSignum | 2048 | 1292.165 | 499.924 | 2.584722878 | 1301.7 | 228.064 | 5.707608391
> VectorSignum.floatSignum | 256 | 176.064 | 39.864 | 4.416616496 | 174.639 | 25.372 | 6.883138893
> VectorSignum.floatSignum | 512 | 337.565 | 71.027 | 4.752629282 | 331.506 | 36.64 | 9.047652838
> VectorSignum.floatSignum | 1024 | 661.488 | 131.074 | 5.046675924 | 644.621 | 63.88 | 10.09112398
> VectorSignum.floatSignum | 2048 | 1299.685 | 253.271 | 5.13159817 | 1279.658 | 118.995 | 10.75388042
> 
> 
> Kindly review and share feedback.
> 
> Best Regards,
> Jatin

src/hotspot/cpu/x86/x86.ad line 1868:

> 1866:       if (UseAVX < 1 ||
> 1867:           (size_in_bits == 512 && !VM_Version::supports_avx512dq()) ||
> 1868:           (size_in_bits == 256 && !VM_Version::supports_avx2())) {

May I ask why do we need avx2 for 256-bit, thanks.

-------------

PR: https://git.openjdk.java.net/jdk/pull/7717


More information about the hotspot-compiler-dev mailing list