1 / 18

Chapter 3 Instruction-Level Parallelism and Its Dynamic Exploitation – Concepts

EEF011 Computer Architecture 計算機結構. Chapter 3 Instruction-Level Parallelism and Its Dynamic Exploitation – Concepts. 吳俊興 高雄大學資訊工程學系 October 2004. Chapter Overview. 3.1 Instruction Level Parallelism: Concepts and Challenges 3.2 Overcoming Data Hazards with Dynamic Scheduling

marcin
Download Presentation

Chapter 3 Instruction-Level Parallelism and Its Dynamic Exploitation – Concepts

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EEF011 Computer Architecture計算機結構 Chapter 3Instruction-Level Parallelism and Its Dynamic Exploitation –Concepts 吳俊興 高雄大學資訊工程學系 October 2004

  2. Chapter Overview 3.1 Instruction Level Parallelism: Concepts and Challenges 3.2 Overcoming Data Hazards with Dynamic Scheduling 3.3 Dynamic Scheduling: Examples & the Algorithm 3.4 Reducing Branch Costs with Dynamic Hardware Prediction 3.5 High Performance Instruction Delivery 3.6 Taking Advantage of More ILP with Multiple Issue 3.7 Hardware-based Speculation 3.8 Studies of the Limitations of ILP 3.9 Limitations on ILP for Realizable Processors 3.10 The P6 Microarchitecture

  3. 3.1 Instruction-Level Parallelism (ILP) • ILP: potential overlap of execution among instructions • chapter 3: dynamic, largely depend on the hardware • chapter 4: static, rely more on software (compilers) • ILP is the principle that there are many instructions in code that don’t depend on each other so it’s possible to execute those instructions in parallel • Building compilers to analyze the code • Building hardware to be even smarter than that code

  4. Pipelining and Stalls Pipeline CPI = Ideal pipeline CPI + Structural stalls + Data hazard stalls + Control stalls • Ideal pipeline CPI: measure of the maximum performance attainable by the implementation • Structural hazards: HW cannot support this combination of instructions • Data hazards: Instruction depends on result of prior instruction still in the pipeline • Control hazards: Caused by delay between the fetching of instructions and decisions about changes in control flow (branches and jumps)

  5. Ideas To Reduce Stalls Chapter 3 Chapter 4

  6. ILP Terminology Basic Block (BB) ILP is quite small • BB: a straight-line code sequence with no branches in except to the entry and no branches out except at the exit (only one entry and one exit) • average dynamic branch frequency 15% to 25% => 4 to 7 instructions execute between a pair of branches • Plus instructions in BB likely to depend on each other To obtain substantial performance enhancements, we must exploit ILP across multiple basic blocks • Simplest: loop-level parallelism to exploit parallelism among iterations of a loop • Loop Level Parallelism - that parallelism that exists within a loop. Such parallelism can cross loop iterations. • Loop Unrolling - Either the compiler or the hardware is able to exploit the parallelism inherent in the loop for (i = 0; i<=1000; i=i+1) x[i] = x[i] + y[i]; • Vector is another way • A vector instruction operates on a sequence of data items • If not vector, then either dynamic via branch prediction or static via loop unrolling by compiler

  7. I: add r1,r2,r3 J: sub r4,r1,r3 Instruction Level Parallelism Data Dependence and Hazards • If two instructions are parallel, they can execute simultaneously in a pipeline without causing any stalls • If two instructions are dependent, they must be executed in order, though they may often be partially overlapped • Three types of dependences: data dependences (true data dependences), name dependences, and control dependences • An instruction j is data dependent on instruction i if either of the following holds • instruction i produces a result that may be used by instruction j • instruction j is data dependent on instruction k, and instruction k is data dependent on instruction i (chain of dependences) InstrJ is data dependent on InstrIInstrJ tries to read operand before InstrI writes it or InstrJ is data dependent on InstrK which is dependent on InstrI Caused by a “TrueDependence” (compiler term) If true dependence caused a hazard in the pipeline, called a Read After Write (RAW) hazard

  8. Instruction Level Parallelism Data Dependence and Hazards • Dependences are a property of programs • Presence of dependence indicates potential for a hazard, but actual hazard and length of any stall is a property of the pipeline • Importance of the data dependencies 1) indicates the possibility of a hazard 2) determines order in which results must be calculated 3) sets an upper bound on how much parallelism can possibly be exploited • Chapter 3 looks mainly at HW schemes to avoid hazard

  9. I: sub r4,r1,r3 J: add r1,r2,r3 K: mul r6,r1,r7 Instruction Level Parallelism Name Dependence #1: Anti-dependence • Name dependence: when 2 instructions • use same register or memory location, called a name, • but no flow of data between the instructions associated with that name; • 2 versions of name dependence • InstrJ writes operand before InstrI reads itCalled an “anti-dependence” by compiler writers.This results from reuse of the name “r1” • If anti-dependence caused a hazard in the pipeline, called a Write After Read (WAR) hazard

  10. I: sub r1,r4,r3 J: add r1,r2,r3 K: mul r6,r1,r7 Instruction Level Parallelism Name Dependence #2: Output dependence • InstrJ writes operand before InstrI writes it. • Called an “output dependence” by compiler writersThis also results from the reuse of name “r1” • If output-dependence caused a hazard in the pipeline, called a Write After Write (WAW) hazard

  11. Instruction Level Parallelism ILP and Data Hazards • HW/SW must preserve program order: order instructions would execute in if executed sequentially 1 at a time as determined by original source program • HW/SW goal: exploit parallelism by preserving program order only where it affects the outcome of the program • Instructions involved in a name dependence can execute simultaneously or be reordered,if name used in instructions is changed so instructions do not conflict • Register renaming resolves name dependence for regs • Either statically by compiler or dynamically by HW

  12. Instruction Level Parallelism Control Dependencies • Every instruction is control dependent on some set of branches, and, in general, these control dependencies must be preserved to preserve program order if p1 { S1; }; if p2 { S2; } • S1 is control dependent on p1, and S2 is control dependent on p2 but not on p1.

  13. Instruction Level Parallelism Control Dependence Ignored • Control dependence need notbe preserved • willing to execute instructions that should not have been executed, thereby violating the control dependences, if can do so without affecting correctness of the program • Instead, 2 properties critical to program correctness are exception behavior and data flow

  14. Instruction Level Parallelism Exception Behavior • Preserving exception behavior => any changes in instruction execution order must not change how exceptions are raised in program (=> no new exceptions) • Example: DADDU R2,R3,R4 BEQZ R2,L1 LW R1,0(R2)L1: • Problem with moving LW before BEQZ?

  15. Instruction Level Parallelism Data Flow • Data flow: actual flow of data values among instructions that produce results and those that consume them • branches make flow dynamic, determine which instruction is supplier of data • Example: DADDU R1,R2,R3 BEQZ R4, L DSUBU R1,R5,R6L: … OR R7,R1,R8 R1 depends on DADDU and DSUBU instructions • OR depends on DADDU or DSUBU? Must preserve data flow on execution

  16. 3.2 Dynamic Scheduling Advantages ofDynamic Scheduling • Handles cases when dependences unknown at compile time • (e.g., because they may involve a memory reference) • The hardware rearranges the instruction execution to reduce the stalls while maintaining data flow and exception behavior • It simplifies the compiler • Allows code that compiled for one pipeline to run efficiently on a different pipeline • Hardware speculation (Section 3.7), a technique with significant performance advantages, that builds on dynamic scheduling

  17. Classic 5-stages Pipeline for MIPS

  18. The idea: Dynamic Scheduling HW Schemes: Instruction Parallelism • Why is this in Hardware at run time? • Works when can’t know real dependence at compile time • Compiler simpler • Code for one machine runs well on another • Key Idea: Allow instructions behind stall to proceed. • Key Idea: Instructions executing in parallel. There are multiple execution units, so use them. DIVD F0,F2,F4 ADDD F10,F0,F8 SUBD F12,F8,F14 • Enables out-of-order execution => out-of-order completion Even though ADDD stalls, the SUBD has no dependencies and can run.

More Related