Rename hosttrace to omnitrace (#18)

[ROCm/rocprofiler-systems commit: 39cf760a4e]
This commit is contained in:
Jonathan R. Madsen authored and GitHub committed 2021-11-24 04:59:59 -06:00
1 parent efb6d766af
commit 9d5ebf9c3b
46 files changed
+906 -830

No files matched your search

+54 -50
View File
@@ -48,7 +48,7 @@ setup_gotchas()
if(_initialized) return;
_initialized = true;
HOSTTRACE_DEBUG(
OMNITRACE_DEBUG(
"[%s] Configuring gotcha wrapper around fork, MPI_Init, and MPI_Init_thread\n",
__FUNCTION__);
@@ -60,7 +60,11 @@ setup_gotchas()
mpi_gotcha_t::template configure<0, int, int*, char***>("MPI_Init");
mpi_gotcha_t::template configure<1, int, int*, char***, int, int*>(
"MPI_Init_thread");
mpi_gotcha_t::template configure<3, int>("MPI_Finalize");
mpi_gotcha_t::template configure<2, int>("MPI_Finalize");
// mpi_gotcha_t::template configure<3, int, tim::mpi::comm_t,
// int*>("MPI_Comm_rank");
// mpi_gotcha_t::template configure<4, int, tim::mpi::comm_t,
// int*>("MPI_Comm_size");
};
}
@@ -69,9 +73,9 @@ ensure_finalization(bool _static_init = false)
{
if(!_static_init)
{
HOSTTRACE_DEBUG("[%s]\n", __FUNCTION__);
OMNITRACE_DEBUG("[%s]\n", __FUNCTION__);
}
return scope::destructor{ []() { hosttrace_trace_finalize(); } };
return scope::destructor{ []() { omnitrace_trace_finalize(); } };
}
auto&
@@ -117,18 +121,18 @@ using Device = critical_trace::Device;
using Phase = critical_trace::Phase;
bool
hosttrace_init_tooling()
omnitrace_init_tooling()
{
static bool _once = false;
if(get_state() != State::PreInit || _once) return false;
_once = true;
HOSTTRACE_DEBUG("[%s]\n", __FUNCTION__);
OMNITRACE_DEBUG("[%s]\n", __FUNCTION__);
if(!get_use_timemory() && !get_use_perfetto())
{
get_state() = State::Finalized;
HOSTTRACE_DEBUG("[%s] Both perfetto and timemory are disabled. Setting the state "
OMNITRACE_DEBUG("[%s] Both perfetto and timemory are disabled. Setting the state "
"to finalized\n",
__FUNCTION__);
return false;
@@ -174,7 +178,7 @@ hosttrace_init_tooling()
}
else
{
tim::trait::runtime_enabled<hosttrace>::set(false);
tim::trait::runtime_enabled<omnitrace>::set(false);
}
}
@@ -182,7 +186,7 @@ hosttrace_init_tooling()
auto& _main_bundle = get_main_bundle();
_main_bundle->start();
assert(_main_bundle->get<mpi_gotcha_t>()->get_is_running());
#if defined(HOSTTRACE_USE_ROCTRACER)
#if defined(OMNITRACE_USE_ROCTRACER)
assert(_main_bundle->get<comp::roctracer>() != nullptr);
assert(_main_bundle->get<comp::roctracer>()->get_is_running());
#endif
@@ -220,11 +224,11 @@ hosttrace_init_tooling()
auto _exe = get_exe_name();
static auto _thread_init = [_exe]() {
hosttrace_thread_data<hosttrace_thread_bundle_t>::construct(
omnitrace_thread_data<omnitrace_thread_bundle_t>::construct(
TIMEMORY_JOIN("", _exe, "/thread-", threading::get_id()),
quirk::config<quirk::auto_start>{});
static thread_local auto _dtor = scope::destructor{ []() {
hosttrace_thread_data<hosttrace_thread_bundle_t>::instance()->stop();
omnitrace_thread_data<omnitrace_thread_bundle_t>::instance()->stop();
} };
(void) _dtor;
};
@@ -258,8 +262,8 @@ hosttrace_init_tooling()
auto& _data = get_instrumentation_bundles();
if(_data.bundles.empty())
{
HOSTTRACE_DEBUG("[%s] skipped %s :: empty bundle stack\n",
"hosttrace_pop_trace", name);
OMNITRACE_DEBUG("[%s] skipped %s :: empty bundle stack\n",
"omnitrace_pop_trace", name);
return;
}
_data.bundles.back()->stop();
@@ -303,21 +307,21 @@ hosttrace_init_tooling()
if(dmp::rank() == 0)
{
// generic filter for filtering relevant options
auto _is_hosttrace_option = [](const auto& _v) {
#if !defined(HOSTTRACE_USE_ROCTRACER)
if(_v.find("HOSTTRACE_ROCTRACER_") == 0) return false;
auto _is_omnitrace_option = [](const auto& _v) {
#if !defined(OMNITRACE_USE_ROCTRACER)
if(_v.find("OMNITRACE_ROCTRACER_") == 0) return false;
#endif
if(!get_use_critical_trace() && _v.find("HOSTTRACE_CRITICAL_TRACE_") == 0)
if(!get_use_critical_trace() && _v.find("OMNITRACE_CRITICAL_TRACE_") == 0)
return false;
return (_v.find("HOSTTRACE_") == 0) ||
return (_v.find("OMNITRACE_") == 0) ||
((_v.find("TIMEMORY_") != 0) && (_v.find("SIGNAL_") != 0));
};
tim::print_env(std::cerr, [_is_hosttrace_option](const std::string& _v) {
return _is_hosttrace_option(_v);
tim::print_env(std::cerr, [_is_omnitrace_option](const std::string& _v) {
return _is_omnitrace_option(_v);
});
print_config_settings(std::cerr, _is_hosttrace_option);
print_config_settings(std::cerr, _is_omnitrace_option);
}
if(get_use_perfetto() && !is_system_backend())
@@ -358,20 +362,20 @@ hosttrace_init_tooling()
extern "C"
{
void hosttrace_push_trace(const char* name)
void omnitrace_push_trace(const char* name)
{
// return if not active
if(get_state() == State::Finalized) return;
if(get_state() != State::Active && !hosttrace_init_tooling())
if(get_state() != State::Active && !omnitrace_init_tooling())
{
HOSTTRACE_DEBUG("[%s] %s :: not active and perfetto not initialized\n",
OMNITRACE_DEBUG("[%s] %s :: not active and perfetto not initialized\n",
__FUNCTION__, name);
return;
}
else
{
HOSTTRACE_DEBUG("[%s] %s\n", __FUNCTION__, name);
OMNITRACE_DEBUG("[%s] %s\n", __FUNCTION__, name);
}
static auto _sample_rate = std::max<size_t>(get_sample_rate(), 1);
@@ -396,11 +400,11 @@ extern "C"
}
}
void hosttrace_pop_trace(const char* name)
void omnitrace_pop_trace(const char* name)
{
if(get_state() == State::Active)
{
HOSTTRACE_DEBUG("[%s] %s\n", __FUNCTION__, name);
OMNITRACE_DEBUG("[%s] %s\n", __FUNCTION__, name);
auto& _sample_data = get_sample_data();
if(!_sample_data.empty())
{
@@ -424,34 +428,34 @@ extern "C"
}
else
{
HOSTTRACE_DEBUG("[%s] %s :: not active\n", __FUNCTION__, name);
OMNITRACE_DEBUG("[%s] %s :: not active\n", __FUNCTION__, name);
}
}
void hosttrace_trace_init(const char*, bool, const char*)
void omnitrace_trace_init(const char*, bool, const char*)
{
HOSTTRACE_DEBUG("[%s]\n", __FUNCTION__);
hosttrace_init_tooling();
OMNITRACE_DEBUG("[%s]\n", __FUNCTION__);
omnitrace_init_tooling();
}
void hosttrace_trace_finalize(void)
void omnitrace_trace_finalize(void)
{
// return if not active
if(get_state() != State::Active) return;
HOSTTRACE_DEBUG("[%s]\n", __FUNCTION__);
OMNITRACE_DEBUG("[%s]\n", __FUNCTION__);
if(dmp::rank() == 0) puts("");
get_state() = State::Finalized;
#if defined(HOSTTRACE_USE_ROCTRACER)
#if defined(OMNITRACE_USE_ROCTRACER)
// ensure that threads running roctracer callbacks shutdown
comp::roctracer::tear_down();
#endif
// join extra thread(s) used by roctracer
HOSTTRACE_DEBUG("[%s] waiting for all roctracer tasks to complete...\n",
OMNITRACE_DEBUG("[%s] waiting for all roctracer tasks to complete...\n",
__FUNCTION__);
tasking::get_roctracer_task_group().join();
@@ -462,7 +466,7 @@ extern "C"
std::string _msg = JOIN("", *get_main_bundle());
auto _pos = _msg.find(">>> ");
if(_pos != std::string::npos) _msg = _msg.substr(_pos + 5);
HOSTTRACE_PRINT("%s\n", _msg.c_str());
OMNITRACE_PRINT("%s\n", _msg.c_str());
get_main_bundle().reset();
}
@@ -470,7 +474,7 @@ extern "C"
// if they are still running (e.g. thread-pool still alive), the
// thread-specific data will be wrong if try to stop them from
// the main thread.
for(auto& itr : hosttrace_thread_data<hosttrace_thread_bundle_t>::instances())
for(auto& itr : omnitrace_thread_data<omnitrace_thread_bundle_t>::instances())
{
if(itr && itr->get<comp::wall_clock>() &&
!itr->get<comp::wall_clock>()->get_is_running())
@@ -478,7 +482,7 @@ extern "C"
std::string _msg = JOIN("", *itr);
auto _pos = _msg.find(">>> ");
if(_pos != std::string::npos) _msg = _msg.substr(_pos + 5);
HOSTTRACE_PRINT("%s\n", _msg.c_str());
OMNITRACE_PRINT("%s\n", _msg.c_str());
}
}
@@ -504,7 +508,7 @@ extern "C"
for(size_t i = 0; i < max_supported_threads; ++i)
{
using critical_trace_hash_data =
hosttrace_thread_data<critical_trace::hash_ids, critical_trace::id>;
omnitrace_thread_data<critical_trace::hash_ids, critical_trace::id>;
if(critical_trace_hash_data::instances().at(i))
critical_trace::add_hash_id(
@@ -514,19 +518,19 @@ extern "C"
for(size_t i = 0; i < max_supported_threads; ++i)
{
using critical_trace_chain_data =
hosttrace_thread_data<critical_trace::call_chain>;
omnitrace_thread_data<critical_trace::call_chain>;
if(critical_trace_chain_data::instances().at(i))
critical_trace::update(i); // launch update task
}
// make sure outstanding hash tasks completed before compute
HOSTTRACE_PRINT("[%s] waiting for all critical trace tasks to complete...\n",
OMNITRACE_PRINT("[%s] waiting for all critical trace tasks to complete...\n",
__FUNCTION__);
tasking::get_critical_trace_task_group().join();
// launch compute task
HOSTTRACE_PRINT("[%s] launching critical trace compute task...\n",
OMNITRACE_PRINT("[%s] launching critical trace compute task...\n",
__FUNCTION__);
critical_trace::compute();
}
@@ -578,24 +582,24 @@ extern "C"
tasking::get_roctracer_thread_pool().destroy_threadpool();
tasking::get_critical_trace_thread_pool().destroy_threadpool();
HOSTTRACE_DEBUG("Finalizing timemory...\n");
OMNITRACE_DEBUG("Finalizing timemory...\n");
tim::timemory_finalize();
HOSTTRACE_DEBUG("Finalizing timemory... Done\n");
OMNITRACE_DEBUG("Finalizing timemory... Done\n");
if(_perfetto_output_error)
throw std::runtime_error("Unable to create perfetto output file");
}
void hosttrace_trace_set_env(const char* env_name, const char* env_val)
void omnitrace_trace_set_env(const char* env_name, const char* env_val)
{
HOSTTRACE_DEBUG("[%s] Setting env: %s=%s\n", __FUNCTION__, env_name, env_val);
OMNITRACE_DEBUG("[%s] Setting env: %s=%s\n", __FUNCTION__, env_name, env_val);
tim::set_env(env_name, env_val, 0);
}
void hosttrace_trace_set_mpi(bool use, bool attached)
void omnitrace_trace_set_mpi(bool use, bool attached)
{
HOSTTRACE_DEBUG("[%s] use: %s, attached: %s\n", __FUNCTION__, (use) ? "y" : "n",
OMNITRACE_DEBUG("[%s] use: %s, attached: %s\n", __FUNCTION__, (use) ? "y" : "n",
(attached) ? "y" : "n");
if(use && !attached)
{
@@ -612,7 +616,7 @@ get_main_bundle()
{
static auto _v =
(setup_gotchas(), std::make_unique<main_bundle_t>(
"hosttrace", quirk::config<quirk::auto_start>{}));
"omnitrace", quirk::config<quirk::auto_start>{}));
return _v;
}
@@ -620,6 +624,6 @@ namespace
{
// if static objects are destroyed randomly (relatively uncommon behavior)
// this might call finalization before perfetto ends the tracing session
// but static variable in hosttrace_init_tooling is more likely
// but static variable in omnitrace_init_tooling is more likely
auto _ensure_finalization = ensure_finalization(true);
} // namespace
@@ -55,7 +55,7 @@ get_config()
(void) _once;
}
#define HOSTTRACE_CONFIG_SETTING(TYPE, ENV_NAME, DESCRIPTION, INITIAL_VALUE) \
#define OMNITRACE_CONFIG_SETTING(TYPE, ENV_NAME, DESCRIPTION, INITIAL_VALUE) \
_config->insert<TYPE, TYPE>(ENV_NAME, ENV_NAME, DESCRIPTION, INITIAL_VALUE, \
std::vector<std::string>{})
} // namespace
@@ -72,112 +72,112 @@ configure_settings()
// if using timemory, default to perfetto being off
auto _default_perfetto_v =
!tim::get_env<bool>("HOSTTRACE_USE_TIMEMORY", false, false);
!tim::get_env<bool>("OMNITRACE_USE_TIMEMORY", false, false);
auto _default_config_file =
JOIN("/", tim::get_env<std::string>("HOME", "."), "hosttrace.cfg");
JOIN("/", tim::get_env<std::string>("HOME", "."), "omnitrace.cfg");
auto _system_backend = tim::get_env("HOSTTRACE_BACKEND_SYSTEM", false, false);
auto _system_backend = tim::get_env("OMNITRACE_BACKEND_SYSTEM", false, false);
HOSTTRACE_CONFIG_SETTING(std::string, "HOSTTRACE_CONFIG_FILE",
"Configuration file of hosttrace and timemory settings",
OMNITRACE_CONFIG_SETTING(std::string, "OMNITRACE_CONFIG_FILE",
"Configuration file of omnitrace and timemory settings",
_default_config_file);
HOSTTRACE_CONFIG_SETTING(bool, "HOSTTRACE_DEBUG", "Enable debugging output",
OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_DEBUG", "Enable debugging output",
_config->get_debug());
auto _hosttrace_debug = _config->get<bool>("HOSTTRACE_DEBUG");
if(_hosttrace_debug) tim::set_env("TIMEMORY_DEBUG_SETTINGS", "1", 0);
auto _omnitrace_debug = _config->get<bool>("OMNITRACE_DEBUG");
if(_omnitrace_debug) tim::set_env("TIMEMORY_DEBUG_SETTINGS", "1", 0);
HOSTTRACE_CONFIG_SETTING(bool, "HOSTTRACE_USE_PERFETTO", "Enable perfetto backend",
OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_USE_PERFETTO", "Enable perfetto backend",
_default_perfetto_v);
HOSTTRACE_CONFIG_SETTING(bool, "HOSTTRACE_USE_TIMEMORY", "Enable timemory backend",
!_config->get<bool>("HOSTTRACE_USE_PERFETTO"));
OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_USE_TIMEMORY", "Enable timemory backend",
!_config->get<bool>("OMNITRACE_USE_PERFETTO"));
HOSTTRACE_CONFIG_SETTING(
bool, "HOSTTRACE_USE_PID",
OMNITRACE_CONFIG_SETTING(
bool, "OMNITRACE_USE_PID",
"Enable tagging filenames with process identifier (either MPI rank or pid)",
true);
HOSTTRACE_CONFIG_SETTING(
size_t, "HOSTTRACE_SAMPLE_RATE",
OMNITRACE_CONFIG_SETTING(
size_t, "OMNITRACE_SAMPLE_RATE",
"Counts every function call (N), only record function if (N % <VALUE> == 0)", 1);
auto _backend = tim::get_env_choice<std::string>(
"HOSTTRACE_BACKEND",
"OMNITRACE_BACKEND",
(_system_backend)
? "system" // if HOSTTRACE_BACKEND_SYSTEM is true, default to system.
? "system" // if OMNITRACE_BACKEND_SYSTEM is true, default to system.
: "inprocess", // Otherwise, default to inprocess
{ "inprocess", "system", "all" }, false);
HOSTTRACE_CONFIG_SETTING(std::string, "HOSTTRACE_BACKEND",
OMNITRACE_CONFIG_SETTING(std::string, "OMNITRACE_BACKEND",
"Specify the perfetto backend to activate. Options are: "
"'inprocess', 'system', or 'all'",
_backend);
HOSTTRACE_CONFIG_SETTING(bool, "HOSTTRACE_CRITICAL_TRACE",
OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_CRITICAL_TRACE",
"Enable generation of the critical trace", false);
HOSTTRACE_CONFIG_SETTING(
bool, "HOSTTRACE_ROCTRACER_TIMELINE_PROFILE",
OMNITRACE_CONFIG_SETTING(
bool, "OMNITRACE_ROCTRACER_TIMELINE_PROFILE",
"Create unique entries for every kernel with timemory backend",
_config->get_timeline_profile());
HOSTTRACE_CONFIG_SETTING(
bool, "HOSTTRACE_ROCTRACER_FLAT_PROFILE",
OMNITRACE_CONFIG_SETTING(
bool, "OMNITRACE_ROCTRACER_FLAT_PROFILE",
"Ignore hierarchy in all kernels entries with timemory backend",
_config->get_flat_profile());
HOSTTRACE_CONFIG_SETTING(bool, "HOSTTRACE_ROCTRACER_HSA_ACTIVITY",
OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_ROCTRACER_HSA_ACTIVITY",
"Enable HSA activity tracing support", false);
HOSTTRACE_CONFIG_SETTING(bool, "HOSTTRACE_ROCTRACER_HSA_API",
OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_ROCTRACER_HSA_API",
"Enable HSA API tracing support", false);
HOSTTRACE_CONFIG_SETTING(std::string, "HOSTTRACE_ROCTRACER_HSA_API_TYPES",
OMNITRACE_CONFIG_SETTING(std::string, "OMNITRACE_ROCTRACER_HSA_API_TYPES",
"HSA API type to collect", "");
HOSTTRACE_CONFIG_SETTING(bool, "HOSTTRACE_CRITICAL_TRACE_DEBUG",
"Enable debugging for critical trace", _hosttrace_debug);
OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_CRITICAL_TRACE_DEBUG",
"Enable debugging for critical trace", _omnitrace_debug);
HOSTTRACE_CONFIG_SETTING(
bool, "HOSTTRACE_CRITICAL_TRACE_SERIALIZE_NAMES",
OMNITRACE_CONFIG_SETTING(
bool, "OMNITRACE_CRITICAL_TRACE_SERIALIZE_NAMES",
"Include names in serialization of critical trace (mainly for debugging)",
_hosttrace_debug);
_omnitrace_debug);
HOSTTRACE_CONFIG_SETTING(size_t, "HOSTTRACE_SHMEM_SIZE_HINT_KB",
OMNITRACE_CONFIG_SETTING(size_t, "OMNITRACE_SHMEM_SIZE_HINT_KB",
"Hint for shared-memory buffer size in perfetto (in KB)",
40960);
HOSTTRACE_CONFIG_SETTING(size_t, "HOSTTRACE_BUFFER_SIZE_KB",
OMNITRACE_CONFIG_SETTING(size_t, "OMNITRACE_BUFFER_SIZE_KB",
"Size of perfetto buffer (in KB)", 1024000);
HOSTTRACE_CONFIG_SETTING(int64_t, "HOSTTRACE_CRITICAL_TRACE_COUNT",
OMNITRACE_CONFIG_SETTING(int64_t, "OMNITRACE_CRITICAL_TRACE_COUNT",
"Number of critical trace to export (0 == all)", 0);
HOSTTRACE_CONFIG_SETTING(uint64_t, "HOSTTRACE_CRITICAL_TRACE_BUFFER_COUNT",
OMNITRACE_CONFIG_SETTING(uint64_t, "OMNITRACE_CRITICAL_TRACE_BUFFER_COUNT",
"Number of critical trace records to store in thread-local "
"memory before submitting to shared buffer",
2000);
HOSTTRACE_CONFIG_SETTING(
uint64_t, "HOSTTRACE_CRITICAL_TRACE_NUM_THREADS",
OMNITRACE_CONFIG_SETTING(
uint64_t, "OMNITRACE_CRITICAL_TRACE_NUM_THREADS",
"Number of threads to use when generating the critical trace",
std::min<uint64_t>(8, std::thread::hardware_concurrency()));
HOSTTRACE_CONFIG_SETTING(
int64_t, "HOSTTRACE_CRITICAL_TRACE_PER_ROW",
OMNITRACE_CONFIG_SETTING(
int64_t, "OMNITRACE_CRITICAL_TRACE_PER_ROW",
"How many critical traces per row in perfetto (0 == all in one row)", 0);
HOSTTRACE_CONFIG_SETTING(
std::string, "HOSTTRACE_COMPONENTS",
OMNITRACE_CONFIG_SETTING(
std::string, "OMNITRACE_COMPONENTS",
"List of components to collect via timemory (see timemory-avail)", "wall_clock");
HOSTTRACE_CONFIG_SETTING(std::string, "HOSTTRACE_OUTPUT_FILE", "Perfetto filename",
OMNITRACE_CONFIG_SETTING(std::string, "OMNITRACE_OUTPUT_FILE", "Perfetto filename",
"");
HOSTTRACE_CONFIG_SETTING(bool, "HOSTTRACE_SETTINGS_DESC",
OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_SETTINGS_DESC",
"Provide descriptions when printing settings", false);
_config->get_flamegraph_output() = false;
@@ -193,13 +193,13 @@ configure_settings()
_config->get_timing_precision() = 6;
for(auto&& itr :
tim::delimit(_config->get<std::string>("HOSTTRACE_CONFIG_FILE"), ";:"))
tim::delimit(_config->get<std::string>("OMNITRACE_CONFIG_FILE"), ";:"))
{
HOSTTRACE_CONDITIONAL_BASIC_PRINT(true, "Reading config file %s\n", itr.c_str());
OMNITRACE_CONDITIONAL_BASIC_PRINT(true, "Reading config file %s\n", itr.c_str());
_config->read(itr);
}
_config->get_global_components() = _config->get<std::string>("HOSTTRACE_COMPONENTS");
_config->get_global_components() = _config->get<std::string>("OMNITRACE_COMPONENTS");
// always initialize timemory because gotcha wrappers are always used
auto _cmd = tim::read_command_line(process::get_id());
@@ -220,11 +220,11 @@ configure_settings()
using argparser_t = tim::argparse::argument_parser;
argparser_t _parser{ _exe };
tim::timemory_init(_cmd, _parser, "hosttrace-");
tim::timemory_init(_cmd, _parser, "omnitrace-");
settings::suppress_parsing() = true;
settings::suppress_config() = true;
settings::use_output_suffix() = _config->get<bool>("HOSTTRACE_USE_PID");
settings::use_output_suffix() = _config->get<bool>("OMNITRACE_USE_PID");
}
void
@@ -253,12 +253,12 @@ print_config_settings(std::ostream& _os,
std::sort(_data.begin(), _data.end(), [](const auto& lhs, const auto& rhs) {
auto _npos = std::string::npos;
// HOSTTRACE_CONFIG_FILE always first
if(lhs.at(0).find("HOSTTRACE_CONFIG") != _npos) return true;
if(rhs.at(0).find("HOSTTRACE_CONFIG") != _npos) return false;
// HOSTTRACE_USE_* prioritized
auto _lhs_use = lhs.at(0).find("HOSTTRACE_USE_");
auto _rhs_use = rhs.at(0).find("HOSTTRACE_USE_");
// OMNITRACE_CONFIG_FILE always first
if(lhs.at(0).find("OMNITRACE_CONFIG") != _npos) return true;
if(rhs.at(0).find("OMNITRACE_CONFIG") != _npos) return false;
// OMNITRACE_USE_* prioritized
auto _lhs_use = lhs.at(0).find("OMNITRACE_USE_");
auto _rhs_use = rhs.at(0).find("OMNITRACE_USE_");
if(_lhs_use != _rhs_use && _lhs_use < _rhs_use) return true;
if(_lhs_use != _rhs_use && _lhs_use > _rhs_use) return false;
// length sort followed by alphabetical sort
@@ -267,7 +267,7 @@ print_config_settings(std::ostream& _os,
: (lhs.at(0).length() < rhs.at(0).length());
});
bool _print_desc = get_debug() || get_config()->get<bool>("HOSTTRACE_SETTINGS_DESC");
bool _print_desc = get_debug() || get_config()->get<bool>("OMNITRACE_SETTINGS_DESC");
auto tot_width = std::accumulate(_widths.begin(), _widths.end(), 0);
if(!_print_desc) tot_width -= _widths.back() + 4;
@@ -277,7 +277,7 @@ print_config_settings(std::ostream& _os,
_spacer << "#" << std::setw(tot_width + 11) << ""
<< "#";
_os << _spacer.str() << "\n";
// _os << "# Hosttrace settings:" << std::setw(tot_width - 8) << "#" << "\n";
// _os << "# Omnitrace settings:" << std::setw(tot_width - 8) << "#" << "\n";
for(const auto& itr : _data)
{
_os << "# ";
@@ -315,112 +315,112 @@ get_exe_name()
std::string
get_config_file()
{
static auto _v = get_config()->find("HOSTTRACE_CONFIG_FILE");
static auto _v = get_config()->find("OMNITRACE_CONFIG_FILE");
return static_cast<tim::tsettings<std::string>&>(*_v->second).get();
}
bool
get_debug()
{
static auto _v = get_config()->find("HOSTTRACE_DEBUG");
static auto _v = get_config()->find("OMNITRACE_DEBUG");
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
}
bool
get_use_perfetto()
{
static auto _v = get_config()->find("HOSTTRACE_USE_PERFETTO");
static auto _v = get_config()->find("OMNITRACE_USE_PERFETTO");
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
}
bool
get_use_timemory()
{
static auto _v = get_config()->find("HOSTTRACE_USE_TIMEMORY");
static auto _v = get_config()->find("OMNITRACE_USE_TIMEMORY");
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
}
bool&
get_use_pid()
{
static auto _v = get_config()->find("HOSTTRACE_USE_PID");
static auto _v = get_config()->find("OMNITRACE_USE_PID");
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
}
bool
get_use_mpip()
{
static bool _v = tim::get_env("HOSTTRACE_USE_MPIP", false, false);
static bool _v = tim::get_env("OMNITRACE_USE_MPIP", false, false);
return _v;
}
bool
get_use_critical_trace()
{
static auto _v = get_config()->find("HOSTTRACE_CRITICAL_TRACE");
static auto _v = get_config()->find("OMNITRACE_CRITICAL_TRACE");
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
}
bool
get_critical_trace_debug()
{
static auto _v = get_config()->find("HOSTTRACE_CRITICAL_TRACE_DEBUG");
static auto _v = get_config()->find("OMNITRACE_CRITICAL_TRACE_DEBUG");
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
}
bool
get_critical_trace_serialize_names()
{
static auto _v = get_config()->find("HOSTTRACE_CRITICAL_TRACE_SERIALIZE_NAMES");
static auto _v = get_config()->find("OMNITRACE_CRITICAL_TRACE_SERIALIZE_NAMES");
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
}
bool
get_roctracer_timeline_profile()
{
static auto _v = get_config()->find("HOSTTRACE_ROCTRACER_TIMELINE_PROFILE");
static auto _v = get_config()->find("OMNITRACE_ROCTRACER_TIMELINE_PROFILE");
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
}
bool
get_roctracer_flat_profile()
{
static auto _v = get_config()->find("HOSTTRACE_ROCTRACER_FLAT_PROFILE");
static auto _v = get_config()->find("OMNITRACE_ROCTRACER_FLAT_PROFILE");
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
}
bool
get_trace_hsa_api()
{
static auto _v = get_config()->find("HOSTTRACE_ROCTRACER_HSA_API");
static auto _v = get_config()->find("OMNITRACE_ROCTRACER_HSA_API");
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
}
bool
get_trace_hsa_activity()
{
static auto _v = get_config()->find("HOSTTRACE_ROCTRACER_HSA_ACTIVITY");
static auto _v = get_config()->find("OMNITRACE_ROCTRACER_HSA_ACTIVITY");
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
}
int64_t
get_critical_trace_per_row()
{
static auto _v = get_config()->find("HOSTTRACE_CRITICAL_TRACE_PER_ROW");
static auto _v = get_config()->find("OMNITRACE_CRITICAL_TRACE_PER_ROW");
return static_cast<tim::tsettings<int64_t>&>(*_v->second).get();
}
size_t
get_perfetto_shmem_size_hint()
{
static auto _v = get_config()->find("HOSTTRACE_SHMEM_SIZE_HINT_KB");
static auto _v = get_config()->find("OMNITRACE_SHMEM_SIZE_HINT_KB");
return static_cast<tim::tsettings<size_t>&>(*_v->second).get();
}
size_t
get_perfetto_buffer_size()
{
static auto _v = get_config()->find("HOSTTRACE_BUFFER_SIZE_KB");
static auto _v = get_config()->find("OMNITRACE_BUFFER_SIZE_KB");
return static_cast<tim::tsettings<size_t>&>(*_v->second).get();
}
@@ -428,7 +428,7 @@ uint64_t
get_critical_trace_update_freq()
{
static uint64_t _v =
get_config()->get<uint64_t>("HOSTTRACE_CRITICAL_TRACE_BUFFER_COUNT");
get_config()->get<uint64_t>("OMNITRACE_CRITICAL_TRACE_BUFFER_COUNT");
return _v;
}
@@ -436,7 +436,7 @@ uint64_t
get_critical_trace_num_threads()
{
static uint64_t _v =
get_config()->get<uint64_t>("HOSTTRACE_CRITICAL_TRACE_NUM_THREADS");
get_config()->get<uint64_t>("OMNITRACE_CRITICAL_TRACE_NUM_THREADS");
return _v;
}
@@ -444,7 +444,7 @@ std::string
get_trace_hsa_api_types()
{
static std::string _v =
get_config()->get<std::string>("HOSTTRACE_ROCTRACER_HSA_API_TYPES");
get_config()->get<std::string>("OMNITRACE_ROCTRACER_HSA_API_TYPES");
return _v;
}
@@ -452,14 +452,14 @@ std::string&
get_backend()
{
// select inprocess, system, or both (i.e. all)
static auto _v = get_config()->find("HOSTTRACE_BACKEND");
static auto _v = get_config()->find("OMNITRACE_BACKEND");
return static_cast<tim::tsettings<std::string>&>(*_v->second).get();
}
std::string
get_perfetto_output_filename()
{
static auto _v = get_config()->find("HOSTTRACE_OUTPUT_FILE");
static auto _v = get_config()->find("OMNITRACE_OUTPUT_FILE");
static auto& _t = static_cast<tim::tsettings<std::string>&>(*_v->second);
if(_t.get().empty())
{
@@ -475,7 +475,7 @@ get_perfetto_output_filename()
_default_fname.replace(_dpos, _pid_patch.length(), "/perfetto-trace");
// have the default display the full path to the output file
_t.set(tim::get_env<std::string>(
"HOSTTRACE_OUTPUT_FILE",
"OMNITRACE_OUTPUT_FILE",
JOIN('/', tim::get_env<std::string>("PWD", ".", false), _default_fname),
false));
}
@@ -485,14 +485,14 @@ get_perfetto_output_filename()
size_t&
get_sample_rate()
{
static auto _v = get_config()->find("HOSTTRACE_SAMPLE_RATE");
static auto _v = get_config()->find("OMNITRACE_SAMPLE_RATE");
return static_cast<tim::tsettings<size_t>&>(*_v->second).get();
}
int64_t
get_critical_trace_count()
{
static auto _v = get_config()->find("HOSTTRACE_CRITICAL_TRACE_COUNT");
static auto _v = get_config()->find("OMNITRACE_CRITICAL_TRACE_COUNT");
return static_cast<tim::tsettings<int64_t>&>(*_v->second).get();
}
@@ -513,10 +513,10 @@ get_cpu_cid()
std::unique_ptr<std::vector<uint64_t>>&
get_cpu_cid_stack(int64_t _tid)
{
struct hosttrace_cpu_cid_stack
struct omnitrace_cpu_cid_stack
{};
using thread_data_t =
hosttrace_thread_data<std::vector<uint64_t>, hosttrace_cpu_cid_stack>;
omnitrace_thread_data<std::vector<uint64_t>, omnitrace_cpu_cid_stack>;
static auto& _v = thread_data_t::instances();
static thread_local auto _v_check = [_tid]() {
thread_data_t::construct((_tid > 0) ? *thread_data_t::instances().at(0)
@@ -178,7 +178,7 @@ entry::operator+=(const entry& rhs)
}
else
{
HOSTTRACE_PRINT(
OMNITRACE_PRINT(
"Warning! Incorrect phase. entry::operator+=(entry) is only valid for "
"Phase::BEGIN += Phase::END\n");
}
@@ -231,7 +231,7 @@ entry::get_overlap(const entry& rhs) const
return (rhs.end_ns - begin_ns);
else
{
HOSTTRACE_PRINT("Warning! entry::get_overlap(entry, tid) "
OMNITRACE_PRINT("Warning! entry::get_overlap(entry, tid) "
"could not determine the overlap :: %s\n",
JOIN("", *this).c_str());
}
@@ -265,7 +265,7 @@ entry::get_independent(const entry& rhs) const
return (end_ns - rhs.end_ns);
else
{
HOSTTRACE_PRINT("Warning! entry::get_independent(entry, tid) "
OMNITRACE_PRINT("Warning! entry::get_independent(entry, tid) "
"could not determine the overlap :: %s\n",
JOIN("", *this).c_str());
}
@@ -335,7 +335,7 @@ entry::is_delta(const entry& _v, const std::string_view& _ctx)
{
if(_v.phase != Phase::DELTA)
{
HOSTTRACE_CT_DEBUG(
OMNITRACE_CT_DEBUG(
"Warning! Invalid phase for entry. entry::%s requires Phase::DELTA :: %s\n",
_ctx.data(), JOIN("", _v).c_str());
return true;
@@ -487,7 +487,7 @@ get_update_frequency()
std::unique_ptr<call_chain>&
get(int64_t _tid)
{
static auto& _v = hosttrace_thread_data<call_chain>::instances();
static auto& _v = omnitrace_thread_data<call_chain>::instances();
static thread_local auto _once = [_tid]() {
if(!_v.at(0)) _v.at(0) = std::make_unique<call_chain>();
if(!_v.at(_tid)) _v.at(_tid) = std::make_unique<call_chain>();
@@ -517,7 +517,7 @@ size_t
add_hash_id(const std::string& _label)
{
using critical_trace_hash_data =
hosttrace_thread_data<critical_trace::hash_ids, critical_trace::id>;
omnitrace_thread_data<critical_trace::hash_ids, critical_trace::id>;
auto _hash = tim::hash::add_hash_id(_label);
if(get_use_critical_trace())
@@ -575,7 +575,7 @@ save_call_graph(const std::string& _fname, const std::string& _label,
const call_graph_t& _call_graph, bool _msg = false,
std::string _func = {})
{
HOSTTRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
using perfstats_t =
tim::lightweight_tuple<comp::wall_clock, comp::peak_rss, comp::page_rss>;
@@ -590,7 +590,7 @@ save_call_graph(const std::string& _fname, const std::string& _label,
auto _hash_map = *tim::hash::get_hash_ids();
for(auto& itr : _hash_map)
itr.second = tim::demangle(itr.second);
ar->setNextName("hosttrace");
ar->setNextName("omnitrace");
ar->startNode();
(*ar)(cereal::make_nvp("hash_map", _hash_map));
ar->setNextName(_label.c_str());
@@ -606,7 +606,7 @@ save_call_graph(const std::string& _fname, const std::string& _label,
if(_msg)
{
if(_func.empty()) _func = __FUNCTION__;
HOSTTRACE_PRINT("[%s] Outputting '%s'...\n", _func.c_str(), _fname.c_str());
OMNITRACE_PRINT("[%s] Outputting '%s'...\n", _func.c_str(), _fname.c_str());
}
ofs << oss.str() << std::endl;
}
@@ -614,7 +614,7 @@ save_call_graph(const std::string& _fname, const std::string& _label,
_perf.stop();
if(_msg)
{
HOSTTRACE_CT_DEBUG("%s\n", JOIN("", _perf).c_str());
OMNITRACE_CT_DEBUG("%s\n", JOIN("", _perf).c_str());
}
}
@@ -623,7 +623,7 @@ save_critical_trace(const std::string& _fname, const std::string& _label,
const std::vector<call_chain>& _cchain, bool _msg = false,
std::string _func = {})
{
HOSTTRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
using perfstats_t =
tim::lightweight_tuple<comp::wall_clock, comp::peak_rss, comp::page_rss>;
@@ -637,7 +637,7 @@ save_critical_trace(const std::string& _fname, const std::string& _label,
auto _hash_map = *tim::hash::get_hash_ids();
for(auto& itr : _hash_map)
itr.second = tim::demangle(itr.second);
ar->setNextName("hosttrace");
ar->setNextName("omnitrace");
ar->startNode();
(*ar)(cereal::make_nvp("hash_map", _hash_map),
cereal::make_nvp(_label.c_str(), _cchain));
@@ -650,7 +650,7 @@ save_critical_trace(const std::string& _fname, const std::string& _label,
if(_msg)
{
if(_func.empty()) _func = __FUNCTION__;
HOSTTRACE_PRINT("[%s] Outputting '%s'...\n", _func.c_str(), _fname.c_str());
OMNITRACE_PRINT("[%s] Outputting '%s'...\n", _func.c_str(), _fname.c_str());
}
std::stringstream oss{};
if(_cchain.size() > 1000)
@@ -667,7 +667,7 @@ save_critical_trace(const std::string& _fname, const std::string& _label,
_perf.stop();
if(_msg)
{
HOSTTRACE_CT_DEBUG("%s\n", JOIN("", _perf).c_str());
OMNITRACE_CT_DEBUG("%s\n", JOIN("", _perf).c_str());
}
}
@@ -675,7 +675,7 @@ void
save_call_chain_text(const std::string& _fname, const call_chain& _call_chain,
bool _msg = false, std::string _func = {})
{
HOSTTRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
using perfstats_t =
tim::lightweight_tuple<comp::wall_clock, comp::peak_rss, comp::page_rss>;
@@ -688,7 +688,7 @@ save_call_chain_text(const std::string& _fname, const call_chain& _call_chain,
if(_msg)
{
if(_func.empty()) _func = __FUNCTION__;
HOSTTRACE_PRINT("[%s] Outputting '%s'...\n", _func.c_str(), _fname.c_str());
OMNITRACE_PRINT("[%s] Outputting '%s'...\n", _func.c_str(), _fname.c_str());
}
ofs << _call_chain << "\n";
}
@@ -696,7 +696,7 @@ save_call_chain_text(const std::string& _fname, const call_chain& _call_chain,
_perf.stop();
if(_msg)
{
HOSTTRACE_CT_DEBUG("%s\n", JOIN("", _perf).c_str());
OMNITRACE_CT_DEBUG("%s\n", JOIN("", _perf).c_str());
}
}
@@ -705,7 +705,7 @@ save_call_chain_json(const std::string& _fname, const std::string& _label,
const call_chain& _call_chain, bool _msg = false,
std::string _func = {})
{
HOSTTRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
using perfstats_t =
tim::lightweight_tuple<comp::wall_clock, comp::peak_rss, comp::page_rss>;
@@ -719,7 +719,7 @@ save_call_chain_json(const std::string& _fname, const std::string& _label,
auto _hash_map = *tim::hash::get_hash_ids();
for(auto& itr : _hash_map)
itr.second = tim::demangle(itr.second);
ar->setNextName("hosttrace");
ar->setNextName("omnitrace");
ar->startNode();
(*ar)(cereal::make_nvp("hash_map", _hash_map),
cereal::make_nvp(_label.c_str(), _call_chain));
@@ -732,7 +732,7 @@ save_call_chain_json(const std::string& _fname, const std::string& _label,
if(_msg)
{
if(_func.empty()) _func = __FUNCTION__;
HOSTTRACE_PRINT("[%s] Outputting '%s'...\n", _func.c_str(), _fname.c_str());
OMNITRACE_PRINT("[%s] Outputting '%s'...\n", _func.c_str(), _fname.c_str());
}
std::stringstream oss{};
if(_call_chain.size() > 100000)
@@ -749,7 +749,7 @@ save_call_chain_json(const std::string& _fname, const std::string& _label,
_perf.stop();
if(_msg)
{
HOSTTRACE_CT_DEBUG("%s\n", JOIN("", _perf).c_str());
OMNITRACE_CT_DEBUG("%s\n", JOIN("", _perf).c_str());
}
}
@@ -764,7 +764,7 @@ load_call_chain(const std::string& _fname, const std::string& _label,
namespace cereal = tim::cereal;
auto ar = tim::policy::input_archive<cereal::JSONInputArchive>::get(ifs);
ar->setNextName("hosttrace");
ar->setNextName("omnitrace");
ar->startNode();
(*ar)(cereal::make_nvp(_label.c_str(), _call_chain));
ar->finishNode();
@@ -798,7 +798,7 @@ find(
void
squash_critical_path(call_chain& _targ)
{
HOSTTRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
static auto _strict_equal = [](const entry& _lhs, const entry& _rhs) {
auto _same_phase = (_lhs.phase == _rhs.phase);
bool _phase_check = true;
@@ -836,7 +836,7 @@ squash_critical_path(call_chain& _targ)
void
combine_critical_path(call_chain& _targ, call_chain _chain)
{
HOSTTRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
call_chain _delta{};
call_chain _begin{};
call_chain _end{};
@@ -876,7 +876,7 @@ combine_critical_path(call_chain& _targ, call_chain _chain)
auto
get_indexed(const call_chain& _chain)
{
HOSTTRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
std::map<int64_t, std::vector<entry>> _indexed = {};
// allocate for all cpu correlation ids
@@ -906,7 +906,7 @@ get_indexed(const call_chain& _chain)
void
find_children(PTL::ThreadPool& _tp, call_graph_t& _graph, const call_chain& _chain)
{
HOSTTRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
using iterator_t = call_graph_sibling_itr_t;
using itr_entry_vec_t = std::vector<std::pair<iterator_t, entry>>;
@@ -916,20 +916,20 @@ find_children(PTL::ThreadPool& _tp, call_graph_t& _graph, const call_chain& _cha
std::map<entry, std::vector<entry>> _entry_map{};
// allocate all entries
HOSTTRACE_CT_DEBUG("[%s] Allocating...\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s] Allocating...\n", __FUNCTION__);
for(const auto& itr : _chain)
{
auto _ins = _entry_map.emplace(itr, std::vector<entry>{});
if(!_ins.second)
{
auto _existing = _ins.first->first;
HOSTTRACE_PRINT("Warning! Duplicate entry for [%s] :: [%s]\n",
OMNITRACE_PRINT("Warning! Duplicate entry for [%s] :: [%s]\n",
JOIN("", _existing).c_str(), JOIN("", itr).c_str());
}
}
task_group_t _tg{ &_tp };
HOSTTRACE_CT_DEBUG("[%s] Parallel mapping...\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s] Parallel mapping...\n", __FUNCTION__);
for(const auto& itr : _chain)
{
_tg.run([&]() { _entry_map[itr] = _indexed.at(itr.cpu_cid); });
@@ -972,12 +972,12 @@ find_children(PTL::ThreadPool& _tp, call_graph_t& _graph, const call_chain& _cha
if(!_indexed.at(-1).empty())
{
HOSTTRACE_CT_DEBUG("[%s] Setting root (line %i)...\n", __FUNCTION__, __LINE__);
OMNITRACE_CT_DEBUG("[%s] Setting root (line %i)...\n", __FUNCTION__, __LINE__);
_graph.set_head(_indexed.at(-1).front());
}
else
{
HOSTTRACE_CT_DEBUG("[%s] Setting root (line %i)...\n", __FUNCTION__, __LINE__);
OMNITRACE_CT_DEBUG("[%s] Setting root (line %i)...\n", __FUNCTION__, __LINE__);
auto _depth = static_cast<uint16_t>(-1);
entry _root{ 0, Device::NONE, Phase::NONE, _depth, 0, 0, 0, 0, 0, 0, 0 };
_graph.set_head(_root);
@@ -988,7 +988,7 @@ find_children(PTL::ThreadPool& _tp, call_graph_t& _graph, const call_chain& _cha
{
if(itr.first.depth == _root->depth + 1)
{
HOSTTRACE_CT_DEBUG("[%s] Generating call-graph...\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s] Generating call-graph...\n", __FUNCTION__);
// _recursive_func(_root, itr.first);
itr_entry_vec_t _data = _func(_root, itr.first);
while(_loop_func(_data))
@@ -1001,7 +1001,7 @@ void
find_sequences(PTL::ThreadPool& _tp, call_graph_t& _graph,
std::vector<call_chain>& _chain)
{
HOSTTRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
using iterator_t = call_graph_preorder_itr_t;
std::vector<iterator_t> _end_nodes{};
size_t _n = 0;
@@ -1010,13 +1010,13 @@ find_sequences(PTL::ThreadPool& _tp, call_graph_t& _graph,
auto _nchild = _graph.number_of_children(itr);
if(_nchild > 0)
{
HOSTTRACE_CT_DEBUG("Skipping node #%zu with %u children :: %s\n", _n, _nchild,
OMNITRACE_CT_DEBUG("Skipping node #%zu with %u children :: %s\n", _n, _nchild,
JOIN("", *itr).c_str());
continue;
}
_end_nodes.emplace_back(itr);
}
HOSTTRACE_CT_DEBUG("Number of end nodes: %zu\n", _end_nodes.size());
OMNITRACE_CT_DEBUG("Number of end nodes: %zu\n", _end_nodes.size());
_chain.resize(_end_nodes.size());
auto _construct = [&](size_t i) {
@@ -1044,7 +1044,7 @@ template <typename ArchiveT, typename T, typename AllocatorT>
void
serialize_graph(ArchiveT& ar, const tim::graph<T, AllocatorT>& t)
{
HOSTTRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
namespace cereal = tim::cereal;
using iterator_t = typename tim::graph<T, AllocatorT>::sibling_iterator;
@@ -1084,7 +1084,7 @@ serialize_subgraph(ArchiveT& ar, const tim::graph<T, AllocatorT>& _graph,
void
update_critical_path(call_chain _chain, int64_t _tid)
{
HOSTTRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
try
{
// remove any data not
@@ -1103,7 +1103,7 @@ template <Device DevT>
std::vector<call_chain>
get_top(const std::vector<call_chain>& _chain, size_t _count)
{
HOSTTRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
std::vector<call_chain> _data{};
_data.reserve(_count);
for(const auto& itr : _chain)
@@ -1121,7 +1121,7 @@ template <Device DevT>
void
generate_perfetto(const std::vector<call_chain>& _data)
{
HOSTTRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s]\n", __FUNCTION__);
auto _func = [&](size_t _beg, size_t _end) {
// ensure all hash ids exist
copy_hash_ids();
@@ -1151,7 +1151,7 @@ compute_critical_trace()
if(_computed) return;
HOSTTRACE_CT_DEBUG("[%s] Generating critical trace...\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s] Generating critical trace...\n", __FUNCTION__);
// ensure all hash ids exist
copy_hash_ids();
@@ -1169,7 +1169,7 @@ compute_critical_trace()
_tp.set_verbose(-1);
PTL::TaskGroup<void> _tg{ &_tp };
HOSTTRACE_CT_DEBUG("[%s] initial call chain: %zu entries\n", __FUNCTION__,
OMNITRACE_CT_DEBUG("[%s] initial call chain: %zu entries\n", __FUNCTION__,
complete_call_chain.size());
perfstats_t _perf{ get_perf_name(__FUNCTION__) };
@@ -1178,17 +1178,17 @@ compute_critical_trace()
std::sort(complete_call_chain.begin(), complete_call_chain.end());
_perf.stop().rekey("Sorting critical trace");
HOSTTRACE_CT_DEBUG("%s\n", JOIN("", _perf).c_str());
OMNITRACE_CT_DEBUG("%s\n", JOIN("", _perf).c_str());
_perf.start();
squash_critical_path(complete_call_chain);
HOSTTRACE_CT_DEBUG("[%s] complete call chain: %zu entries\n", __FUNCTION__,
OMNITRACE_CT_DEBUG("[%s] complete call chain: %zu entries\n", __FUNCTION__,
complete_call_chain.size());
_perf.stop().rekey("Squash critical path");
HOSTTRACE_CT_DEBUG("%s\n", JOIN("", _perf).c_str());
OMNITRACE_CT_DEBUG("%s\n", JOIN("", _perf).c_str());
_tg.run(
[](call_chain _chain, std::string _func) {
@@ -1203,15 +1203,15 @@ compute_critical_trace()
_perf.reset().start();
HOSTTRACE_CT_DEBUG("[%s] Finding children...\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s] Finding children...\n", __FUNCTION__);
call_graph_t _graph{};
find_children(_tp, _graph, complete_call_chain);
HOSTTRACE_CT_DEBUG("[%s] complete call graph: %zu entries\n", __FUNCTION__,
OMNITRACE_CT_DEBUG("[%s] complete call graph: %zu entries\n", __FUNCTION__,
_graph.size() - 1);
_perf.stop().rekey("Finding children");
HOSTTRACE_CT_DEBUG("%s\n", JOIN("", _perf).c_str());
OMNITRACE_CT_DEBUG("%s\n", JOIN("", _perf).c_str());
_tg.run(
[&](std::string _func) {
@@ -1227,17 +1227,17 @@ compute_critical_trace()
_perf.reset().start();
HOSTTRACE_CT_DEBUG("[%s] Finding sequences...\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s] Finding sequences...\n", __FUNCTION__);
// find the sequences
std::vector<call_chain> _top{};
find_sequences(_tp, _graph, _top);
_perf.stop().rekey("Finding sequences");
HOSTTRACE_CT_DEBUG("%s\n", JOIN("", _perf).c_str());
OMNITRACE_CT_DEBUG("%s\n", JOIN("", _perf).c_str());
if(get_critical_trace_count() == 0)
{
HOSTTRACE_CT_DEBUG("[%s] Saving critical trace...\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s] Saving critical trace...\n", __FUNCTION__);
save_critical_trace(
tim::settings::compose_output_filename(
"critical-trace", ".json", get_use_pid(),
@@ -1246,15 +1246,15 @@ compute_critical_trace()
}
else
{
HOSTTRACE_CT_DEBUG("[%s] Getting top CPU functions...\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s] Getting top CPU functions...\n", __FUNCTION__);
// get the top CPU critical traces
auto _top_cpu = get_top<Device::CPU>(_top, get_critical_trace_count());
if(!_top_cpu.empty())
{
HOSTTRACE_CT_DEBUG("[%s] Generating perfetto CPU critical traces...\n",
OMNITRACE_CT_DEBUG("[%s] Generating perfetto CPU critical traces...\n",
__FUNCTION__);
generate_perfetto<Device::CPU>(_top_cpu);
HOSTTRACE_CT_DEBUG("[%s] Saving CPU critical traces...\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s] Saving CPU critical traces...\n", __FUNCTION__);
save_critical_trace(tim::settings::compose_output_filename(
"critical-trace-cpu", ".json", get_use_pid(),
(tim::dmp::is_initialized()) ? tim::dmp::rank()
@@ -1262,15 +1262,15 @@ compute_critical_trace()
"critical_trace", _top_cpu, true, __FUNCTION__);
}
HOSTTRACE_CT_DEBUG("[%s] Getting top GPU functions...\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s] Getting top GPU functions...\n", __FUNCTION__);
// get the top GPU critical traces
auto _top_gpu = get_top<Device::GPU>(_top, get_critical_trace_count());
if(!_top_gpu.empty())
{
HOSTTRACE_CT_DEBUG("[%s] Generating perfetto GPU critical traces...\n",
OMNITRACE_CT_DEBUG("[%s] Generating perfetto GPU critical traces...\n",
__FUNCTION__);
generate_perfetto<Device::GPU>(_top_gpu);
HOSTTRACE_CT_DEBUG("[%s] Saving GPU critical traces...\n", __FUNCTION__);
OMNITRACE_CT_DEBUG("[%s] Saving GPU critical traces...\n", __FUNCTION__);
save_critical_trace(tim::settings::compose_output_filename(
"critical-trace-gpu", ".json", get_use_pid(),
(tim::dmp::is_initialized()) ? tim::dmp::rank()
@@ -1285,7 +1285,7 @@ compute_critical_trace()
} catch(const std::exception& e)
{
HOSTTRACE_PRINT("Thread exited '%s' with exception: %s\n", __FUNCTION__,
OMNITRACE_PRINT("Thread exited '%s' with exception: %s\n", __FUNCTION__,
e.what());
TIMEMORY_CONDITIONAL_DEMANGLED_BACKTRACE(true, 32);
}
@@ -1294,7 +1294,7 @@ compute_critical_trace()
auto _ct_msg = JOIN("", _ct_perf);
auto _ct_pos = _ct_msg.find(">>> ");
if(_ct_pos != std::string::npos) _ct_msg = _ct_msg.substr(_ct_pos + 5);
HOSTTRACE_PRINT("%s\n", _ct_msg.c_str());
OMNITRACE_PRINT("%s\n", _ct_msg.c_str());
}
} // namespace
} // namespace critical_trace
@@ -33,7 +33,7 @@
void
fork_gotcha::audit(const gotcha_data_t&, audit::incoming)
{
HOSTTRACE_DEBUG(
OMNITRACE_DEBUG(
"Warning! Calling fork() within an OpenMPI application using libfabric "
"may result is segmentation fault\n");
TIMEMORY_CONDITIONAL_DEMANGLED_BACKTRACE(get_debug(), 16);
@@ -42,5 +42,5 @@ fork_gotcha::audit(const gotcha_data_t&, audit::incoming)
void
fork_gotcha::audit(const gotcha_data_t& _data, audit::outgoing, pid_t _pid)
{
HOSTTRACE_DEBUG("%s() return PID %i\n", _data.tool_id.c_str(), (int) _pid);
OMNITRACE_DEBUG("%s() return PID %i\n", _data.tool_id.c_str(), (int) _pid);
}
@@ -29,29 +29,29 @@
#include "library/mpi_gotcha.hpp"
#include "library/config.hpp"
#include "library/debug.hpp"
#include "library/hosttrace_component.hpp"
#include "library/omnitrace_component.hpp"
namespace
{
uint64_t mpip_index = std::numeric_limits<uint64_t>::max();
std::string mpi_init_string = {};
// this ensures hosttrace_trace_finalize is called before MPI_Finalize
// this ensures omnitrace_trace_finalize is called before MPI_Finalize
void
hosttrace_mpi_set_attr()
omnitrace_mpi_set_attr()
{
#if defined(TIMEMORY_USE_MPI)
static auto _mpi_copy = [](MPI_Comm, int, void*, void*, void*, int*) {
return MPI_SUCCESS;
};
static auto _mpi_fini = [](MPI_Comm, int, void*, void*) {
HOSTTRACE_DEBUG("MPI Comm attribute finalize\n");
OMNITRACE_DEBUG("MPI Comm attribute finalize\n");
if(mpip_index != std::numeric_limits<uint64_t>::max())
comp::deactivate_mpip<tim::component_tuple<hosttrace_component>, hosttrace>(
comp::deactivate_mpip<tim::component_tuple<omnitrace_component>, omnitrace>(
mpip_index);
if(!mpi_init_string.empty()) hosttrace_pop_trace(mpi_init_string.c_str());
if(!mpi_init_string.empty()) omnitrace_pop_trace(mpi_init_string.c_str());
mpi_init_string = {};
hosttrace_trace_finalize();
omnitrace_trace_finalize();
return MPI_SUCCESS;
};
using copy_func_t = int (*)(MPI_Comm, int, void*, void*, void*, int*);
@@ -68,7 +68,7 @@ hosttrace_mpi_set_attr()
void
mpi_gotcha::audit(const gotcha_data_t& _data, audit::incoming, int*, char***)
{
HOSTTRACE_DEBUG("[%s] %s(int*, char***)\n", __FUNCTION__, _data.tool_id.c_str());
OMNITRACE_DEBUG("[%s] %s(int*, char***)\n", __FUNCTION__, _data.tool_id.c_str());
if(get_state() == ::State::DelayedInit)
{
get_state() = ::State::PreInit;
@@ -79,7 +79,7 @@ mpi_gotcha::audit(const gotcha_data_t& _data, audit::incoming, int*, char***)
void
mpi_gotcha::audit(const gotcha_data_t& _data, audit::incoming, int*, char***, int, int*)
{
HOSTTRACE_DEBUG("[%s] %s(int*, char***, int, int*)\n", __FUNCTION__,
OMNITRACE_DEBUG("[%s] %s(int*, char***, int, int*)\n", __FUNCTION__,
_data.tool_id.c_str());
if(get_state() == ::State::DelayedInit)
{
@@ -88,40 +88,89 @@ mpi_gotcha::audit(const gotcha_data_t& _data, audit::incoming, int*, char***, in
}
}
void
mpi_gotcha::audit(const gotcha_data_t& _data, audit::incoming)
{
OMNITRACE_DEBUG("[%s] %s()\n", __FUNCTION__, _data.tool_id.c_str());
if(mpip_index != std::numeric_limits<uint64_t>::max())
comp::deactivate_mpip<tim::component_tuple<omnitrace_component>, omnitrace>(
mpip_index);
if(!mpi_init_string.empty()) omnitrace_pop_trace(mpi_init_string.c_str());
mpi_init_string = {};
omnitrace_trace_finalize();
}
void
mpi_gotcha::audit(const gotcha_data_t& _data, audit::incoming, comm_t _comm, int* _val)
{
OMNITRACE_DEBUG("[%s] %s()\n", __FUNCTION__, _data.tool_id.c_str());
m_comm = _comm;
if(_data.tool_id == "MPI_Comm_rank")
{
m_rank = _val;
}
else if(_data.tool_id == "MPI_Comm_size")
{
m_size = _val;
}
else
{
OMNITRACE_PRINT("[%s] %s(<comm>, %p) :: unexpected function wrapper\n",
__FUNCTION__, _data.tool_id.c_str(), _val);
}
}
void
mpi_gotcha::audit(const gotcha_data_t& _data, audit::outgoing, int _retval)
{
HOSTTRACE_DEBUG("[%s] %s() returned %i\n", __FUNCTION__, _data.tool_id.c_str(),
OMNITRACE_DEBUG("[%s] %s() returned %i\n", __FUNCTION__, _data.tool_id.c_str(),
(int) _retval);
if(_retval == tim::mpi::success_v && get_state() == ::State::PreInit)
if(_retval == tim::mpi::success_v && get_state() == ::State::PreInit &&
_data.tool_id.find("MPI_Init") == 0)
{
hosttrace_mpi_set_attr();
// hosttrace will set this environement variable to true in binary rewrite mode
omnitrace_mpi_set_attr();
// omnitrace will set this environement variable to true in binary rewrite mode
// when it detects MPI. Hides this env variable from the user to avoid this
// being activated unwaringly during runtime instrumentation because that
// will result in double instrumenting the MPI functions (unless the MPI functions
// were excluded via a regex expression)
if(get_use_mpip())
{
HOSTTRACE_DEBUG("[%s] Activating MPI wrappers...\n", __FUNCTION__);
comp::configure_mpip<tim::component_tuple<hosttrace_component>, hosttrace>();
mpip_index = comp::activate_mpip<tim::component_tuple<hosttrace_component>,
hosttrace>();
OMNITRACE_DEBUG("[%s] Activating MPI wrappers...\n", __FUNCTION__);
comp::configure_mpip<tim::component_tuple<omnitrace_component>, omnitrace>();
mpip_index = comp::activate_mpip<tim::component_tuple<omnitrace_component>,
omnitrace>();
}
hosttrace_push_trace(_data.tool_id.c_str());
omnitrace_push_trace(_data.tool_id.c_str());
}
else if(_retval == tim::mpi::success_v && _data.tool_id.find("MPI_Comm_") == 0)
{
/*if(_data.tool_id == "MPI_Comm_rank")
{
if(m_rank)
tim::mpi::set_rank(*m_rank, m_comm);
else
{
OMNITRACE_PRINT("[%s] %s() returned %i :: nullptr to rank\n",
__FUNCTION__, _data.tool_id.c_str(), (int) _retval);
}
}
else if(_data.tool_id == "MPI_Comm_size")
{
if(m_size)
tim::mpi::set_size(*m_size, m_comm);
else
{
OMNITRACE_PRINT("[%s] %s() returned %i :: nullptr to size\n",
__FUNCTION__, _data.tool_id.c_str(), (int) _retval);
}
}
else
{
OMNITRACE_PRINT("[%s] %s() returned %i :: unexpected function wrapper\n",
__FUNCTION__, _data.tool_id.c_str(), (int) _retval);
}*/
}
}
void
mpi_gotcha::audit(const gotcha_data_t& _data, audit::incoming)
{
HOSTTRACE_DEBUG("[%s] %s()\n", __FUNCTION__, _data.tool_id.c_str());
if(mpip_index != std::numeric_limits<uint64_t>::max())
comp::deactivate_mpip<tim::component_tuple<hosttrace_component>, hosttrace>(
mpip_index);
if(!mpi_init_string.empty()) hosttrace_pop_trace(mpi_init_string.c_str());
mpi_init_string = {};
hosttrace_trace_finalize();
}
TIMEMORY_INITIALIZE_STORAGE(mpi_gotcha)
@@ -26,25 +26,25 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH
// THE SOFTWARE.
#include "library/hosttrace_component.hpp"
#include "library/omnitrace_component.hpp"
#include "library/api.hpp"
void
hosttrace_component::start()
omnitrace_component::start()
{
if(m_prefix) hosttrace_push_trace(m_prefix);
if(m_prefix) omnitrace_push_trace(m_prefix);
}
void
hosttrace_component::stop()
omnitrace_component::stop()
{
if(m_prefix) hosttrace_pop_trace(m_prefix);
if(m_prefix) omnitrace_pop_trace(m_prefix);
}
void
hosttrace_component::set_prefix(const char* _prefix)
omnitrace_component::set_prefix(const char* _prefix)
{
m_prefix = _prefix;
}
TIMEMORY_INITIALIZE_STORAGE(hosttrace_component)
TIMEMORY_INITIALIZE_STORAGE(omnitrace_component)
@@ -39,7 +39,7 @@ namespace component
void
roctracer::preinit()
{
HOSTTRACE_DEBUG("[%s]\n", __FUNCTION__);
OMNITRACE_DEBUG("[%s]\n", __FUNCTION__);
roctracer_data::label() = "roctracer";
roctracer_data::description() = "ROCm tracer (activity API)";
}
@@ -98,12 +98,12 @@ roctracer::setup()
auto_lock_t _lk{ type_mutex<roctracer>() };
if(roctracer_is_setup()) return;
roctracer_is_setup() = true;
HOSTTRACE_DEBUG("[%s]\n", __FUNCTION__);
OMNITRACE_DEBUG("[%s]\n", __FUNCTION__);
tim::set_env("HSA_TOOLS_LIB", "libhosttrace.so", 0);
tim::set_env("HSA_TOOLS_LIB", "libomnitrace.so", 0);
auto _kfdwrapper = dynamic_library{ "HOSTTRACE_ROCTRACER_LIBKFDWRAPPER",
HOSTTRACE_ROCTRACER_LIBKFDWRAPPER };
auto _kfdwrapper = dynamic_library{ "OMNITRACE_ROCTRACER_LIBKFDWRAPPER",
OMNITRACE_ROCTRACER_LIBKFDWRAPPER };
ROCTRACER_CALL(roctracer_set_properties(ACTIVITY_DOMAIN_HIP_API, nullptr));
@@ -134,7 +134,7 @@ roctracer::tear_down()
auto_lock_t _lk{ type_mutex<roctracer>() };
if(!roctracer_is_setup()) return;
roctracer_is_setup() = false;
HOSTTRACE_DEBUG("[%s]\n", __FUNCTION__);
OMNITRACE_DEBUG("[%s]\n", __FUNCTION__);
// flush all the activity
if(roctracer_default_pool() != nullptr)
@@ -185,7 +185,7 @@ extern "C"
bool OnLoad(HsaApiTable* table, uint64_t runtime_version, uint64_t failed_tool_count,
const char* const* failed_tool_names)
{
HOSTTRACE_DEBUG("[%s]\n", __FUNCTION__);
OMNITRACE_DEBUG("[%s]\n", __FUNCTION__);
tim::consume_parameters(table, runtime_version, failed_tool_count,
failed_tool_names);
@@ -218,7 +218,7 @@ extern "C"
// initialize HSA tracing
roctracer_set_properties(ACTIVITY_DOMAIN_HSA_API, (void*) table);
HOSTTRACE_DEBUG(" HSA-trace(");
OMNITRACE_DEBUG(" HSA-trace(");
if(!hsa_api_vec.empty())
{
for(const auto& itr : hsa_api_vec)
@@ -230,7 +230,7 @@ extern "C"
ROCTRACER_CALL(roctracer_enable_op_callback(
ACTIVITY_DOMAIN_HSA_API, cid, hsa_api_callback, nullptr));
HOSTTRACE_DEBUG(" %s", api);
OMNITRACE_DEBUG(" %s", api);
}
}
else
@@ -238,7 +238,7 @@ extern "C"
ROCTRACER_CALL(roctracer_enable_domain_callback(
ACTIVITY_DOMAIN_HSA_API, hsa_api_callback, nullptr));
}
HOSTTRACE_DEBUG("\n");
OMNITRACE_DEBUG("\n");
}
bool trace_hsa_activity = get_trace_hsa_activity();
@@ -253,7 +253,7 @@ extern "C"
};
roctracer_set_properties(ACTIVITY_DOMAIN_HSA_OPS, &ops_properties);
HOSTTRACE_DEBUG(" HSA-activity-trace()\n");
OMNITRACE_DEBUG(" HSA-activity-trace()\n");
ROCTRACER_CALL(roctracer_enable_op_activity(ACTIVITY_DOMAIN_HSA_OPS,
HSA_OP_ID_COPY));
}
@@ -277,7 +277,7 @@ extern "C"
// HSA-runtime on-unload method
void OnUnload()
{
HOSTTRACE_DEBUG("[%s]\n", __FUNCTION__);
OMNITRACE_DEBUG("[%s]\n", __FUNCTION__);
// ONLOAD_TRACE("");
}
}
@@ -49,7 +49,7 @@ auto&
get_roctracer_hip_data(int64_t _tid = threading::get_id())
{
using data_t = std::unordered_map<uint64_t, roctracer_bundle_t>;
using thread_data_t = hosttrace_thread_data<data_t, api::roctracer>;
using thread_data_t = omnitrace_thread_data<data_t, api::roctracer>;
static auto& _v = thread_data_t::instances(thread_data_t::construct_on_init{});
return _v.at(_tid);
}
@@ -80,7 +80,7 @@ auto&
get_hip_activity_callbacks(int64_t _tid = threading::get_id())
{
using thread_data_t =
hosttrace_thread_data<std::vector<std::function<void()>>, api::roctracer>;
omnitrace_thread_data<std::vector<std::function<void()>>, api::roctracer>;
static auto& _v = thread_data_t::instances(thread_data_t::construct_on_init{});
return _v.at(_tid);
}
@@ -113,7 +113,7 @@ hsa_api_callback(uint32_t domain, uint32_t cid, const void* callback_data, void*
(void) arg;
const hsa_api_data_t* data = reinterpret_cast<const hsa_api_data_t*>(callback_data);
HOSTTRACE_DEBUG("<%-30s id(%u)\tcorrelation_id(%lu) %s>\n",
OMNITRACE_DEBUG("<%-30s id(%u)\tcorrelation_id(%lu) %s>\n",
roctracer_op_string(domain, cid, 0), cid, data->correlation_id,
(data->phase == ACTIVITY_API_PHASE_ENTER) ? "on-enter" : "on-exit");
@@ -295,7 +295,7 @@ hip_api_callback(uint32_t domain, uint32_t cid, const void* callback_data, void*
if(op_name == nullptr) return;
const hip_api_data_t* data = reinterpret_cast<const hip_api_data_t*>(callback_data);
HOSTTRACE_DEBUG("<%-30s id(%u)\tcorrelation_id(%lu) %s>\n", op_name, cid,
OMNITRACE_DEBUG("<%-30s id(%u)\tcorrelation_id(%lu) %s>\n", op_name, cid,
data->correlation_id,
(data->phase == ACTIVITY_API_PHASE_ENTER) ? "on-enter" : "on-exit");
@@ -450,7 +450,7 @@ hip_activity_callback(const char* begin, const char* end, void*)
const roctracer_record_t* end_record =
reinterpret_cast<const roctracer_record_t*>(end);
HOSTTRACE_DEBUG("Activity records:\n");
OMNITRACE_DEBUG("Activity records:\n");
while(record < end_record)
{
@@ -460,7 +460,7 @@ hip_activity_callback(const char* begin, const char* end, void*)
if(op_name != nullptr)
{
HOSTTRACE_DEBUG("\t%-30s\tcorrelation_id(%6lu) time_ns(%12lu:%12lu) "
OMNITRACE_DEBUG("\t%-30s\tcorrelation_id(%6lu) time_ns(%12lu:%12lu) "
"delta_ns(%12lu) device_id(%d) "
"stream_id(%lu)\n",
op_name, record->correlation_id, record->begin_ns,
@@ -26,7 +26,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH
// THE SOFTWARE.
#include "hosttrace.hpp"
#include "omnitrace.hpp"
#include <sys/stat.h>
#include <sys/types.h>
@@ -52,10 +52,10 @@ static std::map<string_t, call_expr_pointer_t> beg_expr = {};
static std::map<string_t, call_expr_pointer_t> end_expr = {};
static const auto npos_v = string_t::npos;
static string_t instr_mode = "trace";
static string_t instr_push_func = "hosttrace_push_trace";
static string_t instr_pop_func = "hosttrace_pop_trace";
static string_t instr_push_hash = "hosttrace_push_trace_hash";
static string_t instr_pop_hash = "hosttrace_pop_trace_hash";
static string_t instr_push_func = "omnitrace_push_trace";
static string_t instr_pop_func = "omnitrace_pop_trace";
static string_t instr_push_hash = "omnitrace_push_trace_hash";
static string_t instr_pop_hash = "omnitrace_pop_trace_hash";
static string_t print_instrumented = {};
static string_t print_available = {};
static string_t print_overlapping = {};
@@ -100,7 +100,7 @@ main(int argc, char** argv)
tim::set_env<string_t>("DYNINSTAPI_RT_LIB",
TIMEMORY_JOIN('/', itr, "libdyninstAPI_RT.a"), 0);
}
verbprintf(0, "[hosttrace] DYNINST_API_RT: %s\n",
verbprintf(0, "[omnitrace] DYNINST_API_RT: %s\n",
tim::get_env<string_t>("DYNINSTAPI_RT_LIB", "").c_str());
argv0 = argv[0];
@@ -184,19 +184,19 @@ main(int argc, char** argv)
if(verbose_level > 1)
{
std::cout << "[hosttrace][original]: " << cmd_string(argc, argv) << std::endl;
std::cout << "[hosttrace][cfg-args]: " << cmd_string(_argc, _argv) << std::endl;
std::cout << "[omnitrace][original]: " << cmd_string(argc, argv) << std::endl;
std::cout << "[omnitrace][cfg-args]: " << cmd_string(_argc, _argv) << std::endl;
}
if(_cmdc > 0)
std::cout << "\n[hosttrace][command]: " << cmd_string(_cmdc, _cmdv) << "\n\n";
std::cout << "\n[omnitrace][command]: " << cmd_string(_cmdc, _cmdv) << "\n\n";
if(_cmdc > 0) cmdv0 = _cmdv[0];
std::stringstream jump_description;
jump_description
<< "Instrument with function pointers in HOSTTRACE_JUMP_LIBRARY (default: "
<< tim::get_env<string_t>("HOSTTRACE_JUMP_LIBRARY", "jump/libhosttrace.so")
<< "Instrument with function pointers in OMNITRACE_JUMP_LIBRARY (default: "
<< tim::get_env<string_t>("OMNITRACE_JUMP_LIBRARY", "jump/libomnitrace.so")
<< ")";
// now can loop through the options. If the first character is '-', then we know
@@ -204,7 +204,7 @@ main(int argc, char** argv)
// it is unrecognized, then set the errflag to report an error. When we come to a
// non '-' charcter, then we must be at the application name.
using parser_t = tim::argparse::argument_parser;
parser_t parser("hosttrace");
parser_t parser("omnitrace");
parser.enable_help();
parser.add_argument()
@@ -251,7 +251,7 @@ main(int argc, char** argv)
parser.add_argument()
.names({ "-L", "--library" })
.description(
"Libraries with instrumentation routines (default: \"libhosttrace\")");
"Libraries with instrumentation routines (default: \"libomnitrace\")");
parser.add_argument()
.names({ "-S", "--stdlib" })
.description("Enable instrumentation of C++ standard library functions.")
@@ -267,17 +267,17 @@ main(int argc, char** argv)
parser.add_argument()
.names({ "-d", "--default-components" })
.description("Default components to instrument (only useful when timemory is "
"enabled in hosttrace library)");
"enabled in omnitrace library)");
parser.add_argument()
.names({ "-M", "--mode" })
.description("Instrumentation mode. 'trace' mode is immutable, 'region' mode is "
"mutable by hosttrace library interface")
"mutable by omnitrace library interface")
.choices({ "trace", "region" })
.count(1);
parser.add_argument()
.names({ "--env" })
.description("Environment variables to add to the runtime in form "
"VARIABLE=VALUE. E.g. use '--env HOSTTRACE_USE_TIMEMORY=ON' to "
"VARIABLE=VALUE. E.g. use '--env OMNITRACE_USE_TIMEMORY=ON' to "
"default to using timemory instead of perfetto");
parser.add_argument()
.names({ "--prefer" })
@@ -289,7 +289,7 @@ main(int argc, char** argv)
.action([](auto&) { is_driver = true; });
parser
.add_argument({ "--mpi" },
"Enable MPI support (requires hosttrace built w/ MPI and GOTCHA "
"Enable MPI support (requires omnitrace built w/ MPI and GOTCHA "
"support). NOTE: this will automatically be activated if "
"MPI_Init/MPI_Init_thread and MPI_Finalize are found in the symbol "
"table of target")
@@ -489,7 +489,7 @@ main(int argc, char** argv)
if(!parser.exists("L"))
{
for(auto& itr : inputlib)
itr += "libhosttrace";
itr += "libomnitrace";
if(parser.exists("s"))
{
@@ -540,10 +540,10 @@ main(int argc, char** argv)
if(parser.exists("M"))
{
instr_mode = parser.get<string_t>("M");
instr_push_func = "hosttrace_push_" + instr_mode;
instr_push_hash = "hosttrace_push_" + instr_mode + "_hash";
instr_pop_func = "hosttrace_pop_" + instr_mode;
instr_pop_hash = "hosttrace_pop_" + instr_mode + "_hash";
instr_push_func = "omnitrace_push_" + instr_mode;
instr_push_hash = "omnitrace_push_" + instr_mode + "_hash";
instr_pop_func = "omnitrace_pop_" + instr_mode;
instr_pop_hash = "omnitrace_pop_" + instr_mode + "_hash";
}
if(parser.exists("prefer")) prefer_library = parser.get<string_t>("prefer");
@@ -584,7 +584,7 @@ main(int argc, char** argv)
auto _pos = _exe_base.find_last_of('/');
if(_pos != std::string::npos && _pos + 1 < _exe_base.length())
_exe_base = _exe_base.substr(_pos + 1);
modfunc_dump_dir = TIMEMORY_JOIN("-", "hosttrace", _exe_base, "output");
modfunc_dump_dir = TIMEMORY_JOIN("-", "omnitrace", _exe_base, "output");
}
if(verbose_level >= 0) tim::makedir(modfunc_dump_dir);
@@ -601,8 +601,8 @@ main(int argc, char** argv)
if(!regex_expr.empty()) regex_array.push_back(std::regex(regex_expr, regex_opts));
};
add_regex(func_include, tim::get_env<string_t>("HOSTTRACE_REGEX_INCLUDE", ""));
add_regex(func_exclude, tim::get_env<string_t>("HOSTTRACE_REGEX_EXCLUDE", ""));
add_regex(func_include, tim::get_env<string_t>("OMNITRACE_REGEX_INCLUDE", ""));
add_regex(func_exclude, tim::get_env<string_t>("OMNITRACE_REGEX_EXCLUDE", ""));
if(parser.exists("R"))
{
@@ -672,8 +672,8 @@ main(int argc, char** argv)
{
parser.print_help(extra_help);
fprintf(stderr, "\nError! No command for dynamic instrumentation. Use "
"\n\thosttrace <OPTIONS> -- <COMMAND> <ARGS>\nE.g. "
"\n\thosttrace -o foo.inst -- ./foo\nwill output an "
"\n\tomnitrace <OPTIONS> -- <COMMAND> <ARGS>\nE.g. "
"\n\tomnitrace -o foo.inst -- ./foo\nwill output an "
"instrumented version of 'foo' executable to 'foo.inst'\n");
return EXIT_FAILURE;
}
@@ -705,11 +705,11 @@ main(int argc, char** argv)
//----------------------------------------------------------------------------------//
addr_space =
hosttrace_get_address_space(bpatch, _cmdc, _cmdv, binary_rewrite, _pid, mutname);
omnitrace_get_address_space(bpatch, _cmdc, _cmdv, binary_rewrite, _pid, mutname);
if(!addr_space)
{
fprintf(stderr, "[hosttrace]> Error! address space for dynamic "
fprintf(stderr, "[omnitrace]> Error! address space for dynamic "
"instrumentation was not created\n");
exit(EXIT_FAILURE);
}
@@ -928,11 +928,11 @@ main(int argc, char** argv)
auto* exit_trace = find_function(app_image, instr_pop_func.c_str());
auto* entr_hash = find_function(app_image, instr_push_hash.c_str());
auto* exit_hash = find_function(app_image, instr_pop_hash.c_str());
auto* init_func = find_function(app_image, "hosttrace_trace_init");
auto* fini_func = find_function(app_image, "hosttrace_trace_finalize");
auto* env_func = find_function(app_image, "hosttrace_trace_set_env");
auto* mpi_func = find_function(app_image, "hosttrace_trace_set_mpi");
auto* hash_func = find_function(app_image, "hosttrace_add_hash_id");
auto* init_func = find_function(app_image, "omnitrace_trace_init");
auto* fini_func = find_function(app_image, "omnitrace_trace_finalize");
auto* env_func = find_function(app_image, "omnitrace_trace_set_env");
auto* mpi_func = find_function(app_image, "omnitrace_trace_set_mpi");
auto* hash_func = find_function(app_image, "omnitrace_add_hash_id");
auto* mpi_init_func = find_function(app_image, "MPI_Init", { "MPI_Init_thread" });
auto* mpi_fini_func = find_function(app_image, "MPI_Finalize");
@@ -986,9 +986,9 @@ main(int argc, char** argv)
if(_pos != npos_v) _name = _name.substr(_pos + 1);
_pos = _name.find('.');
if(_pos != npos_v) _name = _name.substr(0, _pos);
_pos = _name.find("libhosttrace-");
_pos = _name.find("libomnitrace-");
if(_pos != npos_v)
_name = _name.erase(_pos, std::string("libhosttrace-").length());
_name = _name.erase(_pos, std::string("libomnitrace-").length());
_pos = _name.find("lib");
if(_pos == 0) _name = _name.substr(_pos + std::string("lib").length());
while((_pos = _name.find('-')) != npos_v)
@@ -997,7 +997,7 @@ main(int argc, char** argv)
verbprintf(2,
"Supplemental instrumentation library '%s' is named '%s' after "
"removing everything before last '/', everything after first '.', and "
"'libhosttrace-'...\n",
"'libomnitrace-'...\n",
itr.c_str(), _name.c_str());
use_stubs[_name] = false;
@@ -1043,8 +1043,8 @@ main(int argc, char** argv)
}
// check standard function signature if no user-specified matches
if(add_instr_library(_name, TIMEMORY_JOIN("", "hosttrace_register_" + _name),
TIMEMORY_JOIN("", "hosttrace_deregister_" + _name)))
if(add_instr_library(_name, TIMEMORY_JOIN("", "omnitrace_register_" + _name),
TIMEMORY_JOIN("", "omnitrace_deregister_" + _name)))
continue;
found_instr_functions:
@@ -1059,16 +1059,16 @@ main(int argc, char** argv)
if(!main_func && is_driver)
{
fprintf(stderr, "[hosttrace]> Couldn't find '%s'\n", main_fname.c_str());
fprintf(stderr, "[omnitrace]> Couldn't find '%s'\n", main_fname.c_str());
if(!_mutatee_init || !_mutatee_fini)
{
fprintf(stderr, "[hosttrace]> Couldn't find '%s' or '%s', aborting\n",
fprintf(stderr, "[omnitrace]> Couldn't find '%s' or '%s', aborting\n",
"_init", "_fini");
throw std::runtime_error("Could not find main function");
}
else
{
fprintf(stderr, "[hosttrace]> using '%s' and '%s' in lieu of '%s'...",
fprintf(stderr, "[omnitrace]> using '%s' and '%s' in lieu of '%s'...",
"_init", "_fini", main_fname.c_str());
}
}
@@ -1081,23 +1081,23 @@ main(int argc, char** argv)
for(const auto& itr :
{ pair_t(main_func, main_fname), pair_t(entr_trace, instr_push_func),
pair_t(exit_trace, instr_pop_func), pair_t(init_func, "hosttrace_trace_init"),
pair_t(fini_func, "hosttrace_trace_finalize"),
pair_t(env_func, "hosttrace_trace_set_env") })
pair_t(exit_trace, instr_pop_func), pair_t(init_func, "omnitrace_trace_init"),
pair_t(fini_func, "omnitrace_trace_finalize"),
pair_t(env_func, "omnitrace_trace_set_env") })
{
if(itr.first == main_func && !is_driver) continue;
if(!itr.first)
{
stringstream_t ss;
ss << "Error! Couldn't find '" << itr.second.c_str() << "' function";
fprintf(stderr, "[hosttrace]> %s\n", ss.str().c_str());
fprintf(stderr, "[omnitrace]> %s\n", ss.str().c_str());
throw std::runtime_error(ss.str());
}
}
if(use_mpi && !(mpi_func || (mpi_init_func && mpi_fini_func)))
{
throw std::runtime_error("MPI support was requested but hosttrace was not built "
throw std::runtime_error("MPI support was requested but omnitrace was not built "
"with MPI and GOTCHA support");
}
@@ -1176,20 +1176,20 @@ main(int argc, char** argv)
verbprintf(2, "Getting call expressions... ");
auto main_call_args = hosttrace_call_expr(main_sign.get());
auto init_call_args = hosttrace_call_expr(default_components, binary_rewrite, cmdv0);
auto fini_call_args = hosttrace_call_expr();
auto umpi_call_args = hosttrace_call_expr(use_mpi, is_attached);
auto main_call_args = omnitrace_call_expr(main_sign.get());
auto init_call_args = omnitrace_call_expr(default_components, binary_rewrite, cmdv0);
auto fini_call_args = omnitrace_call_expr();
auto umpi_call_args = omnitrace_call_expr(use_mpi, is_attached);
auto mode_call_args =
hosttrace_call_expr("HOSTTRACE_INSTRUMENTATION_MODE", instr_mode);
auto mpie_init_args = hosttrace_call_expr("HOSTTRACE_MPI_INIT", "OFF");
auto mpie_fini_args = hosttrace_call_expr("HOSTTRACE_MPI_FINALIZE", "OFF");
omnitrace_call_expr("OMNITRACE_INSTRUMENTATION_MODE", instr_mode);
auto mpie_init_args = omnitrace_call_expr("OMNITRACE_MPI_INIT", "OFF");
auto mpie_fini_args = omnitrace_call_expr("OMNITRACE_MPI_FINALIZE", "OFF");
auto trace_call_args =
hosttrace_call_expr("HOSTTRACE_COMPONENTS", default_components);
auto use_mpi_call_args = hosttrace_call_expr("HOSTTRACE_USE_PID", "ON");
auto use_mpip_call_args = hosttrace_call_expr(
"HOSTTRACE_USE_MPIP", (binary_rewrite && use_mpi && use_mpip) ? "ON" : "OFF");
auto none_call_args = hosttrace_call_expr();
omnitrace_call_expr("OMNITRACE_COMPONENTS", default_components);
auto use_mpi_call_args = omnitrace_call_expr("OMNITRACE_USE_PID", "ON");
auto use_mpip_call_args = omnitrace_call_expr(
"OMNITRACE_USE_MPIP", (binary_rewrite && use_mpi && use_mpip) ? "ON" : "OFF");
auto none_call_args = omnitrace_call_expr();
verbprintf(2, "Done\n");
verbprintf(2, "Getting call snippets... ");
@@ -1228,7 +1228,7 @@ main(int argc, char** argv)
<< " not in form VARIABLE=VALUE\n";
throw std::runtime_error("Bad format");
}
auto _expr = hosttrace_call_expr(p.at(0), p.at(1));
auto _expr = omnitrace_call_expr(p.at(0), p.at(1));
env_variables.push_back(_expr.get(env_func));
}
@@ -1474,10 +1474,10 @@ main(int argc, char** argv)
name.m_name.c_str());
auto _name = name.get();
auto _hash = std::hash<string_t>()(_name);
auto _trace_entr = (entr_hash) ? hosttrace_call_expr(_hash)
: hosttrace_call_expr(_name.c_str());
auto _trace_exit = (exit_hash) ? hosttrace_call_expr(_hash)
: hosttrace_call_expr(_name.c_str());
auto _trace_entr = (entr_hash) ? omnitrace_call_expr(_hash)
: omnitrace_call_expr(_name.c_str());
auto _trace_exit = (exit_hash) ? omnitrace_call_expr(_hash)
: omnitrace_call_expr(_name.c_str());
auto _entr = _trace_entr.get((entr_hash) ? entr_hash : entr_trace);
auto _exit = _trace_exit.get((exit_hash) ? exit_hash : exit_trace);
@@ -1527,11 +1527,11 @@ main(int argc, char** argv)
hash_ids.emplace_back(_lhash, _lname);
auto _lf = [=]() {
auto _ltrace_entr = (entr_hash)
? hosttrace_call_expr(_lhash)
: hosttrace_call_expr(_lname.c_str());
? omnitrace_call_expr(_lhash)
: omnitrace_call_expr(_lname.c_str());
auto _ltrace_exit = (exit_hash)
? hosttrace_call_expr(_lhash)
: hosttrace_call_expr(_lname.c_str());
? omnitrace_call_expr(_lhash)
: omnitrace_call_expr(_lname.c_str());
auto _lentr =
_ltrace_entr.get((entr_hash) ? entr_hash : entr_trace);
auto _lexit =
@@ -1580,7 +1580,7 @@ main(int argc, char** argv)
//
//----------------------------------------------------------------------------------//
hosttrace_snippet_vec hash_snippet_vec;
omnitrace_snippet_vec hash_snippet_vec;
// generate a call expression for each hash + key
for(auto& itr : hash_ids)
hash_snippet_vec.generate(hash_func, itr.first, itr.second.c_str());
@@ -1792,8 +1792,8 @@ main(int argc, char** argv)
if(main_func)
{
printf("[hosttrace]> Getting linked libraries for %s...\n", cmdv0.c_str());
printf("[hosttrace]> Consider instrumenting the relevant libraries...\n\n");
printf("[omnitrace]> Getting linked libraries for %s...\n", cmdv0.c_str());
printf("[omnitrace]> Consider instrumenting the relevant libraries...\n\n");
using TIMEMORY_PIPE = tim::popen::TIMEMORY_PIPE;
@@ -1804,7 +1804,7 @@ main(int argc, char** argv)
strvec_t linked_libraries = tim::popen::read_fork(ldd);
auto perr = tim::popen::pclose(ldd);
if(perr != 0) perror("Error in hosttrace_fork");
if(perr != 0) perror("Error in omnitrace_fork");
for(const auto& itr : linked_libraries)
printf("\t%s\n", itr.c_str());
@@ -1824,8 +1824,8 @@ main(int argc, char** argv)
// addr_space->beginInsertionSet();
verbprintf(4, "Registering fork callbacks...\n");
auto _prefork = bpatch->registerPreForkCallback(&hosttrace_fork_callback);
auto _postfork = bpatch->registerPostForkCallback(&hosttrace_fork_callback);
auto _prefork = bpatch->registerPreForkCallback(&omnitrace_fork_callback);
auto _postfork = bpatch->registerPostForkCallback(&omnitrace_fork_callback);
auto _wait_exec = [&]() {
while(!app_thread->isTerminated())
@@ -1854,7 +1854,7 @@ main(int argc, char** argv)
if(app_thread->terminationStatus() == ExitedNormally)
{
if(app_thread->isTerminated())
printf("\nEnd of hosttrace\n");
printf("\nEnd of omnitrace\n");
else
_wait_exec();
}
@@ -1925,7 +1925,7 @@ instrument_module(const string_t& file_name)
static std::regex ext_regex(ext_str, regex_opts);
static std::regex sys_regex("^(s|k|e|w)_[A-Za-z_0-9\\-]+\\.(c|C)$", regex_opts);
static std::regex userlib_regex(
"^(lib|)(hosttrace|caliper|gotcha|papi|cupti|TAU|likwid|"
"^(lib|)(omnitrace|caliper|gotcha|papi|cupti|TAU|likwid|"
"profiler|tcmalloc|dyninst|pfm|nvtx|upcxx|pthread|nvperf|hsa|\\.\\./sysdeps/|/"
"build/)",
regex_opts);
@@ -2028,7 +2028,7 @@ instrument_entity(const string_t& function_name)
}
static std::regex exclude(
"(hosttrace|tim::|cereal|N3tim|MPI_Init|MPI_Finalize|::__[A-Za-z]|"
"(omnitrace|tim::|cereal|N3tim|MPI_Init|MPI_Finalize|::__[A-Za-z]|"
"dyninst|tm_clones|malloc$|calloc$|free$|realloc$|std::addressof)",
regex_opts);
static std::regex exclude_cxx("(std::_Sp_counted_base|std::use_facet)", regex_opts);
@@ -2223,8 +2223,8 @@ module_constraint(char* fname)
// fname is the name of module/file
string_t _fname = fname;
// never instrumentat any module matching hosttrace
if(_fname.find("hosttrace") != string_t::npos) return true;
// never instrumentat any module matching omnitrace
if(_fname.find("omnitrace") != string_t::npos) return true;
// always instrument these modules
if(_fname == "DEFAULT_MODULE" || _fname == "LIBRARY_MODULE") return false;
@@ -2242,7 +2242,7 @@ bool
routine_constraint(const char* fname)
{
string_t _fname = fname;
if(_fname.find("hosttrace") != string_t::npos) return true;
if(_fname.find("omnitrace") != string_t::npos) return true;
auto npos = std::string::npos;
if(_fname.find("FunctionInfo") != npos || _fname.find("_L_lock") != npos ||
@@ -2283,7 +2283,7 @@ get_absolute_exe_filepath(std::string exe_name)
if(file_exists(TIMEMORY_JOIN('/', pitr, exe_name)))
{
exe_name = TIMEMORY_JOIN('/', pitr, exe_name);
verbprintf(0, "[hosttrace] Resolved '%s' to '%s'...\n", _exe_orig.c_str(),
verbprintf(0, "[omnitrace] Resolved '%s' to '%s'...\n", _exe_orig.c_str(),
exe_name.c_str());
break;
}
@@ -2318,7 +2318,7 @@ get_absolute_lib_filepath(std::string lib_name)
if(file_exists(TIMEMORY_JOIN('/', pitr, lib_name)))
{
lib_name = TIMEMORY_JOIN('/', pitr, lib_name);
verbprintf(0, "[hosttrace] Resolved '%s' to '%s'...\n", _lib_orig.c_str(),
verbprintf(0, "[omnitrace] Resolved '%s' to '%s'...\n", _lib_orig.c_str(),
lib_name.c_str());
break;
}
@@ -26,7 +26,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH
// THE SOFTWARE.
#include "hosttrace.hpp"
#include "omnitrace.hpp"
//======================================================================================//
//
@@ -258,7 +258,7 @@ find_function(image_t* app_image, const std::string& _name, strset_t _extra)
++itr;
}
if(!_func) verbprintf(2, "hosttrace: Unable to find function %s\n", _name.c_str());
if(!_func) verbprintf(2, "omnitrace: Unable to find function %s\n", _name.c_str());
return _func;
}