On Demand Parametric Array Dataflow Analysis Sven Verdoolaege - - PowerPoint PPT Presentation

on demand parametric array dataflow analysis
SMART_READER_LITE
LIVE PREVIEW

On Demand Parametric Array Dataflow Analysis Sven Verdoolaege - - PowerPoint PPT Presentation

January 21, 2013 1 / 43 On Demand Parametric Array Dataflow Analysis Sven Verdoolaege Hristo Nikolov Todor Stefanov Leiden Institute for Advanced Computer Science Ecole Normale Sup erieure and INRIA January 21, 2013 January 21, 2013


slide-1
SLIDE 1

January 21, 2013 1 / 43

On Demand Parametric Array Dataflow Analysis

Sven Verdoolaege Hristo Nikolov Todor Stefanov

Leiden Institute for Advanced Computer Science ´ Ecole Normale Sup´ erieure and INRIA

January 21, 2013

slide-2
SLIDE 2

January 21, 2013 2 / 43

Outline

1

Motivation General Motivation Our Motivation

2

Array Dataflow Analysis Standard Fuzzy On Demand Parametric

3

Dynamic Conditions

4

Parametrization Overview Representation Introduction Additional Constraints

5

Related Work

6

Experimental Results

7

Conclusion

slide-3
SLIDE 3

Motivation January 21, 2013 3 / 43

Outline

1

Motivation General Motivation Our Motivation

2

Array Dataflow Analysis Standard Fuzzy On Demand Parametric

3

Dynamic Conditions

4

Parametrization Overview Representation Introduction Additional Constraints

5

Related Work

6

Experimental Results

7

Conclusion

slide-4
SLIDE 4

Motivation General Motivation January 21, 2013 4 / 43

Motivation

Dataflow analysis determines for read access in a statement instance, the statement instance that wrote the value being read Many uses in polyhedral analysis/compilation

◮ array expansion ◮ scheduling ◮ equivalence checking ◮ optimizing computation/communication overlap in MPI programs ◮ derivation of process networks ◮ . . .

Standard dataflow analysis (Feautrier) requires static affine input programs Extensions are needed for programs with dynamic/non-affine constructs

slide-5
SLIDE 5

Motivation General Motivation January 21, 2013 4 / 43

Motivation

Dataflow analysis determines for read access in a statement instance, the statement instance that wrote the value being read Many uses in polyhedral analysis/compilation

◮ array expansion ◮ scheduling ◮ equivalence checking ◮ optimizing computation/communication overlap in MPI programs ◮ derivation of process networks ◮ . . .

Standard dataflow analysis (Feautrier) requires static affine input programs Extensions are needed for programs with dynamic/non-affine constructs

slide-6
SLIDE 6

Motivation Our Motivation January 21, 2013 5 / 43

Our Motivation: Derivation of Process Networks

Main purpose: extract task level parallelism from dataflow graph statement

process flow dependence

communication channel

⇒ requires dataflow analysis

Processes are mapped to parallel hardware (e.g., FPGA)

slide-7
SLIDE 7

Motivation Our Motivation January 21, 2013 5 / 43

Our Motivation: Derivation of Process Networks

Main purpose: extract task level parallelism from dataflow graph statement

process flow dependence

communication channel

⇒ requires dataflow analysis

Processes are mapped to parallel hardware (e.g., FPGA) Example: for (i = 0; i < n; ++i) { a = f(); g(a); }

f g

slide-8
SLIDE 8

Motivation Our Motivation January 21, 2013 6 / 43

Dynamic Process Networks

int state = 0; for (i = 0; i <= 10; i++) { sample = radioFrontend(); if (state == 0) { state = detect(sample); } else { state = decode(sample, &value0); value1 = processSample0(value0); processSample1(value1); } }

slide-9
SLIDE 9

Motivation Our Motivation January 21, 2013 6 / 43

Dynamic Process Networks

int state = 0; for (i = 0; i <= 10; i++) { sample = radioFrontend(); if (state == 0) { state = detect(sample); } else { state = decode(sample, &value0); value1 = processSample0(value0); processSample1(value1); } }

P_1 state=0 P_3 if() state P_2 radioFrontEnd() P_4 detect() sample P_5 decode() sample enable enable P_6 processSample0 enable P_7 processSample1) enable iteration state iteration state sample sample

slide-10
SLIDE 10

Motivation Our Motivation January 21, 2013 6 / 43

Dynamic Process Networks

int state = 0; for (i = 0; i <= 10; i++) { sample = radioFrontend(); if (state == 0) { state = detect(sample); } else { state = decode(sample, &value0); value1 = processSample0(value0); processSample1(value1); } }

P_1 state=0 P_3 if() state P_2 radioFrontEnd() P_4 detect() sample P_5 decode() sample enable enable P_6 processSample0 enable P_7 processSample1) enable iteration state iteration state sample sample

additional control channels determine operation of data channels dataflow analysis needs to remain exact, but may depend on run-time information

slide-11
SLIDE 11

Array Dataflow Analysis January 21, 2013 7 / 43

Outline

1

Motivation General Motivation Our Motivation

2

Array Dataflow Analysis Standard Fuzzy On Demand Parametric

3

Dynamic Conditions

4

Parametrization Overview Representation Introduction Additional Constraints

5

Related Work

6

Experimental Results

7

Conclusion

slide-12
SLIDE 12

Array Dataflow Analysis Standard January 21, 2013 8 / 43

Standard Array Dataflow Analysis

Given a read from an array element, what was the last write to the same array element before the read? Simple case: array written through a single reference

for (i = 0; i < N; ++i) for (j = 0; j < N - i; ++j) F: a[i+j] = f(a[i+j]); for (i = 0; i < N; ++i) W: Write(a[i]);

slide-13
SLIDE 13

Array Dataflow Analysis Standard January 21, 2013 8 / 43

Standard Array Dataflow Analysis

Given a read from an array element, what was the last write to the same array element before the read? Simple case: array written through a single reference

for (i = 0; i < N; ++i) for (j = 0; j < N - i; ++j) F: a[i+j] = f(a[i+j]); for (i = 0; i < N; ++i) W: Write(a[i]);

slide-14
SLIDE 14

Array Dataflow Analysis Standard January 21, 2013 8 / 43

