add riscv64 CPU compatibility#257
Open
Xeonacid wants to merge 1 commit into
Open
Conversation
Add a riscv64 branch that uses the Zihintpause pause instruction when the target enables it, otherwise falls back to a nop that is valid for the baseline ISA. Read the Linux device-tree timebase-frequency value from procfs or sysfs as the counter frequency, and use rdtime for timestamps so both helpers use the RISC-V time counter units.
tzcnt
reviewed
Jun 20, 2026
| } | ||
| } | ||
| } | ||
| __builtin_unreachable(); |
Owner
There was a problem hiding this comment.
Please add a fallback return value if this is not available. This value is used for heuristics only as described on line 78, so please choose a reasonable value for a RISC-V chip that supports multi-core / multi-thread.
Owner
There was a problem hiding this comment.
Additionally, I think this needs an #ifdef __linux__ check. If not defined, we should also return a fallback.
| #include <atomic> | ||
| #include <cstddef> | ||
| #include <cstdint> | ||
| #include <cstdio> |
Owner
There was a problem hiding this comment.
Please move this include inside of the #if defined(__riscv) block. This header is included almost everywhere in the project, so I try to keep it as slim as possible.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a riscv64 branch that uses the Zihintpause pause instruction when the target enables it, otherwise falls back to a nop that is valid for the baseline ISA.
Read the Linux device-tree timebase-frequency value from procfs or sysfs as the counter frequency, and use rdtime for timestamps so both helpers use the RISC-V time counter units.