SlideShare a Scribd company logo
1 of 18
Preliminary Transformations
Presented By
Ashish Taldeokar
Guide : Prof. Supratim Biswas, CSE Department, IIT Bombay
Motivation
• Programmers wont write code with dependence test in mind
• Must perform some transformation to source code
• Applying Preliminary transformation, makes it easier to build DDG
and do dependence test
• Does not change the semantics of program, hence safe
Introduction
• Loop Normalization
Because dependence test are easier when stride is 1
• Auxiliary Induction variable substitution
recognize loop “invariant” variables
evaluate opportunities for Auxiliary Induction variable substitution
• Copy propagation / Constant Propagation
to propagate constant valued assignments
• Dead code elimination
find usage of “live” variables or useful statements
discard statements that do not matter in further execution
Introduction
• Loop Normalization
Because dependence test are easier when stride is 1
• Auxiliary Induction variable substitution
recognize loop “invariant” variables
evaluate opportunities for Auxiliary Induction variable substitution
• Copy propagation / Constant Propagation
to propagate constant valued assignments
• Dead code elimination
find usage of “live” variables or useful statements
discard statements that do not matter in further execution
Data flow analysis
Example
for( I = 1; I <= 100; I++){
KI = I; ----------------------------- S1
for( J = 1; J <= 300; J += 3 ){
KI = KI + 2; ----------------- S2
U[J] = U[J] * W[KI]; --------- S3
V[J + 3] = V[J] + W[KI]; ----- S4
}
}
Example (loop normalization)
for( I = 1; I <= 100; I++){
KI = I; ----------------------------- S1
for( J = 1; J <= 300; J += 3 ){
KI = KI + 2; ----------------- S2
U[J] = U[J] * W[KI]; --------- S3
V[J + 3] = V[J] + W[KI]; ----- S4
}
}
L = 1 (Lower Bound)
U = 300 (Upper Bound)
S = 3 (Stride)
Example
for( I = 1; I <= 100; I++){
KI = I; ----------------------------- S1
for( J = 1; J <= 300; J += 3 ){
KI = KI + 2; ----------------- S2
U[J] = U[J] * W[KI]; --------- S3
V[J + 3] = V[J] + W[KI]; ----- S4
}
}
L = 1 (Lower Bound)
U = 300 (Upper Bound)
S = 3 (Stride)
L = 1
U = (U-L+S) / S
S = 1
Replace usage of J (loop var) within
the loop as
J = j*S – S + L
In this case,
L = 1, U = (300 – 1 + 3) / 3 = 101, S =1
J = j*3 – 3+1 = 3j-2
Example (loop normalization)
for( I = 1; I <= 100; I++){
KI = I; ----------------------------- S1
for( j = 1; j <= 101; j++ ){
KI = KI + 2; ----------------- S2
U[3j-2] = U[3j-2] * W[KI]; --- S3
V[3j+1] = V[3j-2] + W[KI]; --- S4
}
J = 301; ---------------------------- S5
}
L = 1 (Lower Bound)
U = 300 (Upper Bound)
S = 3 (Stride)
L = 1
U = (U-L+S) / S
S = 1
Replace usage of J (loop var) within
the loop as
J = j*S – S + L
In this case,
L = 1, U = (300 – 1 + 3) / 3 = 101, S =1
J = j*3 – 3+1 = 3j-2
Example (induction variable substitution)
for( I = 1; I <= 100; I++){
KI = I; ----------------------------- S1
for( j = 1; j <= 101; j++ ){
KI = KI + 2; ----------------- S2
U[3j-2] = U[3j-2] * W[KI]; --- S3
V[3j+1] = V[3j-2] + W[KI]; --- S4
}
J = 301; ---------------------------- S5
}
For j loop,
KI is not an affine function of j
Since stride is 1
To express KI = KI + 2 as an affine
function of j, We can do
Remove assignment and
Replace reference of CONST by
CONST*LOOP_VAR
Here,
Remove statement S2
And replace
2 with 2j
And apply where ever used
Example (induction variable substitution)
for( I = 1; I <= 100; I++){
KI = I; ------------------------------- S1
for( j = 1; j <= 101; j++ ){
U[3j-2] = U[3j-2] * W[KI+2j]; -- S3
V[3j+1] = V[3j-2] + W[KI+2j]; -- S4
}
J = 301; ------------------------------ S5
KI = KI + 202; ------------------------ S6
}
For j loop,
KI is not an affine function of j
Since stride is 1
To express KI = KI + 2 as an affine
function of j, We can do
Remove assignment and
Replace reference of CONST by
CONST*LOOP_VAR
Here,
Remove statement S2
And replace
2 with 2j
And apply where ever used
Example
for( I = 1; I <= 100; I++){
KI = I; ------------------------------- S1
for( j = 1; j <= 101; j++ ){
U[3j-2] = U[3j-2] * W[KI+2j]; -- S3
V[3j+1] = V[3j-2] + W[KI+2j]; -- S4
}
J = 301; ------------------------------ S5
KI = KI + 202; ------------------------ S6
}
For outer loop I
Replace References of KI with
KI = I + 0*I
KI = I
Remove S1 and
Replace all further references of KI
with I
Example
for( I = 1; I <= 100; I++){
for( j = 1; j <= 101; j++ ){
U[3j-2] = U[3j-2] * W[I+2j]; -- S3
V[3j+1] = V[3j-2] + W[I+2j]; -- S4
}
J = 301; ----------------------------- S5
KI = I + 202; ------------------------ S6
}
For outer loop I
Replace References of KI with
KI = I + 0*I
KI = I
Remove S1 and
Replace all further references of KI
with I
Example (Dead code elimination)
for( I = 1; I <= 100; I++){
for( j = 1; j <= 101; j++ ){
U[3j-2] = U[3j-2] * W[I+2j]; -- S3
V[3j+1] = V[3j-2] + W[I+2j]; -- S4
}
J = 301; ----------------------------- S5
KI = I + 202; ------------------------ S6
}
Live variable analysis
- Assignment of S3 is used by itself
- Assignment of S4 is used by itself
- Assignment of S5 is not used in the
same scope
- Assignment of S6 is not used in the
same scope
Example (Dead code elimination)
for( I = 1; I <= 100; I++){
for( j = 1; j <= 101; j++ ){
U[3j-2] = U[3j-2] * W[I+2j]; -- S3
V[3j+1] = V[3j-2] + W[I+2j]; -- S4
}
J = 301; ----------------------------- S5
KI = I + 202; ------------------------ S6
}
Remove dead statements
Assignments of KI and J are dead, we
can remove all assignments to those
variable
Example (Result)
for( I = 1; I <= 100; I++){
for( j = 1; j <= 101; j++ ){
U[3j-2] = U[3j-2] * W[I+2j]; -- S3
V[3j+1] = V[3j-2] + W[I+2j]; -- S4
}
}
Result
At this point,
All subscripts are affine functions of
loop induction variable
Ready for dependence analysis and
further apply
vectorization/optimization
Summary
• Loop normalization is a transformation that makes a loop run from a
standard lower bound to an upper bound in steps of one. It is used in
many compilers to simplify dependence testing.
Summary
• Constant propagation, replaces unknown variables with constants
known at compile time. It is performed by an algorithm on a graph
representation of data flow within the program.
Summary
• Induction-variable substitution, eliminates auxiliary induction
variables, replacing them with linear functions of the standard loop
induction variable. A simple variant of the induction-variable
substitution algorithm performs expression folding in loop nests.

