From: Augustin Degomme Date: Wed, 26 May 2021 14:48:09 +0000 (+0200) Subject: mark these as derived datatypes, and don't divide by 0 if possible X-Git-Tag: v3.28~224 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b5e67af10d6cf151dbc6bcac7a0824e9fa537953 mark these as derived datatypes, and don't divide by 0 if possible --- diff --git a/src/smpi/mpi/smpi_datatype.cpp b/src/smpi/mpi/smpi_datatype.cpp index 22a28a3759..d1b5b93260 100644 --- a/src/smpi/mpi/smpi_datatype.cpp +++ b/src/smpi/mpi/smpi_datatype.cpp @@ -372,12 +372,10 @@ int Datatype::copy(const void* sendbuf, int sendcount, MPI_Datatype sendtype, vo recvtype->unserialize(sendbuf, recvbuf, count / recvtype->size(), MPI_REPLACE); } else if (not(recvtype->flags() & DT_FLAG_DERIVED)) { sendtype->serialize(sendbuf, recvbuf, count / sendtype->size()); - } else { + } else if(sendtype->size() != 0 && recvtype->size() != 0){ void * buf_tmp = xbt_malloc(count); - sendtype->serialize( sendbuf, buf_tmp,count/sendtype->size()); recvtype->unserialize( buf_tmp, recvbuf,count/recvtype->size(), MPI_REPLACE); - xbt_free(buf_tmp); } } @@ -432,7 +430,7 @@ int Datatype::create_vector(int count, int block_length, int stride, MPI_Datatyp }else{ /* in this situation the data are contiguous thus it's not required to serialize and unserialize it*/ *new_type = new Datatype(count * block_length * old_type->size(), 0, ((count -1) * stride + block_length)* - old_type->size(), DT_FLAG_CONTIGUOUS); + old_type->size(), DT_FLAG_CONTIGUOUS|DT_FLAG_DERIVED); const std::array ints = {{count, block_length, stride}}; (*new_type)->set_contents(MPI_COMBINER_VECTOR, 3, ints.data(), 0, nullptr, 1, &old_type); retval=MPI_SUCCESS; @@ -458,7 +456,7 @@ int Datatype::create_hvector(int count, int block_length, MPI_Aint stride, MPI_D retval=MPI_SUCCESS; }else{ /* in this situation the data are contiguous thus it's not required to serialize and unserialize it*/ - *new_type = new Datatype(count * block_length * old_type->size(), 0, count * block_length * old_type->size(), DT_FLAG_CONTIGUOUS); + *new_type = new Datatype(count * block_length * old_type->size(), 0, count * block_length * old_type->size(), DT_FLAG_CONTIGUOUS|DT_FLAG_DERIVED); const std::array ints = {{count, block_length}}; (*new_type)->set_contents(MPI_COMBINER_HVECTOR, 2, ints.data(), 1, &stride, 1, &old_type); retval=MPI_SUCCESS;