Parallel Programming with MPI Prof. Sivarama Dandamudi School of Computer Science Carleton University.

Slides:



Advertisements
Similar presentations
Its.unc.edu 1 Collective Communication University of North Carolina - Chapel Hill ITS - Research Computing Instructor: Mark Reed
Advertisements

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.
SOME BASIC MPI ROUTINES With formal datatypes specified.
Distributed Memory Programming with MPI. What is MPI? Message Passing Interface (MPI) is an industry standard message passing system designed to be both.
MPI Collective Communication CS 524 – High-Performance Computing.
EECC756 - Shaaban #1 lec # 7 Spring Message Passing Interface (MPI) MPI, the Message Passing Interface, is a library, and a software standard.
Collective Communications
MPI Point-to-Point Communication CS 524 – High-Performance Computing.
Collective Communication.  Collective communication is defined as communication that involves a group of processes  More restrictive than point to point.
Distributed Systems CS Programming Models- Part II Lecture 17, Nov 2, 2011 Majd F. Sakr, Mohammad Hammoud andVinay Kolar 1.
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.
Parallel Programming with MPI Matthew Pratola
ORNL is managed by UT-Battelle for the US Department of Energy Crash Course In Message Passing Interface Adam Simpson NCCS User Assistance.
Parallel Processing1 Parallel Processing (CS 676) Lecture 7: Message Passing using MPI * Jeremy R. Johnson *Parts of this lecture was derived from chapters.
2a.1 Message-Passing Computing More MPI routines: Collective routines Synchronous routines Non-blocking routines ITCS 4/5145 Parallel Computing, UNC-Charlotte,
1 Collective Communications. 2 Overview  All processes in a group participate in communication, by calling the same function with matching arguments.
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.
Steve Lantz Computing and Information Science Distributed Memory Programming Using Advanced MPI (Message Passing Interface)
PP Lab MPI programming VI. Program 1 Break up a long vector into subvectors of equal length. Distribute subvectors to processes. Let them compute the.
1 Review –6 Basic MPI Calls –Data Types –Wildcards –Using Status Probing Asynchronous Communication Collective Communications Advanced Topics –"V" operations.
CS 838: Pervasive Parallelism Introduction to MPI Copyright 2005 Mark D. Hill University of Wisconsin-Madison Slides are derived from an online tutorial.
MPI Communications Point to Point Collective Communication Data Packaging.
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.
MPI Introduction to MPI Commands. Basics – Send and Receive MPI is a message passing environment. The processors’ method of sharing information is NOT.
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.
Lecture 6: Message Passing Interface (MPI). Parallel Programming Models Message Passing Model Used on Distributed memory MIMD architectures Multiple processes.
CSCI-455/522 Introduction to High Performance Computing Lecture 4.
Oct. 23, 2002Parallel Processing1 Parallel Processing (CS 730) Lecture 6: Message Passing using MPI * Jeremy R. Johnson *Parts of this lecture was derived.
MPI Jakub Yaghob. Literature and references Books Gropp W., Lusk E., Skjellum A.: Using MPI: Portable Parallel Programming with the Message-Passing Interface,
Introduction to MPI CDP 1. Shared Memory vs. Message Passing Shared Memory Implicit communication via memory operations (load/store/lock) Global address.
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. 2 The logical view of a machine supporting the message-passing paradigm consists of p processes, each with its own exclusive address space. The logical.
An Introduction to MPI (message passing interface)
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.
S an D IEGO S UPERCOMPUTER C ENTER N ATIONAL P ARTNERSHIP FOR A DVANCED C OMPUTATIONAL I NFRASTRUCTURE MPI 2 Part II NPACI Parallel Computing Institute.
-1.1- MPI Lectured by: Nguyễn Đức Thái Prepared by: Thoại Nam.
Message Passing Programming Based on MPI Collective Communication I Bora AKAYDIN
Message Passing Interface Using resources from
COMP7330/7336 Advanced Parallel and Distributed Computing MPI Programming: 1. Collective Operations 2. Overlapping Communication with Computation Dr. Xiao.
ITCS 4/5145 Parallel Computing, UNC-Charlotte, B
1 MPI: Message Passing Interface Prabhaker Mateti Wright State University.
Distributed Processing with MPI International Summer School 2015 Tomsk Polytechnic University Assistant Professor Dr. Sergey Axyonov.
Computer Science Department
Introduction to MPI Programming Ganesh C.N.
Introduction to parallel computing concepts and technics
CS4402 – Parallel Computing
Introduction to MPI.
Computer Science Department
Send and Receive.
CS 584.
An Introduction to Parallel Programming with MPI
Send and Receive.
Distributed Systems CS
CS 5334/4390 Spring 2017 Rogelio Long
Lecture 14: Inter-process Communication
A Message Passing Standard for MPP and Workstations
MPI: Message Passing Interface
Hardware Environment VIA cluster - 8 nodes Blade Server – 5 nodes
Message-Passing Computing Message Passing Interface (MPI)
Hello, world in MPI #include <stdio.h> #include "mpi.h"
Computer Science Department
5- Message-Passing Programming
Hello, world in MPI #include <stdio.h> #include "mpi.h"
CS 584 Lecture 8 Assignment?.
Presentation transcript:

