SlideShare a Scribd company logo
1 of 29
Parallel Algorithms
DESIGN AND ANALYSIS OF ALGORITHMS
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Group Members
Arsalan Ali Daim (BSCS14068)
Danish Javed (BSCS14028)
Muhammad Hamza (BSCS14062)
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Outline
1. What is Parallel Algorithm?
2. Its Abilities.
3. Why Parallel Computing?
4. Parallel Algorithms.
5. Limitations for Parallel Algorithms.
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
What is Parallel Algorithm?
A parallel algorithm is an algorithm that has been
specifically written for execution on a computer with two or
more processors.
But it can be run on computers with single processor
(multiple functional units, pipelined functional units, pipelined memory systems)
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
What makes Parallel Algorithms better?
• Throughput: Is the number of operations done per time unit.
• Latency : Is the time needed to complete one operation.
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Why Parallel Computing?
The Real World is Massively Parallel:
• In the natural world, many complex, interrelated events are happening at the same time, yet within a
temporal sequence.
• Compared to serial computing, parallel computing is much better suited for modeling, simulating and
understanding complex, real world phenomena.
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Why Parallel Computing?
SOLVE LARGER / MORE COMPLEX PROBLEMS:
• Many problems are so large and/or complex that it is impractical or impossible to solve them on a
single computer, especially given limited computer memory.
• Example: Web search engines/databases processing millions of transactions per second
TAKE ADVANTAGE OF NON-LOCAL RESOURCES:
• Using computer resources on a wide area network, or even the Internet when local computer
resources are scarce or insufficient.
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Hardware implementation for
Parallel algorithms (PRAM MODEL)
In the PRAM model, processors communicate by reading from and writing to the shared
memory locations
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Classification of PRAM MODEL
PRAM is classified in two basic types
1. CRAM(Concurrent RAM)
2. ERAM(Exclusive RAM)
And they also have some combinations.
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Parallel Algorithm
1. Odd – Even Transposition Sort
2. Parallel Merge Sort
3. Computing Sum of a Sequence with parallelism
There are many more…
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Odd – Even Transposition Sort
 Variation of bubble sort.
 Operates in two alternating phases, even phase and odd phase.
 Even phase
Even-numbered processes exchange numbers with their right
neighbors.
 Odd phase
