LeetKernels

Get fast at GPU kernels.

Solve CUDA, Triton and PyTorch problems on your own NVIDIA GPU, then profile your kernels to see why they're slow.

  1. Connect your GPU
  2. Solve a problem
  3. Profile your kernel
Matrix MultiplicationEasyCUDA
__global__ void matmul(const float* A, const float* B,                       float* C, int M, int N, int K) {    int row = blockIdx.y * blockDim.y + threadIdx.y;    int col = blockIdx.x * blockDim.x + threadIdx.x;    if (row < M && col < K) {        float sum = 0.0f;        for (int i = 0; i < N; i++)            sum += A[row * N + i] * B[i * K + col];        C[row * K + col] = sum;    }}

Accepted1.88 s

14 of 14 tests passed. Median of 15 runs on a GeForce GTX 1650.

Latency bound, compute 60% and memory 60% of peak.

The shaded loop has 100% of stalls, mostly waiting on the global memory queue.

Use fewer, wider loads (float4), or reuse data from shared memory.