Skip to content

Commit

Permalink
Format source
Browse files Browse the repository at this point in the history
  • Loading branch information
dgaliffiAMD committed Oct 2, 2024
1 parent ba6d8ff commit 721a342
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 55 deletions.
10 changes: 5 additions & 5 deletions source/bin/omnitrace-causal/impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ forward_signal(int sig)
int
get_verbose()
{
verbose = get_env("ROCPROFSYS_CAUSAL_VERBOSE",
verbose = get_env("ROCPROFSYS_CAUSAL_VERBOSE",
get_env<int>("ROCPROFSYS_VERBOSE", verbose, false));
auto _debug =
get_env("ROCPROFSYS_CAUSAL_DEBUG", get_env<bool>("ROCPROFSYS_DEBUG", false, false));
auto _debug = get_env("ROCPROFSYS_CAUSAL_DEBUG",
get_env<bool>("ROCPROFSYS_DEBUG", false, false));
if(_debug) verbose += 8;
return verbose;
}
Expand Down Expand Up @@ -861,8 +861,8 @@ parse_args(int argc, char** argv, std::vector<char*>& _env,
auto _is_omni_cfg = [](std::string_view itr) {
return (itr.find("ROCPROFSYS") == 0 && itr.find("ROCPROFSYS_MODE") != 0 &&
itr.find("ROCPROFSYS_DEBUG_") != 0 && itr.find('=') < itr.length());
// rocprof-sys has miscellaneous env options starting with ROCPROFSYS_DEBUG_ that
// are not official options
// rocprof-sys has miscellaneous env options starting with ROCPROFSYS_DEBUG_
// that are not official options
};

auto _omni_env_m = std::map<std::string, std::string>{};
Expand Down
8 changes: 5 additions & 3 deletions source/bin/omnitrace-instrument/module_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,8 @@ module_function::is_internal_constrained() const
"rocprofsys-user)/.*/.*\\.(h|c|cpp|hpp)$" }))
return _report("Excluding", "module", "rocprofsys", 3);

if(std::regex_search(function_name, std::regex{ "9omnitrace|omnitrace|rocprofsys(::|_)" }))
if(std::regex_search(function_name,
std::regex{ "9omnitrace|omnitrace|rocprofsys(::|_)" }))
return _report("Excluding", "function", "rocprofsys", 3);
else if(std::regex_search(function_name, std::regex{ "3tim|tim::|timemory(::|_)" }))
return _report("Excluding", "function", "timemory", 3);
Expand Down Expand Up @@ -572,8 +573,9 @@ module_function::is_routine_constrained() const
return _report("Skipping", "function-constraint", 2);
}

