RFR: 8360559: Optimize Math.sinh for x86 64 bit platforms
Joe Darcy
darcy at openjdk.org
Mon Jul 7 18:03:40 UTC 2025
On Mon, 7 Jul 2025 03:05:15 GMT, Mohamed Issa <missa at openjdk.org> wrote:
> The goal of this PR is to implement an x86_64 intrinsic for java.lang.Math.sinh() using libm. There is a new set of micro-benchmarks are included to check the performance of specific input value ranges to help prevent regressions in the future.
>
> The command to run all range specific micro-benchmarks is posted below.
>
> `make test TEST="micro:SinhPerf.SinhPerfRanges"`
>
> The results of all tests posted below were captured with an [Intel® Xeon 8488C](https://advisor.cloudzero.com/aws/ec2/r7i.metal-24xl) using [OpenJDK v26-b4](https://github.com/openjdk/jdk/releases/tag/jdk-26%2B4) as the baseline version.
>
> For performance data collected with the new built in range micro-benchmark, see the table below. Each result is the mean of 8 individual runs, and the input ranges used match those from the original Java implementation. Overall, the intrinsic provides an an average uplift of 64% when input values fall into the middle three ranges where heavy computation is required. However, very small inputs and very large inputs show drops of 74% and 66% respectively.
>
> | Input range(s) | Baseline throughput (ops/ms) | Intrinsic throughput (ops/ms) | Speedup |
> | :------------------------------------: | :-------------------------------: | :--------------------------------: | :--------: |
> | [-2^(-28), 2^(-28)] | 844160 | 216029 | 0.26x |
> | [-22, -2^(-28)], [2^(-28), 22] | 81662 | 157351 | 1.93x |
> | [-709.78, -22], [22, 709.78] | 119075 | 167635 | 1.41x |
> | [-710.48, -709.78], [709.78, 710.48] | 111636 | 177125 | 1.59x |
> | (-INF, -710.48], [710.48, INF) | 959296 | 313839 | 0.33x |
>
> Finally, the `jtreg:test/jdk/java/lang/Math/HyperbolicTests.java` test passed with the changes.
Are there plans for a cosh intrinsic as follow-up work? There was a previous effort to intrinsify tanh.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/26152#issuecomment-3046086649
More information about the core-libs-dev
mailing list