|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* (C) 2017 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include "mpiimpl.h"
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Algorithm: Short Linear Gather
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* This linear gather algorithm is tuned for short messages. The remote group
|
|
Packit Service |
c5cf8c |
* does a local intracommunicator gather to rank 0. Rank 0 then sends data to
|
|
Packit Service |
c5cf8c |
* root.
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* Cost: (lgp+1).alpha + n.((p-1)/p).beta + n.beta
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
#undef FUNCNAME
|
|
Packit Service |
c5cf8c |
#define FUNCNAME MPIR_Igather_sched_inter_short
|
|
Packit Service |
c5cf8c |
#undef FCNAME
|
|
Packit Service |
c5cf8c |
#define FCNAME MPL_QUOTE(FUNCNAME)
|
|
Packit Service |
c5cf8c |
int MPIR_Igather_sched_inter_short(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
|
|
Packit Service |
c5cf8c |
void *recvbuf, int recvcount, MPI_Datatype recvtype, int root,
|
|
Packit Service |
c5cf8c |
MPIR_Comm * comm_ptr, MPIR_Sched_t s)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int mpi_errno = MPI_SUCCESS;
|
|
Packit Service |
c5cf8c |
int rank;
|
|
Packit Service |
c5cf8c |
MPI_Aint local_size, remote_size;
|
|
Packit Service |
c5cf8c |
MPI_Aint extent, true_extent, true_lb = 0;
|
|
Packit Service |
c5cf8c |
void *tmp_buf = NULL;
|
|
Packit Service |
c5cf8c |
MPIR_Comm *newcomm_ptr = NULL;
|
|
Packit Service |
c5cf8c |
MPIR_SCHED_CHKPMEM_DECL(1);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
remote_size = comm_ptr->remote_size;
|
|
Packit Service |
c5cf8c |
local_size = comm_ptr->local_size;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (root == MPI_ROOT) {
|
|
Packit Service |
c5cf8c |
/* root receives data from rank 0 on remote group */
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_Sched_recv(recvbuf, recvcount * remote_size, recvtype, 0, comm_ptr, s);
|
|
Packit Service |
c5cf8c |
if (mpi_errno)
|
|
Packit Service |
c5cf8c |
MPIR_ERR_POP(mpi_errno);
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
/* remote group. Rank 0 allocates temporary buffer, does
|
|
Packit Service |
c5cf8c |
* local intracommunicator gather, and then sends the data
|
|
Packit Service |
c5cf8c |
* to root. */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
rank = comm_ptr->rank;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
MPIR_Type_get_true_extent_impl(sendtype, &true_lb, &true_extent);
|
|
Packit Service |
c5cf8c |
MPIR_Datatype_get_extent_macro(sendtype, extent);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_Ensure_Aint_fits_in_pointer(sendcount * local_size *
|
|
Packit Service |
c5cf8c |
(MPL_MAX(extent, true_extent)));
|
|
Packit Service |
c5cf8c |
MPIR_SCHED_CHKPMEM_MALLOC(tmp_buf, void *,
|
|
Packit Service |
c5cf8c |
sendcount * local_size * (MPL_MAX(extent, true_extent)),
|
|
Packit Service |
c5cf8c |
mpi_errno, "tmp_buf", MPL_MEM_BUFFER);
|
|
Packit Service |
c5cf8c |
/* adjust for potential negative lower bound in datatype */
|
|
Packit Service |
c5cf8c |
tmp_buf = (void *) ((char *) tmp_buf - true_lb);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* all processes in remote group form new intracommunicator */
|
|
Packit Service |
c5cf8c |
if (!comm_ptr->local_comm) {
|
|
Packit Service |
c5cf8c |
mpi_errno = MPII_Setup_intercomm_localcomm(comm_ptr);
|
|
Packit Service |
c5cf8c |
if (mpi_errno)
|
|
Packit Service |
c5cf8c |
MPIR_ERR_POP(mpi_errno);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
newcomm_ptr = comm_ptr->local_comm;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* now do the a local gather on this intracommunicator */
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_Igather_sched(sendbuf, sendcount, sendtype,
|
|
Packit Service |
c5cf8c |
tmp_buf, sendcount, sendtype, 0, newcomm_ptr, s);
|
|
Packit Service |
c5cf8c |
if (mpi_errno)
|
|
Packit Service |
c5cf8c |
MPIR_ERR_POP(mpi_errno);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
mpi_errno =
|
|
Packit Service |
c5cf8c |
MPIR_Sched_send(tmp_buf, sendcount * local_size, sendtype, root, comm_ptr, s);
|
|
Packit Service |
c5cf8c |
if (mpi_errno)
|
|
Packit Service |
c5cf8c |
MPIR_ERR_POP(mpi_errno);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_SCHED_CHKPMEM_COMMIT(s);
|
|
Packit Service |
c5cf8c |
fn_exit:
|
|
Packit Service |
c5cf8c |
return mpi_errno;
|
|
Packit Service |
c5cf8c |
fn_fail:
|
|
Packit Service |
c5cf8c |
MPIR_SCHED_CHKPMEM_REAP(s);
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
}
|