SlideShare a Scribd company logo
1 of 14
Loop Alignment
(Advanced Compilers)
By-
Isha Pandya
Sumita Das
Introduction
Loop distribution eliminates loop carried dependences by
executing the sources of all dependences before executing any
sinks.
Many carried dependencies are due to array alignment issues.
If we can align all references, then dependencies would go
away, and parallelism is possible.
For e.g.,
DO I = 2,N
A(I) = B(I)+C(I)
D(I) = A(I-1)*2.0
ENDDO
Created by Sumita Das
This loop cannot be run in parallel.
Because the value of A computed on iteration I is used on
iteration I+1.
The two statements can be aligned to compute and use the
values in the same iteration by adding an extra iteration and
adjusting the indices of one of the statement to produce
For e.g., DO I = 1,N+1
IF (I .GT. 1) A(I) = B(I)+C(I)
IF (I .LE. N) D(I+1) = A(I)*2.0
ENDDO
Created by Sumita Das
Illustration of Loop Alignment
Created by Sumita Das
DO I = 2,N
J = MOD(I+N-4,N-1)+2
A(J) = B(J)+C
D(I)=A(I-1)*2.0
ENDDO
Alignment
Loop alignment does incur some overhead—
One extra loop iteration and extra work required to test the
conditionals.
This overhead can be reduced by executing the last iteration of
the first statement with the first iteration of the second
statement.
Created by Sumita Das
For every iteration other than the first, j is one less than i, so
that the assignment to A is for the ith location.
On the first iteration, j=N-1 so that j+1=N, and the assignment
to the last location of A is correctly executed.
 As a result, the total number of loop iterations is restored to its
original count, but there is still the overhead of the MOD
calculation.
Created by Sumita Das
Alternatively, the conditional statements can be eliminated
without adding calls to MOD by peeling off the first and last
executions for each of the statements, yielding
This form permits efficient parallelism with the added
overhead of two statements, one before and one after the
loop, that cannot be executed in parallel.
D(2) = A(1) * 2.0
DO I= 2, N-1
A(I) = B(I) + C(I)
D(I+1) = A(I)*2.0
ENDDO
A(N) = B(N) + C(N)
Created by Sumita Das
It is not possible to use alignment to eliminate all carried
dependences in a loop if the carried dependence is involved in
a recurrence, as the following example shows:
DO I = 1, N
A(I) = B(I) + C
B(I+1) = A(I) + D
ENDDO
In this example, the references to B create a carried
dependence.
For alignment to be successful in this case, we would need to
interchange the order of the two statements in the loop body.
Created by Sumita Das
However, the loop-independent dependence involving A
prevents interchanging the statements before alignment, so our
hope is that we can do the alignment and statement interchange in
a single step to eliminate the carried dependence:
DO I = 1, N+1
IF (I .NE. 1) B(I) = A(I-1) + D
IF (I .NE. N+1) A(I) = B(I) + C
ENDDO
Although B is now aligned, the references to A are misaligned,
creating a new carried dependence.
Looking at this example, it is reasonable to believe that loop
alignment cannot eliminate carried dependences in a recurrence.
Created by Sumita Das
Alignment, replication, and statement reordering are
sufficient to eliminate all carried dependencies in a single
loop containing no recurrence, and in which the distance of
each dependence is a constant independent of the loop
index
 We can establish this constructively.
 Let G = (V,E,) be a weighted graph. v  V is a
statement, and (v1, v2) is the dependence distance
between v1 and v2. Let o: V Z give the offset of
vertices.
 G is said to be carry free if o(v1) + (v1, v2) = o(v2).
