SlideShare a Scribd company logo
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

PDF
Parallel Algorithms
Dr Sandeep Kumar Poonia
 
PPTX
Introduction to Parallel and Distributed Computing
Sayed Chhattan Shah
 
PDF
Chapter 3 principles of parallel algorithm design
DenisAkbar1
 
PPTX
Twitter sentiment analysis ppt
SonuCreation
 
PPTX
Presentation on Elementary data structures
Kuber Chandra
 
PPTX
Cyber security
Siblu28
 
PPTX
Deciability (automata presentation)
Sagar Kumar
 
PDF
Intro to Buses (Computer Architecture)
Matthew Levandowski
 
Parallel Algorithms
Dr Sandeep Kumar Poonia
 
Introduction to Parallel and Distributed Computing
Sayed Chhattan Shah
 
Chapter 3 principles of parallel algorithm design
DenisAkbar1
 
Twitter sentiment analysis ppt
SonuCreation
 
Presentation on Elementary data structures
Kuber Chandra
 
Cyber security
Siblu28
 
Deciability (automata presentation)
Sagar Kumar
 
Intro to Buses (Computer Architecture)
Matthew Levandowski
 

What's hot (20)

PDF
Array Processor
Anshuman Biswal
 
PPTX
Parallel computing and its applications
Burhan Ahmed
 
PPTX
Dichotomy of parallel computing platforms
Syed Zaid Irshad
 
PPT
Parallel processing
rajshreemuthiah
 
PPT
Distributed & parallel system
Manish Singh
 
PDF
Design and analysis of algorithms
Dr Geetha Mohan
 
PPTX
Knowledge representation in AI
Vishal Singh
 
PPTX
Deadlock ppt
Sweetestangel Kochar
 
DOCX
Parallel computing persentation
VIKAS SINGH BHADOURIA
 
PDF
Parallelism
Md Raseduzzaman
 
PPTX
Applications of paralleL processing
Page Maker
 
PPT
Memory Management in OS
vampugani
 
PPTX
Distributed DBMS - Unit 5 - Semantic Data Control
Gyanmanjari Institute Of Technology
 
PPTX
Principal source of optimization in compiler design
Rajkumar R
 
PPTX
Paging and segmentation
Piyush Rochwani
 
PPTX
Uncertainty in AI
Amruth Veerabhadraiah
 
PPT
Chapter 13 - I/O Systems
Wayne Jones Jnr
 
PPTX
Microprogrammed Control Unit
PreethiSureshkumar1
 
PPTX
Parallel processing
Praveen Kumar
 
Array Processor
Anshuman Biswal
 
Parallel computing and its applications
Burhan Ahmed
 
Dichotomy of parallel computing platforms
Syed Zaid Irshad
 
Parallel processing
rajshreemuthiah
 
Distributed & parallel system
Manish Singh
 
Design and analysis of algorithms
Dr Geetha Mohan
 
Knowledge representation in AI
Vishal Singh
 
Deadlock ppt
Sweetestangel Kochar
 
Parallel computing persentation
VIKAS SINGH BHADOURIA
 
Parallelism
Md Raseduzzaman
 
Applications of paralleL processing
Page Maker
 
Memory Management in OS
vampugani
 
Distributed DBMS - Unit 5 - Semantic Data Control
Gyanmanjari Institute Of Technology
 
Principal source of optimization in compiler design
Rajkumar R
 
Paging and segmentation
Piyush Rochwani
 
Uncertainty in AI
Amruth Veerabhadraiah
 
Chapter 13 - I/O Systems
Wayne Jones Jnr
 
Microprogrammed Control Unit
PreethiSureshkumar1
 
Parallel processing
Praveen Kumar
 
Ad

Viewers also liked (20)

PPTX
Parallel sorting algorithm
Richa Kumari
 
PPT
Parallel Algorithm Models
Martin Coronel
 
PDF
Parallel Algorithms
Dr Sandeep Kumar Poonia
 
PPTX
parallel Merging
Richa Kumari
 
PPTX
Parallel sorting
Mr. Vikram Singh Slathia
 
PPT
Parallel algorithms
guest084d20
 
PDF
Parallel sorting Algorithms
GARIMA SHAKYA
 
PPTX
Parallel Algorithms Advantages and Disadvantages
Murtadha Alsabbagh
 
PDF
Algorithm Analysis and Design Class Notes
Kumar Avinash
 
PDF
Design & Analysis Of Algorithm
Computer Hardware & Trouble shooting
 
PDF
An OpenCL Method of Parallel Sorting Algorithms for GPU Architecture
Waqas Tariq
 
PDF
24 Multithreaded Algorithms
Andres Mendez-Vazquez
 
PDF
parallel sorting by regular sampling
Wei Mu
 
DOC
Algorithms Question bank
Shivalik college of engineering
 
PPTX
Analysis &amp; design of algorithm
rahela bham
 
PPT
Introduction
pilavare
 
PPTX
Redesigning a large B2B website - The FusionCharts revamping story
FusionCharts
 
RTF
Design and Analysis of algorithms
Dr. Rupa Ch
 
PDF
design and analysis of algorithm
Muhammad Arish
 
PPT
Higher nab preparation
scaddell
 
Parallel sorting algorithm
Richa Kumari
 
Parallel Algorithm Models
Martin Coronel
 
