From: Augustin Degomme Date: Sun, 4 Apr 2021 17:14:21 +0000 (+0200) Subject: checks for PMPI_Type_create_subarray X-Git-Tag: v3.28~460 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/313a8a55981ce6c9ea67b5dd26793de538487d2f checks for PMPI_Type_create_subarray --- diff --git a/src/smpi/bindings/smpi_pmpi_type.cpp b/src/smpi/bindings/smpi_pmpi_type.cpp index 7155047890..aac1aed1d4 100644 --- a/src/smpi/bindings/smpi_pmpi_type.cpp +++ b/src/smpi/bindings/smpi_pmpi_type.cpp @@ -209,7 +209,16 @@ int PMPI_Type_create_subarray(int ndims, const int* array_of_sizes, if (ndims==0){ *newtype = MPI_DATATYPE_NULL; return MPI_SUCCESS; - } else if (ndims==1){ + } + CHECK_NULL(2, MPI_ERR_ARG, array_of_sizes) + CHECK_NULL(3, MPI_ERR_ARG, array_of_subsizes) + CHECK_NULL(4, MPI_ERR_ARG, array_of_starts) + for (int i = 0; i < ndims; i++) { + CHECK_NEGATIVE_OR_ZERO(2, MPI_ERR_COUNT, array_of_sizes[i]) + CHECK_NEGATIVE(3, MPI_ERR_COUNT, array_of_subsizes[i]) + CHECK_NEGATIVE(4, MPI_ERR_COUNT, array_of_starts[i]) + } + if (ndims==1){ simgrid::smpi::Datatype::create_contiguous( array_of_subsizes[0], oldtype, array_of_starts[0]*oldtype->get_extent(), newtype); return MPI_SUCCESS; } else if (oldtype == MPI_DATATYPE_NULL || not oldtype->is_valid() ) { diff --git a/src/smpi/include/private.hpp b/src/smpi/include/private.hpp index 144e7f2b8d..87bf3fbeeb 100644 --- a/src/smpi/include/private.hpp +++ b/src/smpi/include/private.hpp @@ -534,6 +534,9 @@ XBT_PRIVATE void private_execute_flops(double flops); #define CHECK_NEGATIVE(num, err, val) \ CHECK_ARGS((val) < 0, (err), \ "%s: param %d %s cannot be negative", __func__, (num), _XBT_STRINGIFY(val)); +#define CHECK_NEGATIVE_OR_ZERO(num, err, val) \ + CHECK_ARGS((val) <= 0, (err), \ + "%s: param %d %s cannot be negative or 0", __func__, (num), _XBT_STRINGIFY(val)); #define CHECK_COMM2(num, comm) \ CHECK_MPI_NULL((num), MPI_COMM_NULL, MPI_ERR_COMM, (comm)) #define CHECK_DELETED(num, err, obj) \