RFR: 8330266: RISC-V: Restore frm to RoundingMode::rne after JNI [v2]
Ludovic Henry
luhenry at openjdk.org
Tue Apr 16 10:56:00 UTC 2024
On Tue, 16 Apr 2024 10:45:47 GMT, Vladimir Kempik <vkempik at openjdk.org> wrote:
>> @VladimirKempik again, happy to get input from more people on that document! :)
>
> Here are results from c910 ( licheePi4a). using:
> a) jni_blank as is
> b) modified jni_blank where native func() does this:
>
>
> int x = 2;
> asm
> ("csrw fcsr,%0\n\t"
> :
> : "r" (x)
> );
>
> branchful - exactly this PR
> branchless - this PR without csrr&beq
>
> results:
>
> no fcsr change in native code
>
>
> branchless
> Benchmark Mode Cnt Score Error Units
> CallOverheadConstant.jni_blank avgt 30 133.586 ? 1.431 ns/op
> CallOverheadVirtual.jni_blank avgt 30 131.715 ? 0.570 ns/op
>
>
> branchful
> Benchmark Mode Cnt Score Error Units
> CallOverheadConstant.jni_blank avgt 30 133.376 ? 1.491 ns/op
> CallOverheadVirtual.jni_blank avgt 30 133.560 ? 1.782 ns/op
>
>
> fcsr changed to rdn in native code
>
>
>
> branchless
> Benchmark Mode Cnt Score Error Units
> CallOverheadConstant.jni_blank avgt 30 153.708 ? 1.191 ns/op
> CallOverheadVirtual.jni_blank avgt 30 150.653 ? 1.617 ns/op
>
> branchful
> Benchmark Mode Cnt Score Error Units
> CallOverheadConstant.jni_blank avgt 30 153.595 ? 0.759 ns/op
> CallOverheadVirtual.jni_blank avgt 30 149.992 ? 1.605 ns/op
>
>
> Basically there are not difference here ( thanks to BranchPredictor), so why would you make code more complex (and require additional registers) ?
Great to see there is no performance degradation on the current generation of hardware. That's a great motivator to get this change in with the branch as we already know that the branch is going to bring a performance improvement on next/other generations of hardware.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18785#discussion_r1567150600
More information about the hotspot-dev
mailing list