I'm adding together a load of array elements from each process:
double rho[1024];
//Some operation to calculate rho for each process;
MPI_Allreduce(rho,rho,1024,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);
Will having rho as both the sendbuf and recvbuf work?
Have you checked MPI_IN_PLACE
? According to MPI_AllReduce man page and MPI doc it can be used to specify the same buffer for sendbuf and recvbuf as long as you are working inside the same group.
The call would look like:
MPI_Allreduce(MPI_IN_PLACE,rho,1024,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With