MPI_Recv(buff, count, datatype, source, tag, comm, request); |
MPI_Recv(buff, count, type, MPI_ANY_SOURCE, MPI_ANY_TAG, status); |
status.SOURCE = source id of sender status.TAG = tag of message |
|
Part 1 discuss how to handle unknown format
This is a "cop out" solution...
|
Example:
// Message header int NDataField - number of data field field 1(name, type, length) - name, type and length of field 1 field 2(name, type, length) - name, type and length of field 2 ... field n(name, type, length) - name, type and length of field n // Content of message value of field 1 value of field 2 ... value of field n |
|
|
MPI_Status status; int nbytes; MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status); // It will block the caller until a message is ready // Obtain message size... MPI_Get_count(&status, MPI_CHAR, &nbytes); // Allocate memory to receive data if ( nbytes != MPI_UNDEFINED ) buff = malloc( nbytes ); // Finally, receive the message with a correctly sized buffer... MPI_Recv(buff, nbytes, MPI_CHAR, status.SOURCE, status.TAG, MPI_COMM_WORLD, &status); |
Demo instruction: