Mojo struct
AddressSpace
@register_passable(trivial)
struct AddressSpace
Address space of the pointer.
This type represents memory address spaces for both CPU and GPU targets. On CPUs, typically only GENERIC is used. On GPUs (NVIDIA/AMD), various address spaces provide access to different memory regions with different performance characteristics.
Implemented traits
AnyType,
Copyable,
EqualityComparable,
Identifiable,
ImplicitlyCopyable,
Intable,
Movable,
Stringable,
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
CONSTANT
alias CONSTANT = AddressSpace(4)
Constant GPU memory address space (read-only).
GENERIC
alias GENERIC = AddressSpace(0)
Generic address space. Used for CPU memory and default GPU memory.
GLOBAL
alias GLOBAL = AddressSpace(1)
Global GPU memory address space.
LOCAL
alias LOCAL = AddressSpace(5)
Local GPU memory address space (per thread, private).
SHARED
alias SHARED = AddressSpace(3)
Shared GPU memory address space (per thread block/workgroup).
SHARED_CLUSTER
alias SHARED_CLUSTER = AddressSpace(7)
Shared cluster GPU memory address space (NVIDIA-specific).
Methods
__init__
__init__(value: Int) -> Self
Initializes the address space from the underlying integral value.
Args:
- value (Int): The address space value.
__eq__
__eq__(self, other: Self) -> Bool
Checks if the two address spaces are equal.
Args:
- other (Self): The other address space value.
Returns:
Bool: True if the two address spaces are equal and False otherwise.
__is__
__is__(self, other: Self) -> Bool
Checks if the two address spaces are equal.
Args:
- other (Self): The other address space value.
Returns:
Bool: True if the two address spaces are not equal and False otherwise.
__isnot__
__isnot__(self, other: Self) -> Bool
Checks if the two address spaces are not equal.
Args:
- other (Self): The other address space value.
Returns:
Bool: True if the two address spaces are not equal and False otherwise.
value
value(self) -> Int
The integral value of the address space.
Returns:
Int: The integral value of the address space.
__int__
__int__(self) -> Int
The integral value of the address space.
Returns:
Int: The integral value of the address space.
__str__
__str__(self) -> String
Gets a string representation of the AddressSpace.
Returns:
String: The string representation of the AddressSpace.
write_to
write_to(self, mut writer: T)
Formats the address space to the provided Writer.
Args:
- writer (T): The object to write to.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!