Parallel Programming with MPI Prof. Sivarama Dandamudi School of Computer Science Carleton University

© S. Dandamudi2 Introduction  Problem  Lack of a standard for message–passing routines  Big issue: Portability problems  MPI defines a core set of library routines (API) for message passing (more than 125 functions in total!!)  Several commercial and public domain implementations  Cray, IBM, Intel  MPI-CH from Argonne National Laboratory  LAM from Ohio Supercomputer Center/Indiana University

Carleton University© S. Dandamudi3 Introduction (cont’d)  Some Additional Goals [Snir et al. 1996]  Allows efficient communication  Avoids memory-to-memory copying  Allows computation and communication overlap  Non-blocking communication  Allows implementation in a heterogeneous environment  Provides reliable communication interface  Users don’t have to worry about communication failures

Carleton University© S. Dandamudi4 MPI  MPI is large but not complex  125 functions  But….  Need only 6 functions to write a simple MPI program  MPI_Init  MPI_Finalize  MPI_Comm_size  MPI_Comm_rank  MPI_Send  Mpi_Recv

Carleton University© S. Dandamudi5 MPI (cont’d)  Before any other function is called, we must initialize MPI_Init(&argc, &argc)  To indicate end of MPI calls  MPI_Finalize()  Cleans up the MPI state  Should be the last MPI function call

Carleton University© S. Dandamudi6 MPI (cont’d)  A typical program structure int main(int argc, char **argv) { MPI_Init(&argc, &argv);... /* main program */... MPI_Finalize(); }

Carleton University© S. Dandamudi7 MPI (cont’d)  MPI uses communicators to group processes that communicate with each other  Predefined communicator: MPI_COMM_WORLD consists of all processes running when the program begins execution  Sufficient for simple programs

Carleton University© S. Dandamudi8 MPI (cont’d)  Process rank  Similar to mytid in PVM MPI_Comm_rank(MPI_Comm comm, int *rank)  First argument: Communicator  Second argument: returns process rank

Carleton University© S. Dandamudi9 MPI (cont’d)  Number of processes MPI_Comm_size(MPI_Comm comm, int *size)  First argument: Communicator  Second argument: returns number of processes  Example: MPI_Comm_size(MPI_COMM_WORLD, &nprocs)

Carleton University© S. Dandamudi10 MPI (cont’d)  Sending a message (blocking version) MPI_Send(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm )  Data types  MPI_CHAR, MPI_INT, MPI_LONG  MPI_FLOAT, MPI_DOUBLE Buffer description Destination specification

Carleton University© S. Dandamudi11 MPI (cont’d)  Receiving a message (blocking version) MPI_Recv(void* buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status)  Wildcard specification allowed  MPI_ANY_SOURCE  MPI_ANY_TAG

