Tiling for Dynamic Scheduling Ravi Teja Mullapudi Uday Bondhugula - - PowerPoint PPT Presentation

tiling for dynamic scheduling
SMART_READER_LITE
LIVE PREVIEW

Tiling for Dynamic Scheduling Ravi Teja Mullapudi Uday Bondhugula - - PowerPoint PPT Presentation

Tiling for Dynamic Scheduling Ravi Teja Mullapudi Uday Bondhugula CSA, Indian Institue of Science January 20, 2014 Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 1 / 25 Table of Contents Tiling 1 Introduction Validity


slide-1
SLIDE 1

Tiling for Dynamic Scheduling

Ravi Teja Mullapudi Uday Bondhugula

CSA, Indian Institue of Science

January 20, 2014

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 1 / 25

slide-2
SLIDE 2

Table of Contents

1

Tiling Introduction Validity

2

Limitations Where do current approaches fail?

3

Directions Localizing Dependences Iterative Tiling Approximate Cycle Check

4

Applications

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 2 / 25

slide-3
SLIDE 3

Table of Contents

1

Tiling Introduction Validity

2

Limitations Where do current approaches fail?

3

Directions Localizing Dependences Iterative Tiling Approximate Cycle Check

4

Applications

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 3 / 25

slide-4
SLIDE 4

Tiling

Definition (Computation Graph)

A directed acyclic graph in which the nodes represent operations and edges denote dependences between operations

Definition (Tiling)

Partitioning a computation graph into atomic units of execution

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 4 / 25

slide-5
SLIDE 5

Iteration spaces, Dependences and Hyperplanes

i j

for (i = 0; i < N; i++){ for ( j = 0; j < N; j++) { A[j] = A[j] + B[i]; s1 if (i == j) B[i+1] = A[j]; s2 } }

Iteration spaces

Ds =

  • is
  • is ∈ Zn, A

is + b ≥ 0

  • Ravi Teja M (IISc)

Tiling for Dynamic Scheduling January 20, 2014 5 / 25

slide-6
SLIDE 6

Iteration spaces, Dependences and Hyperplanes

i j

for (i = 0; i < N; i++){ for ( j = 0; j < N; j++) { A[j] = A[j] + B[i]; s1 if (i == j) B[i+1] = A[j]; s2 } }

Dependences

Pe =

  • is,

it

  • is ∈ Ds,

it ∈ Dt, is = he( it), e : s → t

  • Ravi Teja M (IISc)

Tiling for Dynamic Scheduling January 20, 2014 5 / 25

slide-7
SLIDE 7

Iteration spaces, Dependences and Hyperplanes

φ1 φ2

i j

for (i = 0; i < N; i++){ for ( j = 0; j < N; j++) { A[j] = A[j] + B[i]; s1 if (i == j) B[i+1] = A[j]; s2 } }

Hyperplanes

φs( is) = h· is + h0

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 5 / 25

slide-8
SLIDE 8

Iteration spaces, Dependences and Hyperplanes

φ1 φ2

i j

for (i = 0; i < N; i++){ for ( j = 0; j < N; j++) { A[j] = A[j] + B[i]; s1 if (i == j) B[i+1] = A[j]; s2 } }

Hyperplanes

φs( is) = h· is + h0

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 5 / 25

slide-9
SLIDE 9

Validity Conditions

φ1 φ2

i j

φ1 φ2

i j

Non-Negative Dependence Components

φt( it) − φs( is) ≥ 0 , is, it ∈ Pe, e : s → t (HD ≥ 0) Irigoin and Triolet, Lim and Lam, Griebl, Pluto

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 6 / 25

slide-10
SLIDE 10

Validity Conditions

φ1 φ2

i j

φ1 φ2

i j

Lexicographically Non-Negative Tile Dependences

⌊HD⌋ Xue

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 6 / 25

slide-11
SLIDE 11

Table of Contents

1

Tiling Introduction Validity

2

Limitations Where do current approaches fail?

3

Directions Localizing Dependences Iterative Tiling Approximate Cycle Check

4

Applications

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 7 / 25

slide-12
SLIDE 12

Conservative Validity Conditions

φ1 φ2

i j

for (i = 0; i < N; i++){ for ( j = 0; j < N; j++) { A[j] = A[j] + B[i]; s1 if (i == j) B[i+1] = A[j]; s2 } }

Negative dependence components along φ2 but tiling is valid Inter-tile dependences lexicographically negative Tile sizes effect validity

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 8 / 25

slide-13
SLIDE 13

Conservative Validity Conditions

φ1 φ2

i j

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

Negative dependence components along φ2 but tiling is valid Inter-tile dependences lexicographically negative Tile sizes effect validity

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 8 / 25

slide-14
SLIDE 14

Conservative Validity Conditions

