On Wed, 23 Apr 2025 23:54:01 GMT, Vladimir Ivanov <vliva...@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 incrementally with one 
> additional commit since the last revision:
> 
>   CPUFeatures: RISC-V support

src/hotspot/share/opto/vectorIntrinsics.cpp line 563:

> 561:     debug_name = 
> debug_name_oop->const_oop()->as_instance()->java_lang_String_str(buf, buflen);
> 562:   }
> 563:   Node* vcall = make_runtime_call(RC_VECTOR,

By generating an upfront CallLeafVectorNode, we may miss out on performing any 
GVN-style optimization for trigonometric identities like the following. do you 
think creating a macro node which can lazily be expanded to call node during 
macro expansion will help.

arcsin(sin(x)) => x
arccos(cos(x)) => x
sin(arcsin(x) => x
cos(arccos(x) => x

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24462#discussion_r2059057257

Reply via email to