I am writing code that involved a for loop that makes calculations at each index.
The smallest of these calculations is stored in a variable and I use MPI_Allreduce at the end of the program to determine the global minimum across all processes.
However, I need a way of knowing which process has the smallest value, i.e. can MPI_Allreduce tell me which process sends the result? the process with the smallest value? there is some additional data I need to get from that process.
Thanks in advance for any help!
You can use the
MPI_MINLOCoperator in the reduce operation to receive the rank of the process with the minimal value (more specifically, the lowest ranked process that has a minimal value).See http://www.netlib.org/utk/papers/mpi-book/node114.html#SECTION005103000000000000000