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.
Aliases
NONE = Scope(0)
: No memory ordering guarantees. Operations may be reordered freely.THREAD = Scope(1)
: Thread-level scope. Memory operations are ordered within a single thread.WARP = Scope(2)
: Warp-level scope. Memory operations are ordered within a warp of threads.BLOCK = Scope(3)
: Block-level scope. Memory operations ordered within a thread block/CTA.CLUSTER = Scope(4)
: Cluster-level scope. Memory operations ordered within a thread block cluster.GPU = Scope(5)
: GPU-level scope. Memory operations are ordered across all threads on the GPU.SYSTEM = Scope(6)
: System-wide scope. Memory operations ordered across the entire system.
Implemented traits
AnyType
,
CollectionElement
,
Copyable
,
EqualityComparable
,
EqualityComparableCollectionElement
,
ExplicitlyCopyable
,
Movable
,
UnknownDestructibility
,
Writable
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:
True if the instances are the same, False otherwise.
__ne__
__ne__(self, other: Self) -> Bool
Checks if two Scope
instances are not equal.
Args:
- other (
Self
): The otherScope
instance to compare with.
Returns:
True if the instances are different, 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:
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:
True if the values are different, False otherwise.
write_to
write_to[W: Writer](self, mut w: W)
Writes the string representation of the scope to a writer.
Parameters:
- W (
Writer
): The type of writer to use for output. Must implement the Writer interface.
Args:
- w (
W
): The writer to write to.
__str__
__str__(self) -> String
Returns the string representation of the memory scope.
Returns:
A string representation of the memory scope.
__repr__
__repr__(self) -> String
Returns the string representation of the memory scope.
Returns:
A string representation of the memory scope.
mnemonic
mnemonic(self) -> StringLiteral
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:
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!