Standard Array Dataflow Analysis

Given a read from an array element, what was the last write to the same array element before the read? Simple case: array written through a single reference

for (i = 0; i < N; ++i) for (j = 0; j < N - i; ++j) F: a[i+j] = f(a[i+j]); for (i = 0; i < N; ++i) W: Write(a[i]);

Access relations:

A1:=[N]->{F[i,j]->a[i+j]:0<=i<N and 0<=j<N-i}; A2:=[N]->{W[i] -> a[i] : 0 <= i < N };

slide-15
SLIDE 15

Array Dataflow Analysis Standard January 21, 2013 8 / 43

Standard Array Dataflow Analysis

Given a read from an array element, what was the last write to the same array element before the read? Simple case: array written through a single reference

for (i = 0; i < N; ++i) for (j = 0; j < N - i; ++j) F: a[i+j] = f(a[i+j]); for (i = 0; i < N; ++i) W: Write(a[i]);

F W a

A1 A2

Access relations:

A1:=[N]->{F[i,j]->a[i+j]:0<=i<N and 0<=j<N-i}; A2:=[N]->{W[i] -> a[i] : 0 <= i < N };

Map to all writes: R := A2 . (A1ˆ-1);

[N] -> { W[i] -> F[i’,i-i’] : 0 <= i,i’< N and i’<= i }

slide-16
SLIDE 16

Array Dataflow Analysis Standard January 21, 2013 8 / 43

Standard Array Dataflow Analysis

Given a read from an array element, what was the last write to the same array element before the read? Simple case: array written through a single reference

for (i = 0; i < N; ++i) for (j = 0; j < N - i; ++j) F: a[i+j] = f(a[i+j]); for (i = 0; i < N; ++i) W: Write(a[i]);

F W a

A1 A2

Access relations:

A1:=[N]->{F[i,j]->a[i+j]:0<=i<N and 0<=j<N-i}; A2:=[N]->{W[i] -> a[i] : 0 <= i < N };

Map to all writes: R := A2 . (A1ˆ-1);

[N] -> { W[i] -> F[i’,i-i’] : 0 <= i,i’< N and i’<= i }

Last write: lexmax R; # [N] -> { W[i] -> F[i,0] : 0 <= i < N }

slide-17
SLIDE 17

Array Dataflow Analysis Standard January 21, 2013 8 / 43

Standard Array Dataflow Analysis

Given a read from an array element, what was the last write to the same array element before the read? Simple case: array written through a single reference

for (i = 0; i < N; ++i) for (j = 0; j < N - i; ++j) F: a[i+j] = f(a[i+j]); for (i = 0; i < N; ++i) W: Write(a[i]);

F W a

A1 A2

Access relations:

A1:=[N]->{F[i,j]->a[i+j]:0<=i<N and 0<=j<N-i}; A2:=[N]->{W[i] -> a[i] : 0 <= i < N };

Map to all writes: R := A2 . (A1ˆ-1);

[N] -> { W[i] -> F[i’,i-i’] : 0 <= i,i’< N and i’<= i }

Last write: lexmax R; # [N] -> { W[i] -> F[i,0] : 0 <= i < N } In general: impose lexicographical order on shared iterators

slide-18
SLIDE 18

Array Dataflow Analysis Standard January 21, 2013 9 / 43

Standard Array Dataflow Analysis

Multiple Potential Sources

Dataflow is typically performed per read access (“sink”) C Corresponding writes (“potential sources”) P are considered in turn Map to all potential source iterations: Dmem

C,P = (A−1 P ◦ AC) ∩ BP C

(“memory based dependences”; BP

C: P executed before C)

Source may already be known for some sink iterations

⇒ compute partial lexicographical maximum (U′, D) = lexmax

U

M U: sink iterations for which no source has been found M: part of memory based dependences for particular potential source U′ = U \ dom M M′ = lexmax(M ∩ (U → ran M)) Note: here, dependence relations map sink iterations to source iterations

slide-19
SLIDE 19

Array Dataflow Analysis Fuzzy January 21, 2013 10 / 43

Fuzzy Array Dataflow Analysis

Introduces parameters for each lexmax involving dynamic behavior Parameters represent dynamic solution of lexmax operation Derives properties on parameters after dataflow analysis (using resolution)

slide-20
SLIDE 20

Array Dataflow Analysis Fuzzy January 21, 2013 10 / 43

Fuzzy Array Dataflow Analysis

Introduces parameters for each lexmax involving dynamic behavior Parameters represent dynamic solution of lexmax operation Derives properties on parameters after dataflow analysis (using resolution) Parametric result is exact Parameters can be projected out to obtain approximate but static dataflow

slide-21
SLIDE 21

Array Dataflow Analysis Fuzzy January 21, 2013 10 / 43

Fuzzy Array Dataflow Analysis

Introduces parameters for each lexmax involving dynamic behavior Parameters represent dynamic solution of lexmax operation Derives properties on parameters after dataflow analysis (using resolution) Parametric result is exact Parameters can be projected out to obtain approximate but static dataflow Main problem for deriving process networks: Introduces too many parameters

⇒ too many control channels

slide-22
SLIDE 22

Array Dataflow Analysis On Demand Parametric January 21, 2013 11 / 43

On Demand Parametric Array Dataflow Analysis

Similar to FADA: Exact, possibly parametric, dataflow Introduces parameters to represent dynamic behavior But:

+ Parameters have a different meaning + Effect analyzed before parameters are introduced + All computations are performed directly on affine sets and maps − Currently only supports dynamic conditions

slide-23
SLIDE 23

Dynamic Conditions January 21, 2013 12 / 43

Outline

1

Motivation General Motivation Our Motivation

2

Array Dataflow Analysis Standard Fuzzy On Demand Parametric

3

Dynamic Conditions

4

Parametrization Overview Representation Introduction Additional Constraints

5

Related Work

6

Experimental Results

7

Conclusion

slide-24
SLIDE 24

Dynamic Conditions January 21, 2013 13 / 43

Representing Generic Dynamic Conditions

while (1) { sample = radioFrontend(); if ( t(state) ) { D: state = detect(sample); } else { /* ... */ } }

slide-25
SLIDE 25

