-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8315841: RISC-V: Check for hardware TSO support #15613
Conversation
With the Ztso extension [1], some hardware will support TSO on RISC-V. That allows us to reduce the generation of memory fences, given the stronger memory model compared to RVWMO. [1] https://github.com/riscv/riscv-isa-manual/blob/6dcbc6da9ada01f0f57da83cda6059bdec57619f/src/ztso-st-ext.adoc#L1
👋 Welcome back luhenry! A progress list of the required criteria for merging this PR into |
Webrevs
|
Hello Ludovic, will this ( and hw support for tso) help to reduce overhead from getfield IsDone ?
|
Some of the most common cases of fences that are going to be generated are |
IIRC, the TSO elf files will have special bit set in elf header. it could be
|
We don't have to build hotspot for TSO in order to use it in code generated for Java, given the RVTSO memory model is strictly stronger than RVWMO. We could indeed set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good (minus a nit).
@@ -210,6 +210,14 @@ void VM_Version::initialize() { | |||
unaligned_access.value() == MISALIGNED_FAST); | |||
} | |||
|
|||
#if defined(TARGET_ZTSO) && TARGET_ZTSO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If someone compiles with "CXXFLAGS=-marchrv64....ztso..", we need to try to parse the supplied flags, that doesn't seem like fun.
Instead I suggest we add code to read-out the elf flags, i.e:
"Flags: 0x15, RVC, double-float ABI, TSO"
And set UseZtso:
A: If this is a TSO elf.
B: If hwprobe says this TSO hardware (either directly or via vendor).
C: If someone set flag,
I guess your idea was to have a flag like --enable-tso which sets TARGET_TSO ?
If we have that or not I still like above to happen.
(I'm not saying you should do any of this in this PR, I can file new ones)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TARGET_TSO
is set by gcc directly. See https://www.mail-archive.com/gcc-patches@gcc.gnu.org/msg281514.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, it is not set by LLVM what I can see at least (running a couple of weeks old tip).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@luhenry This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 40 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
Maybe this way:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM !
@@ -210,6 +210,14 @@ void VM_Version::initialize() { | |||
unaligned_access.value() == MISALIGNED_FAST); | |||
} | |||
|
|||
#ifdef __riscv_ztso |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I ask where is this __riscv_ztso
macro defined / specified? I tried to search it in the gcc user manual [1] and gcc source code, but I found nothing about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, I don't find docs in the compilers for this either, but:
https://github.com/riscv-non-isa/riscv-toolchain-conventions#cc-preprocessor-definitions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We checked for it with this simple snippet. You can see that in both cases, it returns 0
which implies TSO is enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I think I have found its definition in gcc source code [1]. It's strange that this is not mentioned in [2].
[1] https://github.com/llvm/llvm-project/blob/523c471250a49b5603bd907ff05535f18ef61c91/clang/lib/Basic/Targets/RISCV.cpp#L160C5-L162C77
[2] https://github.com/riscv-non-isa/riscv-toolchain-conventions#cc-preprocessor-definitions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Any tests performed?
@RealFYang I've tested with jcstress on QEMU on x86 with the change and with an obvious breakage (not emitting barriers at all). It would fail when not emitting barriers at all (makes sense, x86 is not a sequential consistency memory model) and it would succeed with this patch (also makes sense given x86 is a TSO). It's obviously lacking testing on an actual hardware that supports TSO and RVWMO, but I'm not aware of any on the market at the moment. We (Rivos) will make sure to test as soon as we have our hardware available, and we'll report back. |
/integrate |
Going to push as commit 35bccac.
Your commit was automatically rebased without conflicts. |
With the Ztso extension [1], some hardware will support TSO on RISC-V. That allows us to reduce the generation of memory fences, given the stronger memory model compared to RVWMO.
[1] https://github.com/riscv/riscv-isa-manual/blob/6dcbc6da9ada01f0f57da83cda6059bdec57619f/src/ztso-st-ext.adoc#L1
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/15613/head:pull/15613
$ git checkout pull/15613
Update a local copy of the PR:
$ git checkout pull/15613
$ git pull https://git.openjdk.org/jdk.git pull/15613/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 15613
View PR using the GUI difftool:
$ git pr show -t 15613
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/15613.diff
Webrev
Link to Webrev Comment