From: Gabriel Corona Date: Tue, 2 Sep 2014 11:29:28 +0000 (+0200) Subject: [smpi] Allow zero-sized custom datatypes with MPI_Type_contiguous() X-Git-Tag: v3_12~849 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/105c1b117af96a9f150b5c06ed68209a8c66e052 [smpi] Allow zero-sized custom datatypes with MPI_Type_contiguous() MPI_Type_contiguous(0, oldtype, newtype) is valid in MPI but SMPI does not accept it as the resulting datatype is considered invalid: SMPI does not accept datatypes with size of 0. Fix the datatype validation function in order to accept this. This type of datatype is used in bcastzerotype. bcast-NTSL is fixed as well (division by zero). --- diff --git a/src/smpi/colls/bcast-NTSL.c b/src/smpi/colls/bcast-NTSL.c index 7b8ede082e..c9df1a7c29 100644 --- a/src/smpi/colls/bcast-NTSL.c +++ b/src/smpi/colls/bcast-NTSL.c @@ -34,7 +34,7 @@ int smpi_coll_tuned_bcast_NTSL(void *buf, int count, MPI_Datatype datatype, int from = (rank + size - 1) % size; /* segment is segment size in number of elements (not bytes) */ - int segment = bcast_NTSL_segment_size_in_byte / extent; + int segment = extent == 0 ? 1 : (bcast_NTSL_segment_size_in_byte / extent); segment = segment == 0 ? 1 :segment; /* pipeline length */ int pipe_length = count / segment; diff --git a/src/smpi/smpi_mpi_dt.c b/src/smpi/smpi_mpi_dt.c index bedd20559a..4cd5f6454e 100644 --- a/src/smpi/smpi_mpi_dt.c +++ b/src/smpi/smpi_mpi_dt.c @@ -151,7 +151,7 @@ CREATE_MPI_DATATYPE(MPI_PTR, void*); int is_datatype_valid(MPI_Datatype datatype) { return datatype != MPI_DATATYPE_NULL && (datatype->flags & DT_FLAG_COMMITED) - && (smpi_datatype_size(datatype)>0); + && (smpi_datatype_size(datatype)>=0); } size_t smpi_datatype_size(MPI_Datatype datatype)