Mojo struct
Scope
struct Scope
Represents memory synchronization scope levels for GPU memory operations.
Defines different scopes of memory visibility and synchronization, from thread-local to system-wide. Each scope level determines how memory operations are ordered and visible across different execution units.
The scope levels form a hierarchy, with each higher level providing stronger ordering guarantees but potentially higher synchronization costs.
Implemented traits
AnyType
,
EqualityComparable
,
ExplicitlyCopyable
,
ImplicitlyCopyable
,
Movable
,
UnknownDestructibility
,
Writable
Aliases
__copyinit__is_trivial
alias __copyinit__is_trivial = True
__del__is_trivial
alias __del__is_trivial = True
__moveinit__is_trivial
alias __moveinit__is_trivial = True
BLOCK
alias BLOCK = Scope(3)
Block-level scope. Memory operations ordered within a thread block/CTA.
CLUSTER
alias CLUSTER = Scope(4)
Cluster-level scope. Memory operations ordered within a thread block cluster.
GPU
alias GPU = Scope(5)
GPU-level scope. Memory operations are ordered across all threads on the GPU.
NONE
alias NONE = Scope(0)
No memory ordering guarantees. Operations may be reordered freely.
SYSTEM
alias SYSTEM = Scope(6)
System-wide scope. Memory operations ordered across the entire system.
THREAD
alias THREAD = Scope(1)
Thread-level scope. Memory operations are ordered within a single thread.
WARP
alias WARP = Scope(2)
Warp-level scope. Memory operations are ordered within a warp of threads.
Methods
__eq__
__eq__(self, other: Self) -> Bool
Checks if two Scope
instances are equal.
Uses pointer comparison for efficiency.
Args:
- other (
Self
): The otherScope
instance to compare with.
Returns:
Bool
: True if the instances are the same, False otherwise.
__is__
__is__(self, other: Self) -> Bool
Checks if two Scope
instances have the same value.
Compares the underlying integer values.
Args:
- other (
Self
): The otherScope
instance to compare with.
Returns:
Bool
: True if the values are the same, False otherwise.
__isnot__
__isnot__(self, other: Self) -> Bool
Checks if two Scope
instances have different values.
Args:
- other (
Self
): The otherScope
instance to compare with.
Returns:
Bool
: True if the values are different, False otherwise.
write_to
write_to(self, mut w: T)
Writes the string representation of the scope to a writer.
Args:
- w (
T
): The writer to write to.
__str__
__str__(self) -> String
Returns the string representation of the memory scope.
Returns:
String
: A string representation of the memory scope.
__repr__
__repr__(self) -> String
Returns the string representation of the memory scope.
Returns:
String
: A string representation of the memory scope.
mnemonic
mnemonic(self) -> StringSlice[StaticConstantOrigin]
Returns the mnemonic string representation of the memory scope.
Converts the memory scope level into a string mnemonic used by LLVM/NVVM intrinsics for memory operations.
Returns:
StringSlice
: A string literal containing the mnemonic.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!