liveBook · Manning

Block pointer

As explained in GPU Programming with Triton

A block pointer is a Triton descriptor containing a tensor’s base address, shape, strides, block shape, and offsets for accessing a tensor region.

A block pointer is a structured descriptor for a rectangular region of a tensor. It records the base address, parent shape and strides, starting offsets, block shape, and dimension order. section 5.6.2

Creating one does not access memory. Loads and stores perform the actual reads and writes; boundary checks can handle tiles that cross tensor edges. section 5.6.2 section 5.4.3

Use tl.advance to update a descriptor’s logical position:

  • Supply one element-offset value per tensor dimension; positive and negative values move the descriptor forward or backward. section 5.6.3
  • Advancement updates coordinates but neither loads data nor checks bounds; a later load can check the updated coordinates. section 5.6.3

Tiled matrix multiplication

Descriptors select matching A and B tiles along the shared K dimension. Advancing A by (0, BLOCK_K) and B by (BLOCK_K, 0) selects the next pair of slices for tl.dot. section 5.6.3

a_block_ptr = tl.make_block_ptr(
    base=a_ptr,
    shape=(M, K),
    strides=(stride_am, stride_ak),
    offsets=(pid_m * BLOCK_M, 0),
    block_shape=(BLOCK_M, BLOCK_K),
    order=(1, 0),
)
b_block_ptr = tl.make_block_ptr(
    base=b_ptr,
    shape=(K, N),
    strides=(stride_bk, stride_bn),
    offsets=(0, pid_n * BLOCK_N),
    block_shape=(BLOCK_K, BLOCK_N),
    order=(1, 0),
)

See how base addresses, shapes, strides, offsets, block shapes, and dimension order define matrix tiles. section 5.6.2

How GPU Programming with Triton covers it

How deep it goes
Defines descriptor fields and coordinate advancement, then applies them to tiled matrix multiplication and transpose without prescribing target-specific lowering.
Examples
Uses A and B tiles in tiled matrix multiplication and input and output tiles in a boundary-checked transpose.
What it assumes
Uses tensor shapes, strides, offsets, and block shapes as descriptor inputs; no broader prerequisite is stated.
What you can do after
Build it from scratch by defining descriptors and advancing matched K tiles through tiled matrix multiplication.
How it connects
Connects Triton tile descriptors to tl.load, tl.store, tl.advance, matrix multiplication, tensor transpose, and boundary checking.

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.