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???
• Simultaneous use of multiple compute
resources to solve a computational problem
• Compute resources
• Primary reasons
• Best practices
• Goals
• Steps
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

INTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxINTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptx
LECO9
 
Pipelinig hazardous
Pipelinig hazardousPipelinig hazardous
Pipelinig hazardous
jasscheema
 
Superscalar Processor
Superscalar ProcessorSuperscalar Processor
Superscalar Processor
Manash Kumar Mondal
 
Optimistic concurrency control in Distributed Systems
Optimistic concurrency control in Distributed SystemsOptimistic concurrency control in Distributed Systems
Optimistic concurrency control in Distributed Systems
mridul mishra
 
VLIW(Very Long Instruction Word)
VLIW(Very Long Instruction Word)VLIW(Very Long Instruction Word)
VLIW(Very Long Instruction Word)
Pragnya Dash
 
open system interconnection
open system interconnectionopen system interconnection
open system interconnection
Ruchi Maurya
 
Multithreading
MultithreadingMultithreading
Multithreading
A B Shinde
 
OSI Model - Open Systems Interconnection
OSI Model - Open Systems InterconnectionOSI Model - Open Systems Interconnection
OSI Model - Open Systems Interconnection
Adeel Rasheed
 
Multithreading computer architecture
 Multithreading computer architecture  Multithreading computer architecture
Multithreading computer architecture
Haris456
 
Osi model vs TCP/IP
Osi model vs TCP/IPOsi model vs TCP/IP
Osi model vs TCP/IP
Mannu Khani
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
Sara Ali
 
Unit IV Memory and I/O Organization
Unit IV Memory and I/O OrganizationUnit IV Memory and I/O Organization
Unit IV Memory and I/O Organization
Balaji Vignesh
 
Os Threads
Os ThreadsOs Threads
Os Threads
Salman Memon
 
Media Access Control (MAC Layer)
Media Access Control (MAC Layer)Media Access Control (MAC Layer)
Media Access Control (MAC Layer)
Meenakshi Paul
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
Anil Kumar Pugalia
 
Chapter 11
Chapter 11Chapter 11
Chapter 11
AbDul ThaYyal
 
Major Function of i/o module
Major Function of i/o moduleMajor Function of i/o module
Major Function of i/o module
Delowar Hossain
 
Real time scheduling - basic concepts
Real time scheduling - basic conceptsReal time scheduling - basic concepts
Real time scheduling - basic concepts
Student
 
deadlock
deadlockdeadlock
Interrupts
Interrupts Interrupts
Interrupts
Zara Tariq
 

What's hot (20)

INTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxINTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptx
 
Pipelinig hazardous
Pipelinig hazardousPipelinig hazardous
Pipelinig hazardous
 
Superscalar Processor
Superscalar ProcessorSuperscalar Processor
Superscalar Processor
 
Optimistic concurrency control in Distributed Systems
Optimistic concurrency control in Distributed SystemsOptimistic concurrency control in Distributed Systems
Optimistic concurrency control in Distributed Systems
 
VLIW(Very Long Instruction Word)
VLIW(Very Long Instruction Word)VLIW(Very Long Instruction Word)
VLIW(Very Long Instruction Word)
 
open system interconnection
open system interconnectionopen system interconnection
open system interconnection
 
Multithreading
MultithreadingMultithreading
Multithreading
 
OSI Model - Open Systems Interconnection
OSI Model - Open Systems InterconnectionOSI Model - Open Systems Interconnection
OSI Model - Open Systems Interconnection
 
Multithreading computer architecture
 Multithreading computer architecture  Multithreading computer architecture
Multithreading computer architecture
 
Osi model vs TCP/IP
Osi model vs TCP/IPOsi model vs TCP/IP
Osi model vs TCP/IP
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
 
Unit IV Memory and I/O Organization
Unit IV Memory and I/O OrganizationUnit IV Memory and I/O Organization
Unit IV Memory and I/O Organization
 
Os Threads
Os ThreadsOs Threads
Os Threads
 
Media Access Control (MAC Layer)
Media Access Control (MAC Layer)Media Access Control (MAC Layer)
Media Access Control (MAC Layer)
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
 
Chapter 11
Chapter 11Chapter 11
Chapter 11
 
Major Function of i/o module
Major Function of i/o moduleMajor Function of i/o module
Major Function of i/o module
 
Real time scheduling - basic concepts
Real time scheduling - basic conceptsReal time scheduling - basic concepts
Real time scheduling - basic concepts
 
deadlock
deadlockdeadlock
deadlock
 
Interrupts
Interrupts Interrupts
Interrupts
 

Similar to Parallel programming concept dependency and loop parallelization

Optimization Techniques
Optimization TechniquesOptimization Techniques
Optimization Techniques
Joud Khattab
 
Loop Unroll_ACA_CS505.ppt
Loop Unroll_ACA_CS505.pptLoop 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, AlfrescoParallel 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 SolrCloudParallel SQL for SolrCloud
Parallel SQL for SolrCloud
Joel Bernstein
 
Chapter 2 Boolean Algebra (part 2)
Chapter 2 Boolean Algebra (part 2)Chapter 2 Boolean Algebra (part 2)
Chapter 2 Boolean Algebra (part 2)
Frankie Jones
 
