IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
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

MMASmemDescriptor

struct MMASmemDescriptor

Descriptor for shared memory operands tcgen05 mma instructions.

This struct represents a descriptor that encodes information about shared memory layout and access patterns for warp group matrix multiply operations. The descriptor contains the following bit fields:

Bit fieldSizeDescription
0-1314Base address in shared memory
16-2914LBO: leading dim byte offset
32-4514SBO: stride dim byte offset
46-483Fixed constant value: 0b001
49-513Matrix base offset, 0 for canonical layouts
521Leading dimension stride mode:
ย ย 0: byte offset relative
ย ย 1: byte address absolute
(only used for 48B K tile)
53-608Fixed constant value: 0
61-633Swizzle mode:
ย ย 0: No swizzling
ย ย 1: 128-Byte with 32B atomic swizzling
ย ย 2: 128-Byte swizzling
ย ย 4: 64-Byte swizzling
ย ย 6: 32-Byte swizzling

Note:

  • Some bits are unused.
  • Base address, LBO, and SBO ignore 4 least significant bits.

See https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#tcgen05-shared-memory-desc-layout

Fieldsโ€‹

  • โ€‹desc (UInt64): The 64-bit descriptor encodes shared memory operand information.

Implemented traitsโ€‹

AnyType, Copyable, ImplicitlyCopyable, ImplicitlyDeletable, MMAOperandDescriptor, Movable, RegisterPassable, TrivialRegisterPassable

comptime membersโ€‹

mask_14_bitsโ€‹

comptime mask_14_bits = Int(16383)

Mask with the lower 14 bits set.

Methodsโ€‹

__init__โ€‹

def __init__(val: UInt64) -> Self

Initialize descriptor with raw 64-bit value.

This constructor allows creating a descriptor directly from a 64-bit integer that already contains the properly formatted bit fields for the descriptor.

The implicit attribute enables automatic conversion from UInt64 to MMASmemDescriptor.

Args:

  • โ€‹val (UInt64): A 64-bit integer containing the complete descriptor bit layout.

__add__โ€‹

def __add__(self, offset: Int) -> Self

Add offset to descriptor's base address.

Args:

  • โ€‹offset (Int): Byte offset to add to base address.

Returns:

Self: New descriptor with updated base address.

__iadd__โ€‹

def __iadd__(mut self, offset: Int)

Add offset to descriptor's base address in-place.

Args:

  • โ€‹offset (Int): Byte offset to add to base address.

createโ€‹

static def create[stride_byte_offset: Int, leading_byte_offset: Int, swizzle_mode: TensorMapSwizzle = TensorMapSwizzle.SWIZZLE_NONE](smem_ptr: Pointer[address_space=AddressSpace.SHARED, _safe=True]) -> Self

Create a descriptor for shared memory operand.

Parameters:

  • โ€‹stride_byte_offset (Int): Stride dimension offset in bytes.
  • โ€‹leading_byte_offset (Int): Leading dimension stride in bytes.
  • โ€‹swizzle_mode (TensorMapSwizzle): Memory access pattern mode.

Args:

Returns:

Self: Initialized descriptor for the shared memory operand.