Non-Blocking Communications

Similar documents
Non-Blocking Communications

Parallel Programming, MPI Lecture 2

Parallel programming MPI

Parallel Programming

Standard MPI - Message Passing Interface

Introduction to the Message Passing Interface (MPI)

Recap of Parallelism & MPI

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

Message Passing Interface

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

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

MPI point-to-point communication

Outline. Communication modes MPI Message Passing Interface Standard

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

High Performance Computing

COSC 6374 Parallel Computation

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

Introduction to MPI: Part II

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)

Reusing this material

MPI. (message passing, MIMD)

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.

Collective Communications

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

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

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

Review of MPI Part 2

HPC Parallel Programing Multi-node Computation with MPI - I

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

DEADLOCK DETECTION IN MPI PROGRAMS

Point-to-Point Communication. Reference:

CME 194 Introduc0on to MPI

Advanced MPI. Andrew Emerson

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

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

High-Performance Computing: MPI (ctd)

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

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

Parallel Short Course. Distributed memory machines

Message Passing Interface

Introduction to parallel computing concepts and technics

Distributed Systems + Middleware Advanced Message Passing with MPI

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

What is Point-to-Point Comm.?

Programming Using the Message Passing Paradigm

Message Passing with MPI Christian Iwainsky HiPerCH

MPI Programming. Henrik R. Nagel Scientific Computing IT Division

15-440: Recitation 8

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

MPI - The Message Passing Interface

Cluster Computing MPI. Industrial Standard Message Passing

MPI Message Passing Interface. Source:

Parallel Programming using MPI. Supercomputing group CINECA

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.

Parallel Programming

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

Introduction to MPI, the Message Passing Library

Advanced MPI. Andrew Emerson

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

Document Classification Problem

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

Advanced Parallel Programming

Buffering in MPI communications

Lecture 9: MPI continued

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

Programming with MPI Collectives

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

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

PARALLEL AND DISTRIBUTED COMPUTING

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

Scientific Computing

High performance computing. Message Passing Interface

CME 194 Introduc0on to MPI

University of Notre Dame

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

Distributed Memory Programming with MPI

Practical Course Scientific Computing and Visualization

Distributed Memory Systems: Part IV

High Performance Computing Course Notes Message Passing Programming III

Introduction to MPI Part II Collective Communications and communicators

Part - II. Message Passing Interface. Dheeraj Bhardwaj

Introduction to MPI. Ricardo Fonseca.

Parallel programming with MPI Part I -Introduction and Point-to-Point Communications

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

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

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

Parallel programming with MPI Part I -Introduction and Point-to-Point

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.

First day. Basics of parallel programming. RIKEN CCS HPC Summer School Hiroya Matsuba, RIKEN CCS

MPI: Parallel Programming for Extreme Machines. Si Hammond, High Performance Systems Group

Transcription:

Non-Blocking Communications

Deadlock 1 5 2 3 4 Communicator 0 2

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 3

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 4

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! 5

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. 6

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. 7

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

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

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. 10

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) 11

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) 12

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

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

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) 15

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); } 16

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) 17

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. 18

Testing Multiple Non-Blocking Comms Process in in in 19

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) 20

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. 21

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 22

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 23