Theorem
Created by Sumita Das
The carried dependences that are not involved in a recurrence
cannot be always eliminated by alignment without introducing
new carried dependences?
Because of the possibility of an alignment conflict—two or
more dependences that cannot be simultaneously aligned.
Consider the following example:
DO I = 1, N
A(I+1) = B(I) + C
X(I)= A(I+1) + A(I)
ENDDO
This loop contains two dependences involving the array A, one
loop-independent dependence and a loop-carried dependence.
Created by Sumita Das
If the statements are aligned to eliminate the carried
dependence, the following code results:
DO I = 0, N
IF (I .NE. 0) A(I+1) = B(I) + C
IF (I .NE. N) X(I+1)= A(I+2) + A(I+1)
ENDDO
The original loop-carried dependence has been eliminated,
but the process of eliminating it has transformed the original
loop-independent dependence into a loop-carried dependence.
The loop still cannot be correctly run in parallel.
Created by Sumita Das
procedure Align(V,E,,0)
While V is not empty
remove element v from V
for each (w,v)  E
if w  V
W  W  {w}
o(w)  o(v) - (w,v)
else if o(w) != o(v) - (w,v)
create vertex w’
replace (w,v) with (w’,v)
replicate all edges into w
onto w’
W  W  {w’}
o(w)’  o(v) - (w,v)
for each (v,w)  E
if w  V
W  W {w}
o(w)  o(v) + (v,w)
else if o(w) != o(v) + (v,w)
create vertex v’
replace (v,w) with (v’,w)
replicate edges into v onto v’
W  W  {v’}
o(v’)  o(w) - (v,w)
end align
Alignment Procedure
Created by Sumita Das
References
Created by Sumita Das
[1] Randy Allen, Ken Kennedy”Optimizing Compilers for Modern
Architectures, Chapter 6: Creating Coarse-Grained Parallelism”,
1st Edition

More Related Content

What's hot

Convolution presentation
Convolution presentationConvolution presentation
Convolution presentationSoham Mondal
 
Computation of Electromagnetic Fields Scattered from Dielectric Objects of Un...
Computation of Electromagnetic Fields Scattered from Dielectric Objects of Un...Computation of Electromagnetic Fields Scattered from Dielectric Objects of Un...
Computation of Electromagnetic Fields Scattered from Dielectric Objects of Un...Alexander Litvinenko
 
Robotics_Final_Paper_Folza
Robotics_Final_Paper_FolzaRobotics_Final_Paper_Folza
Robotics_Final_Paper_FolzaAlex Folz
 
Calculus bicycle and railroad powerpoint
Calculus bicycle and railroad powerpointCalculus bicycle and railroad powerpoint
Calculus bicycle and railroad powerpointJacob Birch
 
Longest Common Subsequence & Matrix Chain Multiplication
Longest Common Subsequence & Matrix Chain MultiplicationLongest Common Subsequence & Matrix Chain Multiplication
Longest Common Subsequence & Matrix Chain MultiplicationJaneAlamAdnan
 
Matrix chain multiplication by MHM
Matrix chain multiplication by MHMMatrix chain multiplication by MHM
Matrix chain multiplication by MHMMd Mosharof Hosen
 
ROOT-LOCUS METHOD, Determine the root loci on the real axis /the asymptotes o...
ROOT-LOCUS METHOD, Determine the root loci on the real axis /the asymptotes o...ROOT-LOCUS METHOD, Determine the root loci on the real axis /the asymptotes o...
ROOT-LOCUS METHOD, Determine the root loci on the real axis /the asymptotes o...Waqas Afzal
 
Algorithms explained
Algorithms explainedAlgorithms explained
Algorithms explainedPIYUSH Dubey
 
Uvl simplysupported beam
Uvl simplysupported beamUvl simplysupported beam
Uvl simplysupported beamAshok Mannava
 
Ce 2009 Gate Paper Prsolutions08
Ce 2009 Gate Paper Prsolutions08Ce 2009 Gate Paper Prsolutions08
Ce 2009 Gate Paper Prsolutions08guestd436758
 
Admission for b.tech
Admission for b.techAdmission for b.tech
Admission for b.techEdhole.com
 
SFG and Mason's Gain Formula
SFG and Mason's Gain FormulaSFG and Mason's Gain Formula
SFG and Mason's Gain Formulapriyankabirlaa
 
