RFR: 8267190: Optimize Vector API test operations [v2]

Paul Sandoz psandoz at openjdk.java.net
Thu May 20 21:19:31 UTC 2021


On Thu, 20 May 2021 01:27:48 GMT, Sandhya Viswanathan <sviswanathan at openjdk.org> wrote:

>> Vector API test operations (IS_DEFAULT, IS_FINITE, IS_INFINITE, IS_NAN and IS_NEGATIVE) are computed in three steps:
>> 1) reinterpreting the floating point vectors as integral vectors (int/long)
>> 2) perform the test in integer domain to get a int/long mask
>> 3) reinterpret the int/long mask as float/double mask
>> Step 3) currently is very slow. It can be optimized by modifying the Java code to utilize the existing reinterpret intrinsic.
>> 
>> For the VectorTestPerf attached to the JBS for JDK-8267190, the performance improves as follows:
>> 
>> Base:
>> Benchmark (size) Mode Cnt Score Error Units
>> VectorTestPerf.IS_DEFAULT 1024 thrpt 5 223.156 ± 90.452 ops/ms
>> VectorTestPerf.IS_FINITE 1024 thrpt 5 223.841 ± 91.685 ops/ms
>> VectorTestPerf.IS_INFINITE 1024 thrpt 5 224.561 ± 83.890 ops/ms
>> VectorTestPerf.IS_NAN 1024 thrpt 5 223.777 ± 70.629 ops/ms
>> VectorTestPerf.IS_NEGATIVE 1024 thrpt 5 218.392 ± 79.806 ops/ms
>> 
>> With patch:
>> Benchmark (size) Mode Cnt Score Error Units
>> VectorTestPerf.IS_DEFAULT 1024 thrpt 5 8812.357 ± 40.477 ops/ms
>> VectorTestPerf.IS_FINITE 1024 thrpt 5 7425.739 ± 296.622 ops/ms
>> VectorTestPerf.IS_INFINITE 1024 thrpt 5 8932.730 ± 269.988 ops/ms
>> VectorTestPerf.IS_NAN 1024 thrpt 5 8574.872 ± 498.649 ops/ms
>> VectorTestPerf.IS_NEGATIVE 1024 thrpt 5 8838.400 ± 11.849 ops/ms
>> 
>> Best Regards,
>> Sandhya
>
> Sandhya Viswanathan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Implement Paul's review comments

Java changes are good, some minor comments if you choose to accept them, no need for me to review further.

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template line 852:

> 850:         private final <E>
> 851:         VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
> 852:             boolean[] maskArray = toArray();

Can you add an `assert length() != species.laneCount()`?

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template line 854:

> 852:             boolean[] maskArray = toArray();
> 853:             // enum-switches don't optimize properly JDK-8161245
> 854:             return (

Minor syntactic quibble: you don't need the '(` and `)` surrounding the switch expressions e.g.:

   return switch (dsp.laneType.switchKey) {
       case ...
   }

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

Marked as reviewed by psandoz (Reviewer).

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


More information about the hotspot-compiler-dev mailing list