Handle OMNITRACE_ENABLED + minor updates (#78)
- handle OMNITRACE_ENABLED=OFF by disabling everything
- use set_data to get wrappee in pthread_create_gotcha
- clear roctracer_data storage if roctracer not initialized
[ROCm/rocprofiler-systems commit: f82845388a]
This commit is contained in:
committed by
GitHub
parent
e292002235
commit
ddac1e4534
+10
-5
@@ -29,10 +29,9 @@
|
||||
#include "library/runtime.hpp"
|
||||
#include "library/sampling.hpp"
|
||||
#include "library/thread_data.hpp"
|
||||
#include "timemory/components/timing/wall_clock.hpp"
|
||||
|
||||
#include <bits/stdint-intn.h>
|
||||
#include <timemory/backends/threading.hpp>
|
||||
#include <timemory/components/timing/wall_clock.hpp>
|
||||
#include <timemory/sampling/allocator.hpp>
|
||||
#include <timemory/utility/types.hpp>
|
||||
|
||||
@@ -203,6 +202,7 @@ void
|
||||
pthread_create_gotcha::configure()
|
||||
{
|
||||
pthread_create_gotcha_t::get_initializer() = []() {
|
||||
if(!tim::settings::enabled()) return;
|
||||
pthread_create_gotcha_t::template configure<
|
||||
0, int, pthread_t*, const pthread_attr_t*, void* (*) (void*), void*>(
|
||||
"pthread_create");
|
||||
@@ -257,6 +257,12 @@ pthread_create_gotcha::shutdown(int64_t _tid)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
pthread_create_gotcha::set_data(wrappee_t _v)
|
||||
{
|
||||
m_wrappee = _v;
|
||||
}
|
||||
|
||||
// pthread_create
|
||||
int
|
||||
pthread_create_gotcha::operator()(pthread_t* thread, const pthread_attr_t* attr,
|
||||
@@ -282,8 +288,7 @@ pthread_create_gotcha::operator()(pthread_t* thread, const pthread_attr_t* attr,
|
||||
{
|
||||
auto* _obj = new wrapper(start_routine, arg, _enable_sampling, _tid, nullptr);
|
||||
// create the thread
|
||||
auto _ret =
|
||||
::pthread_create(thread, attr, &wrapper::wrap, static_cast<void*>(_obj));
|
||||
auto _ret = (*m_wrappee)(thread, attr, &wrapper::wrap, static_cast<void*>(_obj));
|
||||
return _ret;
|
||||
}
|
||||
|
||||
@@ -300,7 +305,7 @@ pthread_create_gotcha::operator()(pthread_t* thread, const pthread_attr_t* attr,
|
||||
auto* _wrap = new wrapper(start_routine, arg, _enable_sampling, _tid, &_promise);
|
||||
|
||||
// create the thread
|
||||
auto _ret = ::pthread_create(thread, attr, &wrapper::wrap, static_cast<void*>(_wrap));
|
||||
auto _ret = (*m_wrappee)(thread, attr, &wrapper::wrap, static_cast<void*>(_wrap));
|
||||
|
||||
// wait for thread to set promise
|
||||
OMNITRACE_DEBUG("waiting for child to signal it is setup...\n");
|
||||
|
||||
+8
-1
@@ -34,9 +34,11 @@ namespace omnitrace
|
||||
{
|
||||
struct pthread_create_gotcha : tim::component::base<pthread_create_gotcha, void>
|
||||
{
|
||||
using routine_t = void* (*) (void*);
|
||||
using wrappee_t = int (*)(pthread_t*, const pthread_attr_t*, routine_t, void*);
|
||||
|
||||
struct wrapper
|
||||
{
|
||||
using routine_t = void* (*) (void*);
|
||||
using promise_t = std::promise<void>;
|
||||
|
||||
wrapper(routine_t _routine, void* _arg, bool, int64_t, promise_t*);
|
||||
@@ -68,6 +70,11 @@ struct pthread_create_gotcha : tim::component::base<pthread_create_gotcha, void>
|
||||
|
||||
static auto& get_execution_time(int64_t _tid = threading::get_id());
|
||||
static bool is_valid_execution_time(int64_t _tid, uint64_t _ts);
|
||||
|
||||
void set_data(wrappee_t);
|
||||
|
||||
private:
|
||||
wrappee_t m_wrappee = &pthread_create;
|
||||
};
|
||||
|
||||
inline auto&
|
||||
|
||||
@@ -166,7 +166,12 @@ void
|
||||
roctracer::shutdown()
|
||||
{
|
||||
auto_lock_t _lk{ type_mutex<roctracer>() };
|
||||
if(!roctracer_is_setup()) return;
|
||||
if(!roctracer_is_setup())
|
||||
{
|
||||
if(!roctracer_is_init() && tim::storage<comp::roctracer_data>::instance())
|
||||
tim::storage<comp::roctracer_data>::instance()->reset();
|
||||
return;
|
||||
}
|
||||
roctracer_is_setup() = false;
|
||||
|
||||
OMNITRACE_VERBOSE_F(1, "shutting down roctracer...\n");
|
||||
|
||||
+9
@@ -853,6 +853,13 @@ hip_activity_callback(const char* begin, const char* end, void*)
|
||||
}
|
||||
}
|
||||
|
||||
bool&
|
||||
roctracer_is_init()
|
||||
{
|
||||
static bool _v = tim::get_env("OMNITRACE_ROCTRACER_IS_INIT", false);
|
||||
return _v;
|
||||
}
|
||||
|
||||
bool&
|
||||
roctracer_is_setup()
|
||||
{
|
||||
@@ -892,7 +899,9 @@ extern "C"
|
||||
const char* const* failed_tool_names)
|
||||
{
|
||||
if(!tim::get_env("OMNITRACE_INIT_TOOLING", true)) return true;
|
||||
if(!tim::settings::enabled()) return true;
|
||||
|
||||
roctracer_is_init() = true;
|
||||
pthread_gotcha::push_enable_sampling_on_child_threads(false);
|
||||
OMNITRACE_CONDITIONAL_BASIC_PRINT_F(get_debug_env() || get_verbose_env() > 0,
|
||||
"\n");
|
||||
|
||||
+3
@@ -71,6 +71,9 @@ hip_api_callback(uint32_t domain, uint32_t cid, const void* callback_data, void*
|
||||
void
|
||||
hip_activity_callback(const char* begin, const char* end, void*);
|
||||
|
||||
bool&
|
||||
roctracer_is_init();
|
||||
|
||||
bool&
|
||||
roctracer_is_setup();
|
||||
|
||||
|
||||
@@ -604,6 +604,22 @@ configure_mode_settings()
|
||||
// recycle all subsequent thread ids
|
||||
threading::recycle_ids() =
|
||||
tim::get_env<bool>("OMNITRACE_RECYCLE_TIDS", !get_use_sampling());
|
||||
|
||||
if(!get_config()->get_enabled())
|
||||
{
|
||||
_set("OMNITRACE_USE_PERFETTO", false);
|
||||
_set("OMNITRACE_USE_TIMEMORY", false);
|
||||
_set("OMNITRACE_USE_ROCM_SMI", false);
|
||||
_set("OMNITRACE_USE_ROCTRACER", false);
|
||||
_set("OMNITRACE_USE_KOKKOSP", false);
|
||||
_set("OMNITRACE_USE_OMPT", false);
|
||||
_set("OMNITRACE_USE_SAMPLING", false);
|
||||
_set("OMNITRACE_USE_PROCESS_SAMPLING", false);
|
||||
_set("OMNITRACE_USE_CODE_COVERAGE", false);
|
||||
_set("OMNITRACE_CRITICAL_TRACE", false);
|
||||
set_setting_value("OMNITRACE_TIMEMORY_COMPONENTS", std::string{});
|
||||
set_setting_value("OMNITRACE_PAPI_EVENTS", std::string{});
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -61,6 +61,7 @@ bool _init_toolset_off = (trait::runtime_enabled<ompt_toolset_t>::set(false),
|
||||
void
|
||||
setup()
|
||||
{
|
||||
if(!tim::settings::enabled()) return;
|
||||
trait::runtime_enabled<ompt_toolset_t>::set(true);
|
||||
trait::runtime_enabled<ompt_context_t>::set(true);
|
||||
comp::user_ompt_bundle::global_init();
|
||||
|
||||
Reference in New Issue
Block a user