SlideShare a Scribd company logo
1 of 11
NADAR SARASWATHI COLLEGE OF ARTS AND SCIENCE
AFFINE ARRAY INDEXES
s
Submitted by,
S.Vijayalakshmi.
Affine Array Indexes
 The focus of this chapter is on the class of affine array accesses, where
each array index is expressed as affine expressions of loop indexes and
symbolic constants.
 Affine functions provide a succinct mapping from the iteration space
to the data space, making it easy to determine which iterations map to
the same data or same cache line.
 Just as 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.
 Once placed in the matrix-vector form, we can apply standard linear
algebra to find pertinent information such as the dimensions of the data
accessed, and which iterations refer to the same data.
Affine Accesses
We say that an array access in a loop is affine if
1. The bounds of the loop are expressed as affine expressions of the
surrounding loop variables and symbolic constants, and
2. The index for each dimension of the array is also an affine
expression of surrounding loop variables and symbolic constants.
E x a m p l e
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
E x a m p l e :
some common array accesses, expressed in matrix notation. The two
loop indexes are i and j, and these form the vector i. Also, X, Y, and Z
are arrays with 1, 2, and 3 dimensions, respectively. The first access,
A[i - 1], is represented by a 1 x 2 matrix F and a vector f of length 1.
Notice that when we perform the matrix-vector multiplication and add
in the vector f, we are left with a single function, which is exactly the
formula for the access to the one-dimensional array X. Also notice the
third access, Y[j,j + 1], which, after matrix-vector multiplication and
addition, yields a pair of functions, (J, j + 1). These are the indexes of
the two dimensions of the array access.
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.
ACCESS AFFINE EXPRESSION
X [ i - 1 ] [ 1 0 ] . i
j .
+ 1 - 1 ]
Y [ i , j ] " 1 0 ‘ 0 1 I
_
j .
+ " 0 "
0
Y [ j , j + 1 ] " 0 1 ‘ 0 1 i-j + “0”1
Y [ l , 2 ] " 0 0 “ 0 0 i .
j .
+ " 1 "
2
" 0 0 " " 1 '
Z [ l , i , 2 * i + j ] 1 0
2 1
_
j
_
+ 0
0
Affine and Non-affine Accesses in Practice
There are certain common data access patterns found in numerical
programs that fail to be affine. Programs involving sparse matrices are
one important
example: One popular representation for sparse matrices is to store
only the nonzero elements in a vector, and auxiliary index arrays are
used to mark where a row starts and which columns contain non-zeros.
Indirect array accesses are used in accessing such data. An access of
this type, such as is a non-affine access to the array X. If the sparsity is
regular, as in banded matrices having non-zeros only around the
diagonal, then dense arrays can be used to represent the subregions
with nonzero elements. In that case, accesses may be affine.
Another common example of nonaffine accesses is linearized arrays.
Programmers sometimes use a linear array to store a logically
multidimensional object. One reason why this is the case is that the
dimensions of the array may not be known at compile time. An access
that would normally look like Z[i,j] would be expressed as Z[i * n + j],
which is a quadratic function. We can convert the linear access into a
multidimensional access if every access can be decomposed into
separate dimensions with the guarantee that none of the components
exceeds its bound. Finally, we note that induction-variable analyses
can be used to convert some nonaffine accesses into affine ones,
E x a m p l e
We can rewrite the code
j = n;
f o r (i = 0; i <= n; i++) {
Z [ j] = 0;
j = J+2;
}
as
j = n;
f o r ( i = 0; i <= n; i++) {
Z[n+2*i] = 0;
}
to make the access to matrix Z affine. •
THE END

More Related Content

What's hot

Classical relations and fuzzy relations
Classical relations and fuzzy relationsClassical relations and fuzzy relations
Classical relations and fuzzy relations
Baran Kaynak
 
Stuart russell and peter norvig artificial intelligence - a modern approach...
Stuart russell and peter norvig   artificial intelligence - a modern approach...Stuart russell and peter norvig   artificial intelligence - a modern approach...
Stuart russell and peter norvig artificial intelligence - a modern approach...
Lê Anh Đạt
 