φ1 φ2

i j

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

Negative dependence components along φ2 but tiling is valid Inter-tile dependences lexicographically negative Tile sizes effect validity

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 8 / 25

slide-15
SLIDE 15

Conservative Validity Conditions

φ1 φ2

i j

φ1 φ2

i j Negative dependence components along φ2 but tiling is valid Inter-tile dependences lexicographically negative Tile sizes effect validity

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 8 / 25

slide-16
SLIDE 16

Uniformly Tiling Iteration Spaces

φ1 φ2

i j

for (i = 0; i < N; i++){ for ( j = 0; j < N; j++) { if (j > i) A[j] = A[j] + A[i]; s1 if (j < i) A[j] = A[j] + A[i]; s2 } }

Tile dependence graph has cycles Splitting breaks cycles

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 9 / 25

slide-17
SLIDE 17

Uniformly Tiling Iteration Spaces

φ1 φ2

i j

for (i = 0; i < N; i++){ for ( j = 0; j < N; j++) { if (j > i) A[j] = A[j] + A[i]; s1 if (j < i) A[j] = A[j] + A[i]; s2 } }

Tile dependence graph has cycles Splitting breaks cycles

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 9 / 25

slide-18
SLIDE 18

Uniformly Tiling Iteration Spaces

φ1 φ2

i j

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

Tile dependence graph has cycles Splitting breaks cycles

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 9 / 25

slide-19
SLIDE 19

Dynamic Scheduling

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

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

Not easy to come up with a static schedule for the tiles Dynamic task scheduler

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 10 / 25

slide-20
SLIDE 20

Table of Contents

1

Tiling Introduction Validity

2

Limitations Where do current approaches fail?

3

Directions Localizing Dependences Iterative Tiling Approximate Cycle Check

4

Applications

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 11 / 25

slide-21
SLIDE 21

General Validity Condition

Definition (Valid Tiling)

A set of hyperplanes φ1, φ2, . . . , φk with tile size τi for φi, is a valid tiling

  • f an iteration space if the dependence graph of k-dimensional tiles formed

by the hyperplanes with their respective tile sizes is cycle-free. Transitive closure of dependence relations

Precise computation might be infeasible Expensive operation even for an approximation

Conservative cycle detection

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 12 / 25

slide-22
SLIDE 22

Localizing Dependences

Theorem

{φ1, . . . , φk} with tile size τi for φi is a valid tiling of an iteration space, if {φ1, . . . , φk−1} is a valid tiling and φk is a valid one-dimensional tiling of each k − 1 dimensional tile formed by {φ1, . . . , φk−1}.

φ1

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 13 / 25

slide-23
SLIDE 23

Localizing Dependences

Theorem

{φ1, . . . , φk} with tile size τi for φi is a valid tiling of an iteration space, if {φ1, . . . , φk−1} is a valid tiling and φk is a valid one-dimensional tiling of each k − 1 dimensional tile formed by {φ1, . . . , φk−1}.

φ1 φ2

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 13 / 25

slide-24
SLIDE 24

Localizing Dependences

Theorem

{φ1, . . . , φk} with tile size τi for φi is a valid tiling of an iteration space, if {φ1, . . . , φk−1} is a valid tiling and φk is a valid one-dimensional tiling of each k − 1 dimensional tile formed by {φ1, . . . , φk−1}.

φ1 φ2

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 13 / 25

slide-25
SLIDE 25

Localizing Dependences

Theorem

{φ1, . . . , φk} with tile size τi for φi is a valid tiling of an iteration space, if {φ1, . . . , φk−1} is a valid tiling and φk is a valid one-dimensional tiling of each k − 1 dimensional tile formed by {φ1, . . . , φk−1}.

φ1 φ2

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 13 / 25

slide-26
SLIDE 26

Localizing Dependences

Theorem

{φ1, . . . , φk} with tile size τi for φi is a valid tiling of an iteration space, if {φ1, . . . , φk−1} is a valid tiling and φk is a valid one-dimensional tiling of each k − 1 dimensional tile formed by {φ1, . . . , φk−1}.

φ1

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 13 / 25

slide-27
SLIDE 27

Localizing Dependences

Dependences in the transformed space

  • T 1

s , . . . , T k s ,

is, T 1

t , . . . , T k t ,

it | is, it ∈ Pe, e : s → t, 1 ≤ l ≤ k, τl ∗ T l

s ≤ φl s(

is) ≤ τl ∗ (T l

s + 1) − 1,

τl ∗ T l

t ≤ φl t(

it) ≤ τi ∗ (T l

t + 1) − 1

  • Inter-Tile Dependences

Pe denotes the inter-tile dependence polyhedron between k-dimensional tiles formed by φ1, . . . , φk due to the depedence edge e.

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 14 / 25

