DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
DNDS::MPI::ResourceRecycler Class Reference

Singleton that tracks and releases long-lived MPI resources at MPI_Finalize time. More...

#include <MPI.hpp>

Public Member Functions

void RegisterCleaner (void *p, std::function< void()> nCleaner)
 Register a cleanup callback keyed by p.
 
void RemoveCleaner (void *p)
 Remove a previously-registered cleaner.
 
void clean ()
 Invoke all registered cleaners and drop them. Called by MPI::Finalize().
 

Static Public Member Functions

static ResourceRecyclerInstance ()
 Access the process-wide singleton.
 

Detailed Description

Singleton that tracks and releases long-lived MPI resources at MPI_Finalize time.

MPI communicators, derived datatypes, and persistent requests must be released before MPI_Finalize; otherwise they leak memory and MPICH prints warnings. Several DNDSR objects (MPITypePairHolder, MPIReqHolder) register themselves here so that MPI::Finalize() can call their cleanup callbacks even if the C++ lifetime would outlive the MPI runtime (e.g., static destructors).

Thread-safe C++11 singleton. Intended to be created under MPI_COMM_WORLD.

Definition at line 272 of file MPI.hpp.

Member Function Documentation

◆ clean()

void DNDS::MPI::ResourceRecycler::clean ( )

Invoke all registered cleaners and drop them. Called by MPI::Finalize().

Definition at line 328 of file MPI.cpp.

Here is the caller graph for this function:

◆ Instance()

ResourceRecycler & DNDS::MPI::ResourceRecycler::Instance ( )
static

Access the process-wide singleton.

Definition at line 310 of file MPI.cpp.

Here is the caller graph for this function:

◆ RegisterCleaner()

void DNDS::MPI::ResourceRecycler::RegisterCleaner ( void *  p,
std::function< void()>  nCleaner 
)

Register a cleanup callback keyed by p.

Warning
Must be paired with RemoveCleaner when p is destroyed, else dangling pointers will be invoked by clean.

Definition at line 316 of file MPI.cpp.

Here is the caller graph for this function:

◆ RemoveCleaner()

void DNDS::MPI::ResourceRecycler::RemoveCleaner ( void *  p)

Remove a previously-registered cleaner.

Definition at line 322 of file MPI.cpp.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: