SlideShare a Scribd company logo
PARALLEL PROGRAMMING CONCEPT
DEPENDENCY AND LOOP
PARALLELIZATION
•Parallel programming concept and
their examples
•Dependency and their two types
with examples
•Loop parallelism and their types
with examples
R.AISHWARYA
Parallel programming???
Parallel programming concept dependency and loop parallelization
• Simultaneous use of multiple compute
resources to solve a computational problem
• Compute resources
• Primary reasons
• Best practices
• Goals
• Steps
Parallel programming concept dependency and loop parallelization
Parallel programming concept dependency and loop parallelization
LOOP DEPENDENCY
Statement 2: b=a+2; “5” Statement 1: a=5;
•Find dependencies within iterations of a loop
•Goal of determining different relationships
between statements.
•To allow multiple processors to work on different
portions of the loop in parallel
•First analyze the dependencies within individual
loops.
•It help determine which statements in the loop
need to be completed before other statements
can start.
•Two general categories of dependencies: Data and
Control dependency
function Dep(a,b)
c:=a.b
d:=2.c
end function
(flow dependency)
function Nodep(a,b)
c:=a.b
d:=2.b
e:=a+b
end function
(no dependency)
DATA DEPENDENCY
TYPE NOTATION DESCRIPTION
True (Flow) Dependence
S1 ->T S2
A true dependence between S1
and S2 means that S1 writes
to a location later read from
by S2
Anti Dependence S1 ->A S2
An anti-dependence between
S1 and S2 means that S1 reads
from a location later written
to by S2.(before)
Output Dependence S1 ->I S2
An input dependence between
S1 and S2 means that S1 and
S2 read from the same
location.
EXAMPLES
True dependence
S0: int a, b;
S1: a = 2;
S2: b = a + 40;
S1 ->T S2, meaning that S1 has a true dependence on S2 because
S1writes to the variable a, which S2 reads from.
Anti-dependence
S0: int a, b = 40;
S1: a = b - 38;
S2: b = -1;
S1 ->A S2, meaning that S1 has an anti-dependence on S2
because S1reads from the variable b before S2 writes to it.
Output-dependence
S0: int a, b = 40;
S1: a = b - 38;
S2: a = 2;
S1 ->O S2, meaning that S1 has an output dependence on S2
because both write to the variable a.
CONTROL DEPENDENCY
if(a == b)
then
{
c = “controlled”;
}
d=“not
controlled”;
if(a == b)
then
{
}
c = “controlled”;
d=“not
controlled”;
if(a == b)
then
{
c = “controlled”;
d=“not
controlled”;
}
DEPENDENCY IN LOOP
Loops can have two types of dependence:
•Loop-carried
dependency
•Loop-independent
dependency
LOOP CARRIED DEPENDENCY
• In loop-carried dependence, statements in an
iteration of a loop depend on statements in
another iteration of the loop.
for(i=0;i<4;i++)
{
S1: b[i]=8;
S2: a[i]=b[i-1] + 10;
}
LOOP INDEPENDENT DEPENDENCY
• In loop-independent dependence, loops have
inter-iteration dependence, but do not have
dependence between iterations.
• Each iteration may be treated as a block and
performed in parallel without other
synchronization efforts.
for (i=0;i<4;i++)
{
S1: b[i] = 8;
S2: a[i] =b[i] + 10;
}
for (i=1; i<4; i++)
for (j=1; j<4; j++)
S3: a[i][j] = a[i][j-1] + 1;
Node : Point in the iteration space
Directed Edge: Dependency
Node: Point in the iteration space
Directed Edge: next point that will
be encountered
after the current point is
traversed
LOOP PARALLELIZATION
•Extraction parallel tasks from loops
•Data is stored in random access data structures
•A program exploiting loop-level parallelism will use
multiple threads or processes which operate on same time
•It provides speedup
•Amdhal’s law
Examples of Loop
parallelization
for (int i = 0; i < n; i++)
{
S1: L[i] = L[i] + 10;
}
for (int i = 1; i < n; i++)
{
S1: L[i] = L[i - 1] + 10;
}
Can the following Loop be made
Parallel?
for (i=1;i<=100;i=i+1)
{
A[i+1] = A[i] + C[i]; /*S1*/
B[i+1] = B[i] + A[i+1]; /*S2*/
}
METHODOLOGIES FOR
PARALLELIZING LOOPS
• DISTRIBUTED Loop
• DOALL Parallelism
• DOACROSS Parallelism
• HELIX
• DOPIPE Parallelism
DISTRIBUTED LOOP
for (int i = 1; i < n; i ++)
{
S1: a[i] = a[i -1] + b[i];
S2: c[i] = c[i] + d[i];
}
loop1: for (int i = 1; i < n; i ++)
{
S1: a[i] = a[i -1] + b[i];
}
loop2: for (int i = 1; i < n; i ++)
{
S2: c[i] = c[i] + d[i];
}
DO ALL PARALLELISM
for (int i = 0; i < n; i++)
{
S1: a[i] = b[i] + c[i];
}
begin_parallelism();
for (int i = 0; i < n; i++)
{
S1: a[i] = b[i] + c[i];
end_parallelism();
}
block();
DO ACROSS PARALLELISM
for (int i = 1; i < n; i++)
{
a[i] = a[i - 1] + b[i] + 1;
}
S1: int tmp = b[i] + 1;
S2: a[i] = a[i - 1] + tmp;
post(0);
for (int i = 1; i < n; i++)
{
S1: int tmp = b[i] + 1;
wait(i - 1);
S2: a[i] = a[i - 1] + tmp;
post(i);
}
DO PIPE PARALLELISM
for (int i = 1; i < n; i++)
{
S1: a[i] = a[i - 1] + b[i];
S2: c[i] = c[i] + a[i];
}
for (int i = 1; i < n; i++)
{
S1: a[i] = a[i - 1] + b[i];
post(i);
}
for (int i = 1; i < n; i++)
{
wait(i);
S2: c[i] = c[i] + a[i];
}
Parallel programming concept dependency and loop parallelization

