Datatype changes
This commit was SVN r1123.
Этот коммит содержится в:
родитель
21408ee4d3
Коммит
dd430f905f
@ -15,7 +15,7 @@ libdatatype_la_SOURCES = \
|
|||||||
$(headers) \
|
$(headers) \
|
||||||
dt_add.c dt_create.c dt_create_array.c dt_create_dup.c dt_create_indexed.c \
|
dt_add.c dt_create.c dt_create_array.c dt_create_dup.c dt_create_indexed.c \
|
||||||
dt_create_struct.c dt_create_vector.c dt_destroy.c dt_module.c \
|
dt_create_struct.c dt_create_vector.c dt_destroy.c dt_module.c \
|
||||||
dt_optimize.c dt_pack.c dt_unpack.c fake_stack.c dt_args.c
|
dt_optimize.c dt_pack.c dt_sndrcv.c dt_unpack.c fake_stack.c dt_args.c
|
||||||
|
|
||||||
# Conditionally install the header files
|
# Conditionally install the header files
|
||||||
|
|
||||||
|
@ -195,6 +195,9 @@ int lam_ddt_set_args( dt_desc_t* pData,
|
|||||||
int ci, int ** i,
|
int ci, int ** i,
|
||||||
int ca, MPI_Aint* a,
|
int ca, MPI_Aint* a,
|
||||||
int cd, MPI_Datatype* d,int type);
|
int cd, MPI_Datatype* d,int type);
|
||||||
|
/* VPS: Added */
|
||||||
|
int lam_ddt_sndrcv(void *sbuf, int scount, MPI_Datatype sdtype, void *rbuf,
|
||||||
|
int rcount, MPI_Datatype rdtype, int tag, MPI_Comm comm);
|
||||||
|
|
||||||
#endif /* DATATYPE_H_HAS_BEEN_INCLUDED */
|
#endif /* DATATYPE_H_HAS_BEEN_INCLUDED */
|
||||||
|
|
||||||
|
@ -122,6 +122,9 @@ lam_datatype_t* lam_mpi_2dblcplex = basicDatatypes + DT_2DOUBLE_COMPLEX;
|
|||||||
|
|
||||||
int local_sizes[DT_MAX_PREDEFINED];
|
int local_sizes[DT_MAX_PREDEFINED];
|
||||||
|
|
||||||
|
/* VPS: fake convertor for time being / to provide pack/unpack functions */
|
||||||
|
lam_convertor_t* lam_convertor;
|
||||||
|
|
||||||
static lam_convertor_t* pDumpConv = NULL;
|
static lam_convertor_t* pDumpConv = NULL;
|
||||||
|
|
||||||
#define COPY_DATA_DESC( PDST, PSRC ) \
|
#define COPY_DATA_DESC( PDST, PSRC ) \
|
||||||
@ -231,6 +234,9 @@ int lam_ddt_init( void )
|
|||||||
for( i = 0; i < DT_MAX_PREDEFINED; i++ )
|
for( i = 0; i < DT_MAX_PREDEFINED; i++ )
|
||||||
local_sizes[i] = basicDatatypes[i].size;
|
local_sizes[i] = basicDatatypes[i].size;
|
||||||
|
|
||||||
|
/* VPS: Create a fake convertor. No error checking here now, since
|
||||||
|
this will be removed sometime */
|
||||||
|
lam_convertor = lam_convertor_create(0,0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
82
src/datatype/dt_sndrcv.c
Обычный файл
82
src/datatype/dt_sndrcv.c
Обычный файл
@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* $HEADER$
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* VPS: gotto change this someday, now including mpi.h, replace this
|
||||||
|
with internal calls. Will gotto code some back end calls for
|
||||||
|
this */
|
||||||
|
#include "mpi.h"
|
||||||
|
#include "datatype/datatype.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* lam_dtsndrcv
|
||||||
|
*
|
||||||
|
* Function: - copy MPI message from buffer into another
|
||||||
|
* - send/recv done if cannot optimize
|
||||||
|
* Accepts: - send buffer
|
||||||
|
* - send count
|
||||||
|
* - send datatype
|
||||||
|
* - receive buffer
|
||||||
|
* - receive count
|
||||||
|
* - receive datatype
|
||||||
|
* - tag
|
||||||
|
* - communicator
|
||||||
|
* Returns: - MPI_SUCCESS or error code
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
lam_ddt_sndrcv(void *sbuf, int scount, MPI_Datatype sdtype, void *rbuf,
|
||||||
|
int rcount, MPI_Datatype rdtype, int tag, MPI_Comm comm)
|
||||||
|
{
|
||||||
|
int err; /* error code */
|
||||||
|
int size; /* packed size */
|
||||||
|
int rank; /* caller's rank */
|
||||||
|
MPI_Status stat; /* status info */
|
||||||
|
int position = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If same datatypes used, just copy.
|
||||||
|
*/
|
||||||
|
if (sdtype == rdtype) {
|
||||||
|
if (scount <= rcount) {
|
||||||
|
lam_ddt_copy_content_same_ddt(rdtype, scount, (char *) rbuf,
|
||||||
|
(char *) sbuf);
|
||||||
|
err = MPI_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
|
Загрузка…
x
Ссылка в новой задаче
Block a user