Skip to main content

Mojo struct

AddressSpace

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, Equatable, ImplicitlyCopyable, ImplicitlyDestructible, Intable, Movable, RegisterPassable, TrivialRegisterPassable, Writable

comptime members

BUFFER_RESOURCE

comptime BUFFER_RESOURCE = AddressSpace(8)

Buffer resource GPU memory address space (AMD-specific).

CONSTANT

comptime CONSTANT = AddressSpace(4)

Constant GPU memory address space (read-only).

GENERIC

comptime GENERIC = AddressSpace.GENERIC

Generic address space. Used for CPU memory and default GPU memory.

GLOBAL

comptime GLOBAL = AddressSpace(1)

Global GPU memory address space.

LOCAL

comptime LOCAL = AddressSpace(5)

Local GPU memory address space (per thread, private).

SHARED

comptime SHARED = AddressSpace(3)

Shared GPU memory address space (per thread block/workgroup).

SHARED_CLUSTER

comptime 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.

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.

write_to

write_to(self, mut writer: T)

Formats the address space to the provided Writer.

Args:

  • writer (T): The object to write to.

write_repr_to

write_repr_to(self, mut writer: T)

Write the string representation of the AddressSpace.

Args:

  • writer (T): The object to write to.

Was this page helpful?