Changeset 2576


Ignore:
Timestamp:
09/19/23 09:51:42 (8 months ago)
Author:
ymipsl
Message:

Implement tracking of unfree communicators.

YM

Location:
XIOS3/trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • XIOS3/trunk/src/client.cpp

    r2547 r2576  
    521521 
    522522      CXios::getMpiGarbageCollector().release() ; // release unfree MPI ressources 
     523      CCommTrack::dumpComm() ; 
    523524      if (!is_MPI_Initialized) 
    524525      { 
  • XIOS3/trunk/src/mpi.hpp

    r1759 r2576  
    3131#include "mpi_tools.hpp" 
    3232 
     33inline int MPI_Comm_dup(MPI_Comm comm, MPI_Comm * newcomm) 
     34{ 
     35  int ret=PMPI_Comm_dup(comm, newcomm) ; 
     36  xios::CCommTrack::registerComm(*newcomm) ; 
     37  return ret ; 
     38} 
     39 
     40inline int MPI_Intercomm_create(MPI_Comm local_comm, int local_leader, 
     41                         MPI_Comm peer_comm, int remote_leader, int tag, MPI_Comm * newintercomm) 
     42{ 
     43  int ret=PMPI_Intercomm_create(local_comm, local_leader, peer_comm, remote_leader, tag, newintercomm) ; 
     44  xios::CCommTrack::registerComm(*newintercomm) ; 
     45  return ret ; 
     46} 
     47 
     48inline int MPI_Intercomm_merge(MPI_Comm intercomm, int high, MPI_Comm * newintracomm) 
     49{ 
     50  int ret=PMPI_Intercomm_merge(intercomm, high, newintracomm) ; 
     51  xios::CCommTrack::registerComm(*newintracomm) ; 
     52  return ret ; 
     53} 
     54 
     55inline int MPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm * newcomm) 
     56{ 
     57  int ret=PMPI_Comm_split(comm, color, key,newcomm) ; 
     58  xios::CCommTrack::registerComm(*newcomm) ; 
     59  return ret ; 
     60} 
     61 
     62inline int MPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm *newcomm) 
     63{ 
     64  int ret=PMPI_Comm_create(comm, group, newcomm) ; 
     65  xios::CCommTrack::registerComm(*newcomm) ; 
     66  return ret ; 
     67} 
     68 
     69inline int MPI_Comm_free(MPI_Comm *comm)  
     70{  
     71  xios::CCommTrack::releaseComm(*comm) ; 
     72  return PMPI_Comm_free(comm) ; 
     73} 
     74 
     75 
    3376#endif 
  • XIOS3/trunk/src/mpi_tools.cpp

    r2507 r2576  
    11#include "mpi.hpp" 
    2 #include "mpi_tools.hpp" 
    3  
    4  
     2#include "backtrace.hpp" 
     3#include "exception.hpp" 
     4#include "log.hpp" 
    55#include <string> 
     6#include <sstream> 
    67 
    78namespace xios   
    89{ 
     10  std::map<MPI_Comm,string> CCommTrack::commTrack_ ; 
     11  void CCommTrack::registerComm(const MPI_Comm& comm) 
     12  { 
     13    auto it = commTrack_.find(comm) ; 
     14    if (it == commTrack_.end())  commTrack_[comm] = MemTrack::backTrace(3); 
     15    else ERROR("CCommtrack::registerComm", << "Communicator already allocated : " << endl<<it->second) 
     16  } 
     17 
     18  void CCommTrack::releaseComm(const MPI_Comm& comm) 
     19  { 
     20    auto it = commTrack_.find(comm) ; 
     21    if (it == commTrack_.end())  ERROR("CCommtrack::releaseComm", << "Communicator not allocated : " << endl) 
     22    else commTrack_.erase(it) ; 
     23  } 
     24 
     25  void CCommTrack::dumpComm(void) 
     26  { 
     27    ostringstream ostr ; 
     28    ostr<<" LIST of UNFREED MPI COMMUNICATORS"<<endl ; 
     29    for(auto& it : commTrack_ ) 
     30    { 
     31      ostr<<"---------------------------"<<endl ; 
     32      ostr<<" -- unfreed communicator --"<<endl ; 
     33      ostr<<" --       backtrace      --"<<endl ; 
     34      ostr<<it.second<<endl ; 
     35    } 
     36    info(100)<<ostr.str() ; 
     37  } 
     38 
    939  int MPI_Bcast_string(std::string& str, int root, MPI_Comm comm)  
    1040  { 
  • XIOS3/trunk/src/mpi_tools.hpp

    r2118 r2576  
    33 
    44#include <string> 
     5#include <map> 
    56 
    67namespace xios 
     
    3334  MPI_Datatype MPI_GetType<long double>(void); 
    3435 
     36  class CCommTrack 
     37  { 
     38    private: 
     39    static std::map<MPI_Comm,std::string> commTrack_ ; 
     40     
     41    public: 
     42    static void registerComm(const MPI_Comm& comm) ; 
    3543 
     44    static void releaseComm(const MPI_Comm& comm) ; 
     45 
     46    static void dumpComm(void) ; 
     47 
     48    static const std::map<MPI_Comm,std::string>& getCommTrack(void) {return commTrack_ ;} 
     49  } ; 
    3650}  
    3751#endif 
  • XIOS3/trunk/src/server.cpp

    r2547 r2576  
    602602 
    603603      CMemChecker::logMem( "CServer::finalize", true ); 
     604       
     605      CCommTrack::dumpComm() ; 
     606 
    604607      if (!is_MPI_Initialized) 
    605608      { 
Note: See TracChangeset for help on using the changeset viewer.