/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ /* * (C) 2017 by Argonne National Laboratory. * See COPYRIGHT in top-level directory. */ #include "mpiimpl.h" /* Algorithm: Pairwise Exchange * * This pairwise exchange algorithm takes p-1 steps. * * We calculate the pairs by using an exclusive-or algorithm: * for (i=1; ilocal_size; rank = comm_ptr->rank; MPIR_Datatype_get_extent_macro(sendtype, sendtype_extent); MPIR_Datatype_get_extent_macro(recvtype, recvtype_extent); /* Make local copy first */ mpi_errno = MPIR_Sched_copy(((char *) sendbuf + rank * sendcount * sendtype_extent), sendcount, sendtype, ((char *) recvbuf + rank * recvcount * recvtype_extent), recvcount, recvtype, s); if (mpi_errno) MPIR_ERR_POP(mpi_errno); is_pof2 = MPL_is_pof2(comm_size, NULL); /* Do the pairwise exchanges */ for (i = 1; i < comm_size; i++) { if (is_pof2 == 1) { /* use exclusive-or algorithm */ src = dst = rank ^ i; } else { src = (rank - i + comm_size) % comm_size; dst = (rank + i) % comm_size; } mpi_errno = MPIR_Sched_send(((char *) sendbuf + dst * sendcount * sendtype_extent), sendcount, sendtype, dst, comm_ptr, s); if (mpi_errno) MPIR_ERR_POP(mpi_errno); mpi_errno = MPIR_Sched_recv(((char *) recvbuf + src * recvcount * recvtype_extent), recvcount, recvtype, src, comm_ptr, s); if (mpi_errno) MPIR_ERR_POP(mpi_errno); MPIR_SCHED_BARRIER(s); } fn_exit: return mpi_errno; fn_fail: goto fn_exit; }