From: Augustin Degomme Date: Mon, 5 Apr 2021 21:57:12 +0000 (+0200) Subject: Don't add handles to the lookup for the sake of just removing them immediately... X-Git-Tag: v3.28~455^2~137 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/ea02d47c2ee462e84798356e4dda87b1467e22b8 Don't add handles to the lookup for the sake of just removing them immediately... if they're not there .. well they are not. --- diff --git a/src/smpi/include/smpi_f2c.hpp b/src/smpi/include/smpi_f2c.hpp index ee02512b23..fa915c425c 100644 --- a/src/smpi/include/smpi_f2c.hpp +++ b/src/smpi/include/smpi_f2c.hpp @@ -33,7 +33,8 @@ protected: if (not f2c_lookup_) f2c_lookup_ = std::make_unique(); } - 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. diff --git a/src/smpi/mpi/smpi_comm.cpp b/src/smpi/mpi/smpi_comm.cpp index 5bb9651b43..117d76f8b6 100644 --- a/src/smpi/mpi/smpi_comm.cpp +++ b/src/smpi/mpi/smpi_comm.cpp @@ -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(); if (comm->info_ != MPI_INFO_NULL) diff --git a/src/smpi/mpi/smpi_datatype.cpp b/src/smpi/mpi/smpi_datatype.cpp index d504388150..1bef5a1213 100644 --- a/src/smpi/mpi/smpi_datatype.cpp +++ b/src/smpi/mpi/smpi_datatype.cpp @@ -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; diff --git a/src/smpi/mpi/smpi_errhandler.cpp b/src/smpi/mpi/smpi_errhandler.cpp index c62d8449d5..74e224226f 100644 --- a/src/smpi/mpi/smpi_errhandler.cpp +++ b/src/smpi/mpi/smpi_errhandler.cpp @@ -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; } } diff --git a/src/smpi/mpi/smpi_f2c.cpp b/src/smpi/mpi/smpi_f2c.cpp index 86f819d520..be9e920baf 100644 --- a/src/smpi/mpi/smpi_f2c.cpp +++ b/src/smpi/mpi/smpi_f2c.cpp @@ -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_; diff --git a/src/smpi/mpi/smpi_file.cpp b/src/smpi/mpi/smpi_file.cpp index 48647a5637..8bdbc70109 100644 --- a/src/smpi/mpi/smpi_file.cpp +++ b/src/smpi/mpi/smpi_file.cpp @@ -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) diff --git a/src/smpi/mpi/smpi_group.cpp b/src/smpi/mpi/smpi_group.cpp index e01112f561..25663c3fcc 100644 --- a/src/smpi/mpi/smpi_group.cpp +++ b/src/smpi/mpi/smpi_group.cpp @@ -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; } } diff --git a/src/smpi/mpi/smpi_info.cpp b/src/smpi/mpi/smpi_info.cpp index ed832a6e27..b4a78fac30 100644 --- a/src/smpi/mpi/smpi_info.cpp +++ b/src/smpi/mpi/smpi_info.cpp @@ -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; } } diff --git a/src/smpi/mpi/smpi_op.cpp b/src/smpi/mpi/smpi_op.cpp index 30434c7b05..9b2bf1b562 100644 --- a/src/smpi/mpi/smpi_op.cpp +++ b/src/smpi/mpi/smpi_op.cpp @@ -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); } } diff --git a/src/smpi/mpi/smpi_request.cpp b/src/smpi/mpi/smpi_request.cpp index 72e5cfa1a3..7fc8421b9b 100644 --- a/src/smpi/mpi/smpi_request.cpp +++ b/src/smpi/mpi/smpi_request.cpp @@ -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 { diff --git a/src/smpi/mpi/smpi_win.cpp b/src/smpi/mpi/smpi_win.cpp index 9850c2a2f2..297dd072c3 100644 --- a/src/smpi/mpi/smpi_win.cpp +++ b/src/smpi/mpi/smpi_win.cpp @@ -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(); }