Fengguang Song Department of Computer Science IUPUI

Size: px
Start display at page:

Download "Fengguang Song Department of Computer Science IUPUI"

Transcription

1 CS 590: High Performance Computing MPI (2) Fengguang Song Department of Computer Science IUPUI int MPI_Recv(void *buf,int count,mpi_datatype datatype,int source,int tag, MPI_Comm comm, MPI_Status *status) Message Data Consists of count successive entries of the type indicated by datatype, starting with the entry at the address buf. MPI data types: Basic data types: one for each data type in hosting languages of C/C++, FORTRAN Derived data type: will learn later. 31 1

2 Basic MPI Data Types MPI datatype C datatype MPI datatype FORTRAN datatype MPI_CHAR MPI_SHORT MPI_INT MPI_LONG MPI_UNSIGNED_CHAR MPI_UNSIGNED_SHORT MPI_UNSIGNED signed char signed short signed int signed long unsigned char unsigned short unsigned int MPI_INTEGER MPI_REAL MPI_DOUBLE_PREC ISION MPI_COMPLEX MPI_LOGICAL INTEGER REAL DOUBLE PRECISION COMPLEX LOGICAL MPI_UNSIGNED_LONG unsigned long int MPI_CHARACTER CHARACTER(1) MPI_DOUBLE MPI_FLOAT MPI_LONG_DOUBLE double float long double MPI_BYTE MPI_PACKED MPI_BYTE MPI_PACKED 32 Message Envelope Envelope: Source Destination Tag Communicator MPI_Send: source is the calling process, destination is defined Destination can be MPI_PROC_NULL // will return asap, no effect. MPI_Recv: destination is the calling process, source is defined Source can be a wildcard, MPI_ANY_SOURCE. Source can also be MPI_PROC_NULL // Return asap, no effect, receive buffer not modified. Tag: non-negative number, 0, 1,, UB; UB can be determined by querying MPI environment (UB>=32767). For MPI_Recv, can be a wildcard, MPI_ANY_TAG. Communicator: specified, usually MPI_COMM_WORLD. 34 2

3 In Order for a Message To be Received 1) Message envelopes must match Message must be directed to the receiver process Message source must match the source specified by MPI_Recv, unless MPI_ANY_SOURCE is specified. Message tag must match the tag specified by MPI_Recv, unless MPI_ANY_TAG is specified Message communicator must match that specified by MPI_Recv. 2) Data type must match Datatype specified by MPI_Send and MPI_Recv must match. MPI_PACKED can match any other data type Can be more complicated when derived data types are involved. 35 Example: Sending A from P0 to P1 double A[10], B[15]; int rank, tag = 1001, tag1=1002; MPI_Status status; MPI_Comm_rank(MPI_COMM_WORLD,&rank); if(rank==0) MPI_Send(A, 10, MPI_DOUBLE, 1, tag, MPI_COMM_WORLD); else if(rank==1){ MPI_Recv(B, 15, MPI_DOUBLE, 0, tag, MPI_COMM_WORLD, &status); // OK // MPI_Recv(B, 15, MPI_FLOAT, 0, tag, MPI_COMM_WORLD, &status); ß wrong // MPI_Recv(B,15,MPI_DOUBLE,0,tag1,MPI_COMM_WORLD,&status); ß un-match // MPI_Recv(B,15,MPI_DOUBLE,1,tag,MPI_COMM_WORLD,&status); ß un-match // MPI_Recv(B,15,MPI_DOUBLE,MPI_ANY_SOURCE,tag,MPI_COMM_WORLD,&status); ß OK // MPI_Recv(B,15,MPI_DOUBLE,0,MPI_ANY_TAG,MPI_COMM_WORLD,&status); ß OK } 36 3

4 Blocking Send/Recv MPI_Send is blocking: will not return until the message data and envelope is safely stored away. The message data might be delivered to the matching receive buffer, or copied to some temporary system buffer. After MPI_Send returns, user can safely access or overwrite the send buffer. MPI_Recv is blocking: returns only after the receive buffer has the received message After it returns, the data is here and ready for use. Non-blocking send/recv: will be discussed later. Non-blocking calls will return immediately; however, not safe to access the send/receive buffers. Need to call other functions to complete send/recv, then safe to access/modify send/receive buffers. 37 Buffering Send and its matching receive operations may not be synchronized in reality. MPI implementation must decide what happens when send/recv are out of sync. Consider: Send occurs 5 seconds before receive is ready; where is the message when receive is not ready? Multiple sends arrive at the same receiving task which can receive one send at a time what happens to the messages that are backing up? MPI implementation (not the MPI standard) decides what happens in these cases. Typically a system buffer is used to hold data in transit. 38 4

5 Buffering System buffer: Invisible to users and managed by MPI library Finite resource that can be easily exhausted May exist on sending or receiving side, or both Can improve performance. User can attach his/her own buffer for MPI message buffering Warning: if the system buffer becomes full, MPI_Send will be blocked for a long time 39 Different Communication Modes for Send Standard mode: MPI_Send System decides whether the outgoing message will be buffered or not Usually, small messages à buffering mode; large messages, no buffering, synchronous mode Buffered mode: MPI_Bsend Message will be copied to user-provided buffer; Sender calls then returns Users attach own buffer using int MPI_Buffer_attach(void *buf, int size) Synchronous mode: MPI_Ssend No buffering Will block until a matching receive starts receiving data Ready mode: MPI_Rsend Can be used only if a matching receive is already posted; avoid handshake etc. otherwise erroneous. 40 5

6 Communication Modes MPI_Send(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) MPI_Bsend(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) MPI_Ssend(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) MPI_Rsend(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) There is only one MPI_Recv; will match any send mode 41 Properties Message Order: MPI messages are order-preserved If a sender sends two messages to the same destination, and both match the same receiver, then the receiver will receive the first message no matter which message physically arrives first at the receiver. However, if a receive matches two messages from two different senders, the receive may receive either one (implementation dependent). 42 6

7 Properties Progress: if a pair of matching send/recv are initiated on two processes, at least one of them will complete Send will complete, unless the receive is satisfied by some other message Receive will complete, unless send is consumed by some other matching receive. 43 Properties No guarantee of fairness If a message is sent to a destination, and the destination process repeatedly posts a receive that matches this send, however the message may never be received since it is each time overtaken by another message sent from another source. It is user s responsibility to prevent the starvation in such situations. e.g., specify the source process 44 7

8 Properties Resource limitation: Pending communications consume system resources (e.g. buffer space) Lack of resource may either cause error or prevent execution of MPI call. e.g. MPI_Bsend that cannot complete, due to lack of buffer space, is erroneous. e.g., MPI_Send that cannot complete, due to lack of buffer space, will only block, waiting for buffer space to be available or for a matching receive. 45 Pay Attention to Deadlock Deadlock is a state when the program cannot proceed. Cyclic dependencies cause deadlock MPI_Comm_rank(MPI_COMM_WORLD,&rank); If(rank==0){ MPI_Recv(buf1,count,MPI_DOUBLE,1,tag,comm); MPI_Send(buf2,count,MPI_DOUBLE,1,tag,comm); } else if (rank==1) { MPI_Recv(buf1,count,MPI_DOUBLE,0,tag,comm); MPI_Send(buf2,count,MPI_DOUBLE,0,tag,comm); } 0 1 MPI_Comm_rank(MPI_COMM_WORLD,&rank); If(rank==0){ MPI_Ssend(buf1,count,MPI_DOUBLE,1,tag,comm); MPI_Recv(buf2,count,MPI_DOUBLE,1,tag,comm); } else if (rank==1) { MPI_Ssend(buf1,count,MPI_DOUBLE,0,tag,comm); MPI_Recv(buf2,count,MPI_DOUBLE,0,tag,comm); } 46 8

9 Pay Attention to Deadlock Lack of buffer space may also cause deadlock MPI_Comm_rank(MPI_COMM_WORLD,&rank); If(rank==0){ MPI_Send(buf1,count,MPI_DOUBLE,1,tag,comm); MPI_Recv(buf2,count,MPI_DOUBLE,1,tag,comm); } else if (rank==1) { MPI_Send(buf1,count,MPI_DOUBLE,0,tag,comm); MPI_Recv(buf2,count,MPI_DOUBLE,0,tag,comm); } Deadlock if not enough buffer space! 47 Using Send-receive 2 remedies: 1) non-blocking communication, 2) send-recv MPI_SENDRECV: combine send and recv in one call Useful in shift operations; Avoid possible deadlock with circular shift operations Equivalent to: execute a nonblocking send and a nonblocking recv, and then wait for them to complete 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) P0 P1 P2 P3 *sendbuf and *recvbuf may not be the same memory address 48 9

