Skip to content

Commit

Permalink
#48: ensure persistent backend state is cleared on context destruction
Browse files Browse the repository at this point in the history
  • Loading branch information
nmm0 committed Jun 8, 2023
1 parent 55a7fcb commit a51d0d4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
16 changes: 13 additions & 3 deletions src/resilience/context/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,28 @@ namespace KokkosResilience
return buffer.data();
}

ContextBase::~ContextBase()
{
unregister_all_regions();
}

void
ContextBase::reset()
{
// Unregister all regions
unregister_all_regions();

reset_impl();
}

void
ContextBase::unregister_all_regions()
{
for ( auto &&[name, members] : regions )
{
for ( const auto &m : members)
{
m_backend->unregister_member(m);
}
}

reset_impl();
}
}
3 changes: 2 additions & 1 deletion src/resilience/context/ContextBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace KokkosResilience
explicit ContextBase( const std::string& cfg_filename , int proc_id = 0)
: ContextBase(Config{cfg_filename}, proc_id) {};

virtual ~ContextBase() {};
virtual ~ContextBase();

template<typename... Traits, typename RegionFunc, typename FilterFunc, typename... T>
void run(const std::string& label, int iteration, RegionFunc&& fun, FilterFunc&& filter,
Expand Down Expand Up @@ -191,6 +191,7 @@ namespace KokkosResilience
template<typename... Traits, typename RegionFunc, typename... T>
void detect_and_register(RegionFunc&& fun, Detail::RegInfo<T>... explicit_members);

void unregister_all_regions();
virtual void reset_impl() = 0;

//Hold onto a buffer per context for de/serializing non-contiguous or non-host views.
Expand Down

0 comments on commit a51d0d4

Please sign in to comment.