RFR: 8353786: Migrate Vector API math library support to FFM API
Vladimir Kozlov
kvn at openjdk.org
Mon Apr 7 17:05:59 UTC 2025
On Fri, 4 Apr 2025 22:52:24 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:
> Migrate Vector API math library (SVML and SLEEF) linkage from native code (in JVM) to Java FFM API.
>
> Since FFM API doesn't support vector calling conventions yet, migration affects only symbol lookup for now. But it still enables significant simplifications on JVM side.
>
> The patch consists of the following parts:
> * on-demand symbol lookup in Java code replaces eager lookup from native code during JVM startup;
> * 2 new VM intrinsics for vector calls (support unary and binary shapes) (code separated from unary/binary vector operations);
> * new internal interface to query supported CPU ISA extensions (`jdk.incubator.vector.CPUFeatures`) used for CPU dispatching.
>
> `java.lang.foreign` API is used to perform symbol lookup in vector math library, then the address is cached and fed into corresponding JVM intrinsic, so C2 can turn it into a direct vector call in generated code.
>
> Once `java.lang.foreign` supports vectors & vector calling conventions, VM intrinsics can go away.
>
> Performance is on par with original implementation (tested with microbenchmarks on linux-x64 and macosx-aarch64).
>
> Testing: hs-tier1 - hs-tier6, microbenchmarks (on linux-x64 and macosx-aarch64)
>
> Thanks!
Few questions?
src/jdk.incubator.vector/share/classes/jdk/incubator/vector/CPUFeatures.java line 60:
> 58: }
> 59:
> 60: public static class X64 {
Should we create `src/jdk.incubator.vector/cpu/` for CPU specific information? As separate refactoring.
src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMathLibrary.java line 100:
> 98:
> 99: /**
> 100: * Naming convention in SVML vector math library.
Does this library has code for all AVX configurations?
-------------
PR Review: https://git.openjdk.org/jdk/pull/24462#pullrequestreview-2747510895
PR Review Comment: https://git.openjdk.org/jdk/pull/24462#discussion_r2031654383
PR Review Comment: https://git.openjdk.org/jdk/pull/24462#discussion_r2031657213
More information about the core-libs-dev
mailing list