For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo struct
Consistency
struct Consistency
Represents memory consistency models for GPU memory operations.
This struct defines different memory consistency levels that control how memory operations are ordered and synchronized between threads. The consistency model affects both performance and correctness of parallel algorithms.
Implemented traitsβ
AnyType,
Copyable,
Deinitable,
Equatable,
ImplicitlyCopyable,
Movable,
RegisterPassable,
TrivialRegisterPassable,
Writable
comptime membersβ
ACQUIREβ
comptime ACQUIRE = Consistency(Int(2))
Acquire consistency for synchronization operations.
Ensures all subsequent memory operations are ordered after this operation. Used in producer-consumer patterns.
RELAXEDβ
comptime RELAXED = Consistency(Int(1))
Relaxed consistency with basic ordering guarantees.
Provides some ordering guarantees while still allowing optimizations. Suitable for operations that don't require strict ordering.
RELEASEβ
comptime RELEASE = Consistency(Int(3))
Release consistency for synchronization operations.
Ensures all previous memory operations are ordered before this operation. Paired with acquire operations for synchronization.
WEAKβ
comptime WEAK = Consistency(Int(0))
Weakest consistency model with minimal ordering guarantees.
Provides maximum flexibility for hardware/compiler optimizations but requires careful synchronization by the programmer.
Methodsβ
__eq__β
def __eq__(self, other: Self) -> Bool
Tests if two Consistency instances are equal.
Args:
- βother (
Self): The Consistency instance to compare against.
Returns:
Bool: True if the consistency levels are equal, False otherwise.
write_toβ
def write_to(self, mut writer: T)
Writes a string representation of the consistency level.
Args:
- βwriter (
T): The object to write to.
write_repr_toβ
def write_repr_to(self, mut writer: T)
Writes a string representation of the consistency level.
Args:
- βwriter (
T): The object to write to.
mnemonicβ
def mnemonic(self) -> StaticString
Returns the mnemonic string for the consistency level.
Returns:
StaticString: A string literal containing the consistency level mnemonic.