liveBook · Manning

Tile shape

As explained in GPU Programming with Triton

Tile shape specifies the dimensional arrangement of elements in a tile.

In tiled matrix multiplication, tile shape sets the dimensions of each program’s work. BLOCK_M × BLOCK_N defines its output tile; BLOCK_K sets the width of each slice accumulated along K. These choices determine which values are loaded together and reused on-chip. section 5.0 section 5.5.4

Tile dimensions affect both implementation and performance:

  • Square output tiles balance reuse between A and B; rectangular tiles may run faster for a particular matrix shape or GPU. section 5.5.4
  • Each program accumulates its output tile across K-slices. The initial kernel assumes dimensions divide evenly by the tile sizes; a later version handles incomplete edge tiles and K remainders. section 5.5.5 section 5.10
  • Autotuning can compare tile shapes alongside warp counts and software-pipeline stages. section 5.10
Figure 5.12 Tiled matrix multiplication for the 4 × 4 numerical example. Program (0, 0) owns C 00. It multiplies A 00 by B 00 for the first K slice, carries the resulting accumulator into the second slice, and adds A 01B 10 before storing C 00. Programs (0, 1), (1, 0), and (1, 1) perform the same K-loop pattern independently for the other output tiles.
CH05 F12 Fartale

Trace how four programs each own an output tile and update its accumulator across the two K-slices of a 4 × 4 product. section 5.5.4

How GPU Programming with Triton covers it

How deep it goes
Defines BLOCK_M, BLOCK_N, and BLOCK_K through pointer tiles, register accumulators, K-loop updates, and output writes; the first kernel assumes divisible dimensions.
Examples
Compares square and rectangular output tiles and traces a 4 × 4 product across four programs.
What you can do after
Build it from scratch by assigning output tiles to programs and accumulating successive K-slices with tl.dot.
How it connects
Connects matrix multiplication, memory reuse, arithmetic intensity, and autotuning.

Also explained in

Compare how 2 books explain tile shape →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of GPU Programming with Triton. The section links point to the parts of the book it draws on.