1 Lecture 2: Parallel computational models. 2  Turing machine  RAM (Figure )  Logic circuit model RAM (Random Access Machine) Operations supposed to.

Slides:



Advertisements
Similar presentations
1 Parallel Algorithms (chap. 30, 1 st edition) Parallel: perform more than one operation at a time. PRAM model: Parallel Random Access Model. p0p0 p1p1.
Advertisements

PRAM Algorithms Sathish Vadhiyar. PRAM Model - Introduction Parallel Random Access Machine Allows parallel-algorithm designers to treat processing power.
Instructor Neelima Gupta Table of Contents Parallel Algorithms.
Optimal PRAM algorithms: Efficiency of concurrent writing “Computer science is no more about computers than astronomy is about telescopes.” Edsger Dijkstra.
Lecture 3: Parallel Algorithm Design
Parallel vs Sequential Algorithms
Advanced Algorithms Piyush Kumar (Lecture 12: Parallel Algorithms) Welcome to COT5405 Courtesy Baker 05.
PRAM (Parallel Random Access Machine)
Efficient Parallel Algorithms COMP308
TECH Computer Science Parallel Algorithms  several operations can be executed at the same time  many problems are most naturally modeled with parallelism.
Advanced Topics in Algorithms and Data Structures Classification of the PRAM model In the PRAM model, processors communicate by reading from and writing.
PRAM Models Advanced Algorithms & Data Structures Lecture Theme 13 Prof. Dr. Th. Ottmann Summer Semester 2006.
Advanced Topics in Algorithms and Data Structures Page 1 Parallel merging through partitioning The partitioning strategy consists of: Breaking up the given.
Simulating a CRCW algorithm with an EREW algorithm Efficient Parallel Algorithms COMP308.
Advanced Topics in Algorithms and Data Structures
Uzi Vishkin.  Introduction  Objective  Model of Parallel Computation ▪ Work Depth Model ( ~ PRAM) ▪ Informal Work Depth Model  PRAM Model  Technique:
CSC401 – Analysis of Algorithms Lecture Notes 1 Introduction
Slide 1 Parallel Computation Models Lecture 3 Lecture 4.
© 2004 Goodrich, Tamassia 1 Lecture 01 Algorithm Analysis Topics Basic concepts Theoretical Analysis Concept of big-oh Choose lower order algorithms Relatives.
Computability and Complexity 32-1 Computability and Complexity Andrei Bulatov Boolean Circuits.
Analysis of Algorithms1 Estimate the running time Estimate the memory space required. Time and space depend on the input size.
Parallel Merging Advanced Algorithms & Data Structures Lecture Theme 15 Prof. Dr. Th. Ottmann Summer Semester 2006.
Analysis of Algorithms
1 Lecture 3 PRAM Algorithms Parallel Computing Fall 2008.
Fall 2008Paradigms for Parallel Algorithms1 Paradigms for Parallel Algorithms.
Advanced Topics in Algorithms and Data Structures 1 Two parallel list ranking algorithms An O (log n ) time and O ( n log n ) work list ranking algorithm.
Basic PRAM algorithms Problem 1. Min of n numbers Problem 2. Computing a position of the first one in the sequence of 0’s and 1’s.
Simulating a CRCW algorithm with an EREW algorithm Lecture 4 Efficient Parallel Algorithms COMP308.
RAM and Parallel RAM (PRAM). Why models? What is a machine model? – A abstraction describes the operation of a machine. – Allowing to associate a value.
Spring2012 Lecture#10 CSE 246 Data Structures and Algorithms.
Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP.
Analysis of Algorithm Lecture 3 Recurrence, control structure and few examples (Part 1) Huma Ayub (Assistant Professor) Department of Software Engineering.
Computer Science and Engineering Parallel and Distributed Processing CSE 8380 February 8, 2005 Session 8.
Parallel Algorithms Sorting and more. Keep hardware in mind When considering ‘parallel’ algorithms, – We have to have an understanding of the hardware.
Algorithm Efficiency CS 110: Data Structures and Algorithms First Semester,
1 Computer Algorithms Lecture 3 Asymptotic Notation Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR.
“elbowing out” Processors used Speedup Efficiency timeexecution Parallel Processors timeexecution Sequential Efficiency   
Lecture 4. RAM Model, Space and Time Complexity
1 Lectures on Parallel and Distributed Algorithms COMP 523: Advanced Algorithmic Techniques Lecturer: Dariusz Kowalski Lectures on Parallel and Distributed.
RAM, PRAM, and LogP models
Computer Science and Engineering Parallel and Distributed Processing CSE 8380 February 3, 2005 Session 7.
Parallel Algorithms. Parallel Models u Hypercube u Butterfly u Fully Connected u Other Networks u Shared Memory v.s. Distributed Memory u SIMD v.s. MIMD.
Parallel computation Section 10.5 Giorgi Japaridze Theory of Computability.
06/12/2015Applied Algorithmics - week41 Non-periodicity and witnesses  Periodicity - continued If string w=w[0..n-1] has periodicity p if w[i]=w[i+p],
Parallel Processing & Distributed Systems Thoai Nam Chapter 2.
Data Structures and Algorithms in Parallel Computing Lecture 1.
3/12/2013Computer Engg, IIT(BHU)1 PRAM ALGORITHMS-1.
Announcement We will have a 10 minutes Quiz on Feb. 4 at the end of the lecture. The quiz is about Big O notation. The weight of this quiz is 3% (please.
Complexity of Algorithms Fundamental Data Structures and Algorithms Ananda Guna January 13, 2005.
1 A simple parallel algorithm Adding n numbers in parallel.
1 COMP9024: Data Structures and Algorithms Week Two: Analysis of Algorithms Hui Wu Session 2, 2014
PRAM and Parallel Computing
Lecture 3: Parallel Algorithm Design
PRAM Model for Parallel Computation
Parallel Algorithms (chap. 30, 1st edition)
Lecture 2: Parallel computational models
Analysis of Algorithms
PRAM Algorithms.
PRAM Model for Parallel Computation
Data Structures and Algorithms in Parallel Computing
Parallel and Distributed Algorithms
Lecture 5 PRAM Algorithms (cont.)
Analysis of Algorithms
CSE838 Lecture notes copy right: Moon Jung Chung
Analysis of Algorithms
Unit –VIII PRAM Algorithms.
Parallel Algorithms A Simple Model for Parallel Processing
Module 6: Introduction to Parallel Computing
Analysis of Algorithms
Presentation transcript:

1 Lecture 2: Parallel computational models

2  Turing machine  RAM (Figure )  Logic circuit model RAM (Random Access Machine) Operations supposed to be executed in one unit time (1) Control operations such as if , goto ( for and while can be realized by for and goto. ) (2) I/O operations such as print (3) Substitution operations such as a = b (4) Arithmetic and logic operations such as +, -, AND. Control Unit (contains algorithms) CPU Memory (unlimited size) Data Sequential computational models

3 O-notation for computing complexity Definition Assume that f(n) is a positive function. If there are two positive constants c, n 0 such that f(n) ≦ c g(n) for all n ≧ n 0, then we say f(n) = O( g(n) ). For example, 3n 2 -5n = O(n 2 ) n log n + n = O(n log n) 45 = O(1) ( The item which grows most quickly)

4 Sequential algorithms Parallel algorithms Models RAM Many types Data division Not necessary Most important Analysis Computing time Computing time Memory size Communicating time Number of processors Algorithm analysis for sequential and parallel algorithms

5 PRAM (Parallel RAM) model PRAM consists of a number of RAM (Random Access Machine) and a shared memory. Each RAM has a unique processor number.  Processors act synchronously.  Processor execute the same program. ( According to the condition fork based on processor numbers, it is possible to executed different operations.)  Data communication between processors (RAMs) are held through the shared common memory.  Each processor can write data to and read data from one memory cell in O(1) time. Shared Memory RAM 1 RAM 2 RAM m

6 Features of PRAM Merits Parallelism of problems can be considered essentially. Algorithms an be easily designed. Algorithms can be changed easily to ones on other parallel computational models. Demerits Communicational cost is not considered. (It is not realistic that one synchronized reading and writing can be done in one unit time.) Distributed memory is not considered. In the following, We use PRAM to discuss parallel algorithms.

7 Analysis of parallel algorithms on PRAM model  Computing time T(n)  Number of processors P(n)  Cost P(n) × T(n)  Speed-up Ts(n)/T(n)  Ts(n): Computing time of the optimal sequential algorithm ) 1.Cost optimal parallel algorithms The cost is the same as the computing time of the optimal sequential algorithm, i.e., speed-up is the same as the number of processors. 2. Time optimal parallel algorithms Fastest when using polynomial number of processors. 3. Optimal parallel algorithms Cost and time optimal. 1.Cost optimal parallel algorithms The cost is the same as the computing time of the optimal sequential algorithm, i.e., speed-up is the same as the number of processors. 2. Time optimal parallel algorithms Fastest when using polynomial number of processors. 3. Optimal parallel algorithms Cost and time optimal.