Numerical Method Analysis: Algebraic and Transcendental Equations (Linear)
Numerical Method Analysis: Algebraic and Transcendental Equations (Linear)Numerical Method Analysis: Algebraic and Transcendental Equations (Linear)
Numerical Method Analysis: Algebraic and Transcendental Equations (Linear)Minhas Kamal
 
PC Test 2 study guide 2011
PC Test 2 study guide 2011PC Test 2 study guide 2011
PC Test 2 study guide 2011vhiggins1
 

What's hot (20)

Control chap7
Control chap7Control chap7
Control chap7
 
Signal flow graph
Signal flow graphSignal flow graph
Signal flow graph
 
Convolution presentation
Convolution presentationConvolution presentation
Convolution presentation
 
Computation of Electromagnetic Fields Scattered from Dielectric Objects of Un...
Computation of Electromagnetic Fields Scattered from Dielectric Objects of Un...Computation of Electromagnetic Fields Scattered from Dielectric Objects of Un...
Computation of Electromagnetic Fields Scattered from Dielectric Objects of Un...
 
Robotics_Final_Paper_Folza
Robotics_Final_Paper_FolzaRobotics_Final_Paper_Folza
Robotics_Final_Paper_Folza
 
Deflection in beams 1
Deflection in beams 1Deflection in beams 1
Deflection in beams 1
 
Calculus bicycle and railroad powerpoint
Calculus bicycle and railroad powerpointCalculus bicycle and railroad powerpoint
Calculus bicycle and railroad powerpoint
 
Longest Common Subsequence & Matrix Chain Multiplication
Longest Common Subsequence & Matrix Chain MultiplicationLongest Common Subsequence & Matrix Chain Multiplication
Longest Common Subsequence & Matrix Chain Multiplication
 
Matrix chain multiplication by MHM
Matrix chain multiplication by MHMMatrix chain multiplication by MHM
Matrix chain multiplication by MHM
 
ROOT-LOCUS METHOD, Determine the root loci on the real axis /the asymptotes o...
ROOT-LOCUS METHOD, Determine the root loci on the real axis /the asymptotes o...ROOT-LOCUS METHOD, Determine the root loci on the real axis /the asymptotes o...
ROOT-LOCUS METHOD, Determine the root loci on the real axis /the asymptotes o...
 
Algorithms explained
Algorithms explainedAlgorithms explained
Algorithms explained
 
Root locus
Root locusRoot locus
Root locus
 
And or graph problem reduction using predicate logic
And or graph problem reduction using predicate logicAnd or graph problem reduction using predicate logic
And or graph problem reduction using predicate logic
 
Uvl simplysupported beam
Uvl simplysupported beamUvl simplysupported beam
Uvl simplysupported beam
 
Ce 2009 Gate Paper Prsolutions08
Ce 2009 Gate Paper Prsolutions08Ce 2009 Gate Paper Prsolutions08
Ce 2009 Gate Paper Prsolutions08
 
Admission for b.tech
Admission for b.techAdmission for b.tech
Admission for b.tech
 
Smith chart basics
Smith chart basicsSmith chart basics
Smith chart basics
 
SFG and Mason's Gain Formula
SFG and Mason's Gain FormulaSFG and Mason's Gain Formula
SFG and Mason's Gain Formula
 
Numerical Method Analysis: Algebraic and Transcendental Equations (Linear)
Numerical Method Analysis: Algebraic and Transcendental Equations (Linear)Numerical Method Analysis: Algebraic and Transcendental Equations (Linear)
Numerical Method Analysis: Algebraic and Transcendental Equations (Linear)
 
PC Test 2 study guide 2011
PC Test 2 study guide 2011PC Test 2 study guide 2011
PC Test 2 study guide 2011
 

Viewers also liked

The cognitive advantage
The cognitive advantageThe cognitive advantage
The cognitive advantageYann Lecourt
 
