Parallelismo.

Slides:



Advertisements
Similar presentations
CSE 160 – Lecture 9 Speed-up, Amdahl’s Law, Gustafson’s Law, efficiency, basic performance metrics.
Advertisements

Graph Algorithms Carl Tropper Department of Computer Science McGill University.
Starting Parallel Algorithm Design David Monismith Based on notes from Introduction to Parallel Programming 2 nd Edition by Grama, Gupta, Karypis, and.
Parallel Processing (CS453). How does one decompose a task into various subtasks? While there is no single recipe that works for all problems, we present.
11Sahalu JunaiduICS 573: High Performance Computing5.1 Analytical Modeling of Parallel Programs Sources of Overhead in Parallel Programs Performance Metrics.
Principles of Parallel Algorithm Design
1 Tuesday, September 26, 2006 Wisdom consists of knowing when to avoid perfection. -Horowitz.
Principles of Parallel Algorithm Design
Virtues of Good (Parallel) Software
Rechen- und Kommunikationszentrum (RZ) Parallelization at a Glance Christian Terboven / Aachen, Germany Stand: Version 2.3.
Parallel Processing (CS526) Spring 2012(Week 4).  Parallelism from two perspectives: ◦ Platform  Parallel Hardware Architecture  Parallel Communication.
CS 420 Design of Algorithms Analytical Models of Parallel Algorithms.
1 Interconnects Shared address space and message passing computers can be constructed by connecting processors and memory unit using a variety of interconnection.
INTEL CONFIDENTIAL Predicting Parallel Performance Introduction to Parallel Programming – Part 10.
CS453 Lecture 3.  A sequential algorithm is evaluated by its runtime (in general, asymptotic runtime as a function of input size).  The asymptotic runtime.
Graph Algorithms. Definitions and Representation An undirected graph G is a pair (V,E), where V is a finite set of points called vertices and E is a finite.
INTRODUCTION TO PARALLEL ALGORITHMS. Objective  Introduction to Parallel Algorithms Tasks and Decomposition Processes and Mapping Processes Versus Processors.
Parallel Programming with MPI and OpenMP
CDP Tutorial 3 Basics of Parallel Algorithm Design uses some of the slides for chapters 3 and 5 accompanying “Introduction to Parallel Computing”, Addison.
Ananth Grama, Anshul Gupta, George Karypis, and Vipin Kumar
Paper_topic: Parallel Matrix Multiplication using Vertical Data.
3/12/2013Computer Engg, IIT(BHU)1 INTRODUCTION-1.
Uses some of the slides for chapters 3 and 5 accompanying “Introduction to Parallel Computing”, Addison Wesley, 2003.
Unit-8 Sorting Algorithms Prepared By:-H.M.PATEL.
Concurrency and Performance Based on slides by Henri Casanova.
COMP7330/7336 Advanced Parallel and Distributed Computing Task Partitioning Dr. Xiao Qin Auburn University
Mergesort example: Merge as we return from recursive calls Merge Divide 1 element 829.
COMP8330/7330/7336 Advanced Parallel and Distributed Computing Decomposition and Parallel Tasks (cont.) Dr. Xiao Qin Auburn University
CPE 779 Parallel Computing - Spring Creating and Using Threads Based on Slides by Katherine Yelick
These slides are based on the book:
Auburn University
Auburn University
Potential for parallel computers/parallel programming
Auburn University
Introduction to Parallel Computing: MPI, OpenMP and Hybrid Programming
18-447: Computer Architecture Lecture 30B: Multiprocessors
Auburn University COMP7330/7336 Advanced Parallel and Distributed Computing Exploratory Decomposition Dr. Xiao Qin Auburn.
PARALLEL COMPUTING Submitted By : P. Nagalakshmi
Distributed Processors
Parallel Tasks Decomposition
Parallel Programming By J. H. Wang May 2, 2017.
Auburn University COMP7330/7336 Advanced Parallel and Distributed Computing Mapping Techniques Dr. Xiao Qin Auburn University.
Auburn University COMP7330/7336 Advanced Parallel and Distributed Computing Data Partition Dr. Xiao Qin Auburn University.
Introduction to parallel algorithms
Auburn University COMP8330/7330/7336 Advanced Parallel and Distributed Computing Communication Costs (cont.) Dr. Xiao.
EE 193: Parallel Computing
Principles of Parallel Algorithm Design
Introduction to Parallel Computing by Grama, Gupta, Karypis, Kumar
Analytical Modeling Of Parallel Programs
Introduction to parallel algorithms
Principles of Parallel Algorithm Design
COMP60621 Fundamentals of Parallel and Distributed Systems
Principles of Parallel Algorithm Design
Principles of Parallel Algorithm Design
Analytical Modeling of Parallel Systems
PERFORMANCE MEASURES. COMPUTATIONAL MODELS Equal Duration Model:  It is assumed that a given task can be divided into n equal subtasks, each of which.
Mattan Erez The University of Texas at Austin
Dense Linear Algebra (Data Distributions)
Principles of Parallel Algorithm Design
Principles of Parallel Algorithm Design
Potential for parallel computers/parallel programming
Potential for parallel computers/parallel programming
Analytical Modeling of Parallel Systems
Principles of Parallel Algorithm Design
Potential for parallel computers/parallel programming
To accompany the text “Introduction to Parallel Computing”,
Potential for parallel computers/parallel programming
COMP60611 Fundamentals of Parallel and Distributed Systems
Divide and Conquer Merge sort and quick sort Binary search
Introduction to parallel algorithms
Presentation transcript:

Parallelismo

Parallel Cost Execution time: Define parallel cost: C = pTp Ideally sequential Ts parallel Tp from the start of the first process until the termination of the last process Define parallel cost: C = pTp Ideally Ts = C = pTp In reality usually Ts < C sometimes Ts > C Why?

Overhead Overhead: C-Ts Where does it come from? idling not enough parallelism load imbalance communication additional and/or repeated calculations

Other Measures Speedup: Efficiency: S=Ts/Tp, where Ts is the best sequential time Efficiency: E = S/p = Ts/pTp = Ts/C = Ts/ (To+Ts)

Parallel Version of Bubble Sort Stage 0 7 4 1 5 2 8 6 9 Stage 1 4 7 1 5 2 8 6 9 Stage 2 4 1 7 2 5 6 8 9 Stage 3 1 4 2 7 5 6 8 9 Stage 4 1 2 4 5 7 6 8 9 Stage 5 1 2 4 5 7 6 8 9 1 2 4 5 6 Stage 6 7 8 9

Parallel Version of Bubble Sort n processors n stages, each stage lasts O(1) and has O(n) work total parallel time: Tp = O(n) total cost O(n2): non-optimal p processors partition into blocks of size n/p internally sort your n/p elements share with your neighbour, merge & split p stages, each stage lasts O(n/p) , initial local sort O(n/p log (n/p)) total parallel time: Tp = O(n/p log (n/p))+O(n) for which values of p does it have linear speedup ?

Superlinear Speedup (S>p) Should not be possible everything must work perfectly just to avoid overhead you could simulate the fast parallel algorithm on a single processor to beat the best sequential algorithm Yet sometimes happens in practice more memory available in a parallel computer different search order in search problems Sequential search – 12 moves Parallel search – 2 moves Use Speedup and Amdahl’s law slides from the book before this one.

Scalability of Parallel Systems Amdahl’s Law the size of the sequential fraction determines how much speedup is achievable S ≤Ts /(fTs+(1-f)Ts/p) = p/(1+(p-1)f), where f is the sequential fraction of the code serial section parallelizable section one processor (1-f)Ts fTs p processors (1-f)Ts/p

Scalability of Parallel Systems II Consequence of Amdahl’s law: for a given instance, adding additional processors gives diminishing returns only relatively few processors can be efficiently used Way around: increase the problem size sequential part tends to grow slower then the parallel part A system is scalable if efficiency can be maintained by increasing problem size

Fine Grain Parallelism All tasks execute a small number of instructions between communication cycles Low computation to communication ratio Facilitates load balancing If granularity is too fine it is possible that the overhead required for communications and synchronization between tasks takes much longer than the computation P0 P1 computation P2 commmunication P3 P4

Coarse Grain Parallelism Typified by long computations consisting of large numbers of instructions between communication synchronization points High computation to communication ratio Lower communication overhead Harder to load balance efficiently P0 P1 computation P2 commmunication P3 P4

Example: Merge Sort 8 1 4 5 2 7 3 6 P1 P2 P3 P4 8 1 4 5 2 7 3 6 P1 P2 Mention that merges on each line happen simultaneously, so only three iterations seen here. 8 1 4 5 2 7 3 6 P1 8 1 4 5 2 7 3 6

Merge Sort Analysis Number of compares 1 + 3 + … + (2i-1) + … + (n-1) ∑i=1..lg(n) 2i-1 = 2n-2-lgn = Θ(n) We have improved from nlg(n) to n simply by applying the old algorithm to parallel computing, by altering the algorithm we can further improve merge sort to (lgn)2

Parallel Design and Dynamic Programming Often in a dynamic programming algorithm a given row or diagonal can be computed simultaneously This makes many dynamic programming algorithms amenable for parallel architectures

