RFR: 8318158: RISC-V: implement roundD/roundF intrinsics [v12]
Olga Mikhaltsova
omikhaltcova at openjdk.org
Thu Dec 28 23:34:42 UTC 2023
On Thu, 21 Dec 2023 23:02:55 GMT, Olga Mikhaltsova <omikhaltcova at openjdk.org> wrote:
>> Please, review this Implementation of the roundD/roundF intrinsics for RISC-V platform.
>>
>> In the table below it is shown that NaN argument should be processed as a special case.
>>
>> RISC-V Java
>> (FCVT.W.S) (FCVT.L.D) (long round(double a)) (int round(float a))
>> Minimum valid input (after rounding) −2^31 −2^63 Long.MIN_VALUE Integer.MIN_VALUE
>> Maximum valid input (after rounding) 2^31 − 1 2^63 − 1 Long.MAX_VALUE Integer.MAX_VALUE
>> Output for out-of-range negative input −2^31 −2^63 Long.MIN_VALUE Integer.MIN_VALUE
>> Output for −∞ −2^31 −2^63 Long.MIN_VALUE Integer.MIN_VALUE
>> Output for out-of-range positive input 2^31 − 1 2^63 - 1 Long.MAX_VALUE Integer.MAX_VALUE
>> Output for +∞ 2^31 − 1 2^63 - 1 Long.MAX_VALUE Integer.MAX_VALUE
>> Output for NaN 2^31 − 1 2^63 - 1 0 0
>>
>> The benchmark running with the 2nd fixed implementation on the T-Head RVB-ICE board shows the following performance improvement::
>>
>> **Before**
>>
>> Benchmark (TESTSIZE) Mode Cnt Score Error Units
>> FpRoundingBenchmark.test_round_double 2048 thrpt 15 59.555 0.179 ops/ms
>> FpRoundingBenchmark.test_round_float 2048 thrpt 15 49.760 0.103 ops/ms
>>
>>
>> **After**
>>
>> Benchmark (TESTSIZE) Mode Cnt Score Error Units
>> FpRoundingBenchmark.test_round_double 2048 thrpt 15 110.956 0.186 ops/ms
>> FpRoundingBenchmark.test_round_float 2048 thrpt 15 115.947 0.122 ops/ms
>
> Olga Mikhaltsova has updated the pull request incrementally with one additional commit since the last revision:
>
> Moved the code up + comments
In addition, some examples with RDN for fadd.s and fcvt.w.s:
fadd.s (src + 0.5f): src = 0.345200 dst = 0.845200
fcvt.w.s: src = 0.845200 dst = 0
RESULT: 0 (JAVA Math.round: 0)
fadd.s (src + 0.5f): src = -0.555550 dst = -0.055550
fcvt.w.s: src = -0.055550 dst = -1
RESULT: -1 (JAVA Math.round: -1)
fadd.s (src + 0.5f): src = -1.500000 dst = -1.000000
fcvt.w.s: src = -1.000000 dst = -1
RESULT: -1 (JAVA Math.round: -1)
fadd.s (src + 0.5f): src = 1.500000 dst = 2.000000
fcvt.w.s: src = 2.000000 dst = 2
RESULT: 2 (JAVA Math.round: 2)
fadd.s (src + 0.5f): src = -1.345000 dst = -0.845000
fcvt.w.s: src = -0.845000 dst = -1
RESULT: -1 (JAVA Math.round: -1)
fadd.s (src + 0.5f): src = -1.450000 dst = -0.950000
fcvt.w.s: src = -0.950000 dst = -1
RESULT: -1 (JAVA Math.round: -1)
fadd.s (src + 0.5f): src = -0.444460 dst = 0.055540
fcvt.w.s: src = 0.055540 dst = 0
RESULT: 0 (JAVA Math.round: 0)
fadd.s (src + 0.5f): src = -0.999990 dst = -0.499990
fcvt.w.s: src = -0.499990 dst = -1
RESULT: -1 (JAVA Math.round: -1)
fadd.s (src + 0.5f): src = 0.999990 dst = 1.499990
fcvt.w.s: src = 1.499990 dst = 1
RESULT: 1 (JAVA Math.round: 1)
fadd.s (src + 0.5f): src = 0.000000 dst = 0.500000
fcvt.w.s: src = 0.500000 dst = 0
RESULT: 0 (JAVA Math.round: 0)
fadd.s (src + 0.5f): src = 0.001000 dst = 0.501000
fcvt.w.s: src = 0.501000 dst = 0
RESULT: 0 (JAVA Math.round: 0)
fadd.s (src + 0.5f): src = -0.001000 dst = 0.499000
fcvt.w.s: src = 0.499000 dst = 0
RESULT: 0 (JAVA Math.round: 0)
-------------
PR Comment: https://git.openjdk.org/jdk/pull/16382#issuecomment-1871623924
More information about the hotspot-dev
mailing list