Download presentation
Presentation is loading. Please wait.
Published bySteven Lester Modified over 8 years ago
1
CS 420 – Design of Algorithms MPI Data Types Basic Message Passing - sends/receives
2
MPI Data Types MPI has a set of its own data type definitions Most MPI types correspond to C types – although some are unique to MPI C types may vary by implementation MPI types are consistent across implementations Supports portability in parallel applications
3
MPI types and C types MPI typesC types MPI_CHARsigned char MPI_SHORTsigned short int MPI_INTsigned int MPI_LONGsigned long int MPI_UNSIGNED_CHARunsigned char MPI_UNSIGNED_SHORTunsigned short int
4
MPI types and C types MPI typesC types MPI_UNSIGNEDunsigned int MPI_UNSIGNED_LONGunsigned long int MPI_FLOATfloat MPI_DOUBLEdouble MPI_LONG_DOUBLElong double
5
Other MPI Data Types MPI_BYTE MPI_PACKED May be others depending on the implementation
6
MPI send and receive MPI_Send and MPI_Recv are the most elemental forms of MPI data communications Provide the core set of functions MPI_Send and MPI_Recv are blocking communications Processing cannot proceed until the communication process is complete.
7
MPI_Send – send a message MPI_Send( void*message, intcount, MPI_Datatype datatype, intdest, inttag, MPI_Commcomm)
8
MPI_Send MPI_Send(a,1,MPI_FLOAT,myrank+1,11,MPI_COM M_WORLD) sends a single float to the next process in MPI_COMM_WORLD and attaches a tag of 11. MPI_Send(vect,100, MPI_FLOAT,5,12, MPI_COMM_WORLD); sends a vector of 100 floats to process 5 in MPI_COMM_WORLD and uses a tag of 12.
9
MPI_Recv int MPI_Recv( void* message, intcount, MPI_Datatypedatatype, intsource, inttag, MPI_Commcomm, MPI_Status*status)
10
MPI_Recv MPI_Recv(x, 1, MPI_FLOAT, lsource, 11, MPI_COMM_WORLD, status); picks up a message with a tag=11,from the source lsource in MPI_COMM_WORLD. The status of the transaction is stored in status. MPI_Recv(xarray, 100, MPI_FLOAT, xproc, 12, MPI_COMM_WORLD, status); picks up a message tagged 12 from the source xproc in MPI_COMM_WORLD. That status of the transaction is stored in status.
11
MPI_Recv - wildcards MPI_ANY_SOURCE lets MPI_Recv take a message from any source. Use as the source parameter MPI_ANY_TAG lets MPI_Recv take a message regardless of its tag.
12
Wildcards No wildcards for MPI_Send No wildcards for communicator Send must specify a tag Recv must specify a matching tag or use a wildcard
13
MPI_ANY_SOURCE To receive from any process MPI_Recv(x, 1, MPI_FLOAT, MPI_ANY_SOURCE, 11, MPI_COMM_WORLD, status); … and if you don’t care what the tag is- MPI_Recv(x, 1, MPI_FLOAT, lsource, MPI_ANY_TAG, MPI_COMM_WORLD,status);
14
MPI_Status Return variable for the results of the communication process. A structure Roughly struct MPI_STATUS { MPI_SOURCE source; MPI_TAG tag; MPI_ERROR errormsg; }
15
MPI_Status Note: no byte count in status variable (how many bytes received in the message) MPI_Get_count( MPI_Status* status, MPI_Datatype datatype, int* count_ptr);
16
MPI Basic Core Functions MPI_Init MPI_Comm_rank MPI_Comm_size MPI_Send MPI_Recv MPI_Finalize
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.