Hardware and Software parallelism
Hardware and Software parallelismHardware and Software parallelism
Hardware and Software parallelism
prashantdahake
 
Structures for discrete time systems
Structures for discrete time systemsStructures for discrete time systems
Structures for discrete time systems
veda C
 

What's hot (20)

Digital Image Processing - Image Restoration
Digital Image Processing - Image RestorationDigital Image Processing - Image Restoration
Digital Image Processing - Image Restoration
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Basics of signals data communication
Basics of signals data communicationBasics of signals data communication
Basics of signals data communication
 
Classical relations and fuzzy relations
Classical relations and fuzzy relationsClassical relations and fuzzy relations
Classical relations and fuzzy relations
 
Mc culloch pitts neuron
Mc culloch pitts neuronMc culloch pitts neuron
Mc culloch pitts neuron
 
Backtracking-N Queens Problem-Graph Coloring-Hamiltonian cycle
Backtracking-N Queens Problem-Graph Coloring-Hamiltonian cycleBacktracking-N Queens Problem-Graph Coloring-Hamiltonian cycle
Backtracking-N Queens Problem-Graph Coloring-Hamiltonian cycle
 
Stuart russell and peter norvig artificial intelligence - a modern approach...
Stuart russell and peter norvig   artificial intelligence - a modern approach...Stuart russell and peter norvig   artificial intelligence - a modern approach...
Stuart russell and peter norvig artificial intelligence - a modern approach...
 
Introduction to datastructure and algorithm
Introduction to datastructure and algorithmIntroduction to datastructure and algorithm
Introduction to datastructure and algorithm
 
Image restoration and enhancement #2
Image restoration and enhancement #2 Image restoration and enhancement #2
Image restoration and enhancement #2
 
Activation function
Activation functionActivation function
Activation function
 
program partitioning and scheduling IN Advanced Computer Architecture
program partitioning and scheduling  IN Advanced Computer Architectureprogram partitioning and scheduling  IN Advanced Computer Architecture
program partitioning and scheduling IN Advanced Computer Architecture
 
Instruction Level Parallelism Compiler optimization Techniques Anna Universit...
Instruction Level Parallelism Compiler optimization Techniques Anna Universit...Instruction Level Parallelism Compiler optimization Techniques Anna Universit...
Instruction Level Parallelism Compiler optimization Techniques Anna Universit...
 
backpropagation in neural networks
backpropagation in neural networksbackpropagation in neural networks
backpropagation in neural networks
 
Hardware and Software parallelism
Hardware and Software parallelismHardware and Software parallelism
Hardware and Software parallelism
 
Routing
RoutingRouting
Routing
 
Image Recontruction
Image RecontructionImage Recontruction
Image Recontruction
 
Digital Image Processing - Image Compression
Digital Image Processing - Image CompressionDigital Image Processing - Image Compression
Digital Image Processing - Image Compression
 
Multithreading: Exploiting Thread-Level Parallelism to Improve Uniprocessor ...
Multithreading: Exploiting Thread-Level  Parallelism to Improve Uniprocessor ...Multithreading: Exploiting Thread-Level  Parallelism to Improve Uniprocessor ...
Multithreading: Exploiting Thread-Level Parallelism to Improve Uniprocessor ...
 
Structures for discrete time systems
Structures for discrete time systemsStructures for discrete time systems
Structures for discrete time systems
 
Image processing (Signal Processing)
Image processing (Signal Processing)Image processing (Signal Processing)
Image processing (Signal Processing)
 

Similar to Affine Array Indexes

LANGUAGE-OF-RELATIONS-AND-FUNCTIONS.pptx
LANGUAGE-OF-RELATIONS-AND-FUNCTIONS.pptxLANGUAGE-OF-RELATIONS-AND-FUNCTIONS.pptx
LANGUAGE-OF-RELATIONS-AND-FUNCTIONS.pptx
JasonTagapanGulla
 
vvvvvvvvvvvvvL2A_CurveRepresentations.pdf
vvvvvvvvvvvvvL2A_CurveRepresentations.pdfvvvvvvvvvvvvvL2A_CurveRepresentations.pdf
vvvvvvvvvvvvvL2A_CurveRepresentations.pdf
Khalil Alhatab
 
