trace scheduling

33
Trace Scheduling By Stefan M. Freudenberger Encyclopedia Of Parallel Computing Bekket McClane @ Advanced Programming Language Jenq-Kuen Lee, NTHU CS, 2016 Spring

Upload: min-yih-hsu

Post on 12-Apr-2017

173 views

Category:

Engineering


2 download

TRANSCRIPT

Trace SchedulingBy Stefan M. Freudenberger

Encyclopedia Of Parallel Computing

Bekket McClane @ Advanced Programming Language Jenq-Kuen Lee, NTHU CS, 2016 Spring

SYLLABUS• Instruction Scheduling Recap

• Trace Formation

• Scheduling

• Code Motion

• Compensation Code

• Summary

Why Instruction Scheduling

Cooper, Keith, and Linda Torczon. Engineering a compiler. Elsevier, 2011. P.644

In Muti Issues Processors…

• Help resolving dependencies of instructions

• More operations running at the same time. Smarter scheduling algorithm is needed.

Local vs Global Scheduling - Local

• Boundary is usually within one basic block

• Pros: Easy to implement

• Cons: Instruction count is too small to apply some optimizations

Local vs Global Scheduling - Global

• Boundary across several basic blocks

• E.g. Extended Basic Blocks, Trace

• Pros: Larger region brings more optimization opportunities

• Cons: Take times determining best scheduling region

BB

BB

BB

Single Entry

Single Exit

BB

BB

BB

(Single Entry)

Multi Exits

Extended Basic Blocks Trace

Allow Enter After

First Instruction

Trace Formation

A

F

E

DC

B

Pick the “hottest” operation

A

F

E

DC

B

Looking both predecessors and

successors direction

A

F

E

DC

B

If encounter branches Pick the mutually most-likely one

10 90 55

A

F

E

DC

B

Stop when no mutually most-likely successor

or reaching max length

Trace Scheduling

Recap: Data Dependency

• Read After Write (RAW) • Write After Read (WAR) • Write After Write (WAW)

Control Dependency• Split Dependency: Prevent operations

from moving below the exit of a BB

• Join Dependency: Prevent operations from moving above the entry of a BB

BB

BB BB BB

BB BB

?

?

Join Dependency Split Dependency

Acyclic Graph: Optimizations Love Linear

Code Motions

•Speculation •Prediction

BC

A

Speculative Code Motion

9010

More likely

B

A

Speculative Code Motion

C

Move above the branch point

BC

A

Prediction

5050 Equally likely

D E

B’

A

Prediction

B’ = B+C

D E

Compensation Code

•Split Compensation •Join Compensation •Mix Compensation

Split Compensation

A, B switched

Copy of A

Join Compensation

A, B switched

Copy of B

Mix Compensation

Suppression of Compensation

Aka. No need to insert compensation code in some situations

E.g. After loop unrolling

SUMMARY• Bigger regions have advantages over single

basic blocks in instruction scheduling

• Can use branch related code motions to construct better trace regions

• Need compensation codes to fix program semantics

IN SHORT…

• Avoiding Branch • Bigger Region,

Better Optimization

Q&A

THANK YOU