Non-Blocking Communications

Similar documents
Non-Blocking Communications

Parallel Programming, MPI Lecture 2

Reusing this material

Collective Communications

Parallel programming MPI

Recap of Parallelism & MPI

Standard MPI - Message Passing Interface

Parallel Programming

Introduction to the Message Passing Interface (MPI)

More about MPI programming. More about MPI programming p. 1

Outline. Communication modes MPI Message Passing Interface Standard

Message Passing Interface

CSE 613: Parallel Programming. Lecture 21 ( The Message Passing Interface )

MPI point-to-point communication

Message Passing Interface. most of the slides taken from Hanjun Kim

Lecture 7: More about MPI programming. Lecture 7: More about MPI programming p. 1

Introduction to MPI: Part II

Topics. Lecture 7. Review. Other MPI collective functions. Collective Communication (cont d) MPI Programming (III)

High Performance Computing

MPI. (message passing, MIMD)

A message contains a number of elements of some particular datatype. MPI datatypes:

Topics. Lecture 6. Point-to-point Communication. Point-to-point Communication. Broadcast. Basic Point-to-point communication. MPI Programming (III)

Intermediate MPI (Message-Passing Interface) 1/11

Basic MPI Communications. Basic MPI Communications (cont d)

COSC 6374 Parallel Computation

Intermediate MPI (Message-Passing Interface) 1/11

COMP 322: Fundamentals of Parallel Programming

MPI. What to Learn This Week? MPI Program Structure. What is MPI? This week, we will learn the basics of MPI programming.

Outline. Communication modes MPI Message Passing Interface Standard. Khoa Coâng Ngheä Thoâng Tin Ñaïi Hoïc Baùch Khoa Tp.HCM

CS 179: GPU Programming. Lecture 14: Inter-process Communication

Review of MPI Part 2

Message Passing Programming. Modes, Tags and Communicators

HPC Parallel Programing Multi-node Computation with MPI - I

Reusing this material

Programming SoHPC Course June-July 2015 Vladimir Subotic MPI - Message Passing Interface

CME 194 Introduc0on to MPI

Message Passing Programming with MPI. Message Passing Programming with MPI 1

Advanced MPI. Andrew Emerson

Point-to-Point Communication. Reference:

CS 470 Spring Mike Lam, Professor. Distributed Programming & MPI

High-Performance Computing: MPI (ctd)

DEADLOCK DETECTION IN MPI PROGRAMS

Acknowledgments. Programming with MPI Basic send and receive. A Minimal MPI Program (C) Contents. Type to enter text

Programming with MPI Basic send and receive

CS 470 Spring Mike Lam, Professor. Distributed Programming & MPI

Distributed Systems + Middleware Advanced Message Passing with MPI

Message Passing Interface

15-440: Recitation 8

What is Point-to-Point Comm.?

Today's agenda. Parallel Programming for Multicore Machines Using OpenMP and MPI

Introduction to parallel computing concepts and technics

Reusing this material

Parallel Short Course. Distributed memory machines

Programming Using the Message Passing Paradigm

Message Passing with MPI Christian Iwainsky HiPerCH

MPI Programming. Henrik R. Nagel Scientific Computing IT Division

Parallel Programming

MPI 5. CSCI 4850/5850 High-Performance Computing Spring 2018

MPI - The Message Passing Interface

Advanced Parallel Programming

Cluster Computing MPI. Industrial Standard Message Passing

MPI Message Passing Interface. Source:

MA471. Lecture 5. Collective MPI Communication

Introduction to MPI. SuperComputing Applications and Innovation Department 1 / 143

Outline. Introduction to HPC computing. OpenMP MPI. Introduction. Understanding communications. Collective communications. Communicators.

Programming Scalable Systems with MPI. Clemens Grelck, University of Amsterdam

Parallel Programming using MPI. Supercomputing group CINECA

Introduction to MPI, the Message Passing Library

