MPI Message Passing Interface

Slides:



Advertisements
Similar presentations
MPI Message Passing Interface Portable Parallel Programs.
Advertisements

Chapter 3. MPI MPI = Message Passing Interface Specification of message passing libraries for developers and users –Not a library by itself, but specifies.
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.
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.
Comp 422: Parallel Programming Lecture 8: Message Passing (MPI)
1 CS4402 – Parallel Computing Lecture 2 MPI – Getting Started. MPI – Point to Point Communication.
Parallel & Cluster Computing MPI Basics Paul Gray, University of Northern Iowa David Joiner, Shodor Education Foundation Tom Murphy, Contra Costa College.
Parallel Processing1 Parallel Processing (CS 676) Lecture 7: Message Passing using MPI * Jeremy R. Johnson *Parts of this lecture was derived from chapters.
2.1 Message-Passing Computing ITCS 4/5145 Parallel Computing, UNC-Charlotte, B. Wilkinson, Jan 17, 2012.
ECE 1747H : Parallel Programming Message Passing (MPI)
1 MPI: Message-Passing Interface Chapter 2. 2 MPI - (Message Passing Interface) Message passing library standard (MPI) is developed by group of academics.
2.1 Message-Passing Computing ITCS 4/5145 Parallel Computing, UNC-Charlotte, B. Wilkinson, Jan 14, 2013.
Part I MPI from scratch. Part I By: Camilo A. SilvaBIOinformatics Summer 2008 PIRE :: REU :: Cyberbridges.
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.
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.
MPI Introduction to MPI Commands. Basics – Send and Receive MPI is a message passing environment. The processors’ method of sharing information is NOT.
Distributed-Memory (Message-Passing) Paradigm FDI 2004 Track M Day 2 – Morning Session #1 C. J. Ribbens.
Parallel Programming with MPI By, Santosh K Jena..
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, ©
CSCI-455/522 Introduction to High Performance Computing Lecture 4.
1 Message Passing Models CEG 4131 Computer Architecture III Miodrag Bolic.
Oct. 23, 2002Parallel Processing1 Parallel Processing (CS 730) Lecture 6: Message Passing using MPI * Jeremy R. Johnson *Parts of this lecture was derived.
Introduction to MPI CDP 1. Shared Memory vs. Message Passing Shared Memory Implicit communication via memory operations (load/store/lock) Global address.
Introduction to Parallel Programming at MCSR Message Passing Computing –Processes coordinate and communicate results via calls to message passing library.
2.1 Collective Communication Involves set of processes, defined by an intra-communicator. Message tags not present. Principal collective operations: MPI_BCAST()
3/12/2013Computer Engg, IIT(BHU)1 MPI-1. MESSAGE PASSING INTERFACE A message passing library specification Extended message-passing model Not a language.
1 Parallel and Distributed Processing Lecture 5: Message-Passing Computing Chapter 2, Wilkinson & Allen, “Parallel Programming”, 2 nd Ed.
Lecture 5 CSS314 Parallel Computing Book: “An Introduction to Parallel Programming” by Peter Pacheco
Message Passing Interface Using resources from
MPI-Message Passing Interface. What is MPI?  MPI is a specification for the developers and users of message passing libraries. By itself, it is NOT a.
1 Programming distributed memory systems Clusters Distributed computers ITCS 4/5145 Parallel Computing, UNC-Charlotte, B. Wilkinson, Jan 6, 2015.
MPI: Message Passing Interface An Introduction S. Lakshmivarahan School of Computer Science.
PVM and MPI.
Introduction to MPI Programming Ganesh C.N.
Chapter 4.
Introduction to parallel computing concepts and technics
MPI Basics.
Auburn University COMP7330/7336 Advanced Parallel and Distributed Computing Message Passing Interface (cont.) Topologies.
CS4402 – Parallel Computing
Introduction to MPI.
MPI Message Passing Interface
Introduction to MPI CDP.
Send and Receive.
CS 584.
MPI: The Message-Passing Interface
Send and Receive.
CS4961 Parallel Programming Lecture 16: Introduction to Message Passing Mary Hall November 3, /03/2011 CS4961.
Introduction to Message Passing Interface (MPI)
Message Passing Models
CS 5334/4390 Spring 2017 Rogelio Long
Lecture 14: Inter-process Communication
A Message Passing Standard for MPP and Workstations
MPI: Message Passing Interface
Message-Passing Computing More MPI routines: Collective routines Synchronous routines Non-blocking routines ITCS 4/5145 Parallel Computing, UNC-Charlotte,
Quiz Questions ITCS 4145/5145 Parallel Programming MPI
Lab Course CFD Parallelisation Dr. Miriam Mehl.
Introduction to parallelism and the Message Passing Interface
Send and Receive.
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"
Distributed Memory Programming with Message-Passing
Hello, world in MPI #include <stdio.h> #include "mpi.h"
Parallel Processing - MPI
Some codes for analysis and preparation for programming
CS 584 Lecture 8 Assignment?.
Programming Parallel Computers
Presentation transcript:

MPI Message Passing Interface Portable Parallel Programs

Message Passing Interface Derived from several previous libraries PVM, P4, Express Standard message-passing library includes best of several previous libraries Versions for C/C++ and FORTRAN Available for free Can be installed on Networks of Workstations Parallel Computers (Cray T3E, IBM SP2, Parsytec PowerXplorer, other)