10 #include <mpi.h> #include <stdio.h> int main(int argc, char **argv) { int my_rank, ncpus; int left_neighbor, right_neighbor; int data_received=-1; int send_tag = 101, recv_tag=101; MPI_Status status; mpirun np 4 test_shift Example Among 4 processes, process 3 received from right neighbor: 0 Among 4 processes, process 2 received from right neighbor: 3 Among 4 processes, process 0 received from right neighbor: 1 Among 4 processes, process 1 received from right neighbor: 2 MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); MPI_Comm_size(MPI_COMM_WORLD, &ncpus); left_neighbor = (my_rank-1 + ncpus)%ncpus; right_neighbor = (my_rank+1)%ncpus; MPI_Sendrecv(&my_rank, 1, MPI_INT, left_neighbor, send_tag, &data_received, 1, MPI_INT, right_neighbor, recv_tag, MPI_COMM_WORLD, &status); printf("among %d processes, process %d received from right neighbor: %d\n", ncpus, my_rank, data_received); // clean up MPI_Finalize(); return 0; } 49 Non-Blocking Communications 50 10

11 Semantics Purpose: Important mechanism for overlapping communication and computations. Communication and computation may proceed concurrently. à You hide communications! Deadlock avoidance May avoid system buffering and memory-to-memory copying, and improve performance How to Use it: 1. Post communication requests ß non-blocking call: MPI_Isend 2. // do some useful work 3. Complete communication call ß MPI_Wait, MPI_Test, 51 Non-blocking send Semantics Non-blocking calls: MPI_Isend, MPI_Irecv Will return immediately. Merely post a request to system to initiate communication. However, communication is not completed. Cannot change the memory provided in these calls until the communication is completed by calling MPI_Wait or MPI_Test. Non-blocking receive 52 11

12 The Interface 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) MPI_Request request is a handle to an internal MPI object. Everything about that non-blocking communication is through that handle. MPI_Request req1, req2; double A[10], B[10]; MPI_Isend(A, 10, MPI_DOUBLE, rank, tag, MPI_COMM_WORLD, &req1); MPI_Irecv(B, 10, MPI_DOUBLE, rank, tag, MPI_COMM_WORLD, &req2); 53 #include <mpi.h> #include <stdio.h> Example int main(int argc, char **argv) { int my_rank, ncpus; int left_neighbor, right_neighbor; int data_received=-1; int tag = 101; MPI_Status statsend, statrecv; MPI_Request reqsend, reqrecv; mpirun np 4 test_shift Among 4 processes, process 3 received from right neighbor: 0 Among 4 processes, process 2 received from right neighbor: 3 Among 4 processes, process 0 received from right neighbor: 1 Among 4 processes, process 1 received from right neighbor: 2 MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); MPI_Comm_size(MPI_COMM_WORLD, &ncpus); left_neighbor = (my_rank-1 + ncpus)%ncpus; right_neighbor = (my_rank+1)%ncpus; MPI_Isend(&my_rank,1,MPI_INT,left_neighbor,tag,MPI_COMM_WORLD,&reqSend); // comm start MPI_Irecv(&data_received,1,MPI_INT,right_neighbor,tag,MPI_COMM_WORLD,&reqRecv); // Here, you can do some useful computations MPI_Wait(&reqSend, &statsend); // complete comm MPI_Wait(&reqRecv, &statrecv); printf("among %d processes, process %d received from right neighbor: %d\n", ncpus, my_rank, data_received); // clean up MPI_Finalize(); return 0; } 54 12

13 Non-blocking Sends 4 communication modes, same semantics as blocking sends. MPI_ISEND standard mode MPI_IBSEND buffered mode MPI_ISSEND synchronous mode MPI_IRSEND ready mode Identical arguments as MPI_Isend int MPI_Ibsend(void *buf,int count,mpi_datatype datatype,int dest, int tag, MPI_Comm comm, MPI_Request *request) int MPI_Issend(void *buf,int count,mpi_datatype datatype,int dest, int tag, MPI_Comm comm, MPI_Request *request) int MPI_Irsend(void *buf,int count,mpi_datatype datatype,int dest, int tag, MPI_Comm comm, MPI_Request *request) 55 Completion Use MPI_Wait or MPI_Test to complete non-blocking communication Semantics: after MPI_Wait returns For send, message data has been safely stored away, and safe to access buffer. For receive, data has been received

14 MPI_Wait int MPI_Wait(MPI_Request *request, MPI_Status *status) *request is a handle returned from MPI_Isend, MPI_Irecv etc Will block until the communication completes (or fails) If request is from MPI_Isend, MPI_Irecv etc Will deallocate the request object (set request to MPI_REQUEST_NULL) Return in status the status information. for MPI_Irecv, hold additional information. For MPI_Isend, not much to be used MPI_Request req; MPI_Status status; MPI_Irecv(, &req); MPI_Wait(&req, &status); 57 MPI_Test int MPI_Test(MPI_Request *request, int *flag, MPI_Status *status) request MPI_Request object from MPI_Isend, etc flag true if communication complete; false if not yet If true, request object will be de-allocated, and set to MPI_REQUEST_NULL status contain status information if complete Does not block, return immediately Provide a mechanism for overlapping communication and computation Do useful computation; periodically check communication status; if not complete, go back to computation