Dynamic Conditions January 21, 2013 13 / 43

Representing Generic Dynamic Conditions

while (1) { sample = radioFrontend(); if ( t(state) ) { D: state = detect(sample); } else { /* ... */ } }

Dynamic condition (t(state)) represented by filter Filter access relation(s): access to (virtual) array representing condition

D(i) → (S0(i) → t0(i))

Filter value relation: values of filter array elements for which statement is executed

D(i) → (1) | i ≥ 0

slide-26
SLIDE 26

Dynamic Conditions January 21, 2013 13 / 43

Representing Generic Dynamic Conditions

while (1) { sample = radioFrontend(); if ( t(state) ) { D: state = detect(sample); } else { /* ... */ } }

Dynamic condition (t(state)) represented by filter Filter access relation(s): access to (virtual) array representing condition

D(i) → (S0(i) → t0(i))

Filter value relation: values of filter array elements for which statement is executed

D(i) → (1) | i ≥ 0 S0: t0 = t(state);

slide-27
SLIDE 27

Dynamic Conditions January 21, 2013 13 / 43

Representing Generic Dynamic Conditions

while (1) { sample = radioFrontend(); if ( t(state) ) { D: state = detect(sample); } else { /* ... */ } }

Dynamic condition (t(state)) represented by filter Filter access relation(s): access to (virtual) array representing condition

D(i) → (S0(i) → t0 filter array (i))

Filter value relation: values of filter array elements for which statement is executed

D(i) → (1) | i ≥ 0 S0: t0 = t(state);

slide-28
SLIDE 28

Dynamic Conditions January 21, 2013 13 / 43

Representing Generic Dynamic Conditions

while (1) { sample = radioFrontend(); if ( t(state) ) { D: state = detect(sample); } else { /* ... */ } }

Dynamic condition (t(state)) represented by filter Filter access relation(s): access to (virtual) array representing condition

D(i) → (S0 statement writing to filter array (i) → t0 filter array (i))

Filter value relation: values of filter array elements for which statement is executed

D(i) → (1) | i ≥ 0 S0: t0 = t(state);

slide-29
SLIDE 29

Dynamic Conditions January 21, 2013 13 / 43

Representing Generic Dynamic Conditions

while (1) { sample = radioFrontend(); if ( t(state) ) { D: state = detect(sample); } else { /* ... */ } }

Dynamic condition (t(state)) represented by filter Filter access relation(s): access to (virtual) array representing condition

D statement reading from filter array (i) → (S0 statement writing to filter array (i) → t0 filter array (i))

Filter value relation: values of filter array elements for which statement is executed

D(i) → (1) | i ≥ 0 S0: t0 = t(state);

slide-30
SLIDE 30

Dynamic Conditions January 21, 2013 14 / 43

Representing Locally Static Affine Conditions

N1: n = f(); for (int k = 0; k < 100; ++k) { M: m = g(); for (int i = 0; i < m; ++i) for (int j = 0; j < n; ++j) A: a[j][i] = g(); N2: n = f(); }

Values of m and n not changed inside i and j loops

⇒ locally static affine loop conditions

slide-31
SLIDE 31

Dynamic Conditions January 21, 2013 14 / 43

Representing Locally Static Affine Conditions

N1: n = f(); for (int k = 0; k < 100; ++k) { M: m = g(); for (int i = 0; i < m; ++i) for (int j = 0; j < n; ++j) A: a[j][i] = g(); N2: n = f(); }

Values of m and n not changed inside i and j loops

⇒ locally static affine loop conditions

Filter access relations:

A(k, i, j) → (M(k) → m()) A(0, i, j) → (N1() → n()) ∪ A(k, i, j) → (N2(k − 1) → n()) | k ≥ 1

Filter value relation:

{ A(k, i, j) → (m, n) | 0 ≤ k ≤ 99 ∧ 0 ≤ i < m ∧ 0 ≤ j < n }

Note: filter access relations exploit (static) dataflow analysis on m and n

slide-32
SLIDE 32

Parametrization January 21, 2013 15 / 43

Outline

1

Motivation General Motivation Our Motivation

2

Array Dataflow Analysis Standard Fuzzy On Demand Parametric

3

Dynamic Conditions

4

Parametrization Overview Representation Introduction Additional Constraints

5

Related Work

6

Experimental Results

7

Conclusion

slide-33
SLIDE 33

Parametrization Overview January 21, 2013 16 / 43

Overview

Dataflow analysis performed for each read access (sink) separately Potential sources considered from closest to furthest

◮ number of shared loop iterators ℓ ◮ textual order

For each lexmax operation

◮ is it possible for potential source not to execute when sink is executed?

(based on filters)

◮ if so, parametrize lexmax problem

slide-34
SLIDE 34

Parametrization Representation January 21, 2013 17 / 43

Parametrization

state = 0; while (1) { sample = radioFrontend(); if (t( state )) { D: state = detect(sample); } else { C: decode(sample , &state, &value0); value1 = processSample0(value0); processSample1(value1); } }

slide-35
SLIDE 35

Parametrization Representation January 21, 2013 17 / 43

Parametrization

state = 0; while (1) { sample = radioFrontend(); if (t( state )) { D: state = detect(sample); } else { C: decode(sample , &state, &value0); value1 = processSample0(value0); processSample1(value1); } }

sink C potential source P

slide-36
SLIDE 36

Parametrization Representation January 21, 2013 17 / 43

Parametrization

state = 0; while (1) { sample = radioFrontend(); if (t( state )) { D: state = detect(sample); } else { C: decode(sample , &state, &value0); value1 = processSample0(value0); processSample1(value1); } }

Memory based dependences: Dmem

C,P = S0(i) → D(i′) | 0 ≤ i′ < i

At ℓ = 1: M = Dmem

C,P ∩ S0(i) → D(i) = ∅

At ℓ = 0: M = S0(i) → D(i′) | 0 ≤ i′ < i Potential source D(i′) may not have executed even if sink S0(i) is executed

⇒ parametrization required

sink C potential source P

slide-37
SLIDE 37

Parametrization Representation January 21, 2013 18 / 43

Parameter Representation

