Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

These are the Lecture Slides of Program Optimization for Multi Core Architectures which includes Triangular Lower Limits, Multiple Loop Limits, Dependence System Solvers, Single Equation, Simple Test, Extreme Value Test etc.Key important points are: Data Dependence Analysis, Interprocedural Dataflow Analysis, Alias Computation, Data Flow Analysis, Presence of Procedure Calls, Data Dependence, Data Dependence Graph

Typology: Slides

2012/2013

Uploaded on 03/28/2013

ekanath
ekanath 🇮🇳

3.8

(4)

80 documents

1 / 10

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Objectives_template
file:///D|/...ary,%20Dr.%20Sanjeev%20K%20Aggrwal%20&%20Dr.%20Rajat%20Moona/Multi-core_Architecture/lecture%2031/31_1.htm[6/14/2012 12:10:49 PM]
Module 16: Data Flow Analysis in Presence of Procedure Calls
Lecture 31: Data Dependence Analysis
The Lecture Contains:
Interprocedural Dataflow Analysis
Alias Computation
Example
Data Flow Analysis in Presence of Procedure Calls
Data Dependence Analysis
Data Dependence
Data Dependence Graph
Basic Block Dependence
Data Dependence in Loops
Unroll the Loop
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download DATADE~2 and more Slides Computer Science in PDF only on Docsity!

Module 16: Data Flow Analysis in Presence of Procedure Calls

Lecture 31: Data Dependence Analysis

The Lecture Contains:

Interprocedural Dataflow Analysis

Alias Computation

Example

Data Flow Analysis in Presence of Procedure Calls

Data Dependence Analysis

Data Dependence

Data Dependence Graph

Basic Block Dependence

Data Dependence in Loops

Unroll the Loop

Module 16: Data Flow Analysis in Presence of Procedure Calls

Lecture 31: Data Dependence Analysis

We can relate in, out and transfer as follows

Consider following control flow graph

Suppose a is an array, c is and integer, and p and q are pointer. Initially

Out

In

out

In

out

in

in

out ={(P,a),(q,a),(q,c) in

out

Module 16: Data Flow Analysis in Presence of Procedure Calls

Lecture 31: Data Dependence Analysis

Data Flow Analysis in Presence of Procedure Calls

Change[p ] set of global variables and formal parameters of p that might be changed during an execution of p. Def[p ] set of formal parameters and global variables having explicit definition within p. A: { a | a is a global variable or formal of p, such that for some procedure q and integer i, p calls q with a as the ith actual parameter and ith formal of q is in change[q] } G: { g | g is a global in change[q] and p calls q }

Data Dependence Analysis

Used for instruction scheduling Used for data cache optimization Determines ordering relationship; a dependence between two statements constraints their execution order Control dependence: arises from control flow

S1: a = b+c S2: if a > 10 goto L S3: d = b*e S4: e = d+ S5: L1: d = e/

Data Dependence

Arises from flow of data between two statements Compiler must analyze programs to find constraints preventing the reordering of operations.

Consider: A = 0 B = A C = A + D D = 2

Moving (2) above (1):: Value of A in (2) changes Moving (4) above (3):: results in wrong value of D in (3)

Module 16: Data Flow Analysis in Presence of Procedure Calls

Lecture 31: Data Dependence Analysis

Three types of constraints:

Flow or True Dependence: When a variable is assigned or defined in one statement and used in subsequent statement Anti Dependence: When a variable is used in one statement and reassigned in subsequently executed statement Output Dependence: When a variable is assigned in one statement and reassigned in subsequent statement

Anti dependence and Output dependence arise from reuse of variable and are also called False dependence.

Flow dependence is inherent in computation and cannot be eliminated by renaming. Therefore it is also called True dependence.

Data Dependence Graph

Data structure used to depict dependency between statements.

Each statement represents a node in the graph Nodes are connected by directed edges

  1. When S2 is flow dependent on S1, it is denoted by S1 S2 or S1 S2 and represented by S1 → S
  2. When there is an anti-dependence from S1 to S2, it is denoted by S1 S2 or S1 S2 and represented by S1 → S
  3. When there is an output-dependence from S1 to S2, it is denoted by S1 S2 and represented by S1 → S

Module 16: Data Flow Analysis in Presence of Procedure Calls

Lecture 31: Data Dependence Analysis

Latency: delay required between initiation times of I 1 and I 2 minus execution time required for I (^1) before another instruction can start. For example, if two cycles must elapse between I 1 and I 2 then latency is 1. r2 ← r1 r3 ← r1+4 r4 ← r2 + r r5 ← r2 - 1

assume load has latency of 1; requires 2 cycles to finish.

Data Dependence in Loops

Each statement executed many times Dependence can flow from one statement to any other Dependence can flow to the same statement

for i = 2, 9 do x(i) = y(i) + z(i) S (^1) a(i) = x(i-1) + 1 S (^2) endfor S 1 → S (^2)

Module 16: Data Flow Analysis in Presence of Procedure Calls

Lecture 31: Data Dependence Analysis

do i = 1, N a(i) = b(i) c(i) = a(i) + b(i) e(i) = c(i+1) enddo

Unroll The Loop

do I = 1, N A = B(I) C(I) = A + B(I) E(I) = C(I+1) enddo

file:///D|/...ry,%20Dr.%20Sanjeev%20K%20Aggrwal%20&%20Dr.%20Rajat%20Moona/Multi-core_Architecture/lecture%2031/31_10.htm[6/14/2012 12:10:50 PM]

Module 16: Data Flow Analysis in Presence of Procedure Calls

Lecture 31: Data Dependence Analysis

Example:

do I = 1, 100 X( 2I+1 ) = .... ...... = X( 2I+4 ) enddo

S 1

S 2

Is there a dependence from S 1 to S 2? Coarse grain analysis: S 1 writes into X and S 2 reads from X. Therefore, S 1 → S 2 or S 1 S (^2) Fine grain analysis: Eqn: 2i 1 + 1 = 2i^2 + 4 has no integer solution Therefore, no dependence from S 1 to S (^2)

DO I = 1, 50

X(I) = ....

.... = X(I+50)

ENDDO

Fine grain analysis: Eqn. i 1 = i 2 + 50 has integer solution. However, no integer solution in the range 1 = i 1 = i 2 = 50 therefore, no dependence from S 1 to S (^2) If are general functions, then the problem is intractable. If are linear functions of loop index, then to test dependence we need to find values of two integers such that

which can be rewritten as

These are called Linear Diophantine Equations.