From 3e89b550e8f3ba2379ebaa307e0e23470fcf58cf Mon Sep 17 00:00:00 2001 From: "Jonathan R. Madsen" Date: Thu, 21 Jul 2022 16:19:52 -0500 Subject: [PATCH] Add pthread category --- source/lib/omnitrace/library/components/fwd.hpp | 2 ++ .../library/components/pthread_create_gotcha.cpp | 14 +++++++------- source/lib/omnitrace/library/perfetto.hpp | 3 ++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/source/lib/omnitrace/library/components/fwd.hpp b/source/lib/omnitrace/library/components/fwd.hpp index c21014fa1..d8e6abd5d 100644 --- a/source/lib/omnitrace/library/components/fwd.hpp +++ b/source/lib/omnitrace/library/components/fwd.hpp @@ -70,6 +70,7 @@ TIMEMORY_DEFINE_NS_API(category, rocm_hip) TIMEMORY_DEFINE_NS_API(category, rocm_hsa) TIMEMORY_DEFINE_NS_API(category, rocm_smi) TIMEMORY_DEFINE_NS_API(category, rocm_roctx) +TIMEMORY_DEFINE_NS_API(category, pthread) TIMEMORY_DEFINE_NS_API(category, kokkos) TIMEMORY_DEFINE_NS_API(category, mpi) TIMEMORY_DEFINE_NS_API(category, ompt) @@ -88,6 +89,7 @@ TIMEMORY_DEFINE_NAME_TRAIT("rocm_smi", category::rocm_smi); TIMEMORY_DEFINE_NAME_TRAIT("rocm_roctx", category::rocm_roctx); TIMEMORY_DEFINE_NAME_TRAIT("sampling", category::sampling); TIMEMORY_DEFINE_NAME_TRAIT("thread_sampling", category::thread_sampling); +TIMEMORY_DEFINE_NAME_TRAIT("pthread", category::pthread); TIMEMORY_DEFINE_NAME_TRAIT("kokkos", category::kokkos); TIMEMORY_DEFINE_NAME_TRAIT("mpi", category::mpi); TIMEMORY_DEFINE_NAME_TRAIT("ompt", category::ompt); diff --git a/source/lib/omnitrace/library/components/pthread_create_gotcha.cpp b/source/lib/omnitrace/library/components/pthread_create_gotcha.cpp index 3b48dc02b..4b22d6fb4 100644 --- a/source/lib/omnitrace/library/components/pthread_create_gotcha.cpp +++ b/source/lib/omnitrace/library/components/pthread_create_gotcha.cpp @@ -324,7 +324,7 @@ int pthread_create_gotcha::operator()(pthread_t* thread, const pthread_attr_t* attr, void* (*start_routine)(void*), void* arg) const { - // auto _initial_thread_state = get_thread_state(); + auto _initial_thread_state = get_thread_state(); OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); bundle_t _bundle{ "pthread_create" }; auto _enable_sampling = pthread_gotcha::sampling_enabled_on_child_threads(); @@ -344,14 +344,14 @@ pthread_create_gotcha::operator()(pthread_t* thread, const pthread_attr_t* attr, if(!get_use_sampling() || !_enable_sampling) { auto* _obj = new wrapper(start_routine, arg, _enable_sampling, _tid, nullptr); - // if(_active && !_coverage && _enable_sampling && - // _initial_thread_state == ThreadState::Enabled) - // start_bundle(_bundle, audit::incoming{}, thread, attr, start_routine, arg); + if(_active && !_coverage && _enable_sampling && + _initial_thread_state == ThreadState::Enabled) + start_bundle(_bundle, audit::incoming{}, thread, attr, start_routine, arg); // create the thread auto _ret = (*m_wrappee)(thread, attr, &wrapper::wrap, static_cast(_obj)); - // if(_active && !_coverage && _enable_sampling && - // _initial_thread_state == ThreadState::Enabled) - // stop_bundle(_bundle, _tid, audit::outgoing{}, _ret); + if(_active && !_coverage && _enable_sampling && + _initial_thread_state == ThreadState::Enabled) + stop_bundle(_bundle, _tid, audit::outgoing{}, _ret); return _ret; } diff --git a/source/lib/omnitrace/library/perfetto.hpp b/source/lib/omnitrace/library/perfetto.hpp index 34db2c8f5..c237c3df8 100644 --- a/source/lib/omnitrace/library/perfetto.hpp +++ b/source/lib/omnitrace/library/perfetto.hpp @@ -79,8 +79,9 @@ perfetto::Category("process_kernel_cpu_time") \ .SetDescription("CPU time of functions executing in kernel-space in " \ "process in seconds (collected in background thread)"), \ - perfetto::Category("mpi").SetDescription("MPI regions"), \ + perfetto::Category("pthread").SetDescription("Pthread functions"), \ perfetto::Category("kokkos").SetDescription("Kokkos regions"), \ + perfetto::Category("mpi").SetDescription("MPI regions"), \ perfetto::Category("ompt").SetDescription("OpenMP Tools regions"), \ perfetto::Category("critical-trace").SetDescription("Combined critical traces"), \ perfetto::Category("host-critical-trace") \