Advanced MPI. Andrew Emerson

The MPI Message-passing Standard Practical use and implementation (III) SPD Course 03/10/2010 Massimo Coppola

Distributed Memory Programming with MPI

Document Classification Problem

Lesson 1. MPI runs on distributed memory systems, shared memory systems, or hybrid systems.

Distributed Memory Systems: Part IV

CME 194 Introduc0on to MPI

Lecture 9: MPI continued

PROGRAMMING WITH MESSAGE PASSING INTERFACE. J. Keller Feb 26, 2018

Programming with MPI Collectives

Introduction to MPI Part II Collective Communications and communicators

Week 3: MPI. Day 02 :: Message passing, point-to-point and collective communications

The MPI Message-passing Standard Practical use and implementation (V) SPD Course 6/03/2017 Massimo Coppola

PARALLEL AND DISTRIBUTED COMPUTING

Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 9

IPM Workshop on High Performance Computing (HPC08) IPM School of Physics Workshop on High Perfomance Computing/HPC08

Buffering in MPI communications

MPI Collective communication

High performance computing. Message Passing Interface

Scientific Computing

University of Notre Dame

What s in this talk? Quick Introduction. Programming in Parallel

Practical Course Scientific Computing and Visualization

Part - II. Message Passing Interface. Dheeraj Bhardwaj

Introduction to MPI. Ricardo Fonseca.

PCAP Assignment I. 1. A. Why is there a large performance gap between many-core GPUs and generalpurpose multicore CPUs. Discuss in detail.

AMath 483/583 Lecture 21

Message Passing Interface. George Bosilca

A Message Passing Standard for MPP and Workstations

Data parallelism. [ any app performing the *same* operation across a data stream ]

Programming Scalable Systems with MPI. UvA / SURFsara High Performance Computing and Big Data. Clemens Grelck, University of Amsterdam

In the simplest sense, parallel computing is the simultaneous use of multiple computing resources to solve a problem.

Transcription:

Non-Blocking Communications

Reusing this material This work is licensed under a Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International License. http://creativecommons.org/licenses/by-nc-sa/4.0/deed.en_us This means you are free to copy and redistribute the material and adapt and build on the material under the following terms: You must give appropriate credit, provide a link to the license and indicate if changes were made. If you adapt or build on the material you must distribute your work under the same license as the original. Note that this presentation contains images owned by others. Please seek their permission before reusing these images. 2

Deadlock 1 5 2 3 4 Communicator 0 3

Completion The mode of a communication determines when its constituent operations complete. - i.e. synchronous / asynchronous The form of an operation determines when the procedure implementing that operation will return - i.e. when control is returned to the user program 4

Blocking Operations Relate to when the operation has completed. Only return from the subroutine call when the operation has completed. These are the routines you used thus far - MPI_Ssend - MPI_Recv 5

Non-Blocking Operations Return straight away and allow the sub-program to continue to perform other work. At some later time the sub-program can test or wait for the completion of the non-blocking operation. Beep! 6

Non-Blocking Operations All non-blocking operations should have matching wait operations. Some systems cannot free resources until wait has been called. A non-blocking operation immediately followed by a matching wait is equivalent to a blocking operation. Non-blocking operations are not the same as sequential subroutine calls as the operation continues after the call has returned. 7

Non-Blocking Communications Separate communication into three phases: Initiate non-blocking communication. Do some work (perhaps involving other communications?) Wait for non-blocking communication to complete. 8

Non-Blocking Send 1 5 2 3 4 Communicator 0 9

Non-Blocking Receive 1 5 2 3 4 Communicator 0 10

Handles used for Non-blocking Comms datatype same as for blocking (MPI_Datatype or INTEGER). communicator same as for blocking (MPI_Comm or INTEGER). request MPI_Request or INTEGER. A request handle is allocated when a communication is initiated. 11

Non-blocking Synchronous Send C: int MPI_Issend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request) int MPI_Wait(MPI_Request *request, MPI_Status *status) Fortran: MPI_ISSEND(buf, count, datatype, dest, tag, comm, request, ierror) MPI_WAIT(request, status, ierror) 12

Non-blocking Receive C: int MPI_Irecv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Request *request) int MPI_Wait(MPI_Request *request, MPI_Status *status) Fortran: MPI_IRECV(buf, count, datatype, src, tag, comm, request, ierror) MPI_WAIT(request, status, ierror) 13

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 or standard Synchronous mode affects completion, not initiation. 14

Communication Modes NON-BLOCKING OPERATION Standard send Synchronous send Buffered send Receive MPI CALL MPI_ISEND MPI_ISSEND MPI_IBSEND MPI_IRECV 15

Completion Waiting versus Testing. C: int MPI_Wait(MPI_Request *request, MPI_Status *status) int MPI_Test(MPI_Request *request, int *flag, MPI_Status *status) Fortran: MPI_WAIT(handle, status, ierror) MPI_TEST(handle, flag, status, ierror) 16

Example (C) MPI_Request request; MPI_Status status; if (rank == 0) { MPI_Issend(sendarray, 10, MPI_INT, 1, tag, MPI_COMM_WORLD, &request); Do_something_else_while Issend_happens(); // now wait for send to complete MPI_Wait(&request, &status); } else if (rank == 1) { MPI_Irecv(recvarray, 10, MPI_INT, 0, tag, MPI_COMM_WORLD, &request); Do_something_else_while Irecv_happens(); // now wait for receive to complete; MPI_Wait(&request, &status); } 17

Example (Fortran) integer request integer, dimension(mpi_status_size) :: status if (rank == 0) then CALL MPI_ISSEND(sendarray, 10, MPI_INTEGER, 1, tag, MPI_COMM_WORLD, request, ierror) CALL Do_something_else_while Issend_happens()! now wait for send to complete CALL MPI_Wait(request, status, ierror) else if (rank == 1) then endif CALL MPI_IRECV(recvarray, 10, MPI_INTEGER, 0, tag, MPI_COMM_WORLD, request, ierror) CALL Do_something_else_while Irecv_happens()! now wait for receive to complete CALL MPI_Wait(request, status, ierror) 18

Multiple Communications Test or wait for completion of one message. Test or wait for completion of all messages. Test or wait for completion of as many messages as possible. 19

Testing Multiple Non-Blocking Comms Process in in in 20

Combined Send and Receive Specify all send / receive arguments in one call - MPI implementation avoids deadlock - useful in simple pairwise communications patterns, but not as generally applicable as non-blocking int MPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype, int dest, int sendtag, void *recvbuf, int recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status); MPI_SENDRECV(sendbuf, sendcount, sendtype, dest, sendtag, recvbuf, recvcount, recvtype, source, recvtag, comm, status, ierror) 21

Exercise See Exercise 4 on the sheet Rotating information around a ring Arrange processes to communicate round a ring. Each process stores a copy of its rank in an integer variable. Each process communicates this value to its right neighbour, and receives a value from its left neighbour. Each process computes the sum of all the values received. Repeat for the number of processes involved and print out the sum stored at each process. 22

Possible solutions Non-blocking send to forward neighbour - blocking receive from backward neighbour - wait for forward send to complete Non-blocking receive from backward neighbour - blocking send to forward neighbour - wait for backward receive to complete Non-blocking send to forward neighbour Non-blocking receive from backward neighbour - wait for forward send to complete - wait for backward receive to complete 23

Notes Your neighbours do not change - send to left, receive from right, send to left, receive from right, You do not alter the data you receive - receive it - add it to you running total - pass the data unchanged along the ring You must not access send or receive buffers until communications are complete - cannot read from a receive buffer until after a wait on irecv - cannot overwrite a send buffer until after a wait on issend 24