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:
zatwierdzone przez
GitHub
rodzic
cbdc7cad4b
commit
2ef9dfd002
+2
-4
@@ -22,7 +22,6 @@
|
||||
|
||||
#include "library/components/pthread_create_gotcha.hpp"
|
||||
#include "library/components/category_region.hpp"
|
||||
#include "library/components/pthread_gotcha.hpp"
|
||||
#include "library/components/roctracer.hpp"
|
||||
#include "library/config.hpp"
|
||||
#include "library/debug.hpp"
|
||||
@@ -213,9 +212,8 @@ pthread_create_gotcha::wrapper::operator()() const
|
||||
if(m_enable_sampling)
|
||||
{
|
||||
_is_sampling = true;
|
||||
pthread_gotcha::push_enable_sampling_on_child_threads(false);
|
||||
OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false);
|
||||
_signals = sampling::setup();
|
||||
pthread_gotcha::pop_enable_sampling_on_child_threads();
|
||||
sampling::unblock_signals();
|
||||
}
|
||||
}
|
||||
@@ -336,7 +334,7 @@ pthread_create_gotcha::operator()(pthread_t* thread, const pthread_attr_t* attr,
|
||||
auto _active = (get_state() == ::omnitrace::State::Active && !_disabled);
|
||||
auto _coverage = (get_mode() == Mode::Coverage);
|
||||
auto _use_sampling = get_use_sampling();
|
||||
auto _sample_child = pthread_gotcha::sampling_enabled_on_child_threads();
|
||||
auto _sample_child = sampling_enabled_on_child_threads();
|
||||
auto _tid = utility::get_thread_index();
|
||||
auto _use_bundle = (_active && !_coverage);
|
||||
const auto& _info = thread_info::init(!_active || !_sample_child || _disabled);
|
||||
|
||||
-53
@@ -69,14 +69,6 @@ namespace
|
||||
using bundle_t = tim::lightweight_tuple<component::pthread_create_gotcha_t,
|
||||
component::pthread_mutex_gotcha_t>;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
auto&
|
||||
get_bundle()
|
||||
{
|
||||
@@ -112,51 +104,6 @@ pthread_gotcha::shutdown()
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
pthread_gotcha::sampling_enabled_on_child_threads()
|
||||
{
|
||||
return sampling_on_child_threads();
|
||||
}
|
||||
|
||||
bool
|
||||
pthread_gotcha::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
|
||||
pthread_gotcha::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
|
||||
pthread_gotcha::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);
|
||||
}
|
||||
|
||||
bool&
|
||||
pthread_gotcha::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;
|
||||
}
|
||||
|
||||
void
|
||||
pthread_gotcha::start()
|
||||
{
|
||||
|
||||
-15
@@ -42,22 +42,7 @@ struct pthread_gotcha : tim::component::base<pthread_gotcha, void>
|
||||
static void configure();
|
||||
static void shutdown();
|
||||
|
||||
// query current value
|
||||
static bool sampling_enabled_on_child_threads();
|
||||
|
||||
// use this to disable sampling in a region (e.g. right before thread creation)
|
||||
static bool push_enable_sampling_on_child_threads(bool _v);
|
||||
|
||||
// use this to restore previous setting
|
||||
static bool pop_enable_sampling_on_child_threads();
|
||||
|
||||
// make sure every newly created thead starts with this value
|
||||
static void set_sampling_on_all_future_threads(bool _v);
|
||||
|
||||
static void start();
|
||||
static void stop();
|
||||
|
||||
private:
|
||||
static bool& sampling_on_child_threads();
|
||||
};
|
||||
} // namespace omnitrace
|
||||
|
||||
+1
-2
@@ -22,7 +22,6 @@
|
||||
|
||||
#include "library/components/pthread_mutex_gotcha.hpp"
|
||||
#include "library/components/category_region.hpp"
|
||||
#include "library/components/pthread_gotcha.hpp"
|
||||
#include "library/config.hpp"
|
||||
#include "library/critical_trace.hpp"
|
||||
#include "library/debug.hpp"
|
||||
@@ -293,7 +292,7 @@ pthread_mutex_gotcha::is_disabled()
|
||||
{
|
||||
return (get_state() != ::omnitrace::State::Active ||
|
||||
get_thread_state() != ThreadState::Enabled ||
|
||||
(get_use_sampling() && !pthread_gotcha::sampling_enabled_on_child_threads()));
|
||||
(get_use_sampling() && !sampling_enabled_on_child_threads()));
|
||||
}
|
||||
} // namespace component
|
||||
} // namespace omnitrace
|
||||
|
||||
+2
-4
@@ -22,13 +22,13 @@
|
||||
|
||||
#include "library/components/roctracer.hpp"
|
||||
#include "library/common.hpp"
|
||||
#include "library/components/pthread_gotcha.hpp"
|
||||
#include "library/config.hpp"
|
||||
#include "library/debug.hpp"
|
||||
#include "library/defines.hpp"
|
||||
#include "library/dynamic_library.hpp"
|
||||
#include "library/redirect.hpp"
|
||||
#include "library/roctracer.hpp"
|
||||
#include "library/runtime.hpp"
|
||||
#include "library/sampling.hpp"
|
||||
#include "library/thread_data.hpp"
|
||||
|
||||
@@ -121,7 +121,7 @@ roctracer::setup()
|
||||
roctracer_is_setup() = true;
|
||||
|
||||
OMNITRACE_VERBOSE_F(1, "setting up roctracer...\n");
|
||||
pthread_gotcha::push_enable_sampling_on_child_threads(false);
|
||||
OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false);
|
||||
|
||||
dynamic_library _amdhip64{ "OMNITRACE_ROCTRACER_LIBAMDHIP64",
|
||||
find_library_path("libamdhip64.so",
|
||||
@@ -169,8 +169,6 @@ roctracer::setup()
|
||||
for(auto& itr : roctracer_setup_routines())
|
||||
itr.second();
|
||||
|
||||
pthread_gotcha::pop_enable_sampling_on_child_threads();
|
||||
|
||||
OMNITRACE_VERBOSE_F(1, "roctracer is setup\n");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user