static std::regex exclude(
"(rocprofsys|rocprof-sys|omnitrace|tim::|MPI_Init|MPI_Finalize|dyninst|DYNINST|tm_clones)", regex_opts);
static std::regex exclude("(rocprofsys|rocprof-sys|omnitrace|tim::|MPI_Init|MPI_"
"Finalize|dyninst|DYNINST|tm_clones)",
regex_opts);
// static std::regex exclude_printf("(|v|f)printf$", regex_opts);
static std::regex exclude_cxx(
"(std::_Sp_counted_base|std::(use|has)_facet|std::locale|::sentry|^std::_|::_(M|"
Expand Down
4 changes: 2 additions & 2 deletions source/bin/omnitrace-run/impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ get_verbose(parser_data_t& _data)
auto& verbose = _data.verbose;
verbose = get_env("ROCPROFSYS_CAUSAL_VERBOSE",
get_env<int>("ROCPROFSYS_VERBOSE", verbose, false));
auto _debug =
get_env("ROCPROFSYS_CAUSAL_DEBUG", get_env<bool>("ROCPROFSYS_DEBUG", false, false));
auto _debug = get_env("ROCPROFSYS_CAUSAL_DEBUG",
get_env<bool>("ROCPROFSYS_DEBUG", false, false));
if(_debug) verbose += 8;
return verbose;
}
Expand Down
6 changes: 4 additions & 2 deletions source/bin/omnitrace-sample/impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,8 @@ parse_args(int argc, char** argv, std::vector<char*>& _env)
.count(1)
.dtype("filepath")
.action([&](parser_t& p) {
update_env(_env, "ROCPROFSYS_PERFETTO_FILE", p.get<std::string>("trace-file"));
update_env(_env, "ROCPROFSYS_PERFETTO_FILE",
p.get<std::string>("trace-file"));
});
parser
.add_argument({ "--trace-buffer-size" },
Expand Down Expand Up @@ -534,7 +535,8 @@ parse_args(int argc, char** argv, std::vector<char*>& _env)
"that can changed via --trace-clock-id.")
.count(1)
.action([&](parser_t& p) {
update_env(_env, "ROCPROFSYS_TRACE_DURATION", p.get<double>("trace-duration"));
update_env(_env, "ROCPROFSYS_TRACE_DURATION",
p.get<double>("trace-duration"));
});
parser
.add_argument(
Expand Down
7 changes: 4 additions & 3 deletions source/lib/common/path.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
{ \
fflush(stderr); \
OMNITRACE_PATH_LOG_START \
fprintf(stderr, "[rocprof-sys]" OMNITRACE_PATH_LOG_NAME "[%i] ", getpid()); \
fprintf(stderr, "[rocprof-sys]" OMNITRACE_PATH_LOG_NAME "[%i] ", getpid()); \
fprintf(stderr, __VA_ARGS__); \
OMNITRACE_PATH_LOG_END \
fflush(stderr); \
Expand Down Expand Up @@ -181,8 +181,9 @@ template <typename RetT>
RetT
get_default_lib_search_paths()
{
auto _paths = join(":", get_env("ROCPROFSYS_PATH", ""), get_env("LD_LIBRARY_PATH", ""),
get_env("LIBRARY_PATH", ""), get_env("PWD", ""), ".");
auto _paths =
join(":", get_env("ROCPROFSYS_PATH", ""), get_env("LD_LIBRARY_PATH", ""),
get_env("LIBRARY_PATH", ""), get_env("PWD", ""), ".");
if constexpr(std::is_same<RetT, std::string>::value)
return _paths;
else
Expand Down
2 changes: 1 addition & 1 deletion source/lib/common/setup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
{ \
fflush(stderr); \
OMNITRACE_SETUP_LOG_START \
fprintf(stderr, "[rocprof-sys]" OMNITRACE_SETUP_LOG_NAME "[%i] ", getpid()); \
fprintf(stderr, "[rocprof-sys]" OMNITRACE_SETUP_LOG_NAME "[%i] ", getpid()); \
fprintf(stderr, __VA_ARGS__); \
OMNITRACE_SETUP_LOG_END \
fflush(stderr); \
Expand Down
36 changes: 20 additions & 16 deletions source/lib/core/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ using utility::parse_numeric_range;
[&]() { \
auto _ret = _config->insert<TYPE, TYPE>( \
ENV_NAME, get_setting_name(ENV_NAME), DESCRIPTION, TYPE{ INITIAL_VALUE }, \
std::set<std::string>{ "custom", "rocprofsys", "librocprof-sys", \
std::set<std::string>{ "custom", "rocprofsys", "librocprof-sys", \
__VA_ARGS__ }); \
if(!_ret.second) \
{ \
Expand All @@ -136,7 +136,7 @@ using utility::parse_numeric_range;
[&]() { \
auto _ret = _config->insert<TYPE, TYPE>( \
ENV_NAME, get_setting_name(ENV_NAME), DESCRIPTION, TYPE{ INITIAL_VALUE }, \
std::set<std::string>{ "custom", "rocprofsys", __VA_ARGS__ }); \
std::set<std::string>{ "custom", "rocprofsys", __VA_ARGS__ }); \
if(!_ret.second) \
{ \
OMNITRACE_PRINT("Warning! Duplicate setting: %s / %s\n", \
Expand All @@ -151,7 +151,7 @@ using utility::parse_numeric_range;
[&]() { \
auto _ret = _config->insert<TYPE, TYPE>( \
ENV_NAME, get_setting_name(ENV_NAME), DESCRIPTION, TYPE{ INITIAL_VALUE }, \
std::set<std::string>{ "custom", "rocprofsys", "librocprof-sys", \
std::set<std::string>{ "custom", "rocprofsys", "librocprof-sys", \
__VA_ARGS__ }, \
std::vector<std::string>{ CMD_LINE }); \
if(!_ret.second) \
Expand Down Expand Up @@ -267,7 +267,8 @@ configure_settings(bool _init)
"communicates with an allocator instance running in a background thread. Each "
"allocator only handles N sampling instances (where N is the value of "
"ROCPROFSYS_SAMPLING_ALLOCATOR_SIZE). When this hint is set to >= the number of "
"threads that get sampled, rocprof-sys can start all the background threads during "
"threads that get sampled, rocprof-sys can start all the background threads "
"during "
"initialization",
get_env<size_t>("ROCPROFSYS_NUM_THREADS", 1), "threading", "performance",
"sampling", "parallelism", "advanced");
Expand Down Expand Up @@ -727,11 +728,12 @@ configure_settings(bool _init)
std::string{ "perfetto-trace.proto" }, "perfetto", "io",
"filename", "advanced");

OMNITRACE_CONFIG_SETTING(bool, "ROCPROFSYS_USE_TEMPORARY_FILES",
"Write data to temporary files to minimize the memory usage "
"of rocprof-sys, e.g. call-stack samples will be periodically "
"written to a file and re-loaded during finalization",
true, "io", "data", "advanced");
OMNITRACE_CONFIG_SETTING(
bool, "ROCPROFSYS_USE_TEMPORARY_FILES",
"Write data to temporary files to minimize the memory usage "
"of rocprof-sys, e.g. call-stack samples will be periodically "
"written to a file and re-loaded during finalization",
true, "io", "data", "advanced");

OMNITRACE_CONFIG_SETTING(
std::string, "ROCPROFSYS_TMPDIR", "Base directory for temporary files",
Expand All @@ -740,7 +742,8 @@ configure_settings(bool _init)
OMNITRACE_CONFIG_SETTING(
std::string, "ROCPROFSYS_CAUSAL_BACKEND",
"Backend for call-stack sampling. See "
"https://rocm.docs.amd.com/projects/omnitrace/en/latest/how-to/performing-causal-profiling.html#backends for more "
"https://rocm.docs.amd.com/projects/omnitrace/en/latest/how-to/"
"performing-causal-profiling.html#backends for more "
"info. If set to \"auto\", rocprof-sys will attempt to use the perf backend and "
"fallback on the timer backend if unavailable",
std::string{ "auto" }, "causal", "analysis")
Expand Down Expand Up @@ -1823,8 +1826,9 @@ get_debug_sampling()
int
get_verbose_env()
{
return (settings_are_configured()) ? get_verbose()
: tim::get_env<int>("ROCPROFSYS_VERBOSE", 0, false);
return (settings_are_configured())
? get_verbose()
: tim::get_env<int>("ROCPROFSYS_VERBOSE", 0, false);
}

int
Expand Down Expand Up @@ -1917,8 +1921,8 @@ get_use_sampling()
static auto _v = get_config()->find("ROCPROFSYS_USE_SAMPLING");
return static_cast<tim::tsettings<bool>&>(*_v->second).get();
#else
OMNITRACE_THROW(
"Error! sampling was enabled but rocprof-sys was not built with libunwind support");
OMNITRACE_THROW("Error! sampling was enabled but rocprof-sys was not built with "
"libunwind support");
static bool _v = false;
return _v;
#endif
Expand Down Expand Up @@ -2617,8 +2621,8 @@ get_causal_mode()
{
if(!settings_are_configured())
{
auto _mode = tim::get_env_choice<std::string>("ROCPROFSYS_CAUSAL_MODE", "function",
{ "line", "function" });
auto _mode = tim::get_env_choice<std::string>("ROCPROFSYS_CAUSAL_MODE",
"function", { "line", "function" });
if(_mode == "line") return CausalMode::Line;
return CausalMode::Function;
}
Expand Down
9 changes: 5 additions & 4 deletions source/lib/omnitrace-dl/dl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@
if(VARNAME == nullptr && _omnitrace_dl_verbose >= _warn_verbose) \
{ \
OMNITRACE_COMMON_LIBRARY_LOG_START \
fprintf(stderr, "[rocprof-sys][dl][pid=%i]> %s :: %s\n", getpid(), FUNCNAME, \
fprintf(stderr, "[rocprof-sys][dl][pid=%i]> %s :: %s\n", getpid(), FUNCNAME, \
dlerror()); \
OMNITRACE_COMMON_LIBRARY_LOG_END \
} \
else if(_omnitrace_dl_verbose > _info_verbose) \
{ \
OMNITRACE_COMMON_LIBRARY_LOG_START \
fprintf(stderr, "[rocprof-sys][dl][pid=%i]> %s :: success\n", getpid(), \
fprintf(stderr, "[rocprof-sys][dl][pid=%i]> %s :: success\n", getpid(), \
FUNCNAME); \
OMNITRACE_COMMON_LIBRARY_LOG_END \
} \
Expand Down Expand Up @@ -258,7 +258,8 @@ struct OMNITRACE_INTERNAL_API indirect
if(_omnitrace_dl_verbose >= 2)
{
OMNITRACE_COMMON_LIBRARY_LOG_START
fprintf(stderr, "[rocprof-sys][dl][pid=%i] dlopen(\"%s\", %s) :: success\n",
fprintf(stderr,
"[rocprof-sys][dl][pid=%i] dlopen(\"%s\", %s) :: success\n",
getpid(), _lib.c_str(), _omnitrace_dl_dlopen_descr);
OMNITRACE_COMMON_LIBRARY_LOG_END
}
Expand Down Expand Up @@ -584,7 +585,7 @@ bool _omnitrace_dl_fini = (std::atexit([]() {
{ \
fflush(stderr); \
OMNITRACE_COMMON_LIBRARY_LOG_START \
fprintf(stderr, "[rocprof-sys][" OMNITRACE_COMMON_LIBRARY_NAME "][%i] ", \
fprintf(stderr, "[rocprof-sys][" OMNITRACE_COMMON_LIBRARY_NAME "][%i] ", \
getpid()); \
fprintf(stderr, __VA_ARGS__); \
OMNITRACE_COMMON_LIBRARY_LOG_END \
Expand Down
6 changes: 3 additions & 3 deletions source/lib/omnitrace/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,9 +598,9 @@ omnitrace_init_hidden(const char* _mode, bool _is_binary_rewrite, const char* _a
OMNITRACE_WARNING_F(
0,
"omnitrace_init(mode=%s, is_binary_rewrite=%s, argv0=%s) "
"called after rocprof-sys was initialized. state = %s. Mode-based settings "
"(via -M <MODE> passed to rocprof-sys exe) may not be properly "
"configured.\n",
"called after rocprof-sys was initialized. state = %s. Mode-based "
"settings (via -M <MODE> passed to rocprof-sys exe) may not be "
"properly configured.\n",
_mode, std::to_string(_is_binary_rewrite).c_str(), _argv0.c_str(),
std::to_string(get_state()).c_str());
}
Expand Down
11 changes: 6 additions & 5 deletions source/lib/omnitrace/library/causal/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ auto&
get_engine()
{
static auto _seed = []() -> hash_value_t {
auto _seed_v = config::get_setting_value<uint64_t>("ROCPROFSYS_CAUSAL_RANDOM_SEED")
.value_or(0);
auto _seed_v =
config::get_setting_value<uint64_t>("ROCPROFSYS_CAUSAL_RANDOM_SEED")
.value_or(0);
if(_seed_v == 0) _seed_v = std::random_device{}();
return _seed_v;
}();
Expand All @@ -134,9 +135,9 @@ get_filters(const std::set<binary::scope_filter::filter_scope>& _scopes = {

// exclude internal libraries used by rocprof-sys
if(_scopes.count(sf::BINARY_FILTER) > 0)
_filters.emplace_back(
sf{ sf::FILTER_EXCLUDE, sf::BINARY_FILTER,
"lib(omnitrace[-\\.]|rocprof-sys[-\\.]|dyninst|tbbmalloc|gotcha\\.|unwind\\.so\\.99)" });
_filters.emplace_back(sf{ sf::FILTER_EXCLUDE, sf::BINARY_FILTER,
"lib(omnitrace[-\\.]|rocprof-sys[-\\.]|dyninst|"
"tbbmalloc|gotcha\\.|unwind\\.so\\.99)" });

// in function mode, it generally doesn't help to experiment on main function since
// telling the user to "make the main function" faster is literally useless since it
Expand Down
5 changes: 4 additions & 1 deletion source/lib/omnitrace/library/components/category_region.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ struct category_region : comp::base<category_region<CategoryT>, void>

static constexpr auto category_name = trait::name<CategoryT>::value;

static std::string label() { return JOIN('_', "rocprofsys", category_name, "region"); }
static std::string label()
{
return JOIN('_', "rocprofsys", category_name, "region");
}

template <typename... OptsT, typename... Args>
static void start(std::string_view name, Args&&...);
Expand Down
3 changes: 2 additions & 1 deletion source/lib/omnitrace/library/kokkosp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ extern "C"
tim::consume_parameters(devInfoCount, deviceInfo);

OMNITRACE_BASIC_VERBOSE_F(
0, "Initializing rocprof-sys kokkos connector (sequence %d, version: %llu)... ",
0,
"Initializing rocprof-sys kokkos connector (sequence %d, version: %llu)... ",
loadSeq, (unsigned long long) interfaceVer);

if(_standalone_initialized || (!omnitrace::config::settings_are_configured() &&
Expand Down
16 changes: 8 additions & 8 deletions source/lib/omnitrace/library/rocm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,14 @@ extern "C"
if(_force_rocprofiler_init || (get_use_rocprofiler() && !_is_empty))
{
#if OMNITRACE_HIP_VERSION < 50500
auto _rocprof =
dynamic_library{ "ROCPROFSYS_ROCPROFILER_LIBRARY",
find_library_path("librocprofiler64.so",
{ "ROCPROFSYS_ROCM_PATH", "ROCM_PATH" },
{ OMNITRACE_DEFAULT_ROCM_PATH },
{ "lib", "lib64", "rocprofiler/lib",
"rocprofiler/lib64" }),
(RTLD_LAZY | RTLD_GLOBAL), false };
auto _rocprof = dynamic_library{
"ROCPROFSYS_ROCPROFILER_LIBRARY",
find_library_path(
"librocprofiler64.so", { "ROCPROFSYS_ROCM_PATH", "ROCM_PATH" },
{ OMNITRACE_DEFAULT_ROCM_PATH },
{ "lib", "lib64", "rocprofiler/lib", "rocprofiler/lib64" }),
(RTLD_LAZY | RTLD_GLOBAL), false
};

OMNITRACE_VERBOSE_F(1 || rocm::on_load_trace,
"Loading rocprofiler library (%s=%s)...\n",
Expand Down
3 changes: 2 additions & 1 deletion source/lib/omnitrace/library/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ namespace omnitrace
{
namespace
{
auto root_process_id = get_env<pid_t>("ROCPROFSYS_ROOT_PROCESS", process::get_id(), false);
auto root_process_id =
get_env<pid_t>("ROCPROFSYS_ROOT_PROCESS", process::get_id(), false);

auto&
get_sampling_on_child_threads_history(int64_t _idx = utility::get_thread_index())
Expand Down

0 comments on commit 721a342

Please sign in to comment.