slide-28
SLIDE 28

Localizing Dependences

Dependences in the transformed space

  • T 1

s , . . . , T k s ,

is, T 1

t , . . . , T k t ,

it | is, it ∈ Pe, e : s → t, 1 ≤ l ≤ k, τl ∗ T l

s ≤ φl s(

is) ≤ τl ∗ (T l

s + 1) − 1,

τl ∗ T l

t ≤ φl t(

it) ≤ τi ∗ (T l

t + 1) − 1

  • Inter-Tile Dependences

Pe denotes the inter-tile dependence polyhedron between k-dimensional tiles formed by φ1, . . . , φk due to the depedence edge e. Computed by projecting out dimensions inner to the tiling dimension φk (for both source and target statements)

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 14 / 25

slide-29
SLIDE 29

Localizing Dependences

Restricted Tile Dependence

Qk

e is a subset of Pk e restricted to the same k − 1 dimensional tile defined

by the k − 1 tiling hyperplanes outer to φk.

φ1

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 15 / 25

slide-30
SLIDE 30

Localizing Dependences

Restricted Tile Dependence

Qk

e is a subset of Pk e restricted to the same k − 1 dimensional tile defined

by the k − 1 tiling hyperplanes outer to φk.

φ1 φ2

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 15 / 25

slide-31
SLIDE 31

Localizing Dependences

Restricted Tile Dependence

Qk

e is a subset of Pk e restricted to the same k − 1 dimensional tile defined

by the k − 1 tiling hyperplanes outer to φk. Qk

e thus captures dependences between only those k-dimensional tiles

which are in the same k −1 dimensional tile formed by φ1, . . . , φk−1 If e is from statement s to statement t, then: Qk

e = Pk e ∧

 

  • 1≤l≤k−1

T l

s = T l t

 

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 15 / 25

slide-32
SLIDE 32

Improved Iterative Tiling

φ1 φ2

i j

1 while τk > 1 do

// 1. Check validity of tiling at level k. for each e ∈ E do Compute Qk

e for dependence e : s → t.

// C is the set of tiles that might be in a cycle C = CycleCheck(Qk

e for each edge e ∈ E)

if C = ∅ then // Tiling is valid, move to next level break // 2. Attempt to correct tiling τk = ⌊τk/2⌋

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 16 / 25

slide-33
SLIDE 33

Improved Iterative Tiling

φ1

i j

1 while τk > 1 do

// 1. Check validity of tiling at level k. for each e ∈ E do Compute Qk

e for dependence e : s → t.

// C is the set of tiles that might be in a cycle C = CycleCheck(Qk

e for each edge e ∈ E)

if C = ∅ then // Tiling is valid, move to next level break // 2. Attempt to correct tiling τk = ⌊τk/2⌋

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 16 / 25

slide-34
SLIDE 34

Improved Iterative Tiling

φ1

i j

1 while τk > 1 do

// 1. Check validity of tiling at level k. for each e ∈ E do Compute Qk

e for dependence e : s → t.

// C is the set of tiles that might be in a cycle C = CycleCheck(Qk

e for each edge e ∈ E)

if C = ∅ then // Tiling is valid, move to next level break // 2. Attempt to correct tiling τk = ⌊τk/2⌋

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 16 / 25

slide-35
SLIDE 35

Improved Iterative Tiling

φ1 φ2

i j

1 while τk > 1 do

// 1. Check validity of tiling at level k. for each e ∈ E do Compute Qk

e for dependence e : s → t.

// C is the set of tiles that might be in a cycle C = CycleCheck(Qk

e for each edge e ∈ E)

if C = ∅ then // Tiling is valid, move to next level break // 2. Attempt to correct tiling τk = ⌊τk/2⌋

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 16 / 25

slide-36
SLIDE 36

Improved Iterative Tiling

φ1 φ2

i j

1 while τk > 1 do

// 1. Check validity of tiling at level k. for each e ∈ E do Compute Qk

e for dependence e : s → t.

// C is the set of tiles that might be in a cycle C = CycleCheck(Qk

e for each edge e ∈ E)

if C = ∅ then // Tiling is valid, move to next level break // 2. Attempt to correct tiling τk = ⌊τk/2⌋

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 16 / 25

slide-37
SLIDE 37

Approximate Cycle Check

Dependences On a Line

Each hyperplane φk gives a one-dimensional coordinate for a tile which can be used to map a tile to a point on a line.

φk p Forward face Backward face

Forward Dependences Backward Dependences When are there no cycles?

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 17 / 25

slide-38
SLIDE 38

Approximate Cycle Check

Dependences On a Line

Each hyperplane φk gives a one-dimensional coordinate for a tile which can be used to map a tile to a point on a line.

φk p Forward face Backward face

