Commit 01115f36 authored by Rajeev Thakur's avatar Rajeev Thakur
Browse files

[svn-r3242] added SMP-aware Allreduce

parent 162c71ac
...@@ -680,10 +680,54 @@ int MPI_Allreduce ( void *sendbuf, void *recvbuf, int count, ...@@ -680,10 +680,54 @@ int MPI_Allreduce ( void *sendbuf, void *recvbuf, int count,
} }
else else
{ {
if (comm_ptr->comm_kind == MPID_INTRACOMM) if (comm_ptr->comm_kind == MPID_INTRACOMM) {
/* intracommunicator */ /* intracommunicator */
#if USE_SMP_COLLECTIVES
if (MPIR_Comm_is_node_aware(comm_ptr)) {
/* on each node, do a reduce to the local root */
if (comm_ptr->node_comm != NULL)
{
/* take care of the MPI_IN_PLACE case. For reduce,
MPI_IN_PLACE is specified only on the root;
for allreduce it is specified on all processes. */
if ((sendbuf == MPI_IN_PLACE) && (comm_ptr->node_comm->rank != 0)) {
/* IN_PLACE and not root of reduce. Data supplied to this
allreduce is in recvbuf. Pass that as the sendbuf to reduce. */
mpi_errno = MPIR_Reduce(recvbuf, NULL, count, datatype,
op, 0, comm_ptr->node_comm);
}
else
mpi_errno = MPIR_Reduce(sendbuf, recvbuf, count, datatype,
op, 0, comm_ptr->node_comm);
if (mpi_errno) goto fn_fail;
}
/* now do an IN_PLACE allreduce among the local roots of all nodes */
if (comm_ptr->node_roots_comm != NULL) {
mpi_errno = MPIR_Allreduce(MPI_IN_PLACE, recvbuf, count, datatype,
op, comm_ptr->node_roots_comm);
if (mpi_errno) goto fn_fail;
}
/* now broadcast the result among local processes */
if (comm_ptr->node_comm != NULL)
{
mpi_errno = MPIR_Bcast(recvbuf, count, datatype, 0, comm_ptr->node_comm);
if (mpi_errno) goto fn_fail;
}
}
else {
mpi_errno = MPIR_Allreduce(sendbuf, recvbuf, count, datatype,
op, comm_ptr);
}
#else
mpi_errno = MPIR_Allreduce(sendbuf, recvbuf, count, datatype, mpi_errno = MPIR_Allreduce(sendbuf, recvbuf, count, datatype,
op, comm_ptr); op, comm_ptr);
#endif
}
else { else {
/* intercommunicator */ /* intercommunicator */
mpi_errno = MPIR_Allreduce_inter(sendbuf, recvbuf, count, mpi_errno = MPIR_Allreduce_inter(sendbuf, recvbuf, count,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment