Docsity

Exploiting ILP Through Software Approaches - Slides | EEC 270, Assignments of Computer Architecture and Organization

Toggle sidebar
bg1
Page ‹#›
Chapter 4 – VLIW
Exploiting ILP through Software
Approaches
Venkatesh Akella
EEC 270
Winter 2005
Based on Slides from Prof. Al. Davis @
cs.utah.edu
Chapter 4 – VLIW
Let the Compiler Do it – Pros and Cons
•Pros
–No window size limitation, the whole program is there to see
–Hardware is simple, so can push the clock rate
–Pragmas and profile information can be used
•Cons
–Binary code compatibility
–Basic blocks are small – global code optimization is might hard
–Lack of run-time knowledge – eg: memory dataflow problems
•Perhaps a mixture of the two?
Chapter 4 – VLIW
Overview of the Chapter
•Basic Compiler Techniques for Exposing ILP
–Loop Unrolling
–Instruction Scheduling
•Static Branch Prediction
•Static Multiple Issue: VLIW Approach
Chapter 4 – VLIW
Overview of the Chapter
•Advanced Compiler Support for Exposing and
Exploiting ILP
–Detecting and Enhancing Loop-Level Parallelism
–Dependence Analysis
–Software Pipelining
–Global Code Scheduling
•Hardware Support for Exposing More
Parallelism at Compile Time
–Predicated Execution
–Compiler Speculation with HW Support
•CASE STUDY : ITANIUM PROCESSOR
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Exploiting ILP Through Software Approaches - Slides | EEC 270 and more Assignments Computer Architecture and Organization in PDF only on Docsity!

Chapter 4 – VLIW

Exploiting ILP through Software

Approaches

Venkatesh Akella

EEC 270

Winter 2005

Based on Slides from Prof. Al. Davis @

cs.utah.edu

Chapter 4 – VLIW

Let the Compiler Do it – Pros and Cons

  • Pros
    • No window size limitation, the whole program is there to see
    • Hardware is simple, so can push the clock rate
    • Pragmas and profile information can be used
  • Cons
    • Binary code compatibility
    • Basic blocks are small – global code optimization is might hard
    • Lack of run-time knowledge – eg: memory dataflow problems
  • Perhaps a mixture of the two? Chapter 4 – VLIW

Overview of the Chapter

  • Basic Compiler Techniques for Exposing ILP
    • Loop Unrolling
    • Instruction Scheduling
  • Static Branch Prediction
  • Static Multiple Issue: VLIW Approach Chapter 4 – VLIW

Overview of the Chapter

  • Advanced Compiler Support for Exposing and

Exploiting ILP

  • Detecting and Enhancing Loop-Level Parallelism
  • Dependence Analysis
  • Software Pipelining
  • Global Code Scheduling
  • Hardware Support for Exposing More

Parallelism at Compile Time

  • Predicated Execution
  • Compiler Speculation with HW Support
  • CASE STUDY : ITANIUM PROCESSOR

Chapter 4 – VLIW

Overview of Software Approaches

Chapter 4 – VLIW

Assumptions for the Examples

Chapter 4 – VLIW

A Simple Loop

Chapter 4 – VLIW

Scheduling the Instructions to

minimize Stalls

Chapter 4 – VLIW

How does unrolling help interact with

dependencies

Chapter 4 – VLIW

Static Branch Prediction

  • Static branch behavior is useful for scheduling instructions when the branch delays are exposed by the architecture (eg: delayed branches or canceling branches)
  • They can also be used to predict which code paths are more plausible which is key for global code optimization
  • Predict Taken or Not Taken – poor accuracy from 9% to 59% misprediction rates
  • Backward taken and forward not-taken, context based prediction
  • Profile information from earlier runs Chapter 4 – VLIW

Misprediction Rate of Profile-based

predictor on SpEC

  • Better for FP programs than integer program
  • Actual performance varies depends on prediction accuracy and branch frequency which varies from 3% to 24% Chapter 4 – VLIW

Number of instructions between

mispredicted branches (log scale)

  • Average = 20 for predict-taken and 110 for profile-based
  • Compare this to 4-5 instructions between a branch without prediction
  • The variation is due to the nature of the program and the branch frequency

Chapter 4 – VLIW

VLIW Processors

  • Suitable for wide issue. N>4 when superscalar

becomes unwieldy

  • Assume VLIW with 2 mem references, 2 FP ops, 1

integer/br unit

  • Show do all x[I] = x[I] + s
  • Unroll as many times as needed to eliminate all stalls Chapter 4 – VLIW

Unrolled 7 times

Sd F28, 8(r1) Bne r1, r2, loop SD F20, 24(r1) SD F12, -16(r1) Daddui 56 R1, r1, - SD F4, 0(r1) Add f28, f26, f Add f20, f18, f2 Add f24, f22, f LD F26, -48(r1) Add f12, f10, f2 Add f16, f14, f LD F18, -32(r1) LD F22, -40(r1) Add F4, F0, F2 Add f8, f6, f LD F10, -16(r1) LD F14, -24(r1) LD F0, 0(R1) LD F6, -8(r1) Mem Ref1 Mem Ref2 FP OP1 FP OP2 Integer Chapter 4 – VLIW