Example: Multiplying a Dense Matrix with a Vector Computation of each element of output vector y is independent of other elements. Based on this, a dense matrix-vector product can be decomposed into n tasks. The figure highlights the portion of the matrix and vector accessed by Task 1. Observations: While tasks share data (namely, the vector b ), they do not have any control dependencies - i.e., no task needs to wait for the (partial) completion of any other. All tasks are of the same size in terms of number of operations. Is this the maximum number of tasks we could decompose this problem into?

Example: Database Query Processing Consider the execution of the query: MODEL = ``CIVIC'' AND YEAR = 2001 AND (COLOR = ``GREEN'' OR COLOR = ``WHITE) on the following database: ID# Model Year Color Dealer Price 4523 Civic 2002 Blue MN $18,000 3476 Corolla 1999 White IL $15,000 7623 Camry 2001 Green NY $21,000 9834 Prius CA 6734 OR $17,000 5342 Altima FL $19,000 3845 Maxima $22,000 8354 Accord 2000 VT 4395 Red 7352 WA

Example: Database Query Processing The execution of the query can be divided into subtasks in various ways. Each task can be thought of as generating an intermediate table of entries that satisfy a particular clause. Decomposing the given query into a number of tasks. Edges in this graph denote that the output of one task is needed to accomplish the next.

Example: Database Query Processing Note that the same problem can be decomposed into subtasks in other ways as well. An alternate decomposition of the given problem into subtasks, along with their data dependencies. Different task decompositions may lead to significant differences with respect to their eventual parallel performance.

Granularity of Task Decompositions The number of tasks into which a problem is decomposed determines its granularity. Decomposition into a large number of tasks results in fine-grained decomposition and that into a small number of tasks results in a coarse grained decomposition. A coarse grained counterpart to the dense matrix-vector product example. Each task in this example corresponds to the computation of three elements of the result vector.

Degree of Concurrency The number of tasks that can be executed in parallel is the degree of concurrency of a decomposition. Since the number of tasks that can be executed in parallel may change over program execution, the maximum degree of concurrency is the maximum number of such tasks at any point during execution. What is the maximum degree of concurrency of the database query examples? The average degree of concurrency is the average number of tasks that can be processed in parallel over the execution of the program. Assuming that each tasks in the database example takes identical processing time, what is the average degree of concurrency in each decomposition? The degree of concurrency increases as the decomposition becomes finer in granularity and vice versa.

Critical Path Length A directed path in the task dependency graph represents a sequence of tasks that must be processed one after the other. The longest such path determines the shortest time in which the program can be executed in parallel. The length of the longest path in a task dependency graph is called the critical path length.

Critical Path Length Consider the task dependency graphs of the two database query decompositions: What are the critical path lengths for the two task dependency graphs? If each task takes 10 time units, what is the shortest parallel execution time for each decomposition? How many processors are needed in each case to achieve this minimum parallel execution time? What is the maximum degree of concurrency?

Recursive Decomposition: Example A classic example of a divide-and-conquer algorithm on which we can apply recursive decomposition is Quicksort. In this example, once the list has been partitioned around the pivot, each sublist can be processed concurrently (i.e., each sublist represents an independent subtask). This can be repeated recursively.

Recursive Decomposition: Example The code can be decomposed naturally using a recursive decomposition strategy. We illustrate this with the following example of finding the minimum number in the set {4, 9, 1, 7, 8, 11, 2, 12}. The task dependency graph associated with this computation is as follows:

Output Data Decomposition: Example Consider the problem of multiplying two n x n matrices A and B to yield matrix C. The output matrix C can be partitioned into four tasks as follows: Task 1: Task 2: Task 3: Task 4:

Output Data Decomposition: Example A partitioning of output data does not result in a unique decomposition into tasks. For example, for the same problem as in previus foil, with identical output data distribution, we can derive the following two (other) decompositions: Decomposition I Decomposition II Task 1: C1,1 = A1,1 B1,1 Task 2: C1,1 = C1,1 + A1,2 B2,1 Task 3: C1,2 = A1,1 B1,2 Task 4: C1,2 = C1,2 + A1,2 B2,2 Task 5: C2,1 = A2,1 B1,1 Task 6: C2,1 = C2,1 + A2,2 B2,1 Task 7: C2,2 = A2,1 B1,2 Task 8: C2,2 = C2,2 + A2,2 B2,2 Task 3: C1,2 = A1,2 B2,2 Task 4: C1,2 = C1,2 + A1,1 B1,2 Task 5: C2,1 = A2,2 B2,1 Task 6: C2,1 = C2,1 + A2,1 B1,1

Partitioning the Graph of Lake Superior Random Partitioning Partitioning for minimum edge-cut.