MPI Point-to-Point Communication CS 524 – High-Performance Computing.

Slides:



Advertisements
Similar presentations
MPI Message Passing Interface
Advertisements

1 Non-Blocking Communications. 2 #include int main(int argc, char **argv) { int my_rank, ncpus; int left_neighbor, right_neighbor; int data_received=-1;
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.
1 Buffers l When you send data, where does it go? One possibility is: Process 0Process 1 User data Local buffer the network User data Local buffer.
Reference: / Point-to-Point Communication.
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.
Point-to-Point Communication Self Test with solution.
SOME BASIC MPI ROUTINES With formal datatypes specified.
1 Parallel Programming with MPI: Day 1 Science & Technology Support High Performance Computing Ohio Supercomputer Center 1224 Kinnear Road Columbus, OH.
Message-Passing Programming and MPI CS 524 – High-Performance Computing.
Distributed Memory Programming with MPI. What is MPI? Message Passing Interface (MPI) is an industry standard message passing system designed to be both.
Lesson2 Point-to-point semantics Embarrassingly Parallel Examples.
High Performance Parallel Programming Dirk van der Knijff Advanced Research Computing Information Division.
Distributed Systems CS Programming Models- Part II Lecture 17, Nov 2, 2011 Majd F. Sakr, Mohammad Hammoud andVinay Kolar 1.
1 Tuesday, October 10, 2006 To err is human, and to blame it on a computer is even more so. -Robert Orben.
A Brief Look At MPI’s Point To Point Communication Brian T. Smith Professor, Department of Computer Science Director, Albuquerque High Performance Computing.
CS 179: GPU Programming Lecture 20: Cross-system communication.
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.
ORNL is managed by UT-Battelle for the US Department of Energy Crash Course In Message Passing Interface Adam Simpson NCCS User Assistance.
1 MPI: Message-Passing Interface Chapter 2. 2 MPI - (Message Passing Interface) Message passing library standard (MPI) is developed by group of academics.
MA471Fall 2003 Lecture5. More Point To Point Communications in MPI Note: so far we have covered –MPI_Init, MPI_Finalize –MPI_Comm_size, MPI_Comm_rank.
Specialized Sending and Receiving David Monismith CS599 Based upon notes from Chapter 3 of the MPI 3.0 Standard
Parallel Computing A task is broken down into tasks, performed by separate workers or processes Processes interact by exchanging information What do we.
Parallel Programming with MPI Prof. Sivarama Dandamudi School of Computer Science Carleton University.
Jonathan Carroll-Nellenback CIRC Summer School MESSAGE PASSING INTERFACE (MPI)
1 MPI Primer Lesson 10 2 What is MPI MPI is the standard for multi- computer and cluster message passing introduced by the Message-Passing Interface.
MPI Communications Point to Point Collective Communication Data Packaging.
Message Passing Programming Model AMANO, Hideharu Textbook pp. 140-147.
Performance Oriented MPI Jeffrey M. Squyres Andrew Lumsdaine NERSC/LBNL and U. Notre Dame.
Summary of MPI commands Luis Basurto. Large scale systems Shared Memory systems – Memory is shared among processors Distributed memory systems – Each.
MPI Introduction to MPI Commands. Basics – Send and Receive MPI is a message passing environment. The processors’ method of sharing information is NOT.
1 The Message-Passing Model l A process is (traditionally) a program counter and address space. l Processes may have multiple threads (program counters.
CS 420 – Design of Algorithms MPI Data Types Basic Message Passing - sends/receives.
MPI Send/Receive Blocked/Unblocked Tom Murphy Director of Contra Costa College High Performance Computing Center Message Passing Interface BWUPEP2011,
1 Overview on Send And Receive routines in MPI Kamyar Miremadi November 2004.
11/04/2010CS4961 CS4961 Parallel Programming Lecture 19: Message Passing, cont. Mary Hall November 4,
Parallel Programming with MPI By, Santosh K Jena..
MA471Fall 2002 Lecture5. More Point To Point Communications in MPI Note: so far we have covered –MPI_Init, MPI_Finalize –MPI_Comm_size, MPI_Comm_rank.
Its.unc.edu 1 University of North Carolina - Chapel Hill ITS Research Computing Instructor: Mark Reed Point to Point Communication.
Introduction to MPI CDP 1. Shared Memory vs. Message Passing Shared Memory Implicit communication via memory operations (load/store/lock) Global address.
1 Lecture 4: Part 2: MPI Point-to-Point Communication.
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 at MCSR Message Passing Computing –Processes coordinate and communicate results via calls to message passing library.
Message Passing Interface (MPI) 2 Amit Majumdar Scientific Computing Applications Group San Diego Supercomputer Center Tim Kaiser (now at Colorado School.
MPI Send/Receive Blocked/Unblocked Josh Alexander, University of Oklahoma Ivan Babic, Earlham College Andrew Fitz Gibbon, Shodor Education Foundation Inc.
Chapter 5. Nonblocking Communication MPI_Send, MPI_Recv are blocking operations Will not return until the arguments to the functions can be safely modified.
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
Distributed Systems CS Programming Models- Part II Lecture 14, Oct 28, 2013 Mohammad Hammoud 1.
Lecture 3 Point-to-Point Communications Dr. Muhammad Hanif Durad Department of Computer and Information Sciences Pakistan Institute Engineering and Applied.
COMP7330/7336 Advanced Parallel and Distributed Computing MPI Programming: 1. Collective Operations 2. Overlapping Communication with Computation Dr. Xiao.
3/12/2013Computer Engg, IIT(BHU)1 MPI-2. POINT-TO-POINT COMMUNICATION Communication between 2 and only 2 processes. One sending and one receiving. Types:
Computer Science Department
Introduction to parallel computing concepts and technics
MPI Point to Point Communication
Introduction to MPI.
Computer Science Department
Blocking / Non-Blocking Send and Receive Operations
Distributed Systems CS
Lecture 14: Inter-process Communication
A Message Passing Standard for MPP and Workstations
Send and Receive.
Barriers implementations
Synchronizing Computations
Computer Science Department
5- Message-Passing Programming
Presentation transcript:

MPI Point-to-Point Communication CS 524 – High-Performance Computing

CS 524 (Wi 2003/04)- Asim LUMS2 Point-to-Point Communication Communication between two processes Source process sends message to destination process Communication takes place within a communicator Destination process is identified by its rank in the communicator source dest communicator

CS 524 (Wi 2003/04)- Asim LUMS3 Definitions “Completion” means that memory locations used in the message transfer can be safely accessed  send: variable sent can be reused after completion  receive: variable received can now be used MPI communication modes differ in what conditions on the receiving end are needed for completion Communication modes can be blocking or non- blocking  Blocking: return from function call implies completion  Non-blocking: routine returns immediately, completion tested for

CS 524 (Wi 2003/04)- Asim LUMS4 Communication Modes ModeCompletion Condition Synchronous sendOnly completes when the receive has completed Buffered sendAlways completes (unless an error occurs), irrespective of receiver Standard sendMessage sent (receive state unknown) Ready sendAlways completes (unless an error occurs), irrespective of whether the receive has completed ReceiveCompletes when a message has arrived

CS 524 (Wi 2003/04)- Asim LUMS5 Blocking Communication Functions ModeMPI Function Standard sendMPI_Send Synchronous sendMPI_Ssend Buffered sendMPI_Bsend Ready sendMPI_Rsend ReceiveMPI_Recv

CS 524 (Wi 2003/04)- Asim LUMS6 Sending a Message int MPI_Send(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)  buf: starting address of the data to be sent  count: number of elements to be sent (not bytes)  datatype: MPI datatype of each element  dest: rank of destination process  tag: message identifier (set by user)  comm: MPI communicator of processors involved MPI_Send(data, 500, MPI_FLOAT, 5, 25, MPI_COMM_WORLD)

CS 524 (Wi 2003/04)- Asim LUMS7 Receiving a Message int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status)  buf: starting address of buffer where the data is to be stored  count: number of elements to be received (not bytes)  datatype: MPI datatype of each element  source: rank of source process  tag: message identifier (set by user)  comm: MPI communicator of processors involved  status: structure of information about the message that is returned MPI_Recv(buffer, 500, MPI_FLOAT, 3, 25, MPI_COMM_WORLD, status)

CS 524 (Wi 2003/04)- Asim LUMS8 Standard and Synchronous Send Standard send  Completes once message has been sent  May or may not imply that message arrived  Don’t make any assumptions (implementation dependent) Synchronous send  Use if need to know that message has been received  Sending and receiving process synchronize regardless of who is faster. Thus, processor idle time is possible  Large synchronization overhead  Safest communication method

CS 524 (Wi 2003/04)- Asim LUMS9 Ready and Buffered Send Ready send  Ready to receive notification must be posted; otherwise it exits with an error  Should not be used unless user is certain that corresponding receive is posted before the send  Lower synchronization overhead for sender as compared to synchronous send Buffered send  Data to be sent is copied to a user-specified buffer  Higher system overhead of copying data to and from buffer  Lower synchronization overhead for sender

CS 524 (Wi 2003/04)- Asim LUMS10 Non-blocking Communications Separates communication into three phases:  Initiate non-blocking transfer  Do some other work not involving the data in transfer, i.e., overlap communication with calculation (latency hiding)  Wait for non-blocking communication to complete Syntax of functions  Similar to blocking functions’ syntax  Each function has an “I” immediately following the “_”. The rest of the name is the same  The last argument is a handle to an opaque request object that contains information about the message, i.e., its completion status

CS 524 (Wi 2003/04)- Asim LUMS11 Non-blocking Communication Functions ModeMPI Function Standard sendMPI_Isend Synchronous sendMPI_Issend Buffered sendMPI_Ibsend Ready sendMPI_Irsend ReceiveMPI_Irecv

CS 524 (Wi 2003/04)- Asim LUMS12 Sending and Receiving a Message int MPI_Isend(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request request) int MPI_Irecv(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Request request)  request: a request handle is allocated when a communication is initiated. Used to test if communication has completed.  Other parameters have the same definitions as for blocking functions

CS 524 (Wi 2003/04)- Asim LUMS13 Blocking and Non-blocking Send and receive can be blocking or non-blocking A blocking send can be used with a non-blocking receive, and vice-versa Non-blocking sends can use any mode – synchronous, buffered, standard, or ready  No advantage for buffered or ready Characteristics of non-blocking communications  No possibility of deadlocks  Decrease in synchronization overhead  Increase or decrease in system overhead  Extra computation and code to test and wait for completion  Must not access buffer before completion

CS 524 (Wi 2003/04)- Asim LUMS14 Blocking Buffered Communication

CS 524 (Wi 2003/04)- Asim LUMS15 Non-blocking Non-buffered Communication

CS 524 (Wi 2003/04)- Asim LUMS16 For a Communication to Succeed Sender must specify a valid destination rank Receiver must specify a valid source rank The communicator must be the same Tags must match Receiver’s buffer must be large enough User-specified buffer should be large enough (buffered send only) Receive posted before send (ready send only)

CS 524 (Wi 2003/04)- Asim LUMS17 Completion Tests Waiting and Testing for completion  Wait: function does not return until completion finished  Test: function returns a TRUE or FALSE value depending on whether or not the communication has completed int MPI_Wait(MPI_Request *request, MPI_Status *status) int MPI_Test(MPI_Request *request, int *flag, MPI_Status *status)

CS 524 (Wi 2003/04)- Asim LUMS18 Testing Multiple Communications Test or wait for completion of one (and only one) message  MPI_Waitany & MPI_Testany Test or wait for completion of all messages  MPI_Waitall & MPI_Testall Test or wait for completion of as many messages as possible  MPI_Waitsome & MPI_Testsome

CS 524 (Wi 2003/04)- Asim LUMS19 Wildcarding Receiver can wildcard To receive from any source specify MPI_ANY_SOURCE as rank of source To receive with any tag specify MPI_ANY_TAG as tag Actual source and tag are returned in the receiver’s status parameter

CS 524 (Wi 2003/04)- Asim LUMS20 Receive Information Information of data is returned from MPI_Recv (or MPI_Irecv) as status Information includes:  Source: status.MPI_SOURCE  Tag: status.MPI_TAG  Error: status.MPI_ERROR  Count: message received may not fill receive buffer. Use following function to find number of elements actually received: int MPI_Get_count(MPI_Status status, MPI_Datatype datatype, int *count) Message order preservation: messages do not overtake each other. Messages are received in the order sent.

CS 524 (Wi 2003/04)- Asim LUMS21 Timers double MPI_Wtime(void) Time is measured in seconds Time to perform a task is measured by consulting the timer before and after

CS 524 (Wi 2003/04)- Asim LUMS22 Deadlocks A deadlock occurs when two or more processors try to access the same set of resources Deadlocks are possible in blocking communication  Example: Two processors initiate a blocking send to each other without posting a receive … MPI_Send(P1) MPI_Recv(P1) … MPI_Send(P0) MPI_Recv (P0) … Process 0Process 1

CS 524 (Wi 2003/04)- Asim LUMS23 Avoiding Deadlocks Different ordering of send and receive: one processor post the send while the other posts the receive Use non-blocking functions: Post non-blocking receives early and test for completion Use MPI_Sendrecv and MPI_Sendrecv_replace: Both processors post the same single function Use buffered mode: Use buffered sends so that execution continues after copying to user-specified buffer