RFR: 8353786: Migrate Vector API math library support to FFM API [v7]
Vladimir Ivanov
vlivanov at openjdk.org
Wed Apr 16 21:29:50 UTC 2025
On Wed, 16 Apr 2025 19:29:07 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!
>
> Vladimir Ivanov has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 21 commits:
>
> - Merge branch 'master' into vector.math.01.java
> - Fix debugName handling
> - Merge branch 'master' into vector.math.01.java
> - RVV and SVE adjustments
> - Merge branch 'master' into vector.math.01.java
> - Fix windows-aarch64 build failure
> - features_string -> cpu_info_string
> - Reviews and Float64Vector-related fix
> - Misc fixes and cleanups
> - CPU features support
> - ... and 11 more: https://git.openjdk.org/jdk/compare/98dac46a...a288cbbf
Both `CPUFeatures.validateFeatures` and the checks it performs are assertions, so it has to be explicitly enabled by `-esa`. The assert validates some assumptions the code has about the format of features string VM produces. And feature names are controlled by JVM (JVM assigns names itself). If there's a mismatch, something is really broken. Why do you think it makes sense to be defensive here and try to recover if the checks fail?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/24462#issuecomment-2810842069
More information about the hotspot-dev
mailing list