I am trying to probe for messages in order to communicate between MPI processes (8 processes). The first process to reach a certain part of the code will signal all the other processes, and the others will terminate upon reaching there.
Here is what I've implemented: (any simpler solutions are welcome)
if(depth == size){
endTime = MPI_Wtime();
MPI_Iprobe(MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &stat, MPI_STATUS_IGNORE);
if(!stat){
printf("Execution completed in %.5f seconds.\n", endTime - beginTime);
for (ctr = 0; ctr < mpi_processors; ctr++) {
if(ctr == mpi_my_pid) continue;
MPI_Isend(&stat, 1, MPI_INT, ctr, 0, MPI_COMM_WORLD, &req);
printf("sent to %d from %d\n",ctr,mpi_my_pid);
}
}
return 1;
}
The code is self-explanatory. stat
is a dummy variable just for "send"ing a message, and also used as the flag for the Iprobe
. The problem is, stat is always zero in all processes, meaning that probing doesn't return any waiting messages to be received. But I can confirm that MPI_Isend runs correctly and sends the message.
Am I doing something fundamentally wrong, or is there a simple bug somewhere that I can't see?
Thanks,
Can.