MPI Services Hide details of architecture Hide details of message passing, buffering Provides message management services packaging send, receive broadcast, reduce, scatter, gather message modes

MPI Program Organization MIMD Multiple Instruction, Multiple Data Every processor runs a different program SPMD Single Program, Multiple Data Every processor runs the same program Each processor computes with different data Variation of computation on different processors through if or switch statements

MPI Progam Organization MIMD in a SPMD framework Different processors can follow different computation paths Branch on if or switch based on processor identity

MPI Basics Starting and Finishing Identifying yourself Sending and Receiving messages

MPI starting and finishing Statement needed in every program before any other MPI code MPI_Init(&argc, &argv); Last statement of MPI code must be MPI_Finalize(); Program will not terminate without this statement

MPI Messages Message content, a sequence of bytes Message needs wrapper analogous to an envelope for a letter Letter Message Address Destination Return Address Source Type of Mailing (class) Message type Letter Weight Size (count) Country Communicator Magazine Broadcast

MPI Basics Communicator Collection of processes Determines scope to which messages are relative identity of process (rank) is relative to communicator scope of global communications (broadcast, etc.)

MPI Message Protocol, Send message contents block of memory count number of items in message message type type of each item destination rank of processor to receive tag integer designator for message communicator the communicator within which the message is sent

MPI Message Protocol, Receive message contents buffer in memory to store received message count size of buffer message type type of each item source rank of processor sending tag integer designator for message communicator the communicator within which the message is sent status information about message received

Message Passing Example #include <stdio.h> #include <string.h> #include "mpi.h" /* includes MPI library code specs */ #define MAXSIZE 100 int main(int argc, char* argv[]) { int myRank; /* rank (identity) of process */ int numProc; /* number of processors */ int source; /* rank of sender */ int dest; /* rank of destination */ int tag = 0; /* tag to distinguish messages */ char mess[MAXSIZE]; /* message (other types possible) */ int count; /* number of items in message */ MPI_Status status; /* status of message received */

Message Passing Example MPI_Init(&argc, &argv); /* start MPI */ /* get number of processes */ MPI_Comm_size(MPI_COMM_WORLD, &numProc); /* get rank of this process */ MPI_Comm_rank(MPI_COMM_WORLD, &myRank); /***********************************************/ /* code to send, receive and process messages */ MPI_Finalize(); /* shut down MPI */ }

Message Passing Example if (myRank != 0){/* all processes send to root */ /* create message */ sprintf(message, "Hello from %d", myRank); dest = 0; /* destination is root */ count = strlen(mess) + 1; /* include '\0' in message */ MPI_Send(mess, count, MPI_CHAR, dest, tag, MPI_COMM_WORLD); } else{/* root (0) process receives and prints messages */ /* from each processor in rank order */ for(source = 1; source < numProc; source++){ MPI_Recv(mess, MAXSIZE, MPI_CHAR, source, tag, MPICOMM_WORLD, &status); printf("%s\n", mess);

MPI message protocol Buffer in MPI_Recv must contain enough space for message. Buffer in MPI_Send need not all be sent Count (second parameter) in MPI_Send determines number of items of given type which are sent (type given by third parameter) Count (second parameter) in MPI_Recv specifies capacity of buffer (number of items) in terms of type given in third parameter

MPI message protocol Send - Receive is point-to-point, destination process is specified by fourth parameter (dest) in MPI_Send Messages can be tagged by integer to distinguish messages with different purposes by the fifth argument in MPI_Send and MPI_Recv MPI_Recv can specify a specific source from which to receive (fourth parameter) MPI_Recv can receive from any source or with any tag using MPI_ANY_SOURCE and MPI_ANY_TAG

MPI message protocol Communicator, sixth parameter in MPI_Send and MPI_Recv, determines context for destination and source ranks MPI_COMM_WORLD is automatically supplied communicator which includes all processes created at start-up Other communicators can be defined by user to group processes and to create virtual topologies

MPI message protocol Status of message received by MPI_Recv is returned in the seventh (status) parameter Number of items actually received can be determined from status by using function MPI_Get_count The following call inserted into the previous code would return the number of characters sent in the integer variable cnt MPI_Get_count(&status, MPI_CHAR, &cnt);

Broadcasting a message Broadcast: one sender, many receivers Includes all processes in communicator, all processes must make an equivalent call to MPI_Bcast Any processor may be sender (root), as determined by the fourth parameter First three parameters specify message as for MPI_Send and MPI_Recv, fifth parameter specifies communicator Broadcast serves as a global synchronization

MPI_Bcast() Syntax MPI_Bcast(mess, count, MPI_INT, root, MPI_COMM_WORLD); mess pointer to message buffer count number of items sent MPI_INT type of item sent Note: count and type should be the same on all processors root sending processor MPI_COMM_WORLD communicator within which broadcast takes place

Timing Programs MPI_Wtime() returns a double giving time in seconds from a fixed time in the past To time a program, record MPI_Wtime() in a variable at start, then again at finish, difference is elapsed time startime = MPI_Wtime(); /* part of program to be timesd */ stoptime = MPI_Wtime(); time = stoptime - starttime;