X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/6760cb07d6b57be16928d95339d71e57c4e24f36..44c034ffa442f8ec4060f073b8debe683e7a32fa:/src/smpi/smpi_mpi_dt.c diff --git a/src/smpi/smpi_mpi_dt.c b/src/smpi/smpi_mpi_dt.c index d553e0d3cb..de903ef5d0 100644 --- a/src/smpi/smpi_mpi_dt.c +++ b/src/smpi/smpi_mpi_dt.c @@ -112,20 +112,15 @@ int smpi_datatype_copy(void* sendbuf, int sendcount, MPI_Datatype sendtype, void /* First check if we really have something to do */ if(recvcount == 0) { retval = sendcount == 0 ? MPI_SUCCESS : MPI_ERR_TRUNCATE; - } else if(sendtype == recvtype) { - /* If same datatypes used, just copy. */ - count = sendcount < recvcount ? sendcount : recvcount; - memcpy(recvbuf, sendbuf, smpi_datatype_size(sendtype) * count); - retval = sendcount > recvcount ? MPI_ERR_TRUNCATE : MPI_SUCCESS; - } else { - /* FIXME: cases - * - If receive packed. - * - If send packed - * to be treated once we have the MPI_Pack things ... - **/ - retval = MPI_SUCCESS; - } - return retval; + } else { + /* FIXME: treat packed cases */ + sendcount *= smpi_datatype_size(sendtype); + recvcount *= smpi_datatype_size(recvtype); + count = sendcount < recvcount ? sendcount : recvcount; + memcpy(recvbuf, sendbuf, count); + retval = sendcount > recvcount ? MPI_ERR_TRUNCATE : MPI_SUCCESS; + } + return retval; } typedef struct s_smpi_mpi_op { @@ -157,7 +152,9 @@ typedef struct s_smpi_mpi_op { } static void max_func(void* a, void* b, int* length, MPI_Datatype* datatype) { - if(*datatype == MPI_SHORT) { + if(*datatype == MPI_CHAR) { + APPLY_FUNC(a, b, length, char, MAX_OP); + } else if(*datatype == MPI_SHORT) { APPLY_FUNC(a, b, length, short, MAX_OP); } else if(*datatype == MPI_INT) { APPLY_FUNC(a, b, length, int, MAX_OP); @@ -179,7 +176,9 @@ static void max_func(void* a, void* b, int* length, MPI_Datatype* datatype) { } static void min_func(void* a, void* b, int* length, MPI_Datatype* datatype) { - if(*datatype == MPI_SHORT) { + if(*datatype == MPI_CHAR) { + APPLY_FUNC(a, b, length, char, MIN_OP); + } else if(*datatype == MPI_SHORT) { APPLY_FUNC(a, b, length, short, MIN_OP); } else if(*datatype == MPI_INT) { APPLY_FUNC(a, b, length, int, MIN_OP); @@ -201,7 +200,9 @@ static void min_func(void* a, void* b, int* length, MPI_Datatype* datatype) { } static void sum_func(void* a, void* b, int* length, MPI_Datatype* datatype) { - if(*datatype == MPI_SHORT) { + if(*datatype == MPI_CHAR) { + APPLY_FUNC(a, b, length, char, SUM_OP); + } else if(*datatype == MPI_SHORT) { APPLY_FUNC(a, b, length, short, SUM_OP); } else if(*datatype == MPI_INT) { APPLY_FUNC(a, b, length, int, SUM_OP); @@ -229,7 +230,9 @@ static void sum_func(void* a, void* b, int* length, MPI_Datatype* datatype) { } static void prod_func(void* a, void* b, int* length, MPI_Datatype* datatype) { - if(*datatype == MPI_SHORT) { + if(*datatype == MPI_CHAR) { + APPLY_FUNC(a, b, length, char, PROD_OP); + } else if(*datatype == MPI_SHORT) { APPLY_FUNC(a, b, length, short, PROD_OP); } else if(*datatype == MPI_INT) { APPLY_FUNC(a, b, length, int, PROD_OP); @@ -257,7 +260,9 @@ static void prod_func(void* a, void* b, int* length, MPI_Datatype* datatype) { } static void land_func(void* a, void* b, int* length, MPI_Datatype* datatype) { - if(*datatype == MPI_SHORT) { + if(*datatype == MPI_CHAR) { + APPLY_FUNC(a, b, length, char, LAND_OP); + } else if(*datatype == MPI_SHORT) { APPLY_FUNC(a, b, length, short, LAND_OP); } else if(*datatype == MPI_INT) { APPLY_FUNC(a, b, length, int, LAND_OP); @@ -275,7 +280,9 @@ static void land_func(void* a, void* b, int* length, MPI_Datatype* datatype) { } static void lor_func(void* a, void* b, int* length, MPI_Datatype* datatype) { - if(*datatype == MPI_SHORT) { + if(*datatype == MPI_CHAR) { + APPLY_FUNC(a, b, length, char, LOR_OP); + } else if(*datatype == MPI_SHORT) { APPLY_FUNC(a, b, length, short, LOR_OP); } else if(*datatype == MPI_INT) { APPLY_FUNC(a, b, length, int, LOR_OP); @@ -293,7 +300,9 @@ static void lor_func(void* a, void* b, int* length, MPI_Datatype* datatype) { } static void lxor_func(void* a, void* b, int* length, MPI_Datatype* datatype) { - if(*datatype == MPI_SHORT) { + if(*datatype == MPI_CHAR) { + APPLY_FUNC(a, b, length, char, LXOR_OP); + } else if(*datatype == MPI_SHORT) { APPLY_FUNC(a, b, length, short, LXOR_OP); } else if(*datatype == MPI_INT) { APPLY_FUNC(a, b, length, int, LXOR_OP); @@ -311,7 +320,9 @@ static void lxor_func(void* a, void* b, int* length, MPI_Datatype* datatype) { } static void band_func(void* a, void* b, int* length, MPI_Datatype* datatype) { - if(*datatype == MPI_SHORT) { + if(*datatype == MPI_CHAR) { + APPLY_FUNC(a, b, length, char, BAND_OP); + } if(*datatype == MPI_SHORT) { APPLY_FUNC(a, b, length, short, BAND_OP); } else if(*datatype == MPI_INT) { APPLY_FUNC(a, b, length, int, BAND_OP); @@ -329,7 +340,9 @@ static void band_func(void* a, void* b, int* length, MPI_Datatype* datatype) { } static void bor_func(void* a, void* b, int* length, MPI_Datatype* datatype) { - if(*datatype == MPI_SHORT) { + if(*datatype == MPI_CHAR) { + APPLY_FUNC(a, b, length, char, BOR_OP); + } else if(*datatype == MPI_SHORT) { APPLY_FUNC(a, b, length, short, BOR_OP); } else if(*datatype == MPI_INT) { APPLY_FUNC(a, b, length, int, BOR_OP); @@ -347,7 +360,9 @@ static void bor_func(void* a, void* b, int* length, MPI_Datatype* datatype) { } static void bxor_func(void* a, void* b, int* length, MPI_Datatype* datatype) { - if(*datatype == MPI_SHORT) { + if(*datatype == MPI_CHAR) { + APPLY_FUNC(a, b, length, char, BXOR_OP); + } else if(*datatype == MPI_SHORT) { APPLY_FUNC(a, b, length, short, BXOR_OP); } else if(*datatype == MPI_INT) { APPLY_FUNC(a, b, length, int, BXOR_OP);