Superscalar execution
5.3.1· Hardware › Advanced Microarchitecture
Ek Processor ko Superscalar Kya Banata Hai?
Width Parameter
Issue width N determine karta hai ki ek cycle mein kitne instructions dispatch ho sakte hain. Common values:
- 2-way superscalar: 2 instructions/cycle (purana Intel Pentium)
- 4-way superscalar: 4 instructions/cycle (Intel Core)
- 6-8 way superscalar: Modern high-performance cores (Intel Skylake, AMD Zen)
Superscalar Execution Kaise Kaam Karta Hai: Pipeline Stages
1. Instruction Fetch (Width N)
Kya hota hai: Ek cycle mein cache se N instructions fetch karo.
Yeh mushkil kyun hai: Instruction stream hamesha achhi tarah aligned nahi hoti. Agar tumhe 4 instructions fetch karni hain lekin woh ek cache-line boundary ke across hain, toh tumhe do cache accesses chahiye ho sakte hain.
Kaise solve hota hai:
- Wide instruction cache ports
- Branch predictors jo aage multiple branches predict karte hain
- Fetched instructions queue karne ke liye instruction buffers
2. Decode (Width N)
Kya hota hai: N instructions ko simultaneously micro-ops mein decode karo.
Yeh mushkil kyun hai: x86 instructions ki length variable hoti hai (1-15 bytes). Parallel mein multiple instructions ke liye instruction boundaries dhundhna complex hai.
Kaise solve hota hai:
- Cache lines mein pre-decode bits add karna
- Pehli kuch positions ke liye complex decoders
- Baaki positions ke liye simpler decoders
- Modern designs mein micro-op cache (decoded instruction cache)
3. Rename and Dispatch
Kya hota hai: False dependencies eliminate karne ke liye architectural registers ko physical registers mein rename karo, phir reservation stations mein dispatch karo.
Yeh kis problem ko solve karta hai:
ADD R1, R2, R3 ; R1 = R2 + R3
MUL R4, R1, R5 ; R4 = R1 * R5 (needs R1, has RAW dependency)
ADD R1, R6, R7 ; R1 = R6 + R7 (WAW hazard with first instruction)
SUB R8, R1, R9 ; R8 = R1 - R9 (which R1? WAR hazard)
Rename solution:
ADD P10, P2, P3 ; Rename R1 → P10
MUL P11, P10, P5 ; Uses P10, can execute when P10 ready
ADD P12, P6, P7 ; Rename R1 → P12 (different physical register!)
SUB P13, P12, P9 ; Uses P12, no confusion
Ab instructions 1 aur 3 mein false dependency nahi hai—woh alag physical registers mein likhte hain.
4. Issue (Out-of-Order)
Kya hota hai: Instructions reservation stations mein wait karti hain jab tak unke operands ready nahi ho jaate, phir execution units ko issue hoti hain.
Key insight: Instructions program order mein issue nahi hoti. Woh tab issue hoti hain jab:
- Functional unit available ho
- Saare source operands ready hon
- Koi structural hazard na ho
Yahi out-of-order execution hai.
5. Execute (Multiple Units)
Kya hota hai: Multiple functional units parallel mein instructions execute karte hain.
Ek typical superscalar mein ho sakta hai:
- 4 integer ALUs
- 2 load/store units (AGU + data port)
- 2 floating-point units
- 1 branch unit
Throughput vs Latency:
- Integer ADD: 1 cycle latency, 4/cycle throughput (4 units)
- Integer MUL: 3 cycle latency, 1/cycle throughput (1 unit)
- FP DIV: 20 cycle latency, 1/20 cycle throughput (1 unit, not pipelined)
6. Retire (In-Order, Width N)
Kya hota hai: Reorder buffer (ROB) ensure karta hai ki instructions apne results program order mein commit karein, precise exceptions maintain karte hue.
In-order retirement kyun: Agar exception aata hai, toh faulting instruction se pehle ki saari instructions complete honi chahiye, aur baad wali instructions ka koi visible effect nahi hona chahiye.
Derivation: Maximum IPC
Chaliye theoretical maximum instructions per cycle (IPC) derive karte hain.
Diya gaya:
- Issue width:
- Functional units ki sankhya: type ke
- Instruction mix: fraction ko unit type chahiye
- Average instruction latency:
Step 1: Maximum fetch/decode rate = instructions/cycle
Step 2: Dependencies ki wajah se maximum issue rate limited hoti hai. Perfect register renaming aur infinite ROB ke saath, yeh limited hoti hai:
Step 3: Functional unit throughput: Type ke units ke saath:
Step 4: Instruction mix ko consider karte hue overall throughput: Agar fraction instructions ko unit type chahiye:
Yeh step kyun?: Agar 50% instructions load/store hain () aur tumhare paas 2 load/store units hain (), toh memory operations tumhe maximum IPC tak limit karti hain.
Step 5: Dependency limit. Agar average dependency chain length hai aur latency hai:
Final formula:
Superscalar ke liye Critical Structures
Reorder Buffer (ROB)
Kya hai: Circular buffer jo in-flight instructions ko program order mein track karta hai.
Kyun: Out-of-order execution ko in-order retirement ke saath enable karta hai (precise exceptions).
Kaise: Har ROB entry mein hota hai:
- Instruction ka PC
- Destination register (logical)
- Result value ya physical register ka pointer
- Status (pending/complete)
- Exception flags
Size matters:
Bada ROB → independent kaam dhundhne ke liye zyada instructions → higher IPC, lekin zyada complex hardware.
Register Alias Table (RAT)
Kya hai: Architectural registers ko physical registers mein map karta hai.
Size: architectural registers aur physical registers ke liye:
- RAT entries: (har architectural register ke liye ek)
- Har entry: bits
Kyun: WAW aur WAR hazards eliminate karta hai, zyada parallelism enable karta hai.
Example: x86-64 mein 16 integer registers hain. Ek modern design mein 180 physical registers ho sakte hain.
Reservation Stations
Kya hain: Buffers jo operands ka wait kar rahi instructions ko hold karte hain.
Kyun: Instruction issue ko execution se decouple karte hain, instructions ko dispatch block kiye bina wait karne dete hain.
Key property: Instructions tab wake up hoti hain jab unka last operand ready ho jaata hai (associative search).
Limitations aur Tradeoffs
Recall Superscalar ko 12-Saal ke Bachche ko Explain Karo
Socho tum homework kar rahe ho. Tumhare paas kaafi problems solve karni hain: math problems, reading comprehension, aur ek picture banana.
Normal computer (scalar): Tumhare paas ek desk hai. Tum ek waqt mein ek problem karte ho. Math problem → reading → drawing → agli math problem. Agla shuru karne se pehle pehla khatam karna padta hai.
Pipelined computer: Tum phir bhi ek waqt mein ek karte ho, lekin jaise hi math problem padhna khatam karo, pehla solve karte waqt agla padh sakte ho. Jaise assembly line.
Superscalar computer: Ab tumhare paas TEEN desks aur tumhare teen copies hain! Ek math kar sakta hai, ek padh sakta hai, aur ek draw kar sakta hai—sab ek saath! Lekin ek catch hai: agar drawing ko math problem ka answer chahiye, toh wait karna padega. Saath hi, tumhare paas sirf ek pencil sharpener hai, toh agar teeno ko pencil sharpen karni hai, do ko wait karna padega.
Yahi superscalar hai: ek saath multiple cheezein karna, lekin tabhi jab woh ek doosre par depend na karti hon aur tumhare paas sabke liye enough tools hon.
Connections
- Instruction-Level Parallelism: Superscalar ILP exploit karne ki primary technique hai
- Register Renaming: False dependencies eliminate karne ke liye essential hai
- Out-of-Order Execution: Superscalar processors typically OoO execute karte hain
- Branch Prediction: Pipeline ko instructions se feed rakhne ke liye critical hai
- Tomasulo's Algorithm: Superscalar ke liye classic dynamic scheduling algorithm
- Reorder Buffer: Out-of-order superscalar mein precise exceptions maintain karta hai
- VLIW Architecture: Alternative approach jahan compiler instruction scheduling karta hai
- Cache Hierarchy: Multiple memory ops/cycle ke liye sufficient bandwidth provide karna zaroori hai
- Power-Performance Tradeoffs: Wider superscalar matlab zyada power consumption
#flashcards/hardware
Superscalar processor kya hota hai? :: Ek processor jo ek hi clock cycle mein multiple functional units aur dynamic scheduling use karke multiple instructions simultaneously fetch, decode, aur execute kar sakta hai.
Data dependencies ke teen types kya hain?
Register renaming false dependencies kaise eliminate karta hai?
Reorder Buffer (ROB) ka purpose kya hai?
Superscalar processors mein in-order retirement kyun zaroori hai?
Superscalar processor ki IPC kya limit karta hai?
Superscalar processor ki issue width kya hoti hai?
Reservation stations out-of-order execution kaise enable karte hain? :: Woh operands ka wait kar rahi instructions ko buffer karte hain aur unhe functional units ko tab issue karte hain jab operands ready ho jaate hain aur units available hoti hain, dispatch ko execution se decouple karke.