Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix refcount for Datatype_contents.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 28 May 2021 15:16:30 +0000 (17:16 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 28 May 2021 15:28:17 +0000 (17:28 +0200)
Error seen with Petsc test: vec_is_sf_tutorials-ex3_basic_dupped.

src/smpi/include/smpi_datatype.hpp
src/smpi/mpi/smpi_datatype.cpp
src/smpi/mpi/smpi_datatype_derived.cpp

index 7bd716a..434299a 100644 (file)
@@ -94,6 +94,7 @@ class Datatype_contents {
                     int number_of_integers, const int* integers, 
                     int number_of_addresses, const MPI_Aint* addresses, 
                     int number_of_datatypes, const MPI_Datatype* datatypes);
+  ~Datatype_contents();
 };
 
 class Datatype : public F2C, public Keyval{
index 8fb7e77..3f5b211 100644 (file)
@@ -315,7 +315,8 @@ int Datatype::get_contents(int max_integers, int max_addresses, int max_datatype
   if (static_cast<unsigned>(max_datatypes) < contents_->datatypes_.size())
     return MPI_ERR_COUNT;
   std::copy(begin(contents_->datatypes_), end(contents_->datatypes_), array_of_datatypes);
-  std::for_each(begin(contents_->datatypes_), end(contents_->datatypes_), std::mem_fn(&Datatype::ref));
+  for (auto& datatype : contents_->datatypes_)
+    datatype->ref();
   return MPI_SUCCESS;
 }
 
index b9c9cf7..60ccd26 100644 (file)
@@ -21,6 +21,14 @@ Datatype_contents::Datatype_contents(int combiner, int number_of_integers, const
     , addresses_(addresses, addresses + number_of_addresses)
     , datatypes_(datatypes, datatypes + number_of_datatypes)
 {
+  for (auto& datatype : datatypes_)
+    datatype->ref();
+}
+
+Datatype_contents::~Datatype_contents()
+{
+  for (auto& datatype : datatypes_)
+    Datatype::unref(datatype);
 }
 
 Type_Contiguous::Type_Contiguous(int size, MPI_Aint lb, MPI_Aint ub, int flags, int block_count, MPI_Datatype old_type)