diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b511fa501e8..61a26d592eee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1520,6 +1520,8 @@ if(HPX_WITH_APEX_NO_UPDATE) set(_hpx_apex_no_update NO_UPDATE) endif() if(HPX_WITH_APEX) + # We want to track parent dependencies + hpx_add_config_define(HPX_HAVE_THREAD_PARENT_REFERENCE) # handle APEX library include(GitExternal) git_external(apex diff --git a/hpx/runtime/threads/thread_data.hpp b/hpx/runtime/threads/thread_data.hpp index 6e2a89633f6f..faff986f493e 100644 --- a/hpx/runtime/threads/thread_data.hpp +++ b/hpx/runtime/threads/thread_data.hpp @@ -604,7 +604,13 @@ namespace hpx { namespace threads parent_locality_id_ = get_locality_id(); #endif #if defined(HPX_HAVE_APEX) - set_apex_data(apex_new_task(get_description())); + if (parent_thread_id_) { + set_apex_data(apex_new_task(get_description(), + parent_thread_id_.get()->get_apex_data())); + } else { + set_apex_data(apex_new_task(get_description(), + nullptr)); + } #endif HPX_ASSERT(init_data.stacksize != 0); HPX_ASSERT(coroutine_.is_ready()); diff --git a/hpx/util/apex.hpp b/hpx/util/apex.hpp index 4ccdd6f72f89..571171b2ae2e 100644 --- a/hpx/util/apex.hpp +++ b/hpx/util/apex.hpp @@ -36,21 +36,19 @@ namespace hpx { namespace util } inline void * apex_new_task( - thread_description const& description) + thread_description const& description, + void * parent_task) { if (description.kind() == thread_description::data_type_description) { - return (void*)apex::new_task(description.get_description()); + return (void*)apex::new_task(description.get_description(), + UINTMAX_MAX, (apex::task_wrapper*)parent_task); } else { - return (void*)apex::new_task(description.get_address()); + return (void*)apex::new_task(description.get_address(), + UINTMAX_MAX, (apex::task_wrapper*)parent_task); } } - inline void * apex_new_task(char const* name) - { - return (void*)apex::new_task(name); - } - inline void * apex_update_task(void * wrapper, thread_description const& description) { @@ -68,6 +66,8 @@ namespace hpx { namespace util return (void*)apex::update_task((apex::task_wrapper*)wrapper, name); } + /* This is a scoped object around task scheduling to measure the time + * spent executing hpx threads */ struct apex_wrapper { apex_wrapper(void* const data_ptr) : stopped(false), data_(nullptr)