SlideShare a Scribd company logo
1 of 24
Iteration spaces
and
Affine array indexes
By
Vijayapriya P
II-MSc (CS)
Department of CS & IT
Nadar saraswathi college of arts & science
 Define iteration
 Constructing iteration spaces from nest loops
 Execution Order for Loop Nests
 Matrix Formulation of Inequalities
 Incorporating Symbolic Constants
 Controlling the Order of Execution
 Affine array indexes
 Affine bounds and indices
 Affine accesses
 Affine and Nonaffine accesses in practice
Topic includes
 The iteration space of a loop nest is defined to be all the
combinations of loop-index values in the nest.
there are three kinds of spaces in our transformation model
 iteration space
 data space
 processor space
 Each of the nested loops had a lower bound of 0 and an
upper bound of n — 1. loop nests, the upper and/or lower
bounds on one loop index can depend on the values of the
indexes of the outer loops.
Define iteration spaces
 The sort of loop nests that can be handled by the
techniques to be developed.
 Each loop has a single loop index, which we assume is
incremented by 1 at each iteration.
 That assumption is without loss of generality, since if the
incrementation is by integer c > 1,
we can always replace uses of the index i by uses of ci +
a for some positive or negative constant a, and then
increment i by 1 in the loop.
Constructing iteration spaces
from loop nests
 We can always replace uses of the index i by uses of ci+
a for some positive or negative constant a, and then
increment i by 1 in the loop. However, in more complicated, but
still quite realistic, loop nests, the upper and/or lower bounds on
one loop index can depend on the values of the indexes of the
outer loops.
For (i=2 ; i<=100; i=i+3)
Z[i]=0;
which increments i by 3 each time around the loop. The
effect is to set to 0 each of the elements Z[2], Z[5], Z [ 8 ] , . .
. , Z[98].
For (j=2; j<=32; j++)
Z [3*j+2]=0;
Substitute 3j + 2 for i. The lower limit i = 2 becomes j = 0
(just solve 3j + 2 = 2 for j ) , and the upper limit i < 100
becomes j < 32 (simplify 3j + 2 < 100 to get j < 32.67 and
round down because j has to be an integer).
For-loops in loop nests. A while-loop or repeat-loop can be
replaced by a for-loop if there is an index and upper and
lower bounds .
 Model this two-deep loop nest by the 2-dimensional
polyhedron . The two axes represent the values of the loop
Indexes i and j
 Index i can take on any integral value between 0 and 5;
index j can take on any integral value such that i < j < 7 .
 A sequential execution of a loop nest sweeps through
iterations in its iteration space in an ascending
lexicographic order.
 A vector i = I is lexicographically less
than another vector ,written , if and only if
there exists an m < min such that d
note that m=0 .
Execution order for loop nests
The iterations in a d-deep loop can be represented
mathematically as
fi in Zd j Bi + b 0g
Matrix formulation of inequalities
1. Z, as is conventional in mathematics, represents the
set of integers - positive, negative, and zero,
2. B is a d*d integer matrix,
3. b is an integer vector of length d, and
4. 0 is a vector of d 0's.
Matrix formulation of inequalities
The iterations in a d-deep loop can be represented
mathematically as. fi in Zd j Bi + b 0g
 To optimize a loop nest that involves certain variables
that are loop-invariant for all the loops in the nest. We call
such variables symbolic constants, but to describe the
boundaries of an iteration space we need to treat them as
variables and create an entry for them in the vector of loop
indexes.
i.e., The vector i in the general formulation of inequalities.
Incorporating symbolic constants
for(i=0;i<=n; i++)
{
…
}
This loop defines a one-dimensional iteration space,
with index i, bounded by i 0 and i ≤ n. Since n is a
symbolic constant.
Controlling the order of execution
 The linear inequalities extracted from the lower and
upper bounds of a loop body define a set of iterations over
a convex polyhedron. the representation assumes no
execution ordering between iterations within the iteration
space.
 The original program imposes one sequential order on
the iterations, which is the lexicographic order with respect
to the loop index variables ordered from the outermost to
the innermost.
projection
 Find the loop bounds of the outer loop index in a two-
