Support sampling duration, sampling TIDs (#142)

- Sampling duration config values
  - OMNITRACE_SAMPLING_DURATION
  - OMNITRACE_PROCESS_SAMPLING_DURATION
  - Disables sampling after this time (in seconds) has elapsed 
- Sampling thread-id config values
  - OMNITRACE_SAMPLING_TIDS
  - OMNITRACE_SAMPLING_CPUTIME_TIDS
  - OMNITRACE_SAMPLING_REALTIME_TIDS
  - Allows user to select certain threads for sampling
- Miscellaneous
  - Tweaked the finalization verbosity messages
  - moved sampling-on-child-threads into runtime.hpp and runtime.cpp
  - fixed submodule dyninst header install

[ROCm/rocprofiler-systems commit: e67afd33eb]
This commit is contained in:
Jonathan R. Madsen
2022-08-31 06:29:19 -05:00
committed by GitHub
parent cbdc7cad4b
commit 2ef9dfd002
17 changed files with 390 additions and 155 deletions
@@ -52,6 +52,26 @@
namespace omnitrace
{
namespace
{
auto&
get_sampling_on_child_threads_history(int64_t _idx = utility::get_thread_index())
{
static auto _v = utility::get_filled_array<OMNITRACE_MAX_THREADS>(
[]() { return utility::get_reserved_vector<bool>(32); });
return _v.at(_idx);
}
bool&
sampling_on_child_threads()
{
static thread_local bool _v = get_sampling_on_child_threads_history().empty()
? false
: get_sampling_on_child_threads_history().back();
return _v;
}
} // namespace
int
get_realtime_signal()
{
@@ -254,4 +274,40 @@ pop_thread_state()
}
return get_thread_state();
}
bool
sampling_enabled_on_child_threads()
{
return sampling_on_child_threads();
}
bool
push_enable_sampling_on_child_threads(bool _v)
{
bool _last = sampling_on_child_threads();
sampling_on_child_threads() = _v;
auto& _hist = get_sampling_on_child_threads_history();
_hist.emplace_back(_last);
return _last;
}
bool
pop_enable_sampling_on_child_threads()
{
auto& _hist = get_sampling_on_child_threads_history();
if(!_hist.empty())
{
bool _restored = _hist.back();
_hist.pop_back();
sampling_on_child_threads() = _restored;
}
return sampling_on_child_threads();
}
void
set_sampling_on_all_future_threads(bool _v)
{
for(size_t i = 0; i < max_supported_threads; ++i)
get_sampling_on_child_threads_history(i).emplace_back(_v);
}
} // namespace omnitrace