Fix the main library stop routine for timemory (#39)

* Fix the main library stop routine for timemory

- the main pop_timemory function was popping too many calls
- this primarily affected recursive calls

* Lengthen the timeout for the Configure CMake step

* Fix python tests

- new validate-timemory-json.py script

* Documentation update

- Call-counts in timemory output examples in documentation were affected by the changes

* Fix the per-thread metrics during finalization

- pthread_create_mutex starts/stops the per-thread data
- removed unintentional continue statement

* Docs tweaks

* Fix lap counter on per-thread metrics

[ROCm/rocprofiler-systems commit: a142b2029d]
This commit is contained in:
Jonathan R. Madsen
2022-06-13 15:57:44 -05:00
committed by GitHub
parent ad9fd4b7ec
commit aeab36501a
12 changed files with 209 additions and 102 deletions
@@ -696,8 +696,10 @@ omnitrace_init_tooling_hidden()
if(get_state() != State::Finalized)
{
if(get_use_sampling()) sampling::shutdown();
if(thread_data<omnitrace_thread_bundle_t>::instance())
thread_data<omnitrace_thread_bundle_t>::instance()->stop();
auto& _thr_bundle = thread_data<omnitrace_thread_bundle_t>::instance();
if(_thr_bundle && _thr_bundle->get<comp::wall_clock>() &&
_thr_bundle->get<comp::wall_clock>()->get_is_running())
_thr_bundle->stop();
}
} };
(void) _thread_setup;
@@ -744,6 +746,7 @@ omnitrace_init_tooling_hidden()
_data.allocator.destroy(_v);
_data.allocator.deallocate(_v, 1);
_data.bundles.erase(_data.bundles.begin() + (i - 1));
break;
}
}
};
@@ -1122,7 +1125,6 @@ omnitrace_finalize_hidden(void)
if(itr && itr->get<comp::wall_clock>() &&
!itr->get<comp::wall_clock>()->get_is_running())
{
continue;
std::string _msg = JOIN("", *itr);
auto _pos = _msg.find(">>> ");
if(_pos != std::string::npos) _msg = _msg.substr(_pos + 5);
@@ -109,6 +109,8 @@ pthread_create_gotcha::wrapper::wrapper(routine_t _routine, void* _arg,
void*
pthread_create_gotcha::wrapper::operator()() const
{
using thread_bundle_data_t = thread_data<omnitrace_thread_bundle_t>;
if(is_shutdown && *is_shutdown)
{
if(m_promise) m_promise->set_value();
@@ -134,6 +136,10 @@ pthread_create_gotcha::wrapper::operator()() const
if(_tid >= 0)
{
get_execution_time(_tid)->second = comp::wall_clock::record();
auto& _thr_bundle = thread_bundle_data_t::instance();
if(_thr_bundle && _thr_bundle->get<comp::wall_clock>() &&
_thr_bundle->get<comp::wall_clock>()->get_is_running())
_thr_bundle->stop();
pthread_create_gotcha::shutdown(_tid);
}
set_thread_state(ThreadState::Completed);
@@ -146,6 +152,13 @@ pthread_create_gotcha::wrapper::operator()() const
{
_tid = threading::get_id();
threading::set_thread_name(TIMEMORY_JOIN(" ", "Thread", _tid).c_str());
if(!thread_bundle_data_t::instances().at(_tid))
{
thread_data<omnitrace_thread_bundle_t>::construct(
TIMEMORY_JOIN("", get_exe_name(), "/thread-", threading::get_id()),
quirk::config<quirk::auto_start>{});
thread_bundle_data_t::instances().at(_tid)->start();
}
if(bundles && bundles_mutex)
{
std::unique_lock<std::mutex> _lk{ *bundles_mutex };