Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
checks for PMPI_Type_create_subarray
authorAugustin Degomme <adegomme@users.noreply.github.com>
Sun, 4 Apr 2021 17:14:21 +0000 (19:14 +0200)
committerAugustin Degomme <adegomme@users.noreply.github.com>
Sun, 4 Apr 2021 17:14:21 +0000 (19:14 +0200)
src/smpi/bindings/smpi_pmpi_type.cpp
src/smpi/include/private.hpp

index 7155047..aac1aed 100644 (file)
@@ -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() ) {
index 144e7f2..87bf3fb 100644 (file)
@@ -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)                                                                                  \