Performance

  • 9 cycles for 7 iterations
  • Note anything smaller in terms of unrolling will result in empty cycles
  • 1.29 cycles per result
  • Increases code size - unrolling + packing density in cache is poor ( empty slots)
  • Compression and Encoding is possible
  • Register pressure
  • Lockstep execution is not efficient - any stall in pipeline causes all instructions to stall
  • If you relax this requirement, hw has to do some checking
  • Lack of binary compatibility » Dynamic Binary Translation or Emulation » New approaches such as IA64 relaxes the strictness
  • VLIW permits simpler/standard memory such as

caches as opposed to a Vector Processor

Chapter 4 – VLIW

Compiler Techniques to Expose ILP

  • ECS 243 EEC175 classes dedicated to this topic
  • What can the compiler do?

a) Detecting and Enhancing Loop Level Parallelism

b) Source Level Optimizations

c) Eliminating Dependent Computation

a) Copy propagation b) Symbolic Substitution c) Tree Height Reduction d) Algebraic Simplification

d) Software Pipelining -

e) Global Scheduling

Chapter 4 – VLIW

Software Pipelining

  • Symbolic Loop Unrolling
  • Loop unrolling is good for uncovering parallelism among instructions by creating longer sequences of st. line code - increasing the window size
  • Eg: repeat (n) [A;B;C] is replaced by repeat (n/2) [A1; B1; C1; A2; B2; C2] Reorder instructions to avoid hazards, hence expose ILP - code size increases, some branches are eliminated Software pipelining is different - it involves reorganizing a loop with instructions from different iterations: A; (repeat (n-1) [BCA]) B; C B, C, A are instructions from DIFFERENT iterations of the loop Chapter 4 – VLIW

Software Pipelining

A; (repeat (n-1) [BCA]) B; C Prolog New Loop Epilog B, C, A are instructions from DIFFERENT iterations of the loop

This does in SW what Tomasulo’s algorithm did in

HW - interleaving instructions from different

iterations of a loop and executing them in parallel

Prolog and Epilog code is to make sure that the same

code is executed in both the cases I.e. semantics

of the program are not altered.

Chapter 4 – VLIW

A Concrete Example

Loop:LD F0, 0(R1) ADD F4, F4, F SD F4, 0(R1) DADDUI R1, R1, - BNE R1, R2, LOOP

LD F0, 0(R1)

STALL

ADD F4, F0, F LD F0, -8(R1) DADDUI R1, R1, - Loop:SD F4, 16(R1) -- stores M[I] ADD F4, F0, F2 --- adds M[I-1] LD F0, 0(R1) ---- loads M[I-2] DADDUI R1, R1, - STALL BNE R1, R2, LOOP STALL ADD F4, F4, F SD F4, 8(R1) STALL STALL SD F4, 8(R1)

EPILOG

PREAMBLE

Instructions not executed In the final 2 iterations Chapter 4 – VLIW

Loop Unrolling vs SW Pipelining

  • SW is symbolic so does not increase the code

size.

  • Does not increase register pressure, however

register management is tricky - lifetimes of

registers values can be long

  • Loop unrolling and SW pipelining attack different

problems so in general they can be combined

  • LU - reduces loop overhead I.e. branch and

counter update

  • SWP - reduces the time when the loop is not

running at its peak

Chapter 4 – VLIW

Figuratively Speaking

Chapter 4 – VLIW

Going Beyond Basic Blocks

What are the consequences of moving instruction K before the branch? Instr J is dependent on K instead of P If branch is not taken C[I] will get wrong value -- Add compensating code -- keep copy of B Welcome to Speculation!! Static Approaches to speculation: a) Global Scheduling: Trace Scheduling, Superblocks b) Predicated Execution Loop Body a[I] = a[I] + b[I]; If (a(I)==0) B[I] = XXX Else X; C[I] = YYY; J: reads B J: reads B P: write B k: write B Chapter 4 – VLIW

Global Scheduling - Fisher 1984

  • Going Beyond BASIC BLOCKS
  • Exploit Parallelism ACROSS BB I.e. inter BB parallelism as opposed to INTRA BB parallelism with Loop Unroll and SWP
  • Useful when there is no support for predication and loop unrolling doesn’t help because of conditional branches inside the loop body
  • Pick a trace - a sequence of basic blocks (called trace) that is executed frequently
  • Trace Selection can be done by profiling
  • Loop unrolling and static branch prediction can be used
  • Trace Compaction - Squeeze the trace into a small number of VLIW instructions by moving instructions as early as possible
    • packing with constraints
  • Add Compensation Code for paths that will be taken if the prediction is wrong Chapter 4 – VLIW

Predicated Execution -A Form of Speculation

  • Works when static branch prediction is poor
  • Wide issue m/c when multiple branches have to be resolved
  • ILP is limited due to control dependencies
  • Convert control dependency into data dependency - predicated/cond instr
  • This helps both hw based scheduling and SW pipelining and global scheduling
  • Every instruction refers to a cond.
  • If the condition is TRUE execute the instruction

normally, if it is FALSE it becomes a NOP

Chapter 4 – VLIW

Third Scheme to Preserve Exception Behavior

LD R1, 0(R3) -- load A LD R14, 0(R2) -- speculative Load B BEQZ R1, L DADDI R14, R1, 4 L3: SD R14, 0(R3) R14 has a poison bit, which is turned on when LD in BLUE I.e. spec LD causes an exception When non speculative SD in GREEN tries to read R14, it will cause an EXCEPTION Note an extra bit in an instruction is needed to signify is it a normal instr or a speculative instruction. This is set by the compiler