RFR: 8348638: Performance regression in Math.tanh [v5]
Jatin Bhateja
jbhateja at openjdk.org
Thu Apr 17 15:51:47 UTC 2025
On Thu, 17 Apr 2025 13:25:42 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:
>> Mohamed Issa has refreshed the contents of this pull request, and previous commits have been removed. The incremental views will show differences compared to the previous content of the PR. The pull request contains one new commit since the last revision:
>>
>> Add new tanh micro-benchmark that covers different ranges of input values
>
> test/micro/org/openjdk/bench/java/lang/MathBench.java line 73:
>
>> 71:
>> 72: @Param("2.7755575615628914E-17")
>> 73: public double tanhBound2;
>
> We can declare tanBoundIndex as a Parameter and then select from [hard-coded value ranges](https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/lang/FdLibm.java#L3258), which will allow us to execute all the special ranges and NaN value.
> double tanhRangeArray [][] = { 0.0 , 0x1.0P-56}, {0x1.0P-56, 1.0}, {1.0, 22.0}, {22.0, Double.POSITIVE_INFINITY}}
> double tanhRangeLowerBound = tanhRangeArray[tanhRangeIndex][0];
> double tanhRangeLowerBound = tanhRangeArray[tanhRangeIndex][1];
I see in a standalone micro that NaN / Inf case performs better without intrinsics
NaN:-
GNR>java -XX:+UnlockDiagnosticVMOptions -XX:DisableIntrinsic=_dtanh -cp . test
[time] 174 ms [res]
GNR>java -XX:+UnlockDiagnosticVMOptions -cp . test
[time] 278 ms [res]
Inf:-
GNR>java -XX:+UnlockDiagnosticVMOptions -cp . test
[time] 410 ms [res]
GNR>java -XX:+UnlockDiagnosticVMOptions -XX:DisableIntrinsic=_dtanh -cp . test
[time] 165 ms [res]
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23889#discussion_r2048996659
More information about the hotspot-compiler-dev
mailing list