software pipelining and register pressure in vliw architectures: … · 2011-09-12 · fundamental...

20
Software Pipelining and Register Pressure in VLIW Architectures: Preconditionning Data Dependence Graphs is Experimentally Better than Lifetime-Sensitive Scheduling Fr´ ed´ eric Brault, Benoˆ ıt Dupont-de-Dinechin, Sid-Ahmed-Ali Touati, Albert Cohen ODES 2010 1 / 20

Upload: others

Post on 29-Jul-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Software Pipelining and Register Pressure in VLIW Architectures: … · 2011-09-12 · Fundamental principle: Theorem [Touati2001] Let G be a loop DDG. Let G0the extended DDG of G

Software Pipelining and Register Pressure inVLIW Architectures: Preconditionning DataDependence Graphs is Experimentally Better

than Lifetime-Sensitive Scheduling

Frederic Brault, Benoıt Dupont-de-Dinechin,Sid-Ahmed-Ali Touati, Albert Cohen

ODES 2010

1 / 20

Page 2: Software Pipelining and Register Pressure in VLIW Architectures: … · 2011-09-12 · Fundamental principle: Theorem [Touati2001] Let G be a loop DDG. Let G0the extended DDG of G

An old debate about an open question

Phase ordering problem:instruction scheduling before/after register allocation?

Highlighted in the 80’s for sequential code, with register minimisation

Wealth of heuristics for acyclic scheduling

What about cyclic scheduling?

2 / 20

Page 3: Software Pipelining and Register Pressure in VLIW Architectures: … · 2011-09-12 · Fundamental principle: Theorem [Touati2001] Let G be a loop DDG. Let G0the extended DDG of G

Related work

Software pipelining under resource constraints only→ register pressure often goes out of control

Software pipelining under resource and register constraints→ to spill or to increase the II – that is the question

Post-pass cyclic register allocation→ necessary: modulo expansion (unrolling) and register assignment

3 / 20

Page 4: Software Pipelining and Register Pressure in VLIW Architectures: … · 2011-09-12 · Fundamental principle: Theorem [Touati2001] Let G be a loop DDG. Let G0the extended DDG of G

Our strategy for VLIW

1 Decoupling register pressure control from instruction scheduling→ better compiler engineering→ focus scheduling on the core objectives (II, hiding memory latency)

2 Handling register constraints before scheduled resource constraints→ Memory operations have unknown static latencies→ Imprecisescheduling and WCET analysis

3 Avoid spilling instead of scheduling spill code while taking care of II→ Memory operations consume more power

4 / 20

Page 5: Software Pipelining and Register Pressure in VLIW Architectures: … · 2011-09-12 · Fundamental principle: Theorem [Touati2001] Let G be a loop DDG. Let G0the extended DDG of G

The target platform

ST231 processor

4-issue VLIW processor at 400 MHz

64 general purpose 32-bit registers (GR)

8 1-bit condition registers (BR)

1 LSU, 1 BCU, 4 ALU and 1 MAU functional units

32 KB 4-way Dcache, 32 KB direct-mapped Icache

Toolchain: ST200cc with LAO

Front-end compiler based on Open64

At -O3 optimization level, the LAO backend component performsVLIW software pipelining

Post-pass register allocation in ST200cc

5 / 20

Page 6: Software Pipelining and Register Pressure in VLIW Architectures: … · 2011-09-12 · Fundamental principle: Theorem [Touati2001] Let G be a loop DDG. Let G0the extended DDG of G

SIRA: an example

(1,0)

(3,2)(3, 1)

(1,1)(2,0)

(1,2)

(0,4)

(0,6)(0,3)

(0,3)

(b) Reuse Graphs for Register Types t1 and t2

(c) DDG with Killing Nodes (d) Preconditioned DDG after Applying SIRA

(0,0)

(0,−2) (0,−1)

(0,−1)

(0,0)(0,−2)

=4 =3=2

=6=3

(a) Initial DDG

(0,2)

u3 u4u4

u2

u4u3

u1 u2

Register type t1 Register type t2

u1 u1u2

u3 u1

u4u3

u1

ku1t2

ku4t2

u2

ku2t2

ku1t1 ku3

t1

ku1t2

ku2t2

ku4t2

µu1,u1

µu2,u4µu4,u2

µu1,u3 µu3,u1

ku3t1

ku1t1

Eµ = {(kut , v)|(u, v) ∈ Ereuse,t}V k = {kut |u ∈ V R,t}Ek = {(v, kut)|v ∈ Cons(ut)}