Carleton University© S. Dandamudi12 MPI (cont’d)  Receiving a message  Status of the received message  Status gives two pieces of information directly  Useful when wildcards are used  status.MPI_SOURCE  Gives identity of the source  status.MPI_TAG  Gives the tag information

Carleton University© S. Dandamudi13 MPI (cont’d)  Receiving a message  Status also gives message size information indirectly MPI_Get_count(MPI_Status *status, MPI_Datatype datatype, int *count)  Takes status and the datatype as inputs and returns the number of elements via count

Carleton University© S. Dandamudi14 MPI (cont’d)  Non-blocking communication  Prefix send and recv by “I” (for immediate)  MPI_Isend  MPI_Irecv  Need completion operations to see if the operation is completed  MPI_Wait  MPI_Test

Carleton University© S. Dandamudi15 MPI (cont’d)  Sending a message (non-blocking version) MPI_Isend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request ) Returns the request handle

Carleton University© S. Dandamudi16 MPI (cont’d)  Receiving a message (non-blocking version) MPI_Irecv(void* buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Request *request )  Same arguments as Isend

Carleton University© S. Dandamudi17 MPI (cont’d)  How do we know when a non-blocking operation is done?  Use MPI_Test or MPI_Wait  Completion of a send indicates:  Sender can access the send buffer  Completion of a receive indicates  Receive buffer contains the message

Carleton University© S. Dandamudi18 MPI (cont’d)  MPI_Test returns the status  Does not wait for the operation to complete MPI_Test(MPI_Request*request, int *flag, MPI_Status *status) Request handle Operation status: true (if completed) If flag = true, gives status

Carleton University© S. Dandamudi19 MPI (cont’d)  MPI_Wait waits until the operation is completed MPI_Wait( MPI_Request *request, MPI_Status *status) Request handle Gives status

Carleton University© S. Dandamudi20 MPI Collective Communication  Collective communication  Several functions are provided to support collective communication  Some examples are given here:  MPI_Barrier  MPI_Bcast  MPI_Scatter  MPI_Gather  MPI_Reduce Broadcast Barrier synchronization Global reduction

Carleton University© S. Dandamudi21 From Snir et al. 1996

Carleton University© S. Dandamudi22 MPI Collective Communication (cont’d)  MPI_Barrier blocks the caller until all group members have called it MPI_Barrier( MPI_Comm comm )  The call returns at any process only after all group members have entered the call

Carleton University© S. Dandamudi23 MPI Collective Communication (cont’d)  MPI_Bcast broadcasts a message from root to all processes of the group MPI_Bcast( void* buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm )

Carleton University© S. Dandamudi24 MPI Collective Communication (cont’d)  MPI_Scatter distributes data from the root process to all the others in the group MPI_Scatter(void* send_buf, int send_count, MPI_Datatype send_type, void* recv_buf, int recv_count, MPI_Datatype recv_type, int root, MPI_Comm comm )

Carleton University© S. Dandamudi25 MPI Collective Communication (cont’d)  MPI_Gather inverse of the scatter operation (gathers data and stores it in rank order) MPI_Scatter(void* send_buf, int send_count, MPI_Datatype send_type, void* recv_buf, int recv_count, MPI_Datatype recv_type, int root, MPI_Comm comm )

Carleton University© S. Dandamudi26 MPI Collective Communication (cont’d)  MPI_Reduce performs global reduction operations such as sum, max, min, AND, etc. MPI_Reduce(void* send_buf, void* recv_buf, int count, MPI_Datatype datatype, MPI_Op operation, int root, MPI_Comm comm )

Carleton University© S. Dandamudi27 MPI Collective Communication (cont’d)  Predefined reduce operations include MPI_MAXmaximum MPI_MINminimum MPI_SUMsum MPI_PRODproduct MPI_LANDlogical AND MPI_BANDbitwise AND MPI_LORlogical OR MPI_BORbitwise OR MPI_LXORlogical XOR MPI_BXORbitwise XOR

Carleton University© S. Dandamudi28 From Snir et al Last slide