deep loop nest by projecting the convex polyhedron
representing the iteration space onto the outer dimension of
the space.
 The projection of a polyhedron on a lower-dimensional
space is intuitively the shadow cast by the object onto that
space. The projection of the two-dimensional iteration space
 The algorithm to generate the loop bounds to iterate over
a convex polyhedron is straightforward. We compute the
loop bounds in order, from the innermost to the outer loops.
Algorithm : Computing bounds for a given order of variables.
INPUT : A convex polyhedron S over variables v1,... ,vn.
OUTPUT : A set of lower bounds L{ and upper bounds Ui
for each vi, expressed only in terms of the fj's, for j < i.
METHOD : The algorithm is described
Loop- Bounds generation
Changing Axes
 Sweeping the iteration space horizontally and vertically, as
discussed above, are just two of the most common ways of
visiting the iteration space. there are many other possibilities.
 There are many other iteration-traversal orders not handled
by this technique. For example, we may wish to visit all the
odd rows in an iteration space before we visit the even rows.
Affine array indexes
Affine array indexes
 The class of affine array accesses, where each array index is
Expressed as affine expression of loop indexes and symbolic
Constant. Affine function provide a succinct mapping from the
iteration. Space to the data space, making it easy to determine
which Iteration map to the same data or same cache line.
 The affine upper and lower bounds of a loop can be
Represented as a matrix-vector calculation , we can do the
Same for affine access functions.
Affine bounds and indices
 Assume loop bounds and array index expression are
Affine expression
A0+a1*i1+ …+ak * ik
 Each loop bound for loop index ik is an affine expression
Over the previous loop indices i1 to i(k-1). Each loop
index expression is a affine expression over all loop
indices.
Affine accesses
 The bounds of the loop are expressed as affine expressions
of the surrounding loop variables and symbolic constants.
 The index for each dimension of the array is also an affine
expression of surrounding loop variables and symbolic
constants.
Example
 Suppose i and j are loop index variables bounded by affine
expressions. Some examples of affine array accesses are Z[i],
Z[i + j + 1], Z[0], Z[i, i], and Z[2*i +1,3* j — 10].
If n is a symbolic constant for a loop nest, then Z[S * n, n — j]
is another example of an affine array access. However, Z[i * j]
and Z[n * j] are not affine accesses.
 Each affine array access can be described by two matrices and
two vectors. The first matrix-vector pair is the B and b that
describe the iteration space for the access, as in the inequality of
Equation .
 The second pair, which we usually refer to
as F and f, represent the function(s) of the loop-index variables
that produce the array index(es) used in the various dimensions
of the array access.
Formally, we represent an array access in a loop nest that
uses a vector of index variables i by the four-tuple T =
(F,f,B>b); it maps a vector i within the bounds
Bi+b>0
To the array element location
Fi+f
Also notice the third access, Y [j,j + 1], which, after matrix-
vector multiplication and addition, yields a pair of
functions, (J,j + 1). Finally, let us observe the fourth access
K[l,2] . This access is a constant, and unsurprisingly the
matrix F is all 0's. Thus, the vector of loop indexes, i, does
not appear in the access function.
Compiler Designing
Compiler Designing

More Related Content

What's hot

String Handling in c++
String Handling in c++String Handling in c++
String Handling in c++
Fahim Adil
 
Limits
LimitsLimits
Limits
sarcia
 

What's hot (20)

Limit and continuity
Limit and continuityLimit and continuity
Limit and continuity
 
A210106
A210106A210106
A210106
 
String Handling in c++
String Handling in c++String Handling in c++
String Handling in c++
 
SMU MCA SUMMER 2014 ASSIGNMENTS
SMU MCA SUMMER 2014 ASSIGNMENTSSMU MCA SUMMER 2014 ASSIGNMENTS
SMU MCA SUMMER 2014 ASSIGNMENTS
 
C pointers
C pointersC pointers
C pointers
 
String in programming language in c or c++
 String in programming language  in c or c++  String in programming language  in c or c++
String in programming language in c or c++
 
Boolean algebra
Boolean algebraBoolean algebra
Boolean algebra
 
Limits
LimitsLimits
Limits
 
Strings
StringsStrings
Strings
 
Pointers in C
Pointers in CPointers in C
Pointers in C
 
Pointers_c
Pointers_cPointers_c
Pointers_c
 
String.ppt
String.pptString.ppt
String.ppt
 
Ap review session continuity, differentiability and major theorems
Ap review session continuity, differentiability and major theoremsAp review session continuity, differentiability and major theorems
Ap review session continuity, differentiability and major theorems
 
String in c programming
String in c programmingString in c programming
String in c programming
 
Managing I/O & String function in C
Managing I/O & String function in CManaging I/O & String function in C
Managing I/O & String function in C
 
Very interesting C programming Technical Questions
Very interesting C programming Technical Questions Very interesting C programming Technical Questions
Very interesting C programming Technical Questions
 
Pointers
PointersPointers
Pointers
 
ppt on pointers
ppt on pointersppt on pointers
ppt on pointers
 
Fuzzy controler
Fuzzy controlerFuzzy controler
Fuzzy controler
 
Presentation on pointer.
Presentation on pointer.Presentation on pointer.
Presentation on pointer.
 

Similar to Compiler Designing

problems-and-exercises-in-integral-equations-krasnov-kiselev-makarenko.pdf
problems-and-exercises-in-integral-equations-krasnov-kiselev-makarenko.pdfproblems-and-exercises-in-integral-equations-krasnov-kiselev-makarenko.pdf
problems-and-exercises-in-integral-equations-krasnov-kiselev-makarenko.pdf
ShivamSharma340355
 
M1 unit v-jntuworld
M1 unit v-jntuworldM1 unit v-jntuworld
M1 unit v-jntuworld
mrecedu
 
elliptic-curves-modern
elliptic-curves-modernelliptic-curves-modern
elliptic-curves-modern
Eric Seifert
 
Signal Processing Introduction using Fourier Transforms
Signal Processing Introduction using Fourier TransformsSignal Processing Introduction using Fourier Transforms
Signal Processing Introduction using Fourier Transforms
Arvind Devaraj
 

Similar to Compiler Designing (20)

Complier Design
Complier DesignComplier Design
Complier Design
 
Affine Array Indexes
Affine Array IndexesAffine Array Indexes
Affine Array Indexes
 
Computer graphics unit 4th
Computer graphics unit 4thComputer graphics unit 4th
Computer graphics unit 4th
 
Affine array index
Affine array indexAffine array index
Affine array index
 
MULTI RESOLUTION LATTICE DISCRETE FOURIER TRANSFORM (MRL-DFT)
MULTI RESOLUTION LATTICE DISCRETE FOURIER TRANSFORM (MRL-DFT)MULTI RESOLUTION LATTICE DISCRETE FOURIER TRANSFORM (MRL-DFT)
MULTI RESOLUTION LATTICE DISCRETE FOURIER TRANSFORM (MRL-DFT)
 
Control chap7
Control chap7Control chap7
Control chap7
 
signal space analysis.ppt
signal space analysis.pptsignal space analysis.ppt
signal space analysis.ppt
 
problems-and-exercises-in-integral-equations-krasnov-kiselev-makarenko.pdf
problems-and-exercises-in-integral-equations-krasnov-kiselev-makarenko.pdfproblems-and-exercises-in-integral-equations-krasnov-kiselev-makarenko.pdf
problems-and-exercises-in-integral-equations-krasnov-kiselev-makarenko.pdf
 
M1 unit v-jntuworld
M1 unit v-jntuworldM1 unit v-jntuworld
M1 unit v-jntuworld
 
Design of sampled data control systems part 2. 6th lecture
Design of sampled data control systems part 2.  6th lectureDesign of sampled data control systems part 2.  6th lecture
Design of sampled data control systems part 2. 6th lecture
 
MC0082 –Theory of Computer Science
MC0082 –Theory of Computer ScienceMC0082 –Theory of Computer Science
MC0082 –Theory of Computer Science
 
Sp 3828 10.1007-2_f978-3-642-31265-6_20
Sp 3828 10.1007-2_f978-3-642-31265-6_20Sp 3828 10.1007-2_f978-3-642-31265-6_20
Sp 3828 10.1007-2_f978-3-642-31265-6_20
 
Vector Calculus.
Vector Calculus.Vector Calculus.
Vector Calculus.
 
elliptic-curves-modern
elliptic-curves-modernelliptic-curves-modern
elliptic-curves-modern
 
QB104541.pdf
QB104541.pdfQB104541.pdf
QB104541.pdf
 
Wk 6 part 2 non linearites and non linearization april 05
Wk 6 part 2 non linearites and non linearization april 05Wk 6 part 2 non linearites and non linearization april 05
Wk 6 part 2 non linearites and non linearization april 05
 
project report(1)
project report(1)project report(1)
project report(1)
 
Parenthesization.pptx
Parenthesization.pptxParenthesization.pptx
Parenthesization.pptx
 
Signal Processing Introduction using Fourier Transforms
Signal Processing Introduction using Fourier TransformsSignal Processing Introduction using Fourier Transforms
Signal Processing Introduction using Fourier Transforms
 
Programmable PN Sequence Generators
Programmable PN Sequence GeneratorsProgrammable PN Sequence Generators
Programmable PN Sequence Generators
 

Recently uploaded

%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 

Recently uploaded (20)

%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 

Compiler Designing

  • 1. Iteration spaces and Affine array indexes By Vijayapriya P II-MSc (CS) Department of CS & IT Nadar saraswathi college of arts & science
  • 2.  Define iteration  Constructing iteration spaces from nest loops  Execution Order for Loop Nests  Matrix Formulation of Inequalities  Incorporating Symbolic Constants  Controlling the Order of Execution  Affine array indexes  Affine bounds and indices  Affine accesses  Affine and Nonaffine accesses in practice Topic includes
  • 3.  The iteration space of a loop nest is defined to be all the combinations of loop-index values in the nest. there are three kinds of spaces in our transformation model  iteration space  data space  processor space  Each of the nested loops had a lower bound of 0 and an upper bound of n — 1. loop nests, the upper and/or lower bounds on one loop index can depend on the values of the indexes of the outer loops. Define iteration spaces
  • 4.  The sort of loop nests that can be handled by the techniques to be developed.  Each loop has a single loop index, which we assume is incremented by 1 at each iteration.  That assumption is without loss of generality, since if the incrementation is by integer c > 1, we can always replace uses of the index i by uses of ci + a for some positive or negative constant a, and then increment i by 1 in the loop. Constructing iteration spaces from loop nests
  • 5.  We can always replace uses of the index i by uses of ci+ a for some positive or negative constant a, and then increment i by 1 in the loop. However, in more complicated, but still quite realistic, loop nests, the upper and/or lower bounds on one loop index can depend on the values of the indexes of the outer loops. For (i=2 ; i<=100; i=i+3) Z[i]=0; which increments i by 3 each time around the loop. The effect is to set to 0 each of the elements Z[2], Z[5], Z [ 8 ] , . . . , Z[98].
  • 6. For (j=2; j<=32; j++) Z [3*j+2]=0; Substitute 3j + 2 for i. The lower limit i = 2 becomes j = 0 (just solve 3j + 2 = 2 for j ) , and the upper limit i < 100 becomes j < 32 (simplify 3j + 2 < 100 to get j < 32.67 and round down because j has to be an integer). For-loops in loop nests. A while-loop or repeat-loop can be replaced by a for-loop if there is an index and upper and lower bounds .
  • 7.  Model this two-deep loop nest by the 2-dimensional polyhedron . The two axes represent the values of the loop Indexes i and j  Index i can take on any integral value between 0 and 5; index j can take on any integral value such that i < j < 7 .
  • 8.  A sequential execution of a loop nest sweeps through iterations in its iteration space in an ascending lexicographic order.  A vector i = I is lexicographically less than another vector ,written , if and only if there exists an m < min such that d note that m=0 . Execution order for loop nests
  • 9. The iterations in a d-deep loop can be represented mathematically as fi in Zd j Bi + b 0g Matrix formulation of inequalities
  • 10. 1. Z, as is conventional in mathematics, represents the set of integers - positive, negative, and zero, 2. B is a d*d integer matrix, 3. b is an integer vector of length d, and 4. 0 is a vector of d 0's. Matrix formulation of inequalities The iterations in a d-deep loop can be represented mathematically as. fi in Zd j Bi + b 0g
  • 11.  To optimize a loop nest that involves certain variables that are loop-invariant for all the loops in the nest. We call such variables symbolic constants, but to describe the boundaries of an iteration space we need to treat them as variables and create an entry for them in the vector of loop indexes. i.e., The vector i in the general formulation of inequalities. Incorporating symbolic constants
  • 12. for(i=0;i<=n; i++) { … } This loop defines a one-dimensional iteration space, with index i, bounded by i 0 and i ≤ n. Since n is a symbolic constant.
  • 13. Controlling the order of execution  The linear inequalities extracted from the lower and upper bounds of a loop body define a set of iterations over a convex polyhedron. the representation assumes no execution ordering between iterations within the iteration space.  The original program imposes one sequential order on the iterations, which is the lexicographic order with respect to the loop index variables ordered from the outermost to the innermost.
  • 14. projection  Find the loop bounds of the outer loop index in a two- deep loop nest by projecting the convex polyhedron representing the iteration space onto the outer dimension of the space.  The projection of a polyhedron on a lower-dimensional space is intuitively the shadow cast by the object onto that space. The projection of the two-dimensional iteration space
  • 15.  The algorithm to generate the loop bounds to iterate over a convex polyhedron is straightforward. We compute the loop bounds in order, from the innermost to the outer loops. Algorithm : Computing bounds for a given order of variables. INPUT : A convex polyhedron S over variables v1,... ,vn. OUTPUT : A set of lower bounds L{ and upper bounds Ui for each vi, expressed only in terms of the fj's, for j < i. METHOD : The algorithm is described Loop- Bounds generation
  • 16. Changing Axes  Sweeping the iteration space horizontally and vertically, as discussed above, are just two of the most common ways of visiting the iteration space. there are many other possibilities.  There are many other iteration-traversal orders not handled by this technique. For example, we may wish to visit all the odd rows in an iteration space before we visit the even rows.
  • 18. Affine array indexes  The class of affine array accesses, where each array index is Expressed as affine expression of loop indexes and symbolic Constant. Affine function provide a succinct mapping from the iteration. Space to the data space, making it easy to determine which Iteration map to the same data or same cache line.  The affine upper and lower bounds of a loop can be Represented as a matrix-vector calculation , we can do the Same for affine access functions.
  • 19. Affine bounds and indices  Assume loop bounds and array index expression are Affine expression A0+a1*i1+ …+ak * ik  Each loop bound for loop index ik is an affine expression Over the previous loop indices i1 to i(k-1). Each loop index expression is a affine expression over all loop indices.
  • 20. Affine accesses  The bounds of the loop are expressed as affine expressions of the surrounding loop variables and symbolic constants.  The index for each dimension of the array is also an affine expression of surrounding loop variables and symbolic constants. Example  Suppose i and j are loop index variables bounded by affine expressions. Some examples of affine array accesses are Z[i], Z[i + j + 1], Z[0], Z[i, i], and Z[2*i +1,3* j — 10].
  • 21. If n is a symbolic constant for a loop nest, then Z[S * n, n — j] is another example of an affine array access. However, Z[i * j] and Z[n * j] are not affine accesses.  Each affine array access can be described by two matrices and two vectors. The first matrix-vector pair is the B and b that describe the iteration space for the access, as in the inequality of Equation .  The second pair, which we usually refer to as F and f, represent the function(s) of the loop-index variables that produce the array index(es) used in the various dimensions of the array access.
  • 22. Formally, we represent an array access in a loop nest that uses a vector of index variables i by the four-tuple T = (F,f,B>b); it maps a vector i within the bounds Bi+b>0 To the array element location Fi+f Also notice the third access, Y [j,j + 1], which, after matrix- vector multiplication and addition, yields a pair of functions, (J,j + 1). Finally, let us observe the fourth access K[l,2] . This access is a constant, and unsurprisingly the matrix F is all 0's. Thus, the vector of loop indexes, i, does not appear in the access function.