From 3b22ae9021117927f42e3ae0d8876933fb5239be Mon Sep 17 00:00:00 2001 From: Kevin Huck Date: Thu, 22 Mar 2018 14:56:32 -0700 Subject: [PATCH] Adding parent dependencies for hpx threads. --- CMakeLists.txt | 2 ++ hpx/runtime/threads/thread_data.hpp | 8 +++++++- hpx/util/apex.hpp | 16 ++++++++-------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a66d4d69104..2056630209e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1535,6 +1535,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 6e2a89633f6..faff986f493 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 4ccdd6f72f8..571171b2ae2 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)