15 MPI_Wait Variants Deal with an array of MPI_Requests: MPI_Request req[4]; MPI_Waitall: MPI_Waitall(int count, MPI_Request *request, MPI_Status *status) Blocks until all active requests in array complete; return status of all communications Deallocate request objects, set to MPI_REQUEST_NULL MPI_Waitany: MPI_Waitany(int count,mpi_request *req, int *index, MPI_Status *stat) Blocks until one of the active requests in array completes; return THE index and the status of completing request; deallocate that request object. If none completes, return index=mpi_undefined. MPI_Waitsome: MPI_Waitsome(int incount, MPI_Request *req, int *outcount, int *array_indices, MPI_Status *array_status) Blocks until at least one of the active communications completes; return associated indices and status of completed communications; deallocate objects. If none, outcount=mpi_undefined. MPI_Request req[2]; MPI_Status stat[2]; MPI_Isend(, &req[0]); MPI_Isend(, &req[1]); MPI_Waitall(2, req, stat); MPI_Request req[2]; MPI_Status stat; Int index; MPI_Isend(, &req[0]); MPI_Isend(, &req[1]); MPI_Waitany(2, req, &index, &stat); 60 MPI_Test Variants MPI_Testall: MPI_Testall(int count, MPI_Request *array_req, int *flag, MPI_Status *array_stat) Return flag=true if all active requests complete; return flag=false otherwise. If true, will de-allocate request objects, set to MPI_REQUEST_NULL. MPI_Testany: MPI_Testany(int count, MPI_Request *array_req, int *index, int *flag, MPI_Status *stat) If one of active comm completes, return flag=true the index and status of completing comm; deallocate that object. Return flag=false, index=mpi_undefined if none completes Return flag=true, index=mpi_undefined if none active requests. MPI_Testsome: MPI_Testsome(int incount, MPI_Request *array_req, int *outcount, int *array_indices, MPI_Status *array_stat) Return in outcount the number of completed active comm and associated indices and status of completing comm. If none completes, return outcount=0 if none active comm, outcount=mpi_undefined

16 CS 590: High Performance Computing MPI (3) Fengguang Song Department of Computer Science IUPUI 16

17 Collective Communications 74 Overview of Collective Communications All processes in a group participate in a communication, by calling the same function with matching arguments. Types of collective operations: Synchronization: MPI_Barrier Collective data movement: MPI_Bcast, MPI_Scatter, MPI_Gather, MPI_Allgather, MPI_Alltoall Collective computation: MPI_Reduce, MPI_Allreduce, MPI_Scan Collective routines are blocking Completion of function call means the communication buffer can be accessed 75 17

18 Overview of Collective Communications MPI guarantees messages from collective communications will not be confused with P2P communications. All processes must participate in communication If you want only a sub-group of processes involved in collective communication, need to create a sub-group/subcommunicator from MPI_COMM_WORLD 76 Barrier int MPI_Barrier(MPI_Comm comm) Blocks the calling process until all group members have called it. Affect program performance Refrain from using it. MPI_Barrier(MPI_COMM_WORLD); // synchronization point 77 18

19 Broadcast int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm) Broadcasts a message from process with rank root to all processes in group, including itself. comm and root must be the same in all processes count and datatype must be the same for all processes Exception: could be different when derived datatypes are involved. int num=-1; If(my_rank==0) num=100; //the ROOT MPI_Bcast(&num, 1, MPI_INT, 0/*root*/, MPI_COMM_WORLD); 78 Scatter Int MPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype *sendtype, void *recvbuf, int recvcount, MPI_Datatype *recvtype, int root, MPI_Comm comm) Inverse to MPI_Gather Split message into ncpus equal segments i-th segment to i-th process sendbuf, sendcount, sendtype important only at root, ignored in other processes. sendcount is the number of items sent to each process, not the total number of items in sendbuf 79 19

20 Scatter Example int A[1000], B[100]; //10 processes in total... // initializa A etc MPI_Scatter(A, 100/*not 1000*/, MPI_INT, B, 100, MPI_INT, 0, MPI_COMM_WORLD); 80 Gather Int MPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm) Gathers message to root; concatenated based on rank order at root process Recvbuf, recvcount, recvtype are only important at root; ignored in other processes. root and comm must be identical on all processes. recvbuf and sendbuf cannot be the same on root process. recvcount=sendcount, recvtype=sendtype. recvcount is the number of items received from each process, not the total number of items received, and not the size of receive buffer! 81 20

21 Gather Example int rank, ncous; int root = 0; int *data_received=null, data_send[100]; // assume running with 10 cpus MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &ncpus); if(rank==root) data_received = new int[100*ncpus]; // 100*10 MPI_Gather(data_send, 100, MPI_INT, data_received, 100 /*not 100*ncpus!*/, MPI_INT, root, MPI_COMM_WORLD); 82 All Gather (i.e., everyone gathers) Int MPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype *sendtype, void *recvbuf, int recvcount, MPI_Datatype *recvtype, root, MPI_Comm comm) Concatenated messages according to rank order received by all processes Again, recvcount is the number of items from each process, not the total number of items received Again, sendcount=recvcount,sendtype=recvtype int A[100], B[1000]; // assume 10 processors MPI_Allgather(A, 100, MPI_INT, B, 100, MPI_INT, MPI_COMM_WORLD); // ok 83 21

22 All-to-All MPI_Alltoall can be seen as a global transposition operation, acting on chunks of data. int MPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm) Most stressful communication. Important for distributed matrix transposition, and critical to FFT-based algorithms sendcount is the number of items sent to each process, not the total number of items in sendbuf. recvcount is the number of items received from each process, not the total number of items received. For now, sendcount=recvcount, sendtype=recvtype 84 All-to-All Example double A[4], B[4];... // assume 4 cpus for(i=0;i<4;i++) A[i] = my_rank*4 + i; MPI_Alltoall(A, 1, MPI_DOUBLE, B, 1, MPI_DOUBLE, MPI_COMM_WORLD); Cpu 0 Cpu 1 Cpu 2 Cpu

23 Reduction Perform global reduction operations (sum, max, min, and, etc) across processors. MPI_Reduce return result to one processor MPI_Allreduce return result to all processors MPI_Scan parallel prefix operation 86 Reduction Int MPI_Reduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm) Element-wise combine data from input buffers across processors using operation op store results in output buffer on processor root. All processes must provide input/output buffers of the same length and data type. Operation op must be associative: Pre-defined operations User can define own operations int rank, res; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Reduce(&rank, &res, 1, MPI_INT, MPI_MAX, 0, MPI_COMM_WORLD); 87 23

24 Pre-Defined Operations MPI_MAX MPI_MIN MPI_SUM MPI_PROD MPI_LAND MPI_LOR MPI_BAND MPI_BOR MPI_LXOR MPI_BXOR MPI_MAXLOC MPI_MINLOC Logical AND Logical OR Bitwise AND Bitwise OR max + location min + location 88 All Reduce int MPI_Allreduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) Reduction result stored on all processors

25 Scan Int MPI_Scan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) Prefix reduction To process j, return results of reduction on input buffers of processes 0, 1,, j. int MPI_Op_create(MPI_User_function *function, int commute, MPI_Op *op) 90 25

26 Process Subgroups and Subcommunicators Process Virtual Topology Process Groups & Communicators You can create sub-groups of processes, or subcommunicators Must create sub-groups or sub-communicators from some existing groups or communicators e.g., start from MPI_COMM_WORLD (or MPI_COMM_SELF) 99 26

