RFR: 8353686: Optimize Math.cbrt for x86 64 bit platforms [v4]

Jatin Bhateja jbhateja at openjdk.org
Fri May 30 17:22:53 UTC 2025


On Thu, 29 May 2025 18:49:28 GMT, Mohamed Issa <duke at openjdk.org> wrote:

>> test/micro/org/openjdk/bench/java/lang/CbrtPerf.java line 56:
>> 
>>> 54:     public static class CbrtPerfRanges {
>>> 55:         public static int cbrtInputCount = 2048;
>>> 56: 
>> 
>> Please create separate CbrtPerfSpecialValues for +/- 0.0 and +/- Infinity and NaN values.
>> I understand that handling special cases in intrinsic may impact general case performance but its ok to have atleast micro for it.
>
> Ok, I added this to the new set of micro-benchmarks. I kept them as variable values.

With Intrinsic Disabled:-

Benchmark                                              Mode  Cnt        Score   Error   Units
CbrtPerf.CbrtPerfSpecialValues.cbrtDouble0            thrpt    2  1343559.770          ops/ms
CbrtPerf.CbrtPerfSpecialValues.cbrtDoubleInf          thrpt    2   881930.283          ops/ms
CbrtPerf.CbrtPerfSpecialValues.cbrtDoubleNaN          thrpt    2   973307.409          ops/ms
CbrtPerf.CbrtPerfSpecialValues.cbrtDoubleNegative0    thrpt    2  1342454.046          ops/ms
CbrtPerf.CbrtPerfSpecialValues.cbrtDoubleNegativeInf  thrpt    2   880169.071          ops/ms

With Intrinsic Enabled:-

Benchmark                                              Mode  Cnt       Score   Error   Units
CbrtPerf.CbrtPerfSpecialValues.cbrtDouble0            thrpt    2  293228.991          ops/ms
CbrtPerf.CbrtPerfSpecialValues.cbrtDoubleInf          thrpt    2  329190.573          ops/ms
CbrtPerf.CbrtPerfSpecialValues.cbrtDoubleNaN          thrpt    2  334625.414          ops/ms
CbrtPerf.CbrtPerfSpecialValues.cbrtDoubleNegative0    thrpt    2  270939.709          ops/ms
CbrtPerf.CbrtPerfSpecialValues.cbrtDoubleNegativeInf  thrpt    2  328087.618          ops/ms


As expected, optimized intrinsic penalizes special case performance to optimize generic case control paths. Have you tried adding these special checks and measuring the impact on performance?  Alternatively, we can create a follow up JBS to address it later.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24470#discussion_r2116295936


More information about the graal-dev mailing list