Deprecate omnitrace use thread sampling (#68)
* Deprecate OMNITRACE_USE_THREAD_SAMPLING * Reworked config based on OMNITRACE_MODE - config::set_default_setting_value(...) - config::get_mode() is now dynamically deduced - moved tweaking defaults from library.cpp to config::configure_mode_settings(...) - timemory submodule update fixing vsetting issue * runtime.md update * revert accidental lambda name change * Reintroduce (deprecated) OMNITRACE_ROCM_SMI_DEVICES - add handle_deprecated_setting(...) for this deprecated setting
This commit is contained in:
committed by
GitHub
parent
cfa16cbe2f
commit
27e4e82376
@@ -36,10 +36,10 @@
|
||||
#include "library/defines.hpp"
|
||||
#include "library/gpu.hpp"
|
||||
#include "library/ompt.hpp"
|
||||
#include "library/process_sampler.hpp"
|
||||
#include "library/ptl.hpp"
|
||||
#include "library/sampling.hpp"
|
||||
#include "library/thread_data.hpp"
|
||||
#include "library/thread_sampler.hpp"
|
||||
#include "library/timemory.hpp"
|
||||
|
||||
#include <timemory/utility/procfs/maps.hpp>
|
||||
@@ -64,8 +64,8 @@ struct user_regions
|
||||
using omni_functors = omnitrace::component::functors<omni_regions>;
|
||||
using user_functors = omnitrace::component::functors<user_regions>;
|
||||
|
||||
TIMEMORY_DEFINE_NAME_TRAIT("host", omni_functors);
|
||||
TIMEMORY_DEFINE_NAME_TRAIT("user", user_functors);
|
||||
TIMEMORY_DEFINE_NAME_TRAIT("host", omni_functors)
|
||||
TIMEMORY_DEFINE_NAME_TRAIT("user", user_functors)
|
||||
|
||||
TIMEMORY_INVOKE_PREINIT(omni_functors)
|
||||
TIMEMORY_INVOKE_PREINIT(user_functors)
|
||||
@@ -117,6 +117,9 @@ ensure_finalization(bool _static_init = false)
|
||||
// see:
|
||||
// https://github.com/ROCm-Developer-Tools/roctracer/issues/22#issuecomment-572814465
|
||||
tim::set_env("HSA_ENABLE_INTERRUPT", "0", 0);
|
||||
#if defined(OMNITRACE_USE_ROCTRACER) && OMNITRACE_USE_ROCTRACER > 0
|
||||
tim::set_env("HSA_TOOLS_LIB", "libomnitrace.so", 0);
|
||||
#endif
|
||||
}
|
||||
return scope::destructor{ []() { omnitrace_finalize_hidden(); } };
|
||||
}
|
||||
@@ -428,7 +431,6 @@ omnitrace_init_library_hidden()
|
||||
(void) _tid;
|
||||
|
||||
static bool _once = false;
|
||||
auto _mode = get_mode();
|
||||
auto _debug_init = get_debug_init();
|
||||
|
||||
OMNITRACE_CONDITIONAL_BASIC_PRINT_F(_debug_init, "State is %s...\n",
|
||||
@@ -472,68 +474,16 @@ omnitrace_init_library_hidden()
|
||||
if(_debug_init) config::set_setting_value("OMNITRACE_DEBUG", _debug_value);
|
||||
} };
|
||||
|
||||
OMNITRACE_DEBUG_F("\n");
|
||||
|
||||
// below will effectively do:
|
||||
// get_cpu_cid_stack(0)->emplace_back(-1);
|
||||
// plus query some env variables
|
||||
add_critical_trace<Device::CPU, Phase::NONE>(0, -1, 0, 0, 0, 0, 0, 0, 0, -1, 0);
|
||||
|
||||
if(gpu::device_count() == 0 && get_state() != State::Active)
|
||||
{
|
||||
OMNITRACE_DEBUG_F(
|
||||
"No HIP devices were found: disabling roctracer and rocm_smi...\n");
|
||||
get_use_roctracer() = false;
|
||||
get_use_rocm_smi() = false;
|
||||
}
|
||||
|
||||
if(_mode == Mode::Sampling)
|
||||
{
|
||||
OMNITRACE_CONDITIONAL_PRINT_F(get_verbose() >= 0,
|
||||
"Disabling critical trace in %s mode...\n",
|
||||
std::to_string(_mode).c_str());
|
||||
get_use_critical_trace() = false;
|
||||
get_use_sampling() = tim::get_env("OMNITRACE_USE_SAMPLING", true);
|
||||
get_use_thread_sampling() =
|
||||
tim::get_env("OMNITRACE_USE_THREAD_SAMPLING", get_use_sampling());
|
||||
}
|
||||
else if(_mode == Mode::Coverage)
|
||||
{
|
||||
for(auto&& itr :
|
||||
{ "USE_SAMPLING", "USE_THREAD_SAMPLING", "CRITICAL_TRACE", "USE_ROCTRACER",
|
||||
"USE_ROCM_SMI", "USE_PERFETTO", "USE_TIMEMORY", "USE_KOKKOSP", "USE_OMPT" })
|
||||
{
|
||||
auto _name = JOIN('_', "OMNITRACE", itr);
|
||||
if(!config::set_setting_value(_name, false))
|
||||
{
|
||||
OMNITRACE_VERBOSE_F(4, "No configuration setting named '%s'",
|
||||
_name.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tim::trait::runtime_enabled<comp::roctracer>::set(get_use_roctracer());
|
||||
tim::trait::runtime_enabled<comp::roctracer_data>::set(get_use_roctracer() &&
|
||||
get_use_timemory());
|
||||
|
||||
get_instrumentation_interval() = std::max<size_t>(get_instrumentation_interval(), 1);
|
||||
|
||||
if(get_use_kokkosp())
|
||||
{
|
||||
auto _force = 0;
|
||||
auto _current_kokkosp_lib = tim::get_env<std::string>("KOKKOS_PROFILE_LIBRARY");
|
||||
if(std::regex_search(_current_kokkosp_lib, std::regex{ "libtimemory\\." }))
|
||||
_force = 1;
|
||||
tim::set_env("KOKKOS_PROFILE_LIBRARY", "libomnitrace.so", _force);
|
||||
}
|
||||
|
||||
// recycle all subsequent thread ids
|
||||
threading::recycle_ids() =
|
||||
tim::get_env<bool>("OMNITRACE_RECYCLE_TIDS", !get_use_sampling());
|
||||
|
||||
#if defined(OMNITRACE_USE_ROCTRACER) && OMNITRACE_USE_ROCTRACER > 0
|
||||
tim::set_env("HSA_TOOLS_LIB", "libomnitrace.so", 0);
|
||||
#endif
|
||||
OMNITRACE_CONDITIONAL_BASIC_PRINT_F(_debug_init, "\n");
|
||||
}
|
||||
|
||||
//======================================================================================//
|
||||
@@ -582,10 +532,10 @@ omnitrace_init_tooling_hidden()
|
||||
// if set to finalized, don't continue
|
||||
if(get_state() > State::Active) return;
|
||||
if(config::get_trace_thread_locks()) pthread_mutex_gotcha::validate();
|
||||
if(get_use_thread_sampling())
|
||||
if(get_use_process_sampling())
|
||||
{
|
||||
pthread_gotcha::push_enable_sampling_on_child_threads(false);
|
||||
thread_sampler::setup();
|
||||
process_sampler::setup();
|
||||
pthread_gotcha::pop_enable_sampling_on_child_threads();
|
||||
}
|
||||
if(get_use_sampling())
|
||||
@@ -929,24 +879,6 @@ omnitrace_init_hidden(const char* _mode, bool _is_binary_rewrite, const char* _a
|
||||
tim::set_env("OMNITRACE_MODE", _mode, 0);
|
||||
config::is_binary_rewrite() = _is_binary_rewrite;
|
||||
|
||||
if(get_mode() == Mode::Coverage)
|
||||
{
|
||||
tim::set_env("OMNITRACE_USE_PERFETTO", "OFF", 0);
|
||||
tim::set_env("OMNITRACE_USE_TIMEMORY", "OFF", 0);
|
||||
tim::set_env("OMNITRACE_USE_KOKKOSP", "OFF", 0);
|
||||
tim::set_env("OMNITRACE_USE_SAMPLING", "OFF", 0);
|
||||
tim::set_env("OMNITRACE_USE_ROCTRACER", "OFF", 0);
|
||||
tim::set_env("OMNITRACE_USE_ROCM_SMI", "OFF", 0);
|
||||
}
|
||||
|
||||
// set OMNITRACE_USE_SAMPLING to ON by default if mode is sampling
|
||||
tim::set_env("OMNITRACE_USE_SAMPLING", (get_mode() == Mode::Sampling) ? "ON" : "OFF",
|
||||
0);
|
||||
|
||||
// default to KokkosP enabled when sampling, otherwise default to off
|
||||
tim::set_env("OMNITRACE_USE_KOKKOSP", (get_mode() == Mode::Sampling) ? "ON" : "OFF",
|
||||
0);
|
||||
|
||||
if(!_set_mpi_called)
|
||||
{
|
||||
_start_gotcha_callback = []() { get_gotcha_bundle()->start(); };
|
||||
@@ -1083,10 +1015,10 @@ omnitrace_finalize_hidden(void)
|
||||
OMNITRACE_VERBOSE_F(1, "Shutting down pthread gotcha...\n");
|
||||
pthread_gotcha::shutdown();
|
||||
|
||||
if(get_use_thread_sampling())
|
||||
if(get_use_process_sampling())
|
||||
{
|
||||
OMNITRACE_VERBOSE_F(1, "Shutting down background sampler...\n");
|
||||
thread_sampler::shutdown();
|
||||
process_sampler::shutdown();
|
||||
}
|
||||
|
||||
if(get_use_roctracer())
|
||||
@@ -1185,10 +1117,10 @@ omnitrace_finalize_hidden(void)
|
||||
tasking::join();
|
||||
}
|
||||
|
||||
if(get_use_thread_sampling())
|
||||
if(get_use_process_sampling())
|
||||
{
|
||||
OMNITRACE_VERBOSE_F(1, "Post-processing the system-level samples...\n");
|
||||
thread_sampler::post_process();
|
||||
process_sampler::post_process();
|
||||
}
|
||||
|
||||
if(get_use_critical_trace())
|
||||
|
||||
Reference in New Issue
Block a user