chapter five
5 Higher-dimensional kernels
This chapter covers
- Row-major and column-major memory layout, strides, and memory coalescing
- Writing and optimizing a matrix transpose kernel using shared memory tiling
- Building aligned and boundary-safe tiled matrix products
- Reaching Tensor Core matrix instructions through
tl.dot - Applying grouped L2 ordering, autotuning, correctness tests, and roofline analysis
If you were asked to name the main components of any modern deep learning architecture, you would most likely say the attention mechanism, or a linear layer. Linear layers and attention projections express their main calculation as matrix multiplication. Many convolution implementations reduce their work to matrix multiplication, while softmax, normalization, and activation kernels retain different arithmetic and memory-access patterns. Matrix multiplication therefore provides a practical route from multidimensional indexing to the specialized matrix hardware in a current GPU.