Odd-numbered processes exchange numbers with their
right neighbors.
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Odd – Even Transposition Sort – Example
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Parallel time complexity: Tpar = O(n) (for P=n)
Algorithm
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Odd – Even Transposition Sort
Assuming our array of n elements to sort is
very large, we will be working with many
virtual processors on the same processor
to emulate one Process per element.
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Merge Sort
Example of divide and conquer algorithms.
Sorting algorithm to sort a vector, first divide it into two parts.
Apply same method again to each subdivided part. When both are sorted with m and n
elements.
Merge them and it will produce sorted vector.
The average complexity T(n) = O(nlogn)
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Parallel Merge Sort
Divided into two tasks:
1.Divide the list
2.Conquer the list
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Parallel Merge Sort
Divide the list onto different processors
Simple tree structure like this:
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Parallel Merge Sort
Merge elements as they come together.
Simple tree structure like this:
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Parallel Merge Sort – Algorithm
ALGORITHM: mergesort(A)
1 if (|A| = 1) then return A
2 else
3 in parallel do
4 L := mergesort(A[0..|A|/2))
5 R := mergesort(A[|A|/2..|A|))
6 return merge(L, R)
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Parallel Merge Sort – Complexity
Sequential Merge Sort = O(nlogn)
In Parallel, we have n processors
logn time required to divide sequence
logn time required to merge sequence
logn+logn = 2logn
So, T(n) = O(logn)
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Computing the sum of a Sequence.
Consider a sequence of n elements.
Devise an algorithm that performs many operations in parallel.
In parallel, each element of A with an even index is paired and summed with the next element
of A. Like , A[0] is paired with A[1], A[2] with A[3], and so on.
The result is a new sequence of ⌈n/2⌉ numbers.
This pairing and summing step can be repeated until, after ⌈log2 n⌉ steps, a sequence consisting
of a single value is produced, and this value is equal to the final sum.
Sequentially, its time complexity is O(n) but using this technique of parallelism the time
complexity reduced to O(log2n).
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
The Limitations and Problems
• Data Dependency
• Race Condition
• Resource Requirements
• Scalability
• Parallel Slowdown
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Data Dependency
Results from multiple use of the same location(s) in storage by different tasks.
e.g.
for (int i=0;i<100;i++)
array[i]=array[i-1]*20;
Shared memory architectures -synchronize read/write operations between tasks.
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Race Condition
If instruction 1B is executed between 1A and 3A, or if instruction 1A is executed between 1B and
3B, the program will produce incorrect data. This is known as a race condition.
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Resource Requirements
• The primary intent of parallel programming is to decrease execution wall clock time, however
in order to accomplish this, more CPU time is required. For example, a parallel code that runs
in 1 hour on 8 processors actually uses 8 hours of CPU time.
• The amount of memory required can be greater for parallel codes than serial codes, due to
the need to replicate data and for overheads associated with parallel support libraries and
subsystems.
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Scalability
Two types of scaling based on time to solution:
◦ Strong scaling: The total problem size stays fixed as more processors are added.
◦ Weak scaling: The problem size per processor stays fixed as more processors are added.
Hardware factors play a significant role in scalability. Examples:
◦ Memory-CPU bus bandwidth
◦ Amount of memory available on any given machine or set of machines
◦ Processor clock speed
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Parallel Slowdown
• Not all parallelization results in speed-up.
• Once task split up into multiple threads those threads spend a large amount of time
communicating among each other resulting degradation in the system.
• This is known as parallel slowdown.
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
Parallel Slowdown – Example
I have observed a few such attempts where parallel code used the Threading Building
Blocks library (TBB). Much to experimenters’ astonishment, not only their simple parallel
programs sometimes expose no reasonable speedup but even those can be slower than
sequential counterparts!
Conclusion: when developing programs with TBB, you should take into account that using TBB
classes and functions may impact compiler optimizations, which has especially bad impact on
simple algorithms with small amount of work per iteration. Proper use of local variables helps
optimization and improves parallel speedup.
For Further info: https://software.intel.com/en-us/blogs/2008/03/04/why-a-simple-test-can-
get-parallel-slowdown
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
The End.
PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
‫شکریہ‬

More Related Content

What's hot

Lecture 06 production system
Lecture 06 production systemLecture 06 production system
Lecture 06 production systemHema Kashyap
 
Classification using back propagation algorithm
Classification using back propagation algorithmClassification using back propagation algorithm
Classification using back propagation algorithmKIRAN R
 
Lecture 1 introduction to parallel and distributed computing
Lecture 1   introduction to parallel and distributed computingLecture 1   introduction to parallel and distributed computing
Lecture 1 introduction to parallel and distributed computingVajira Thambawita
 
Thrashing allocation frames.43
Thrashing allocation frames.43Thrashing allocation frames.43
Thrashing allocation frames.43myrajendra
 
management of distributed transactions
management of distributed transactionsmanagement of distributed transactions
management of distributed transactionsNilu Desai
 
Load Balancing in Parallel and Distributed Database
Load Balancing in Parallel and Distributed DatabaseLoad Balancing in Parallel and Distributed Database
Load Balancing in Parallel and Distributed DatabaseMd. Shamsur Rahim
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithmsDr Geetha Mohan
 
Matching techniques
Matching techniquesMatching techniques
Matching techniquesNagpalkirti
 
Inductive bias
Inductive biasInductive bias
Inductive biasswapnac12
 
Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...
Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...
Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...Gyanmanjari Institute Of Technology
 
Agreement Protocols, distributed File Systems, Distributed Shared Memory
Agreement Protocols, distributed File Systems, Distributed Shared MemoryAgreement Protocols, distributed File Systems, Distributed Shared Memory
Agreement Protocols, distributed File Systems, Distributed Shared MemorySHIKHA GAUTAM
 
Principles of soft computing-Associative memory networks
Principles of soft computing-Associative memory networksPrinciples of soft computing-Associative memory networks
Principles of soft computing-Associative memory networksSivagowry Shathesh
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy methodhodcsencet
 