27 Sub-communicators: How? MPI_Comm Communicator MPI_Group Process Group Sub-communicator Process sub-group 100 Facts about groups and communicators Group: ordered set of processes each process in group has a unique rank within that group process can belong to more than one group Rank is always relative to a group Communicators: from the programming viewpoint, groups and communicators are equivalent why distinguish between groups and communicators? sometimes you want to create two communicators for the same group useful for supporting libraries Groups and communicators are dynamic objects and can be created and destroyed during the execution of the program 27

28 Typical Usage 1. Extract handle of the global group from MPI_COMM_WORLD using MPI_Comm_group 2. Form new group as a subset of global group using MPI_Group_incl or MPI_Group_excl 3. Create new communicator for the new group using MPI_Comm_create 4. Determine new rank in new communicator using MPI_Comm_rank 5. Conduct communications using any MPI message passing routine 6. When finished, free up new communicator and group (optional) using MPI_Comm_free and MPI_Group_free Communicator à Process Group MPI_Comm_group gets group associated with communicator int MPI_Comm_group(MPI_Comm comm, MPI_Group *group)... MPI_Group group; MPI_Comm_group(MPI_COMM_WORLD, &group);

29 Details MPI_Group_excl: create a new group by removing certain processes from existing group int MPI_Group_excl(MPI_Group group, int n, int *ranks, MPI_Group *newgroup); ranks: containing ranks to be excluded MPI_Group_incl: create a new group from certain selected processes from existing group int MPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group *newgroup); ranks: containing ranks to be included Process Group à Communicator MPI_Comm_create(): create a communicator from a process group group is a sub-group of that associated with comm Collective operation int MPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm *newcomm) MPI_Group MPI_GROUP_WORLD, slave; MPI_Comm slave_comm; int ranks[1]; Ranks[0] = 0; MPI_Comm_group(MPI_COMM_WORLD, &MPI_GROUP_WORLD); MPI_Group_excl(MPI_GROUP_WORLD, 1, &ranks, &slave); MPI_Comm_create(MPI_COMM_WORLD, slave, &slave_comm);... MPI_Group_free(&slave); MPI_Comm_free(&slave_comm);

30 main(int argc, char **argv) { int me, count, count2; void *send_buf, *recv_buf, *send_buf2, *recv_buf2; MPI_Group MPI_GROUP_WORLD, grprem; MPI_Comm commslave; static int ranks[] = {0}; MPI_Init(&argc, &argv); MPI_Comm_group(MPI_COMM_WORLD, &MPI_GROUP_WORLD); MPI_Comm_rank(MPI_COMM_WORLD, &me); MPI_Group_excl(MPI_GROUP_WORLD, 1, ranks, &grprem); MPI_Comm_create(MPI_COMM_WORLD, grprem, &commslave); if(me!= 0){ /* compute on slave */ MPI_Reduce(send_buf,recv_buff,count, MPI_INT, MPI_SUM, 1, commslave); } /* zero falls through immediately to this reduce, others do later... */ MPI_Reduce(send_buf2, recv_buff2, count2, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); MPI_Comm_free(&commslave); MPI_Group_free(&MPI_GROUP_WORLD); MPI_Group_free(&grprem); MPI_Finalize(); } Communicator Splitter int MPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm *newcomm) Partition comm into disjoint sub-communicators, one for each value color Processes providing same color values will belong to the same new communicator newcomm Within newcomm, processes ranked based on key values that are provided (optional) color must be non-negative. If MPI_UNDEFINED is provided in color, MPI_COMM_NULL will be returned in newcomm. MPI_Comm_rank(MPI_COMM_WORLD, &rank); myrow = (int)(rank/ncol); //answer is 0, 1,... nrows-1 MPI_Comm_split(MPI_COMM_WORLD, myrow, rank, row_comm);

31 Virtual Topology 1-D Ranking (0, 1,, N-1) often does not reflect logical communication patterns of processes Desirable to arrange processes to reflect the underlying problem geometry or numerical algorithm, e.g. 2D or 3D grids Virtual topology: logical process arrangement Virtual topology does not reflect machine s physical topology 110 Cartesian Topology n-dimensional Cartesian topology (m1, m2, m3,, mn) grid; mi is the number of processes in i-th direction A process can be represented by its coordinate (j1, j2, j3,, jn) Constructor: MPI_Cart_create()

32 Cartesian Constructor int MPI_Cart_create(MPI_Comm comm_old, int ndims, int *dims, int *periods, int reorder, MPI_Comm *comm_cart) comm_old: existing communicator ndims: dimension of Cartesian topology dims: dimension [ndims], number of processes in each direction periods: dimension [ndims], true or false, periodic or not in each direction reorder: trueàmay reorder rank; false, no re-ordering of ranks comm_cart: new communicator with Cartesian topology MPI_Comm comm_new; int dims[2], periods[2], ncpus; MPI_Comm_size(MPI_COMM_WORLD, &ncpus); dims[0] = 2; dims[1] = ncpus/2; // assume ncpus dividable by 2 periods[0] = periods[1] = 1; MPI_Cart_create(MPI_COMM_WORLD, 2, dims, periods, 0, &comm_new); Topology Inquiry Functions int MPI_Cartdim_get(MPI_Comm comm, int *ndims) int MPI_Cart_coords(MPI_Comm comm, int rank, int maxdims, int *coords) int MPI_Cart_rank(MPI_Comm, int *coords, int *rank) MPI_Cartdim_get returns the dimension of Cartesian topology MPI_Cart_coords returns the coordinates of a process of rank MPI_Cart_rank returns of the rank of a process with coordinate *coords MPI_Comm comm_cart; int ndims, rank, *coords; // create Cartesian topology on comm_cart MPI_Comm_rank(comm_cart, &rank); MPI_Cartdim_get(comm_cart, &ndims); coords = new int[ndims]; MPI_Cart_coords(comm_cart, rank, ndims, coords); // coords contains coord MPI_Cart_rank(comm_cart, coords, &rank);

Programming Using the Message Passing Paradigm

Programming Using the Message Passing Paradigm Programming Using the Message Passing Paradigm Ananth Grama, Anshul Gupta, George Karypis, and Vipin Kumar To accompany the text ``Introduction to Parallel Computing'', Addison Wesley, 2003. Topic Overview

More information

MPI. (message passing, MIMD)

MPI. (message passing, MIMD) MPI (message passing, MIMD) What is MPI? a message-passing library specification extension of C/C++ (and Fortran) message passing for distributed memory parallel programming Features of MPI Point-to-point

More information

Recap of Parallelism & MPI

Recap of Parallelism & MPI Recap of Parallelism & MPI Chris Brady Heather Ratcliffe The Angry Penguin, used under creative commons licence from Swantje Hess and Jannis Pohlmann. Warwick RSE 13/12/2017 Parallel programming Break

More information

Standard MPI - Message Passing Interface

Standard MPI - Message Passing Interface c Ewa Szynkiewicz, 2007 1 Standard MPI - Message Passing Interface The message-passing paradigm is one of the oldest and most widely used approaches for programming parallel machines, especially those

