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

matmul_kernel

def matmul_kernel[c_type: DType, a_type: DType, b_type: DType, tile_size: Int, s_type: DType = get_accum_type[c_type]()](c_ptr: MutPointer[Scalar[c_type], MutAnyOrigin], a_ptr: ImmPointer[Scalar[a_type], ImmutAnyOrigin], b_ptr: ImmPointer[Scalar[b_type], ImmutAnyOrigin], m_dev: Int32, n_dev: Int32, k_dev: Int32)

Matrix Multiplication using shared memory. This version loads blocks of size tile_size x tile_size from A and B and updates a tile_size x tile_size in C. The thread block should have shape (tile_size, tile_size, 1). Each thread is mapped one element in C. The grid should have shape (N/tile_size, M/tile_size, 1). N is the first dimension for coalesced access.

Parameters:

  • ​c_type (DType): DType of the output matrix C elements.
  • ​a_type (DType): DType of the input matrix A elements.
  • ​b_type (DType): DType of the input matrix B elements.
  • ​tile_size (Int): Side length, in elements, of the square shared-memory tile loaded from A and B and written to C.
  • ​s_type (DType): DType used for the inner accumulation (defaults to the accumulator type for c_type).

Args:

Was this page helpful?