Last change
on this file since 2604 was
2593,
checked in by jderouillat, 9 months ago
|
Rename the MemTrack? namespace associated to CppTrace? (conflict with the --memtrack option), waiting for its full integration
|
-
Property svn:executable set to
*
|
File size:
1.2 KB
|
Rev | Line | |
---|
[2310] | 1 | #ifndef __MPI_GARBAGE_COLLECTOR_HPP__ |
---|
| 2 | #define __MPI_GARBAGE_COLLECTOR_HPP__ |
---|
| 3 | #include "mpi.hpp" |
---|
[2580] | 4 | #include "backtrace.hpp" |
---|
[2310] | 5 | namespace xios |
---|
| 6 | { |
---|
| 7 | class CMpiGarbageCollector |
---|
| 8 | { |
---|
| 9 | |
---|
| 10 | private: |
---|
| 11 | |
---|
| 12 | struct SType |
---|
| 13 | { |
---|
| 14 | enum {COMM, WIN} type ; |
---|
| 15 | MPI_Comm comm ; |
---|
| 16 | MPI_Win win ; |
---|
| 17 | std::string str; |
---|
| 18 | } ; |
---|
| 19 | std::list<SType> stack_ ; |
---|
| 20 | |
---|
| 21 | public: |
---|
| 22 | |
---|
[2580] | 23 | void registerCommunicator(MPI_Comm& comm, std::string str) { stack_.push_front(SType{SType::COMM, comm, MPI_WIN_NULL, str}) ;} |
---|
[2593] | 24 | void registerCommunicator(MPI_Comm& comm) { stack_.push_front(SType{SType::COMM, comm, MPI_WIN_NULL, MemCppTrack::backTrace(2)}) ;} |
---|
[2580] | 25 | void registerWindow(MPI_Win& win, std::string str) { stack_.push_front(SType{SType::WIN, MPI_COMM_NULL, win, str}) ;} |
---|
[2593] | 26 | void registerWindow(MPI_Win& win) { stack_.push_front(SType{SType::WIN, MPI_COMM_NULL, win, MemCppTrack::backTrace(2)}) ;} |
---|
[2310] | 27 | void release(void) |
---|
| 28 | { |
---|
| 29 | for( auto& it : stack_) |
---|
[2589] | 30 | if (it.type==SType::COMM) xios::MPI_Comm_free(&it.comm); |
---|
[2310] | 31 | else if (it.type==SType::WIN) MPI_Win_free(&it.win); |
---|
[2569] | 32 | stack_.clear(); |
---|
[2310] | 33 | } |
---|
| 34 | } ; |
---|
| 35 | |
---|
| 36 | } |
---|
| 37 | |
---|
[2569] | 38 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.