RFR: 8312425: [vectorapi] AArch64: Optimize vector math operations with SLEEF
David Holmes
dholmes at openjdk.org
Wed Oct 18 07:40:00 UTC 2023
On Wed, 18 Oct 2023 06:12:29 GMT, Xiaohong Gong <xgong at openjdk.org> wrote:
> Currently the vector floating-point math APIs like `VectorOperators.SIN/COS/TAN...` are not intrinsified on AArch64 platform, which causes large performance gap on AArch64. Note that those APIs are optimized by C2 compiler on X86 platforms by calling Intel's SVML code [1]. To close the gap, we would like to optimize these APIs for AArch64 by calling a third-party vector library called libsleef [2], which are available in mainstream Linux distros (e.g. [3] [4]).
>
> SLEEF supports multiple accuracies. To match Vector API's requirement and implement the math ops on AArch64, we 1) call 1.0 ULP accuracy with FMA instructions used stubs in libsleef for most of the operations by default, and 2) add the vector calling convention to apply with the runtime calls to stub code in libsleef. Note that for those APIs that libsleef does not support 1.0 ULP, we choose 0.5 ULP instead.
>
> To help loading the expected libsleef library, this patch also adds an experimental JVM option (i.e. `-XX:UseSleefLib`) for AArch64 platforms. People can use it to denote the libsleef path/name explicitly. By default, it points to the system installed library. If the library does not exist or the dynamic loading of it in runtime fails, the math vector ops will fall-back to use the default scalar version without error. But a warning is printed out if people specifies a nonexistent library explicitly.
>
> Note that this is a part of the original proposed patch in panama-dev [5], just with some initial review comments addressed. And now we'd like to get some wider feedbacks from more hotspot experts.
>
> [1] https://github.com/openjdk/jdk/pull/3638
> [2] https://sleef.org/
> [3] https://packages.fedoraproject.org/pkgs/sleef/sleef/
> [4] https://packages.debian.org/bookworm/libsleef3
> [5] https://mail.openjdk.org/pipermail/panama-dev/2022-December/018172.html
Changes requested by dholmes (Reviewer).
src/hotspot/cpu/aarch64/globals_aarch64.hpp line 131:
> 129: "Branch Protection to use: none, standard, pac-ret") \
> 130: product(ccstr, UseSleefLib, "libsleef.so.3", EXPERIMENTAL, \
> 131: "Sleef library to use for the vector math operations") \
Experimental functionality like this should not be enabled by default as you are changing the behaviour for all users. This needs to be off by default with user's being able to opt-in if they want.
src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp line 8555:
> 8553: } else {
> 8554: if (FLAG_IS_DEFAULT(UseSleefLib)) {
> 8555: log_info(library)("Fail to load sleef library!");
The library name being looked up is probably useful here too.
-------------
PR Review: https://git.openjdk.org/jdk/pull/16234#pullrequestreview-1684300759
PR Review Comment: https://git.openjdk.org/jdk/pull/16234#discussion_r1363389306
PR Review Comment: https://git.openjdk.org/jdk/pull/16234#discussion_r1363385262
More information about the hotspot-dev
mailing list