6.2.9 · D1 · HinglishGPU Architecture

FoundationsBank conflicts in shared memory

1,807 words8 min read↑ Read in English

6.2.9 · D1 · Hardware › GPU Architecture › Bank conflicts in shared memory

Is sawaal ka jawab dene se pehle tumhare paas kuch words aur symbols hone chahiye. Parent note mein warp, bank, word, stride, mod, gcd, aur [r][c] addressing aise use hote hain jaise tum pehle se jaante ho. Yeh page inhe ek-ek karke, ek order mein build karta hai jahaan har piece pichle pe tikaa ho.


1. Ek thread, aur unka ek warp of 32

Woh number jo ek thread ko batata hai "main kaun hoon" threadIdx.x likha jaata hai. Agar tumhare paas 32 threads hain, toh threadIdx.x tak jaata hai. Hum is number ko poore note mein bulayenge.

Figure — Bank conflicts in shared memory

2. Bytes, words, aur kyun hum addresses ko 4 se divide karte hain

Byte-address ko word-number mein convert karne ke liye 4 se divide karo aur remainder phenk do:

Woh marks floor symbol hain — "ek whole number pe round down karo." Humein iska zaroorat hai kyunki addresses 0, 1, 2, 3 sab ko word 0 pe collapse karna hai.

Figure — Bank conflicts in shared memory

3. mod operation — woh clock jo banks ko repeat karti hai

Picture ek clock face hai. Ek clock karta hai: 12 ke baad wrap karke 0 pe aa jaata hai. Bank assignment karta hai: word 31 ke baad bank 0 pe wrap ho jaata hai.

Figure — Bank conflicts in shared memory

4. Stride — mere threads kitni door tak pahunchte hain

Toh thread word read karta hai, aur isliye bank mein land karta hai

Yeh akela line is poore topic ki engine hai. Parent note jo bhi compute karta hai woh is line mein specific plug karke hai.


5. GCD — woh tool jo collision count predict karta hai

Woh payoff formula jo parent use karta hai:

  • Coprime stride (): map saare 32 banks hit karta hai — ek permutation, perfectly conflict-free. (Isliye odd-stride .x field access safe hai.)
  • : sirf distinct banks use hote hain, toh threads ek ko share karte hain — ek -way conflict.

6. [r][c] addressing — 2-D array ek number kaise banta hai

Isliye ek column read karna (matrix[i][col], row vary karte hue) ka stride hota hai: yeh worst case hai jab , aur pad karne se safe ho jaata hai (kyunki , row-step ko bank-space mein wapas friendly stride of 1 bana deta hai).


Prerequisite map

Thread and threadIdx

Warp of 32 threads

Byte

4-byte word

Bank index = word mod 32

mod 32 wrap-around

Stride s and bank of thread i

gcd predicts conflict degree

Row-major r times C plus c

Bank conflicts in shared memory


Yeh aage kahan jaate hain

  • Banks ek wider 6.2.07-Shared-memory-architecture picture ke andar rehte hain.
  • Global memory mein wahi "different lanes at once" idea 6.2.08-Memory-coalescing hai.
  • Column-walk conflict 6.3.01-Matrix-transpose-optimization ka star villain hai.
  • Kitna shared memory afford kar sakte ho yeh 6.2.10-Occupancy-and-resource-limits se juda hai.
  • Threads ka lockstep mein kaam karna 6.2.11-Warp-divergence ke neeche bhi hai.
  • Parent pe wapas jaao: is topic ka Hinglish version.

Equipment checklist

Daayein taraf dhako aur reveal karne se pehle out loud jawab do.

Ek thread hai
ek worker jo apne data pe same code run karta hai, threadIdx.x se identify hota hai.
Ek warp hai
32 threads ka ek bundle jo lockstep mein execute karta hai aur apne memory requests simultaneously fire karta hai.
Ek byte-address vs ek word
byte ek numbered slot hai; ek 4-byte word chaar bytes ek float/int mein jode hue hain.
Byte-address ko 4 se kyun divide karte hain
ise word-index mein convert karne ke liye, kyunki banks 4 bytes wide hain aur sirf words ki care karte hain.
ka matlab hai
ko se divide karne ke baad remainder; yeh clock ki tarah wrap karta hai, mein land karta hai.
Master bank formula
.
Stride kya measure karta hai
thread aur thread ke beech words mein gap; thread bank ko hit karta hai.
hai
woh sabse bada whole number jo aur dono ko divide karta hai; conflict degree ke barabar hota hai.
Coprime strides kyun safe hain
agar toh map ek permutation hai jo saare 32 banks hit karta hai.
matrix[r][c] ka word address (row-major, columns)
; ek column walk ka stride hota hai.
ko 32 se 33 pad karna kyun kaam karta hai
, toh har row-step ek bank shift karta hai instead of collide karne ke.