From a704117f7aa1273357b77c1b6abc03917e5d09ec Mon Sep 17 00:00:00 2001 From: Kevin Huck Date: Mon, 20 May 2024 12:35:13 -0700 Subject: [PATCH] Minor changes to fix thread tracing When threads are created before main (looking at you, CUDA), or are not terminated before main terminates (looking at you, Iris), we need to make sure that the registered new threads have a thread ID. To do that, the top level timers for those threads should have synchronous start/stop events, otherwise they get a single "unified" event at the end with the thread ID belonging to the main thread (because it is the one cleaning up a the end). --- src/apex/apex.cpp | 1 + src/wrappers/pthread_wrapper_internal.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/apex/apex.cpp b/src/apex/apex.cpp index a01588e9..f3066179 100644 --- a/src/apex/apex.cpp +++ b/src/apex/apex.cpp @@ -1925,6 +1925,7 @@ void register_thread(const std::string &name, std::shared_ptr twp = new_task(task_name, UINTMAX_MAX, (parent == nullptr ? task_wrapper::get_apex_main_wrapper() : parent)); + twp->explicit_trace_start = true; start(twp); //printf("New thread: %p\n", &(*twp)); thread_instance::set_top_level_timer(twp); diff --git a/src/wrappers/pthread_wrapper_internal.cpp b/src/wrappers/pthread_wrapper_internal.cpp index 26cf174c..92ea2da8 100644 --- a/src/wrappers/pthread_wrapper_internal.cpp +++ b/src/wrappers/pthread_wrapper_internal.cpp @@ -108,6 +108,7 @@ class apex_wrapper { apex::register_thread("APEX pthread wrapper", parent); //_twp = apex::new_task((apex_function_address)func, UINTMAX_MAX, parent); _twp = apex::new_task((apex_function_address)func); + _twp->explicit_trace_start = true; } ~apex_wrapper() { this->stop();