SlideShare a Scribd company logo
3
Most read
11
Most read
16
Most read
AssociateProfessor,KGC-DehradunBy Dr. Heman Pathak
Definition 2.1:
Cost of an Algorithm
The cost of a PRAM computation is the
product of the parallel time complexity
and the number of processors used.
For example, a PRAM algorithm that has
time complexity (log p) using p
processors has cost (p log p).
Definition 2.2:
Cost Optimal Algorithm
A cost optimal parallel algorithm is
an algorithm for which the cost is in
the same complexity class as an
optimal sequential algorithm.
Definition: Cost Optimal
Problem
Sequential
Cost
Parallel Algorithm Cost
Optimal
No. of PEs Complexity Cost
Sum of n Numbers n n/2 log(n) nlog(n) No
Prefix Sum (n) n n-1 log(n) nlog(n) No
List Ranking n n log(n) nlog(n) No
Pre-order Tree
Traversal
n 2(n-1) log(n) nlog(n) No
Merging two sorted list n n log(n) nlog(n) No
Graph Coloring (n) Polynomial Cn n2 Cn X n2 No
Cost Optimal: Reduction Algorithm
Cost Optimal: Reduction Algorithm
 The total number of operations performed by the parallel
algorithm is of the same complexity class as an optimal sequential
algorithm.
 The parallel reduction algorithm performs about n/2 additions in
the first step, n/4 additions in the second step, n/8 additions in
the third step, and so on, executing a total of n -1 additions over
the log⁡( 𝑛) iterations.
 Since both the sequential and the parallel algorithms perform n-1
additions, a cost-optimal variant of the parallel reduction
algorithm may exists.
Cost Optimal: Reduction Algorithm
Cost = P * Time Complexity
= nlog(n)
Cost optimal = (n-1)
n-1 = P * log(n)
P = (n-1)/ log(n)
TC = log(n)
Cost = (n-1) same as Sequential
Once we have determined the appropriate number of processors, we
need to verify that there is indeed a cost-optimal parallel-reduction
algorithm with logarithmic time complexity.
Brent’s Theorem(2.2)(1974)
Brent’s Theorem Proof
Cost optimal algorithm
Application to Parallel Reduction
Parallel Algorithm: Sum of n Numbers
• No. of Operations (M) = n-1
• Time Complexity (T) = log⁡( 𝑛)
• No. of PEs = 𝑛/2
Cost Optimal Parallel Algorithm
• No. of Operations (M) = n-1
• Time Complexity (T) = log⁡( 𝑛)
• No. of PEs (P) = (n-1)/ log(n) =⁡ 𝑛/log⁡( 𝑛)
Application to Parallel Reduction
Application to Parallel Reduction
n = 16
p = (n/log n) = 4
Application to Parallel Reduction
Steps No. of Op. General
1 9 n-1
2 8 n-2
3 6 n-4
4 2 n-8
: : :
i n-2i
Sequential Algorithm
for i = 1 to n-1
a[i] = a[i] + a[i-1]
endfor
Application to Parallel Reduction
Cost optimal algorithm

More Related Content

What's hot (20)

PPTX
Travelling salesman dynamic programming
maharajdey
 
PPT
Block Cipher and its Design Principles
SHUBHA CHATURVEDI
 
PPTX
Uninformed search /Blind search in AI
Kirti Verma
 
PDF
An overview of Hidden Markov Models (HMM)
ananth
 
PPTX
Convolutional Neural Network (CNN)
Muhammad Haroon
 
PDF
Compiler Design- Machine Independent Optimizations
Jyothishmathi Institute of Technology and Science Karimnagar
 
PPTX
Clustering ppt
sreedevibalasubraman
 
PPT
Dynamic programming
Shakil Ahmed
 
PDF
Searching and Sorting Algorithms
Ashutosh Satapathy
 
PPTX
Artificial neural networks and its applications
PoojaKoshti2
 
PPTX
(Machine Learning) Ensemble learning
Omkar Rane
 
PPTX
recurrence relations
Anurag Cheela
 
PPTX
Data structures - unit 1
SaranyaP45
 
PDF
Algorithms Lecture 2: Analysis of Algorithms I
Mohamed Loey
 
PPT
Clustering
M Rizwan Aqeel
 
DOC
Unit 2 in daa
Nv Thejaswini
 
PPTX
End-to-End Machine Learning Project
Eng Teong Cheah
 
PPTX
Ant colony optimization
Joy Dutta
 
PPTX
Local beam search example
Megha Sharma
 
Travelling salesman dynamic programming
maharajdey
 
Block Cipher and its Design Principles
SHUBHA CHATURVEDI
 
Uninformed search /Blind search in AI
Kirti Verma
 
An overview of Hidden Markov Models (HMM)
ananth
 
Convolutional Neural Network (CNN)
Muhammad Haroon
 
Compiler Design- Machine Independent Optimizations
Jyothishmathi Institute of Technology and Science Karimnagar
 
Clustering ppt
sreedevibalasubraman
 
Dynamic programming
Shakil Ahmed
 
Searching and Sorting Algorithms
Ashutosh Satapathy
 
Artificial neural networks and its applications
PoojaKoshti2
 
(Machine Learning) Ensemble learning
Omkar Rane
 
recurrence relations
Anurag Cheela
 
Data structures - unit 1
SaranyaP45
 
Algorithms Lecture 2: Analysis of Algorithms I
Mohamed Loey
 
Clustering
M Rizwan Aqeel
 
Unit 2 in daa
Nv Thejaswini
 
End-to-End Machine Learning Project
Eng Teong Cheah
 
Ant colony optimization
Joy Dutta
 
Local beam search example
Megha Sharma
 

Similar to Cost optimal algorithm (20)

PDF
Parallel Algorithms: Sort & Merge, Image Processing, Fault Tolerance
University of Technology - Iraq
 
PPTX
Parallel algorithms
Danish Javed
 
PDF
Elementary Parallel Algorithms
Heman Pathak
 
PDF
Parallel Algorithms
Dr Sandeep Kumar Poonia
 
PPTX
Algorithms & Complexity Calculation
Akhil Kaushik
 
PPT
daaadafrhdncxfbfbgdngfmfhmhagshh_unit_i.ppt
PRASAD BANOTH
 
PPT
daa_unit THIS IS GNDFJG SDGSGS SFDF .ppt
DrKBManwade
 
PDF
Gk3611601162
IJERA Editor
 
PPTX
Intro to super. advance algorithm..pptx
ManishBaranwal10
 
PPT
data unit notes from department of computer science
sdcmcatmk
 
PPTX
TimeComplexity important topic of Algorithm analysis .pptx
haiderkhooradnan
 
PPTX
Analysis of Algorithms (1).pptx, asymptotic
Minakshee Patil
 
PPTX
DS Unit-1.pptx very easy to understand..
KarthikeyaLanka1
 
PPTX
Analysis of Algorithms, recurrence relation, solving recurrences
Minakshee Patil
 
PDF
DATA STRUCTURE
RobinRohit2
 
PDF
DATA STRUCTURE.pdf
ibrahim386946
 
PDF
Data Structure & Algorithms - Mathematical
babuk110
 
PDF
Unit 1_final DESIGN AND ANALYSIS OF ALGORITHM.pdf
saiscount01
 
PPTX
Introduction to Algorithm
Manash Kumar Mondal
 
PPT
Design and Analysis of Algorithm Fundamental
devesfcs
 
Parallel Algorithms: Sort & Merge, Image Processing, Fault Tolerance
University of Technology - Iraq
 
Parallel algorithms
Danish Javed
 
Elementary Parallel Algorithms
Heman Pathak
 
Parallel Algorithms
Dr Sandeep Kumar Poonia
 
Algorithms & Complexity Calculation
Akhil Kaushik
 
daaadafrhdncxfbfbgdngfmfhmhagshh_unit_i.ppt
PRASAD BANOTH
 
daa_unit THIS IS GNDFJG SDGSGS SFDF .ppt
DrKBManwade
 
Gk3611601162
IJERA Editor
 
Intro to super. advance algorithm..pptx
ManishBaranwal10
 
data unit notes from department of computer science
sdcmcatmk
 
TimeComplexity important topic of Algorithm analysis .pptx
haiderkhooradnan
 