6 / 20

Page 7: Software Pipelining and Register Pressure in VLIW Architectures: … · 2011-09-12 · Fundamental principle: Theorem [Touati2001] Let G be a loop DDG. Let G0the extended DDG of G

Comparing SIRA vs. existing work

Unique features of SIRAI Optimise for multiple register types simultaneously or one after anotherI Model (read and write) delays in accessing registersI Model register banks, buffers or rotating register files.I Register pressure guarantee independent of the scheduling algorithmI Correctness proofs for the model and algorithmsI Reproducible results: standalone C library (SIRAlib), distributed with

experimental data

Validation of the effectiveness of SIRA in a production compilerI Compiler construction: simplifies scheduling/allocation orderingI Software engineering: SIRA as an independent C library plugable in any

compilerI Reproducibility: the source code is publicly released (LGPL)I Effectiveness: already published for standalone DDG, experimental

results of this talk for an integrated context.

7 / 20

Page 8: Software Pipelining and Register Pressure in VLIW Architectures: … · 2011-09-12 · Fundamental principle: Theorem [Touati2001] Let G be a loop DDG. Let G0the extended DDG of G

SIRA: schedule independent register allocation

Fundamental principle: Theorem [Touati2001]

Let G be a loop DDG. Let G′ the extended DDG of G associated with thevalid reuse graph Greuse,t for the register type t. Then, any softwarepipelining σ of G does not require more then

∑µt

u,v registers of type t,

where µtu,v is the reuse distance between u and v in Greuse,t. Formally:

∀σ ∈ Σ(G),PeriodicRegisterRequirementtσ(G) ≤

∑µt

u,v

8 / 20

Page 9: Software Pipelining and Register Pressure in VLIW Architectures: … · 2011-09-12 · Fundamental principle: Theorem [Touati2001] Let G be a loop DDG. Let G0the extended DDG of G

SIRA: How it works ?

The SIRALINA heuristic works in two polynomial steps:

1 Step 1: Computes the minimal reuse distances between every possiblecouple of statements (i.e. Compute a function µt : VR,t × VR,t → Zfor each register type t);

2 Step 2: Compute a bijection Ereuse,t : VR,t → VR,t that minimises∑er∈Ereuse,t

µt(er) for each register type t.

9 / 20

Page 10: Software Pipelining and Register Pressure in VLIW Architectures: … · 2011-09-12 · Fundamental principle: Theorem [Touati2001] Let G be a loop DDG. Let G0the extended DDG of G

SIRA: How it works ?

1 Step 1: It is a cyclic scheduling problem under precendenceconstraints only. It may be solved optimally by a min-cost max flowproblem, or by a linear program with a totally unimodular constraintsmatrix. The complexity is O(‖V‖3 log ‖V‖)

2 Step 2: It is a linear assignment problem, solved optimally by theHungarian algorithm in O(‖V‖3).

10 / 20

Page 11: Software Pipelining and Register Pressure in VLIW Architectures: … · 2011-09-12 · Fundamental principle: Theorem [Touati2001] Let G be a loop DDG. Let G0the extended DDG of G

SIRA: How it works ?

(1,0)

(3,2)(3, 1)

(1,1)(2,0)

(1,2)

(0,4)

(0,6)(0,3)

(0,3)

(b) Reuse Graphs for Register Types t1 and t2

(c) DDG with Killing Nodes (d) Preconditioned DDG after Applying SIRA

(0,0)

(0,−2) (0,−1)

(0,−1)

(0,0)(0,−2)

=4 =3=2

=6=3

(a) Initial DDG

(0,2)

u3 u4u4

u2

u4u3

u1 u2

Register type t1 Register type t2

u1 u1u2

u3 u1

u4u3

u1

ku1t2

ku4t2

u2

ku2t2

ku1t1 ku3

t1

ku1t2

ku2t2

ku4t2

µu1,u1

µu2,u4µu4,u2

µu1,u3 µu3,u1

ku3t1

ku1t1

Eµ = {(kut , v)|(u, v) ∈ Ereuse,t}V k = {kut |u ∈ V R,t}Ek = {(v, kut)|v ∈ Cons(ut)}

11 / 20

Page 12: Software Pipelining and Register Pressure in VLIW Architectures: … · 2011-09-12 · Fundamental principle: Theorem [Touati2001] Let G be a loop DDG. Let G0the extended DDG of G

Plugging SIRA into the ST231 toolchain