More Related Content

Recently uploaded

Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxMustafa Ahmed
 
engineering chemistry power point presentation
engineering chemistry  power point presentationengineering chemistry  power point presentation
engineering chemistry power point presentationsj9399037128
 
CLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference ModalCLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference ModalSwarnaSLcse
 
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024EMMANUELLEFRANCEHELI
 
Passive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.pptPassive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.pptamrabdallah9
 
21P35A0312 Internship eccccccReport.docx
21P35A0312 Internship eccccccReport.docx21P35A0312 Internship eccccccReport.docx
21P35A0312 Internship eccccccReport.docxrahulmanepalli02
 
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdflitvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdfAlexander Litvinenko
 
Geometric constructions Engineering Drawing.pdf
Geometric constructions Engineering Drawing.pdfGeometric constructions Engineering Drawing.pdf
Geometric constructions Engineering Drawing.pdfJNTUA
 
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxSLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxCHAIRMAN M
 
Adsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) pptAdsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) pptjigup7320
 
Circuit Breakers for Engineering Students
Circuit Breakers for Engineering StudentsCircuit Breakers for Engineering Students
Circuit Breakers for Engineering Studentskannan348865
 
What is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsWhat is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsVIEW
 
Call for Papers - Journal of Electrical Systems (JES), E-ISSN: 1112-5209, ind...
Call for Papers - Journal of Electrical Systems (JES), E-ISSN: 1112-5209, ind...Call for Papers - Journal of Electrical Systems (JES), E-ISSN: 1112-5209, ind...
Call for Papers - Journal of Electrical Systems (JES), E-ISSN: 1112-5209, ind...Christo Ananth
 
Independent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging StationIndependent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging Stationsiddharthteach18
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxkalpana413121
 
Artificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfArtificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfKira Dess
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxMustafa Ahmed
 
5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...archanaece3
 
Dynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptxDynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptxMustafa Ahmed
 
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...Amil baba
 

Recently uploaded (20)

Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptx
 
engineering chemistry power point presentation
engineering chemistry  power point presentationengineering chemistry  power point presentation
engineering chemistry power point presentation
 
CLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference ModalCLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference Modal
 
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
 
Passive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.pptPassive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.ppt
 
21P35A0312 Internship eccccccReport.docx
21P35A0312 Internship eccccccReport.docx21P35A0312 Internship eccccccReport.docx
21P35A0312 Internship eccccccReport.docx
 
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdflitvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
 
Geometric constructions Engineering Drawing.pdf
Geometric constructions Engineering Drawing.pdfGeometric constructions Engineering Drawing.pdf
Geometric constructions Engineering Drawing.pdf
 
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxSLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
 
Adsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) pptAdsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) ppt
 
Circuit Breakers for Engineering Students
Circuit Breakers for Engineering StudentsCircuit Breakers for Engineering Students
Circuit Breakers for Engineering Students
 
What is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsWhat is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, Functions
 
Call for Papers - Journal of Electrical Systems (JES), E-ISSN: 1112-5209, ind...
Call for Papers - Journal of Electrical Systems (JES), E-ISSN: 1112-5209, ind...Call for Papers - Journal of Electrical Systems (JES), E-ISSN: 1112-5209, ind...
Call for Papers - Journal of Electrical Systems (JES), E-ISSN: 1112-5209, ind...
 
Independent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging StationIndependent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging Station
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptx
 
Artificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfArtificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdf
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptx
 
5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...
 
Dynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptxDynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptx
 
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
 

Featured

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 