Dynamic ticket pricing. Squeezing more juice from half time oranges
Dynamic ticket pricing. Squeezing more juice from half time oranges  Dynamic ticket pricing. Squeezing more juice from half time oranges
Dynamic ticket pricing. Squeezing more juice from half time oranges Value Partners
 
Talent Gradient Construction Based on Competency
Talent Gradient Construction Based on CompetencyTalent Gradient Construction Based on Competency
Talent Gradient Construction Based on CompetencyVincent T. ZHAO
 
Crear Unha Conta Gmail
Crear Unha Conta GmailCrear Unha Conta Gmail
Crear Unha Conta Gmailvicente
 
Unit 9 photography techniques iuuo
Unit 9   photography techniques iuuoUnit 9   photography techniques iuuo
Unit 9 photography techniques iuuoliamwhitemtb
 
Qtp important frameworks
Qtp important frameworksQtp important frameworks
Qtp important frameworksprs0302
 
Eye Catching Photos
Eye Catching PhotosEye Catching Photos
Eye Catching PhotosYee Seng Gan
 
Unit 4 Saving and Investing PPT
Unit 4 Saving and Investing PPTUnit 4 Saving and Investing PPT
Unit 4 Saving and Investing PPTJenny Hubbard
 
Example of arrogance in quran the story of qarun and haman
Example of arrogance in quran the story of qarun and haman Example of arrogance in quran the story of qarun and haman
Example of arrogance in quran the story of qarun and haman Amel Hope
 
X2 t08 04 inequality techniques (2012)
X2 t08 04 inequality techniques (2012)X2 t08 04 inequality techniques (2012)
X2 t08 04 inequality techniques (2012)Nigel Simmons
 
Hybrid cloud iaa-s_office-365-azure_sharepoint-konferenz-wien-2013_ankbs_mich...
Hybrid cloud iaa-s_office-365-azure_sharepoint-konferenz-wien-2013_ankbs_mich...Hybrid cloud iaa-s_office-365-azure_sharepoint-konferenz-wien-2013_ankbs_mich...
Hybrid cloud iaa-s_office-365-azure_sharepoint-konferenz-wien-2013_ankbs_mich...Michael Kirst-Neshva
 
Twig: Friendly Curly Braces Invade Your Templates!
Twig: Friendly Curly Braces Invade Your Templates!Twig: Friendly Curly Braces Invade Your Templates!
Twig: Friendly Curly Braces Invade Your Templates!Ryan Weaver
 

Viewers also liked (20)

The cognitive advantage
The cognitive advantageThe cognitive advantage
The cognitive advantage
 
Trigical for Trigeminal Neuralgia Treatment
Trigical for Trigeminal Neuralgia TreatmentTrigical for Trigeminal Neuralgia Treatment
Trigical for Trigeminal Neuralgia Treatment
 
Dynamic ticket pricing. Squeezing more juice from half time oranges
Dynamic ticket pricing. Squeezing more juice from half time oranges  Dynamic ticket pricing. Squeezing more juice from half time oranges
Dynamic ticket pricing. Squeezing more juice from half time oranges
 
Talent Gradient Construction Based on Competency
Talent Gradient Construction Based on CompetencyTalent Gradient Construction Based on Competency
Talent Gradient Construction Based on Competency
 
Crear Unha Conta Gmail
Crear Unha Conta GmailCrear Unha Conta Gmail
Crear Unha Conta Gmail
 
Saim chishti books eemane abitalib2of2
Saim chishti books eemane abitalib2of2Saim chishti books eemane abitalib2of2
Saim chishti books eemane abitalib2of2
 
Boe February 10 2009 Agenda
Boe February 10 2009 AgendaBoe February 10 2009 Agenda
Boe February 10 2009 Agenda
 
Unit 9 photography techniques iuuo
Unit 9   photography techniques iuuoUnit 9   photography techniques iuuo
Unit 9 photography techniques iuuo
 
Systems analysis and design (abe)
Systems analysis and design (abe)Systems analysis and design (abe)
Systems analysis and design (abe)
 
Karylronco
KarylroncoKarylronco
Karylronco
 
Qtp important frameworks
Qtp important frameworksQtp important frameworks
Qtp important frameworks
 
Eye Catching Photos
Eye Catching PhotosEye Catching Photos
Eye Catching Photos
 
Unit 4 Saving and Investing PPT
Unit 4 Saving and Investing PPTUnit 4 Saving and Investing PPT
Unit 4 Saving and Investing PPT
 
Example of arrogance in quran the story of qarun and haman
Example of arrogance in quran the story of qarun and haman Example of arrogance in quran the story of qarun and haman
Example of arrogance in quran the story of qarun and haman
 
X2 t08 04 inequality techniques (2012)
X2 t08 04 inequality techniques (2012)X2 t08 04 inequality techniques (2012)
X2 t08 04 inequality techniques (2012)
 
Autocad lisp
Autocad lispAutocad lisp
Autocad lisp
 
Kbl corporate profile
Kbl corporate profileKbl corporate profile
Kbl corporate profile
 
Zcvb
ZcvbZcvb
Zcvb
 
Hybrid cloud iaa-s_office-365-azure_sharepoint-konferenz-wien-2013_ankbs_mich...
Hybrid cloud iaa-s_office-365-azure_sharepoint-konferenz-wien-2013_ankbs_mich...Hybrid cloud iaa-s_office-365-azure_sharepoint-konferenz-wien-2013_ankbs_mich...
Hybrid cloud iaa-s_office-365-azure_sharepoint-konferenz-wien-2013_ankbs_mich...
 
Twig: Friendly Curly Braces Invade Your Templates!
Twig: Friendly Curly Braces Invade Your Templates!Twig: Friendly Curly Braces Invade Your Templates!
Twig: Friendly Curly Braces Invade Your Templates!
 

Similar to Loop alignment

Boolean Algebra by SUKHDEEP SINGH
Boolean Algebra by SUKHDEEP SINGHBoolean Algebra by SUKHDEEP SINGH
Boolean Algebra by SUKHDEEP SINGHSukhdeep Bisht
 
Scalable Online Betweenness Centrality in Evolving Graphs
Scalable Online Betweenness Centrality in Evolving GraphsScalable Online Betweenness Centrality in Evolving Graphs
Scalable Online Betweenness Centrality in Evolving GraphsNicolas Kourtellis
 
Analytic function 1
Analytic function 1Analytic function 1
Analytic function 1SaimaSadiq7
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxanhlodge
 
Influence lines gdlc
Influence lines   gdlcInfluence lines   gdlc
Influence lines gdlcAnsar Abbas
 
METRIC DIMENSION AND UNCERTAINTY OF TRAVERSING ROBOTS IN A NETWORK
METRIC DIMENSION AND UNCERTAINTY OF TRAVERSING ROBOTS IN A NETWORKMETRIC DIMENSION AND UNCERTAINTY OF TRAVERSING ROBOTS IN A NETWORK
METRIC DIMENSION AND UNCERTAINTY OF TRAVERSING ROBOTS IN A NETWORKgraphhoc
 
METRIC DIMENSION AND UNCERTAINTY OF TRAVERSING ROBOTS IN A NETWORK
METRIC DIMENSION AND UNCERTAINTY OF TRAVERSING ROBOTS IN A NETWORKMETRIC DIMENSION AND UNCERTAINTY OF TRAVERSING ROBOTS IN A NETWORK
METRIC DIMENSION AND UNCERTAINTY OF TRAVERSING ROBOTS IN A NETWORKFransiskeran
 
LAB05ex1.mfunction LAB05ex1m = 1; .docx
LAB05ex1.mfunction LAB05ex1m = 1;                          .docxLAB05ex1.mfunction LAB05ex1m = 1;                          .docx
LAB05ex1.mfunction LAB05ex1m = 1; .docxsmile790243
 
W ee network_theory_10-06-17_ls2-sol
W ee network_theory_10-06-17_ls2-solW ee network_theory_10-06-17_ls2-sol
W ee network_theory_10-06-17_ls2-solAnkit Chaurasia
 
