[llvm] [NVPTX] Add Volta Atomic SequentiallyConsistent Load and Store Operations (PR #98551)
Artem Belevich via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 5 11:08:38 PDT 2024
================
@@ -106,15 +107,30 @@ enum LoadStore {
isStoreShift = 6
};
-namespace PTXLdStInstCode {
-enum MemorySemantic {
+// Extends LLVM AtomicOrdering with PTX Orderings:
+using OrderingUnderlyingType = unsigned int;
+enum Ordering : OrderingUnderlyingType {
NotAtomic = 0, // PTX calls these: "Weak"
- Volatile = 1,
+ // Unordered = 1, // NVPTX maps LLVM Unorderd to Relaxed
Relaxed = 2,
- Acquire = 3,
- Release = 4,
- RelaxedMMIO = 5
+ // Consume = 3, // Unimplemented in LLVM; NVPTX would map to "Acquire"
+ Acquire = 4,
+ Release = 5,
+ // AcquireRelease = 6, // TODO
+ SequentiallyConsistent = 7,
+ Volatile = 8,
+ RelaxedMMIO = 9,
+ LAST = RelaxedMMIO
};
+// Values match LLVM AtomicOrdering for common orderings:
+static_assert(Ordering::NotAtomic == (unsigned)AtomicOrdering::NotAtomic);
+static_assert(Ordering::Relaxed == (unsigned)AtomicOrdering::Monotonic);
+static_assert(Ordering::Acquire == (unsigned)AtomicOrdering::Acquire);
+static_assert(Ordering::Release == (unsigned)AtomicOrdering::Release);
+static_assert(Ordering::SequentiallyConsistent ==
+ (unsigned)AtomicOrdering::SequentiallyConsistent);
----------------
Artem-B wrote:
Yeah, something like that. On a second thought, it's probably an overkill. While matching numeric values to AtomicOrdering is a convenience, it's not necessary. We're not extending AtomicOrdering, but, rather, defining an new ordering with some overlap with AtomicOrdering.
How important in practice is it to have the matching numeric values?
Perhaps what we need is a set of ordering values, w/o any attempt to inherit from AtomicOrdering, or comments that we map some values to something else, and, if needed, an explicit mapping function between AtomicOrdering and NVPTX ordering.
https://github.com/llvm/llvm-project/pull/98551
More information about the llvm-commits
mailing list