Advanced topics in artificial neural networks
Advanced topics in artificial neural networksAdvanced topics in artificial neural networks
Advanced topics in artificial neural networksswapnac12
 
Production System in AI
Production System in AIProduction System in AI
Production System in AIBharat Bhushan
 

What's hot (20)

Artificial Neural Networks for Data Mining
Artificial Neural Networks for Data MiningArtificial Neural Networks for Data Mining
Artificial Neural Networks for Data Mining
 
Lecture 06 production system
Lecture 06 production systemLecture 06 production system
Lecture 06 production system
 
Classification using back propagation algorithm
Classification using back propagation algorithmClassification using back propagation algorithm
Classification using back propagation algorithm
 
Lecture 1 introduction to parallel and distributed computing
Lecture 1   introduction to parallel and distributed computingLecture 1   introduction to parallel and distributed computing
Lecture 1 introduction to parallel and distributed computing
 
Pram model
Pram modelPram model
Pram model
 
Thrashing allocation frames.43
Thrashing allocation frames.43Thrashing allocation frames.43
Thrashing allocation frames.43
 
management of distributed transactions
management of distributed transactionsmanagement of distributed transactions
management of distributed transactions
 
Basics of Soft Computing
Basics of Soft  Computing Basics of Soft  Computing
Basics of Soft Computing
 
Load Balancing in Parallel and Distributed Database
Load Balancing in Parallel and Distributed DatabaseLoad Balancing in Parallel and Distributed Database
Load Balancing in Parallel and Distributed Database
 
Concurrency
ConcurrencyConcurrency
Concurrency
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithms
 
Matching techniques
Matching techniquesMatching techniques
Matching techniques
 
Inductive bias
Inductive biasInductive bias
Inductive bias
 
Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...
Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...
Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...
 
Agreement Protocols, distributed File Systems, Distributed Shared Memory
Agreement Protocols, distributed File Systems, Distributed Shared MemoryAgreement Protocols, distributed File Systems, Distributed Shared Memory
Agreement Protocols, distributed File Systems, Distributed Shared Memory
 
Principles of soft computing-Associative memory networks
Principles of soft computing-Associative memory networksPrinciples of soft computing-Associative memory networks
Principles of soft computing-Associative memory networks
 
Parallel computing persentation
Parallel computing persentationParallel computing persentation
Parallel computing persentation
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
 
Advanced topics in artificial neural networks
Advanced topics in artificial neural networksAdvanced topics in artificial neural networks
Advanced topics in artificial neural networks
 
Production System in AI
Production System in AIProduction System in AI
Production System in AI
 

Viewers also liked

Parallel sorting algorithm
Parallel sorting algorithmParallel sorting algorithm
Parallel sorting algorithmRicha Kumari
 
Parallel Algorithm Models
Parallel Algorithm ModelsParallel Algorithm Models
Parallel Algorithm ModelsMartin Coronel
 
Parallel sorting Algorithms
Parallel  sorting AlgorithmsParallel  sorting Algorithms
Parallel sorting AlgorithmsGARIMA SHAKYA
 
Parallel Algorithms Advantages and Disadvantages
Parallel Algorithms Advantages and DisadvantagesParallel Algorithms Advantages and Disadvantages
Parallel Algorithms Advantages and DisadvantagesMurtadha Alsabbagh
 
Algorithm Analysis and Design Class Notes
Algorithm Analysis and Design Class NotesAlgorithm Analysis and Design Class Notes
Algorithm Analysis and Design Class NotesKumar Avinash
 
An OpenCL Method of Parallel Sorting Algorithms for GPU Architecture
An OpenCL Method of Parallel Sorting Algorithms for GPU ArchitectureAn OpenCL Method of Parallel Sorting Algorithms for GPU Architecture
An OpenCL Method of Parallel Sorting Algorithms for GPU ArchitectureWaqas Tariq
 
parallel sorting by regular sampling
parallel sorting by regular samplingparallel sorting by regular sampling
parallel sorting by regular samplingWei Mu
 
Analysis &amp; design of algorithm
Analysis &amp; design of algorithmAnalysis &amp; design of algorithm
Analysis &amp; design of algorithmrahela bham
 