Forward Dependences Backward Dependences When are there no cycles?

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 17 / 25

slide-39
SLIDE 39

Approximate Cycle Check

Dependences On a Line

Each hyperplane φk gives a one-dimensional coordinate for a tile which can be used to map a tile to a point on a line.

φk p Forward face Backward face

Forward Dependences Backward Dependences When are there no cycles?

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 17 / 25

slide-40
SLIDE 40

Approximate Cycle Check

p Forward face Backward face

Backward Violation

Bk

e,e′ =

  • T 1

s , . . . , T k s | ∃T l t , ∃T l s′, ∃T l t′, (T k s ≥ T k t + 1) ∧

(T k

s′ ≤ T k t′ − 1) ∧1≤l≤k (T l t′ = T l s) ∧

T 1

s , . . . , T k s , T 1 t , . . . , T k t ∈ Qk e , e : s → t

T 1

s′, . . . , T k s′, T 1 t′, . . . , T k t′ ∈ Qk e′, e′ : s′ → t′

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 18 / 25

slide-41
SLIDE 41

Approximate Cycle Check

p Forward face Backward face

Forward Violation

F k

e,e′ =

  • T 1

s , . . . , T k s | ∃T l t , ∃T l s′, ∃T l t′, (T k s ≤ T k t − 1) ∧

(T k

s′ ≥ T k t′ + 1) ∧1≤l≤k (T l t′ = T l s) ∧

T 1

s , . . . , T k s , T 1 t , . . . , T k t ∈ Qk e , e : s → t

T 1

s′, . . . , T k s′, T 1 t′, . . . , T k t′ ∈ Qk e′, e′ : s′ → t′

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 18 / 25

slide-42
SLIDE 42

Approximate Cycle Check

Input : Tile dependence polyhedra at level k Qk

e for all e ∈ E the set of edges in

the GDG. Output: Set of tiles that might be part of a cycle // Bk set of tiles that satisfy B at level k. // F k set of tiles that satisfy F at level k. Bk = ∅, F k = ∅ for each pair Qk

e , Qk e′ e, e′ ∈ E // e can be equal to e′

do Compute Bk

e,e′, F k e,e′ using Qk e and Qk e′

Bk = Bk

e,e′ ∪ Bk

F k = F k

e,e′ ∪ F k

return Bk ∪ F k

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 19 / 25

slide-43
SLIDE 43

Table of Contents

1

Tiling Introduction Validity

2

Limitations Where do current approaches fail?

3

Directions Localizing Dependences Iterative Tiling Approximate Cycle Check

4

Applications

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 20 / 25

slide-44
SLIDE 44

Floyd-Warshall All Pairs Shortest Paths

φ1 φ2

k i Using additional arrays R and C to remove false dependences in the All-Pairs Shortest-Paths kernel

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 21 / 25

slide-45
SLIDE 45

Floyd-Warshall All Pairs Shortest Paths

φ1 φ2

k i All-Pairs Shortest-Paths kernel after removing spurious writes

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 21 / 25

slide-46
SLIDE 46

Zuker’s RNA Secondary Structure Prediction

for (i = N-1; i >= 0; i--) { for (j = i+1; j < N; j++) { for (k = 0; k < j-i; k++) { S[i][j] = MAX(S[i][k+i] + S[k+i+1][j], S[i][j]); } S[i][j] = MAX(S[i][j], S[i+1][j-1] + can_pair(RNA[i],RNA[j])); } }

Complex dynamic programming recurrence 3-d tiling the O(n3) loop nest

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 22 / 25

slide-47
SLIDE 47

Zuker’s RNA Secondary Structure Prediction

for (i = 0; i < N; i++){ for ( j = 0; j < i+1; j++) { A[i] = A[i] + A[i-j]; s1 } }

φ1 φ2

i j

Merging tiles Use commutative properties

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 22 / 25

slide-48
SLIDE 48

Experimental Evalutation

10 20 30 40 50 60 70 1 2 4 8 16 32 Speedup over seq Number of threads CnC 2d tiled CnC 3d tiled

(a) floyd – seq time is 231s

2 4 6 8 10 12 14 16 18 1 2 4 8 16 32 Speedup over single thread Number of threads GTfold CnC 3d tiled

(b) zuker – single thread time is 253s

Experimental setup is a four socket machine with an AMD Opteron 6136 (2.4 GHz, 128 KB L1, 512 KB L2, 6 MB L3 cache) in each socket.

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 23 / 25

slide-49
SLIDE 49

Conclusions and Future Work

Using improved validity constraints for hyperplane search Integrating splitting techniques More accurate cycle detection

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 24 / 25

slide-50
SLIDE 50

Questions?

Thank You!

Ravi Teja M (IISc) Tiling for Dynamic Scheduling January 20, 2014 25 / 25