86
86
86
main() {... } main() { main() { main() {......... } } } 86
main() { main() { main() {......... } } } main() { if(rank==)... } main() { if(rank==)... } main() { if(rank==x)... } 86
P(N) P(N) / P(M) * ( M / N ) 86
.8.7.5.6 Execution Time.4..8.6.4. Number of Ranks 86
.8.6.7.5 4.7.5 Execution Time.4..8.6.4. Number of Ranks Execution Speed 8 6 4 Number of Ranks 86
86
86
86
main() { if(rank==)... } main() { if(rank==)... } main() { if(rank==n-)... } main() { if(rank==)... } main() { if(rank==)... } main() { if(rank==4)... } main() { if(rank==7)... } main() { if(rank==8)... } main() { if(rank==9)... } 86
86
double A[]; double A[]; double A[]; 86
86
86
C:! int MPI_Init( int **argc, char **argv )!! int MPI_Finalize( void ) F:!! MPI_INIT( ierr )!! MPI_FINALIZE( ierr ) 86
C:!! int MPI_Comm_rank( MPI_COMM_WORLD, int *rank )!! int MPI_Comm_size( MPI_COMM_WORLD, int *size ) F:!! MPI_COMM_RANK( MPI_COMM_WORLD, rank, ierr )!! MPI_COMM_SIZE( MPI_COMM_WORLD, size, ierr ) 86
86
86
86
86
C:! MPI_Send( void *data, int count, MPI_Datatype type,!!! int dest, int tag, MPI_COMM_WORLD ) F:! MPI_SEND( data, count, type, dest, tag, MPI_COMM_WORLD,!!! ierr )!! 86
C:!! MPI_Recv( void *data, int count, MPI_Datatype type,!!! int src, int tag, MPI_COMM_WORLD, MPI_Status status ) F:!! MPI_RECV( data, count, type, src, tag, MPI_COMM_WORLD,!!! status, ierr )!! 86
The send bu er specified by the MPI_SEND operation consists of count succ the type indicated by datatype, starting with the entry at address buf. Note the message length in terms of number of elements, not number of bytes. machine independent and closer to the application level. The data part of the message consists of a sequence of count values, e indicated by datatype. count may be zero, in which case the data part of empty. The basic datatypes that can be specified for message data values co POINT-TO-POINT COMMUNICATION basic datatypes of the host language. Possible values of this argument for F C datatype corresponding Fortran types are listed in Table.. char MPIにおけるデータ型 8 C言語のデータ型との対応 CHAPTER. MPI datatype MPI_CHAR 4 5 6 7 8 9 MPI_SHORT MPI_INT MPI_LONG MPI_LONG_LONG_INT MPI_LONG_LONG (as a synonym) MPI_SIGNED_CHAR MPI_UNSIGNED_CHAR 4 5 6 7 8 9 MPI_UNSIGNED_SHORT MPI_UNSIGNED MPI_UNSIGNED_LONG MPI_UNSIGNED_LONG_LONG MPI_FLOAT MPI_DOUBLE MPI_LONG_DOUBLE MPI_WCHAR 4 5 6 7 8 9 4 MPI_C_BOOL MPI_INT8_T MPI_INT6_T MPI_INT_T MPI_INT64_T MPI_UINT8_T MPI_UINT6_T MPI_UINT_T MPI_UINT64_T MPI_C_COMPLEX MPI_C_FLOAT_COMPLEX (as a synonym) MPI_C_DOUBLE_COMPLEX MPI_C_LONG_DOUBLE_COMPLEX MPI_BYTE MPI_PACKED FORTRAN言語のデータ 型との対応 (treated as printable character) signed short int MPI datatype Fortran datatype signed int signed long int MPI_INTEGER INTEGER signed long long int MPI_REAL REAL signed long long int signed char MPI_DOUBLE_PRECISION DOUBLE PRECISION (treated as integral value) unsigned char MPI_COMPLEX COMPLEX (treated as integral value) MPI_LOGICAL LOGICAL unsigned short int unsigned int MPI_CHARACTER CHARACTER() unsigned long int MPI_BYTE unsigned long long int float MPI_PACKED double long double wchar_t (defined in <stddef.h>) Table.: Predefined MPI datatypes corresponding to Fortran dat (treated as printable character) _Bool int8_t Possible values for this argument for C and the corresponding C typ int6_t int_t Table.... BLOCKING SEND AND RECEIVE OPERATIONS int64_t The datatypes MPI_BYTE and MPI_PACKED do not correspond to uint8_t uint6_t datatype C datatype consists Fortran datatype datatype. A value MPI of type MPI_BYTE of a byte (8 binary digi uint_t MPI_Aint INTEGER (KIND=MPI_ADDRESS_KIND) uninterpreted and ismpi_aint di erent from a character. Di erent machines may uint64_t MPI_OFFSET MPI_Offset INTEGER (KIND=MPI_OFFSET_KIND) float _Complex representations for characters, or may use more than one byte to represent float _Complex byte has the binary value on all Cmachines. The double _Complexthe other hand, Tablea.: Predefined MPIsame datatypes corresponding to both and Fortran datatype long double _Complex C言語とFORTRAN言語 両方に対応するデータ型 MPI_PACKED is explained in Section 4.. Thesupport datatypes of MPI_AINT MPI_OFFSET correspond to the C ty MPI requires these and datatypes, which match thempi-defined basic datat MPI_Aint and MPI_O set and their Fortran equivalents INTEGER (KIND= and ISO C. Additional MPI datatypes should be provided if the host languag MPI_ADDRESS_KIND) and INTEGER (KIND=MPI_OFFSET_KIND). This is described in Table.: Predefined MPI datatypes corresponding to C datatypes types: ble MPI_DOUBLE_COMPLEX for double precisioncommunication complex in Fortth RIKEN AICS HPC Summer Schooldata 5.. See Section 6.. for information on interlanguage with types. be of type DOUBLE COMPLEX; MPI_REAL, MPI_REAL4 and MPI_REAL8 fo 年8月6日火曜日 Rationale. The datatypes MPI_C_BOOL, MPI_INT8_T, MPI_INT6_T, 5 6 7 8 9 4 4 4
86
86
86
86
86
MPI_Send Sender CTS RTS Message Receiver MPI_Recv Rendezvous Protocol Sender MPI_Send Message Receiver MPI_Recv Eager Protocol 86
int rank; char data[len] MPI_Status status; if( rank == ) { MPI_Send( data, LEN, MPI_CHAR,, TAG, MPI_COMM_WORLD ); MPI_Recv( data, LEN, MPI_CHAR,, TAG, MPI_COMM_WORLD, &status ); } else if( rank == ) { MPI_Send( data, LEN, MPI_CHAR,, TAG, MPI_COMM_WORLD ); MPI_Recv( data, LEN, MPI_CHAR,, TAG, MPI_COMM_WORLD, &status ); } 86
B Rendezvous J Eager Intel Nehalem (.67 GHz) Infiniband QDR MVAPICH Bandwidth [MB/s] 86 BJ BJ BJ BJ BJ BJ BJ B J B J BJ BJ B J J Message Size [Byte]
C:! MPI_Isend( void *data, int count, MPI_Datatype type,!!! int dst, int tag, MPI_COMM_WORLD, MPI_Request *req)! MPI_Irecv( void *data, int count, MPI_Datatype type,!!! int src, int tag, MPI_COMM_WORLD, MPI_Request *req )! MPI_Wait( MPI_Request *req, MPI_Status *status ) F:! MPI_ISEND( data, count, type, dst, tag, MPI_COMM_WORLD,!!! req, ierr )!! MPI_IRECV( data, count, type, src, tag, MPI_COMM_WORLD,!!! req, ierr )! MPI_WAIT( req, status, ierr ) 86
MPI_Isend MPI_Wait Sender CTS RTS Message Receiver MPI_Irecv MPI_Wait 86
int rank; char data[len]; MPI_Status status; MPI_Request request; if(! rank == ) { MPI_Irecv( data, LEN, MPI_CHAR,, TAG, MPI_COMM_WORLD, &request ); MPI_Send( data, LEN, MPI_CHAR,, TAG, MPI_COMM_WORLD ); } else if( rank == ) { MPI_Irecv( data, LEN, MPI_CHAR,, TAG, MPI_COMM_WORLD, &request ); MPI_Send( data, LEN, MPI_CHAR,, TAG, MPI_COMM_WORLD ); } MPI_Wait( &request, &status ); 86
int rank; char data[len] data[len]; MPI_Status status; if( rank == ) { MPI_Sendrecv(!data, LEN, MPI_CHAR,, TAG,! %!!!! data, LEN, MPI_CHAR,, TAG,! %!!!! MPI_COMM_WORLD, &status ); } else if( rank == ) { MPI_Sendrecv(!data, LEN, MPI_CHAR,, TAG,! % }!!!! data, LEN, MPI_CHAR,, TAG,! %!!!! MPI_COMM_WORLD, &status ); 86
86
86
86
86
86
C: MPI_Bcast( void *data, int count, MPI_Datatype type,!!!!!! int root, MPI_COMM_WORLD ) F:! MPI_BCAST( data, count, type, root, MPI_COMM_WORLD, ierr ) 4 5 6 7 8 9 root= 4 5 6 7 8 9 4 5 6 7 8 9 4 5 6 7 8 9 4 5 6 7 8 9 4 count = 86
C:!MPI_Gather( void *sdat, int scount, MPI_Datatype stype,!!!!!! void *rdat, int rcount, MPI_Datatype rtype,!!!!!! int root, MPI_COMM_WORLD ) F:! MPI_GATHER( sdat, scount, stype, rdat, rcount, rtype,!!!!!! root, MPI_COMM_WORLD, ierr ) root= scount = rcount = 86
C:!MPI_Scatter( void *sdat, int scount, MPI_Datatype stype,!!!!!! void *rdat, int rcount, MPI_Datatype rtype,!!!!!! int root, MPI_COMM_WORLD ) F:! MPI_SCATTER( sdat, scount, stype, rdat, rcount, rtype,!!!!!! root, MPI_COMM_WORLD, ierr ) 4 5 6 7 8 root= 4 5 6 7 8 scount = rcount = 86
C:!MPI_Reduce( void *sdat, void *rdat, int count,!!!!!! MPI_Datatype type, MPI_Op op, int root,!!!!!! MPI_COMM_WORLD ) F:! MPI_REDUCE( sdat, rdat, count, type, op, root,!!!!!! MPI_COMM_WORLD, ierr ) count = 8, op = MPI_SUM root= 4 8 6 4 4 4 4 5 5 5 5 4 6 6 6 6 8 7 7 7 7 8 8 8 8 86
MPI_MAX MPI_MIN MPI_SUM MPI_PROD MPI_LAND MPI_BAND MPI_LOR MPI_BOR MPI_LXOR MPI_BXOR MPI_MAXLOC MPI_MINLOC maximum minimum sum product logical and bit-wise and logical or bit-wise or logical exclusive or (xor) bit-wise exclusive or (xor) max value and location min value and location 86
C:!MPI_Allgather( void *sdat, int scount, MPI_Datatype stype,!!!!!! void *rdat, int rcount, MPI_Datatype rtype,!!!!!! MPI_COMM_WORLD ) F:! MPI_ALLGATHER( sdat, scount, stype, rdat, rcount, rtype,!!!!!! MPI_COMM_WORLD, ierr ) scount = rcount = 86
C:!MPI_Gather( void *sdat, int scount, MPI_Datatype stype,!!!!!! void *rdat, int rcount, MPI_Datatype rtype,!!!!!! int root, MPI_COMM_WORLD ) F:! MPI_GATHER( sdat, scount, stype, rdat, rcount, rtype,!!!!!! root, MPI_COMM_WORLD, ierr ) root= scount = rcount = 86
C:!MPI_Allreduce( void *sdat, void *rdat, int count,!!!!!!! MPI_Datatype type, MPI_Op op,!!!!!!! MPI_COMM_WORLD ) F:! MPI_ALLREDUCE( sdat, rdat, count, type, op,!!!!!!! MPI_COMM_WORLD, ierr ) count = 8, op = MPI_PROD 6 6 6 6 8 8 8 8 4 56 4 56 4 56 4 56 5 65 5 65 5 65 5 65 6 96 6 96 6 96 6 96 7 7 7 7 86
C:!MPI_Reduce( void *sdat, void *rdat, int count,!!!!!! MPI_Datatype type, MPI_Op op, int root,!!!!!! MPI_COMM_WORLD ) F:! MPI_REDUCE( sdat, rdat, count, type, op, root,!!!!!! MPI_COMM_WORLD, ierr ) count = 8, op = MPI_SUM root= 4 8 6 4 4 4 4 5 5 5 5 4 6 6 6 6 8 7 7 7 7 8 8 8 8 86
for( root=; root<n-; root++ ) MPI_Gather(..., root,... ); for( root=; root<n-; root++ ) MPI_Reduce(..., root,... ); 86
C: MPI_Alltoall( void *sdat, int scount, MPI_Datatype stype,!!!!! void *rdat, int rcount, MPI_Datatype rtype,!!!!! MPI_COMM_WORLD ) F:! MPI_ALLTOALL( sdat, scount, stype, rdat, rcount, rtype,!!!!! MPI_COMM_WORLD, ierr ) scount = rcount = 8 9 6 7 4 5 4 5 6 7 8 9 8 9 6 7 4 5 4 5 6 7 8 9 8 9 6 7 4 5 4 5 6 7 8 9 86
C: MPI_Alltoall( void *sdat, int scount, MPI_Datatype stype,!!!!! void *rdat, int rcount, MPI_Datatype rtype,!!!!! MPI_COMM_WORLD ) F:! MPI_ALLTOALL( sdat, scount, stype, rdat, rcount, rtype,!!!!! MPI_COMM_WORLD, ierr ) scount = rcount = 8 9 rank 6 7 4 5 4 5 6 7 8 9 rank 8 9 6 7 4 5 4 5 6 7 8 9 rank 8 9 6 7 4 5 4 5 6 7 rank 8 9 86
C:!MPI_Barrier( MPI_COMM_WORLD ) F:!MPI_BARRIER( MPI_COMM_WORLD, ierr ) 86
86
C:!MPI_Comm_dup( MPI_Comm comm, MPI_Comm *new )! MPI_Comm_free( MPI_Comm *comm ) F:!MPI_COMM_DUP( comm, new, ierr)! MPI_COMM_FREE( comm, ierr ) 86
C:!MPI_Comm_split( MPI_Comm comm, int color, int key,!!!!!!!! MPI_Comm *new ) F:!MPI_COMM_SPLIT( COMM, color, key, new, ierr ) 86
86
86
86
86
86