8 World of sequential computation  P problems : the class of problems which can be solved in polynomial time (O(n )).  NP problems : the class of problems which can be solved non-determinately in polynomial time.  NP-complete problems : the class of NP problems which can be reduced to each other.  P = NP ? World of parallel computation  NC Problems: the class of problems which can be solved in log-polynomial time (O(lg n) ).  P-complete problems : the class of problems which are not NC problems and can be reduced to each other.  Similarly, NC = P ? NC-class and P-class k k Analysis of parallel algorithms on PRAM model

9 An Example of PRAM Algorithms Problem : Find the sum of n integers (x 1, x 2,..., x n ) - Assume that n integers are put in array A[1..n] on the shared memory. - To simplify the problem, let n = 2 k (k is an integer). main () { for (h=1; h ≦ log n; h++) { if (index of processor i ≦ n/2 h ) processor i do { a = A[2i-1]; /* Reading from the shared memory*/ b = A[2i];/* Reading from the shared memory*/ c = a + b; A[i] = c;/* Writing to the shared memory */ } } if (the number of processor == 1) printf("%d¥n", c); }

10 Processor Pi reads A[2i-1], A[2i] from the shared memory, then writes their summation to A[i] of the shared memory. P i A[i] A[2i-1] A[2i] A[1] P 1 A[2] P 2 A[3]A[4] A[n] An Example of PRAM Algorithms

11 Find the summation of 8 integers (x 1, x 2,..., x 8 ). Sequential algorithm P 1 P 1 P 2 P 3 P 4 P 1 P 2 x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 Output Input Step 1 Step 2 Step 3 Parallel algorithm An Example of PRAM Algorithms

12 Analysis of the algorithm Computing time : for loop is repeated log n times, each loop can be executed in O(1) time → O(log n) time Number of processors : not larger than n/2 → n/2 processors Cost: O(n log n) It is not cost optimal since the optimal sequential algorithm run in Θ(n) time. It is not cost optimal since the optimal sequential algorithm run in Θ(n) time. An Example of PRAM Algorithms

13  EREW (Exclusive read exclusive write) PRAM Both concurrent reading and concurrent writing are prohibited.  CREW (Concurrent Read Exclusive write) PRAM Concurrent reading is allowed, but concurrent writing is prohibited. Classification of PRAM by the access restriction

14  CRCW (Concurrent Read Concurrent write) PRAM Both concurrent reading and concurrent writing are allowed. It is classified furthermore: - common CRCW PRAM Concurrent writing happens is only if the writing data are the same. - arbitrary CRCW PRAM An arbitrary data is written. - priority CRCW PRAM The processor with the smallest number writes the data. Classification of PRAM by the access restriction

15 Algorithms on different PRAM models Algorithms for calculating and of n bits (Input is put in array A[1..n])  Algorithm on EREW PRAM model main (){ for (h=1; h ≦ log n; h++) { if (index of processor i ≦ n/2h) processor i do { a = A[2i-1]; b = A[2i]; if ((a==1) and (b==1)) a[i] = 1; }}}  Algorithm on common CRCW PRAM model main (){ if (A[index of processor i] == 1) processor i do A[1] = 1; } O(log n) time n/2 processors O(log n) time n/2 processors O(1) time n processors O(1) time n processors Abilities of PRAM models: EREW < CREW < CRCW

Exercise 1. Suppose nxn matrix A and matrix B are saved in two dimension arrays. Design a PRAM algorithm for A+B using n and nxn processors, respectively. Answer the following questions: (1)What PRAM models that you use in your algorithms? (2)What are the runings time? (3)Are you algorithms cost optimal? (4)Are your algorithms time optimal? 2. Design a PRAM algorithm for A+B using k (k <= nxn processors). Answer the same questions. 16