12 / 20

Page 13: Software Pipelining and Register Pressure in VLIW Architectures: … · 2011-09-12 · Fundamental principle: Theorem [Touati2001] Let G be a loop DDG. Let G0the extended DDG of G

Experiments

Setup

FFMPEG, MEDIABENCH and SPEC CPU2000 benchmarks

ST231 register count lowered to 32 GR, 4 BR, optimizedsimultaneously

Instruction schedulers

SIRA frees aggressive scheduling from register pressure worries1 Optimal: Integer Linear Programming, minimize II and schedule length2 Unwinding heuristic: unrolling-based method to build modulo schedules3 Lifetime-sensitive heuristic: minimizes the sum of life-ranges

Questions

Does SIRA improve performance? For which scheduler?

How does a lifetime sensitive heuristic compare with the combinationof SIRA with a pressure-unaware algorithm?

13 / 20

Page 14: Software Pipelining and Register Pressure in VLIW Architectures: … · 2011-09-12 · Fundamental principle: Theorem [Touati2001] Let G be a loop DDG. Let G0the extended DDG of G

Experiments

Setup

Instrumentation of the toolchain yields static numbers about spillsand II

For each benchmark and each scheduler, we compare the numbersobtained with the scheduler alone to those obtained with both SIRAand the scheduler

14 / 20

Page 15: Software Pipelining and Register Pressure in VLIW Architectures: … · 2011-09-12 · Fundamental principle: Theorem [Touati2001] Let G be a loop DDG. Let G0the extended DDG of G

Experiments

Mean spill variation =P

(Spillwith SIRA−Spillwithout SIRA)PSpillwithout sira

Mean II variation = (P

IIwith SIRA−IIwithout SIRA)PIIwithout SIRA

15 / 20

Page 16: Software Pipelining and Register Pressure in VLIW Architectures: … · 2011-09-12 · Fundamental principle: Theorem [Touati2001] Let G be a loop DDG. Let G0the extended DDG of G

Experiments: cross-comparison

Question

How does a lifetime sensitive heuristic compare with the combination ofSIRA with a pressure-unaware algorithm?

Setup

SIRA + unwinding scheduler vs. lifetime-sensitive scheduler alone

SIRA + optimal scheduler vs. lifetime-sensitive scheduler alone

16 / 20

Page 17: Software Pipelining and Register Pressure in VLIW Architectures: … · 2011-09-12 · Fundamental principle: Theorem [Touati2001] Let G be a loop DDG. Let G0the extended DDG of G

Experiments: cross-comparisons

17 / 20

Page 18: Software Pipelining and Register Pressure in VLIW Architectures: … · 2011-09-12 · Fundamental principle: Theorem [Touati2001] Let G be a loop DDG. Let G0the extended DDG of G

Experiments: spill code in post-passDoes SIRA reduce spill or prevent it altogether?

Answer: evaluate Loops that do not have spill anymore once SIRA is usedLoops that had spill without SIRA

18 / 20

Page 19: Software Pipelining and Register Pressure in VLIW Architectures: … · 2011-09-12 · Fundamental principle: Theorem [Touati2001] Let G be a loop DDG. Let G0the extended DDG of G

Conclusions

Using SIRA significantly decreases both II and spills, for all schedulers

Not surprisingly, results are less impressive on the lifetime-sensitivescheduler, since the heuristic already reduce register pressure

The combination of SIRA with an aggressive scheduler outperformsthe lifetime-sensitive approach

19 / 20

Page 20: Software Pipelining and Register Pressure in VLIW Architectures: … · 2011-09-12 · Fundamental principle: Theorem [Touati2001] Let G be a loop DDG. Let G0the extended DDG of G

The speedup debateSpeedups depend on the data input, and the time fraction spend inthe SWP loops.The compiler optimises for an architectural objective, while speedupcomes from a complex interaction with the micro-architecture and theexperimental environment.If you get a speedup, who guarantees that it comes as a directconsequence of the plugged optimisation ? Phase ordering, hiddenside effects, etc.In our case: SWP loops account for 0% to 5% of the wholeapplicatiosn execution times. Most of the speedups are equal to 1.The other speedups vary from 0.85 to 2.4. Except in one case(FFMPEG), all the observed speedups and slowdons come fromI-cache effects !Do not trust speedups when you work on code optimisation ! Trustwhat you can prove or demonstrate, not what you observ. Codequality is a matter of many metrics, speedup is a single metric amongmany others. 20 / 20