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 function

wmma_cdna

def wmma_cdna[*, a_reuse: Bool = False, b_reuse: Bool = False](mut d: SIMD, a: SIMD, b: SIMD, c: SIMD)

Computes one CDNA5 WMMA, d = a * b + c, with the given reuse hints.

The instruction is picked from the dtypes and lane widths of the operands, the same way the generic mma picks it. Every combination below is one v_wmma instruction whose A and B operands live in registers, so the fragments are the per-lane slices of the 16x16 output tile.

Supported combinations, as (A, B, C, D dtypes, lane widths of A/B/C/D):

  • (float8_e4m3fn or float8_e5m2 for A and B, float16 or float32 for C and D, 32/32/8/8), 16x16x64. A and B pair freely, giving the fp8.fp8, fp8.bf8, bf8.fp8 and bf8.bf8 instruction forms.
  • The same four pairings and accumulators at 64/64/8/8, 16x16x128.
  • (float16, float16, float16 or float32, 16/16/8/8) and (bfloat16, bfloat16, bfloat16 or float32, 16/16/8/8), 16x16x32.
  • (bfloat16, bfloat16, float32, bfloat16, 16/16/8/8), 16x16x32: the mixed form whose f32 accumulator becomes a bf16 result.
  • (float32, float32, float32, 2/2/8/8), 16x16x4.

Constraints:

  • Requires CDNA5 (gfx1250) or newer; the call fails to compile elsewhere.
  • The lane widths of A, B, C and D must match the instruction shape for their dtypes, as listed above.
  • A set reuse hint asserts that this WMMA reads the same A (or B) registers as the WMMA immediately before it in the final instruction order. The compiler may reorder WMMAs, so a caller must only set a hint where that order is guaranteed.

Parameters:

  • ​a_reuse (Bool): Hint that this WMMA reads the same A registers as the WMMA immediately before it in the final instruction order, which lets the matrix core skip reloading them.
  • ​b_reuse (Bool): The same hint for the B registers.

Args:

  • ​d (SIMD): The destination fragment, overwritten with the result.
  • ​a (SIMD): The A fragment.
  • ​b (SIMD): The B fragment.
  • ​c (SIMD): The accumulator fragment.

Was this page helpful?