2004-01-12 00:26:55 +03:00
|
|
|
/*
|
2004-11-22 04:38:40 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
|
|
* All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-01-12 00:26:55 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "ompi_config.h"
|
2004-02-15 00:26:30 +03:00
|
|
|
#include "coll_basic.h"
|
2004-01-12 00:26:55 +03:00
|
|
|
|
|
|
|
#include "mpi.h"
|
2004-06-29 04:02:25 +04:00
|
|
|
#include "include/constants.h"
|
2004-03-17 21:45:16 +03:00
|
|
|
#include "datatype/datatype.h"
|
2004-06-29 04:02:25 +04:00
|
|
|
#include "communicator/communicator.h"
|
2004-03-17 21:45:16 +03:00
|
|
|
#include "mca/coll/coll.h"
|
|
|
|
#include "mca/coll/base/coll_tags.h"
|
2004-01-12 00:26:55 +03:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
2004-06-29 04:02:25 +04:00
|
|
|
* alltoallw_intra
|
2004-01-12 00:26:55 +03:00
|
|
|
*
|
2004-06-07 19:33:53 +04:00
|
|
|
* Function: - MPI_Alltoallw for non-ompid RPIs
|
2004-01-12 00:26:55 +03:00
|
|
|
* Accepts: - same as MPI_Alltoallw()
|
|
|
|
* Returns: - MPI_SUCCESS or an MPI error code
|
|
|
|
*/
|
2004-06-29 04:02:25 +04:00
|
|
|
int mca_coll_basic_alltoallw_intra(void *sbuf, int *scounts, int *sdisps,
|
|
|
|
struct ompi_datatype_t **sdtypes,
|
|
|
|
void *rbuf, int *rcounts, int *rdisps,
|
|
|
|
struct ompi_datatype_t **rdtypes,
|
|
|
|
struct ompi_communicator_t *comm)
|
2004-01-12 00:26:55 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int size;
|
|
|
|
int rank;
|
|
|
|
int err;
|
|
|
|
char *psnd;
|
|
|
|
char *prcv;
|
2004-06-29 04:02:25 +04:00
|
|
|
size_t nreqs;
|
2004-01-12 00:26:55 +03:00
|
|
|
MPI_Request *preq;
|
|
|
|
|
|
|
|
/* Initialize. */
|
|
|
|
|
2004-06-29 04:02:25 +04:00
|
|
|
size = ompi_comm_size(comm);
|
|
|
|
rank = ompi_comm_rank(comm);
|
2004-01-12 00:26:55 +03:00
|
|
|
|
|
|
|
/* simple optimization */
|
|
|
|
|
|
|
|
psnd = ((char *) sbuf) + sdisps[rank];
|
|
|
|
prcv = ((char *) rbuf) + rdisps[rank];
|
2004-06-29 04:02:25 +04:00
|
|
|
|
2004-10-04 22:03:52 +04:00
|
|
|
if (0 != scounts[rank]) {
|
|
|
|
err = ompi_ddt_sndrcv(psnd, scounts[rank], sdtypes[rank],
|
|
|
|
prcv, rcounts[rank], rdtypes[rank],
|
|
|
|
MCA_COLL_BASE_TAG_ALLTOALLW, comm);
|
|
|
|
if (MPI_SUCCESS != err) {
|
|
|
|
return err;
|
|
|
|
}
|
2004-01-12 00:26:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If only one process, we're done. */
|
|
|
|
|
|
|
|
if (1 == size) {
|
|
|
|
return MPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initiate all send/recv to/from others. */
|
|
|
|
|
2004-10-04 22:03:52 +04:00
|
|
|
nreqs = 0;
|
2004-06-29 04:02:25 +04:00
|
|
|
preq = comm->c_coll_basic_data->mccb_reqs;
|
|
|
|
|
|
|
|
/* Post all receives first -- a simple optimization */
|
|
|
|
|
2004-01-12 00:26:55 +03:00
|
|
|
for (i = 0; i < size; ++i) {
|
2004-10-04 22:03:52 +04:00
|
|
|
if (i == rank || 0 == rcounts[i])
|
2004-01-12 00:26:55 +03:00
|
|
|
continue;
|
|
|
|
|
|
|
|
prcv = ((char *) rbuf) + rdisps[i];
|
2004-06-29 04:02:25 +04:00
|
|
|
err = mca_pml.pml_irecv_init(prcv, rcounts[i], rdtypes[i],
|
|
|
|
i, MCA_COLL_BASE_TAG_ALLTOALLW, comm, preq++);
|
2004-10-04 22:03:52 +04:00
|
|
|
++nreqs;
|
2004-01-12 00:26:55 +03:00
|
|
|
if (MPI_SUCCESS != err) {
|
2004-06-29 04:02:25 +04:00
|
|
|
mca_coll_basic_free_reqs(comm->c_coll_basic_data->mccb_reqs, nreqs);
|
2004-01-12 00:26:55 +03:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-29 04:02:25 +04:00
|
|
|
/* Now post all sends */
|
|
|
|
|
2004-01-12 00:26:55 +03:00
|
|
|
for (i = 0; i < size; ++i) {
|
2004-10-04 23:06:45 +04:00
|
|
|
if (i == rank || 0 == scounts[i])
|
2004-01-12 00:26:55 +03:00
|
|
|
continue;
|
|
|
|
|
|
|
|
psnd = ((char *) sbuf) + sdisps[i];
|
2004-06-29 04:02:25 +04:00
|
|
|
err = mca_pml.pml_isend_init(psnd, scounts[i], sdtypes[i],
|
|
|
|
i, MCA_COLL_BASE_TAG_ALLTOALLW,
|
|
|
|
MCA_PML_BASE_SEND_STANDARD, comm, preq++);
|
2004-10-04 22:03:52 +04:00
|
|
|
++nreqs;
|
2004-01-12 00:26:55 +03:00
|
|
|
if (MPI_SUCCESS != err) {
|
2004-06-29 04:02:25 +04:00
|
|
|
mca_coll_basic_free_reqs(comm->c_coll_basic_data->mccb_reqs, nreqs);
|
2004-01-12 00:26:55 +03:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-29 04:02:25 +04:00
|
|
|
/* Start your engines. This will never return an error. */
|
2004-01-12 00:26:55 +03:00
|
|
|
|
2004-06-29 04:02:25 +04:00
|
|
|
mca_pml.pml_start(nreqs, comm->c_coll_basic_data->mccb_reqs);
|
2004-01-12 00:26:55 +03:00
|
|
|
|
2004-06-29 04:02:25 +04:00
|
|
|
/* Wait for them all. If there's an error, note that we don't care
|
|
|
|
what the error was -- just that there *was* an error. The PML
|
|
|
|
will finish all requests, even if one or more of them fail.
|
|
|
|
i.e., by the end of this call, all the requests are free-able.
|
|
|
|
So free them anyway -- even if there was an error, and return the
|
|
|
|
error after we free everything. */
|
2004-01-12 00:26:55 +03:00
|
|
|
|
2004-10-12 19:50:01 +04:00
|
|
|
err = ompi_request_wait_all(nreqs, comm->c_coll_basic_data->mccb_reqs,
|
2004-06-29 04:02:25 +04:00
|
|
|
MPI_STATUSES_IGNORE);
|
2004-01-12 00:26:55 +03:00
|
|
|
|
|
|
|
/* Free the requests. */
|
|
|
|
|
2004-06-29 04:02:25 +04:00
|
|
|
mca_coll_basic_free_reqs(comm->c_coll_basic_data->mccb_reqs, nreqs);
|
2004-01-12 00:26:55 +03:00
|
|
|
|
|
|
|
/* All done */
|
|
|
|
|
|
|
|
return MPI_SUCCESS;
|
2004-06-29 04:02:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* alltoallw_inter
|
|
|
|
*
|
|
|
|
* Function: - MPI_Alltoallw for non-lamd RPIs
|
|
|
|
* Accepts: - same as MPI_Alltoallw()
|
|
|
|
* Returns: - MPI_SUCCESS or an MPI error code
|
|
|
|
*/
|
|
|
|
int mca_coll_basic_alltoallw_inter(void *sbuf, int *scounts, int *sdisps,
|
|
|
|
struct ompi_datatype_t **sdtypes,
|
|
|
|
void *rbuf, int *rcounts, int *rdisps,
|
|
|
|
struct ompi_datatype_t **rdtypes,
|
|
|
|
struct ompi_communicator_t *comm)
|
|
|
|
{
|
2004-08-04 02:12:57 +04:00
|
|
|
int i;
|
|
|
|
int size;
|
|
|
|
int rank;
|
|
|
|
int err;
|
|
|
|
char *psnd;
|
|
|
|
char *prcv;
|
|
|
|
size_t nreqs;
|
|
|
|
MPI_Request *preq;
|
|
|
|
|
|
|
|
/* Initialize. */
|
|
|
|
size = ompi_comm_remote_size(comm);
|
|
|
|
rank = ompi_comm_rank(comm);
|
|
|
|
|
|
|
|
/* Initiate all send/recv to/from others. */
|
|
|
|
nreqs = size * 2;
|
|
|
|
preq = comm->c_coll_basic_data->mccb_reqs;
|
|
|
|
|
|
|
|
/* Post all receives first -- a simple optimization */
|
|
|
|
for (i = 0; i < size; ++i) {
|
|
|
|
prcv = ((char *) rbuf) + rdisps[i];
|
|
|
|
err = mca_pml.pml_irecv_init(prcv, rcounts[i], rdtypes[i],
|
|
|
|
i, MCA_COLL_BASE_TAG_ALLTOALLW,
|
|
|
|
comm, preq++);
|
|
|
|
if (OMPI_SUCCESS != err) {
|
|
|
|
mca_coll_basic_free_reqs(comm->c_coll_basic_data->mccb_reqs, nreqs);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now post all sends */
|
|
|
|
for (i = 0; i < size; ++i) {
|
|
|
|
psnd = ((char *) sbuf) + sdisps[i];
|
|
|
|
err = mca_pml.pml_isend_init(psnd, scounts[i], sdtypes[i],
|
|
|
|
i, MCA_COLL_BASE_TAG_ALLTOALLW,
|
|
|
|
MCA_PML_BASE_SEND_STANDARD, comm, preq++);
|
|
|
|
if (OMPI_SUCCESS != err) {
|
|
|
|
mca_coll_basic_free_reqs(comm->c_coll_basic_data->mccb_reqs, nreqs);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Start your engines. This will never return an error. */
|
|
|
|
mca_pml.pml_start(nreqs, comm->c_coll_basic_data->mccb_reqs);
|
|
|
|
|
|
|
|
/* Wait for them all. If there's an error, note that we don't care
|
|
|
|
what the error was -- just that there *was* an error. The PML
|
|
|
|
will finish all requests, even if one or more of them fail.
|
|
|
|
i.e., by the end of this call, all the requests are free-able.
|
|
|
|
So free them anyway -- even if there was an error, and return the
|
|
|
|
error after we free everything. */
|
2004-10-12 19:50:01 +04:00
|
|
|
err = ompi_request_wait_all(nreqs, comm->c_coll_basic_data->mccb_reqs,
|
2004-08-04 02:12:57 +04:00
|
|
|
MPI_STATUSES_IGNORE);
|
|
|
|
|
|
|
|
/* Free the requests. */
|
|
|
|
mca_coll_basic_free_reqs(comm->c_coll_basic_data->mccb_reqs, nreqs);
|
|
|
|
|
|
|
|
/* All done */
|
|
|
|
return err;
|
2004-01-12 00:26:55 +03:00
|
|
|
}
|