Introduction
IntroductionIntroduction
Introductionpilavare
 
Redesigning a large B2B website - The FusionCharts revamping story
Redesigning a large B2B website - The FusionCharts revamping storyRedesigning a large B2B website - The FusionCharts revamping story
Redesigning a large B2B website - The FusionCharts revamping storyFusionCharts
 
Design and Analysis of algorithms
Design and Analysis of algorithmsDesign and Analysis of algorithms
Design and Analysis of algorithmsDr. Rupa Ch
 
design and analysis of algorithm
design and analysis of algorithmdesign and analysis of algorithm
design and analysis of algorithmMuhammad Arish
 
Higher nab preparation
Higher nab preparationHigher nab preparation
Higher nab preparationscaddell
 
Introduction To Parallel Computing
Introduction To Parallel ComputingIntroduction To Parallel Computing
Introduction To Parallel ComputingJörn Dinkla
 
Introduction to Parallel Computing
Introduction to Parallel ComputingIntroduction to Parallel Computing
Introduction to Parallel ComputingRoshan Karunarathna
 

Viewers also liked (20)

Parallel sorting algorithm
Parallel sorting algorithmParallel sorting algorithm
Parallel sorting algorithm
 
Parallel Algorithm Models
Parallel Algorithm ModelsParallel Algorithm Models
Parallel Algorithm Models
 
parallel Merging
parallel Mergingparallel Merging
parallel Merging
 
Parallel sorting
Parallel sortingParallel sorting
Parallel sorting
 
Parallel sorting Algorithms
Parallel  sorting AlgorithmsParallel  sorting Algorithms
Parallel sorting Algorithms
 
Parallel Algorithms Advantages and Disadvantages
Parallel Algorithms Advantages and DisadvantagesParallel Algorithms Advantages and Disadvantages
Parallel Algorithms Advantages and Disadvantages
 
Algorithm Analysis and Design Class Notes
Algorithm Analysis and Design Class NotesAlgorithm Analysis and Design Class Notes
Algorithm Analysis and Design Class Notes
 
Design & Analysis Of Algorithm
Design & Analysis Of AlgorithmDesign & Analysis Of Algorithm
Design & Analysis Of Algorithm
 
An OpenCL Method of Parallel Sorting Algorithms for GPU Architecture
An OpenCL Method of Parallel Sorting Algorithms for GPU ArchitectureAn OpenCL Method of Parallel Sorting Algorithms for GPU Architecture
An OpenCL Method of Parallel Sorting Algorithms for GPU Architecture
 
24 Multithreaded Algorithms
24 Multithreaded Algorithms24 Multithreaded Algorithms
24 Multithreaded Algorithms
 
parallel sorting by regular sampling
parallel sorting by regular samplingparallel sorting by regular sampling
parallel sorting by regular sampling
 
Algorithms Question bank
Algorithms Question bankAlgorithms Question bank
Algorithms Question bank
 
Analysis &amp; design of algorithm
Analysis &amp; design of algorithmAnalysis &amp; design of algorithm
Analysis &amp; design of algorithm
 
Introduction
IntroductionIntroduction
Introduction
 
Redesigning a large B2B website - The FusionCharts revamping story
Redesigning a large B2B website - The FusionCharts revamping storyRedesigning a large B2B website - The FusionCharts revamping story
Redesigning a large B2B website - The FusionCharts revamping story
 
Design and Analysis of algorithms
Design and Analysis of algorithmsDesign and Analysis of algorithms
Design and Analysis of algorithms
 
design and analysis of algorithm
design and analysis of algorithmdesign and analysis of algorithm
design and analysis of algorithm
 
Higher nab preparation
Higher nab preparationHigher nab preparation
Higher nab preparation
 
Introduction To Parallel Computing
Introduction To Parallel ComputingIntroduction To Parallel Computing
Introduction To Parallel Computing
 
Introduction to Parallel Computing
Introduction to Parallel ComputingIntroduction to Parallel Computing
Introduction to Parallel Computing
 

Similar to Parallel algorithms

Introduction to OpenMP (Performance)
Introduction to OpenMP (Performance)Introduction to OpenMP (Performance)
Introduction to OpenMP (Performance)Akhila Prabhakaran
 