Data Flow Modeling
Data Flow ModelingData Flow Modeling
Data Flow Modeling
Padmanaban Kalyanaraman
 
Dzanan_Bajgoric_C2CUDA_MscThesis_Present
Dzanan_Bajgoric_C2CUDA_MscThesis_PresentDzanan_Bajgoric_C2CUDA_MscThesis_Present
Dzanan_Bajgoric_C2CUDA_MscThesis_Present
Džanan Bajgorić
 
Cursor
CursorCursor
Cursor
Jay Patel
 
Cursor
CursorCursor
Cursor
Jay Patel
 
parallel programming.ppt
parallel programming.pptparallel programming.ppt
parallel programming.ppt
nazimsattar
 
VLSI Lab manual PDF
VLSI Lab manual PDFVLSI 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"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 graphAlgorithms of graph
Algorithms of graph
getacew
 
Lab9 processos
Lab9 processosLab9 processos
Lab9 processos
Eduardo Bezerra
 
Realtime Analytics
Realtime AnalyticsRealtime Analytics
Realtime Analytics
eXascale Infolab
 
Number_Systems_and_Boolean_Algebra.ppt
Number_Systems_and_Boolean_Algebra.pptNumber_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 CatalystCompiling openCypher graph queries with Spark Catalyst
Compiling openCypher graph queries with Spark Catalyst
Gábor Szárnyas
 
m4_VHDL_ED.pdf
m4_VHDL_ED.pdfm4_VHDL_ED.pdf
m4_VHDL_ED.pdf
JonGarciario
 
Digital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECEDigital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECE
Ramesh Naik Bhukya
 
Normalization.pdf
Normalization.pdfNormalization.pdf
Normalization.pdf
abhijose1
 

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

Optimization Techniques
Optimization TechniquesOptimization Techniques
Optimization Techniques
 
Loop Unroll_ACA_CS505.ppt
Loop Unroll_ACA_CS505.pptLoop Unroll_ACA_CS505.ppt
Loop Unroll_ACA_CS505.ppt
 
Parallel Computing with SolrCloud: Presented by Joel Bernstein, Alfresco
Parallel Computing with SolrCloud: Presented by Joel Bernstein, AlfrescoParallel Computing with SolrCloud: Presented by Joel Bernstein, Alfresco
Parallel Computing with SolrCloud: Presented by Joel Bernstein, Alfresco
 
Parallel SQL for SolrCloud
Parallel SQL for SolrCloudParallel SQL for SolrCloud
Parallel SQL for SolrCloud
 
Chapter 2 Boolean Algebra (part 2)
Chapter 2 Boolean Algebra (part 2)Chapter 2 Boolean Algebra (part 2)
Chapter 2 Boolean Algebra (part 2)
 
Data Flow Modeling
Data Flow ModelingData Flow Modeling
Data Flow Modeling
 
Dzanan_Bajgoric_C2CUDA_MscThesis_Present
Dzanan_Bajgoric_C2CUDA_MscThesis_PresentDzanan_Bajgoric_C2CUDA_MscThesis_Present
Dzanan_Bajgoric_C2CUDA_MscThesis_Present
 
Cursor
CursorCursor
Cursor
 
Cursor
CursorCursor
Cursor
 
parallel programming.ppt
parallel programming.pptparallel programming.ppt
parallel programming.ppt
 
VLSI Lab manual PDF
VLSI Lab manual PDFVLSI Lab manual PDF
VLSI Lab manual PDF
 
Pavlo Zhdanov "Mastering solid and base principles for software design"
Pavlo Zhdanov "Mastering solid and base principles for software design"Pavlo Zhdanov "Mastering solid and base principles for software design"
Pavlo Zhdanov "Mastering solid and base principles for software design"
 
Algorithms of graph
Algorithms of graphAlgorithms of graph
Algorithms of graph
 
Lab9 processos
Lab9 processosLab9 processos
Lab9 processos
 
Realtime Analytics
Realtime AnalyticsRealtime Analytics
Realtime Analytics
 
Number_Systems_and_Boolean_Algebra.ppt
Number_Systems_and_Boolean_Algebra.pptNumber_Systems_and_Boolean_Algebra.ppt
Number_Systems_and_Boolean_Algebra.ppt
 
Compiling openCypher graph queries with Spark Catalyst
Compiling openCypher graph queries with Spark CatalystCompiling openCypher graph queries with Spark Catalyst
Compiling openCypher graph queries with Spark Catalyst
 
m4_VHDL_ED.pdf
m4_VHDL_ED.pdfm4_VHDL_ED.pdf
m4_VHDL_ED.pdf
 
Digital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECEDigital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECE
 
Normalization.pdf
Normalization.pdfNormalization.pdf
Normalization.pdf
 

Recently uploaded

Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
danielkiash986
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
iammrhaywood
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
RidwanHassanYusuf
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
ssuser13ffe4
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
zuzanka
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
Steve Thomason
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
RamseyBerglund
 
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDFLifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Vivekanand Anglo Vedic Academy
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
deepaannamalai16
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
 

Recently uploaded (20)

Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
 
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDFLifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
 

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
  • 3.
  • 4. • Simultaneous use of multiple compute resources to solve a computational problem • Compute resources • Primary reasons • Best practices • Goals • Steps
  • 5.
  • 6.
  • 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]; }