Today Objectives Chapter 6 of Quinn Creating 2-D arrays Thinking about “grain size” Introducing point-to-point communications Reading and printing 2-D.

Slides:



Advertisements
Similar presentations
Practical techniques & Examples
Advertisements

Parallel Processing1 Parallel Processing (CS 667) Lecture 9: Advanced Point to Point Communication Jeremy R. Johnson *Parts of this lecture was derived.
Sahalu Junaidu ICS 573: High Performance Computing 8.1 Topic Overview Matrix-Matrix Multiplication Block Matrix Operations A Simple Parallel Matrix-Matrix.
Parallel Programming in C with MPI and OpenMP
CS 484. Dense Matrix Algorithms There are two types of Matrices Dense (Full) Sparse We will consider matrices that are Dense Square.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Parallel Programming in C with MPI and OpenMP Michael J. Quinn.
Parallel Programming in C with MPI and OpenMP Michael J. Quinn.
CISC October Goals for today: Foster’s parallel algorithm design –Partitioning –Task dependency graph Granularity Concurrency Collective communication.
1 Friday, October 20, 2006 “Work expands to fill the time available for its completion.” -Parkinson’s 1st Law.
Chapter 6 Floyd’s Algorithm. 2 Chapter Objectives Creating 2-D arrays Thinking about “grain size” Introducing point-to-point communications Reading and.
Lecture 6 Objectives Communication Complexity Analysis Collective Operations –Reduction –Binomial Trees –Gather and Scatter Operations Review Communication.
Point-to-Point Communication Self Test with solution.
Chapter 6 Floyd’s Algorithm. 2 Chapter Objectives Creating 2-D arrays Thinking about “grain size” Introducing point-to-point communications Reading and.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 8 Matrix-vector Multiplication.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Parallel Programming in C with MPI and OpenMP Michael J. Quinn.
Comp 422: Parallel Programming Lecture 8: Message Passing (MPI)
CS 584. Dense Matrix Algorithms There are two types of Matrices Dense (Full) Sparse We will consider matrices that are Dense Square.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Parallel Programming in C with MPI and OpenMP Michael J. Quinn.
MPI Point-to-Point Communication CS 524 – High-Performance Computing.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Parallel Programming in C with MPI and OpenMP Michael J. Quinn.
Lecture 8 Objectives Material from Chapter 9 More complete introduction of MPI functions Show how to implement manager-worker programs Parallel Algorithms.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Parallel Programming in C with MPI and OpenMP Michael J. Quinn.
1 Tuesday, October 10, 2006 To err is human, and to blame it on a computer is even more so. -Robert Orben.
Chapter 13 Finite Difference Methods: Outline Solving ordinary and partial differential equations Finite difference methods (FDM) vs Finite Element Methods.
CS 179: GPU Programming Lecture 20: Cross-system communication.
1 TRAPEZOIDAL RULE IN MPI Copyright © 2010, Elsevier Inc. All rights Reserved.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Parallel Programming in C with MPI and OpenMP Michael J. Quinn.
A Message Passing Standard for MPP and Workstations Communications of the ACM, July 1996 J.J. Dongarra, S.W. Otto, M. Snir, and D.W. Walker.
L15: Putting it together: N-body (Ch. 6) October 30, 2012.
Computer Science 320 Broadcasting. Floyd’s Algorithm on SMP for i = 0 to n – 1 parallel for r = 0 to n – 1 for c = 0 to n – 1 d rc = min(d rc, d ri +
Chapter 3 Parallel Algorithm Design. Outline Task/channel model Task/channel model Algorithm design methodology Algorithm design methodology Case studies.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Parallel Programming in C with MPI and OpenMP Michael J. Quinn.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Parallel Programming in C with MPI and OpenMP Michael J. Quinn.
CS 584 l Assignment. Systems of Linear Equations l A linear equation in n variables has the form l A set of linear equations is called a system. l A solution.
Lecture 4. RAM Model, Space and Time Complexity
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.
Parallel Programming with MPI Prof. Sivarama Dandamudi School of Computer Science Carleton University.
CS 838: Pervasive Parallelism Introduction to MPI Copyright 2005 Mark D. Hill University of Wisconsin-Madison Slides are derived from an online tutorial.
Message Passing Programming Model AMANO, Hideharu Textbook pp. 140-147.
Summary of MPI commands Luis Basurto. Large scale systems Shared Memory systems – Memory is shared among processors Distributed memory systems – Each.
1 Overview on Send And Receive routines in MPI Kamyar Miremadi November 2004.
MPI (continue) An example for designing explicit message passing programs Advanced MPI concepts.
Parallel Programming with MPI By, Santosh K Jena..
Parallel Programming in C with MPI and OpenMP Michael J. Quinn.
Lecture 4 TTH 03:30AM-04:45PM Dr. Jianjun Hu CSCE569 Parallel Computing University of South Carolina Department of.
Message Passing and MPI Laxmikant Kale CS Message Passing Program consists of independent processes, –Each running in its own address space –Processors.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Parallel Programming in C with MPI and OpenMP Michael J. Quinn.
MPI Point to Point Communication CDP 1. Message Passing Definitions Application buffer Holds the data for send or receive Handled by the user System buffer.
1 BİL 542 Parallel Computing. 2 Message Passing Chapter 2.
An Introduction to MPI (message passing interface)
Introduction to Parallel Programming Language notation: message passing 5 parallel algorithms of increasing complexity: –Matrix multiplication –Successive.
Parallel Algorithms & Implementations: Data-Parallelism, Asynchronous Communication and Master/Worker Paradigm FDI 2007 Track Q Day 2 – Morning Session.
Message Passing Programming Based on MPI Collective Communication I Bora AKAYDIN
Message Passing Interface Using resources from
Lecture 3: Today’s topics MPI Broadcast (Quinn Chapter 5) –Sieve of Eratosthenes MPI Send and Receive calls (Quinn Chapter 6) –Floyd’s algorithm Other.
COMP7330/7336 Advanced Parallel and Distributed Computing MPI Programming: 1. Collective Operations 2. Overlapping Communication with Computation Dr. Xiao.
CS 4410 – Parallel Computing 1 Chap 9 CS 4410 – Parallel Computing Dr. Dave Gallagher Chap 9 Manager Worker.
ITCS 4/5145 Parallel Computing, UNC-Charlotte, B
High Altitude Low Opening?
Parallel Programming in C with MPI and OpenMP
Parallel Programming in C with MPI and OpenMP
Parallel Programming with MPI and OpenMP
Introduction to Parallel Programming
CSCE569 Parallel Computing
CSCE569 Parallel Computing
Parallel Programming in C with MPI and OpenMP
May 19 Lecture Outline Introduce MPI functionality
CSCE569 Parallel Computing
Parallel Graph Algorithms
Parallel Programming in C with MPI and OpenMP
Presentation transcript:

Today Objectives Chapter 6 of Quinn Creating 2-D arrays Thinking about “grain size” Introducing point-to-point communications Reading and printing 2-D matrices Analyzing performance when computations and communications overlap

Outline All-pairs shortest path problem Dynamic 2-D arrays Parallel algorithm design Point-to-point communication Block row matrix I/O Analysis and benchmarking

All-pairs Shortest Path Problem A E B C D A B C D E ABCD E Resulting Adjacency Matrix Containing Distances

Floyd’s Algorithm An Example of Dynamic Programming for k  0 to n-1 for i  0 to n-1 for j  0 to n-1 a[i,j]  min (a[i,j], a[i,k] + a[k,j]) endfor

Why It Works i k j Shortest path from i to k through 0, 1, …, k-1 Shortest path from k to j through 0, 1, …, k-1 Shortest path from i to j through 0, 1, …, k-1 Computed in previous iterations

Designing Parallel Algorithm Partitioning Communication Agglomeration and Mapping

Partitioning Domain or functional decomposition? Look at pseudocode Same assignment statement executed n 3 times No functional parallelism Domain decomposition: divide matrix A into its n 2 elements

Communication Primitive tasks Updating a[3,4] when k = 1 Iteration k: every task in row k broadcasts its value w/in task column Iteration k: every task in column k broadcasts its value w/in task row

Agglomeration and Mapping Number of tasks: static Communication among tasks: structured Computation time per task: constant Strategy: –Agglomerate tasks to minimize communication –Create one task per MPI process

Two Data Decompositions Rowwise block stripedColumnwise block striped

Comparing Decompositions Columnwise block striped –Broadcast within columns eliminated Rowwise block striped –Broadcast within rows eliminated –Reading matrix from file simpler Choose rowwise block striped decomposition

File Input File

Pop Quiz Why don’t we input the entire file at once and then scatter its contents among the processes, allowing concurrent message passing?

Dynamic 1-D Array Creation A Heap Run-time Stack int *A; A = (int *) malloc (n * sizeof (int));

Dynamic 2-D Array Creation Heap Run-time Stack BstorageB int **B, *Bstorage, i; Bstorage = (int *) malloc (m * n * sizeof (int)); for ( i=0; i<m, ++i) B[i] = &Bstorage[i*n];

Point-to-point Communication Involves a pair of processes One process sends a message Other process receives the message

Send/Receive Not Collective

Function MPI_Send int MPI_Send ( void *message, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm )

Function MPI_Recv int MPI_Recv ( void *message, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status )

Coding Send/Receive … if (ID == j) { … Receive from I … } … if (ID == i) { … Send to j … } … Receive is before Send. Why does this work?

Inside MPI_Send and MPI_Recv Sending ProcessReceiving Process Program Memory System Buffer System Buffer Program Memory MPI_Send MPI_Recv

Return from MPI_Send Function blocks until message buffer free Message buffer is free when –Message copied to system buffer, or –Message transmitted Typical scenario –Message copied to system buffer –Transmission overlaps computation

Return from MPI_Recv Function blocks until message in buffer If message never arrives, function never returns

Deadlock Deadlock: process waiting for a condition that will never become true Easy to write send/receive code that deadlocks –Two processes: both receive before send –Send tag doesn’t match receive tag –Process sends message to wrong destination process

Parallel Floyd’s Computational Complexity Innermost loop has complexity  (n) Middle loop executed at most  n/p  times Outer loop executed n times Overall complexity  (n 3 /p)

Communication Complexity No communication in inner loop No communication in middle loop Broadcast in outer loop — complexity is  (n log p) – why? Overall complexity  (n 2 log p)

Execution Time Expression (1) Iterations of outer loop Iterations of middle loop Cell update time Iterations of outer loop Messages per broadcast Message-passing time bytes/msg Iterations of inner loop

Computation/communication Overlap

Execution Time Expression (2) Iterations of outer loop Iterations of middle loop Cell update time Iterations of outer loop Messages per broadcast Message-passing time Iterations of inner loop Message transmission

Predicted vs. Actual Performance Execution Time (sec) ProcessesPredictedActual

Summary Two matrix decompositions –Rowwise block striped –Columnwise block striped Blocking send/receive functions –MPI_Send –MPI_Recv Overlapping communications with computations