Last change
on this file since 2520 was
2310,
checked in by ymipsl, 3 years ago
|
Implement small garbage collector for unfreed MPI windows and communicator.
YM
|
-
Property svn:executable set to
*
|
File size:
862 bytes
|
Line | |
---|
1 | #ifndef __MPI_GARBAGE_COLLECTOR_HPP__ |
---|
2 | #define __MPI_GARBAGE_COLLECTOR_HPP__ |
---|
3 | #include "mpi.hpp" |
---|
4 | namespace xios |
---|
5 | { |
---|
6 | class CMpiGarbageCollector |
---|
7 | { |
---|
8 | |
---|
9 | private: |
---|
10 | |
---|
11 | struct SType |
---|
12 | { |
---|
13 | enum {COMM, WIN} type ; |
---|
14 | MPI_Comm comm ; |
---|
15 | MPI_Win win ; |
---|
16 | std::string str; |
---|
17 | } ; |
---|
18 | std::list<SType> stack_ ; |
---|
19 | |
---|
20 | public: |
---|
21 | |
---|
22 | void registerCommunicator(MPI_Comm& comm, std::string str="") { stack_.push_back(SType{SType::COMM, comm, MPI_WIN_NULL, str}) ;} |
---|
23 | void registerWindow(MPI_Win& win, std::string str="") { stack_.push_back(SType{SType::WIN, MPI_COMM_NULL, win, str}) ;} |
---|
24 | void release(void) |
---|
25 | { |
---|
26 | for( auto& it : stack_) |
---|
27 | if (it.type==SType::COMM) MPI_Comm_free(&it.comm); |
---|
28 | else if (it.type==SType::WIN) MPI_Win_free(&it.win); |
---|
29 | } |
---|
30 | } ; |
---|
31 | |
---|
32 | } |
---|
33 | |
---|
34 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.