Featured (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 

Preliminary transformations

  • 1. Preliminary Transformations Presented By Ashish Taldeokar Guide : Prof. Supratim Biswas, CSE Department, IIT Bombay
  • 2. Motivation • Programmers wont write code with dependence test in mind • Must perform some transformation to source code • Applying Preliminary transformation, makes it easier to build DDG and do dependence test • Does not change the semantics of program, hence safe
  • 3. Introduction • Loop Normalization Because dependence test are easier when stride is 1 • Auxiliary Induction variable substitution recognize loop “invariant” variables evaluate opportunities for Auxiliary Induction variable substitution • Copy propagation / Constant Propagation to propagate constant valued assignments • Dead code elimination find usage of “live” variables or useful statements discard statements that do not matter in further execution
  • 4. Introduction • Loop Normalization Because dependence test are easier when stride is 1 • Auxiliary Induction variable substitution recognize loop “invariant” variables evaluate opportunities for Auxiliary Induction variable substitution • Copy propagation / Constant Propagation to propagate constant valued assignments • Dead code elimination find usage of “live” variables or useful statements discard statements that do not matter in further execution Data flow analysis
  • 5. Example for( I = 1; I <= 100; I++){ KI = I; ----------------------------- S1 for( J = 1; J <= 300; J += 3 ){ KI = KI + 2; ----------------- S2 U[J] = U[J] * W[KI]; --------- S3 V[J + 3] = V[J] + W[KI]; ----- S4 } }
  • 6. Example (loop normalization) for( I = 1; I <= 100; I++){ KI = I; ----------------------------- S1 for( J = 1; J <= 300; J += 3 ){ KI = KI + 2; ----------------- S2 U[J] = U[J] * W[KI]; --------- S3 V[J + 3] = V[J] + W[KI]; ----- S4 } } L = 1 (Lower Bound) U = 300 (Upper Bound) S = 3 (Stride)
  • 7. Example for( I = 1; I <= 100; I++){ KI = I; ----------------------------- S1 for( J = 1; J <= 300; J += 3 ){ KI = KI + 2; ----------------- S2 U[J] = U[J] * W[KI]; --------- S3 V[J + 3] = V[J] + W[KI]; ----- S4 } } L = 1 (Lower Bound) U = 300 (Upper Bound) S = 3 (Stride) L = 1 U = (U-L+S) / S S = 1 Replace usage of J (loop var) within the loop as J = j*S – S + L In this case, L = 1, U = (300 – 1 + 3) / 3 = 101, S =1 J = j*3 – 3+1 = 3j-2
  • 8. Example (loop normalization) for( I = 1; I <= 100; I++){ KI = I; ----------------------------- S1 for( j = 1; j <= 101; j++ ){ KI = KI + 2; ----------------- S2 U[3j-2] = U[3j-2] * W[KI]; --- S3 V[3j+1] = V[3j-2] + W[KI]; --- S4 } J = 301; ---------------------------- S5 } L = 1 (Lower Bound) U = 300 (Upper Bound) S = 3 (Stride) L = 1 U = (U-L+S) / S S = 1 Replace usage of J (loop var) within the loop as J = j*S – S + L In this case, L = 1, U = (300 – 1 + 3) / 3 = 101, S =1 J = j*3 – 3+1 = 3j-2
  • 9. Example (induction variable substitution) for( I = 1; I <= 100; I++){ KI = I; ----------------------------- S1 for( j = 1; j <= 101; j++ ){ KI = KI + 2; ----------------- S2 U[3j-2] = U[3j-2] * W[KI]; --- S3 V[3j+1] = V[3j-2] + W[KI]; --- S4 } J = 301; ---------------------------- S5 } For j loop, KI is not an affine function of j Since stride is 1 To express KI = KI + 2 as an affine function of j, We can do Remove assignment and Replace reference of CONST by CONST*LOOP_VAR Here, Remove statement S2 And replace 2 with 2j And apply where ever used
  • 10. Example (induction variable substitution) for( I = 1; I <= 100; I++){ KI = I; ------------------------------- S1 for( j = 1; j <= 101; j++ ){ U[3j-2] = U[3j-2] * W[KI+2j]; -- S3 V[3j+1] = V[3j-2] + W[KI+2j]; -- S4 } J = 301; ------------------------------ S5 KI = KI + 202; ------------------------ S6 } For j loop, KI is not an affine function of j Since stride is 1 To express KI = KI + 2 as an affine function of j, We can do Remove assignment and Replace reference of CONST by CONST*LOOP_VAR Here, Remove statement S2 And replace 2 with 2j And apply where ever used
  • 11. Example for( I = 1; I <= 100; I++){ KI = I; ------------------------------- S1 for( j = 1; j <= 101; j++ ){ U[3j-2] = U[3j-2] * W[KI+2j]; -- S3 V[3j+1] = V[3j-2] + W[KI+2j]; -- S4 } J = 301; ------------------------------ S5 KI = KI + 202; ------------------------ S6 } For outer loop I Replace References of KI with KI = I + 0*I KI = I Remove S1 and Replace all further references of KI with I
  • 12. Example for( I = 1; I <= 100; I++){ for( j = 1; j <= 101; j++ ){ U[3j-2] = U[3j-2] * W[I+2j]; -- S3 V[3j+1] = V[3j-2] + W[I+2j]; -- S4 } J = 301; ----------------------------- S5 KI = I + 202; ------------------------ S6 } For outer loop I Replace References of KI with KI = I + 0*I KI = I Remove S1 and Replace all further references of KI with I
  • 13. Example (Dead code elimination) for( I = 1; I <= 100; I++){ for( j = 1; j <= 101; j++ ){ U[3j-2] = U[3j-2] * W[I+2j]; -- S3 V[3j+1] = V[3j-2] + W[I+2j]; -- S4 } J = 301; ----------------------------- S5 KI = I + 202; ------------------------ S6 } Live variable analysis - Assignment of S3 is used by itself - Assignment of S4 is used by itself - Assignment of S5 is not used in the same scope - Assignment of S6 is not used in the same scope
  • 14. Example (Dead code elimination) for( I = 1; I <= 100; I++){ for( j = 1; j <= 101; j++ ){ U[3j-2] = U[3j-2] * W[I+2j]; -- S3 V[3j+1] = V[3j-2] + W[I+2j]; -- S4 } J = 301; ----------------------------- S5 KI = I + 202; ------------------------ S6 } Remove dead statements Assignments of KI and J are dead, we can remove all assignments to those variable
  • 15. Example (Result) for( I = 1; I <= 100; I++){ for( j = 1; j <= 101; j++ ){ U[3j-2] = U[3j-2] * W[I+2j]; -- S3 V[3j+1] = V[3j-2] + W[I+2j]; -- S4 } } Result At this point, All subscripts are affine functions of loop induction variable Ready for dependence analysis and further apply vectorization/optimization
  • 16. Summary • Loop normalization is a transformation that makes a loop run from a standard lower bound to an upper bound in steps of one. It is used in many compilers to simplify dependence testing.
  • 17. Summary • Constant propagation, replaces unknown variables with constants known at compile time. It is performed by an algorithm on a graph representation of data flow within the program.
  • 18. Summary • Induction-variable substitution, eliminates auxiliary induction variables, replacing them with linear functions of the standard loop induction variable. A simple variant of the induction-variable substitution algorithm performs expression folding in loop nests.