Analysis of Algorithms (1).pptx, asymptotic
Minakshee Patil
 
DS Unit-1.pptx very easy to understand..
KarthikeyaLanka1
 
Analysis of Algorithms, recurrence relation, solving recurrences
Minakshee Patil
 
DATA STRUCTURE
RobinRohit2
 
DATA STRUCTURE.pdf
ibrahim386946
 
Data Structure & Algorithms - Mathematical
babuk110
 
Unit 1_final DESIGN AND ANALYSIS OF ALGORITHM.pdf
saiscount01
 
Introduction to Algorithm
Manash Kumar Mondal
 
Design and Analysis of Algorithm Fundamental
devesfcs
 
Ad

More from Heman Pathak (14)

PDF
Interconnection Network
Heman Pathak
 
PDF
Central processing unit
Heman Pathak
 
PDF
Registers and counters
Heman Pathak
 
PDF
Sequential Circuit
Heman Pathak
 
PDF
Combinational logic 2
Heman Pathak
 
PDF
Combinational logic 1
Heman Pathak
 
PDF
Simplification of Boolean Function
Heman Pathak
 
PDF
Chapter 2: Boolean Algebra and Logic Gates
Heman Pathak
 
PDF
Chapter 7: Matrix Multiplication
Heman Pathak
 
PDF
Chapter 5: Mapping and Scheduling
Heman Pathak
 
PDF
Chapter 4: Parallel Programming Languages
Heman Pathak
 
PDF
Parallel Algorithm for Graph Coloring
Heman Pathak
 
PDF
Parallel Algorithms
Heman Pathak
 
PDF
Chapter 1 - introduction - parallel computing
Heman Pathak
 
Interconnection Network
Heman Pathak
 
Central processing unit
Heman Pathak
 
Registers and counters
Heman Pathak
 
Sequential Circuit
Heman Pathak
 
Combinational logic 2
Heman Pathak
 
Combinational logic 1
Heman Pathak
 
Simplification of Boolean Function
Heman Pathak
 
Chapter 2: Boolean Algebra and Logic Gates
Heman Pathak
 
Chapter 7: Matrix Multiplication
Heman Pathak
 
Chapter 5: Mapping and Scheduling
Heman Pathak
 
Chapter 4: Parallel Programming Languages
Heman Pathak
 
Parallel Algorithm for Graph Coloring
Heman Pathak
 
Parallel Algorithms
Heman Pathak
 
Chapter 1 - introduction - parallel computing
Heman Pathak
 
Ad

Recently uploaded (20)

PPTX
Break Statement in Programming with 6 Real Examples
manojpoojary2004
 
PPTX
ISO/IEC JTC 1/WG 9 (MAR) Convenor Report
Kurata Takeshi
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
PPTX
site survey architecture student B.arch.
sri02032006
 
PPTX
Pharmaceuticals and fine chemicals.pptxx
jaypa242004
 
PDF
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
PPTX
Electron Beam Machining for Production Process
Rajshahi University of Engineering & Technology(RUET), Bangladesh
 
PPTX
Types of Bearing_Specifications_PPT.pptx
PranjulAgrahariAkash
 
PDF
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
PDF
Ethics and Trustworthy AI in Healthcare – Governing Sensitive Data, Profiling...
AlqualsaDIResearchGr
 
PDF
UNIT-4-FEEDBACK AMPLIFIERS AND OSCILLATORS (1).pdf
Sridhar191373
 
PPTX
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
PDF
6th International Conference on Machine Learning Techniques and Data Science ...
ijistjournal
 
PDF
Zilliz Cloud Demo for performance and scale
Zilliz
 
PPTX
Green Building & Energy Conservation ppt
Sagar Sarangi
 
PDF
Additional Information in midterm CPE024 (1).pdf
abolisojoy
 
PDF
A presentation on the Urban Heat Island Effect
studyfor7hrs
 
PPTX
Introduction to Neural Networks and Perceptron Learning Algorithm.pptx
Kayalvizhi A
 
PDF
Book.pdf01_Intro.ppt algorithm for preperation stu used
archu26
 