Original: M = S0(i) → D(i′) | 0 ≤ i′ < i After parameter introduction: M′ =

  • S0(i) → D(λP

C(i)) | 0 ≤ λP C(i) < i ∧ βP C(i) = 1

  • ⇒ lexmax M′ = M′
slide-38
SLIDE 38

Parametrization Representation January 21, 2013 18 / 43

Parameter Representation

Original: M = S0(i) → D(i′) | 0 ≤ i′ < i After parameter introduction: M′ =

  • S0(i) → D(λP

C(i)) | 0 ≤ λP C(i) < i ∧ βP C(i) = 1

  • ⇒ lexmax M′ = M′

Meaning of the parameters:

λP

C(k): last executed iteration of Dmem C,P (k)

βP

C(k): any iteration of Dmem C,P (k) is executed

Note: FADA introduces separate set of parameters for each lexmax Note: λP

C(k) and βP C(k) depend on k, but dependence can be kept implicit

⇒ λP

C and βP C

slide-39
SLIDE 39

Parametrization Introduction January 21, 2013 19 / 43

Introducing as few Parameters as possible

In principle, the number of elements in λ is equal to the number of iterators However, in many cases, we can avoid introducing some of those elements

slide-40
SLIDE 40

Parametrization Introduction January 21, 2013 19 / 43

Introducing as few Parameters as possible

In principle, the number of elements in λ is equal to the number of iterators However, in many cases, we can avoid introducing some of those elements dimensions inside innermost condition that is not static affine

slide-41
SLIDE 41

Parametrization Introduction January 21, 2013 19 / 43

Introducing as few Parameters as possible

In principle, the number of elements in λ is equal to the number of iterators However, in many cases, we can avoid introducing some of those elements dimensions inside innermost condition that is not static affine

for (i = 0; i < 100; ++i) if (t()) for (j = 0; j < 100; ++j) A: a = t(); B: b = a;

M = B() → A(i, j) | 0 ≤ i, j < 100

slide-42
SLIDE 42

Parametrization Introduction January 21, 2013 19 / 43

Introducing as few Parameters as possible

In principle, the number of elements in λ is equal to the number of iterators However, in many cases, we can avoid introducing some of those elements dimensions inside innermost condition that is not static affine

for (i = 0; i < 100; ++i) if (t()) for (j = 0; j < 100; ++j) A: a = t(); B: b = a;

M = B() → A(i, j) | 0 ≤ i, j < 100 M′ = B() → A(λ0, j) | 0 ≤ λ0, j < 100 ∧ β = 1

slide-43
SLIDE 43

Parametrization Introduction January 21, 2013 19 / 43

Introducing as few Parameters as possible

In principle, the number of elements in λ is equal to the number of iterators However, in many cases, we can avoid introducing some of those elements dimensions inside innermost condition that is not static affine

for (i = 0; i < 100; ++i) if (t()) for (j = 0; j < 100; ++j) A: a = t(); B: b = a;

M = B() → A(i, j) | 0 ≤ i, j < 100 M′ = B() → A(λ0, j) | 0 ≤ λ0, j < 100 ∧ β = 1

lexmax M′ = B() → A(λ0, 99) | 0 ≤ λ0 < 100 ∧ β = 1

slide-44
SLIDE 44

Parametrization Introduction January 21, 2013 19 / 43

Introducing as few Parameters as possible

In principle, the number of elements in λ is equal to the number of iterators However, in many cases, we can avoid introducing some of those elements dimensions inside innermost condition that is not static affine dimensions that can only attain a single value (for a given value of k)

slide-45
SLIDE 45

Parametrization Introduction January 21, 2013 20 / 43

Introducing as few Parameters as possible

Dimensions that can only attain a single value

for (int k = 0; k < 100; ++k) { N: N = f(); M: M = g(); for (int i = 0; i < N; ++i) for (int j = 0; j < M; ++j) A: a[i][j] = i + j; for (int i = 0; i < N; ++i) for (int j = 0; j < M; ++j) H: h(i, j, a[i][j]); }

Dmem

H,A

= H(k, i, j) → A(k ′, i, j) | k ′ ≤ k λ1(k, i, j) = i λ2(k, i, j) = j ⇒ no need to introduce λ1 and λ2

slide-46
SLIDE 46

Parametrization Introduction January 21, 2013 21 / 43

Introducing as few Parameters as possible

In principle, the number of elements in λ is equal to the number of iterators However, in many cases, we can avoid introducing some of those elements dimensions inside innermost condition that is not static affine dimensions that can only attain a single value (for a given value of k)

slide-47
SLIDE 47

Parametrization Introduction January 21, 2013 21 / 43

Introducing as few Parameters as possible

In principle, the number of elements in λ is equal to the number of iterators However, in many cases, we can avoid introducing some of those elements dimensions inside innermost condition that is not static affine dimensions that can only attain a single value (for a given value of k) dimensions before ℓ

slide-48
SLIDE 48

Parametrization Introduction January 21, 2013 22 / 43

Introducing as few Parameters as possible

Dimensions before ℓ

for (int k = 0; k < 100; ++k) { N: N = f(); M: M = g(); for (int i = 0; i < N; ++i) for (int j = 0; j < M; ++j) A: a[i][j] = i + j; for (int i = 0; i < N; ++i) for (int j = 0; j < M; ++j) H: h(i, j, a[i][j]); }

At ℓ = 1: M = H(k, i, j) → A(k, i, j)

⇒ no need to introduce λ0 (yet) at ℓ = 1

slide-49
SLIDE 49

Parametrization Introduction January 21, 2013 22 / 43

Introducing as few Parameters as possible

Dimensions before ℓ

for (int k = 0; k < 100; ++k) { N: N = f(); M: M = g(); for (int i = 0; i < N; ++i) for (int j = 0; j < M; ++j) A: a[i][j] = i + j; for (int i = 0; i < N; ++i) for (int j = 0; j < M; ++j) H: h(i, j, a[i][j]); }

At ℓ = 1: M = H(k, i, j) → A(k, i, j)

⇒ no need to introduce λ0 (yet) at ℓ = 1

Note: all sinks are accounted for at ℓ = 1

⇒ no need to consider ℓ = 0 and λ0 not needed at all

slide-50
SLIDE 50

Parametrization Introduction January 21, 2013 23 / 43

Introducing as few Parameters as possible

