- Fix some compiler warnings / handle some errors better
- Remove most of the top-level MPI functions and replace with back-end functions (George will replace Pack/Unpack) This commit was SVN r2358.
Этот коммит содержится в:
родитель
41592650f2
Коммит
0db460b371
@ -2,11 +2,13 @@
|
|||||||
* $HEADER$
|
* $HEADER$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* VPS: gotto change this someday, now including mpi.h, replace this
|
#include "ompi_config.h"
|
||||||
with internal calls. Will gotto code some back end calls for
|
|
||||||
this */
|
|
||||||
#include "mpi.h"
|
|
||||||
#include "datatype/datatype.h"
|
#include "datatype/datatype.h"
|
||||||
|
#include "communicator/communicator.h"
|
||||||
|
#include "request/request.h"
|
||||||
|
#include "mca/pml/pml.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ompi_dtsndrcv
|
* ompi_dtsndrcv
|
||||||
@ -23,60 +25,85 @@
|
|||||||
* - communicator
|
* - communicator
|
||||||
* Returns: - MPI_SUCCESS or error code
|
* Returns: - MPI_SUCCESS or error code
|
||||||
*/
|
*/
|
||||||
int
|
int ompi_ddt_sndrcv(void *sbuf, int scount, MPI_Datatype sdtype, void *rbuf,
|
||||||
ompi_ddt_sndrcv(void *sbuf, int scount, MPI_Datatype sdtype, void *rbuf,
|
int rcount, MPI_Datatype rdtype, int tag, MPI_Comm comm)
|
||||||
int rcount, MPI_Datatype rdtype, int tag, MPI_Comm comm)
|
|
||||||
{
|
{
|
||||||
int err; /* error code */
|
int err;
|
||||||
int size; /* packed size */
|
int size;
|
||||||
int rank; /* caller's rank */
|
int rank;
|
||||||
MPI_Status stat; /* status info */
|
|
||||||
int position = 0;
|
int position = 0;
|
||||||
|
ompi_convertor_t *local_convertor;
|
||||||
|
ompi_request_t *req;
|
||||||
|
|
||||||
|
/* If same datatypes used, just copy. */
|
||||||
|
|
||||||
/*
|
|
||||||
* If same datatypes used, just copy.
|
|
||||||
*/
|
|
||||||
if (sdtype == rdtype) {
|
if (sdtype == rdtype) {
|
||||||
if (scount <= rcount) {
|
if (scount <= rcount) {
|
||||||
ompi_ddt_copy_content_same_ddt(rdtype, scount, (char *) rbuf,
|
ompi_ddt_copy_content_same_ddt(rdtype, scount, (char *) rbuf,
|
||||||
(char *) sbuf);
|
(char *) sbuf);
|
||||||
err = MPI_SUCCESS;
|
err = MPI_SUCCESS;
|
||||||
}
|
} else {
|
||||||
}
|
err = MPI_ERR_TRUNCATE;
|
||||||
/*
|
}
|
||||||
* If receive packed.
|
|
||||||
*/
|
|
||||||
else if (rdtype == MPI_PACKED) {
|
|
||||||
MPI_Pack_size(scount, sdtype, MPI_COMM_WORLD, &size);
|
|
||||||
if (size <= rcount) {
|
|
||||||
if (MPI_SUCCESS == MPI_Pack(sbuf, scount, sdtype,
|
|
||||||
rbuf, rcount, &position, MPI_COMM_WORLD)) {
|
|
||||||
err = MPI_SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* If send packed.
|
|
||||||
*/
|
|
||||||
else if (sdtype == MPI_PACKED) {
|
|
||||||
MPI_Pack_size(rcount, rdtype, MPI_COMM_WORLD, &size);
|
|
||||||
if (size >= scount) {
|
|
||||||
if (MPI_SUCCESS == MPI_Unpack(sbuf, scount, &position,
|
|
||||||
rbuf, rcount, rdtype,
|
|
||||||
MPI_COMM_WORLD)) {
|
|
||||||
err = MPI_SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Let send/recv handle it.
|
|
||||||
*/
|
|
||||||
else {
|
|
||||||
MPI_Comm_rank(comm, &rank);
|
|
||||||
err = MPI_Sendrecv(sbuf, scount, sdtype, rank, tag,
|
|
||||||
rbuf, rcount, rdtype, rank, tag, comm, &stat);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(err);
|
/* If receive packed. */
|
||||||
|
|
||||||
|
else if (rdtype == MPI_PACKED) {
|
||||||
|
local_convertor = OBJ_NEW(ompi_convertor_t);
|
||||||
|
ompi_convertor_init_for_send(local_convertor, 0, sdtype,
|
||||||
|
scount, NULL, 0);
|
||||||
|
err = ompi_convertor_get_packed_size(local_convertor, &size);
|
||||||
|
OBJ_RELEASE(local_convertor);
|
||||||
|
if (OMPI_SUCCESS != err) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size <= rcount) {
|
||||||
|
err = MPI_Pack(sbuf, scount, sdtype,
|
||||||
|
rbuf, rcount, &position, MPI_COMM_WORLD);
|
||||||
|
} else {
|
||||||
|
err = MPI_ERR_TRUNCATE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If send packed. */
|
||||||
|
|
||||||
|
else if (sdtype == MPI_PACKED) {
|
||||||
|
local_convertor = OBJ_NEW(ompi_convertor_t);
|
||||||
|
ompi_convertor_init_for_send(local_convertor, 0, rdtype,
|
||||||
|
rcount, NULL, 0);
|
||||||
|
err = ompi_convertor_get_packed_size(local_convertor, &size);
|
||||||
|
OBJ_RELEASE(local_convertor);
|
||||||
|
if (OMPI_SUCCESS != err) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scount <= size) {
|
||||||
|
err = MPI_Unpack(sbuf, scount, &position,
|
||||||
|
rbuf, rcount, rdtype,
|
||||||
|
MPI_COMM_WORLD);
|
||||||
|
} else {
|
||||||
|
err = MPI_ERR_TRUNCATE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Let the PML handle it (i.e., do a normal send/recv) */
|
||||||
|
|
||||||
|
else {
|
||||||
|
rank = ompi_comm_rank(comm);
|
||||||
|
err = mca_pml.pml_irecv(rbuf, rcount, rdtype, rank, tag, comm, &req);
|
||||||
|
if (MPI_SUCCESS != err) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
err = mca_pml.pml_send(sbuf, scount, sdtype, rank, tag,
|
||||||
|
MCA_PML_BASE_SEND_STANDARD, comm);
|
||||||
|
if (MPI_SUCCESS != err) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
err = mca_pml.pml_wait(1, &req, NULL, MPI_STATUS_IGNORE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user