More Related Content

What's hot (20)

Multithreading Presentation
Multithreading Presentation
Neeraj Kaushik
 
Program and Network Properties
Program and Network Properties
Beekrum Duwal
 
Operating system 31 multiple processor scheduling
Operating system 31 multiple processor scheduling
Vaibhav Khanna
 
Security in distributed systems
Security in distributed systems
Haitham Ahmed
 
Distributed Mutual exclusion algorithms
Distributed Mutual exclusion algorithms
MNM Jain Engineering College
 
Concept of Pipelining
Concept of Pipelining
SHAKOOR AB
 
Local multipoint distribution service(lmds)
Local multipoint distribution service(lmds)
Vivek Kumar
 
WSN presentation
WSN presentation
Braj Raj Singh
 
Operating System: Deadlock
Operating System: Deadlock
InteX Research Lab
 
memory Interleaving and low order interleaving and high interleaving
memory Interleaving and low order interleaving and high interleaving
Jawwad Rafiq
 
Email HTTP And FTP
Email HTTP And FTP
Shishpal Vishnoi
 
Overview on NUMA
Overview on NUMA
Abed Maatalla
 
Tcp Udp Icmp And The Transport Layer
Tcp Udp Icmp And The Transport Layer
tmavroidis
 
Embedded Systems (18EC62) - ARM Cortex-M3 Instruction Set and Programming (Mo...
Embedded Systems (18EC62) - ARM Cortex-M3 Instruction Set and Programming (Mo...
Shrishail Bhat
 
multiplexing
multiplexing
Srinivasa Rao
 
11. dfs
11. dfs
Dr Sandeep Kumar Poonia
 
Chapter 3: Data & Signals
Chapter 3: Data & Signals
Shafaan Khaliq Bhatti
 
Deadlock avoidance (Safe State, Resource Allocation Graph Algorithm)
Deadlock avoidance (Safe State, Resource Allocation Graph Algorithm)
Shayek Parvez
 
Multi-Hopping
Multi-Hopping
Aditya Pandey
 
Types and Functions of DDBMS
Types and Functions of DDBMS
Adeel Rasheed
 
Multithreading Presentation
Multithreading Presentation
Neeraj Kaushik
 
Program and Network Properties
Program and Network Properties
Beekrum Duwal
 
Operating system 31 multiple processor scheduling
Operating system 31 multiple processor scheduling
Vaibhav Khanna
 
Security in distributed systems
Security in distributed systems
Haitham Ahmed
 
Concept of Pipelining
Concept of Pipelining
SHAKOOR AB
 
Local multipoint distribution service(lmds)
Local multipoint distribution service(lmds)
Vivek Kumar
 
memory Interleaving and low order interleaving and high interleaving
memory Interleaving and low order interleaving and high interleaving
Jawwad Rafiq
 
Tcp Udp Icmp And The Transport Layer
Tcp Udp Icmp And The Transport Layer
tmavroidis
 
Embedded Systems (18EC62) - ARM Cortex-M3 Instruction Set and Programming (Mo...
Embedded Systems (18EC62) - ARM Cortex-M3 Instruction Set and Programming (Mo...
Shrishail Bhat
 
Deadlock avoidance (Safe State, Resource Allocation Graph Algorithm)
Deadlock avoidance (Safe State, Resource Allocation Graph Algorithm)
Shayek Parvez
 
Types and Functions of DDBMS
Types and Functions of DDBMS
Adeel Rasheed
 

Similar to Parallel programming concept dependency and loop parallelization (20)

Optimization Techniques
Optimization Techniques
Joud Khattab
 
Loop Unroll_ACA_CS505.ppt
Loop Unroll_ACA_CS505.ppt
HassanJavaid48
 
Parallel Computing with SolrCloud: Presented by Joel Bernstein, Alfresco
Parallel Computing with SolrCloud: Presented by Joel Bernstein, Alfresco
Lucidworks
 
Parallel SQL for SolrCloud
Parallel SQL for SolrCloud
Joel Bernstein
 
Chapter 2 Boolean Algebra (part 2)
Chapter 2 Boolean Algebra (part 2)
Frankie Jones
 
LOOP STATEMENTS AND TYPES OF LOOP IN C LANGUAGE BY RIZWAN
LOOP STATEMENTS AND TYPES OF LOOP IN C LANGUAGE BY RIZWAN
MD RIZWAN MOLLA
 
Data Flow Modeling
Data Flow Modeling
Padmanaban Kalyanaraman
 
Dzanan_Bajgoric_C2CUDA_MscThesis_Present
Dzanan_Bajgoric_C2CUDA_MscThesis_Present
Džanan Bajgorić
 
Cursor
Cursor
Jay Patel
 
Cursor
Cursor
Jay Patel
 
parallel programming.ppt
parallel programming.ppt
nazimsattar
 
VLSI Lab manual PDF
VLSI Lab manual PDF
UR11EC098
 
Pavlo Zhdanov "Mastering solid and base principles for software design"
Pavlo Zhdanov "Mastering solid and base principles for software design"
LogeekNightUkraine
 
Algorithms of graph
Algorithms of graph
getacew
 
Lab9 processos
Lab9 processos
Eduardo Bezerra
 
Realtime Analytics
Realtime Analytics
eXascale Infolab
 
Number_Systems_and_Boolean_Algebra.ppt
Number_Systems_and_Boolean_Algebra.ppt
VEERA BOOPATHY E
 
Compiling openCypher graph queries with Spark Catalyst
Compiling openCypher graph queries with Spark Catalyst
Gábor Szárnyas
 
m4_VHDL_ED.pdf
m4_VHDL_ED.pdf
JonGarciario
 
Digital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECE
Ramesh Naik Bhukya
 
Optimization Techniques
Optimization Techniques
Joud Khattab
 
Loop Unroll_ACA_CS505.ppt
Loop Unroll_ACA_CS505.ppt
HassanJavaid48
 
Parallel Computing with SolrCloud: Presented by Joel Bernstein, Alfresco
Parallel Computing with SolrCloud: Presented by Joel Bernstein, Alfresco
Lucidworks
 
Parallel SQL for SolrCloud
Parallel SQL for SolrCloud
Joel Bernstein
 
Chapter 2 Boolean Algebra (part 2)
Chapter 2 Boolean Algebra (part 2)
Frankie Jones
 
LOOP STATEMENTS AND TYPES OF LOOP IN C LANGUAGE BY RIZWAN
LOOP STATEMENTS AND TYPES OF LOOP IN C LANGUAGE BY RIZWAN
MD RIZWAN MOLLA
 
Dzanan_Bajgoric_C2CUDA_MscThesis_Present
Dzanan_Bajgoric_C2CUDA_MscThesis_Present
Džanan Bajgorić
 
parallel programming.ppt
parallel programming.ppt
nazimsattar
 
VLSI Lab manual PDF
VLSI Lab manual PDF
UR11EC098
 
Pavlo Zhdanov "Mastering solid and base principles for software design"
Pavlo Zhdanov "Mastering solid and base principles for software design"
LogeekNightUkraine
 
Algorithms of graph
Algorithms of graph
getacew
 
Number_Systems_and_Boolean_Algebra.ppt
Number_Systems_and_Boolean_Algebra.ppt
VEERA BOOPATHY E
 
Compiling openCypher graph queries with Spark Catalyst
Compiling openCypher graph queries with Spark Catalyst
Gábor Szárnyas
 
Digital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECE
Ramesh Naik Bhukya
 
Ad

Recently uploaded (20)

LDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation Sampler
LDM & Mia eStudios
 
BINARY files CSV files JSON files with example.pptx
BINARY files CSV files JSON files with example.pptx
Ramakrishna Reddy Bijjam
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
Introduction to Generative AI and Copilot.pdf
Introduction to Generative AI and Copilot.pdf
TechSoup
 
How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18
Celine George
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
LDMMIA Spring Ending Guest Grad Student News
LDMMIA Spring Ending Guest Grad Student News
LDM & Mia eStudios
 
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
Arshad Shaikh
 
Nice Dream.pdf /
Nice Dream.pdf /
ErinUsher3
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
Overview of Employee in Odoo 18 - Odoo Slides
Overview of Employee in Odoo 18 - Odoo Slides
Celine George
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
LDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation Sampler
LDM & Mia eStudios
 
BINARY files CSV files JSON files with example.pptx
BINARY files CSV files JSON files with example.pptx
Ramakrishna Reddy Bijjam
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
Introduction to Generative AI and Copilot.pdf
Introduction to Generative AI and Copilot.pdf
TechSoup
 
How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18
Celine George
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
LDMMIA Spring Ending Guest Grad Student News
LDMMIA Spring Ending Guest Grad Student News
LDM & Mia eStudios
 
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
Arshad Shaikh
 
Nice Dream.pdf /
Nice Dream.pdf /
ErinUsher3
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
Overview of Employee in Odoo 18 - Odoo Slides
Overview of Employee in Odoo 18 - Odoo Slides
Celine George
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
Ad

Parallel programming concept dependency and loop parallelization

  • 1. PARALLEL PROGRAMMING CONCEPT DEPENDENCY AND LOOP PARALLELIZATION •Parallel programming concept and their examples •Dependency and their two types with examples •Loop parallelism and their types with examples R.AISHWARYA
  • 4. • Simultaneous use of multiple compute resources to solve a computational problem • Compute resources • Primary reasons • Best practices • Goals • Steps
  • 8. Statement 2: b=a+2; “5” Statement 1: a=5;
  • 9. •Find dependencies within iterations of a loop •Goal of determining different relationships between statements. •To allow multiple processors to work on different portions of the loop in parallel •First analyze the dependencies within individual loops. •It help determine which statements in the loop need to be completed before other statements can start. •Two general categories of dependencies: Data and Control dependency
  • 10. function Dep(a,b) c:=a.b d:=2.c end function (flow dependency) function Nodep(a,b) c:=a.b d:=2.b e:=a+b end function (no dependency)
  • 11. DATA DEPENDENCY TYPE NOTATION DESCRIPTION True (Flow) Dependence S1 ->T S2 A true dependence between S1 and S2 means that S1 writes to a location later read from by S2 Anti Dependence S1 ->A S2 An anti-dependence between S1 and S2 means that S1 reads from a location later written to by S2.(before) Output Dependence S1 ->I S2 An input dependence between S1 and S2 means that S1 and S2 read from the same location.
  • 12. EXAMPLES True dependence S0: int a, b; S1: a = 2; S2: b = a + 40; S1 ->T S2, meaning that S1 has a true dependence on S2 because S1writes to the variable a, which S2 reads from. Anti-dependence S0: int a, b = 40; S1: a = b - 38; S2: b = -1; S1 ->A S2, meaning that S1 has an anti-dependence on S2 because S1reads from the variable b before S2 writes to it. Output-dependence S0: int a, b = 40; S1: a = b - 38; S2: a = 2; S1 ->O S2, meaning that S1 has an output dependence on S2 because both write to the variable a.
  • 13. CONTROL DEPENDENCY if(a == b) then { c = “controlled”; } d=“not controlled”; if(a == b) then { } c = “controlled”; d=“not controlled”; if(a == b) then { c = “controlled”; d=“not controlled”; }
  • 14. DEPENDENCY IN LOOP Loops can have two types of dependence: •Loop-carried dependency •Loop-independent dependency
  • 15. LOOP CARRIED DEPENDENCY • In loop-carried dependence, statements in an iteration of a loop depend on statements in another iteration of the loop. for(i=0;i<4;i++) { S1: b[i]=8; S2: a[i]=b[i-1] + 10; }
  • 16. LOOP INDEPENDENT DEPENDENCY • In loop-independent dependence, loops have inter-iteration dependence, but do not have dependence between iterations. • Each iteration may be treated as a block and performed in parallel without other synchronization efforts. for (i=0;i<4;i++) { S1: b[i] = 8; S2: a[i] =b[i] + 10; }
  • 17. for (i=1; i<4; i++) for (j=1; j<4; j++) S3: a[i][j] = a[i][j-1] + 1; Node : Point in the iteration space Directed Edge: Dependency Node: Point in the iteration space Directed Edge: next point that will be encountered after the current point is traversed
  • 19. •Extraction parallel tasks from loops •Data is stored in random access data structures •A program exploiting loop-level parallelism will use multiple threads or processes which operate on same time •It provides speedup •Amdhal’s law
  • 20. Examples of Loop parallelization for (int i = 0; i < n; i++) { S1: L[i] = L[i] + 10; } for (int i = 1; i < n; i++) { S1: L[i] = L[i - 1] + 10; }
  • 21. Can the following Loop be made Parallel? for (i=1;i<=100;i=i+1) { A[i+1] = A[i] + C[i]; /*S1*/ B[i+1] = B[i] + A[i+1]; /*S2*/ }
  • 22. METHODOLOGIES FOR PARALLELIZING LOOPS • DISTRIBUTED Loop • DOALL Parallelism • DOACROSS Parallelism • HELIX • DOPIPE Parallelism
  • 23. DISTRIBUTED LOOP for (int i = 1; i < n; i ++) { S1: a[i] = a[i -1] + b[i]; S2: c[i] = c[i] + d[i]; } loop1: for (int i = 1; i < n; i ++) { S1: a[i] = a[i -1] + b[i]; } loop2: for (int i = 1; i < n; i ++) { S2: c[i] = c[i] + d[i]; }
  • 24. DO ALL PARALLELISM for (int i = 0; i < n; i++) { S1: a[i] = b[i] + c[i]; } begin_parallelism(); for (int i = 0; i < n; i++) { S1: a[i] = b[i] + c[i]; end_parallelism(); } block();
  • 25. DO ACROSS PARALLELISM for (int i = 1; i < n; i++) { a[i] = a[i - 1] + b[i] + 1; } S1: int tmp = b[i] + 1; S2: a[i] = a[i - 1] + tmp; post(0); for (int i = 1; i < n; i++) { S1: int tmp = b[i] + 1; wait(i - 1); S2: a[i] = a[i - 1] + tmp; post(i); }
  • 26. DO PIPE PARALLELISM for (int i = 1; i < n; i++) { S1: a[i] = a[i - 1] + b[i]; S2: c[i] = c[i] + a[i]; } for (int i = 1; i < n; i++) { S1: a[i] = a[i - 1] + b[i]; post(i); } for (int i = 1; i < n; i++) { wait(i); S2: c[i] = c[i] + a[i]; }