Receive data from any source and then print that data and the source
I am creating a program in C, and I need assistance identifying the source for an MPI program when I receive the data from any source. Essentially, the lines of code are below:
int i; // Declares the variable to store the received int in.
if(WORLD_RANK == 0) {
MPI_Recv(&i, 1, MPI_INT, MPI_ANY_SOURCE, 0, MPI_COMM_开发者_C百科WORLD, MPI_STATUS_IGNORE);
printf("Received %d from %d\n", i, SOURCE_WORLD_RANK)
} else { MPI_Send()}// complete some work here and then send data back
SOURCE_WORLD_RANK needs to be the source of the data I received, the value saved in I.
精彩评论