6.2.5 · D1 · HinglishGPU Architecture

FoundationsWarps and warp scheduling

2,087 words9 min read↑ Read in English

6.2.5 · D1 · Hardware › GPU Architecture › Warps and warp scheduling

Yeh page kuch bhi assume nahi karta. Warps and warp scheduling ko theek se padhne se pehle, hum har word, symbol, aur picture build karenge jis par woh tika hua hai. Upar se neeche padho; har block agla earn karta hai.


0. Yahan "thread" kya hai?

Warps se pehle, hume woh atom chahiye jisse woh bante hain.

Threads kabhi akele nahi rehte. Woh containers ke ek nested set mein aate hain, jise hum aage draw karte hain.

  • Grid ek launch ke liye threads ki poori fauj hai.
  • Block grid ke andar ek team hai — usi block ke threads fast shared memory ke zariye baat kar sakte hain.
  • Warp sabse chota squad hai jo hardware actually move karta hai: 32 threads ek saath glued.

Yeh nesting bilkul Thread-Blocks-and-Grids ka subject hai; yahan hume sirf boxes dekhne ki zarurat hai.


1. threadIdx — thread ka name tag

blockDim — block kitna bada hai?


2. Flattening: name tag se line position tak

Hardware saare threads ko single-file line mein lagata hai. Us line mein thread ki jagah dhundhne ke liye hum block ko row by row padhte hain (pehle x fastest, phir y, phir z). Ise row-major order kehte hain.

Picture kyun row-major matter karta hai yeh dikhati hai: yeh decide karta hai ki kaun se threads ek hi warp mein jaate hain. Ek single warp 32 consecutive line positions ka ek slice hota hai — toh ek warp do rows ki boundary cross kar sakta hai.


3. Number 32, floor, aur ceiling

Ab hum warp ko arithmetically define kar sakte hain.

Do naye symbols aaye. Inse milte hain:


4. Lockstep, SIMT, aur mask

Lekin branches hote hain — kabhi kabhi kuch threads ko ek instruction skip karni chahiye. Hardware ise ek mask se handle karta hai.


5. Stalls, cycles, aur latency hiding


6. Occupancy — readiness meter

Do symbols ise support karte hain:

  • SM (Streaming Multiprocessor): GPU par ek physical engine jo kaafi warps rakhta hai aur schedulers contain karta hai. Ise ek factory floor samjho; poore GPU mein kaafi hote hain.
  • Warp scheduler: ek SM ke andar traffic controller jo har cycle ek ready warp pick karke issue karta hai.

Occupancy ko free mein 1 tak push kyun nahi kiya ja sakta: har warp registers (Register-Pressure) aur shared memory claim karta hai. Zyada warps → har warp ke liye kam. Woh trade-off in foundations se real tuning story ka bridge hai.


Prerequisite map

Thread one worker one index

threadIdx and blockDim coordinates

Linear index row-major flatten

Floor and ceiling rounding

Warp 32 consecutive threads

Lockstep and SIMT

Active mask on-off switches

Warp divergence serial replay

Cycle clock tick

Latency L waiting

Stall no progress

Latency hiding swap warps

Occupancy fullness meter

Warps and warp scheduling


Equipment checklist

Self-test: right side cover karo aur aage padhne se pehle har ek ka jawab zor se bolo.

Thread kya hota hai, ek sentence mein?
Ek worker jo apne data slice par program ki ek copy run karta hai.
threadIdx aur blockDim kya describe karte hain?
Thread ka coordinate label, aur block ke har axis par kitne threads hain.
Thread (3,2,0) ko (16,4,1) block mein flatten karo.
.
kya karta hai, aur kya karta hai?
Floor round down karta hai; ceiling round up karta hai.
Kaun sa thread ka warp ID deta hai, aur kaun sa warp count?
Floor warp ID deta hai; ceiling warps ki number deta hai.
136 threads ke block ke liye kitne warps?
.
"Lockstep / SIMT" ka matlab kya hai?
Saare 32 threads same clock tick par same instruction chalate hain, har ek ke apne data ke saath.
Active mask kya hai?
Ek 32-bit on/off switch jo decide karta hai ki kaun se threads current instruction par act karte hain.
Divergence slow kyun hai?
Dono branches ek ke baad ek opposite masks ke saath chalte hain, kyunki ek warp ek time par sirf ek instruction chalata hai.
Stall kya hai, aur ise kaise chhupaate hain?
Ek warp jo aage nahi badh sakta; ek doosra ready warp free mein swap in kiya jaata hai khali cycles fill karne ke liye.
Latency ko instructions ke saath hide karne ke liye warps ki formula do.
.
Occupancy define karo.
Active warps per SM divided by max warps per SM.