More information

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

Programming SoHPC Course June-July 2015 Vladimir Subotic MPI - Message Passing Interface www.bsc.es Programming with Message-Passing Libraries SoHPC Course June-July 2015 Vladimir Subotic 1 Data Transfer Blocking: Function does not return, before message can be accessed again Process is blocked

More information

Outline. Communication modes MPI Message Passing Interface Standard

Outline. Communication modes MPI Message Passing Interface Standard MPI THOAI NAM Outline Communication modes MPI Message Passing Interface Standard TERMs (1) Blocking If return from the procedure indicates the user is allowed to reuse resources specified in the call Non-blocking

More information

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

Topics. Lecture 7. Review. Other MPI collective functions. Collective Communication (cont d) MPI Programming (III) Topics Lecture 7 MPI Programming (III) Collective communication (cont d) Point-to-point communication Basic point-to-point communication Non-blocking point-to-point communication Four modes of blocking

More information

Distributed Systems + Middleware Advanced Message Passing with MPI

Distributed Systems + Middleware Advanced Message Passing with MPI Distributed Systems + Middleware Advanced Message Passing with MPI Gianpaolo Cugola Dipartimento di Elettronica e Informazione Politecnico, Italy cugola@elet.polimi.it http://home.dei.polimi.it/cugola

More information

Practical Scientific Computing: Performanceoptimized

Practical Scientific Computing: Performanceoptimized Practical Scientific Computing: Performanceoptimized Programming Programming with MPI November 29, 2006 Dr. Ralf-Peter Mundani Department of Computer Science Chair V Technische Universität München, Germany

More information

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

IPM Workshop on High Performance Computing (HPC08) IPM School of Physics Workshop on High Perfomance Computing/HPC08 IPM School of Physics Workshop on High Perfomance Computing/HPC08 16-21 February 2008 MPI tutorial Luca Heltai Stefano Cozzini Democritos/INFM + SISSA 1 When

More information

COMP 322: Fundamentals of Parallel Programming

COMP 322: Fundamentals of Parallel Programming COMP 322: Fundamentals of Parallel Programming https://wiki.rice.edu/confluence/display/parprog/comp322 Lecture 37: Introduction to MPI (contd) Vivek Sarkar Department of Computer Science Rice University

More information

Review of MPI Part 2

Review of MPI Part 2 Review of MPI Part Russian-German School on High Performance Computer Systems, June, 7 th until July, 6 th 005, Novosibirsk 3. Day, 9 th of June, 005 HLRS, University of Stuttgart Slide Chap. 5 Virtual

More information

Cluster Computing MPI. Industrial Standard Message Passing

Cluster Computing MPI. Industrial Standard Message Passing MPI Industrial Standard Message Passing MPI Features Industrial Standard Highly portable Widely available SPMD programming model Synchronous execution MPI Outer scope int MPI_Init( int *argc, char ** argv)

More information

High Performance Computing

High Performance Computing High Performance Computing Course Notes 2009-2010 2010 Message Passing Programming II 1 Communications Point-to-point communications: involving exact two processes, one sender and one receiver For example,

More information

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

CS 470 Spring Mike Lam, Professor. Distributed Programming & MPI CS 470 Spring 2018 Mike Lam, Professor Distributed Programming & MPI MPI paradigm Single program, multiple data (SPMD) One program, multiple processes (ranks) Processes communicate via messages An MPI

More information

Parallel Programming. Using MPI (Message Passing Interface)

Parallel Programming. Using MPI (Message Passing Interface) Parallel Programming Using MPI (Message Passing Interface) Message Passing Model Simple implementation of the task/channel model Task Process Channel Message Suitable for a multicomputer Number of processes

More information

Parallel Computing. Distributed memory model MPI. Leopold Grinberg T. J. Watson IBM Research Center, USA. Instructor: Leopold Grinberg

Parallel Computing. Distributed memory model MPI. Leopold Grinberg T. J. Watson IBM Research Center, USA. Instructor: Leopold Grinberg Parallel Computing Distributed memory model MPI Leopold Grinberg T. J. Watson IBM Research Center, USA Why do we need to compute in parallel large problem size - memory constraints computation on a single

More information

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

CS 470 Spring Mike Lam, Professor. Distributed Programming & MPI CS 470 Spring 2017 Mike Lam, Professor Distributed Programming & MPI MPI paradigm Single program, multiple data (SPMD) One program, multiple processes (ranks) Processes communicate via messages An MPI

More information

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

Message Passing Interface. most of the slides taken from Hanjun Kim Message Passing Interface most of the slides taken from Hanjun Kim Message Passing Pros Scalable, Flexible Cons Someone says it s more difficult than DSM MPI (Message Passing Interface) A standard message

More information

Message Passing Interface

Message Passing Interface Message Passing Interface DPHPC15 TA: Salvatore Di Girolamo DSM (Distributed Shared Memory) Message Passing MPI (Message Passing Interface) A message passing specification implemented

More information

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

CSE 613: Parallel Programming. Lecture 21 ( The Message Passing Interface ) CSE 613: Parallel Programming Lecture 21 ( The Message Passing Interface ) Jesmin Jahan Tithi Department of Computer Science SUNY Stony Brook Fall 2013 ( Slides from Rezaul A. Chowdhury ) Principles of

More information

High-Performance Computing: MPI (ctd)

High-Performance Computing: MPI (ctd) High-Performance Computing: MPI (ctd) Adrian F. Clark: alien@essex.ac.uk 2015 16 Adrian F. Clark: alien@essex.ac.uk High-Performance Computing: MPI (ctd) 2015 16 1 / 22 A reminder Last time, we started

More information

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

Outline. Communication modes MPI Message Passing Interface Standard. Khoa Coâng Ngheä Thoâng Tin Ñaïi Hoïc Baùch Khoa Tp.HCM THOAI NAM Outline Communication modes MPI Message Passing Interface Standard TERMs (1) Blocking If return from the procedure indicates the user is allowed to reuse resources specified in the call Non-blocking

More information

4. Parallel Programming with MPI

4. Parallel Programming with MPI 4. Parallel Programming with MPI 4. Parallel Programming with MPI... 4.. MPI: Basic Concepts and Definitions...3 4... The Concept of Parallel Program...3 4..2. Data Communication Operations...3 4..3. Communicators...3

More information

Department of Informatics V. HPC-Lab. Session 4: MPI, CG M. Bader, A. Breuer. Alex Breuer

Department of Informatics V. HPC-Lab. Session 4: MPI, CG M. Bader, A. Breuer. Alex Breuer HPC-Lab Session 4: MPI, CG M. Bader, A. Breuer Meetings Date Schedule 10/13/14 Kickoff 10/20/14 Q&A 10/27/14 Presentation 1 11/03/14 H. Bast, Intel 11/10/14 Presentation 2 12/01/14 Presentation 3 12/08/14

More information

Programming Using the Message-Passing Paradigm (Chapter 6) Alexandre David

Programming Using the Message-Passing Paradigm (Chapter 6) Alexandre David Programming Using the Message-Passing Paradigm (Chapter 6) Alexandre David 1.2.05 1 Topic Overview Principles of Message-Passing Programming MPI: the Message Passing Interface Topologies and Embedding