In principle, the number of elements in λ is equal to the number of iterators However, in many cases, we can avoid introducing some of those elements dimensions inside innermost condition that is not static affine dimensions that can only attain a single value (for a given value of k) dimensions before ℓ

slide-51
SLIDE 51

Parametrization Introduction January 21, 2013 23 / 43

Introducing as few Parameters as possible

In principle, the number of elements in λ is equal to the number of iterators However, in many cases, we can avoid introducing some of those elements dimensions inside innermost condition that is not static affine dimensions that can only attain a single value (for a given value of k) dimensions before ℓ

⇒ replace β by σ: the number of implicitly equal shared iterators β = 1 → σ ≥ ℓ β = 0 → σ < ℓ

slide-52
SLIDE 52

Parametrization Introduction January 21, 2013 23 / 43

Introducing as few Parameters as possible

In principle, the number of elements in λ is equal to the number of iterators However, in many cases, we can avoid introducing some of those elements dimensions inside innermost condition that is not static affine dimensions that can only attain a single value (for a given value of k) dimensions before ℓ

⇒ replace β by σ: the number of implicitly equal shared iterators β = 1 → σ ≥ ℓ β = 0 → σ < ℓ

◮ when moving to ℓ − 1 ⋆ introduce additional parameter λℓ−1 (if needed) ⋆ make implicit equality explicit ◮ at the end of the dataflow analysis

σ ≥ ℓ≤ → β = 1 σ < ℓ≤ → β = 0 (ℓ≤: smallest ℓ for which parametrization was applied) λ(k) and β(k) now refer to last execution of D(k) (D: result of projecting out parameters from final dataflow relation)

slide-53
SLIDE 53

Parametrization Introduction January 21, 2013 24 / 43

When to Introduce Parameters

Sink C Potential source P Subset of sink iteration U Mapping to potential source iterations M Computing

(U′, D) = lexmax

U

M

slide-54
SLIDE 54

Parametrization Introduction January 21, 2013 24 / 43

When to Introduce Parameters

Sink C Potential source P Subset of sink iteration U Mapping to potential source iterations M Computing

(U′, D) = lexmax

U

M

1

No filter on source

⇒ stop (no parametrization required)

slide-55
SLIDE 55

Parametrization Introduction January 21, 2013 24 / 43

When to Introduce Parameters

Sink C Potential source P Subset of sink iteration U Mapping to potential source iterations M Computing

(U′, D) = lexmax

U

M

1

No filter on source

⇒ stop (no parametrization required)

2

Let F be the filter on the sink

3

Filter on source contradicts F

⇒ replace M by empty relation and stop

slide-56
SLIDE 56

Parametrization Introduction January 21, 2013 25 / 43

Filter on source contradicts F

while (1) { N: n = f(); a = g(); if (n < 100) H: a = h(); if (n > 200) T: t( a ); } ℓ = 1

Potential source filter access relation

  • H(i) → (N(i) → n)
  • Potential source filter value relation
  • H(i) → (n) | i ≥ 0 ∧ n < 100
  • Sink filter access relation
  • T(i) → (N(i) → n)
  • Sink filter value relation
  • T(i) → (n) | i ≥ 0 ∧ n > 200
  • potential source

sink

slide-57
SLIDE 57

Parametrization Introduction January 21, 2013 25 / 43

Filter on source contradicts F

while (1) { N: n = f(); a = g(); if (n < 100) H: a = h(); if (n > 200) T: t( a ); } ℓ = 1

Potential source filter access relation

  • H(i) → (N(i) → n)
  • Potential source filter value relation
  • H(i) → (n) | i ≥ 0 ∧ n < 100
  • Sink filter access relation
  • T(i) → (N(i) → n)
  • Sink filter value relation
  • T(i) → (n) | i ≥ 0 ∧ n > 200
  • potential source

sink same filter element

slide-58
SLIDE 58

Parametrization Introduction January 21, 2013 25 / 43

Filter on source contradicts F

while (1) { N: n = f(); a = g(); if (n < 100) H: a = h(); if (n > 200) T: t( a ); } ℓ = 1

Potential source filter access relation

  • H(i) → (N(i) → n)
  • Potential source filter value relation
  • H(i) → (n) | i ≥ 0 ∧ n < 100
  • Sink filter access relation
  • T(i) → (N(i) → n)
  • Sink filter value relation
  • T(i) → (n) | i ≥ 0 ∧ n > 200
  • potential source

sink same filter element contradiction

slide-59
SLIDE 59

Parametrization Introduction January 21, 2013 26 / 43

When to Introduce Parameters

Sink C Potential source P Subset of sink iteration U Mapping to potential source iterations M Computing

(U′, D) = lexmax

U

M

1

No filter on source

⇒ stop (no parametrization required)

2

Let F be the filter on the sink

3

Filter on source contradicts F

⇒ replace M by empty relation and stop

slide-60
SLIDE 60

Parametrization Introduction January 21, 2013 26 / 43

When to Introduce Parameters

Sink C Potential source P Subset of sink iteration U Mapping to potential source iterations M Computing

(U′, D) = lexmax

U

M

1

No filter on source

⇒ stop (no parametrization required)

2

Let F be the filter on the sink

3

Filter on source contradicts F

⇒ replace M by empty relation and stop

4

Let F′ be equal to F updated with information from other sources

5

Filter on source contradicts F′

⇒ replace M by empty relation and stop

slide-61
SLIDE 61

Parametrization Introduction January 21, 2013 27 / 43

Filter on source contradicts F′

N: n = f(); if (n < 100) H: a = h(); if (n < 200) H2: a = h2(); T: t( a ); } lexmax

U

M M = T() → H() U =

  • T() | σH2 < 0
  • potential source

sink

slide-62
SLIDE 62

Parametrization Introduction January 21, 2013 27 / 43

Filter on source contradicts F′

N: n = f(); if (n < 100) H: a = h(); if (n < 200) H2: a = h2(); T: t( a ); } lexmax

U

M M = T() → H() U =

  • T() | σH2 < 0
  • potential source

sink

H2 not executed

slide-63
SLIDE 63

Parametrization Introduction January 21, 2013 27 / 43

Filter on source contradicts F′