Chapter on Functions and Graphs.ppt
Chapter on Functions and Graphs.pptChapter on Functions and Graphs.ppt
Chapter on Functions and Graphs.ppt
PhongLan30
 

Similar to Affine Array Indexes (20)

Affine array index
Affine array indexAffine array index
Affine array index
 
Compiler Designing
Compiler DesigningCompiler Designing
Compiler Designing
 
Lesson 1_Functions.pptx
Lesson 1_Functions.pptxLesson 1_Functions.pptx
Lesson 1_Functions.pptx
 
Bostock and Chandler chapter3 functions
Bostock and Chandler chapter3 functionsBostock and Chandler chapter3 functions
Bostock and Chandler chapter3 functions
 
LANGUAGE-OF-RELATIONS-AND-FUNCTIONS.pptx
LANGUAGE-OF-RELATIONS-AND-FUNCTIONS.pptxLANGUAGE-OF-RELATIONS-AND-FUNCTIONS.pptx
LANGUAGE-OF-RELATIONS-AND-FUNCTIONS.pptx
 
Linear_Algebra_final.pdf
Linear_Algebra_final.pdfLinear_Algebra_final.pdf
Linear_Algebra_final.pdf
 
Digital text book 11
Digital text book 11Digital text book 11
Digital text book 11
 
vvvvvvvvvvvvvL2A_CurveRepresentations.pdf
vvvvvvvvvvvvvL2A_CurveRepresentations.pdfvvvvvvvvvvvvvL2A_CurveRepresentations.pdf
vvvvvvvvvvvvvL2A_CurveRepresentations.pdf
 
17481 1235049029519454-2
17481 1235049029519454-217481 1235049029519454-2
17481 1235049029519454-2
 
Introduction to Functions of Several Variables
Introduction to Functions of Several VariablesIntroduction to Functions of Several Variables
Introduction to Functions of Several Variables
 
graph representation.pdf
graph representation.pdfgraph representation.pdf
graph representation.pdf
 
GRAPH MATRIX APPLICATIONS.pdf
GRAPH MATRIX APPLICATIONS.pdfGRAPH MATRIX APPLICATIONS.pdf
GRAPH MATRIX APPLICATIONS.pdf
 
lec7.ppt
lec7.pptlec7.ppt
lec7.ppt
 
International Journal of Mathematics and Statistics Invention (IJMSI)
International Journal of Mathematics and Statistics Invention (IJMSI)International Journal of Mathematics and Statistics Invention (IJMSI)
International Journal of Mathematics and Statistics Invention (IJMSI)
 
Eigen-Decomposition: Eigenvalues and Eigenvectors.pdf
Eigen-Decomposition: Eigenvalues and Eigenvectors.pdfEigen-Decomposition: Eigenvalues and Eigenvectors.pdf
Eigen-Decomposition: Eigenvalues and Eigenvectors.pdf
 
Edsc 304 lesson 1
Edsc 304 lesson 1Edsc 304 lesson 1
Edsc 304 lesson 1
 
Functions
FunctionsFunctions
Functions
 
Chapter on Functions and Graphs.ppt
Chapter on Functions and Graphs.pptChapter on Functions and Graphs.ppt
Chapter on Functions and Graphs.ppt
 
Lesson 1
Lesson 1Lesson 1
Lesson 1
 
1.1 Lecture on Limits and Coninuity.pdf
1.1 Lecture on Limits and Coninuity.pdf1.1 Lecture on Limits and Coninuity.pdf
1.1 Lecture on Limits and Coninuity.pdf
 

More from NilaNila16 (13)

Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
 
Web Programming
Web ProgrammingWeb Programming
Web Programming
 
MapReduce Paradigm
MapReduce ParadigmMapReduce Paradigm
MapReduce Paradigm
 
Hadoop Distributed File System
Hadoop Distributed File SystemHadoop Distributed File System
Hadoop Distributed File System
 
Data Mining
Data MiningData Mining
Data Mining
 
Operating system
Operating systemOperating system
Operating system
 
RDBMS
RDBMSRDBMS
RDBMS
 
