diff --git a/projects/rocprofiler-systems/external/timemory b/projects/rocprofiler-systems/external/timemory index e4e430931c..33ef109c08 160000 --- a/projects/rocprofiler-systems/external/timemory +++ b/projects/rocprofiler-systems/external/timemory @@ -1 +1 @@ -Subproject commit e4e430931c7c32c9e81f7eca499c5d5a757d61d1 +Subproject commit 33ef109c0839fa694ba05f39a74106694aaeec15 diff --git a/projects/rocprofiler-systems/source/bin/omnitrace-avail/generate_config.cpp b/projects/rocprofiler-systems/source/bin/omnitrace-avail/generate_config.cpp index 65cb9b67dc..e887905762 100644 --- a/projects/rocprofiler-systems/source/bin/omnitrace-avail/generate_config.cpp +++ b/projects/rocprofiler-systems/source/bin/omnitrace-avail/generate_config.cpp @@ -175,8 +175,7 @@ void pop(type_list) type_list{})); } -void -update_choices(); +void update_choices(std::shared_ptr); void generate_config(std::string _config_file, const std::set& _config_fmts, @@ -184,7 +183,12 @@ generate_config(std::string _config_file, const std::set& _config_f { custom_setting_serializer::options = _options; - _config_file = settings::format(_config_file, settings::instance()->get_tag()); + auto _settings = tim::settings::shared_instance(); + tim::settings::push(); + _settings->find("suppress_config")->second->reset(); + _settings->find("suppress_parsing")->second->reset(); + + _config_file = settings::format(_config_file, _settings->get_tag()); bool _absolute = _config_file.at(0) == '/'; auto _dirs = tim::delimit(_config_file, "/\\/"); _config_file = _dirs.back(); @@ -211,7 +215,7 @@ generate_config(std::string _config_file, const std::set& _config_f } } - update_choices(); + update_choices(_settings); using json_t = cereal::PrettyJSONOutputArchive; using xml_t = cereal::XMLOutputArchive; @@ -221,8 +225,7 @@ generate_config(std::string _config_file, const std::set& _config_f static std::time_t _time{ std::time(nullptr) }; - auto _serialize = [](auto&& _ar) { - auto _settings = settings::shared_instance(); + auto _serialize = [_settings](auto&& _ar) { _ar->setNextName(TIMEMORY_PROJECT_NAME); _ar->startNode(); (*_ar)(cereal::make_nvp("version", std::string{ OMNITRACE_VERSION_STRING })); @@ -290,8 +293,7 @@ generate_config(std::string _config_file, const std::set& _config_f if(_config_fmts.count("txt") > 0) { std::stringstream _ss{}; - auto _settings = settings::shared_instance(); - size_t _w = min_width; + size_t _w = min_width; std::vector> _data{}; for(const auto& itr : *_settings) @@ -328,6 +330,16 @@ generate_config(std::string _config_file, const std::set& _config_f _lhs->get_env_name().find(itr) != 0) return false; } + for(const auto* itr : + { "OMNITRACE_SUPPRESS_PARSING", "OMNITRACE_SUPPRESS_CONFIG" }) + { + if(_lhs->get_env_name().find(itr) == 0 && + _rhs->get_env_name().find(itr) != 0) + return false; + if(_rhs->get_env_name().find(itr) == 0 && + _lhs->get_env_name().find(itr) != 0) + return true; + } return _lhs->get_name() < _rhs->get_name(); }); } @@ -398,10 +410,12 @@ generate_config(std::string _config_file, const std::set& _config_f // restores the original serializer pop(type_list{}); + + tim::settings::pop(); } void -update_choices() +update_choices(std::shared_ptr _settings) { std::vector _info = get_component_info(); @@ -431,7 +445,6 @@ update_choices() if(settings::verbose() >= 2 || settings::debug()) printf("[omnitrace-avail] # of component choices: %zu\n", _component_choices.size()); - settings::shared_instance() - ->find("OMNITRACE_TIMEMORY_COMPONENTS") + _settings->find("OMNITRACE_TIMEMORY_COMPONENTS") ->second->set_choices(_component_choices); } diff --git a/projects/rocprofiler-systems/source/lib/omnitrace/library/config.cpp b/projects/rocprofiler-systems/source/lib/omnitrace/library/config.cpp index 0ee7fb9407..d2d00f7db7 100644 --- a/projects/rocprofiler-systems/source/lib/omnitrace/library/config.cpp +++ b/projects/rocprofiler-systems/source/lib/omnitrace/library/config.cpp @@ -76,12 +76,14 @@ get_setting_name(std::string _v) #define OMNITRACE_CONFIG_SETTING(TYPE, ENV_NAME, DESCRIPTION, INITIAL_VALUE, ...) \ [&]() { \ auto _ret = _config->insert( \ - ENV_NAME, get_setting_name(ENV_NAME), DESCRIPTION, INITIAL_VALUE, \ + ENV_NAME, get_setting_name(ENV_NAME), DESCRIPTION, TYPE{ INITIAL_VALUE }, \ std::set{ "custom", "omnitrace", "libomnitrace", \ __VA_ARGS__ }); \ if(!_ret.second) \ + { \ OMNITRACE_PRINT("Warning! Duplicate setting: %s / %s\n", \ get_setting_name(ENV_NAME).c_str(), ENV_NAME); \ + } \ return _config->find(ENV_NAME)->second; \ }() @@ -89,11 +91,13 @@ get_setting_name(std::string _v) #define OMNITRACE_CONFIG_EXT_SETTING(TYPE, ENV_NAME, DESCRIPTION, INITIAL_VALUE, ...) \ [&]() { \ auto _ret = _config->insert( \ - ENV_NAME, get_setting_name(ENV_NAME), DESCRIPTION, INITIAL_VALUE, \ + ENV_NAME, get_setting_name(ENV_NAME), DESCRIPTION, TYPE{ INITIAL_VALUE }, \ std::set{ "custom", "omnitrace", __VA_ARGS__ }); \ if(!_ret.second) \ + { \ OMNITRACE_PRINT("Warning! Duplicate setting: %s / %s\n", \ get_setting_name(ENV_NAME).c_str(), ENV_NAME); \ + } \ return _config->find(ENV_NAME)->second; \ }() @@ -102,12 +106,14 @@ get_setting_name(std::string _v) CMD_LINE, ...) \ [&]() { \ auto _ret = _config->insert( \ - ENV_NAME, get_setting_name(ENV_NAME), DESCRIPTION, INITIAL_VALUE, \ + ENV_NAME, get_setting_name(ENV_NAME), DESCRIPTION, TYPE{ INITIAL_VALUE }, \ std::set{ "custom", "omnitrace", "libomnitrace", __VA_ARGS__ }, \ std::vector{ CMD_LINE }); \ if(!_ret.second) \ + { \ OMNITRACE_PRINT("Warning! Duplicate setting: %s / %s\n", \ get_setting_name(ENV_NAME).c_str(), ENV_NAME); \ + } \ return _config->find(ENV_NAME)->second; \ }() } // namespace @@ -182,7 +188,7 @@ configure_settings(bool _init) std::string, "OMNITRACE_MODE", "Data collection mode. Used to set default values for OMNITRACE_USE_* options. " "Typically set by omnitrace binary instrumenter.", - "trace", "backend"); + std::string{ "trace" }, "backend"); OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_CI", "Enable some runtime validation checks (typically enabled " @@ -247,7 +253,7 @@ configure_settings(bool _init) OMNITRACE_CONFIG_SETTING(size_t, "OMNITRACE_INSTRUMENTATION_INTERVAL", "Instrumentation only takes measurements once every N " "function calls (not statistical)", - 1, "instrumentation", "data_sampling"); + size_t{ 1 }, "instrumentation", "data_sampling"); OMNITRACE_CONFIG_SETTING( double, "OMNITRACE_SAMPLING_FREQ", @@ -265,18 +271,19 @@ configure_settings(bool _init) "CPUs to collect frequency information for. Values should be separated by commas " "and can be explicit or ranges, e.g. 0,1,5-8. An empty value implies 'all' and " "'none' suppresses all CPU frequency sampling", - "", "process_sampling"); + std::string{}, "process_sampling"); OMNITRACE_CONFIG_SETTING(std::string, "OMNITRACE_ROCM_SMI_DEVICES", - "[DEPRECATED] Renamed to OMNITRACE_SAMPLING_GPUS", "all", - "rocm_smi", "rocm", "process_sampling", "deprecated"); + "[DEPRECATED] Renamed to OMNITRACE_SAMPLING_GPUS", + std::string{ "all" }, "rocm_smi", "rocm", "process_sampling", + "deprecated"); OMNITRACE_CONFIG_SETTING( std::string, "OMNITRACE_SAMPLING_GPUS", "Devices to query when OMNITRACE_USE_ROCM_SMI=ON. Values should be separated by " "commas and can be explicit or ranges, e.g. 0,1,5-8. An empty value implies " "'all' and 'none' suppresses all GPU sampling", - "all", "rocm_smi", "rocm", "process_sampling"); + std::string{ "all" }, "rocm_smi", "rocm", "process_sampling"); auto _backend = tim::get_env_choice( "OMNITRACE_PERFETTO_BACKEND", @@ -342,11 +349,11 @@ configure_settings(bool _init) OMNITRACE_CONFIG_SETTING(size_t, "OMNITRACE_PERFETTO_SHMEM_SIZE_HINT_KB", "Hint for shared-memory buffer size in perfetto (in KB)", - 4096, "perfetto", "data"); + size_t{ 4096 }, "perfetto", "data"); OMNITRACE_CONFIG_SETTING(size_t, "OMNITRACE_PERFETTO_BUFFER_SIZE_KB", - "Size of perfetto buffer (in KB)", 1024000, "perfetto", - "data"); + "Size of perfetto buffer (in KB)", size_t{ 1024000 }, + "perfetto", "data"); OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_PERFETTO_COMBINE_TRACES", "Combine Perfetto traces. If not explicitly set, it will " @@ -362,14 +369,14 @@ configure_settings(bool _init) ->set_choices({ "fill", "discard" }); OMNITRACE_CONFIG_EXT_SETTING(int64_t, "OMNITRACE_CRITICAL_TRACE_COUNT", - "Number of critical trace to export (0 == all)", 0, - "data", "critical_trace", "omnitrace-critical-trace", - "perfetto"); + "Number of critical trace to export (0 == all)", + int64_t{ 0 }, "data", "critical_trace", + "omnitrace-critical-trace", "perfetto"); 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, "data", "critical_trace"); + uint64_t{ 2000 }, "data", "critical_trace"); OMNITRACE_CONFIG_SETTING( uint64_t, "OMNITRACE_CRITICAL_TRACE_NUM_THREADS", @@ -379,8 +386,8 @@ configure_settings(bool _init) OMNITRACE_CONFIG_EXT_SETTING( int64_t, "OMNITRACE_CRITICAL_TRACE_PER_ROW", - "How many critical traces per row in perfetto (0 == all in one row)", 0, "io", - "critical_trace", "omnitrace-critical-trace", "perfetto"); + "How many critical traces per row in perfetto (0 == all in one row)", + int64_t{ 0 }, "io", "critical_trace", "omnitrace-critical-trace", "perfetto"); OMNITRACE_CONFIG_SETTING( std::string, "OMNITRACE_TIMEMORY_COMPONENTS", @@ -388,10 +395,11 @@ configure_settings(bool _init) "wall_clock", "timemory", "component"); OMNITRACE_CONFIG_SETTING(std::string, "OMNITRACE_OUTPUT_FILE", - "[DEPRECATED] See OMNITRACE_PERFETTO_FILE", "", "perfetto", - "io", "filename", "deprecated"); + "[DEPRECATED] See OMNITRACE_PERFETTO_FILE", std::string{}, + "perfetto", "io", "filename", "deprecated"); OMNITRACE_CONFIG_SETTING(std::string, "OMNITRACE_PERFETTO_FILE", "Perfetto filename", - "perfetto-trace.proto", "perfetto", "io", "filename"); + std::string{ "perfetto-trace.proto" }, "perfetto", "io", + "filename"); // set the defaults _config->get_flamegraph_output() = false; diff --git a/projects/rocprofiler-systems/tests/CMakeLists.txt b/projects/rocprofiler-systems/tests/CMakeLists.txt index 6d250b8fe9..9a2701fa2a 100644 --- a/projects/rocprofiler-systems/tests/CMakeLists.txt +++ b/projects/rocprofiler-systems/tests/CMakeLists.txt @@ -445,6 +445,7 @@ endfunction() file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/invalid.cfg " +OMNITRACE_CONFIG_FILE = FOOBAR = ON ")