RFR: 8355698: JDK not supporting sleef could cause exception at runtime after JDK-8353786
Hamlin Li
mli at openjdk.org
Wed Apr 30 19:46:26 UTC 2025
On Tue, 29 Apr 2025 02:40:01 GMT, SendaoYan <syan at openjdk.org> wrote:
>> Hi,
>> Can you help to review this patch?
>>
>> Before [JDK-8353786](https://bugs.openjdk.org/browse/JDK-8353786), when a released jdk not supportting sleef (for any reason, e.g. low gcc version, intrinsic not supported, rvv not supported, and so on) runs on machine support vector operation (e.g. on riscv, it supports rvv), it can not call into sleef, but will not fail either, it falls back to java scalar version implementation.
>> But after [JDK-8353786](https://bugs.openjdk.org/browse/JDK-8353786), it will cause an exception thrown at runtime.
>>
>> This change the behaviour of existing jdk, and it should not throw exception anyway.
>>
>> @iwanowww @RealFYang
>>
>> Thanks!
>
> This PR can fix the failure of [JDK-8355656](https://bugs.openjdk.org/browse/JDK-8355656)
I think, first [JDK-8353786](https://bugs.openjdk.org/browse/JDK-8353786) changes the behaviour of jdk (previously it does not throw exception or fail in other ways). second it should fall back to a java implementation rather than fail, this is more friendly to jdk vendors and users. As you can see, @sendaoYan report another issue related to it on x64 platform.
For the jdk vendors, I suppose they should try their best to build a jdk with full vector math library support, but they can fail to do so for many reasons, in that situation we should fall back to a default version which could be slow in performance, but should not fail, because we already has a java scalar version implemented, and the motivation of this version is for falling back when there is no optimal native version.
> The assumption is if vector math library is present, it provides full set of stubs.
Yes. The issues here is the released jdk could be lack of support of such library for various reasons.
> Do we really want to complicate things even more by supporting arbitrary subsets of vector math stubs?
I'm not sure what you mean here, but seems to me the fix is simple, we just not throw exception and allow it fall back to java scalar version, and this behaviour is consitent with previous jdk behaviour. Or can you clarify further?
> IMO a better way to fix the problem is to avoid building/bundling SLEEF when any stubs are missing.
This behavour was decided in previous PRs https://github.com/openjdk/jdk/pull/20781, https://github.com/openjdk/jdk/pull/21083, https://github.com/openjdk/jdk/pull/21502, and some other uncommited PRs prior to these ones.
And the x64 math libraray support (SVML) in jdk was introduced even earlier.
How do you think about it?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/24914#issuecomment-2838053586
More information about the hotspot-dev
mailing list