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,
Equatable,
ImplicitlyCopyable,
ImplicitlyDestructible,
Movable,
RegisterPassable,
TrivialRegisterPassable,
Writable
comptime members
ACQUIRE
comptime ACQUIRE = Consistency(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(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(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(0)
Weakest consistency model with minimal ordering guarantees.
Provides maximum flexibility for hardware/compiler optimizations but requires careful synchronization by the programmer.
Methods
__eq__
__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
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
write_repr_to(self, mut writer: T)
Writes a string representation of the consistency level.
Args:
- writer (
T): The object to write to.
mnemonic
mnemonic(self) -> StaticString
Returns the mnemonic string for the consistency level.
Returns:
StaticString: A string literal containing the consistency level mnemonic.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!