Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't add handles to the lookup for the sake of just removing them immediately...
authorAugustin Degomme <adegomme@users.noreply.github.com>
Mon, 5 Apr 2021 21:57:12 +0000 (23:57 +0200)
committerAugustin Degomme <adegomme@users.noreply.github.com>
Tue, 6 Apr 2021 18:07:16 +0000 (20:07 +0200)
if they're not there .. well they are not.

src/smpi/include/smpi_f2c.hpp
src/smpi/mpi/smpi_comm.cpp
src/smpi/mpi/smpi_datatype.cpp
src/smpi/mpi/smpi_errhandler.cpp
src/smpi/mpi/smpi_f2c.cpp
src/smpi/mpi/smpi_file.cpp
src/smpi/mpi/smpi_group.cpp
src/smpi/mpi/smpi_info.cpp
src/smpi/mpi/smpi_op.cpp
src/smpi/mpi/smpi_request.cpp
src/smpi/mpi/smpi_win.cpp

index ee02512..fa915c4 100644 (file)
@@ -33,7 +33,8 @@ protected:
     if (not f2c_lookup_)
       f2c_lookup_ = std::make_unique<f2c_lookup_type>();
   }
-  static int f2c_id() { return f2c_id_; }
+  int f2c_id() { return my_f2c_id_; }
+  static int global_f2c_id() { return f2c_id_; }
   static void f2c_id_increment() { f2c_id_++; }
   void mark_as_deleted() { deleted_ = true; };
 
@@ -44,7 +45,7 @@ public:
   virtual ~F2C() = default;
 
   int add_f();
-  static void free_f(int id) { f2c_lookup_->erase(id); }
+  static void free_f(int id) { if(id!=-1) f2c_lookup_->erase(id); }
   int c2f();
 
   // This method should be overridden in all subclasses to avoid casting the result when calling it.
index 5bb9651..117d76f 100644 (file)
@@ -339,7 +339,7 @@ void Comm::unref(Comm* comm){
 
   if(comm->refcount_==0){
     if(simgrid::smpi::F2C::lookup() != nullptr)
-      F2C::free_f(comm->c2f());
+      F2C::free_f(comm->f2c_id());
     comm->cleanup_smp();
     comm->cleanup_attr<Comm>();
     if (comm->info_ != MPI_INFO_NULL)
index d504388..1bef5a1 100644 (file)
@@ -150,7 +150,7 @@ Datatype::~Datatype()
     return;
   //prevent further usage
   flags_ &= ~ DT_FLAG_COMMITED;
-  F2C::free_f(this->c2f());
+  F2C::free_f(this->f2c_id());
   //if still used, mark for deletion
   if(refcount_!=0){
       flags_ |=DT_FLAG_DESTROYED;
index c62d844..74e2242 100644 (file)
@@ -47,7 +47,7 @@ void Errhandler::unref(Errhandler* errhandler){
     return;
   errhandler->refcount_--;
   if(errhandler->refcount_==0){
-    F2C::free_f(errhandler->c2f());
+    F2C::free_f(errhandler->f2c_id());
     delete errhandler;
   }
 }
index 86f819d..be9e920 100644 (file)
@@ -25,8 +25,7 @@ F2C::F2C() = default;
 int F2C::add_f()
 {
   allocate_lookup();
-
-  my_f2c_id_                 = f2c_id();
+  my_f2c_id_                 = global_f2c_id();
   (*f2c_lookup_)[my_f2c_id_] = this;
   f2c_id_increment();
   return my_f2c_id_;
index 48647a5..8bdbc70 100644 (file)
@@ -81,7 +81,7 @@ namespace smpi{
     }
     delete win_;
     delete file_;
-    F2C::free_f(this->c2f());
+    F2C::free_f(this->f2c_id());
     if (info_ != MPI_INFO_NULL)
       simgrid::smpi::Info::unref(info_);
     if (errhandler_ != MPI_ERRHANDLER_NULL)
index e01112f..25663c3 100644 (file)
@@ -78,7 +78,7 @@ void Group::unref(Group* group)
   group->refcount_--;
   if (group->refcount_ <= 0) {
     if (simgrid::smpi::F2C::lookup() != nullptr)
-      F2C::free_f(group->c2f());
+      F2C::free_f(group->f2c_id());
     delete group;
   }
 }
index ed832a6..b4a78fa 100644 (file)
@@ -17,7 +17,7 @@ void Info::ref()
 void Info::unref(Info* info){
   info->refcount_--;
   if(info->refcount_==0){
-    F2C::free_f(info->c2f());
+    F2C::free_f(info->f2c_id());
     delete info;
   }
 }
index 30434c7..9b2bf1b 100644 (file)
@@ -280,7 +280,7 @@ void Op::unref(MPI_Op* op){
   if((*op)!=MPI_OP_NULL){
     (*op)->refcount_--;
     if ((*op)->refcount_ == 0 && not (*op)->is_predefined_){
-      F2C::free_f((*op)->c2f());
+      F2C::free_f((*op)->f2c_id());
       delete(*op);
     }
   }
index 72e5cfa..7fc8421 100644 (file)
@@ -91,7 +91,7 @@ void Request::unref(MPI_Request* request)
       Op::unref(&(*request)->op_);
 
     (*request)->print_request("Destroying");
-    F2C::free_f((*request)->c2f());
+    F2C::free_f((*request)->f2c_id());
     delete *request;
     *request = MPI_REQUEST_NULL;
   } else {
index 9850c2a..297dd07 100644 (file)
@@ -78,7 +78,7 @@ Win::~Win(){
   if(allocated_ !=0)
     xbt_free(base_);
 
-  F2C::free_f(this->c2f());
+  F2C::free_f(this->f2c_id());
   cleanup_attr<Win>();
 }