All topics

xGeMM

Writing single-precision matrix multiplication from scratch in CUDA, one optimisation at a time, until it gets close to cuBLAS.

7 parts, about 45 minutes of readingCode on GitHub

Matrix multiplication sits at the heart of almost every neural network, and NVIDIA’s cuBLAS does it extremely fast. It starts from a naive CUDA kernel and closes the gap step by step: global memory coalescing, shared memory tiling, 1D and 2D thread coarsening with registers, and vectorised memory access. Each chapter explains the hardware idea first, then the code, then the benchmark.

  1. 0
    xGeMM: GPU Accelerated Matrix Multiplication (almost) like cuBLAS

    Programming general matrix multiplication from scratch in CUDA.

    8 min read

  2. 1
    xGeMM Chapter 1: Getting Started with CUDA Programming

    A simple introduction explaining how to get started with CUDA.

    9 min read

  3. 2
    xGeMM Chapter 2: GPU Global Memory Coalescing

    Explaining memory coalescing in GPUs.

    11 min read

  4. 3
    xGeMM Chapter 3: GPU Shared Memory

    Explaining shared memory in GPUs.

    8 min read

  5. 4
    xGeMM Chapter 4: 1D Thread Coarsening using GPU Registers

    Explaining 1D thread coarsening using GPU registers.

    5 min read

  6. 5
    xGeMM Chapter 5: 2D Thread Coarsening using GPU Registers

    Explaining 2D thread coarsening using GPU registers.

    4 min read

  7. 6
    xGeMM Chapter 6: Vectorized Memory Accesses

    Explaining vectorized memory accesses in GPUs.

    2 min read