Modeling An Rational Integral With Saber State Ams
Modeling An Rational Integral With Saber State AmsModeling An Rational Integral With Saber State Ams
Modeling An Rational Integral With Saber State Amsdomnitei
 
Differential Equations Assignment Help
Differential Equations Assignment HelpDifferential Equations Assignment Help
Differential Equations Assignment HelpMath Homework Solver
 
BCA_MATHEMATICS-I_Unit-V
BCA_MATHEMATICS-I_Unit-VBCA_MATHEMATICS-I_Unit-V
BCA_MATHEMATICS-I_Unit-VRai University
 
Differential Equations Assignment Help
Differential Equations Assignment HelpDifferential Equations Assignment Help
Differential Equations Assignment HelpMaths Assignment Help
 

Similar to Loop alignment (20)

Boolean Algebra by SUKHDEEP SINGH
Boolean Algebra by SUKHDEEP SINGHBoolean Algebra by SUKHDEEP SINGH
Boolean Algebra by SUKHDEEP SINGH
 
Scalable Online Betweenness Centrality in Evolving Graphs
Scalable Online Betweenness Centrality in Evolving GraphsScalable Online Betweenness Centrality in Evolving Graphs
Scalable Online Betweenness Centrality in Evolving Graphs
 
Analytic function 1
Analytic function 1Analytic function 1
Analytic function 1
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
 
Bode plot
Bode plot Bode plot
Bode plot
 
Contour
ContourContour
Contour
 
U unit4 vm
U unit4 vmU unit4 vm
U unit4 vm
 
Influence lines gdlc
Influence lines   gdlcInfluence lines   gdlc
Influence lines gdlc
 
METRIC DIMENSION AND UNCERTAINTY OF TRAVERSING ROBOTS IN A NETWORK
METRIC DIMENSION AND UNCERTAINTY OF TRAVERSING ROBOTS IN A NETWORKMETRIC DIMENSION AND UNCERTAINTY OF TRAVERSING ROBOTS IN A NETWORK
METRIC DIMENSION AND UNCERTAINTY OF TRAVERSING ROBOTS IN A NETWORK
 
METRIC DIMENSION AND UNCERTAINTY OF TRAVERSING ROBOTS IN A NETWORK
METRIC DIMENSION AND UNCERTAINTY OF TRAVERSING ROBOTS IN A NETWORKMETRIC DIMENSION AND UNCERTAINTY OF TRAVERSING ROBOTS IN A NETWORK
METRIC DIMENSION AND UNCERTAINTY OF TRAVERSING ROBOTS IN A NETWORK
 
LAB05ex1.mfunction LAB05ex1m = 1; .docx
LAB05ex1.mfunction LAB05ex1m = 1;                          .docxLAB05ex1.mfunction LAB05ex1m = 1;                          .docx
LAB05ex1.mfunction LAB05ex1m = 1; .docx
 
Capitulo9
Capitulo9Capitulo9
Capitulo9
 
W ee network_theory_10-06-17_ls2-sol
W ee network_theory_10-06-17_ls2-solW ee network_theory_10-06-17_ls2-sol
W ee network_theory_10-06-17_ls2-sol
 
Complex Integral
Complex IntegralComplex Integral
Complex Integral
 
Modeling An Rational Integral With Saber State Ams
Modeling An Rational Integral With Saber State AmsModeling An Rational Integral With Saber State Ams
Modeling An Rational Integral With Saber State Ams
 
Differential Equations Assignment Help
Differential Equations Assignment HelpDifferential Equations Assignment Help
Differential Equations Assignment Help
 
BCA_MATHEMATICS-I_Unit-V
BCA_MATHEMATICS-I_Unit-VBCA_MATHEMATICS-I_Unit-V
BCA_MATHEMATICS-I_Unit-V
 
Differential Equations Assignment Help
Differential Equations Assignment HelpDifferential Equations Assignment Help
Differential Equations Assignment Help
 