Migration To Multi Core - Parallel Programming Models
Migration To Multi Core - Parallel Programming ModelsMigration To Multi Core - Parallel Programming Models
Migration To Multi Core - Parallel Programming ModelsZvi Avraham
 
Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Dr. Pankaj Agarwal
 
The International Journal of Engineering and Science (The IJES)
The International Journal of Engineering and Science (The IJES)The International Journal of Engineering and Science (The IJES)
The International Journal of Engineering and Science (The IJES)theijes
 
Parallel Computing-Part-1.pptx
Parallel Computing-Part-1.pptxParallel Computing-Part-1.pptx
Parallel Computing-Part-1.pptxkrnaween
 
Parallel Computing - Lec 5
Parallel Computing - Lec 5Parallel Computing - Lec 5
Parallel Computing - Lec 5Shah Zaib
 
GRAPH MATCHING ALGORITHM FOR TASK ASSIGNMENT PROBLEM
GRAPH MATCHING ALGORITHM FOR TASK ASSIGNMENT PROBLEMGRAPH MATCHING ALGORITHM FOR TASK ASSIGNMENT PROBLEM
GRAPH MATCHING ALGORITHM FOR TASK ASSIGNMENT PROBLEMIJCSEA Journal
 
Data Parallel and Object Oriented Model
Data Parallel and Object Oriented ModelData Parallel and Object Oriented Model
Data Parallel and Object Oriented ModelNikhil Sharma
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxSyed Zaid Irshad
 
ICS 2410.Parallel.Sytsems.Lecture.Week 3.week5.pptx
ICS 2410.Parallel.Sytsems.Lecture.Week 3.week5.pptxICS 2410.Parallel.Sytsems.Lecture.Week 3.week5.pptx
ICS 2410.Parallel.Sytsems.Lecture.Week 3.week5.pptxjohnsmith96441
 
IRJET- Latin Square Computation of Order-3 using Open CL
IRJET- Latin Square Computation of Order-3 using Open CLIRJET- Latin Square Computation of Order-3 using Open CL
IRJET- Latin Square Computation of Order-3 using Open CLIRJET Journal
 
Data structure introduction
Data structure introductionData structure introduction
Data structure introductionNavneetSandhu0
 
Presentation_Parallel GRASP algorithm for job shop scheduling
Presentation_Parallel GRASP algorithm for job shop schedulingPresentation_Parallel GRASP algorithm for job shop scheduling
Presentation_Parallel GRASP algorithm for job shop schedulingAntonio Maria Fiscarelli
 

Similar to Parallel algorithms (20)

unit 2 hpc.pptx
unit 2 hpc.pptxunit 2 hpc.pptx
unit 2 hpc.pptx
 
Introduction to OpenMP (Performance)
Introduction to OpenMP (Performance)Introduction to OpenMP (Performance)
Introduction to OpenMP (Performance)
 
Gk3611601162
Gk3611601162Gk3611601162
Gk3611601162
 
Migration To Multi Core - Parallel Programming Models
Migration To Multi Core - Parallel Programming ModelsMigration To Multi Core - Parallel Programming Models
Migration To Multi Core - Parallel Programming Models
 
Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis
 
The International Journal of Engineering and Science (The IJES)
The International Journal of Engineering and Science (The IJES)The International Journal of Engineering and Science (The IJES)
The International Journal of Engineering and Science (The IJES)
 
Cc module 3.pptx
Cc module 3.pptxCc module 3.pptx
Cc module 3.pptx
 
Parallel Computing-Part-1.pptx
Parallel Computing-Part-1.pptxParallel Computing-Part-1.pptx
Parallel Computing-Part-1.pptx
 
Parallel Computing - Lec 5
Parallel Computing - Lec 5Parallel Computing - Lec 5
Parallel Computing - Lec 5
 
RAJAT PROJECT.pptx
RAJAT PROJECT.pptxRAJAT PROJECT.pptx
RAJAT PROJECT.pptx
 
