Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deregister BArena from Profiling in Arena::Finalize #4164

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Src/Base/AMReX_Arena.H
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ public:
*/
void registerForProfiling (const std::string& memory_name);

/**
* \brief Remove this Arena from the list of Arenas that are profiled by TinyProfiler.
* This is equivalent to destructing and re-constructing the Arena
*/
void deregisterFromProfiling ();

#ifdef AMREX_USE_GPU
//! Is this GPU stream ordered memory allocator?
[[nodiscard]] virtual bool isStreamOrderedArena () const { return false; }
Expand Down
15 changes: 15 additions & 0 deletions Src/Base/AMReX_Arena.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ Arena::registerForProfiling ([[maybe_unused]] const std::string& memory_name)
#endif
}

void
Arena::deregisterFromProfiling ()
{
#ifdef AMREX_TINY_PROFILING
if (m_profiler.m_do_profiling) {
TinyProfiler::DeregisterArena(m_profiler.m_profiling_stats);
m_profiler.m_do_profiling = false;
m_profiler.m_profiling_stats.clear();
m_profiler.m_currently_allocated.clear();
}
#endif
}

std::size_t
Arena::align (std::size_t s)
{
Expand Down Expand Up @@ -588,6 +601,8 @@ Arena::Finalize ()
delete the_cpu_arena;
the_cpu_arena = nullptr;
}

The_BArena()->deregisterFromProfiling();
}

Arena*
Expand Down
Loading