Joukowski
JoukowskiJoukowski
Joukowski
 
Number theory
Number theoryNumber theory
Number theory
 

More from Sumita Das

Numerical on bisection method
Numerical on bisection methodNumerical on bisection method
Numerical on bisection methodSumita Das
 
Numerical on dichotomous search
Numerical on dichotomous searchNumerical on dichotomous search
Numerical on dichotomous searchSumita Das
 
Presentation on binary search, quick sort, merge sort and problems
Presentation on binary search, quick sort, merge sort  and problemsPresentation on binary search, quick sort, merge sort  and problems
Presentation on binary search, quick sort, merge sort and problemsSumita Das
 
Maps in android
Maps in androidMaps in android
Maps in androidSumita Das
 
Hardware and software parallelism
Hardware and software parallelismHardware and software parallelism
Hardware and software parallelismSumita Das
 
Trusted systems1
Trusted systems1Trusted systems1
Trusted systems1Sumita Das
 
Activity selection problem
Activity selection problemActivity selection problem
Activity selection problemSumita Das
 
Multiprotocol label switching
Multiprotocol label switchingMultiprotocol label switching
Multiprotocol label switchingSumita Das
 
Asymptotic analysis of parallel programs
Asymptotic analysis of parallel programsAsymptotic analysis of parallel programs
Asymptotic analysis of parallel programsSumita Das
 
Distributed systems1
Distributed systems1Distributed systems1
Distributed systems1Sumita Das
 

More from Sumita Das (10)

Numerical on bisection method
Numerical on bisection methodNumerical on bisection method
Numerical on bisection method
 
Numerical on dichotomous search
Numerical on dichotomous searchNumerical on dichotomous search
Numerical on dichotomous search
 
Presentation on binary search, quick sort, merge sort and problems
Presentation on binary search, quick sort, merge sort  and problemsPresentation on binary search, quick sort, merge sort  and problems
Presentation on binary search, quick sort, merge sort and problems
 
Maps in android
Maps in androidMaps in android
Maps in android
 
Hardware and software parallelism
Hardware and software parallelismHardware and software parallelism
Hardware and software parallelism
 
Trusted systems1
Trusted systems1Trusted systems1
Trusted systems1
 
Activity selection problem
Activity selection problemActivity selection problem
Activity selection problem
 
Multiprotocol label switching
Multiprotocol label switchingMultiprotocol label switching
Multiprotocol label switching
 
Asymptotic analysis of parallel programs
Asymptotic analysis of parallel programsAsymptotic analysis of parallel programs
Asymptotic analysis of parallel programs
 
Distributed systems1
Distributed systems1Distributed systems1
Distributed systems1
 

Recently uploaded

Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLManishPatel169454
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...tanu pandey
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 

Recently uploaded (20)

Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 

