RFR: 8312425: [vectorapi] AArch64: Optimize vector math operations with SLEEF [v11]
fitzsim
duke at openjdk.org
Thu Jul 18 20:52:38 UTC 2024
On Tue, 9 Jul 2024 12:08:50 GMT, Hamlin Li <mli at openjdk.org> wrote:
>> Hi,
>> Can you help to review the patch?
>> This pr is based on previous work and discussion in [pr 16234](https://github.com/openjdk/jdk/pull/16234), [pr 18294](https://github.com/openjdk/jdk/pull/18294).
>> * NOTE: This pr depends on https://github.com/openjdk/jdk/pull/19185, which includes a README, a script to generate sleef inline headers and generated sleef inline headers.
>>
>> Compared with previous prs, the major change in this pr is to integrate the source of sleef (for the steps, please check `src/jdk.incubator.vector/linux/native/libvectormath/README`), rather than depends on external sleef things (header or lib) at build or run time.
>> Besides of this change, also modify the previous changes accordingly, e.g. remove some uncessary files or changes especially in make dir of jdk.
>>
>> Besides of the code changes, one important task is to handle the legal process.
>>
>> Thanks!
>>
>> ## Test
>> tests:
>> * test/jdk/jdk/incubator/vector/
>> * test/hotspot/jtreg/compiler/vectorapi/
>>
>> options:
>> * -XX:UseSVE=1 -XX:+EnableVectorSupport -XX:+UseVectorStubs
>> * -XX:UseSVE=0 -XX:+EnableVectorSupport -XX:+UseVectorStubs
>> * -XX:+EnableVectorSupport -XX:-UseVectorStubs
>>
>> ## Performance
>>
>> ### Options
>> * +intrinsic: 'FORK=1;ITER=10;WARMUP_ITER=10;JAVA_OPTIONS=-XX:+UnlockExperimentalVMOptions -XX:+EnableVectorSupport -XX:+UseVectorStubs'
>> * -intrinsic: 'FORK=1;ITER=10;WARMUP_ITER=10;JAVA_OPTIONS=-XX:+UnlockExperimentalVMOptions -XX:+EnableVectorSupport -XX:-UseVectorStubs'
>>
>> ### Float
>> data
>> <google-sheets-html-origin style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
>> Benchmark | (size) | Mode | Cnt | Error | Units | Score +intrinsic (UseSVE=1) | Score -intrinsic | Improvement(UseSVE=1) | Score +intrinsic (UseSVE=0) | Score -intrinsic | Improvement (UseSVE=0)
>> -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | --
>> Float128Vector.ACOS | 1024 | thrpt | 10 | 0.015 | ops/ms | 245.439 | 101.483 | 2.419 | 245.733 | 102.033 | 2.408
>> Float128Vector.ASIN | 1024 | thrpt | 10 | 0.013 | ops/ms | 296.702 | 103.559 | 2.865 | 296.741 | 103.18 | 2.876
>> Float128Vector.ATAN | 1024 | thrpt | 10 | 0.004 | ops/ms | 196.862 | 49.627 | 3.967 | 195.891 | 49.771 | 3.936
>> Float128Vector.ATAN...
>
> Hamlin Li has updated the pull request incrementally with one additional commit since the last revision:
>
> skip TANH
It is possible to regenerate `sleefinline_advsimd.h` and `sleefinline_sve.h` with some new OpenJDK build logic and only the following fifteen SLEEF source files:
32K ./src/jdk.incubator.vector/linux/native/sleef/src/arch/helperadvsimd.h
40K ./src/jdk.incubator.vector/linux/native/sleef/src/arch/helpersve.h
8.0K ./src/jdk.incubator.vector/linux/native/sleef/src/common/addSuffix.c
20K ./src/jdk.incubator.vector/linux/native/sleef/src/common/commonfuncs.h
16K ./src/jdk.incubator.vector/linux/native/sleef/src/common/dd.h
20K ./src/jdk.incubator.vector/linux/native/sleef/src/common/df.h
4.0K ./src/jdk.incubator.vector/linux/native/sleef/src/common/estrin.h
12K ./src/jdk.incubator.vector/linux/native/sleef/src/common/keywords.txt
12K ./src/jdk.incubator.vector/linux/native/sleef/src/common/misc.h
4.0K ./src/jdk.incubator.vector/linux/native/sleef/src/common/quaddef.h
4.0K ./src/jdk.incubator.vector/linux/native/sleef/src/libm/funcproto.h
20K ./src/jdk.incubator.vector/linux/native/sleef/src/libm/mkrename.c
116K ./src/jdk.incubator.vector/linux/native/sleef/src/libm/sleefinline_header.h.org
164K ./src/jdk.incubator.vector/linux/native/sleef/src/libm/sleefsimddp.c
152K ./src/jdk.incubator.vector/linux/native/sleef/src/libm/sleefsimdsp.c
624K total
I was able to extract the shell and C preprocessing steps from the upstream CMake-based build system (by adding `--verbose` to `cmake --build` in `createSleef.sh`) and convert them into an OpenJDK `.gmk` file.
[This branch](https://github.com/fitzsim/jdk/commits/regenerate-sleef-headers-1/) shows various approaches; ideas include:
- the fifteen source files are checked directly into the OpenJDK repository
- a `--regenerate-sleef-headers` configure option that will cause the headers to be rebuilt as their dependencies change
- a `make regenerate-sleef-headers` phony target that unconditionally rebuilds the headers
- cross-compilation support when `--openjdk-target=aarch64-linux-gnu` is specified on an `x86-64` build machine
- a README section with hints on how to maintain the OpenJDK build rules
Whenever the OpenJDK SLEEF source code copies were updated, one would also check for changes in the upstream CMake steps.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/18605#issuecomment-2237551700
More information about the build-dev
mailing list