Skip to main content
Log in

Mojo struct

Scope

struct Scope

Represents memory synchronization scope levels for GPU memory operations.

This struct 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 are ordered within a thread block/CTA.
  • CLUSTER = Scope(4): Cluster-level scope. Memory operations are 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 are ordered across the entire system.

Implemented traits

AnyType, CollectionElement, Copyable, EqualityComparable, EqualityComparableCollectionElement, ExplicitlyCopyable, Movable, UnknownDestructibility

Methods

__eq__

__eq__(self, other: Self) -> Bool

__ne__

__ne__(self, other: Self) -> Bool

__is__

__is__(self, other: Self) -> Bool

__isnot__

__isnot__(self, other: Self) -> Bool

mnemonic

mnemonic(self) -> StringLiteral

Returns the mnemonic string representation of the memory scope.

This method converts the memory scope level into a string mnemonic used by LLVM/NVVM intrinsics for memory operations.

Returns:

A string literal containing the mnemonic.