Parallel Algorithms
Dr Sandeep Kumar Poonia
 
parallel Merging
Richa Kumari
 
Parallel sorting
Mr. Vikram Singh Slathia
 
Parallel algorithms
guest084d20
 
Parallel sorting Algorithms
GARIMA SHAKYA
 
Parallel Algorithms Advantages and Disadvantages
Murtadha Alsabbagh
 
Algorithm Analysis and Design Class Notes
Kumar Avinash
 
Design & Analysis Of Algorithm
Computer Hardware & Trouble shooting
 
An OpenCL Method of Parallel Sorting Algorithms for GPU Architecture
Waqas Tariq
 
24 Multithreaded Algorithms
Andres Mendez-Vazquez
 
parallel sorting by regular sampling
Wei Mu
 
Algorithms Question bank
Shivalik college of engineering
 
Analysis &amp; design of algorithm
rahela bham
 
Introduction
pilavare
 
Redesigning a large B2B website - The FusionCharts revamping story
FusionCharts
 
Design and Analysis of algorithms
Dr. Rupa Ch
 
design and analysis of algorithm
Muhammad Arish
 
Higher nab preparation
scaddell
 
Ad

Similar to Parallel algorithms (20)

PPTX
unit 2 hpc.pptx
gopal467344
 
PDF
Introduction to OpenMP (Performance)
Akhila Prabhakaran
 
PDF
Gk3611601162
IJERA Editor
 
PPT
Migration To Multi Core - Parallel Programming Models
Zvi Avraham
 
PPTX
1.1 Introduction.pptx about the design thinking of the engineering students
HrushikeshDandu
 
PDF
Introduction to Algorithms Complexity Analysis
Dr. Pankaj Agarwal
 
PDF
The International Journal of Engineering and Science (The IJES)
theijes
 
PPTX
Cc module 3.pptx
ssuserbead51
 
PPTX
Parallel Computing-Part-1.pptx
krnaween
 
PDF
Parallel Computing - Lec 5
Shah Zaib
 
PPTX
RAJAT PROJECT.pptx
SayedMohdAsim2
 
PDF
GRAPH MATCHING ALGORITHM FOR TASK ASSIGNMENT PROBLEM
IJCSEA Journal
 
PPTX
Data Parallel and Object Oriented Model
Nikhil Sharma
 
PPTX
Design and Analysis of Algorithms.pptx
Syed Zaid Irshad
 
PDF
Design Analysis and Algorithm Module1.pdf
Shana799280
 
PPTX
ICS 2410.Parallel.Sytsems.Lecture.Week 3.week5.pptx
johnsmith96441
 
DOCX
Matrix Multiplication Report
International Islamic University
 
PDF
IRJET- Latin Square Computation of Order-3 using Open CL
IRJET Journal
 
PPTX
Interpreting the Data:Parallel Analysis with Sawzall
Tilani Gunawardena PhD(UNIBAS), BSc(Pera), FHEA(UK), CEng, MIESL
 
PPTX
Data structure introduction
NavneetSandhu0
 
unit 2 hpc.pptx
gopal467344
 
Introduction to OpenMP (Performance)
Akhila Prabhakaran
 
Gk3611601162
IJERA Editor
 
Migration To Multi Core - Parallel Programming Models
Zvi Avraham
 
1.1 Introduction.pptx about the design thinking of the engineering students
HrushikeshDandu
 
Introduction to Algorithms Complexity Analysis
Dr. Pankaj Agarwal
 
The International Journal of Engineering and Science (The IJES)
theijes
 
Cc module 3.pptx
ssuserbead51
 
Parallel Computing-Part-1.pptx
krnaween
 
Parallel Computing - Lec 5
Shah Zaib
 
RAJAT PROJECT.pptx
SayedMohdAsim2
 
GRAPH MATCHING ALGORITHM FOR TASK ASSIGNMENT PROBLEM
IJCSEA Journal
 
Data Parallel and Object Oriented Model
Nikhil Sharma
 
Design and Analysis of Algorithms.pptx
Syed Zaid Irshad
 
Design Analysis and Algorithm Module1.pdf
Shana799280
 
ICS 2410.Parallel.Sytsems.Lecture.Week 3.week5.pptx
johnsmith96441
 
Matrix Multiplication Report
International Islamic University
 
IRJET- Latin Square Computation of Order-3 using Open CL
IRJET Journal
 
Interpreting the Data:Parallel Analysis with Sawzall
Tilani Gunawardena PhD(UNIBAS), BSc(Pera), FHEA(UK), CEng, MIESL
 
Data structure introduction
NavneetSandhu0
 

Recently uploaded (20)

PPTX
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
DOCX
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
DOCX
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
PPTX
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
DOCX
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
PPTX
CDH. pptx
AneetaSharma15
 
PDF
RA 12028_ARAL_Orientation_Day-2-Sessions_v2.pdf
Seven De Los Reyes
 
PPTX
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PDF
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
PPTX
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
PDF
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
PPTX
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
PPTX
A Smarter Way to Think About Choosing a College
Cyndy McDonald
 
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
CDH. pptx
AneetaSharma15
 
RA 12028_ARAL_Orientation_Day-2-Sessions_v2.pdf
Seven De Los Reyes
 
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
A Smarter Way to Think About Choosing a College
Cyndy McDonald
 

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) ‫شکریہ‬