Linear Block Codes
Linear Block CodesLinear Block Codes
Linear Block Codes
 
Applications of graph theory
                      Applications of graph theory                      Applications of graph theory
Applications of graph theory
 
Hasse Diagram
Hasse DiagramHasse Diagram
Hasse Diagram
 
Fuzzy set
Fuzzy set Fuzzy set
Fuzzy set
 
Recurrence Relation
Recurrence RelationRecurrence Relation
Recurrence Relation
 
Input/Output Exploring java.io
Input/Output Exploring java.ioInput/Output Exploring java.io
Input/Output Exploring java.io
 

Recently uploaded

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 

Affine Array Indexes

  • 1. NADAR SARASWATHI COLLEGE OF ARTS AND SCIENCE AFFINE ARRAY INDEXES s Submitted by, S.Vijayalakshmi.
  • 2. Affine Array Indexes  The focus of this chapter is on the class of affine array accesses, where each array index is expressed as affine expressions of loop indexes and symbolic constants.  Affine functions provide a succinct mapping from the iteration space to the data space, making it easy to determine which iterations map to the same data or same cache line.  Just as 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.  Once placed in the matrix-vector form, we can apply standard linear algebra to find pertinent information such as the dimensions of the data accessed, and which iterations refer to the same data.
  • 3. Affine Accesses We say that an array access in a loop is affine if 1. The bounds of the loop are expressed as affine expressions of the surrounding loop variables and symbolic constants, and 2. The index for each dimension of the array is also an affine expression of surrounding loop variables and symbolic constants.
  • 4. E x a m p l e 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.
  • 5. 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
  • 6. E x a m p l e : some common array accesses, expressed in matrix notation. The two loop indexes are i and j, and these form the vector i. Also, X, Y, and Z are arrays with 1, 2, and 3 dimensions, respectively. The first access, A[i - 1], is represented by a 1 x 2 matrix F and a vector f of length 1. Notice that when we perform the matrix-vector multiplication and add in the vector f, we are left with a single function, which is exactly the formula for the access to the one-dimensional array X. Also notice the third access, Y[j,j + 1], which, after matrix-vector multiplication and addition, yields a pair of functions, (J, j + 1). These are the indexes of the two dimensions of the array access.
  • 7. 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. ACCESS AFFINE EXPRESSION X [ i - 1 ] [ 1 0 ] . i j . + 1 - 1 ] Y [ i , j ] " 1 0 ‘ 0 1 I _ j . + " 0 " 0 Y [ j , j + 1 ] " 0 1 ‘ 0 1 i-j + “0”1 Y [ l , 2 ] " 0 0 “ 0 0 i . j . + " 1 " 2 " 0 0 " " 1 ' Z [ l , i , 2 * i + j ] 1 0 2 1 _ j _ + 0 0
  • 8. Affine and Non-affine Accesses in Practice There are certain common data access patterns found in numerical programs that fail to be affine. Programs involving sparse matrices are one important example: One popular representation for sparse matrices is to store only the nonzero elements in a vector, and auxiliary index arrays are used to mark where a row starts and which columns contain non-zeros. Indirect array accesses are used in accessing such data. An access of this type, such as is a non-affine access to the array X. If the sparsity is regular, as in banded matrices having non-zeros only around the diagonal, then dense arrays can be used to represent the subregions with nonzero elements. In that case, accesses may be affine.
  • 9. Another common example of nonaffine accesses is linearized arrays. Programmers sometimes use a linear array to store a logically multidimensional object. One reason why this is the case is that the dimensions of the array may not be known at compile time. An access that would normally look like Z[i,j] would be expressed as Z[i * n + j], which is a quadratic function. We can convert the linear access into a multidimensional access if every access can be decomposed into separate dimensions with the guarantee that none of the components exceeds its bound. Finally, we note that induction-variable analyses can be used to convert some nonaffine accesses into affine ones,
  • 10. E x a m p l e We can rewrite the code j = n; f o r (i = 0; i <= n; i++) { Z [ j] = 0; j = J+2; } as j = n; f o r ( i = 0; i <= n; i++) { Z[n+2*i] = 0; } to make the access to matrix Z affine. •