Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix refcounting of smpi::Info.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 11 Dec 2019 21:45:08 +0000 (22:45 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 12 Dec 2019 13:16:52 +0000 (14:16 +0100)
src/smpi/mpi/smpi_comm.cpp
src/smpi/mpi/smpi_file.cpp
src/smpi/mpi/smpi_win.cpp

index d8ca45b..d6ca527 100644 (file)
@@ -120,6 +120,7 @@ int Comm::dup_with_info(MPI_Info info, MPI_Comm* newcomm){
     (*newcomm)->info_=MPI_INFO_NULL;
   }
   if(info != MPI_INFO_NULL){
+    info->ref();
     (*newcomm)->info_=info;
   }
   return ret;
@@ -333,6 +334,8 @@ void Comm::unref(Comm* comm){
   if(comm->refcount_==0){
     comm->cleanup_smp();
     comm->cleanup_attr<Comm>();
+    if (comm->info_ != MPI_INFO_NULL)
+      simgrid::smpi::Info::unref(comm->info_);
     delete comm->topo_; // there's no use count on topos
     delete comm;
   }
@@ -537,17 +540,21 @@ void Comm::finish_rma_calls(){
   }
 }
 
-MPI_Info Comm::info(){
-  if(info_== MPI_INFO_NULL)
+MPI_Info Comm::info()
+{
+  if (info_ == MPI_INFO_NULL)
     info_ = new Info();
   info_->ref();
   return info_;
 }
 
-void Comm::set_info(MPI_Info info){
-  if(info_!= MPI_INFO_NULL)
+void Comm::set_info(MPI_Info info)
+{
+  if (info_ != MPI_INFO_NULL)
+    simgrid::smpi::Info::unref(info);
+  info_ = info;
+  if (info_ != MPI_INFO_NULL)
     info->ref();
-  info_=info;
 }
 
 MPI_Errhandler Comm::errhandler(){
index 7f1d69b..4c22c66 100644 (file)
@@ -27,6 +27,8 @@ namespace simgrid{
 namespace smpi{
 
   File::File(MPI_Comm comm, const char *filename, int amode, MPI_Info info): comm_(comm), flags_(amode), info_(info) {
+    if (info_ != MPI_INFO_NULL)
+      info_->ref();
     std::string fullname=filename;
     if (simgrid::s4u::Host::current()->get_disks().empty())
       xbt_die("SMPI/IO : Trying to open file on a diskless host ! Add one to your platform file");
@@ -72,6 +74,8 @@ namespace smpi{
     }
     delete win_;
     delete file_;
+    if (info_ != MPI_INFO_NULL)
+      simgrid::smpi::Info::unref(info_);
   }
 
   int File::close(MPI_File *fh){
@@ -270,17 +274,21 @@ namespace smpi{
     return simgrid::smpi::colls::barrier(comm_);
   }
 
-  MPI_Info File::info(){
-    if(info_== MPI_INFO_NULL)
+  MPI_Info File::info()
+  {
+    if (info_ == MPI_INFO_NULL)
       info_ = new Info();
     info_->ref();
     return info_;
   }
 
-  void File::set_info(MPI_Info info){
-    if(info_!= MPI_INFO_NULL)
-      info->ref();
-    info_=info;
+  void File::set_info(MPI_Info info)
+  {
+    if (info_ != MPI_INFO_NULL)
+      simgrid::smpi::Info::unref(info_);
+    info_ = info;
+    if (info_ != MPI_INFO_NULL)
+      info_->ref();
   }
 
   MPI_Comm File::comm(){
index 9efd479..588e5cf 100644 (file)
@@ -66,9 +66,8 @@ Win::~Win(){
   if (name_ != nullptr){
     xbt_free(name_);
   }
-  if(info_!=MPI_INFO_NULL){
-    MPI_Info_free(&info_);
-  }
+  if (info_ != MPI_INFO_NULL)
+    simgrid::smpi::Info::unref(info_);
 
   comm_->remove_rma_win(this);
 
@@ -118,8 +117,9 @@ void Win::get_group(MPI_Group* group){
   }
 }
 
-MPI_Info Win::info(){
-  if(info_== MPI_INFO_NULL)
+MPI_Info Win::info()
+{
+  if (info_ == MPI_INFO_NULL)
     info_ = new Info();
   info_->ref();
   return info_;
@@ -145,10 +145,13 @@ int Win::dynamic(){
   return dynamic_;
 }
 
-void Win::set_info(MPI_Info info){
-  if(info_!= MPI_INFO_NULL)
-    info->ref();
-  info_=info;
+void Win::set_info(MPI_Info info)
+{
+  if (info_ != MPI_INFO_NULL)
+    simgrid::smpi::Info::unref(info_);
+  info_ = info;
+  if (info_ != MPI_INFO_NULL)
+    info_->ref();
 }
 
 void Win::set_name(const char* name){