GRAPH MATCHING ALGORITHM FOR TASK ASSIGNMENT PROBLEM
GRAPH MATCHING ALGORITHM FOR TASK ASSIGNMENT PROBLEMGRAPH MATCHING ALGORITHM FOR TASK ASSIGNMENT PROBLEM
GRAPH MATCHING ALGORITHM FOR TASK ASSIGNMENT PROBLEM
 
Data Parallel and Object Oriented Model
Data Parallel and Object Oriented ModelData Parallel and Object Oriented Model
Data Parallel and Object Oriented Model
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
 
ICS 2410.Parallel.Sytsems.Lecture.Week 3.week5.pptx
ICS 2410.Parallel.Sytsems.Lecture.Week 3.week5.pptxICS 2410.Parallel.Sytsems.Lecture.Week 3.week5.pptx
ICS 2410.Parallel.Sytsems.Lecture.Week 3.week5.pptx
 
Matrix Multiplication Report
Matrix Multiplication ReportMatrix Multiplication Report
Matrix Multiplication Report
 
IRJET- Latin Square Computation of Order-3 using Open CL
IRJET- Latin Square Computation of Order-3 using Open CLIRJET- Latin Square Computation of Order-3 using Open CL
IRJET- Latin Square Computation of Order-3 using Open CL
 
Interpreting the Data:Parallel Analysis with Sawzall
Interpreting the Data:Parallel Analysis with SawzallInterpreting the Data:Parallel Analysis with Sawzall
Interpreting the Data:Parallel Analysis with Sawzall
 
Data structure introduction
Data structure introductionData structure introduction
Data structure introduction
 
Parallel Computing
Parallel ComputingParallel Computing
Parallel Computing
 
Presentation_Parallel GRASP algorithm for job shop scheduling
Presentation_Parallel GRASP algorithm for job shop schedulingPresentation_Parallel GRASP algorithm for job shop scheduling
Presentation_Parallel GRASP algorithm for job shop scheduling
 

Recently uploaded

Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 

Recently uploaded (20)

Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 