PDF
IoT - Unit 2 (Internet of Things-Concepts) - PPT.pdf
dipakraut82
 
Break Statement in Programming with 6 Real Examples
manojpoojary2004
 
ISO/IEC JTC 1/WG 9 (MAR) Convenor Report
Kurata Takeshi
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
site survey architecture student B.arch.
sri02032006
 
Pharmaceuticals and fine chemicals.pptxx
jaypa242004
 
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
Electron Beam Machining for Production Process
Rajshahi University of Engineering & Technology(RUET), Bangladesh
 
Types of Bearing_Specifications_PPT.pptx
PranjulAgrahariAkash
 
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
Ethics and Trustworthy AI in Healthcare – Governing Sensitive Data, Profiling...
AlqualsaDIResearchGr
 
UNIT-4-FEEDBACK AMPLIFIERS AND OSCILLATORS (1).pdf
Sridhar191373
 
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
6th International Conference on Machine Learning Techniques and Data Science ...
ijistjournal
 
Zilliz Cloud Demo for performance and scale
Zilliz
 
Green Building & Energy Conservation ppt
Sagar Sarangi
 
Additional Information in midterm CPE024 (1).pdf
abolisojoy
 
A presentation on the Urban Heat Island Effect
studyfor7hrs
 
Introduction to Neural Networks and Perceptron Learning Algorithm.pptx
Kayalvizhi A
 
Book.pdf01_Intro.ppt algorithm for preperation stu used
archu26
 
IoT - Unit 2 (Internet of Things-Concepts) - PPT.pdf
dipakraut82
 

Cost optimal algorithm

  • 2. Definition 2.1: Cost of an Algorithm The cost of a PRAM computation is the product of the parallel time complexity and the number of processors used. For example, a PRAM algorithm that has time complexity (log p) using p processors has cost (p log p).
  • 3. Definition 2.2: Cost Optimal Algorithm A cost optimal parallel algorithm is an algorithm for which the cost is in the same complexity class as an optimal sequential algorithm.
  • 4. Definition: Cost Optimal Problem Sequential Cost Parallel Algorithm Cost Optimal No. of PEs Complexity Cost Sum of n Numbers n n/2 log(n) nlog(n) No Prefix Sum (n) n n-1 log(n) nlog(n) No List Ranking n n log(n) nlog(n) No Pre-order Tree Traversal n 2(n-1) log(n) nlog(n) No Merging two sorted list n n log(n) nlog(n) No Graph Coloring (n) Polynomial Cn n2 Cn X n2 No
  • 6. Cost Optimal: Reduction Algorithm  The total number of operations performed by the parallel algorithm is of the same complexity class as an optimal sequential algorithm.  The parallel reduction algorithm performs about n/2 additions in the first step, n/4 additions in the second step, n/8 additions in the third step, and so on, executing a total of n -1 additions over the log⁡( 𝑛) iterations.  Since both the sequential and the parallel algorithms perform n-1 additions, a cost-optimal variant of the parallel reduction algorithm may exists.
  • 7. Cost Optimal: Reduction Algorithm Cost = P * Time Complexity = nlog(n) Cost optimal = (n-1) n-1 = P * log(n) P = (n-1)/ log(n) TC = log(n) Cost = (n-1) same as Sequential Once we have determined the appropriate number of processors, we need to verify that there is indeed a cost-optimal parallel-reduction algorithm with logarithmic time complexity.
  • 11. Application to Parallel Reduction Parallel Algorithm: Sum of n Numbers • No. of Operations (M) = n-1 • Time Complexity (T) = log⁡( 𝑛) • No. of PEs = 𝑛/2 Cost Optimal Parallel Algorithm • No. of Operations (M) = n-1 • Time Complexity (T) = log⁡( 𝑛) • No. of PEs (P) = (n-1)/ log(n) =⁡ 𝑛/log⁡( 𝑛)
  • 13. Application to Parallel Reduction n = 16 p = (n/log n) = 4
  • 14. Application to Parallel Reduction Steps No. of Op. General 1 9 n-1 2 8 n-2 3 6 n-4 4 2 n-8 : : : i n-2i Sequential Algorithm for i = 1 to n-1 a[i] = a[i] + a[i-1] endfor