N: n = f(); if (n < 100) H: a = h(); if (n < 200) H2: a = h2(); T: t( a ); } lexmax

U

M M = T() → H() U =

  • T() | σH2 < 0
  • Updated sink filter access relation
  • T(i) → (N(i) → n)
  • Updated sink filter value relation
  • T(i) → (n) | i ≥ 0 ∧ n ≥ 200
  • potential source

sink

H2 not executed

slide-64
SLIDE 64

Parametrization Introduction January 21, 2013 28 / 43

When to Introduce Parameters

Sink C Potential source P Subset of sink iteration U Mapping to potential source iterations M Computing

(U′, D) = lexmax

U

M

1

No filter on source

⇒ stop (no parametrization required)

2

Let F be the filter on the sink

3

Filter on source contradicts F

⇒ replace M by empty relation and stop

4

Let F′ be equal to F updated with information from other sources

5

Filter on source contradicts F′

⇒ replace M by empty relation and stop

slide-65
SLIDE 65

Parametrization Introduction January 21, 2013 28 / 43

When to Introduce Parameters

Sink C Potential source P Subset of sink iteration U Mapping to potential source iterations M Computing

(U′, D) = lexmax

U

M

1

No filter on source

⇒ stop (no parametrization required)

2

Let F be the filter on the sink

3

Filter on source contradicts F

⇒ replace M by empty relation and stop

4

Let F′ be equal to F updated with information from other sources

5

Filter on source contradicts F′

⇒ replace M by empty relation and stop

6

Filter on source implied by F

⇒ stop (no parametrization required)

slide-66
SLIDE 66

Parametrization Introduction January 21, 2013 29 / 43

Filter on source implied by F

while (1) { N: n = f(); a = g(); if (n < 200) H: a = h(); if (n < 100) T: t( a ); } ℓ = 1

Potential source filter access relation

  • H(i) → (N(i) → n)
  • Potential source filter value relation
  • H(i) → (n) | i ≥ 0 ∧ n < 200
  • Sink filter access relation
  • T(i) → (N(i) → n)
  • Sink filter value relation
  • T(i) → (n) | i ≥ 0 ∧ n < 100
  • potential source

sink

slide-67
SLIDE 67

Parametrization Introduction January 21, 2013 30 / 43

When to Introduce Parameters

Sink C Potential source P Subset of sink iteration U Mapping to potential source iterations M Computing

(U′, D) = lexmax

U

M

1

No filter on source

⇒ stop (no parametrization required)

2

Let F be the filter on the sink

3

Filter on source contradicts F

⇒ replace M by empty relation and stop

4

Let F′ be equal to F updated with information from other sources

5

Filter on source contradicts F′

⇒ replace M by empty relation and stop

6

Filter on source implied by F

⇒ stop (no parametrization required)

slide-68
SLIDE 68

Parametrization Introduction January 21, 2013 30 / 43

When to Introduce Parameters

Sink C Potential source P Subset of sink iteration U Mapping to potential source iterations M Computing

(U′, D) = lexmax

U

M

1

No filter on source

⇒ stop (no parametrization required)

2

Let F be the filter on the sink

3

Filter on source contradicts F

⇒ replace M by empty relation and stop

4

Let F′ be equal to F updated with information from other sources

5

Filter on source contradicts F′

⇒ replace M by empty relation and stop

6

Filter on source implied by F

⇒ stop (no parametrization required)

7

Filter on source implied by F′

⇒ parametrize D and stop

slide-69
SLIDE 69

Parametrization Introduction January 21, 2013 31 / 43

Filter on source implied by F′

N: n = f(); if (n < 200) H: a = h(); if (n > 100) H2: a = h2(); T: t( a ); } lexmax

U

M M = T() → H() U =

  • T() | σH2 < 0
  • Updated sink filter access relation
  • T(i) → (N(i) → n)
  • Updated sink filter value relation
  • T(i) → (n) | i ≥ 0 ∧ n ≤ 100
  • potential source

sink

slide-70
SLIDE 70

Parametrization Introduction January 21, 2013 32 / 43

When to Introduce Parameters

Sink C Potential source P Subset of sink iteration U Mapping to potential source iterations M Computing

(U′, D) = lexmax

U

M

1

No filter on source

⇒ stop (no parametrization required)

2

Let F be the filter on the sink

3

Filter on source contradicts F

⇒ replace M by empty relation and stop

4

Let F′ be equal to F updated with information from other sources

5

Filter on source contradicts F′

⇒ replace M by empty relation and stop

6

Filter on source implied by F

⇒ stop (no parametrization required)

7

Filter on source implied by F′

⇒ parametrize D and stop

slide-71
SLIDE 71

Parametrization Introduction January 21, 2013 32 / 43

When to Introduce Parameters

Sink C Potential source P Subset of sink iteration U Mapping to potential source iterations M Computing

(U′, D) = lexmax

U

M

1

No filter on source

⇒ stop (no parametrization required)

2

Let F be the filter on the sink

3

Filter on source contradicts F

⇒ replace M by empty relation and stop

4

Let F′ be equal to F updated with information from other sources

5

Filter on source contradicts F′

⇒ replace M by empty relation and stop

6

Filter on source implied by F

⇒ stop (no parametrization required)

7

Filter on source implied by F′

⇒ parametrize D and stop

8

Parametrize M

slide-72
SLIDE 72

Parametrization Additional Constraints January 21, 2013 33 / 43

Additional Constraints on Parameters

Some source iterations are definitely executed

⇒ λ no later than definitely executed iterations

slide-73
SLIDE 73

Parametrization Additional Constraints January 21, 2013 33 / 43

Additional Constraints on Parameters

Some source iterations are definitely executed

⇒ λ no later than definitely executed iterations

Eliminate (some) conflicts with other parameters

state = 0; while (1) { sample = radioFrontend(); if (t( state )) { D: state = detect(sample); } else { C: decode(sample , &state, &value0); value1 = processSample0(value0); processSample1(value1); } } ⇒ λC

0(i) and λD 0(i) cannot both be smaller than i − 1

slide-74
SLIDE 74

Related Work January 21, 2013 34 / 43

Outline

1

Motivation General Motivation Our Motivation

2

Array Dataflow Analysis Standard Fuzzy On Demand Parametric

3