Parallel algorithms

  • 1. Parallel Algorithms DESIGN AND ANALYSIS OF ALGORITHMS PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 2. Group Members Arsalan Ali Daim (BSCS14068) Danish Javed (BSCS14028) Muhammad Hamza (BSCS14062) PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 3. Outline 1. What is Parallel Algorithm? 2. Its Abilities. 3. Why Parallel Computing? 4. Parallel Algorithms. 5. Limitations for Parallel Algorithms. PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 4. What is Parallel Algorithm? A parallel algorithm is an algorithm that has been specifically written for execution on a computer with two or more processors. But it can be run on computers with single processor (multiple functional units, pipelined functional units, pipelined memory systems) PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 5. What makes Parallel Algorithms better? • Throughput: Is the number of operations done per time unit. • Latency : Is the time needed to complete one operation. PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 6. Why Parallel Computing? The Real World is Massively Parallel: • In the natural world, many complex, interrelated events are happening at the same time, yet within a temporal sequence. • Compared to serial computing, parallel computing is much better suited for modeling, simulating and understanding complex, real world phenomena. PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 7. Why Parallel Computing? SOLVE LARGER / MORE COMPLEX PROBLEMS: • Many problems are so large and/or complex that it is impractical or impossible to solve them on a single computer, especially given limited computer memory. • Example: Web search engines/databases processing millions of transactions per second TAKE ADVANTAGE OF NON-LOCAL RESOURCES: • Using computer resources on a wide area network, or even the Internet when local computer resources are scarce or insufficient. PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 8. Hardware implementation for Parallel algorithms (PRAM MODEL) In the PRAM model, processors communicate by reading from and writing to the shared memory locations PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 9. Classification of PRAM MODEL PRAM is classified in two basic types 1. CRAM(Concurrent RAM) 2. ERAM(Exclusive RAM) And they also have some combinations. PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 10. Parallel Algorithm 1. Odd – Even Transposition Sort 2. Parallel Merge Sort 3. Computing Sum of a Sequence with parallelism There are many more… PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 11. Odd – Even Transposition Sort  Variation of bubble sort.  Operates in two alternating phases, even phase and odd phase.  Even phase Even-numbered processes exchange numbers with their right neighbors.  Odd phase Odd-numbered processes exchange numbers with their right neighbors. PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 12. Odd – Even Transposition Sort – Example PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS) Parallel time complexity: Tpar = O(n) (for P=n)
  • 13. Algorithm PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 14. Odd – Even Transposition Sort Assuming our array of n elements to sort is very large, we will be working with many virtual processors on the same processor to emulate one Process per element. PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 15. Merge Sort Example of divide and conquer algorithms. Sorting algorithm to sort a vector, first divide it into two parts. Apply same method again to each subdivided part. When both are sorted with m and n elements. Merge them and it will produce sorted vector. The average complexity T(n) = O(nlogn) PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 16. Parallel Merge Sort Divided into two tasks: 1.Divide the list 2.Conquer the list PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 17. Parallel Merge Sort Divide the list onto different processors Simple tree structure like this: PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 18. Parallel Merge Sort Merge elements as they come together. Simple tree structure like this: PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 19. Parallel Merge Sort – Algorithm ALGORITHM: mergesort(A) 1 if (|A| = 1) then return A 2 else 3 in parallel do 4 L := mergesort(A[0..|A|/2)) 5 R := mergesort(A[|A|/2..|A|)) 6 return merge(L, R) PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 20. Parallel Merge Sort – Complexity Sequential Merge Sort = O(nlogn) In Parallel, we have n processors logn time required to divide sequence logn time required to merge sequence logn+logn = 2logn So, T(n) = O(logn) PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 21. Computing the sum of a Sequence. Consider a sequence of n elements. Devise an algorithm that performs many operations in parallel. In parallel, each element of A with an even index is paired and summed with the next element of A. Like , A[0] is paired with A[1], A[2] with A[3], and so on. The result is a new sequence of ⌈n/2⌉ numbers. This pairing and summing step can be repeated until, after ⌈log2 n⌉ steps, a sequence consisting of a single value is produced, and this value is equal to the final sum. Sequentially, its time complexity is O(n) but using this technique of parallelism the time complexity reduced to O(log2n). PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 22. The Limitations and Problems • Data Dependency • Race Condition • Resource Requirements • Scalability • Parallel Slowdown PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 23. Data Dependency Results from multiple use of the same location(s) in storage by different tasks. e.g. for (int i=0;i<100;i++) array[i]=array[i-1]*20; Shared memory architectures -synchronize read/write operations between tasks. PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 24. Race Condition If instruction 1B is executed between 1A and 3A, or if instruction 1A is executed between 1B and 3B, the program will produce incorrect data. This is known as a race condition. PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 25. Resource Requirements • The primary intent of parallel programming is to decrease execution wall clock time, however in order to accomplish this, more CPU time is required. For example, a parallel code that runs in 1 hour on 8 processors actually uses 8 hours of CPU time. • The amount of memory required can be greater for parallel codes than serial codes, due to the need to replicate data and for overheads associated with parallel support libraries and subsystems. PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 26. Scalability Two types of scaling based on time to solution: ◦ Strong scaling: The total problem size stays fixed as more processors are added. ◦ Weak scaling: The problem size per processor stays fixed as more processors are added. Hardware factors play a significant role in scalability. Examples: ◦ Memory-CPU bus bandwidth ◦ Amount of memory available on any given machine or set of machines ◦ Processor clock speed PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 27. Parallel Slowdown • Not all parallelization results in speed-up. • Once task split up into multiple threads those threads spend a large amount of time communicating among each other resulting degradation in the system. • This is known as parallel slowdown. PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 28. Parallel Slowdown – Example I have observed a few such attempts where parallel code used the Threading Building Blocks library (TBB). Much to experimenters’ astonishment, not only their simple parallel programs sometimes expose no reasonable speedup but even those can be slower than sequential counterparts! Conclusion: when developing programs with TBB, you should take into account that using TBB classes and functions may impact compiler optimizations, which has especially bad impact on simple algorithms with small amount of work per iteration. Proper use of local variables helps optimization and improves parallel speedup. For Further info: https://software.intel.com/en-us/blogs/2008/03/04/why-a-simple-test-can- get-parallel-slowdown PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS)
  • 29. The End. PARALLEL ALGORITHM (DESIGN AND ANALYSIS OF ALGORITHMS) ‫شکریہ‬