More information

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

Topics. Lecture 6. Point-to-point Communication. Point-to-point Communication. Broadcast. Basic Point-to-point communication. MPI Programming (III) Topics Lecture 6 MPI Programming (III) Point-to-point communication Basic point-to-point communication Non-blocking point-to-point communication Four modes of blocking communication Manager-Worker Programming

More information

Introduction to MPI: Part II

Introduction to MPI: Part II Introduction to MPI: Part II Pawel Pomorski, University of Waterloo, SHARCNET ppomorsk@sharcnetca November 25, 2015 Summary of Part I: To write working MPI (Message Passing Interface) parallel programs

More information

Parallel Programming

Parallel Programming Parallel Programming Point-to-point communication Prof. Paolo Bientinesi pauldj@aices.rwth-aachen.de WS 18/19 Scenario Process P i owns matrix A i, with i = 0,..., p 1. Objective { Even(i) : compute Ti

More information

Non-Blocking Communications

Non-Blocking Communications 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

More information

Collective Communications

Collective Communications Collective 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

More information

Introduction to MPI. HY555 Parallel Systems and Grids Fall 2003

Introduction to MPI. HY555 Parallel Systems and Grids Fall 2003 Introduction to MPI HY555 Parallel Systems and Grids Fall 2003 Outline MPI layout Sending and receiving messages Collective communication Datatypes An example Compiling and running Typical layout of an

More information

Experiencing Cluster Computing Message Passing Interface

Experiencing Cluster Computing Message Passing Interface Experiencing Cluster Computing Message Passing Interface Class 6 Message Passing Paradigm The Underlying Principle A parallel program consists of p processes with different address spaces. Communication

More information

Parallel programming MPI

Parallel programming MPI Parallel programming MPI Distributed memory Each unit has its own memory space If a unit needs data in some other memory space, explicit communication (often through network) is required Point-to-point

More information

Message Passing Interface

Message Passing Interface Message Passing Interface by Kuan Lu 03.07.2012 Scientific researcher at Georg-August-Universität Göttingen and Gesellschaft für wissenschaftliche Datenverarbeitung mbh Göttingen Am Faßberg, 37077 Göttingen,

More information

Programming Using the Message Passing Interface

Programming Using the Message Passing Interface Programming Using the Message Passing Interface Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu SSE3054: Multicore Systems, Spring 2017, Jinkyu Jeong

More information

MPI point-to-point communication

MPI point-to-point communication MPI point-to-point communication Slides Sebastian von Alfthan CSC Tieteen tietotekniikan keskus Oy CSC IT Center for Science Ltd. Introduction MPI processes are independent, they communicate to coordinate

More information

Scientific Computing

Scientific Computing Lecture on Scientific Computing Dr. Kersten Schmidt Lecture 21 Technische Universität Berlin Institut für Mathematik Wintersemester 2014/2015 Syllabus Linear Regression, Fast Fourier transform Modelling

More information

Distributed Memory Systems: Part IV

Distributed Memory Systems: Part IV Chapter 5 Distributed Memory Systems: Part IV Max Planck Institute Magdeburg Jens Saak, Scientific Computing II 293/342 The Message Passing Interface is a standard for creation of parallel programs using

More information

COSC 6374 Parallel Computation

COSC 6374 Parallel Computation COSC 6374 Parallel Computation Message Passing Interface (MPI ) II Advanced point-to-point operations Spring 2008 Overview Point-to-point taxonomy and available functions What is the status of a message?

More information

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

CS 179: GPU Programming. Lecture 14: Inter-process Communication CS 179: GPU Programming Lecture 14: Inter-process Communication The Problem What if we want to use GPUs across a distributed system? GPU cluster, CSIRO Distributed System A collection of computers Each

More information

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

MPI: Parallel Programming for Extreme Machines. Si Hammond, High Performance Systems Group MPI: Parallel Programming for Extreme Machines Si Hammond, High Performance Systems Group Quick Introduction Si Hammond, (sdh@dcs.warwick.ac.uk) WPRF/PhD Research student, High Performance Systems Group,

More information

Point-to-Point Communication. Reference:

Point-to-Point Communication. Reference: Point-to-Point Communication Reference: http://foxtrot.ncsa.uiuc.edu:8900/public/mpi/ Introduction Point-to-point communication is the fundamental communication facility provided by the MPI library. Point-to-point

More information

Intermediate MPI features

Intermediate MPI features Intermediate MPI features Advanced message passing Collective communication Topologies Group communication Forms of message passing (1) Communication modes: Standard: system decides whether message is

More information

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

CS 470 Spring Mike Lam, Professor. Distributed Programming & MPI CS 470 Spring 2019 Mike Lam, Professor Distributed Programming & MPI MPI paradigm Single program, multiple data (SPMD) One program, multiple processes (ranks) Processes communicate via messages An MPI

More information

Intermediate MPI. M. D. Jones, Ph.D. Center for Computational Research University at Buffalo State University of New York

Intermediate MPI. M. D. Jones, Ph.D. Center for Computational Research University at Buffalo State University of New York Intermediate MPI M. D. Jones, Ph.D. Center for Computational Research University at Buffalo State University of New York High Performance Computing I, 2008 M. D. Jones, Ph.D. (CCR/UB) Intermediate MPI

More information

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

Today's agenda. Parallel Programming for Multicore Machines Using OpenMP and MPI Today's agenda Homework discussion Bandwidth and latency in theory and in practice Paired and Nonblocking Pt2Pt Communications Other Point to Point routines Collective Communications: One-with-All Collective

More information

Non-Blocking Communications

Non-Blocking Communications 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

More information

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

Message Passing Programming with MPI. Message Passing Programming with MPI 1 Message Passing Programming with MPI Message Passing Programming with MPI 1 What is MPI? Message Passing Programming with MPI 2 MPI Forum First message-passing interface standard. Sixty people from forty

More information

MPI Message Passing Interface

MPI Message Passing Interface MPI Message Passing Interface Portable Parallel Programs Parallel Computing A problem is broken down into tasks, performed by separate workers or processes Processes interact by exchanging information

More information

HPC Parallel Programing Multi-node Computation with MPI - I

HPC Parallel Programing Multi-node Computation with MPI - I HPC Parallel Programing Multi-node Computation with MPI - I Parallelization and Optimization Group TATA Consultancy Services, Sahyadri Park Pune, India TCS all rights reserved April 29, 2013 Copyright

More information

Basic MPI Communications. Basic MPI Communications (cont d)

Basic MPI Communications. Basic MPI Communications (cont d) Basic MPI Communications MPI provides two non-blocking routines: MPI_Isend(buf,cnt,type,dst,tag,comm,reqHandle) buf: source of data to be sent cnt: number of data elements to be sent type: type of each

More information

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

A message contains a number of elements of some particular datatype. MPI datatypes: Messages Messages A message contains a number of elements of some particular datatype. MPI datatypes: Basic types. Derived types. Derived types can be built up from basic types. C types are different from

More information

Buffering in MPI communications

Buffering in MPI communications Buffering in MPI communications Application buffer: specified by the first parameter in MPI_Send/Recv functions System buffer: Hidden from the programmer and managed by the MPI library Is limitted and

More information

MPI MESSAGE PASSING INTERFACE

MPI MESSAGE PASSING INTERFACE MPI MESSAGE PASSING INTERFACE David COLIGNON, ULiège CÉCI - Consortium des Équipements de Calcul Intensif http://www.ceci-hpc.be Outline Introduction From serial source code to parallel execution MPI functions

More information

MPI - The Message Passing Interface

MPI - The Message Passing Interface MPI - The Message Passing Interface The Message Passing Interface (MPI) was first standardized in 1994. De facto standard for distributed memory machines. All Top500 machines (http://www.top500.org) are

More information

MPI Programming. Henrik R. Nagel Scientific Computing IT Division

MPI Programming. Henrik R. Nagel Scientific Computing IT Division 1 MPI Programming Henrik R. Nagel Scientific Computing IT Division 2 Outline Introduction Basic MPI programming Examples Finite Difference Method Finite Element Method LU Factorization Monte Carlo Method

More information

ME964 High Performance Computing for Engineering Applications

ME964 High Performance Computing for Engineering Applications ME964 High Performance Computing for Engineering Applications Parallel Computing with MPI Building/Debugging MPI Executables MPI Send/Receive Collective Communications with MPI April 10, 2012 Dan Negrut,

More information

Parallel Computing. PD Dr. rer. nat. habil. Ralf-Peter Mundani. Computation in Engineering / BGU Scientific Computing in Computer Science / INF

Parallel Computing. PD Dr. rer. nat. habil. Ralf-Peter Mundani. Computation in Engineering / BGU Scientific Computing in Computer Science / INF Parallel Computing PD Dr. rer. nat. habil. Ralf-Peter Mundani Computation in Engineering / BGU Scientific Computing in Computer Science / INF Winter Term 2018/19 Part 5: Programming Memory-Coupled Systems

More information

Working with IITJ HPC Environment

Working with IITJ HPC Environment Working with IITJ HPC Environment by Training Agenda for 23 Dec 2011 1. Understanding Directory structure of IITJ HPC 2. User vs root 3. What is bash_profile 4. How to install any source code in your user

More information

Parallel Programming using MPI. Supercomputing group CINECA

Parallel Programming using MPI. Supercomputing group CINECA Parallel Programming using MPI Supercomputing group CINECA Contents Programming with message passing Introduction to message passing and MPI Basic MPI programs MPI Communicators Send and Receive function

More information

Introduction to the Message Passing Interface (MPI)

Introduction to the Message Passing Interface (MPI) Applied Parallel Computing LLC http://parallel-computing.pro Introduction to the Message Passing Interface (MPI) Dr. Alex Ivakhnenko March 4, 2018 Dr. Alex Ivakhnenko (APC LLC) Introduction to MPI March

More information

Introduction to MPI. Ricardo Fonseca. https://sites.google.com/view/rafonseca2017/

Introduction to MPI. Ricardo Fonseca. https://sites.google.com/view/rafonseca2017/ Introduction to MPI Ricardo Fonseca https://sites.google.com/view/rafonseca2017/ Outline Distributed Memory Programming (MPI) Message Passing Model Initializing and terminating programs Point to point

More information

Message Passing with MPI

Message Passing with MPI Message Passing with MPI PPCES 2016 Hristo Iliev IT Center / JARA-HPC IT Center der RWTH Aachen University Agenda Motivation Part 1 Concepts Point-to-point communication Non-blocking operations Part 2

More information

Message Passing Interface

Message Passing Interface MPSoC Architectures MPI Alberto Bosio, Associate Professor UM Microelectronic Departement bosio@lirmm.fr Message Passing Interface API for distributed-memory programming parallel code that runs across

More information

High Performance Computing Course Notes Message Passing Programming III

High Performance Computing Course Notes Message Passing Programming III High Performance Computing Course Notes 2008-2009 2009 Message Passing Programming III Communication modes Synchronous mode The communication is considered complete when the sender receives the acknowledgement

More information

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

Lesson 1. MPI runs on distributed memory systems, shared memory systems, or hybrid systems. The goals of this lesson are: understanding the MPI programming model managing the MPI environment handling errors point-to-point communication 1. The MPI Environment Lesson 1 MPI (Message Passing Interface)

More information

Capstone Project. Project: Middleware for Cluster Computing

Capstone Project. Project: Middleware for Cluster Computing Capstone Project Project: Middleware for Cluster Computing Middleware is computer software that connects software components or applications. The software consists of a set of enabling services that allow

More information

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

Introduction to MPI. SuperComputing Applications and Innovation Department 1 / 143 Introduction to MPI Isabella Baccarelli - i.baccarelli@cineca.it Mariella Ippolito - m.ippolito@cineca.it Cristiano Padrin - c.padrin@cineca.it Vittorio Ruggiero - v.ruggiero@cineca.it SuperComputing Applications

More information

Introduction to MPI Part II Collective Communications and communicators

Introduction to MPI Part II Collective Communications and communicators Introduction to MPI Part II Collective Communications and communicators Andrew Emerson, Fabio Affinito {a.emerson,f.affinito}@cineca.it SuperComputing Applications and Innovation Department Collective

More information

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

What s in this talk? Quick Introduction. Programming in Parallel What s in this talk? Parallel programming methodologies - why MPI? Where can I use MPI? MPI in action Getting MPI to work at Warwick Examples MPI: Parallel Programming for Extreme Machines Si Hammond,

More information

Programming with MPI Collectives

Programming with MPI Collectives Programming with MPI Collectives Jan Thorbecke Type to enter text Delft University of Technology Challenge the future Collectives Classes Communication types exercise: BroadcastBarrier Gather Scatter exercise:

More information

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

More about MPI programming. More about MPI programming p. 1 More about MPI programming More about MPI programming p. 1 Some recaps (1) One way of categorizing parallel computers is by looking at the memory configuration: In shared-memory systems, the CPUs share

More information

Slides prepared by : Farzana Rahman 1

Slides prepared by : Farzana Rahman 1 Introduction to MPI 1 Background on MPI MPI - Message Passing Interface Library standard defined by a committee of vendors, implementers, and parallel programmers Used to create parallel programs based

More information

Reusing this material

Reusing this material Messages 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

More information

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

Week 3: MPI. Day 02 :: Message passing, point-to-point and collective communications Week 3: MPI Day 02 :: Message passing, point-to-point and collective communications Message passing What is MPI? A message-passing interface standard MPI-1.0: 1993 MPI-1.1: 1995 MPI-2.0: 1997 (backward-compatible

More information

COMP 322: Fundamentals of Parallel Programming. Lecture 34: Introduction to the Message Passing Interface (MPI), contd

COMP 322: Fundamentals of Parallel Programming. Lecture 34: Introduction to the Message Passing Interface (MPI), contd COMP 322: Fundamentals of Parallel Programming Lecture 34: Introduction to the Message Passing Interface (MPI), contd Vivek Sarkar, Eric Allen Department of Computer Science, Rice University Contact email:

More information

MPI MESSAGE PASSING INTERFACE

MPI MESSAGE PASSING INTERFACE MPI MESSAGE PASSING INTERFACE David COLIGNON CÉCI - Consortium des Équipements de Calcul Intensif http://hpc.montefiore.ulg.ac.be Outline Introduction From serial source code to parallel execution MPI

More information

Parallel Programming in C with MPI and OpenMP

Parallel Programming in C with MPI and OpenMP Parallel Programming in C with MPI and OpenMP Michael J. Quinn Chapter 4 Message-Passing Programming Learning Objectives n Understanding how MPI programs execute n Familiarity with fundamental MPI functions

More information

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

Parallel programming with MPI Part I -Introduction and Point-to-Point Communications Parallel programming with MPI Part I -Introduction and Point-to-Point Communications A. Emerson, A. Marani, Supercomputing Applications and Innovation (SCAI), CINECA 23 February 2016 MPI course 2016 Contents

More information

Parallel Programming with MPI: Day 1

Parallel Programming with MPI: Day 1 Parallel Programming with MPI: Day 1 Science & Technology Support High Performance Computing Ohio Supercomputer Center 1224 Kinnear Road Columbus, OH 43212-1163 1 Table of Contents Brief History of MPI

More information

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

Parallel programming with MPI Part I -Introduction and Point-to-Point Parallel programming with MPI Part I -Introduction and Point-to-Point Communications A. Emerson, Supercomputing Applications and Innovation (SCAI), CINECA 1 Contents Introduction to message passing and

More information

Introduction to parallel computing concepts and technics

Introduction to parallel computing concepts and technics Introduction to parallel computing concepts and technics Paschalis Korosoglou (support@grid.auth.gr) User and Application Support Unit Scientific Computing Center @ AUTH Overview of Parallel computing

More information

Intermediate MPI (Message-Passing Interface) 1/11

Intermediate MPI (Message-Passing Interface) 1/11 Intermediate MPI (Message-Passing Interface) 1/11 What happens when a process sends a message? Suppose process 0 wants to send a message to process 1. Three possibilities: Process 0 can stop and wait until

More information

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

MPI 5. CSCI 4850/5850 High-Performance Computing Spring 2018 MPI 5 CSCI 4850/5850 High-Performance Computing Spring 2018 Tae-Hyuk (Ted) Ahn Department of Computer Science Program of Bioinformatics and Computational Biology Saint Louis University Learning Objectives

More information

Distributed Memory Parallel Programming

Distributed Memory Parallel Programming COSC Big Data Analytics Parallel Programming using MPI Edgar Gabriel Spring 201 Distributed Memory Parallel Programming Vast majority of clusters are homogeneous Necessitated by the complexity of maintaining

More information

Intermediate MPI (Message-Passing Interface) 1/11

Intermediate MPI (Message-Passing Interface) 1/11 Intermediate MPI (Message-Passing Interface) 1/11 What happens when a process sends a message? Suppose process 0 wants to send a message to process 1. Three possibilities: Process 0 can stop and wait until

More information

Parallel Short Course. Distributed memory machines

Parallel Short Course. Distributed memory machines Parallel Short Course Message Passing Interface (MPI ) I Introduction and Point-to-point operations Spring 2007 Distributed memory machines local disks Memory Network card 1 Compute node message passing

More information

Programming Distributed Memory Machines with MPI

Programming Distributed Memory Machines with MPI Programming Distributed Memory Machines with MPI Ricardo Rocha and Fernando Silva Computer Science Department Faculty of Sciences University of Porto Parallel Computing 2015/2016 R. Rocha and F. Silva

More information

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

In the simplest sense, parallel computing is the simultaneous use of multiple computing resources to solve a problem. 1. Introduction to Parallel Processing In the simplest sense, parallel computing is the simultaneous use of multiple computing resources to solve a problem. a) Types of machines and computation. A conventional

More information

Message Passing Interface. George Bosilca

Message Passing Interface. George Bosilca Message Passing Interface George Bosilca bosilca@icl.utk.edu Message Passing Interface Standard http://www.mpi-forum.org Current version: 3.1 All parallelism is explicit: the programmer is responsible

More information

Introduction to Parallel Programming

Introduction to Parallel Programming University of Nizhni Novgorod Faculty of Computational Mathematics & Cybernetics Section 4. Part 1. Introduction to Parallel Programming Parallel Programming with MPI Gergel V.P., Professor, D.Sc., Software

More information

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

Programming Scalable Systems with MPI. Clemens Grelck, University of Amsterdam Clemens Grelck University of Amsterdam UvA / SurfSARA High Performance Computing and Big Data Course June 2014 Parallel Programming with Compiler Directives: OpenMP Message Passing Gentle Introduction

More information

Parallel Programming, MPI Lecture 2

Parallel Programming, MPI Lecture 2 Parallel Programming, MPI Lecture 2 Ehsan Nedaaee Oskoee 1 1 Department of Physics IASBS IPM Grid and HPC workshop IV, 2011 Outline 1 Introduction and Review The Von Neumann Computer Kinds of Parallel

More information

Introduction to MPI. Shaohao Chen Research Computing Services Information Services and Technology Boston University

Introduction to MPI. Shaohao Chen Research Computing Services Information Services and Technology Boston University Introduction to MPI Shaohao Chen Research Computing Services Information Services and Technology Boston University Outline Brief overview on parallel computing and MPI Using MPI on BU SCC Basic MPI programming

More information

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

MPI. What to Learn This Week? MPI Program Structure. What is MPI? This week, we will learn the basics of MPI programming. What to Learn This Week? This week, we will learn the basics of MPI programming. MPI This will give you a taste of MPI, but it is far from comprehensive discussion. Again, the focus will be on MPI communications.

More information

Message Passing with MPI Christian Iwainsky HiPerCH

Message Passing with MPI Christian Iwainsky HiPerCH Message Passing with MPI Christian Iwainsky HiPerCH 05.08.2013 FB. Computer Science Scientific Computing Christian Iwainsky 1 Agenda Recap MPI Part 1 Concepts Point-to-Point Basic Datatypes MPI Part 2

More information

CDP. MPI Derived Data Types and Collective Communication

CDP. MPI Derived Data Types and Collective Communication CDP MPI Derived Data Types and Collective Communication Why Derived Data Types? Elements in an MPI message are of the same type. Complex data, requires two separate messages. Bad example: typedef struct

More information

Part - II. Message Passing Interface. Dheeraj Bhardwaj

Part - II. Message Passing Interface. Dheeraj Bhardwaj Part - II Dheeraj Bhardwaj Department of Computer Science & Engineering Indian Institute of Technology, Delhi 110016 India http://www.cse.iitd.ac.in/~dheerajb 1 Outlines Basics of MPI How to compile and

More information

Introduzione al Message Passing Interface (MPI) Andrea Clematis IMATI CNR

Introduzione al Message Passing Interface (MPI) Andrea Clematis IMATI CNR Introduzione al Message Passing Interface (MPI) Andrea Clematis IMATI CNR clematis@ge.imati.cnr.it Ack. & riferimenti An Introduction to MPI Parallel Programming with the Message Passing InterfaceWilliam

More information