]> AND Public Git Repository - simgrid.git/blobdiff - src/smpi/bindings/smpi_pmpi_type.cpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
generalize mark_as_deleted call
[simgrid.git] / src / smpi / bindings / smpi_pmpi_type.cpp
index 7155047890fdac15c5d786f7f4b9868ede0286d4..04208cb9c4267c85aef1a2195a527756edff3adc 100644 (file)
@@ -17,6 +17,7 @@ int PMPI_Type_free(MPI_Datatype * datatype)
   if (*datatype == MPI_DATATYPE_NULL || (*datatype)->flags() & DT_FLAG_PREDEFINED) {
     return MPI_ERR_TYPE;
   } else {
+    (*datatype)->mark_as_deleted();
     simgrid::smpi::Datatype::unref(*datatype);
     *datatype=MPI_DATATYPE_NULL;
     return MPI_SUCCESS;
@@ -209,7 +210,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() ) {