Autonomic Performance Environment for eXascale (APEX)  2.3.1
task_wrapper.hpp
1 /*
2  * Copyright (c) 2014-2020 Kevin Huck
3  * Copyright (c) 2014-2020 University of Oregon
4  *
5  * Distributed under the Boost Software License, Version 1.0. (See accompanying
6  * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7  */
8 
9 #pragma once
10 
11 namespace apex {
12 struct task_wrapper;
13 }
14 
15 #ifdef APEX_HAVE_HPX_CONFIG
16 #include <hpx/config.hpp>
17 #include <hpx/modules/threading_base.hpp>
18 #endif
19 #include "task_identifier.hpp"
20 #include "profiler.hpp"
21 #include <vector>
22 #include <memory>
23 #include <string>
24 #include <unordered_set>
25 
26 namespace apex {
27 
31 #ifdef APEX_HAVE_HPX_CONFIG
32 struct task_wrapper : public hpx::util::external_timer::task_wrapper {
33 #else
34 struct task_wrapper {
35 #endif
36 
39  task_identifier * task_id;
43  profiler * prof;
47  uint64_t guid;
51  uint64_t parent_guid;
55  std::shared_ptr<task_wrapper> parent;
60  std::vector<profiler*> data_ptr;
66  task_identifier* alias;
70  task_wrapper(void) :
71  task_id(nullptr),
72  prof(nullptr),
73  guid(0ull),
74  parent_guid(0ull),
75  parent(nullptr),
76  alias(nullptr)
77  { }
82  inline task_identifier * get_task_id(void) {
83  if (alias != nullptr) {
84  return alias;
85  }
86  return task_id;
87  }
92  static std::shared_ptr<task_wrapper> & get_apex_main_wrapper(void) {
93  static std::shared_ptr<task_wrapper> tt_ptr(nullptr);
94  static std::mutex mtx;
95  if (tt_ptr.get() == nullptr) {
96  mtx.lock();
97  if (tt_ptr.get() == nullptr) {
98  const std::string apex_main_str("APEX MAIN");
99  tt_ptr = std::make_shared<task_wrapper>();
100  tt_ptr->task_id = task_identifier::get_task_id(apex_main_str);
101  }
102  mtx.unlock();
103  }
104  return tt_ptr;
105  }
106 }; // struct task_wrapper
107 
108 } // namespace apex
apex::task_wrapper::prof
profiler * prof
A pointer to the active profiler object timing this task.
Definition: task_wrapper.hpp:43
apex::task_wrapper::data_ptr
std::vector< profiler * > data_ptr
Internal usage, used to manage HPX direct actions when their parent task is yielded by the runtime.
Definition: task_wrapper.hpp:60
apex::task_wrapper::get_apex_main_wrapper
static std::shared_ptr< task_wrapper > & get_apex_main_wrapper(void)
Static method to get a pre-defined task_wrapper around "main".
Definition: task_wrapper.hpp:92
apex::task_wrapper::task_id
task_identifier * task_id
A pointer to the task_identifier for this task_wrapper.
Definition: task_wrapper.hpp:39
apex::task_wrapper
A wrapper around APEX tasks.
Definition: task_wrapper.hpp:34
apex
The main APEX namespace.
Definition: apex_api.hpp:50
apex::task_wrapper::task_wrapper
task_wrapper(void)
Constructor.
Definition: task_wrapper.hpp:70
apex::task_wrapper::guid
uint64_t guid
An internally generated GUID for this task.
Definition: task_wrapper.hpp:47
apex::task_wrapper::parent
std::shared_ptr< task_wrapper > parent
A managed pointer to the parent task_wrapper for this task.
Definition: task_wrapper.hpp:55
apex::task_wrapper::get_task_id
task_identifier * get_task_id(void)
Get the task_identifier for this task_wrapper.
Definition: task_wrapper.hpp:82
apex::task_wrapper::parent_guid
uint64_t parent_guid
An internally generated GUID for the parent task of this task.
Definition: task_wrapper.hpp:51
apex::task_wrapper::alias
task_identifier * alias
If the task changes names after creation (due to the application of an annotation) then the alias bec...
Definition: task_wrapper.hpp:66