Dynamic Conditions

4

Parametrization Overview Representation Introduction Additional Constraints

5

Related Work

6

Experimental Results

7

Conclusion

slide-75
SLIDE 75

Related Work January 21, 2013 35 / 43

Interaction with Libraries

clang GMP isl NTL PolyLib pet barvinok isa iscc

IMPACT 2012 IMPACT 2011

isl: manipulates parametric affine sets and relations barvinok: counts elements in parametric affine sets and relations pet: extracts polyhedral model from clang AST isa: prototype tool set including

derivation of process networks (with On Demand Parametric ADA) equivalence checker

slide-76
SLIDE 76

Related Work January 21, 2013 35 / 43

Interaction with Libraries

clang GMP isl NTL PolyLib pet barvinok PPCG isa iscc

HiPEAC 2013 IMPACT 2012 IMPACT 2011

isl: manipulates parametric affine sets and relations barvinok: counts elements in parametric affine sets and relations pet: extracts polyhedral model from clang AST isa: prototype tool set including

derivation of process networks (with On Demand Parametric ADA) equivalence checker

PPCG: Polyhedral Parallel Code Generator

slide-77
SLIDE 77

Related Work January 21, 2013 36 / 43

Related Work

Fuzzy Array Dataflow Analysis

⇒ only known publicly available implementation: fadatool

Pugh et al. (1994) and Maslov (1995) produce approximate results Collard et al. (1999)

◮ handle unstructured programs ◮ only collect constraints ◮ assume Omega can solve the constraints, but it cannot

slide-78
SLIDE 78

Experimental Results January 21, 2013 37 / 43

Outline

1

Motivation General Motivation Our Motivation

2

Array Dataflow Analysis Standard Fuzzy On Demand Parametric

3

Dynamic Conditions

4

Parametrization Overview Representation Introduction Additional Constraints

5

Related Work

6

Experimental Results

7

Conclusion

slide-79
SLIDE 79

Experimental Results January 21, 2013 38 / 43

Experimental Results

input da fadatool fadatool -s time p d time p l time p l Example from paper 0.01s 5 0.01s 6 6 0.01s 6 6 Example from slides 0.01s 4 9 0.01s 6 16 incorrect fuzzy4 0.06s 3 9 0.02s 4 9 0.01s 9 for1 0.02s 2 3 0.01s 4 46 0.02s 2 3 for2 0.03s 2 3 0.09s 12 5k 0.04s 4 3 for3 0.04s 2 3 42s 24 1M 0.08s 6 3 for4 0.06s 2 3 0.16s 8 3 for5 0.08s 2 3 0.25s 10 3 for6 0.14s 2 3 0.42s 12 3 cascade if1 0.02s 2 3 0.01s 2 4 0.01s 2 4 cascade if2 0.02s 2 10 0.02s 4 52 0.02s 2 8 cascade if3 0.03s 2 22 0.03 6 723 0.36s 3 16 cascade if4 0.02s 2 10 0.17s 8 9k 1m 4 28 while1 0.01s 4 0.00s 1 4 0.01s 4 while2 0.03s 3 4 0.01s 5 6 incorrect if var 0.03s 4 3 0.01s 2 8 0.01s 2 4 if while 0.04s 2 14 0.01s 5 58 0.02s 4 58 if2 0.02s 2 2 0.46s 12 29k 0.04s 4 2

slide-80
SLIDE 80

Experimental Results January 21, 2013 38 / 43

Experimental Results

input da fadatool fadatool -s time p d time p l time p l Example from paper 0.01s 5 0.01s 6 6 0.01s 6 6 Example from slides 0.01s 4 9 0.01s 6 16 incorrect fuzzy4 0.06s 3 9 0.02s 4 9 0.01s 9 for1 0.02s 2 3 0.01s 4 46 0.02s 2 3 for2 0.03s 2 3 0.09s 12 5k 0.04s 4 3 for3 0.04s 2 3 42s 24 1M 0.08s 6 3 for4 0.06s 2 3 0.16s 8 3 for5 0.08s 2 3 0.25s 10 3 for6 0.14s 2 3 0.42s 12 3 cascade if1 0.02s 2 3 0.01s 2 4 0.01s 2 4 cascade if2 0.02s 2 10 0.02s 4 52 0.02s 2 8 cascade if3 0.03s 2 22 0.03 6 723 0.36s 3 16 cascade if4 0.02s 2 10 0.17s 8 9k 1m 4 28 while1 0.01s 4 0.00s 1 4 0.01s 4 while2 0.03s 3 4 0.01s 5 6 incorrect if var 0.03s 4 3 0.01s 2 8 0.01s 2 4 if while 0.04s 2 14 0.01s 5 58 0.02s 4 58 if2 0.02s 2 2 0.46s 12 29k 0.04s 4 2

slide-81
SLIDE 81

Experimental Results January 21, 2013 38 / 43

Experimental Results

input da fadatool fadatool -s time p d time p l time p l Example from paper 0.01s 5 0.01s 6 6 0.01s 6 6 Example from slides 0.01s 4 9 0.01s 6 16 incorrect fuzzy4 0.06s 3 9 0.02s 4 9 0.01s 9 for1 0.02s 2 3 0.01s 4 46 0.02s 2 3 for2 0.03s 2 3 0.09s 12 5k 0.04s 4 3 for3 0.04s 2 3 42s 24 1M 0.08s 6 3 for4 0.06s 2 3 0.16s 8 3 for5 0.08s 2 3 0.25s 10 3 for6 0.14s 2 3 0.42s 12 3 cascade if1 0.02s 2 3 0.01s 2 4 0.01s 2 4 cascade if2 0.02s 2 10 0.02s 4 52 0.02s 2 8 cascade if3 0.03s 2 22 0.03 6 723 0.36s 3 16 cascade if4 0.02s 2 10 0.17s 8 9k 1m 4 28 while1 0.01s 4 0.00s 1 4 0.01s 4 while2 0.03s 3 4 0.01s 5 6 incorrect if var 0.03s 4 3 0.01s 2 8 0.01s 2 4 if while 0.04s 2 14 0.01s 5 58 0.02s 4 58 if2 0.02s 2 2 0.46s 12 29k 0.04s 4 2

slide-82
SLIDE 82

