RFR: 8345177: RISC-V: Add gtests for cmpxchg
Robbin Ehn
rehn at openjdk.org
Fri Nov 29 06:40:37 UTC 2024
On Fri, 29 Nov 2024 02:36:23 GMT, Fei Yang <fyang at openjdk.org> wrote:
>> Hi, please consider.
>>
>> This adds tests to some of the base cases.
>> Focusing on the cases when we pass in same register in some of the argument. (variant 0,1,2,3)
>>
>> Note: Google Test filter = *RiscV.cmpxchg*
>> [==========] Running 4 tests from 1 test suite.
>> [----------] Global test environment set-up.
>> [----------] 4 tests from RiscV
>> [ RUN ] RiscV.cmpxchg_int64_plain_lr_sc_vm
>> [ OK ] RiscV.cmpxchg_int64_plain_lr_sc_vm (2 ms)
>> [ RUN ] RiscV.cmpxchg_int64_plain_maybe_zacas_vm
>> [ OK ] RiscV.cmpxchg_int64_plain_maybe_zacas_vm (0 ms)
>> [ RUN ] RiscV.cmpxchg_int32_plain_lr_sc_vm
>> [ OK ] RiscV.cmpxchg_int32_plain_lr_sc_vm (0 ms)
>> [ RUN ] RiscV.cmpxchg_int32_plain_maybe_zacas_vm
>> [ OK ] RiscV.cmpxchg_int32_plain_maybe_zacas_vm (0 ms)
>> [----------] 4 tests from RiscV (20806 ms total)
>>
>> [----------] Global test environment tear-down
>> [==========] 4 tests from 1 test suite ran. (20809 ms total)
>> [ PASSED ] 4 tests.
>>
>>
>> Executed with `-XX:+UnlockExperimentalVMOptions -XX:+UseZacas`
>>
>> Thanks, Robbin
>
> test/hotspot/gtest/riscv/test_assembler_riscv.cpp line 153:
>
>> 151: }
>> 152: _masm.flush();
>> 153: OrderAccess::cross_modify_fence();
>
> Do we need this `cross_modify_fence`? Seems to me the preceding `_masm.flush()` which delegates work to `riscv_flush_icache` syscall will do here. Same question for the `CmovTester` case.
The exact implementation of flush we may want to change, e.g. Zjid, I/D consistency.
And the same goes for CMF, e.g. with Zijd it may be an IMPORT.I and FENCE.I or similar.
Here we don't care about that, we only want to test some instructions.
The scary options here is UseCtxFencei, which allows us to avoid some icache flush.
And we may want to remove more icache flushes.
By having both we get a pretty good guarantee that future optimizations don't break this gtest.
As producer I call flush(), as consumer I call CMF.
But yes we can remove CMF, I'm fine with that also, maybe my paranoia is not warranted.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22437#discussion_r1863022454
More information about the hotspot-dev
mailing list