470 likes | 474 Vues
Ordonnancement de systèmes Alpha structurés. Patrice Quinton, Tanguy Risset Séminaire Roscoff. Outline. Cyclic scheduling: state of the art Scheduling in MMAlpha Experiments in MMAlpha. Review: affine dependences. Feautrier 92 Farkas Lemma Darte 92 Duality fundamental theorem
E N D
Ordonnancement de systèmes Alpha structurés Patrice Quinton, Tanguy Risset Séminaire Roscoff Patrice Quinton, Tanguy Risset
Outline • Cyclic scheduling: state of the art • Scheduling in MMAlpha • Experiments in MMAlpha Patrice Quinton, Tanguy Risset
Review: affine dependences • Feautrier 92 • Farkas Lemma • Darte 92 • Duality fundamental theorem • Mauras, Quinton, Rajopadhye, Saouter 91 • dual representation of polyhedra • Do not handle resource constraints Patrice Quinton, Tanguy Risset
Scheduling in CAD community • Schedule of an acyclic graph under resource constraints • Heuristics: • list scheduling, FDS, Sim. Al. • Exact method: • Integer linear programming • Does not handle loops Patrice Quinton, Tanguy Risset
Scheduling in the compiler community • Problem tackled: • instruction level parallelism • resource constraints or register constraints • Software pipelining + loop unrolling • heuristics • integer linear programming • One single uniform loop Patrice Quinton, Tanguy Risset
Recent work: exact solution • Dirk Fimmel, Jan Muller: • solve resource constraints, register constraints and initiation interval in a single ILP: • minimize latency with respect to dependences, register and resource constraints. Patrice Quinton, Tanguy Risset
Duration 1 4 2 6 10 14 Recent work: heuristics • Gasperoni, Eisenbeis, Darte & Robert • transform the cyclic 1D problem into an acyclic one Patrice Quinton, Tanguy Risset
12k 12(k+1) time Ak Ak+1 Dk-1 Bk Ck Dk BK+1 Ck+1 Ek Fk Fk-1 Ek+1 Fk+1 =12 ressources Recent work: heuristics Patrice Quinton, Tanguy Risset
time 24(k+1) 24k Dk-1 Ek Ck Ak Dk Ek Fk Ek+1 =24 ressources Resource constrained scheduling Patrice Quinton, Tanguy Risset
Questions • How do we adapt these theories • software pipelining • resource constraints scheduling to polyedral hardware generation with MMAlpha? Patrice Quinton, Tanguy Risset
Outline • Cyclic scheduling: state of the art • Scheduling in MMAlpha • Experiments in MMAlpha Patrice Quinton, Tanguy Risset
Classical linear schedule in MMAlpha design flow Patrice Quinton, Tanguy Risset
Duration 1 4 2 6 10 14 Classical linear schedule in MMAlpha design flow Patrice Quinton, Tanguy Risset
6 2 C D 2 1 1 0 1 A B F E 2 0 0 10 1 4 14 Classical linear schedule in MMAlpha design flow Patrice Quinton, Tanguy Risset
Classical linear schedule in MMAlpha design flow schedule[ scheduleType -> sameLinearPart, durations -> {0,0,1,4,2,6,10,14,0,0}, addConstraints -> {/* linear constraints */} ] Patrice Quinton, Tanguy Risset
Multi-dimensional scheduling • Virtual clock counter is a vector (hours, minutes,….) t2 N t1 N Patrice Quinton, Tanguy Risset
Multi-dimensional scheduling • Useful for • Fast prototyping of parallelism in complex applications • SVD (S. Robert, 1997) • Kalman filtering (A. Mozipo, 1998) • Efficient code generation • Quilleré 1999 • Structured scheduling Patrice Quinton, Tanguy Risset
Extension to structured scheduling • Structured systems of recurrence equations (Dinechin97) • Example: • matrix product can be expressed as N2 independent dot products. • Question: • Provided we have a layout for the dot product, can we use it for matrix product? Patrice Quinton, Tanguy Risset
Example: Matrix-Matrix product {i,j,k|1<=i,j,k<=N}: A[i,j,k] = A[i,j-1,k-1]; {i,j,k|1<=i,j,k<=N}: B[i,j,k] = B[i-1,j,k-1]; {i,j,k|1<=i,j,k<=N}: C[i,j,k] = C[i,j,k-1]*A[i,j,k]*B[i,j,k]; {i,j|1<=i,j<=N}: c[i,j] = C[i,j,N]; Patrice Quinton, Tanguy Risset
k j c[1,1] A(1,1,4) B(1,1,4) A(1,1,3) B(1,1,3) A(1,1,2) B(1,1,2) A(1,1,1) B(1,1,1) i 0 Example: Matrix-Matrix product Patrice Quinton, Tanguy Risset
k c a(4) b(4) a(3) b(3) a(2) b(2) a(1) b(1) 0 Alpha code for dot product Patrice Quinton, Tanguy Risset
k c a(4) b(4) a(3) b(3) a(2) b(2) a(1) b(1) 0 Alpha code for dot product system dot:{N|1<=N} (a,b:{k|1<=k<=N} of integer)returns (c: integer); var Acc:{k|0<=k<=N} of integer; let Acc[k] = case {|k=0}:0[]; {|k>0}:Acc[k-1]+a[k]*b[k]; esac; c[]=Acc[N]; tel; Patrice Quinton, Tanguy Risset
k j c[1,1] A(1,1,4) B(1,1,4) A(1,1,3) B(1,1,3) B(1,1,2) A(1,1,2) A(1,1,1) B(1,1,1) i 0 Matrix product using dot product {i,j,k|1<=i,j,k<=N}: A[i,j,k] = A[i,j-1,k-1]; {i,j,k|1<=i,j,k<=N}: B[i,j,k] = B[i-1,j,k-1]; use {i,j|1<=i<=N} dot[N](A,B) returns (C); Patrice Quinton, Tanguy Risset
DG: A B ACC C Structured dependence graph Patrice Quinton, Tanguy Risset
DG: A B SDG: A B ACC C C Structured dependence graph Patrice Quinton, Tanguy Risset
What is a structured scheduling? • Schedule each computation such that • dependencies are satisfied • timing functions are positive • All instances of a given subsystem have the same schedule • Schedule is built from the structured dependence graph. Patrice Quinton, Tanguy Risset
Necessary form of a structured scheduling This form can be imposed by means of linear constraints use {i,j|1<=i<=N} dot[N](A,B) returns (C); Patrice Quinton, Tanguy Risset
k c a(4) b(4) a(3) b(3) a(2) b(2) a(1) b(1) 0 Schedule of the dot product Patrice Quinton, Tanguy Risset
Structured 1D schedule use {i,j|1<=i<=N} dot[N](A,B) returns (C); Patrice Quinton, Tanguy Risset
2D schedule use {i,j|1<=i<=N} dot[N](A,B) returns (C); Patrice Quinton, Tanguy Risset
c[1,1] A(1,1,4) B(1,1,4) A(1,1,3) B(1,1,3) A(1,1,2) B(1,1,2) A(1,1,1) B(1,1,1) 0 How to interpret this? k j i Patrice Quinton, Tanguy Risset
c[1,1] A(1,1,4) B(1,1,4) A(1,1,3) B(1,1,3) A(1,1,2) B(1,1,2) A(1,1,1) B(1,1,1) 0 j=1 k j i Patrice Quinton, Tanguy Risset
c[1,1] A(1,1,4) B(1,1,4) A(1,1,3) B(1,1,3) A(1,1,2) B(1,1,2) A(1,1,1) B(1,1,1) 0 j=1 k j i Patrice Quinton, Tanguy Risset
c[1,1] A(1,1,4) B(1,1,4) A(1,1,3) B(1,1,3) A(1,1,2) B(1,1,2) A(1,1,1) B(1,1,1) 0 j=1 k j i Patrice Quinton, Tanguy Risset
c[1,1] A(1,1,4) B(1,1,4) A(1,1,3) B(1,1,3) A(1,1,2) B(1,1,2) A(1,1,1) B(1,1,1) 0 j=1 k j i Patrice Quinton, Tanguy Risset
j=2 j k i Patrice Quinton, Tanguy Risset
j=3 k j i Patrice Quinton, Tanguy Risset
Matrix product re-using hardware Matrix product C B*,* C1,* C2,* C3,* A1,* A2,* A3,* Acc + * B A Dot product Patrice Quinton, Tanguy Risset
Advantage of structured scheduling • Preserves designer’s structuring • Re-uses hardware • Constraints are linear • uses a classical schedule tool • Reduces the schedule computation complexity • Improves readability of the schedule information Patrice Quinton, Tanguy Risset
Outline • Cyclic scheduling: state of the art • Scheduling in MMAlpha • Experiments in MMAlpha Patrice Quinton, Tanguy Risset
Experiments • Vertex method: Simplex of Mathematica • Farkas method: Pip software • Evaluation of structured vs « flat » scheduling Patrice Quinton, Tanguy Risset
Test set (vertex method) Patrice Quinton, Tanguy Risset
#Constraints vs #Variables Patrice Quinton, Tanguy Risset
Schedule time vs #constraints Patrice Quinton, Tanguy Risset
#Constraints vs #Variables (Farkas method) Patrice Quinton, Tanguy Risset
Schedule time vs #constraints Patrice Quinton, Tanguy Risset
Flat vs structured schedule Patrice Quinton, Tanguy Risset