Log inStart free
LESSON 27.11 · 5 STAGES · 2 CONTROLS · 3 CHECKSPRO · PREVIEW

Shared-memory bank conflicts

Watch 32 threads queue at one bank, then spread out.


Pro lesson. Stage 1 is free to watch. Pro opens all 5 stages, 2 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 27.11 · KERNEL BAYSTRIDE 16 WORDS · PAD 0 B
01
Stage 1 of 5 · The banks
Shared memory has 32 banks of 4 bytes. One row of A fills 16 banks, so two rows share one line.
Explain it simply

Think of the 32 banks as 32 checkout lanes, each one 4 bytes wide. A word goes to bank number word mod 32, so the words wrap around the banks line by line. Each row is 16 words long, so two rows share a line, and every second row starts at bank 0.

A grid of 32 bank columns holds the FP16 tile of A: 16 words per row, 0 of them padding.

A tile (weights)B values, memory timeconflict, extra cyclesmath time, speedpadding word
012345678910111213141516171819202122232425262728293031FP16: 2 B per value, 2 per word16 words per row → stride 16row i starts at word 16·i16 lines of 32 wordspadding: 0 Bthe tile of A in 32 banksbank numberbank = word mod 32 · stride 16 words012345678910111213141516171819202122232425262728293031FP16: 2 B per value, 2 per word16 words per row → stride 16row i starts at word 16·i16 lines of 32 wordspadding: 0 Bthe tile of A in 32 banksbank numberbank = word mod 32 · stride 16 words
Toy: the 27.C2 GEMM, a 32 × 32 tile of A, 32 banks of 4 bytes
STAGE 1 / 5
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
bank=word(i,c) mod 32\text{bank} = \text{word}(\sy{i}{param}{i}, \sy{c}{param}{c}) \bmod 32
row 1, word 0: word 16, bank 16 mod 32=16\text{row }1\text{, word }0:\ \text{word } 16,\ \text{bank } 16 \bmod 32 = 16

The bank is the number of the word for row i, column c, mod 32.

Common mix-ups

MYTHTwo threads that use one bank always conflict.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01With FP32 and the plain layout, how many cycles does the column read take?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 5
Unlock the full explainer
  • 4 more stages and 2 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.