Experimental Results January 21, 2013 39 / 43

Larger Example — Input

for (j = 1; j <= frame; j++) { initialize(frame, n_act, &scor, &act, &ps, cmp, &s, &n, &idx, &mixw_cb , &cmp_l, &n_act_l , &act_l, &scor_l) for (i = 0; i < n; ++i) { initFeatBuff(i, &feat_buff , &featbuf_l); copyFeat(&s, frame, i, idx, &s); mgau_dist(&s, frame, i, &featbuf_l , &s); hist_l = mgau_norm(&s, frame, i); if (mixw_cb >= 1) { if (cmp_l >= 1) get_scors_4b_all(&s, i, hist_l, &scor_l, &scor_l); else get_scors_4b(&s, i, hist_l, n_act_l , &act_l, &scor_l, &scor_l); } else { if (cmp_l >= 1) get_scors_8b_all(&s, i, hist_l, &scor_l, &scor_l); else get_scors_8b(&s, i, hist_l, n_act_l , &act_l, &scor_l, &scor_l); } write_scor(&scor_l, &scor_l); } }

slide-83
SLIDE 83

Experimental Results January 21, 2013 40 / 43

Larger Example — Dataflow Graph

initialize initFeatBuff n copyFeat idx n s mgau_dist n mgau_norm n get_scors_4b_all mixw_cb cmp_l scor_l n get_scors_4b mixw_cb cmp_l n_act_l act_l scor_l n get_scors_8b_all mixw_cb cmp_l scor_l n get_scors_8b mixw_cb cmp_l n_act_l act_l scor_l n write_scor n n featbuf_l n idx s s n s s s s s n hist_l hist_l hist_l hist_l n mixw_cbcmp_l scor_l beta_1 n mixw_cbcmp_ln_act_lact_l scor_l beta_2 n mixw_cbcmp_l scor_l beta_3 n mixw_cbcmp_ln_act_lact_l scor_l beta_4 scor_l scor_l scor_l scor_l n scor_l: 0scor_l: 0scor_l: 0

slide-84
SLIDE 84

Experimental Results January 21, 2013 41 / 43

Larger Example — (Partial) Process Network

initialize

  • ut_8ND_0
  • ut_7ND_0
  • ut_7ND_0
  • ut_7ND_0
  • ut_7ND_0
  • ut_7ND_0
  • ut_7ND_0
  • ut_7ND_0
  • ut_7ND_0
  • ut_7ND_0
  • ut_9ND_0
  • ut_9ND_0
  • ut_9ND_0
  • ut_9ND_0
  • ut_10ND_0
  • ut_10ND_0
  • ut_10ND_0
  • ut_10ND_0
  • ut_11ND_0
  • ut_11ND_0
  • ut_6ND_0
  • ut_12ND_0
  • ut_12ND_0
  • ut_13ND_0
  • ut_13ND_0
  • ut_13ND_0
  • ut_13ND_0

in_4ND_2 ED_0 in_0ND_1 ED_1 in_0ND_2 ED_2 in_0ND_3 ED_3 in_0ND_4 ED_4 in_0ND_5 ED_5 in_0ND_6 ED_6 in_0ND_7 ED_7 in_0ND_8 ED_8 in_0ND_9 ED_9 in_1ND_5 ED_10 in_1ND_6 ED_11 in_1ND_7 ED_12 in_1ND_8 ED_13 in_2ND_5 ED_14 in_2ND_6 ED_15 in_2ND_7 ED_16 in_2ND_8 ED_17 in_6ND_6 ED_23 in_6ND_8 ED_24 in_1ND_2 ED_26 in_7ND_6 ED_37 in_7ND_8 ED_38 in_6ND_5 ED_40 in_8ND_6 ED_42 in_6ND_7 ED_44 in_8ND_8 ED_46 initFeatBuff

  • ut_3ND_1

in_4ND_3 ED_35 copyFeat

  • ut_5ND_2

in_1ND_2 in_1ND_3 ED_28 mgau_dist

  • ut_5ND_3
  • ut_5ND_3
  • ut_5ND_3
  • ut_5ND_3
  • ut_5ND_3
  • ut_5ND_3

ED_27 in_1ND_4 ED_29 in_3ND_5 ED_30 in_3ND_6 ED_31 in_3ND_7 ED_32 in_3ND_8 ED_33 mgau_norm

  • ut_4ND_4
  • ut_4ND_4
  • ut_4ND_4
  • ut_4ND_4

in_5ND_5 ED_19 in_5ND_6 ED_20 in_5ND_7 ED_21 in_5ND_8 ED_22 get_scors_4b_all

  • ut_7ND_5

dc0_ND_5_b in_6ND_5 in_3ND_9 ED_48 dc0_ND_9_b CED_53 get_scors_4b

  • ut_9ND_6

dc0_ND_6_b in_8ND_6 in_4ND_9 ED_49 dc1_ND_9_b CED_54 get_scors_8b_all

  • ut_7ND_7

dc0_ND_7_b in_6ND_7 in_5ND_9 ED_50 dc2_ND_9_b CED_55 get_scors_8b

  • ut_9ND_8

dc0_ND_8_b in_8ND_8 in_1ND_9 ED_51 dc3_ND_9_b CED_56 write_scor

  • ut_2ND_9
  • ut_2ND_9
  • ut_2ND_9
  • ut_2ND_9

in_1ND_9 in_1ND_9 in_1ND_9 ED_41 ED_43 ED_45 ED_47

slide-85
SLIDE 85

Conclusion January 21, 2013 42 / 43

Outline

1

Motivation General Motivation Our Motivation

2

Array Dataflow Analysis Standard Fuzzy On Demand Parametric

3

Dynamic Conditions

4

Parametrization Overview Representation Introduction Additional Constraints

5

Related Work

6

Experimental Results

7

Conclusion

slide-86
SLIDE 86

Conclusion January 21, 2013 43 / 43

Conclusion

Conclusions Dynamic behavior represented using “filters” Exact, possibly parametric, dataflow analysis Prototype implementation in isa Similar to FADA, but

◮ Parameters have a different meaning ◮ Effect analyzed before parameters are introduced ◮ All computations are performed directly on affine sets and maps

Future work Tighter integration into pet