Loop alignment

  • 2. Introduction Loop distribution eliminates loop carried dependences by executing the sources of all dependences before executing any sinks. Many carried dependencies are due to array alignment issues. If we can align all references, then dependencies would go away, and parallelism is possible. For e.g., DO I = 2,N A(I) = B(I)+C(I) D(I) = A(I-1)*2.0 ENDDO Created by Sumita Das
  • 3. This loop cannot be run in parallel. Because the value of A computed on iteration I is used on iteration I+1. The two statements can be aligned to compute and use the values in the same iteration by adding an extra iteration and adjusting the indices of one of the statement to produce For e.g., DO I = 1,N+1 IF (I .GT. 1) A(I) = B(I)+C(I) IF (I .LE. N) D(I+1) = A(I)*2.0 ENDDO Created by Sumita Das
  • 4. Illustration of Loop Alignment Created by Sumita Das
  • 5. DO I = 2,N J = MOD(I+N-4,N-1)+2 A(J) = B(J)+C D(I)=A(I-1)*2.0 ENDDO Alignment Loop alignment does incur some overhead— One extra loop iteration and extra work required to test the conditionals. This overhead can be reduced by executing the last iteration of the first statement with the first iteration of the second statement. Created by Sumita Das
  • 6. For every iteration other than the first, j is one less than i, so that the assignment to A is for the ith location. On the first iteration, j=N-1 so that j+1=N, and the assignment to the last location of A is correctly executed.  As a result, the total number of loop iterations is restored to its original count, but there is still the overhead of the MOD calculation. Created by Sumita Das
  • 7. Alternatively, the conditional statements can be eliminated without adding calls to MOD by peeling off the first and last executions for each of the statements, yielding This form permits efficient parallelism with the added overhead of two statements, one before and one after the loop, that cannot be executed in parallel. D(2) = A(1) * 2.0 DO I= 2, N-1 A(I) = B(I) + C(I) D(I+1) = A(I)*2.0 ENDDO A(N) = B(N) + C(N) Created by Sumita Das
  • 8. It is not possible to use alignment to eliminate all carried dependences in a loop if the carried dependence is involved in a recurrence, as the following example shows: DO I = 1, N A(I) = B(I) + C B(I+1) = A(I) + D ENDDO In this example, the references to B create a carried dependence. For alignment to be successful in this case, we would need to interchange the order of the two statements in the loop body. Created by Sumita Das
  • 9. However, the loop-independent dependence involving A prevents interchanging the statements before alignment, so our hope is that we can do the alignment and statement interchange in a single step to eliminate the carried dependence: DO I = 1, N+1 IF (I .NE. 1) B(I) = A(I-1) + D IF (I .NE. N+1) A(I) = B(I) + C ENDDO Although B is now aligned, the references to A are misaligned, creating a new carried dependence. Looking at this example, it is reasonable to believe that loop alignment cannot eliminate carried dependences in a recurrence. Created by Sumita Das
  • 10. Alignment, replication, and statement reordering are sufficient to eliminate all carried dependencies in a single loop containing no recurrence, and in which the distance of each dependence is a constant independent of the loop index  We can establish this constructively.  Let G = (V,E,) be a weighted graph. v  V is a statement, and (v1, v2) is the dependence distance between v1 and v2. Let o: V Z give the offset of vertices.  G is said to be carry free if o(v1) + (v1, v2) = o(v2). Theorem Created by Sumita Das
  • 11. The carried dependences that are not involved in a recurrence cannot be always eliminated by alignment without introducing new carried dependences? Because of the possibility of an alignment conflict—two or more dependences that cannot be simultaneously aligned. Consider the following example: DO I = 1, N A(I+1) = B(I) + C X(I)= A(I+1) + A(I) ENDDO This loop contains two dependences involving the array A, one loop-independent dependence and a loop-carried dependence. Created by Sumita Das
  • 12. If the statements are aligned to eliminate the carried dependence, the following code results: DO I = 0, N IF (I .NE. 0) A(I+1) = B(I) + C IF (I .NE. N) X(I+1)= A(I+2) + A(I+1) ENDDO The original loop-carried dependence has been eliminated, but the process of eliminating it has transformed the original loop-independent dependence into a loop-carried dependence. The loop still cannot be correctly run in parallel. Created by Sumita Das
  • 13. procedure Align(V,E,,0) While V is not empty remove element v from V for each (w,v)  E if w  V W  W  {w} o(w)  o(v) - (w,v) else if o(w) != o(v) - (w,v) create vertex w’ replace (w,v) with (w’,v) replicate all edges into w onto w’ W  W  {w’} o(w)’  o(v) - (w,v) for each (v,w)  E if w  V W  W {w} o(w)  o(v) + (v,w) else if o(w) != o(v) + (v,w) create vertex v’ replace (v,w) with (v’,w) replicate edges into v onto v’ W  W  {v’} o(v’)  o(w) - (v,w) end align Alignment Procedure Created by Sumita Das
  • 14. References Created by Sumita Das [1] Randy Allen, Ken Kennedy”Optimizing Compilers for Modern Architectures, Chapter 6: Creating Coarse-Grained Parallelism”, 1st Edition