From 6fa2a2f2a44105f6dde88ccbc1d01985e10d78f3 Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Wed, 11 Sep 2024 10:27:50 -0400 Subject: [PATCH 01/39] Rename the omnitrace-dl library - Part 1 Signed-off-by: David Galiffi --- source/lib/binary/analysis.cpp | 2 +- source/lib/common/setup.hpp | 4 ++-- source/lib/core/argparse.cpp | 2 +- source/lib/core/config.cpp | 4 ++-- source/lib/omnitrace-dl/CMakeLists.txt | 2 +- source/lib/omnitrace-dl/dl.cpp | 8 ++++---- source/lib/omnitrace/library/kokkosp.cpp | 4 ++-- source/python/libpyomnitrace.cpp | 4 ++-- tests/omnitrace-kokkos-tests.cmake | 6 +++--- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/source/lib/binary/analysis.cpp b/source/lib/binary/analysis.cpp index bdc4204c2..4b3938f03 100644 --- a/source/lib/binary/analysis.cpp +++ b/source/lib/binary/analysis.cpp @@ -240,7 +240,7 @@ lookup_ipaddr_entry(uintptr_t _addr, unw_context_t* _context_p, for(const auto& itr : binary::get_link_map("libomnitrace.so", "", "")) _insert_exclude_range(itr.real()); - for(const auto& itr : binary::get_link_map("libomnitrace-dl.so", "", "")) + for(const auto& itr : binary::get_link_map("librocsys.so", "", "")) _insert_exclude_range(itr.real()); return _exclude_range_v; diff --git a/source/lib/common/setup.hpp b/source/lib/common/setup.hpp index 08546e529..46e2e3a29 100644 --- a/source/lib/common/setup.hpp +++ b/source/lib/common/setup.hpp @@ -88,7 +88,7 @@ inline namespace common inline std::vector get_environ(int _verbose, std::string _search_paths = {}, std::string _omnilib = "libomnitrace.so", - std::string _omnilib_dl = "libomnitrace-dl.so") + std::string _omnilib_dl = "librocsys.so") { auto _data = std::vector{}; auto _omnilib_path = path::get_origin(_omnilib); @@ -275,7 +275,7 @@ get_environ(int _verbose, std::string _search_paths = {}, inline void setup_environ(int _verbose, const std::string& _search_paths = {}, std::string _omnilib = "libomnitrace.so", - std::string _omnilib_dl = "libomnitrace-dl.so") + std::string _omnilib_dl = "librocsys-dl.so") { auto _data = get_environ(_verbose, _search_paths, std::move(_omnilib), std::move(_omnilib_dl)); diff --git a/source/lib/core/argparse.cpp b/source/lib/core/argparse.cpp index c91ad674b..b37f4b4c3 100644 --- a/source/lib/core/argparse.cpp +++ b/source/lib/core/argparse.cpp @@ -219,7 +219,7 @@ init_parser(parser_data& _data) } } - _data.dl_libpath = get_realpath(get_internal_libpath("libomnitrace-dl.so").c_str()); + _data.dl_libpath = get_realpath(get_internal_libpath("librocsys-dl.so").c_str()); _data.omni_libpath = get_realpath(get_internal_libpath("libomnitrace.so").c_str()); #if defined(OMNITRACE_USE_ROCTRACER) || defined(OMNITRACE_USE_ROCPROFILER) diff --git a/source/lib/core/config.cpp b/source/lib/core/config.cpp index d7bb5d959..56551f585 100644 --- a/source/lib/core/config.cpp +++ b/source/lib/core/config.cpp @@ -255,7 +255,7 @@ configure_settings(bool _init) OMNITRACE_CONFIG_EXT_SETTING(int, "OMNITRACE_DL_VERBOSE", "Verbosity within the omnitrace-dl library", 0, - "debugging", "libomnitrace-dl", "advanced"); + "debugging", "librocsys-dl", "advanced"); OMNITRACE_CONFIG_SETTING( size_t, "OMNITRACE_NUM_THREADS_HINT", @@ -1163,7 +1163,7 @@ configure_mode_settings(const std::shared_ptr& _config) if(_config->get("OMNITRACE_USE_KOKKOSP")) { auto _current_kokkosp_lib = tim::get_env("KOKKOS_PROFILE_LIBRARY"); - if(_current_kokkosp_lib.find("libomnitrace-dl.so") == std::string::npos && + if(_current_kokkosp_lib.find("librocsys-dl.so") == std::string::npos && _current_kokkosp_lib.find("libomnitrace.so") == std::string::npos) { auto _force = 0; diff --git a/source/lib/omnitrace-dl/CMakeLists.txt b/source/lib/omnitrace-dl/CMakeLists.txt index f2f35f76f..37de7dc63 100644 --- a/source/lib/omnitrace-dl/CMakeLists.txt +++ b/source/lib/omnitrace-dl/CMakeLists.txt @@ -36,7 +36,7 @@ add_target_cxx_flag_if_avail(omnitrace-dl-library "-g3") set_target_properties( omnitrace-dl-library - PROPERTIES OUTPUT_NAME omnitrace-dl + PROPERTIES OUTPUT_NAME rocsys-dl VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} BUILD_RPATH "\$ORIGIN" diff --git a/source/lib/omnitrace-dl/dl.cpp b/source/lib/omnitrace-dl/dl.cpp index 0181df2d6..95ac31e58 100644 --- a/source/lib/omnitrace-dl/dl.cpp +++ b/source/lib/omnitrace-dl/dl.cpp @@ -113,7 +113,7 @@ get_omnitrace_is_preloaded() { static bool _v = []() { auto&& _preload_libs = get_env("LD_PRELOAD", std::string{}); - return (_preload_libs.find("libomnitrace-dl.so") != std::string::npos); + return (_preload_libs.find("librocsys-dl.so") != std::string::npos); }(); return _v; } @@ -125,7 +125,7 @@ get_omnitrace_preload() auto&& _preload = get_env("OMNITRACE_PRELOAD", true); auto&& _preload_libs = get_env("LD_PRELOAD", std::string{}); return (_preload && - _preload_libs.find("libomnitrace-dl.so") != std::string::npos); + _preload_libs.find("librocsys-dl.so") != std::string::npos); }(); return _v; } @@ -134,7 +134,7 @@ inline void reset_omnitrace_preload() { auto&& _preload_libs = get_env("LD_PRELOAD", std::string{}); - if(_preload_libs.find("libomnitrace-dl.so") != std::string::npos) + if(_preload_libs.find("librocsys-dl.so") != std::string::npos) { (void) get_omnitrace_is_preloaded(); (void) get_omnitrace_preload(); @@ -494,7 +494,7 @@ get_indirect() static auto _libomni = get_env("OMNITRACE_LIBRARY", "libomnitrace.so"); static auto _libuser = get_env("OMNITRACE_USER_LIBRARY", "libomnitrace-user.so"); - static auto _libdlib = get_env("OMNITRACE_DL_LIBRARY", "libomnitrace-dl.so"); + static auto _libdlib = get_env("OMNITRACE_DL_LIBRARY", "librocsys-dl.so"); static auto* _v = new indirect{ _libomni, _libuser, _libdlib }; return *_v; } diff --git a/source/lib/omnitrace/library/kokkosp.cpp b/source/lib/omnitrace/library/kokkosp.cpp index df19b5991..b322ff047 100644 --- a/source/lib/omnitrace/library/kokkosp.cpp +++ b/source/lib/omnitrace/library/kokkosp.cpp @@ -229,7 +229,7 @@ extern "C" } for(const auto& itr : _libs) { - if(itr.find("libomnitrace-dl.so") != std::string::npos) + if(itr.find("librocsys-dl.so") != std::string::npos) { std::stringstream _libs_str{}; for(const auto& litr : _libs) @@ -237,7 +237,7 @@ extern "C" OMNITRACE_ABORT( "%s was invoked with libomnitrace.so as the " "KOKKOS_PROFILE_LIBRARY.\n" - "However, libomnitrace-dl.so has already been loaded by the " + "However, librocsys-dl.so has already been loaded by the " "process.\nTo avoid duplicate collections culminating is an " "error, please set KOKKOS_PROFILE_LIBRARY=%s.\nLoaded " "libraries:\n%s", diff --git a/source/python/libpyomnitrace.cpp b/source/python/libpyomnitrace.cpp index 798038622..50cf088d9 100644 --- a/source/python/libpyomnitrace.cpp +++ b/source/python/libpyomnitrace.cpp @@ -157,12 +157,12 @@ PYBIND11_MODULE(libpyomnitrace, omni) pyuser::generate(omni); auto _python_path = tim::get_env("OMNITRACE_PATH", std::string{}, false); - auto _libpath = std::string{ "libomnitrace-dl.so" }; + auto _libpath = std::string{ "librocsys-dl.so" }; if(!_python_path.empty()) _libpath = TIMEMORY_JOIN("/", _python_path, _libpath); // permit env override if default path fails/is wrong _libpath = tim::get_env("OMNITRACE_DL_LIBRARY", _libpath); // this is necessary when building with -static-libstdc++ - // without it, loading libomnitrace.so within libomnitrace-dl.so segfaults + // without it, loading libomnitrace.so within librocsys-dl.so segfaults if(!dlopen(_libpath.c_str(), RTLD_NOW | RTLD_GLOBAL)) { auto _msg = diff --git a/tests/omnitrace-kokkos-tests.cmake b/tests/omnitrace-kokkos-tests.cmake index 156f369bb..618aca67a 100644 --- a/tests/omnitrace-kokkos-tests.cmake +++ b/tests/omnitrace-kokkos-tests.cmake @@ -26,7 +26,7 @@ omnitrace_add_test( LABELS "kokkos;kokkos-profile-library" RUN_ARGS -i 25 -s 20 -p ENVIRONMENT - "${_base_environment};OMNITRACE_USE_KOKKOSP=ON;OMNITRACE_COUT_OUTPUT=ON;OMNITRACE_SAMPLING_FREQ=50;OMNITRACE_KOKKOSP_PREFIX=[kokkos];KOKKOS_PROFILE_LIBRARY=libomnitrace-dl.so" + "${_base_environment};OMNITRACE_USE_KOKKOSP=ON;OMNITRACE_COUT_OUTPUT=ON;OMNITRACE_SAMPLING_FREQ=50;OMNITRACE_KOKKOSP_PREFIX=[kokkos];KOKKOS_PROFILE_LIBRARY=librocsys-dl.so" REWRITE_RUN_PASS_REGEX "\\|_\\[kokkos\\] [a-zA-Z]" RUNTIME_PASS_REGEX "\\|_\\[kokkos\\] [a-zA-Z]") @@ -45,7 +45,7 @@ omnitrace_add_test( omnitrace_add_test( SKIP_RUNTIME SKIP_REWRITE - NAME lulesh-baseline-kokkosp-libomnitrace-dl + NAME lulesh-baseline-kokkosp-librocsys-dl TARGET lulesh MPI ${LULESH_USE_MPI} GPU ${LULESH_USE_GPU} @@ -53,7 +53,7 @@ omnitrace_add_test( LABELS "kokkos;kokkos-profile-library" RUN_ARGS -i 10 -s 20 -p ENVIRONMENT - "${_base_environment};OMNITRACE_USE_KOKKOSP=ON;OMNITRACE_COUT_OUTPUT=ON;OMNITRACE_SAMPLING_FREQ=50;OMNITRACE_KOKKOSP_PREFIX=[kokkos];KOKKOS_PROFILE_LIBRARY=libomnitrace-dl.so" + "${_base_environment};OMNITRACE_USE_KOKKOSP=ON;OMNITRACE_COUT_OUTPUT=ON;OMNITRACE_SAMPLING_FREQ=50;OMNITRACE_KOKKOSP_PREFIX=[kokkos];KOKKOS_PROFILE_LIBRARY=librocsys-dl.so" BASELINE_PASS_REGEX "\\|_\\[kokkos\\] [a-zA-Z]") omnitrace_add_test( From 0d00267bb5a4c457c7bfef496dff1a3ac1b3e19d Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Wed, 11 Sep 2024 16:35:56 -0400 Subject: [PATCH 02/39] Rename the omnitrace-rt library Signed-off-by: David Galiffi --- source/lib/omnitrace-dl/dl.cpp | 4 ++-- source/lib/omnitrace-rt/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/lib/omnitrace-dl/dl.cpp b/source/lib/omnitrace-dl/dl.cpp index 95ac31e58..8f1aeb33b 100644 --- a/source/lib/omnitrace-dl/dl.cpp +++ b/source/lib/omnitrace-dl/dl.cpp @@ -1175,7 +1175,7 @@ get_default_mode() auto _link_map = get_link_map(nullptr); for(const auto& itr : _link_map) { - if(itr.find("libomnitrace-rt.so") != std::string::npos || + if(itr.find("librocsys-rt.so") != std::string::npos || itr.find("libdyninstAPI_RT.so") != std::string::npos) return "trace"; } @@ -1256,7 +1256,7 @@ omnitrace_preload() get_env("OMNITRACE_INSTRUMENT_MODE", dl::InstrumentMode::BinaryRewrite); for(const auto& itr : _link_map) { - if(itr.find("libomnitrace-rt.so") != std::string::npos || + if(itr.find("librocsys-rt.so") != std::string::npos || itr.find("libdyninstAPI_RT.so") != std::string::npos) { omnitrace_set_instrumented(static_cast(_instr_mode)); diff --git a/source/lib/omnitrace-rt/CMakeLists.txt b/source/lib/omnitrace-rt/CMakeLists.txt index c189d4d29..eacaf6df4 100644 --- a/source/lib/omnitrace-rt/CMakeLists.txt +++ b/source/lib/omnitrace-rt/CMakeLists.txt @@ -108,7 +108,7 @@ add_target_cxx_flag_if_avail(omnitrace-rt-library "-g3") set_target_properties( omnitrace-rt-library - PROPERTIES OUTPUT_NAME omnitrace-rt + PROPERTIES OUTPUT_NAME rocsys-rt VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} BUILD_RPATH "\$ORIGIN" From 4348317c0fd6dca151333aab0b20f81d712cce2e Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Wed, 11 Sep 2024 20:32:08 -0400 Subject: [PATCH 03/39] Rename the omnitrace-user library Signed-off-by: David Galiffi --- source/lib/omnitrace-dl/dl.cpp | 2 +- source/lib/omnitrace-user/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/lib/omnitrace-dl/dl.cpp b/source/lib/omnitrace-dl/dl.cpp index 8f1aeb33b..5dc6330f9 100644 --- a/source/lib/omnitrace-dl/dl.cpp +++ b/source/lib/omnitrace-dl/dl.cpp @@ -493,7 +493,7 @@ get_indirect() omnitrace_preinit_library(); static auto _libomni = get_env("OMNITRACE_LIBRARY", "libomnitrace.so"); - static auto _libuser = get_env("OMNITRACE_USER_LIBRARY", "libomnitrace-user.so"); + static auto _libuser = get_env("OMNITRACE_USER_LIBRARY", "librocprof-sys-user.so"); static auto _libdlib = get_env("OMNITRACE_DL_LIBRARY", "librocsys-dl.so"); static auto* _v = new indirect{ _libomni, _libuser, _libdlib }; return *_v; diff --git a/source/lib/omnitrace-user/CMakeLists.txt b/source/lib/omnitrace-user/CMakeLists.txt index 112f756ee..ea3920f2e 100644 --- a/source/lib/omnitrace-user/CMakeLists.txt +++ b/source/lib/omnitrace-user/CMakeLists.txt @@ -30,7 +30,7 @@ target_link_libraries(omnitrace-user-library set_target_properties( omnitrace-user-library - PROPERTIES OUTPUT_NAME omnitrace-user + PROPERTIES OUTPUT_NAME rocprof-sys-user VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} POSITION_INDEPENDENT_CODE ON From ae15a05b1f4dfd9593ab912c2278735e884a69fe Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Wed, 11 Sep 2024 21:02:27 -0400 Subject: [PATCH 04/39] Rename the omnitrace-rt library - Part 2 Signed-off-by: David Galiffi --- source/lib/omnitrace-dl/dl.cpp | 4 ++-- source/lib/omnitrace-rt/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/lib/omnitrace-dl/dl.cpp b/source/lib/omnitrace-dl/dl.cpp index 5dc6330f9..beedf0e11 100644 --- a/source/lib/omnitrace-dl/dl.cpp +++ b/source/lib/omnitrace-dl/dl.cpp @@ -1175,7 +1175,7 @@ get_default_mode() auto _link_map = get_link_map(nullptr); for(const auto& itr : _link_map) { - if(itr.find("librocsys-rt.so") != std::string::npos || + if(itr.find("librocprof-sys-rt.so") != std::string::npos || itr.find("libdyninstAPI_RT.so") != std::string::npos) return "trace"; } @@ -1256,7 +1256,7 @@ omnitrace_preload() get_env("OMNITRACE_INSTRUMENT_MODE", dl::InstrumentMode::BinaryRewrite); for(const auto& itr : _link_map) { - if(itr.find("librocsys-rt.so") != std::string::npos || + if(itr.find("librocprof-sys-rt.so") != std::string::npos || itr.find("libdyninstAPI_RT.so") != std::string::npos) { omnitrace_set_instrumented(static_cast(_instr_mode)); diff --git a/source/lib/omnitrace-rt/CMakeLists.txt b/source/lib/omnitrace-rt/CMakeLists.txt index eacaf6df4..df591d4ca 100644 --- a/source/lib/omnitrace-rt/CMakeLists.txt +++ b/source/lib/omnitrace-rt/CMakeLists.txt @@ -108,7 +108,7 @@ add_target_cxx_flag_if_avail(omnitrace-rt-library "-g3") set_target_properties( omnitrace-rt-library - PROPERTIES OUTPUT_NAME rocsys-rt + PROPERTIES OUTPUT_NAME rocprof-sys-rt VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} BUILD_RPATH "\$ORIGIN" From a664a07e43fe2f771d7b08e92c99c457c019a10a Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Wed, 11 Sep 2024 22:38:36 -0400 Subject: [PATCH 05/39] Rename omnitrace-dl library - Part 2 Signed-off-by: David Galiffi --- source/lib/binary/analysis.cpp | 2 +- source/lib/common/setup.hpp | 4 ++-- source/lib/core/argparse.cpp | 2 +- source/lib/core/config.cpp | 4 ++-- source/lib/omnitrace-dl/CMakeLists.txt | 2 +- source/lib/omnitrace-dl/dl.cpp | 8 ++++---- source/lib/omnitrace/library/kokkosp.cpp | 4 ++-- source/python/libpyomnitrace.cpp | 4 ++-- tests/omnitrace-kokkos-tests.cmake | 6 +++--- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/source/lib/binary/analysis.cpp b/source/lib/binary/analysis.cpp index 4b3938f03..9980e21bf 100644 --- a/source/lib/binary/analysis.cpp +++ b/source/lib/binary/analysis.cpp @@ -240,7 +240,7 @@ lookup_ipaddr_entry(uintptr_t _addr, unw_context_t* _context_p, for(const auto& itr : binary::get_link_map("libomnitrace.so", "", "")) _insert_exclude_range(itr.real()); - for(const auto& itr : binary::get_link_map("librocsys.so", "", "")) + for(const auto& itr : binary::get_link_map("librocprof-sys-dl.so", "", "")) _insert_exclude_range(itr.real()); return _exclude_range_v; diff --git a/source/lib/common/setup.hpp b/source/lib/common/setup.hpp index 46e2e3a29..94ca32349 100644 --- a/source/lib/common/setup.hpp +++ b/source/lib/common/setup.hpp @@ -88,7 +88,7 @@ inline namespace common inline std::vector get_environ(int _verbose, std::string _search_paths = {}, std::string _omnilib = "libomnitrace.so", - std::string _omnilib_dl = "librocsys.so") + std::string _omnilib_dl = "librocprof-sys-dl.so") { auto _data = std::vector{}; auto _omnilib_path = path::get_origin(_omnilib); @@ -275,7 +275,7 @@ get_environ(int _verbose, std::string _search_paths = {}, inline void setup_environ(int _verbose, const std::string& _search_paths = {}, std::string _omnilib = "libomnitrace.so", - std::string _omnilib_dl = "librocsys-dl.so") + std::string _omnilib_dl = "librocprof-sys-dl.so") { auto _data = get_environ(_verbose, _search_paths, std::move(_omnilib), std::move(_omnilib_dl)); diff --git a/source/lib/core/argparse.cpp b/source/lib/core/argparse.cpp index b37f4b4c3..a6b83897b 100644 --- a/source/lib/core/argparse.cpp +++ b/source/lib/core/argparse.cpp @@ -219,7 +219,7 @@ init_parser(parser_data& _data) } } - _data.dl_libpath = get_realpath(get_internal_libpath("librocsys-dl.so").c_str()); + _data.dl_libpath = get_realpath(get_internal_libpath("librocprof-sys-dl.so").c_str()); _data.omni_libpath = get_realpath(get_internal_libpath("libomnitrace.so").c_str()); #if defined(OMNITRACE_USE_ROCTRACER) || defined(OMNITRACE_USE_ROCPROFILER) diff --git a/source/lib/core/config.cpp b/source/lib/core/config.cpp index 56551f585..43bb5aae7 100644 --- a/source/lib/core/config.cpp +++ b/source/lib/core/config.cpp @@ -255,7 +255,7 @@ configure_settings(bool _init) OMNITRACE_CONFIG_EXT_SETTING(int, "OMNITRACE_DL_VERBOSE", "Verbosity within the omnitrace-dl library", 0, - "debugging", "librocsys-dl", "advanced"); + "debugging", "librocprof-sys-dl", "advanced"); OMNITRACE_CONFIG_SETTING( size_t, "OMNITRACE_NUM_THREADS_HINT", @@ -1163,7 +1163,7 @@ configure_mode_settings(const std::shared_ptr& _config) if(_config->get("OMNITRACE_USE_KOKKOSP")) { auto _current_kokkosp_lib = tim::get_env("KOKKOS_PROFILE_LIBRARY"); - if(_current_kokkosp_lib.find("librocsys-dl.so") == std::string::npos && + if(_current_kokkosp_lib.find("librocprof-sys-dl.so") == std::string::npos && _current_kokkosp_lib.find("libomnitrace.so") == std::string::npos) { auto _force = 0; diff --git a/source/lib/omnitrace-dl/CMakeLists.txt b/source/lib/omnitrace-dl/CMakeLists.txt index 37de7dc63..ff651926c 100644 --- a/source/lib/omnitrace-dl/CMakeLists.txt +++ b/source/lib/omnitrace-dl/CMakeLists.txt @@ -36,7 +36,7 @@ add_target_cxx_flag_if_avail(omnitrace-dl-library "-g3") set_target_properties( omnitrace-dl-library - PROPERTIES OUTPUT_NAME rocsys-dl + PROPERTIES OUTPUT_NAME rocprof-sys-dl VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} BUILD_RPATH "\$ORIGIN" diff --git a/source/lib/omnitrace-dl/dl.cpp b/source/lib/omnitrace-dl/dl.cpp index beedf0e11..1c993cf9b 100644 --- a/source/lib/omnitrace-dl/dl.cpp +++ b/source/lib/omnitrace-dl/dl.cpp @@ -113,7 +113,7 @@ get_omnitrace_is_preloaded() { static bool _v = []() { auto&& _preload_libs = get_env("LD_PRELOAD", std::string{}); - return (_preload_libs.find("librocsys-dl.so") != std::string::npos); + return (_preload_libs.find("librocprof-sys-dl.so") != std::string::npos); }(); return _v; } @@ -125,7 +125,7 @@ get_omnitrace_preload() auto&& _preload = get_env("OMNITRACE_PRELOAD", true); auto&& _preload_libs = get_env("LD_PRELOAD", std::string{}); return (_preload && - _preload_libs.find("librocsys-dl.so") != std::string::npos); + _preload_libs.find("librocprof-sys-dl.so") != std::string::npos); }(); return _v; } @@ -134,7 +134,7 @@ inline void reset_omnitrace_preload() { auto&& _preload_libs = get_env("LD_PRELOAD", std::string{}); - if(_preload_libs.find("librocsys-dl.so") != std::string::npos) + if(_preload_libs.find("librocprof-sys-dl.so") != std::string::npos) { (void) get_omnitrace_is_preloaded(); (void) get_omnitrace_preload(); @@ -494,7 +494,7 @@ get_indirect() static auto _libomni = get_env("OMNITRACE_LIBRARY", "libomnitrace.so"); static auto _libuser = get_env("OMNITRACE_USER_LIBRARY", "librocprof-sys-user.so"); - static auto _libdlib = get_env("OMNITRACE_DL_LIBRARY", "librocsys-dl.so"); + static auto _libdlib = get_env("OMNITRACE_DL_LIBRARY", "librocprof-sys-dl.so"); static auto* _v = new indirect{ _libomni, _libuser, _libdlib }; return *_v; } diff --git a/source/lib/omnitrace/library/kokkosp.cpp b/source/lib/omnitrace/library/kokkosp.cpp index b322ff047..30e4f2be6 100644 --- a/source/lib/omnitrace/library/kokkosp.cpp +++ b/source/lib/omnitrace/library/kokkosp.cpp @@ -229,7 +229,7 @@ extern "C" } for(const auto& itr : _libs) { - if(itr.find("librocsys-dl.so") != std::string::npos) + if(itr.find("librocprof-sys-dl.so") != std::string::npos) { std::stringstream _libs_str{}; for(const auto& litr : _libs) @@ -237,7 +237,7 @@ extern "C" OMNITRACE_ABORT( "%s was invoked with libomnitrace.so as the " "KOKKOS_PROFILE_LIBRARY.\n" - "However, librocsys-dl.so has already been loaded by the " + "However, librocprof-sys-dl.so has already been loaded by the " "process.\nTo avoid duplicate collections culminating is an " "error, please set KOKKOS_PROFILE_LIBRARY=%s.\nLoaded " "libraries:\n%s", diff --git a/source/python/libpyomnitrace.cpp b/source/python/libpyomnitrace.cpp index 50cf088d9..b2087c3a8 100644 --- a/source/python/libpyomnitrace.cpp +++ b/source/python/libpyomnitrace.cpp @@ -157,12 +157,12 @@ PYBIND11_MODULE(libpyomnitrace, omni) pyuser::generate(omni); auto _python_path = tim::get_env("OMNITRACE_PATH", std::string{}, false); - auto _libpath = std::string{ "librocsys-dl.so" }; + auto _libpath = std::string{ "librocprof-sys-dl.so" }; if(!_python_path.empty()) _libpath = TIMEMORY_JOIN("/", _python_path, _libpath); // permit env override if default path fails/is wrong _libpath = tim::get_env("OMNITRACE_DL_LIBRARY", _libpath); // this is necessary when building with -static-libstdc++ - // without it, loading libomnitrace.so within librocsys-dl.so segfaults + // without it, loading libomnitrace.so within librocprof-sys-dl.so segfaults if(!dlopen(_libpath.c_str(), RTLD_NOW | RTLD_GLOBAL)) { auto _msg = diff --git a/tests/omnitrace-kokkos-tests.cmake b/tests/omnitrace-kokkos-tests.cmake index 618aca67a..962c82542 100644 --- a/tests/omnitrace-kokkos-tests.cmake +++ b/tests/omnitrace-kokkos-tests.cmake @@ -26,7 +26,7 @@ omnitrace_add_test( LABELS "kokkos;kokkos-profile-library" RUN_ARGS -i 25 -s 20 -p ENVIRONMENT - "${_base_environment};OMNITRACE_USE_KOKKOSP=ON;OMNITRACE_COUT_OUTPUT=ON;OMNITRACE_SAMPLING_FREQ=50;OMNITRACE_KOKKOSP_PREFIX=[kokkos];KOKKOS_PROFILE_LIBRARY=librocsys-dl.so" + "${_base_environment};OMNITRACE_USE_KOKKOSP=ON;OMNITRACE_COUT_OUTPUT=ON;OMNITRACE_SAMPLING_FREQ=50;OMNITRACE_KOKKOSP_PREFIX=[kokkos];KOKKOS_PROFILE_LIBRARY=librocprof-sys-dl.so" REWRITE_RUN_PASS_REGEX "\\|_\\[kokkos\\] [a-zA-Z]" RUNTIME_PASS_REGEX "\\|_\\[kokkos\\] [a-zA-Z]") @@ -45,7 +45,7 @@ omnitrace_add_test( omnitrace_add_test( SKIP_RUNTIME SKIP_REWRITE - NAME lulesh-baseline-kokkosp-librocsys-dl + NAME lulesh-baseline-kokkosp-librocprof-sys-dl TARGET lulesh MPI ${LULESH_USE_MPI} GPU ${LULESH_USE_GPU} @@ -53,7 +53,7 @@ omnitrace_add_test( LABELS "kokkos;kokkos-profile-library" RUN_ARGS -i 10 -s 20 -p ENVIRONMENT - "${_base_environment};OMNITRACE_USE_KOKKOSP=ON;OMNITRACE_COUT_OUTPUT=ON;OMNITRACE_SAMPLING_FREQ=50;OMNITRACE_KOKKOSP_PREFIX=[kokkos];KOKKOS_PROFILE_LIBRARY=librocsys-dl.so" + "${_base_environment};OMNITRACE_USE_KOKKOSP=ON;OMNITRACE_COUT_OUTPUT=ON;OMNITRACE_SAMPLING_FREQ=50;OMNITRACE_KOKKOSP_PREFIX=[kokkos];KOKKOS_PROFILE_LIBRARY=librocprof-sys-dl.so" BASELINE_PASS_REGEX "\\|_\\[kokkos\\] [a-zA-Z]") omnitrace_add_test( From a6b5e1a11eca74a975c87980d677f10820921155 Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Thu, 12 Sep 2024 10:37:56 -0400 Subject: [PATCH 06/39] Rename the omnitrace-core library Signed-off-by: David Galiffi --- source/lib/core/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/lib/core/CMakeLists.txt b/source/lib/core/CMakeLists.txt index bef6228c1..cc125084a 100644 --- a/source/lib/core/CMakeLists.txt +++ b/source/lib/core/CMakeLists.txt @@ -72,4 +72,4 @@ target_link_libraries( $ $,omnitrace::omnitrace-lto,>>) -set_target_properties(omnitrace-core-library PROPERTIES OUTPUT_NAME omnitrace-core) +set_target_properties(omnitrace-core-library PROPERTIES OUTPUT_NAME rocprof-sys-core) From 86c21abcb601723537c3fa061feee7127c85ebcb Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Thu, 12 Sep 2024 11:44:18 -0400 Subject: [PATCH 07/39] Rename the omnitrace-binary library Signed-off-by: David Galiffi --- source/lib/binary/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/lib/binary/CMakeLists.txt b/source/lib/binary/CMakeLists.txt index 8eefb0a44..0388b7f3a 100644 --- a/source/lib/binary/CMakeLists.txt +++ b/source/lib/binary/CMakeLists.txt @@ -25,4 +25,4 @@ target_link_libraries( omnitrace-binary-library PRIVATE omnitrace::omnitrace-interface-library omnitrace::omnitrace-core) -set_target_properties(omnitrace-binary-library PROPERTIES OUTPUT_NAME omnitrace-binary) +set_target_properties(omnitrace-binary-library PROPERTIES OUTPUT_NAME rocprof-sys-binary) From 117e28fca744449ea101aa2885fb9fd1aa9bcd99 Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Thu, 12 Sep 2024 18:06:17 -0400 Subject: [PATCH 08/39] Source formatting Signed-off-by: David Galiffi --- source/lib/core/argparse.cpp | 2 +- source/lib/omnitrace/library/kokkosp.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/lib/core/argparse.cpp b/source/lib/core/argparse.cpp index a6b83897b..5fdee3afc 100644 --- a/source/lib/core/argparse.cpp +++ b/source/lib/core/argparse.cpp @@ -219,7 +219,7 @@ init_parser(parser_data& _data) } } - _data.dl_libpath = get_realpath(get_internal_libpath("librocprof-sys-dl.so").c_str()); + _data.dl_libpath = get_realpath(get_internal_libpath("librocprof-sys-dl.so").c_str()); _data.omni_libpath = get_realpath(get_internal_libpath("libomnitrace.so").c_str()); #if defined(OMNITRACE_USE_ROCTRACER) || defined(OMNITRACE_USE_ROCPROFILER) diff --git a/source/lib/omnitrace/library/kokkosp.cpp b/source/lib/omnitrace/library/kokkosp.cpp index 30e4f2be6..4464ef5f7 100644 --- a/source/lib/omnitrace/library/kokkosp.cpp +++ b/source/lib/omnitrace/library/kokkosp.cpp @@ -237,9 +237,9 @@ extern "C" OMNITRACE_ABORT( "%s was invoked with libomnitrace.so as the " "KOKKOS_PROFILE_LIBRARY.\n" - "However, librocprof-sys-dl.so has already been loaded by the " - "process.\nTo avoid duplicate collections culminating is an " - "error, please set KOKKOS_PROFILE_LIBRARY=%s.\nLoaded " + "However, librocprof-sys-dl.so has already been loaded by " + "the process.\nTo avoid duplicate collections culminating " + "is an error, please set KOKKOS_PROFILE_LIBRARY=%s.\nLoaded " "libraries:\n%s", __FUNCTION__, itr.c_str(), _libs_str.str().c_str()); } From 0c0ed868a88875eab03efa70804d3959310757f8 Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Fri, 13 Sep 2024 11:00:48 -0400 Subject: [PATCH 09/39] Rename the omnitrace library Signed-off-by: David Galiffi --- scripts/dl-gen.py | 2 +- scripts/gperftools-cpu-profile.sh | 2 +- source/bin/omnitrace-avail/avail.cpp | 2 +- source/bin/omnitrace-causal/impl.cpp | 2 +- .../omnitrace-instrument/internal_libs.cpp | 2 +- .../omnitrace-instrument.cpp | 15 +- source/bin/omnitrace-sample/impl.cpp | 8 +- source/lib/binary/analysis.cpp | 2 +- source/lib/binary/link_map.hpp | 6 +- source/lib/common/setup.hpp | 4 +- source/lib/core/argparse.cpp | 2 +- source/lib/core/config.cpp | 14 +- source/lib/omnitrace-dl/dl.cpp | 2896 ++++++++--------- source/lib/omnitrace-user/omnitrace/types.h | 2 +- source/lib/omnitrace/CMakeLists.txt | 4 +- source/lib/omnitrace/api.hpp | 2 +- source/lib/omnitrace/library.cpp | 4 +- source/lib/omnitrace/library/causal/data.cpp | 2 +- source/lib/omnitrace/library/kokkosp.cpp | 4 +- source/python/libpyomnitrace.cpp | 2 +- tests/omnitrace-kokkos-tests.cmake | 4 +- 21 files changed, 1491 insertions(+), 1490 deletions(-) diff --git a/scripts/dl-gen.py b/scripts/dl-gen.py index 60e63cd33..f725ec896 100755 --- a/scripts/dl-gen.py +++ b/scripts/dl-gen.py @@ -6,7 +6,7 @@ """ This script reads in function prototypes can generates the implementation pieces -needed to dlsym the function in libomnitrace +needed to dlsym the function in librocprof-sys. Example input file: diff --git a/scripts/gperftools-cpu-profile.sh b/scripts/gperftools-cpu-profile.sh index fabc56737..e11b6369d 100755 --- a/scripts/gperftools-cpu-profile.sh +++ b/scripts/gperftools-cpu-profile.sh @@ -87,7 +87,7 @@ run-pprof() } # configure pre-loading of profiler library -for i in $(find ${PWD} -type f | egrep 'libomnitrace' | egrep -v '\.a$' | egrep '\.so$') $(ldd ${1} | awk '{print $(NF-1)}') +for i in $(find ${PWD} -type f | egrep 'librocprof-sys' | egrep -v '\.a$' | egrep '\.so$') $(ldd ${1} | awk '{print $(NF-1)}') do if [ -f "${i}" ]; then run-verbose ADD_LIBS "${i}"; fi done diff --git a/source/bin/omnitrace-avail/avail.cpp b/source/bin/omnitrace-avail/avail.cpp index 5fe5c446f..8085a5065 100644 --- a/source/bin/omnitrace-avail/avail.cpp +++ b/source/bin/omnitrace-avail/avail.cpp @@ -118,7 +118,7 @@ write_hw_counter_info(std::ostream&, const array_t& = {}, namespace { -// initialize HIP before main so that libomnitrace is not HSA_TOOLS_LIB +// initialize HIP before main so that librocprof-sys is not HSA_TOOLS_LIB int gpu_count = omnitrace::gpu::hip_device_count(); // statically allocated shared_ptrs to prevent use after free errors diff --git a/source/bin/omnitrace-causal/impl.cpp b/source/bin/omnitrace-causal/impl.cpp index 5e901fa4c..722ab0ca5 100644 --- a/source/bin/omnitrace-causal/impl.cpp +++ b/source/bin/omnitrace-causal/impl.cpp @@ -244,7 +244,7 @@ prepare_environment_for_run(std::vector& _env) { update_env(_env, "LD_PRELOAD", join(":", LIBPTHREAD_SO, - get_realpath(get_internal_libpath("libomnitrace-dl.so"))), + get_realpath(get_internal_libpath("librocprof-sys-dl.so"))), true); } } diff --git a/source/bin/omnitrace-instrument/internal_libs.cpp b/source/bin/omnitrace-instrument/internal_libs.cpp index b8ebb7d05..1f25f5206 100644 --- a/source/bin/omnitrace-instrument/internal_libs.cpp +++ b/source/bin/omnitrace-instrument/internal_libs.cpp @@ -418,7 +418,7 @@ get_internal_libs_data_impl() for(const auto* itr : { "lib", "lib64" }) { for(const auto* litr : - { "libomnitrace-dl.so", "libomnitrace-user.so", "libomnitrace-rt.so" }) + { "librocprof-sys-dl.so", "librocprof-sys-user.so", "librocprof-sys-rt.so" }) { auto _libpath = join('/', _omnitrace_base_path, itr, litr); if(filepath::exists(_libpath)) diff --git a/source/bin/omnitrace-instrument/omnitrace-instrument.cpp b/source/bin/omnitrace-instrument/omnitrace-instrument.cpp index 91844e90a..264604398 100644 --- a/source/bin/omnitrace-instrument/omnitrace-instrument.cpp +++ b/source/bin/omnitrace-instrument/omnitrace-instrument.cpp @@ -345,6 +345,7 @@ main(int argc, char** argv) for(const auto& itr : omnitrace_get_link_map(nullptr)) { if(itr.find("omnitrace") != std::string::npos || + itr.find("rocprof-sys") != std::string::npos || std::regex_search( itr, std::regex{ "lib(dyninstAPI|stackwalk|pcontrol|patchAPI|parseAPI|" "instructionAPI|symtabAPI|dynDwarf|common|dynElf|tbb|" @@ -376,7 +377,7 @@ main(int argc, char** argv) string_t mutname = {}; string_t outfile = {}; string_t logfile = {}; - std::vector inputlib = { "libomnitrace-dl" }; + std::vector inputlib = { "librocprof-sys-dl" }; std::vector libname = {}; std::vector sharedlibname = {}; std::vector staticlibname = {}; @@ -1757,9 +1758,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("libomnitrace-"); + _pos = _name.find("librocprof-sys-"); if(_pos != npos_v) - _name = _name.erase(_pos, std::string("libomnitrace-").length()); + _name = _name.erase(_pos, std::string("librocprof-sys-").length()); _pos = _name.find("lib"); if(_pos == 0) _name = _name.substr(_pos + std::string("lib").length()); while((_pos = _name.find('-')) != npos_v) @@ -1768,7 +1769,7 @@ main(int argc, char** argv) verbprintf(2, "Supplemental instrumentation library '%s' is named '%s' after " "removing everything before last '/', everything after first '.', and " - "'libomnitrace-'...\n", + "'librocprof-sys-'...\n", itr.c_str(), _name.c_str()); use_stubs[_name] = false; @@ -1927,7 +1928,7 @@ main(int argc, char** argv) { if(_libname.empty()) _libname = get_absolute_lib_filepath(itr); } - if(_libname.empty()) _libname = "libomnitrace-dl.so"; + if(_libname.empty()) _libname = "librocprof-sys-dl.so"; if(!binary_rewrite && !is_attached) env_vars.clear(); @@ -2076,7 +2077,7 @@ main(int argc, char** argv) size_t _ninits = 0; for(auto* itr : _objs) { - if(itr->name().find("libomnitrace") != std::string::npos) continue; + if(itr->name().find("librocprof-sys") != std::string::npos) continue; try { verbprintf(2, "Adding main init callbacks (via %s)...\n", @@ -2815,7 +2816,7 @@ find_dyn_api_rt() { #if defined(OMNITRACE_BUILD_DYNINST) std::string _dyn_api_rt_base = - (binary_rewrite) ? "libomnitrace-rt" : "libdyninstAPI_RT"; + (binary_rewrite) ? "librocprof-sys-rt" : "libdyninstAPI_RT"; #else std::string _dyn_api_rt_base = "libdyninstAPI_RT"; #endif diff --git a/source/bin/omnitrace-sample/impl.cpp b/source/bin/omnitrace-sample/impl.cpp index 4833f9b56..cb89a0942 100644 --- a/source/bin/omnitrace-sample/impl.cpp +++ b/source/bin/omnitrace-sample/impl.cpp @@ -130,8 +130,8 @@ get_initial_environment() } } - auto _dl_libpath = get_realpath(get_internal_libpath("libomnitrace-dl.so")); - auto _omni_libpath = get_realpath(get_internal_libpath("libomnitrace.so")); + auto _dl_libpath = get_realpath(get_internal_libpath("librocprof-sys-dl.so")); + auto _omni_libpath = get_realpath(get_internal_libpath("librocprof-sys.so")); update_env(_env, "LD_PRELOAD", _dl_libpath, UPD_APPEND); update_env(_env, "LD_LIBRARY_PATH", tim::filepath::dirname(_dl_libpath), UPD_APPEND); @@ -315,9 +315,9 @@ parse_args(int argc, char** argv, std::vector& _env) }; auto* _dl_libpath = - realpath(get_internal_libpath("libomnitrace-dl.so").c_str(), nullptr); + realpath(get_internal_libpath("librocprof-sys-dl.so").c_str(), nullptr); auto* _omni_libpath = - realpath(get_internal_libpath("libomnitrace.so").c_str(), nullptr); + realpath(get_internal_libpath("librocprof-sys.so").c_str(), nullptr); auto parser = parser_t(argv[0]); diff --git a/source/lib/binary/analysis.cpp b/source/lib/binary/analysis.cpp index 9980e21bf..c88b3de2a 100644 --- a/source/lib/binary/analysis.cpp +++ b/source/lib/binary/analysis.cpp @@ -237,7 +237,7 @@ lookup_ipaddr_entry(uintptr_t _addr, unw_context_t* _context_p, } }; - for(const auto& itr : binary::get_link_map("libomnitrace.so", "", "")) + for(const auto& itr : binary::get_link_map("librocprof-sys.so", "", "")) _insert_exclude_range(itr.real()); for(const auto& itr : binary::get_link_map("librocprof-sys-dl.so", "", "")) diff --git a/source/lib/binary/link_map.hpp b/source/lib/binary/link_map.hpp index 2faee5917..328c8f378 100644 --- a/source/lib/binary/link_map.hpp +++ b/source/lib/binary/link_map.hpp @@ -54,11 +54,11 @@ std::optional get_linked_path(const char*, open_modes_vec_t&& = {}); // default parameters: get the linked binaries for the exe but exclude the linked binaries -// from libomnitrace +// from librocprof-sys std::set get_link_map(const char* _lib = nullptr, - const std::string& _exclude_linked_by = "libomnitrace.so", - const std::string& _exclude_re = "libomnitrace-([a-zA-Z]+)\\.so", + const std::string& _exclude_linked_by = "librocprof-sys.so", + const std::string& _exclude_re = "librocprof-sys-([a-zA-Z]+)\\.so", open_modes_vec_t&& _open_modes = {}); } // namespace binary } // namespace omnitrace diff --git a/source/lib/common/setup.hpp b/source/lib/common/setup.hpp index 94ca32349..225a92ea1 100644 --- a/source/lib/common/setup.hpp +++ b/source/lib/common/setup.hpp @@ -87,7 +87,7 @@ inline namespace common { inline std::vector get_environ(int _verbose, std::string _search_paths = {}, - std::string _omnilib = "libomnitrace.so", + std::string _omnilib = "librocprof-sys.so", std::string _omnilib_dl = "librocprof-sys-dl.so") { auto _data = std::vector{}; @@ -274,7 +274,7 @@ get_environ(int _verbose, std::string _search_paths = {}, inline void setup_environ(int _verbose, const std::string& _search_paths = {}, - std::string _omnilib = "libomnitrace.so", + std::string _omnilib = "librocprof-sys.so", std::string _omnilib_dl = "librocprof-sys-dl.so") { auto _data = diff --git a/source/lib/core/argparse.cpp b/source/lib/core/argparse.cpp index 5fdee3afc..e294644e7 100644 --- a/source/lib/core/argparse.cpp +++ b/source/lib/core/argparse.cpp @@ -220,7 +220,7 @@ init_parser(parser_data& _data) } _data.dl_libpath = get_realpath(get_internal_libpath("librocprof-sys-dl.so").c_str()); - _data.omni_libpath = get_realpath(get_internal_libpath("libomnitrace.so").c_str()); + _data.omni_libpath = get_realpath(get_internal_libpath("librocprof-sys.so").c_str()); #if defined(OMNITRACE_USE_ROCTRACER) || defined(OMNITRACE_USE_ROCPROFILER) update_env(_data, "HSA_TOOLS_LIB", _data.dl_libpath); diff --git a/source/lib/core/config.cpp b/source/lib/core/config.cpp index 43bb5aae7..44cfc7d88 100644 --- a/source/lib/core/config.cpp +++ b/source/lib/core/config.cpp @@ -121,7 +121,7 @@ using utility::parse_numeric_range; [&]() { \ auto _ret = _config->insert( \ ENV_NAME, get_setting_name(ENV_NAME), DESCRIPTION, TYPE{ INITIAL_VALUE }, \ - std::set{ "custom", "omnitrace", "libomnitrace", \ + std::set{ "custom", "omnitrace", "librocprof-sys", \ __VA_ARGS__ }); \ if(!_ret.second) \ { \ @@ -131,7 +131,7 @@ using utility::parse_numeric_range; return _config->find(ENV_NAME)->second; \ }() -// below does not include "libomnitrace" +// below does not include "librocprof-sys" #define OMNITRACE_CONFIG_EXT_SETTING(TYPE, ENV_NAME, DESCRIPTION, INITIAL_VALUE, ...) \ [&]() { \ auto _ret = _config->insert( \ @@ -151,7 +151,7 @@ using utility::parse_numeric_range; [&]() { \ auto _ret = _config->insert( \ ENV_NAME, get_setting_name(ENV_NAME), DESCRIPTION, TYPE{ INITIAL_VALUE }, \ - std::set{ "custom", "omnitrace", "libomnitrace", __VA_ARGS__ }, \ + std::set{ "custom", "omnitrace", "librocprof-sys", __VA_ARGS__ }, \ std::vector{ CMD_LINE }); \ if(!_ret.second) \ { \ @@ -864,7 +864,7 @@ configure_settings(bool _init) { auto _categories = itr->second->get_categories(); _categories.emplace("omnitrace"); - _categories.emplace("libomnitrace"); + _categories.emplace("librocprof-sys"); itr->second->set_categories(_categories); } }; @@ -1164,7 +1164,7 @@ configure_mode_settings(const std::shared_ptr& _config) { auto _current_kokkosp_lib = tim::get_env("KOKKOS_PROFILE_LIBRARY"); if(_current_kokkosp_lib.find("librocprof-sys-dl.so") == std::string::npos && - _current_kokkosp_lib.find("libomnitrace.so") == std::string::npos) + _current_kokkosp_lib.find("librocprof-sys.so") == std::string::npos) { auto _force = 0; std::string _message = {}; @@ -1175,8 +1175,8 @@ configure_mode_settings(const std::shared_ptr& _config) JOIN("", " (forced. Previous value: '", _current_kokkosp_lib, "')"); } OMNITRACE_BASIC_VERBOSE_F(1, "Setting KOKKOS_PROFILE_LIBRARY=%s%s\n", - "libomnitrace.so", _message.c_str()); - tim::set_env("KOKKOS_PROFILE_LIBRARY", "libomnitrace.so", _force); + "librocprof-sys.so", _message.c_str()); + tim::set_env("KOKKOS_PROFILE_LIBRARY", "librocprof-sys.so", _force); } } diff --git a/source/lib/omnitrace-dl/dl.cpp b/source/lib/omnitrace-dl/dl.cpp index 1c993cf9b..8844343a3 100644 --- a/source/lib/omnitrace-dl/dl.cpp +++ b/source/lib/omnitrace-dl/dl.cpp @@ -1,1448 +1,1448 @@ -// MIT License -// -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#if !defined(OMNITRACE_DL_SOURCE) -# define OMNITRACE_DL_SOURCE 1 -#endif - -#define OMNITRACE_COMMON_LIBRARY_NAME "dl" - -#include - -#define OMNITRACE_COMMON_LIBRARY_LOG_START \ - fprintf(stderr, "%s", ::tim::log::color::info()); -#define OMNITRACE_COMMON_LIBRARY_LOG_END fprintf(stderr, "%s", ::tim::log::color::end()); - -#include "common/defines.h" -#include "common/delimit.hpp" -#include "common/environment.hpp" -#include "common/invoke.hpp" -#include "common/join.hpp" -#include "common/setup.hpp" -#include "dl/dl.hpp" -#include "omnitrace/categories.h" -#include "omnitrace/types.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//--------------------------------------------------------------------------------------// - -#define OMNITRACE_DLSYM(VARNAME, HANDLE, FUNCNAME) \ - if(HANDLE) \ - { \ - *(void**) (&VARNAME) = dlsym(HANDLE, FUNCNAME); \ - if(VARNAME == nullptr && _omnitrace_dl_verbose >= _warn_verbose) \ - { \ - OMNITRACE_COMMON_LIBRARY_LOG_START \ - fprintf(stderr, "[omnitrace][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, "[omnitrace][dl][pid=%i]> %s :: success\n", getpid(), \ - FUNCNAME); \ - OMNITRACE_COMMON_LIBRARY_LOG_END \ - } \ - } - -//--------------------------------------------------------------------------------------// - -using main_func_t = int (*)(int, char**, char**); - -std::ostream& -operator<<(std::ostream& _os, const SpaceHandle& _handle) -{ - _os << _handle.name; - return _os; -} - -namespace omnitrace -{ -namespace dl -{ -namespace -{ -inline int -get_omnitrace_env() -{ - auto&& _debug = get_env("OMNITRACE_DEBUG", false); - return get_env("OMNITRACE_VERBOSE", (_debug) ? 100 : 0); -} - -inline int -get_omnitrace_dl_env() -{ - return get_env("OMNITRACE_DL_DEBUG", false) - ? 100 - : get_env("OMNITRACE_DL_VERBOSE", get_omnitrace_env()); -} - -inline bool& -get_omnitrace_is_preloaded() -{ - static bool _v = []() { - auto&& _preload_libs = get_env("LD_PRELOAD", std::string{}); - return (_preload_libs.find("librocprof-sys-dl.so") != std::string::npos); - }(); - return _v; -} - -inline bool -get_omnitrace_preload() -{ - static bool _v = []() { - auto&& _preload = get_env("OMNITRACE_PRELOAD", true); - auto&& _preload_libs = get_env("LD_PRELOAD", std::string{}); - return (_preload && - _preload_libs.find("librocprof-sys-dl.so") != std::string::npos); - }(); - return _v; -} - -inline void -reset_omnitrace_preload() -{ - auto&& _preload_libs = get_env("LD_PRELOAD", std::string{}); - if(_preload_libs.find("librocprof-sys-dl.so") != std::string::npos) - { - (void) get_omnitrace_is_preloaded(); - (void) get_omnitrace_preload(); - auto _modified_preload = std::string{}; - for(const auto& itr : delimit(_preload_libs, ":")) - { - if(itr.find("libomnitrace") != std::string::npos) continue; - _modified_preload += common::join("", ":", itr); - } - if(!_modified_preload.empty() && _modified_preload.find(':') == 0) - _modified_preload = _modified_preload.substr(1); - - setenv("LD_PRELOAD", _modified_preload.c_str(), 1); - } -} - -inline pid_t -get_omnitrace_root_pid() -{ - auto _pid = getpid(); - setenv("OMNITRACE_ROOT_PROCESS", std::to_string(_pid).c_str(), 0); - return get_env("OMNITRACE_ROOT_PROCESS", _pid); -} - -void -omnitrace_preinit() OMNITRACE_INTERNAL_API; - -void -omnitrace_postinit(std::string exe = {}) OMNITRACE_INTERNAL_API; - -pid_t _omnitrace_root_pid = get_omnitrace_root_pid(); - -// environment priority: -// - OMNITRACE_DL_DEBUG -// - OMNITRACE_DL_VERBOSE -// - OMNITRACE_DEBUG -// - OMNITRACE_VERBOSE -int _omnitrace_dl_verbose = get_omnitrace_dl_env(); - -// The docs for dlopen suggest that the combination of RTLD_LOCAL + RTLD_DEEPBIND -// (when available) helps ensure that the symbols in the instrumentation library -// libomnitrace.so will use it's own symbols... not symbols that are potentially -// instrumented. However, this only applies to the symbols in libomnitrace.so, -// which is NOT self-contained, i.e. symbols in timemory and the libs it links to -// (such as libpapi.so) are not protected by the deep-bind option. Additionally, -// it should be noted that DynInst does *NOT* add instrumentation by manipulating the -// dynamic linker (otherwise it would only be limited to shared libs) -- it manipulates -// the instructions in the binary so that a call to a function such as "main" actually -// calls "main_dyninst", which executes the instrumentation snippets around the actual -// "main" (this is the reason you need the dyninstAPI_RT library). -// -// UPDATE: -// Use of RTLD_DEEPBIND has been removed because it causes the dyninst -// ProcControlAPI to segfault within pthread_cond_wait on certain executables. -// -// Here are the docs on the dlopen options used: -// -// RTLD_LAZY -// Perform lazy binding. Only resolve symbols as the code that references them is -// executed. If the symbol is never referenced, then it is never resolved. (Lazy -// binding is only performed for function references; references to variables are -// always immediately bound when the library is loaded.) -// -// RTLD_LOCAL -// This is the converse of RTLD_GLOBAL, and the default if neither flag is specified. -// Symbols defined in this library are not made available to resolve references in -// subsequently loaded libraries. -// -// RTLD_DEEPBIND (since glibc 2.3.4) -// Place the lookup scope of the symbols in this library ahead of the global scope. -// This means that a self-contained library will use its own symbols in preference to -// global symbols with the same name contained in libraries that have already been -// loaded. This flag is not specified in POSIX.1-2001. -// -#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 4 -auto _omnitrace_dl_dlopen_flags = RTLD_LAZY | RTLD_LOCAL; -const char* _omnitrace_dl_dlopen_descr = "RTLD_LAZY | RTLD_LOCAL"; -#else -auto _omnitrace_dl_dlopen_flags = RTLD_LAZY | RTLD_LOCAL; -const char* _omnitrace_dl_dlopen_descr = "RTLD_LAZY | RTLD_LOCAL"; -#endif - -/// This class contains function pointers for omnitrace's instrumentation functions -struct OMNITRACE_INTERNAL_API indirect -{ - OMNITRACE_INLINE indirect(const std::string& _omnilib, const std::string& _userlib, - const std::string& _dllib) - : m_omnilib{ common::path::find_path(_omnilib, _omnitrace_dl_verbose) } - , m_dllib{ common::path::find_path(_dllib, _omnitrace_dl_verbose) } - , m_userlib{ common::path::find_path(_userlib, _omnitrace_dl_verbose) } - { - if(_omnitrace_dl_verbose >= 1) - { - OMNITRACE_COMMON_LIBRARY_LOG_START - fprintf(stderr, "[omnitrace][dl][pid=%i] %s resolved to '%s'\n", getpid(), - ::basename(_omnilib.c_str()), m_omnilib.c_str()); - fprintf(stderr, "[omnitrace][dl][pid=%i] %s resolved to '%s'\n", getpid(), - ::basename(_dllib.c_str()), m_dllib.c_str()); - fprintf(stderr, "[omnitrace][dl][pid=%i] %s resolved to '%s'\n", getpid(), - ::basename(_userlib.c_str()), m_userlib.c_str()); - OMNITRACE_COMMON_LIBRARY_LOG_END - } - - auto _search_paths = common::join(':', common::path::dirname(_omnilib), - common::path::dirname(_dllib)); - common::setup_environ(_omnitrace_dl_verbose, _search_paths, _omnilib, _dllib); - - m_omnihandle = open(m_omnilib); - m_userhandle = open(m_userlib); - init(); - } - - OMNITRACE_INLINE ~indirect() { dlclose(m_omnihandle); } - - static OMNITRACE_INLINE void* open(const std::string& _lib) - { - auto* libhandle = dlopen(_lib.c_str(), _omnitrace_dl_dlopen_flags); - - if(libhandle) - { - if(_omnitrace_dl_verbose >= 2) - { - OMNITRACE_COMMON_LIBRARY_LOG_START - fprintf(stderr, "[omnitrace][dl][pid=%i] dlopen(\"%s\", %s) :: success\n", - getpid(), _lib.c_str(), _omnitrace_dl_dlopen_descr); - OMNITRACE_COMMON_LIBRARY_LOG_END - } - } - else - { - if(_omnitrace_dl_verbose >= 0) - { - perror("dlopen"); - OMNITRACE_COMMON_LIBRARY_LOG_START - fprintf(stderr, "[omnitrace][dl][pid=%i] dlopen(\"%s\", %s) :: %s\n", - getpid(), _lib.c_str(), _omnitrace_dl_dlopen_descr, dlerror()); - OMNITRACE_COMMON_LIBRARY_LOG_END - } - } - - dlerror(); // Clear any existing error - - return libhandle; - } - - OMNITRACE_INLINE void init() - { - if(!m_omnihandle) m_omnihandle = open(m_omnilib); - - int _warn_verbose = 0; - int _info_verbose = 2; - // Initialize all pointers - OMNITRACE_DLSYM(omnitrace_init_library_f, m_omnihandle, "omnitrace_init_library"); - OMNITRACE_DLSYM(omnitrace_init_tooling_f, m_omnihandle, "omnitrace_init_tooling"); - OMNITRACE_DLSYM(omnitrace_init_f, m_omnihandle, "omnitrace_init"); - OMNITRACE_DLSYM(omnitrace_finalize_f, m_omnihandle, "omnitrace_finalize"); - OMNITRACE_DLSYM(omnitrace_set_env_f, m_omnihandle, "omnitrace_set_env"); - OMNITRACE_DLSYM(omnitrace_set_mpi_f, m_omnihandle, "omnitrace_set_mpi"); - OMNITRACE_DLSYM(omnitrace_push_trace_f, m_omnihandle, "omnitrace_push_trace"); - OMNITRACE_DLSYM(omnitrace_pop_trace_f, m_omnihandle, "omnitrace_pop_trace"); - OMNITRACE_DLSYM(omnitrace_push_region_f, m_omnihandle, "omnitrace_push_region"); - OMNITRACE_DLSYM(omnitrace_pop_region_f, m_omnihandle, "omnitrace_pop_region"); - OMNITRACE_DLSYM(omnitrace_push_category_region_f, m_omnihandle, - "omnitrace_push_category_region"); - OMNITRACE_DLSYM(omnitrace_pop_category_region_f, m_omnihandle, - "omnitrace_pop_category_region"); - OMNITRACE_DLSYM(omnitrace_register_source_f, m_omnihandle, - "omnitrace_register_source"); - OMNITRACE_DLSYM(omnitrace_register_coverage_f, m_omnihandle, - "omnitrace_register_coverage"); - OMNITRACE_DLSYM(omnitrace_progress_f, m_omnihandle, "omnitrace_progress"); - OMNITRACE_DLSYM(omnitrace_annotated_progress_f, m_omnihandle, - "omnitrace_annotated_progress"); - - OMNITRACE_DLSYM(kokkosp_print_help_f, m_omnihandle, "kokkosp_print_help"); - OMNITRACE_DLSYM(kokkosp_parse_args_f, m_omnihandle, "kokkosp_parse_args"); - OMNITRACE_DLSYM(kokkosp_declare_metadata_f, m_omnihandle, - "kokkosp_declare_metadata"); - OMNITRACE_DLSYM(kokkosp_request_tool_settings_f, m_omnihandle, - "kokkosp_request_tool_settings"); - OMNITRACE_DLSYM(kokkosp_init_library_f, m_omnihandle, "kokkosp_init_library"); - OMNITRACE_DLSYM(kokkosp_finalize_library_f, m_omnihandle, - "kokkosp_finalize_library"); - OMNITRACE_DLSYM(kokkosp_begin_parallel_for_f, m_omnihandle, - "kokkosp_begin_parallel_for"); - OMNITRACE_DLSYM(kokkosp_end_parallel_for_f, m_omnihandle, - "kokkosp_end_parallel_for"); - OMNITRACE_DLSYM(kokkosp_begin_parallel_reduce_f, m_omnihandle, - "kokkosp_begin_parallel_reduce"); - OMNITRACE_DLSYM(kokkosp_end_parallel_reduce_f, m_omnihandle, - "kokkosp_end_parallel_reduce"); - OMNITRACE_DLSYM(kokkosp_begin_parallel_scan_f, m_omnihandle, - "kokkosp_begin_parallel_scan"); - OMNITRACE_DLSYM(kokkosp_end_parallel_scan_f, m_omnihandle, - "kokkosp_end_parallel_scan"); - OMNITRACE_DLSYM(kokkosp_begin_fence_f, m_omnihandle, "kokkosp_begin_fence"); - OMNITRACE_DLSYM(kokkosp_end_fence_f, m_omnihandle, "kokkosp_end_fence"); - OMNITRACE_DLSYM(kokkosp_push_profile_region_f, m_omnihandle, - "kokkosp_push_profile_region"); - OMNITRACE_DLSYM(kokkosp_pop_profile_region_f, m_omnihandle, - "kokkosp_pop_profile_region"); - OMNITRACE_DLSYM(kokkosp_create_profile_section_f, m_omnihandle, - "kokkosp_create_profile_section"); - OMNITRACE_DLSYM(kokkosp_destroy_profile_section_f, m_omnihandle, - "kokkosp_destroy_profile_section"); - OMNITRACE_DLSYM(kokkosp_start_profile_section_f, m_omnihandle, - "kokkosp_start_profile_section"); - OMNITRACE_DLSYM(kokkosp_stop_profile_section_f, m_omnihandle, - "kokkosp_stop_profile_section"); - OMNITRACE_DLSYM(kokkosp_allocate_data_f, m_omnihandle, "kokkosp_allocate_data"); - OMNITRACE_DLSYM(kokkosp_deallocate_data_f, m_omnihandle, - "kokkosp_deallocate_data"); - OMNITRACE_DLSYM(kokkosp_begin_deep_copy_f, m_omnihandle, - "kokkosp_begin_deep_copy"); - OMNITRACE_DLSYM(kokkosp_end_deep_copy_f, m_omnihandle, "kokkosp_end_deep_copy"); - OMNITRACE_DLSYM(kokkosp_profile_event_f, m_omnihandle, "kokkosp_profile_event"); - OMNITRACE_DLSYM(kokkosp_dual_view_sync_f, m_omnihandle, "kokkosp_dual_view_sync"); - OMNITRACE_DLSYM(kokkosp_dual_view_modify_f, m_omnihandle, - "kokkosp_dual_view_modify"); - -#if OMNITRACE_USE_ROCTRACER > 0 - OMNITRACE_DLSYM(hsa_on_load_f, m_omnihandle, "OnLoad"); - OMNITRACE_DLSYM(hsa_on_unload_f, m_omnihandle, "OnUnload"); -#endif - -#if OMNITRACE_USE_ROCPROFILER > 0 - OMNITRACE_DLSYM(rocp_on_load_tool_prop_f, m_omnihandle, "OnLoadToolProp"); - OMNITRACE_DLSYM(rocp_on_unload_tool_f, m_omnihandle, "OnUnloadTool"); -#endif - -#if OMNITRACE_USE_OMPT == 0 - _warn_verbose = 5; -#else - OMNITRACE_DLSYM(ompt_start_tool_f, m_omnihandle, "ompt_start_tool"); -#endif - - if(!m_userhandle) m_userhandle = open(m_userlib); - _warn_verbose = 0; - OMNITRACE_DLSYM(omnitrace_user_configure_f, m_userhandle, - "omnitrace_user_configure"); - - if(omnitrace_user_configure_f) - { - omnitrace_user_callbacks_t _cb = {}; - _cb.start_trace = &omnitrace_user_start_trace_dl; - _cb.stop_trace = &omnitrace_user_stop_trace_dl; - _cb.start_thread_trace = &omnitrace_user_start_thread_trace_dl; - _cb.stop_thread_trace = &omnitrace_user_stop_thread_trace_dl; - _cb.push_region = &omnitrace_user_push_region_dl; - _cb.pop_region = &omnitrace_user_pop_region_dl; - _cb.progress = &omnitrace_user_progress_dl; - _cb.push_annotated_region = &omnitrace_user_push_annotated_region_dl; - _cb.pop_annotated_region = &omnitrace_user_pop_annotated_region_dl; - _cb.annotated_progress = &omnitrace_user_annotated_progress_dl; - (*omnitrace_user_configure_f)(OMNITRACE_USER_REPLACE_CONFIG, _cb, nullptr); - } - } - -public: - using user_cb_t = omnitrace_user_callbacks_t; - - // libomnitrace functions - void (*omnitrace_init_library_f)(void) = nullptr; - void (*omnitrace_init_tooling_f)(void) = nullptr; - void (*omnitrace_init_f)(const char*, bool, const char*) = nullptr; - void (*omnitrace_finalize_f)(void) = nullptr; - void (*omnitrace_set_env_f)(const char*, const char*) = nullptr; - void (*omnitrace_set_mpi_f)(bool, bool) = nullptr; - void (*omnitrace_register_source_f)(const char*, const char*, size_t, size_t, - const char*) = nullptr; - void (*omnitrace_register_coverage_f)(const char*, const char*, size_t) = nullptr; - void (*omnitrace_push_trace_f)(const char*) = nullptr; - void (*omnitrace_pop_trace_f)(const char*) = nullptr; - int (*omnitrace_push_region_f)(const char*) = nullptr; - int (*omnitrace_pop_region_f)(const char*) = nullptr; - int (*omnitrace_push_category_region_f)(omnitrace_category_t, const char*, - omnitrace_annotation_t*, size_t) = nullptr; - int (*omnitrace_pop_category_region_f)(omnitrace_category_t, const char*, - omnitrace_annotation_t*, size_t) = nullptr; - void (*omnitrace_progress_f)(const char*) = nullptr; - void (*omnitrace_annotated_progress_f)(const char*, omnitrace_annotation_t*, - size_t) = nullptr; - - // libomnitrace-user functions - int (*omnitrace_user_configure_f)(int, user_cb_t, user_cb_t*) = nullptr; - - // KokkosP functions - void (*kokkosp_print_help_f)(char*) = nullptr; - void (*kokkosp_parse_args_f)(int, char**) = nullptr; - void (*kokkosp_declare_metadata_f)(const char*, const char*) = nullptr; - void (*kokkosp_request_tool_settings_f)(const uint32_t, - Kokkos_Tools_ToolSettings*) = nullptr; - void (*kokkosp_init_library_f)(const int, const uint64_t, const uint32_t, - void*) = nullptr; - void (*kokkosp_finalize_library_f)() = nullptr; - void (*kokkosp_begin_parallel_for_f)(const char*, uint32_t, uint64_t*) = nullptr; - void (*kokkosp_end_parallel_for_f)(uint64_t) = nullptr; - void (*kokkosp_begin_parallel_reduce_f)(const char*, uint32_t, uint64_t*) = nullptr; - void (*kokkosp_end_parallel_reduce_f)(uint64_t) = nullptr; - void (*kokkosp_begin_parallel_scan_f)(const char*, uint32_t, uint64_t*) = nullptr; - void (*kokkosp_end_parallel_scan_f)(uint64_t) = nullptr; - void (*kokkosp_begin_fence_f)(const char*, uint32_t, uint64_t*) = nullptr; - void (*kokkosp_end_fence_f)(uint64_t) = nullptr; - void (*kokkosp_push_profile_region_f)(const char*) = nullptr; - void (*kokkosp_pop_profile_region_f)() = nullptr; - void (*kokkosp_create_profile_section_f)(const char*, uint32_t*) = nullptr; - void (*kokkosp_destroy_profile_section_f)(uint32_t) = nullptr; - void (*kokkosp_start_profile_section_f)(uint32_t) = nullptr; - void (*kokkosp_stop_profile_section_f)(uint32_t) = nullptr; - void (*kokkosp_allocate_data_f)(const SpaceHandle, const char*, const void* const, - const uint64_t) = nullptr; - void (*kokkosp_deallocate_data_f)(const SpaceHandle, const char*, const void* const, - const uint64_t) = nullptr; - void (*kokkosp_begin_deep_copy_f)(SpaceHandle, const char*, const void*, SpaceHandle, - const char*, const void*, uint64_t) = nullptr; - void (*kokkosp_end_deep_copy_f)() = nullptr; - void (*kokkosp_profile_event_f)(const char*) = nullptr; - void (*kokkosp_dual_view_sync_f)(const char*, const void* const, bool) = nullptr; - void (*kokkosp_dual_view_modify_f)(const char*, const void* const, bool) = nullptr; - - // HSA functions -#if OMNITRACE_USE_ROCTRACER > 0 - bool (*hsa_on_load_f)(HsaApiTable*, uint64_t, uint64_t, const char* const*) = nullptr; - void (*hsa_on_unload_f)() = nullptr; -#endif - - // ROCP functions -#if OMNITRACE_USE_ROCPROFILER > 0 - void (*rocp_on_load_tool_prop_f)(void* settings) = nullptr; - void (*rocp_on_unload_tool_f)() = nullptr; -#endif - - // OpenMP functions -#if defined(OMNITRACE_USE_OMPT) && OMNITRACE_USE_OMPT > 0 - ompt_start_tool_result_t* (*ompt_start_tool_f)(unsigned int, const char*); -#endif - - auto get_omni_library() const { return m_omnilib; } - auto get_user_library() const { return m_userlib; } - auto get_dl_library() const { return m_dllib; } - -private: - void* m_omnihandle = nullptr; - void* m_userhandle = nullptr; - std::string m_omnilib = {}; - std::string m_dllib = {}; - std::string m_userlib = {}; -}; - -inline indirect& -get_indirect() OMNITRACE_INTERNAL_API; - -indirect& -get_indirect() -{ - omnitrace_preinit_library(); - - static auto _libomni = get_env("OMNITRACE_LIBRARY", "libomnitrace.so"); - static auto _libuser = get_env("OMNITRACE_USER_LIBRARY", "librocprof-sys-user.so"); - static auto _libdlib = get_env("OMNITRACE_DL_LIBRARY", "librocprof-sys-dl.so"); - static auto* _v = new indirect{ _libomni, _libuser, _libdlib }; - return *_v; -} - -auto& -get_inited() -{ - static bool* _v = new bool{ false }; - return *_v; -} - -auto& -get_finied() -{ - static bool* _v = new bool{ false }; - return *_v; -} - -auto& -get_active() -{ - static bool* _v = new bool{ false }; - return *_v; -} - -auto& -get_enabled() -{ - static auto* _v = new std::atomic{ get_env("OMNITRACE_INIT_ENABLED", true) }; - return *_v; -} - -auto& -get_thread_enabled() -{ - static thread_local bool _v = get_enabled(); - return _v; -} - -auto& -get_thread_count() -{ - static thread_local int64_t _v = 0; - return _v; -} - -auto& -get_thread_status() -{ - static thread_local bool _v = false; - return _v; -} - -InstrumentMode& -get_instrumented() -{ - static auto _v = get_env("OMNITRACE_INSTRUMENT_MODE", InstrumentMode::None); - return _v; -} - -// ensure finalization is called -bool _omnitrace_dl_fini = (std::atexit([]() { - if(get_active()) omnitrace_finalize(); - }), - true); -} // namespace -} // namespace dl -} // namespace omnitrace - -//--------------------------------------------------------------------------------------// - -#define OMNITRACE_DL_INVOKE(...) \ - ::omnitrace::common::invoke(__FUNCTION__, ::omnitrace::dl::_omnitrace_dl_verbose, \ - (::omnitrace::dl::get_thread_status() = false), \ - __VA_ARGS__) - -#define OMNITRACE_DL_IGNORE(...) \ - ::omnitrace::common::ignore(__FUNCTION__, ::omnitrace::dl::_omnitrace_dl_verbose, \ - __VA_ARGS__) - -#define OMNITRACE_DL_INVOKE_STATUS(STATUS, ...) \ - ::omnitrace::common::invoke(__FUNCTION__, ::omnitrace::dl::_omnitrace_dl_verbose, \ - STATUS, __VA_ARGS__) - -#define OMNITRACE_DL_LOG(LEVEL, ...) \ - if(::omnitrace::dl::_omnitrace_dl_verbose >= LEVEL) \ - { \ - fflush(stderr); \ - OMNITRACE_COMMON_LIBRARY_LOG_START \ - fprintf(stderr, "[omnitrace][" OMNITRACE_COMMON_LIBRARY_NAME "][%i] ", \ - getpid()); \ - fprintf(stderr, __VA_ARGS__); \ - OMNITRACE_COMMON_LIBRARY_LOG_END \ - fflush(stderr); \ - } - -using omnitrace::dl::get_indirect; -namespace dl = omnitrace::dl; - -extern "C" -{ - void omnitrace_preinit_library(void) - { - if(omnitrace::common::get_env("OMNITRACE_MONOCHROME", tim::log::monochrome())) - tim::log::monochrome() = true; - } - - int omnitrace_preload_library(void) - { - return (::omnitrace::dl::get_omnitrace_preload()) ? 1 : 0; - } - - void omnitrace_init_library(void) - { - OMNITRACE_DL_INVOKE(get_indirect().omnitrace_init_library_f); - } - - void omnitrace_init_tooling(void) - { - OMNITRACE_DL_INVOKE(get_indirect().omnitrace_init_tooling_f); - } - - void omnitrace_init(const char* a, bool b, const char* c) - { - if(dl::get_inited() && dl::get_finied()) - { - OMNITRACE_DL_LOG( - 2, "%s(%s) ignored :: already initialized and finalized\n", __FUNCTION__, - ::omnitrace::join(::omnitrace::QuoteStrings{}, ", ", a, b, c).c_str()); - return; - } - else if(dl::get_inited() && dl::get_active()) - { - OMNITRACE_DL_LOG( - 2, "%s(%s) ignored :: already initialized and active\n", __FUNCTION__, - ::omnitrace::join(::omnitrace::QuoteStrings{}, ", ", a, b, c).c_str()); - return; - } - - if(dl::get_instrumented() < dl::InstrumentMode::PythonProfile) - dl::omnitrace_preinit(); - - bool _invoked = false; - OMNITRACE_DL_INVOKE_STATUS(_invoked, get_indirect().omnitrace_init_f, a, b, c); - if(_invoked) - { - dl::get_active() = true; - dl::get_inited() = true; - dl::_omnitrace_dl_verbose = dl::get_omnitrace_dl_env(); - if(dl::get_instrumented() < dl::InstrumentMode::PythonProfile) - dl::omnitrace_postinit((c) ? std::string{ c } : std::string{}); - } - } - - void omnitrace_finalize(void) - { - if(dl::get_inited() && dl::get_finied()) - { - OMNITRACE_DL_LOG(2, "%s() ignored :: already initialized and finalized\n", - __FUNCTION__); - return; - } - else if(dl::get_finied() && !dl::get_active()) - { - OMNITRACE_DL_LOG(2, "%s() ignored :: already finalized but not active\n", - __FUNCTION__); - return; - } - - bool _invoked = false; - OMNITRACE_DL_INVOKE_STATUS(_invoked, get_indirect().omnitrace_finalize_f); - if(_invoked) - { - dl::get_active() = false; - dl::get_finied() = true; - } - } - - void omnitrace_push_trace(const char* name) - { - if(!dl::get_active()) return; - if(dl::get_thread_enabled()) - { - OMNITRACE_DL_INVOKE(get_indirect().omnitrace_push_trace_f, name); - } - else - { - ++dl::get_thread_count(); - } - } - - void omnitrace_pop_trace(const char* name) - { - if(!dl::get_active()) return; - if(dl::get_thread_enabled()) - { - OMNITRACE_DL_INVOKE(get_indirect().omnitrace_pop_trace_f, name); - } - else - { - if(dl::get_thread_count()-- == 0) omnitrace_user_start_thread_trace_dl(); - } - } - - int omnitrace_push_region(const char* name) - { - if(!dl::get_active()) return 0; - if(dl::get_thread_enabled()) - { - return OMNITRACE_DL_INVOKE(get_indirect().omnitrace_push_region_f, name); - } - else - { - ++dl::get_thread_count(); - } - return 0; - } - - int omnitrace_pop_region(const char* name) - { - if(!dl::get_active()) return 0; - if(dl::get_thread_enabled()) - { - return OMNITRACE_DL_INVOKE(get_indirect().omnitrace_pop_region_f, name); - } - else - { - if(dl::get_thread_count()-- == 0) omnitrace_user_start_thread_trace_dl(); - } - return 0; - } - - int omnitrace_push_category_region(omnitrace_category_t _category, const char* name, - omnitrace_annotation_t* _annotations, - size_t _annotation_count) - { - if(!dl::get_active()) return 0; - if(dl::get_thread_enabled()) - { - return OMNITRACE_DL_INVOKE(get_indirect().omnitrace_push_category_region_f, - _category, name, _annotations, _annotation_count); - } - else - { - ++dl::get_thread_count(); - } - return 0; - } - - int omnitrace_pop_category_region(omnitrace_category_t _category, const char* name, - omnitrace_annotation_t* _annotations, - size_t _annotation_count) - { - if(!dl::get_active()) return 0; - if(dl::get_thread_enabled()) - { - return OMNITRACE_DL_INVOKE(get_indirect().omnitrace_pop_category_region_f, - _category, name, _annotations, _annotation_count); - } - else - { - ++dl::get_thread_count(); - } - return 0; - } - - void omnitrace_set_env(const char* a, const char* b) - { - if(dl::get_inited() && dl::get_active()) - { - OMNITRACE_DL_IGNORE(2, "already initialized and active", a, b); - return; - } - OMNITRACE_DL_LOG(2, "%s(%s, %s)\n", __FUNCTION__, a, b); - setenv(a, b, 0); - // OMNITRACE_DL_INVOKE(get_indirect().omnitrace_set_env_f, a, b); - } - - void omnitrace_set_mpi(bool a, bool b) - { - if(dl::get_inited() && dl::get_active()) - { - OMNITRACE_DL_IGNORE(2, "already initialized and active", a, b); - return; - } - OMNITRACE_DL_INVOKE(get_indirect().omnitrace_set_mpi_f, a, b); - } - - void omnitrace_register_source(const char* file, const char* func, size_t line, - size_t address, const char* source) - { - OMNITRACE_DL_LOG(3, "%s(\"%s\", \"%s\", %zu, %zu, \"%s\")\n", __FUNCTION__, file, - func, line, address, source); - OMNITRACE_DL_INVOKE(get_indirect().omnitrace_register_source_f, file, func, line, - address, source); - } - - void omnitrace_register_coverage(const char* file, const char* func, size_t address) - { - OMNITRACE_DL_INVOKE(get_indirect().omnitrace_register_coverage_f, file, func, - address); - } - - int omnitrace_user_start_trace_dl(void) - { - dl::get_enabled().store(true); - return omnitrace_user_start_thread_trace_dl(); - } - - int omnitrace_user_stop_trace_dl(void) - { - dl::get_enabled().store(false); - return omnitrace_user_stop_thread_trace_dl(); - } - - int omnitrace_user_start_thread_trace_dl(void) - { - dl::get_thread_enabled() = true; - return 0; - } - - int omnitrace_user_stop_thread_trace_dl(void) - { - dl::get_thread_enabled() = false; - return 0; - } - - int omnitrace_user_push_region_dl(const char* name) - { - if(!dl::get_active()) return 0; - return OMNITRACE_DL_INVOKE(get_indirect().omnitrace_push_region_f, name); - } - - int omnitrace_user_pop_region_dl(const char* name) - { - if(!dl::get_active()) return 0; - return OMNITRACE_DL_INVOKE(get_indirect().omnitrace_pop_region_f, name); - } - - int omnitrace_user_progress_dl(const char* name) - { - OMNITRACE_DL_INVOKE(get_indirect().omnitrace_progress_f, name); - return 0; - } - - int omnitrace_user_push_annotated_region_dl(const char* name, - omnitrace_annotation_t* _annotations, - size_t _annotation_count) - { - if(!dl::get_active()) return 0; - return OMNITRACE_DL_INVOKE(get_indirect().omnitrace_push_category_region_f, - OMNITRACE_CATEGORY_USER, name, _annotations, - _annotation_count); - } - - int omnitrace_user_pop_annotated_region_dl(const char* name, - omnitrace_annotation_t* _annotations, - size_t _annotation_count) - { - if(!dl::get_active()) return 0; - return OMNITRACE_DL_INVOKE(get_indirect().omnitrace_pop_category_region_f, - OMNITRACE_CATEGORY_USER, name, _annotations, - _annotation_count); - } - - int omnitrace_user_annotated_progress_dl(const char* name, - omnitrace_annotation_t* _annotations, - size_t _annotation_count) - { - OMNITRACE_DL_INVOKE(get_indirect().omnitrace_annotated_progress_f, name, - _annotations, _annotation_count); - return 0; - } - - void omnitrace_progress(const char* _name) - { - return OMNITRACE_DL_INVOKE(get_indirect().omnitrace_progress_f, _name); - } - - void omnitrace_annotated_progress(const char* _name, - omnitrace_annotation_t* _annotations, - size_t _annotation_count) - { - return OMNITRACE_DL_INVOKE(get_indirect().omnitrace_annotated_progress_f, _name, - _annotations, _annotation_count); - } - - void omnitrace_set_instrumented(int _mode) - { - OMNITRACE_DL_LOG(2, "%s(%i)\n", __FUNCTION__, _mode); - auto _mode_v = static_cast(_mode); - if(_mode_v < dl::InstrumentMode::None || _mode_v >= dl::InstrumentMode::Last) - { - OMNITRACE_DL_LOG(-127, - "%s(mode=%i) invoked with invalid instrumentation mode. " - "mode should be %i >= mode < %i\n", - __FUNCTION__, _mode, - static_cast(dl::InstrumentMode::None), - static_cast(dl::InstrumentMode::Last)); - } - dl::get_instrumented() = _mode_v; - } - - //----------------------------------------------------------------------------------// - // - // KokkosP - // - //----------------------------------------------------------------------------------// - - void kokkosp_print_help(char* argv0) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_print_help_f, argv0); - } - - void kokkosp_parse_args(int argc, char** argv) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_parse_args_f, argc, argv); - } - - void kokkosp_declare_metadata(const char* key, const char* value) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_declare_metadata_f, key, value); - } - - void kokkosp_request_tool_settings(const uint32_t version, - Kokkos_Tools_ToolSettings* settings) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_request_tool_settings_f, - version, settings); - } - - void kokkosp_init_library(const int loadSeq, const uint64_t interfaceVer, - const uint32_t devInfoCount, void* deviceInfo) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_init_library_f, loadSeq, - interfaceVer, devInfoCount, deviceInfo); - } - - void kokkosp_finalize_library() - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_finalize_library_f); - } - - void kokkosp_begin_parallel_for(const char* name, uint32_t devid, uint64_t* kernid) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_begin_parallel_for_f, name, - devid, kernid); - } - - void kokkosp_end_parallel_for(uint64_t kernid) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_end_parallel_for_f, kernid); - } - - void kokkosp_begin_parallel_reduce(const char* name, uint32_t devid, uint64_t* kernid) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_begin_parallel_reduce_f, name, - devid, kernid); - } - - void kokkosp_end_parallel_reduce(uint64_t kernid) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_end_parallel_reduce_f, kernid); - } - - void kokkosp_begin_parallel_scan(const char* name, uint32_t devid, uint64_t* kernid) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_begin_parallel_scan_f, name, - devid, kernid); - } - - void kokkosp_end_parallel_scan(uint64_t kernid) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_end_parallel_scan_f, kernid); - } - - void kokkosp_begin_fence(const char* name, uint32_t devid, uint64_t* kernid) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_begin_fence_f, name, devid, - kernid); - } - - void kokkosp_end_fence(uint64_t kernid) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_end_fence_f, kernid); - } - - void kokkosp_push_profile_region(const char* name) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_push_profile_region_f, name); - } - - void kokkosp_pop_profile_region() - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_pop_profile_region_f); - } - - void kokkosp_create_profile_section(const char* name, uint32_t* secid) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_create_profile_section_f, name, - secid); - } - - void kokkosp_destroy_profile_section(uint32_t secid) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_destroy_profile_section_f, - secid); - } - - void kokkosp_start_profile_section(uint32_t secid) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_start_profile_section_f, secid); - } - - void kokkosp_stop_profile_section(uint32_t secid) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_stop_profile_section_f, secid); - } - - void kokkosp_allocate_data(const SpaceHandle space, const char* label, - const void* const ptr, const uint64_t size) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_allocate_data_f, space, label, - ptr, size); - } - - void kokkosp_deallocate_data(const SpaceHandle space, const char* label, - const void* const ptr, const uint64_t size) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_deallocate_data_f, space, label, - ptr, size); - } - - void kokkosp_begin_deep_copy(SpaceHandle dst_handle, const char* dst_name, - const void* dst_ptr, SpaceHandle src_handle, - const char* src_name, const void* src_ptr, uint64_t size) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_begin_deep_copy_f, dst_handle, - dst_name, dst_ptr, src_handle, src_name, src_ptr, - size); - } - - void kokkosp_end_deep_copy() - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_end_deep_copy_f); - } - - void kokkosp_profile_event(const char* name) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_profile_event_f, name); - } - - void kokkosp_dual_view_sync(const char* label, const void* const data, bool is_device) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_dual_view_sync_f, label, data, - is_device); - } - - void kokkosp_dual_view_modify(const char* label, const void* const data, - bool is_device) - { - return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_dual_view_modify_f, label, data, - is_device); - } - - //----------------------------------------------------------------------------------// - // - // HSA - // - //----------------------------------------------------------------------------------// - -#if OMNITRACE_USE_ROCTRACER > 0 - bool OnLoad(HsaApiTable* table, uint64_t runtime_version, uint64_t failed_tool_count, - const char* const* failed_tool_names) - { - return OMNITRACE_DL_INVOKE(get_indirect().hsa_on_load_f, table, runtime_version, - failed_tool_count, failed_tool_names); - } - - void OnUnload() { return OMNITRACE_DL_INVOKE(get_indirect().hsa_on_unload_f); } -#endif - - //----------------------------------------------------------------------------------// - // - // ROCP - // - //----------------------------------------------------------------------------------// - -#if OMNITRACE_USE_ROCPROFILER > 0 - void OnLoadToolProp(void* settings) - { - OMNITRACE_DL_LOG(-16, - "invoking %s(rocprofiler_settings_t*) within omnitrace-dl.so " - "will cause a silent failure for rocprofiler. ROCP_TOOL_LIB " - "should be set to libomnitrace.so\n", - __FUNCTION__); - abort(); - return OMNITRACE_DL_INVOKE(get_indirect().rocp_on_load_tool_prop_f, settings); - } - - void OnUnloadTool() - { - return OMNITRACE_DL_INVOKE(get_indirect().rocp_on_unload_tool_f); - } -#endif - - //----------------------------------------------------------------------------------// - // - // OMPT - // - //----------------------------------------------------------------------------------// -#if OMNITRACE_USE_OMPT > 0 - ompt_start_tool_result_t* ompt_start_tool(unsigned int omp_version, - const char* runtime_version) - { - return OMNITRACE_DL_INVOKE(get_indirect().ompt_start_tool_f, omp_version, - runtime_version); - } -#endif -} - -namespace omnitrace -{ -namespace dl -{ -namespace -{ -bool -omnitrace_preload() OMNITRACE_INTERNAL_API; - -std::vector -get_link_map(const char*, - std::vector&& = { (RTLD_LAZY | RTLD_NOLOAD) }) OMNITRACE_INTERNAL_API; - -const char* -get_default_mode() OMNITRACE_INTERNAL_API; - -void -verify_instrumented_preloaded() OMNITRACE_INTERNAL_API; - -std::vector -get_link_map(const char* _name, std::vector&& _open_modes) -{ - void* _handle = nullptr; - bool _noload = false; - for(auto _mode : _open_modes) - { - _handle = dlopen(_name, _mode); - _noload = (_mode & RTLD_NOLOAD) == RTLD_NOLOAD; - if(_handle) break; - } - - auto _chain = std::vector{}; - if(_handle) - { - struct link_map* _link_map = nullptr; - dlinfo(_handle, RTLD_DI_LINKMAP, &_link_map); - struct link_map* _next = _link_map->l_next; - while(_next) - { - if(_next->l_name != nullptr && !std::string_view{ _next->l_name }.empty()) - { - _chain.emplace_back(_next->l_name); - } - _next = _next->l_next; - } - - if(_noload == false) dlclose(_handle); - } - return _chain; -} - -const char* -get_default_mode() -{ - if(get_env("OMNITRACE_USE_CAUSAL", false)) return "causal"; - - auto _link_map = get_link_map(nullptr); - for(const auto& itr : _link_map) - { - if(itr.find("librocprof-sys-rt.so") != std::string::npos || - itr.find("libdyninstAPI_RT.so") != std::string::npos) - return "trace"; - } - - return "sampling"; -} - -void -omnitrace_preinit() -{ - switch(get_instrumented()) - { - case InstrumentMode::None: - case InstrumentMode::BinaryRewrite: - case InstrumentMode::ProcessCreate: - case InstrumentMode::ProcessAttach: - { - auto _use_mpip = get_env("OMNITRACE_USE_MPIP", false); - auto _use_mpi = get_env("OMNITRACE_USE_MPI", _use_mpip); - auto _causal = get_env("OMNITRACE_USE_CAUSAL", false); - auto _mode = get_env("OMNITRACE_MODE", get_default_mode()); - - if(_use_mpi && !(_causal && _mode == "causal")) - { - // only make this call if true bc otherwise, if - // false, it will disable the MPIP component and - // we may intercept the MPI init call later. - // If _use_mpi defaults to true above, calling this - // will override can current env or config value for - // OMNITRACE_USE_PID. - omnitrace_set_mpi(_use_mpi, dl::get_instrumented() == - dl::InstrumentMode::ProcessAttach); - } - break; - } - case InstrumentMode::PythonProfile: - case InstrumentMode::Last: break; - } -} - -void -omnitrace_postinit(std::string _exe) -{ - switch(get_instrumented()) - { - case InstrumentMode::None: - case InstrumentMode::BinaryRewrite: - case InstrumentMode::ProcessCreate: - case InstrumentMode::ProcessAttach: - { - if(_exe.empty()) - _exe = tim::filepath::readlink(join('/', "/proc", getpid(), "exe")); - - omnitrace_init_tooling(); - if(_exe.empty()) - omnitrace_push_trace("main"); - else - omnitrace_push_trace(basename(_exe.c_str())); - break; - } - case InstrumentMode::PythonProfile: - { - omnitrace_init_tooling(); - break; - } - case InstrumentMode::Last: break; - } -} - -bool -omnitrace_preload() -{ - auto _preload = get_omnitrace_is_preloaded() && get_omnitrace_preload() && - get_env("OMNITRACE_ENABLED", true); - - auto _link_map = get_link_map(nullptr); - auto _instr_mode = - get_env("OMNITRACE_INSTRUMENT_MODE", dl::InstrumentMode::BinaryRewrite); - for(const auto& itr : _link_map) - { - if(itr.find("librocprof-sys-rt.so") != std::string::npos || - itr.find("libdyninstAPI_RT.so") != std::string::npos) - { - omnitrace_set_instrumented(static_cast(_instr_mode)); - break; - } - } - - verify_instrumented_preloaded(); - - static bool _once = false; - if(_once) return _preload; - _once = true; - - if(_preload) - { - reset_omnitrace_preload(); - omnitrace_preinit_library(); - } - - return _preload; -} - -void -verify_instrumented_preloaded() -{ - // if preloaded then we are fine - if(get_omnitrace_is_preloaded()) return; - - // value returned by get_instrumented is set by either: - // - the search of the linked libraries - // - via the instrumenter - // if binary rewrite or runtime instrumentation, there is an opportunity for - // LD_PRELOAD - switch(dl::get_instrumented()) - { - case dl::InstrumentMode::None: - case dl::InstrumentMode::ProcessAttach: - case dl::InstrumentMode::ProcessCreate: - case dl::InstrumentMode::PythonProfile: - { - return; - } - case dl::InstrumentMode::BinaryRewrite: - { - break; - } - case dl::InstrumentMode::Last: - { - throw std::runtime_error( - "Invalid instrumentation type: InstrumentMode::Last"); - } - } - - static const char* _notice = R"notice( - - NNNNNNNN NNNNNNNN OOOOOOOOO TTTTTTTTTTTTTTTTTTTTTTTIIIIIIIIII CCCCCCCCCCCCCEEEEEEEEEEEEEEEEEEEEEE - N:::::::N N::::::N OO:::::::::OO T:::::::::::::::::::::TI::::::::I CCC::::::::::::CE::::::::::::::::::::E - N::::::::N N::::::N OO:::::::::::::OO T:::::::::::::::::::::TI::::::::I CC:::::::::::::::CE::::::::::::::::::::E - N:::::::::N N::::::NO:::::::OOO:::::::OT:::::TT:::::::TT:::::TII::::::IIC:::::CCCCCCCC::::CEE::::::EEEEEEEEE::::E - N::::::::::N N::::::NO::::::O O::::::OTTTTTT T:::::T TTTTTT I::::I C:::::C CCCCCC E:::::E EEEEEE - N:::::::::::N N::::::NO:::::O O:::::O T:::::T I::::IC:::::C E:::::E - N:::::::N::::N N::::::NO:::::O O:::::O T:::::T I::::IC:::::C E::::::EEEEEEEEEE - N::::::N N::::N N::::::NO:::::O O:::::O T:::::T I::::IC:::::C E:::::::::::::::E - N::::::N N::::N:::::::NO:::::O O:::::O T:::::T I::::IC:::::C E:::::::::::::::E - N::::::N N:::::::::::NO:::::O O:::::O T:::::T I::::IC:::::C E::::::EEEEEEEEEE - N::::::N N::::::::::NO:::::O O:::::O T:::::T I::::IC:::::C E:::::E - N::::::N N:::::::::NO::::::O O::::::O T:::::T I::::I C:::::C CCCCCC E:::::E EEEEEE - N::::::N N::::::::NO:::::::OOO:::::::O TT:::::::TT II::::::IIC:::::CCCCCCCC::::CEE::::::EEEEEEEE:::::E - N::::::N N:::::::N OO:::::::::::::OO T:::::::::T I::::::::I CC:::::::::::::::CE::::::::::::::::::::E - N::::::N N::::::N OO:::::::::OO T:::::::::T I::::::::I CCC::::::::::::CE::::::::::::::::::::E - NNNNNNNN NNNNNNN OOOOOOOOO TTTTTTTTTTT IIIIIIIIII CCCCCCCCCCCCCEEEEEEEEEEEEEEEEEEEEEE - - _ _ _____ ______ - | | | |/ ____| ____| - | | | | (___ | |__ - | | | |\___ \| __| - | |__| |____) | |____ - \____/|_____/|______| - - ____ __ __ _ _ _____ _______ _____ _____ ______ _____ _ _ _ _ - / __ \| \/ | \ | |_ _|__ __| __ \ /\ / ____| ____| | __ \| | | | \ | | - | | | | \ / | \| | | | | | | |__) | / \ | | | |__ ______| |__) | | | | \| | - | | | | |\/| | . ` | | | | | | _ / / /\ \| | | __|______| _ /| | | | . ` | - | |__| | | | | |\ |_| |_ | | | | \ \ / ____ \ |____| |____ | | \ \| |__| | |\ | - \____/|_| |_|_| \_|_____| |_| |_| \_\/_/ \_\_____|______| |_| \_\\____/|_| \_| - - - Due to a variety of edge cases we've encountered, OmniTrace now requires that binary rewritten executables and libraries be launched - with the 'omnitrace-run' executable. - - In order to launch the executable with 'omnitrace-run', prefix the current command with 'omnitrace-run' and a standalone double hyphen ('--'). - For MPI applications, place 'omnitrace-run --' after the MPI command. - E.g.: - - - mpirun -n 2 - - should be: - - omnitrace-run -- - mpirun -n 2 omnitrace-run -- - - Note: the command-line arguments passed to 'omnitrace-run' (which are specified before the double hyphen) will override configuration variables - and/or any configuration values specified to 'omnitrace-instrument' via the '--config' or '--env' options. - E.g.: - - $ omnitrace-instrument -o ./sleep.inst --env OMNITRACE_SAMPLING_DELAY=5.0 -- sleep - $ echo "OMNITRACE_SAMPLING_FREQ = 500" > omnitrace.cfg - $ export OMNITRACE_CONFIG_FILE=omnitrace.cfg - $ omnitrace-run --sampling-freq=100 --sampling-delay=1.0 -- ./sleep.inst 10 - - In the first command, a default sampling delay of 5 seconds in embedded into the instrumented 'sleep.inst'. - In the second command, the sampling frequency will be set to 500 interrupts per second when OmniTrace reads the config file - In the fourth command, the sampling frequency and sampling delay are overridden to 100 interrupts per second and 1 second, respectively, when sleep.inst runs - - Thanks for using OmniTrace and happy optimizing! - )notice"; - - // emit notice - std::cerr << _notice << std::endl; - - std::quick_exit(EXIT_FAILURE); -} - -bool _handle_preload = omnitrace_preload(); -main_func_t main_real = nullptr; -} // namespace -} // namespace dl -} // namespace omnitrace - -extern "C" -{ - int omnitrace_main(int argc, char** argv, char** envp) OMNITRACE_INTERNAL_API; - void omnitrace_set_main(main_func_t) OMNITRACE_INTERNAL_API; - - void omnitrace_set_main(main_func_t _main_real) - { - ::omnitrace::dl::main_real = _main_real; - } - - int omnitrace_main(int argc, char** argv, char** envp) - { - OMNITRACE_DL_LOG(0, "%s\n", __FUNCTION__); - using ::omnitrace::common::get_env; - using ::omnitrace::dl::get_default_mode; - - // prevent re-entry - static int _reentry = 0; - if(_reentry > 0) return -1; - _reentry = 1; - - if(!::omnitrace::dl::main_real) - throw std::runtime_error("[omnitrace][dl] Unsuccessful wrapping of main: " - "nullptr to real main function"); - - if(envp) - { - size_t _idx = 0; - while(envp[_idx] != nullptr) - { - auto _env_v = std::string_view{ envp[_idx++] }; - if(_env_v.find("OMNITRACE") != 0 && - _env_v.find("libomnitrace") == std::string_view::npos) - continue; - auto _pos = _env_v.find('='); - if(_pos < _env_v.length()) - { - auto _var = std::string{ _env_v }.substr(0, _pos); - auto _val = std::string{ _env_v }.substr(_pos + 1); - OMNITRACE_DL_LOG(1, "%s(%s, %s)\n", "omnitrace_set_env", _var.c_str(), - _val.c_str()); - setenv(_var.c_str(), _val.c_str(), 0); - } - } - } - - auto _mode = get_env("OMNITRACE_MODE", get_default_mode()); - omnitrace_init(_mode.c_str(), - dl::get_instrumented() == dl::InstrumentMode::BinaryRewrite, - argv[0]); - - int ret = (*::omnitrace::dl::main_real)(argc, argv, envp); - - omnitrace_pop_trace(basename(argv[0])); - omnitrace_finalize(); - - return ret; - } -} +// MIT License +// +// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#if !defined(OMNITRACE_DL_SOURCE) +# define OMNITRACE_DL_SOURCE 1 +#endif + +#define OMNITRACE_COMMON_LIBRARY_NAME "dl" + +#include + +#define OMNITRACE_COMMON_LIBRARY_LOG_START \ + fprintf(stderr, "%s", ::tim::log::color::info()); +#define OMNITRACE_COMMON_LIBRARY_LOG_END fprintf(stderr, "%s", ::tim::log::color::end()); + +#include "common/defines.h" +#include "common/delimit.hpp" +#include "common/environment.hpp" +#include "common/invoke.hpp" +#include "common/join.hpp" +#include "common/setup.hpp" +#include "dl/dl.hpp" +#include "omnitrace/categories.h" +#include "omnitrace/types.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//--------------------------------------------------------------------------------------// + +#define OMNITRACE_DLSYM(VARNAME, HANDLE, FUNCNAME) \ + if(HANDLE) \ + { \ + *(void**) (&VARNAME) = dlsym(HANDLE, FUNCNAME); \ + if(VARNAME == nullptr && _omnitrace_dl_verbose >= _warn_verbose) \ + { \ + OMNITRACE_COMMON_LIBRARY_LOG_START \ + fprintf(stderr, "[omnitrace][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, "[omnitrace][dl][pid=%i]> %s :: success\n", getpid(), \ + FUNCNAME); \ + OMNITRACE_COMMON_LIBRARY_LOG_END \ + } \ + } + +//--------------------------------------------------------------------------------------// + +using main_func_t = int (*)(int, char**, char**); + +std::ostream& +operator<<(std::ostream& _os, const SpaceHandle& _handle) +{ + _os << _handle.name; + return _os; +} + +namespace omnitrace +{ +namespace dl +{ +namespace +{ +inline int +get_omnitrace_env() +{ + auto&& _debug = get_env("OMNITRACE_DEBUG", false); + return get_env("OMNITRACE_VERBOSE", (_debug) ? 100 : 0); +} + +inline int +get_omnitrace_dl_env() +{ + return get_env("OMNITRACE_DL_DEBUG", false) + ? 100 + : get_env("OMNITRACE_DL_VERBOSE", get_omnitrace_env()); +} + +inline bool& +get_omnitrace_is_preloaded() +{ + static bool _v = []() { + auto&& _preload_libs = get_env("LD_PRELOAD", std::string{}); + return (_preload_libs.find("librocprof-sys-dl.so") != std::string::npos); + }(); + return _v; +} + +inline bool +get_omnitrace_preload() +{ + static bool _v = []() { + auto&& _preload = get_env("OMNITRACE_PRELOAD", true); + auto&& _preload_libs = get_env("LD_PRELOAD", std::string{}); + return (_preload && + _preload_libs.find("librocprof-sys-dl.so") != std::string::npos); + }(); + return _v; +} + +inline void +reset_omnitrace_preload() +{ + auto&& _preload_libs = get_env("LD_PRELOAD", std::string{}); + if(_preload_libs.find("librocprof-sys-dl.so") != std::string::npos) + { + (void) get_omnitrace_is_preloaded(); + (void) get_omnitrace_preload(); + auto _modified_preload = std::string{}; + for(const auto& itr : delimit(_preload_libs, ":")) + { + if(itr.find("librocprof-sys") != std::string::npos) continue; + _modified_preload += common::join("", ":", itr); + } + if(!_modified_preload.empty() && _modified_preload.find(':') == 0) + _modified_preload = _modified_preload.substr(1); + + setenv("LD_PRELOAD", _modified_preload.c_str(), 1); + } +} + +inline pid_t +get_omnitrace_root_pid() +{ + auto _pid = getpid(); + setenv("OMNITRACE_ROOT_PROCESS", std::to_string(_pid).c_str(), 0); + return get_env("OMNITRACE_ROOT_PROCESS", _pid); +} + +void +omnitrace_preinit() OMNITRACE_INTERNAL_API; + +void +omnitrace_postinit(std::string exe = {}) OMNITRACE_INTERNAL_API; + +pid_t _omnitrace_root_pid = get_omnitrace_root_pid(); + +// environment priority: +// - OMNITRACE_DL_DEBUG +// - OMNITRACE_DL_VERBOSE +// - OMNITRACE_DEBUG +// - OMNITRACE_VERBOSE +int _omnitrace_dl_verbose = get_omnitrace_dl_env(); + +// The docs for dlopen suggest that the combination of RTLD_LOCAL + RTLD_DEEPBIND +// (when available) helps ensure that the symbols in the instrumentation library +// librocprof-sys.so will use it's own symbols... not symbols that are potentially +// instrumented. However, this only applies to the symbols in librocprof-sys.so, +// which is NOT self-contained, i.e. symbols in timemory and the libs it links to +// (such as libpapi.so) are not protected by the deep-bind option. Additionally, +// it should be noted that DynInst does *NOT* add instrumentation by manipulating the +// dynamic linker (otherwise it would only be limited to shared libs) -- it manipulates +// the instructions in the binary so that a call to a function such as "main" actually +// calls "main_dyninst", which executes the instrumentation snippets around the actual +// "main" (this is the reason you need the dyninstAPI_RT library). +// +// UPDATE: +// Use of RTLD_DEEPBIND has been removed because it causes the dyninst +// ProcControlAPI to segfault within pthread_cond_wait on certain executables. +// +// Here are the docs on the dlopen options used: +// +// RTLD_LAZY +// Perform lazy binding. Only resolve symbols as the code that references them is +// executed. If the symbol is never referenced, then it is never resolved. (Lazy +// binding is only performed for function references; references to variables are +// always immediately bound when the library is loaded.) +// +// RTLD_LOCAL +// This is the converse of RTLD_GLOBAL, and the default if neither flag is specified. +// Symbols defined in this library are not made available to resolve references in +// subsequently loaded libraries. +// +// RTLD_DEEPBIND (since glibc 2.3.4) +// Place the lookup scope of the symbols in this library ahead of the global scope. +// This means that a self-contained library will use its own symbols in preference to +// global symbols with the same name contained in libraries that have already been +// loaded. This flag is not specified in POSIX.1-2001. +// +#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 4 +auto _omnitrace_dl_dlopen_flags = RTLD_LAZY | RTLD_LOCAL; +const char* _omnitrace_dl_dlopen_descr = "RTLD_LAZY | RTLD_LOCAL"; +#else +auto _omnitrace_dl_dlopen_flags = RTLD_LAZY | RTLD_LOCAL; +const char* _omnitrace_dl_dlopen_descr = "RTLD_LAZY | RTLD_LOCAL"; +#endif + +/// This class contains function pointers for omnitrace's instrumentation functions +struct OMNITRACE_INTERNAL_API indirect +{ + OMNITRACE_INLINE indirect(const std::string& _omnilib, const std::string& _userlib, + const std::string& _dllib) + : m_omnilib{ common::path::find_path(_omnilib, _omnitrace_dl_verbose) } + , m_dllib{ common::path::find_path(_dllib, _omnitrace_dl_verbose) } + , m_userlib{ common::path::find_path(_userlib, _omnitrace_dl_verbose) } + { + if(_omnitrace_dl_verbose >= 1) + { + OMNITRACE_COMMON_LIBRARY_LOG_START + fprintf(stderr, "[omnitrace][dl][pid=%i] %s resolved to '%s'\n", getpid(), + ::basename(_omnilib.c_str()), m_omnilib.c_str()); + fprintf(stderr, "[omnitrace][dl][pid=%i] %s resolved to '%s'\n", getpid(), + ::basename(_dllib.c_str()), m_dllib.c_str()); + fprintf(stderr, "[omnitrace][dl][pid=%i] %s resolved to '%s'\n", getpid(), + ::basename(_userlib.c_str()), m_userlib.c_str()); + OMNITRACE_COMMON_LIBRARY_LOG_END + } + + auto _search_paths = common::join(':', common::path::dirname(_omnilib), + common::path::dirname(_dllib)); + common::setup_environ(_omnitrace_dl_verbose, _search_paths, _omnilib, _dllib); + + m_omnihandle = open(m_omnilib); + m_userhandle = open(m_userlib); + init(); + } + + OMNITRACE_INLINE ~indirect() { dlclose(m_omnihandle); } + + static OMNITRACE_INLINE void* open(const std::string& _lib) + { + auto* libhandle = dlopen(_lib.c_str(), _omnitrace_dl_dlopen_flags); + + if(libhandle) + { + if(_omnitrace_dl_verbose >= 2) + { + OMNITRACE_COMMON_LIBRARY_LOG_START + fprintf(stderr, "[omnitrace][dl][pid=%i] dlopen(\"%s\", %s) :: success\n", + getpid(), _lib.c_str(), _omnitrace_dl_dlopen_descr); + OMNITRACE_COMMON_LIBRARY_LOG_END + } + } + else + { + if(_omnitrace_dl_verbose >= 0) + { + perror("dlopen"); + OMNITRACE_COMMON_LIBRARY_LOG_START + fprintf(stderr, "[omnitrace][dl][pid=%i] dlopen(\"%s\", %s) :: %s\n", + getpid(), _lib.c_str(), _omnitrace_dl_dlopen_descr, dlerror()); + OMNITRACE_COMMON_LIBRARY_LOG_END + } + } + + dlerror(); // Clear any existing error + + return libhandle; + } + + OMNITRACE_INLINE void init() + { + if(!m_omnihandle) m_omnihandle = open(m_omnilib); + + int _warn_verbose = 0; + int _info_verbose = 2; + // Initialize all pointers + OMNITRACE_DLSYM(omnitrace_init_library_f, m_omnihandle, "omnitrace_init_library"); + OMNITRACE_DLSYM(omnitrace_init_tooling_f, m_omnihandle, "omnitrace_init_tooling"); + OMNITRACE_DLSYM(omnitrace_init_f, m_omnihandle, "omnitrace_init"); + OMNITRACE_DLSYM(omnitrace_finalize_f, m_omnihandle, "omnitrace_finalize"); + OMNITRACE_DLSYM(omnitrace_set_env_f, m_omnihandle, "omnitrace_set_env"); + OMNITRACE_DLSYM(omnitrace_set_mpi_f, m_omnihandle, "omnitrace_set_mpi"); + OMNITRACE_DLSYM(omnitrace_push_trace_f, m_omnihandle, "omnitrace_push_trace"); + OMNITRACE_DLSYM(omnitrace_pop_trace_f, m_omnihandle, "omnitrace_pop_trace"); + OMNITRACE_DLSYM(omnitrace_push_region_f, m_omnihandle, "omnitrace_push_region"); + OMNITRACE_DLSYM(omnitrace_pop_region_f, m_omnihandle, "omnitrace_pop_region"); + OMNITRACE_DLSYM(omnitrace_push_category_region_f, m_omnihandle, + "omnitrace_push_category_region"); + OMNITRACE_DLSYM(omnitrace_pop_category_region_f, m_omnihandle, + "omnitrace_pop_category_region"); + OMNITRACE_DLSYM(omnitrace_register_source_f, m_omnihandle, + "omnitrace_register_source"); + OMNITRACE_DLSYM(omnitrace_register_coverage_f, m_omnihandle, + "omnitrace_register_coverage"); + OMNITRACE_DLSYM(omnitrace_progress_f, m_omnihandle, "omnitrace_progress"); + OMNITRACE_DLSYM(omnitrace_annotated_progress_f, m_omnihandle, + "omnitrace_annotated_progress"); + + OMNITRACE_DLSYM(kokkosp_print_help_f, m_omnihandle, "kokkosp_print_help"); + OMNITRACE_DLSYM(kokkosp_parse_args_f, m_omnihandle, "kokkosp_parse_args"); + OMNITRACE_DLSYM(kokkosp_declare_metadata_f, m_omnihandle, + "kokkosp_declare_metadata"); + OMNITRACE_DLSYM(kokkosp_request_tool_settings_f, m_omnihandle, + "kokkosp_request_tool_settings"); + OMNITRACE_DLSYM(kokkosp_init_library_f, m_omnihandle, "kokkosp_init_library"); + OMNITRACE_DLSYM(kokkosp_finalize_library_f, m_omnihandle, + "kokkosp_finalize_library"); + OMNITRACE_DLSYM(kokkosp_begin_parallel_for_f, m_omnihandle, + "kokkosp_begin_parallel_for"); + OMNITRACE_DLSYM(kokkosp_end_parallel_for_f, m_omnihandle, + "kokkosp_end_parallel_for"); + OMNITRACE_DLSYM(kokkosp_begin_parallel_reduce_f, m_omnihandle, + "kokkosp_begin_parallel_reduce"); + OMNITRACE_DLSYM(kokkosp_end_parallel_reduce_f, m_omnihandle, + "kokkosp_end_parallel_reduce"); + OMNITRACE_DLSYM(kokkosp_begin_parallel_scan_f, m_omnihandle, + "kokkosp_begin_parallel_scan"); + OMNITRACE_DLSYM(kokkosp_end_parallel_scan_f, m_omnihandle, + "kokkosp_end_parallel_scan"); + OMNITRACE_DLSYM(kokkosp_begin_fence_f, m_omnihandle, "kokkosp_begin_fence"); + OMNITRACE_DLSYM(kokkosp_end_fence_f, m_omnihandle, "kokkosp_end_fence"); + OMNITRACE_DLSYM(kokkosp_push_profile_region_f, m_omnihandle, + "kokkosp_push_profile_region"); + OMNITRACE_DLSYM(kokkosp_pop_profile_region_f, m_omnihandle, + "kokkosp_pop_profile_region"); + OMNITRACE_DLSYM(kokkosp_create_profile_section_f, m_omnihandle, + "kokkosp_create_profile_section"); + OMNITRACE_DLSYM(kokkosp_destroy_profile_section_f, m_omnihandle, + "kokkosp_destroy_profile_section"); + OMNITRACE_DLSYM(kokkosp_start_profile_section_f, m_omnihandle, + "kokkosp_start_profile_section"); + OMNITRACE_DLSYM(kokkosp_stop_profile_section_f, m_omnihandle, + "kokkosp_stop_profile_section"); + OMNITRACE_DLSYM(kokkosp_allocate_data_f, m_omnihandle, "kokkosp_allocate_data"); + OMNITRACE_DLSYM(kokkosp_deallocate_data_f, m_omnihandle, + "kokkosp_deallocate_data"); + OMNITRACE_DLSYM(kokkosp_begin_deep_copy_f, m_omnihandle, + "kokkosp_begin_deep_copy"); + OMNITRACE_DLSYM(kokkosp_end_deep_copy_f, m_omnihandle, "kokkosp_end_deep_copy"); + OMNITRACE_DLSYM(kokkosp_profile_event_f, m_omnihandle, "kokkosp_profile_event"); + OMNITRACE_DLSYM(kokkosp_dual_view_sync_f, m_omnihandle, "kokkosp_dual_view_sync"); + OMNITRACE_DLSYM(kokkosp_dual_view_modify_f, m_omnihandle, + "kokkosp_dual_view_modify"); + +#if OMNITRACE_USE_ROCTRACER > 0 + OMNITRACE_DLSYM(hsa_on_load_f, m_omnihandle, "OnLoad"); + OMNITRACE_DLSYM(hsa_on_unload_f, m_omnihandle, "OnUnload"); +#endif + +#if OMNITRACE_USE_ROCPROFILER > 0 + OMNITRACE_DLSYM(rocp_on_load_tool_prop_f, m_omnihandle, "OnLoadToolProp"); + OMNITRACE_DLSYM(rocp_on_unload_tool_f, m_omnihandle, "OnUnloadTool"); +#endif + +#if OMNITRACE_USE_OMPT == 0 + _warn_verbose = 5; +#else + OMNITRACE_DLSYM(ompt_start_tool_f, m_omnihandle, "ompt_start_tool"); +#endif + + if(!m_userhandle) m_userhandle = open(m_userlib); + _warn_verbose = 0; + OMNITRACE_DLSYM(omnitrace_user_configure_f, m_userhandle, + "omnitrace_user_configure"); + + if(omnitrace_user_configure_f) + { + omnitrace_user_callbacks_t _cb = {}; + _cb.start_trace = &omnitrace_user_start_trace_dl; + _cb.stop_trace = &omnitrace_user_stop_trace_dl; + _cb.start_thread_trace = &omnitrace_user_start_thread_trace_dl; + _cb.stop_thread_trace = &omnitrace_user_stop_thread_trace_dl; + _cb.push_region = &omnitrace_user_push_region_dl; + _cb.pop_region = &omnitrace_user_pop_region_dl; + _cb.progress = &omnitrace_user_progress_dl; + _cb.push_annotated_region = &omnitrace_user_push_annotated_region_dl; + _cb.pop_annotated_region = &omnitrace_user_pop_annotated_region_dl; + _cb.annotated_progress = &omnitrace_user_annotated_progress_dl; + (*omnitrace_user_configure_f)(OMNITRACE_USER_REPLACE_CONFIG, _cb, nullptr); + } + } + +public: + using user_cb_t = omnitrace_user_callbacks_t; + + // librocprof-sys functions + void (*omnitrace_init_library_f)(void) = nullptr; + void (*omnitrace_init_tooling_f)(void) = nullptr; + void (*omnitrace_init_f)(const char*, bool, const char*) = nullptr; + void (*omnitrace_finalize_f)(void) = nullptr; + void (*omnitrace_set_env_f)(const char*, const char*) = nullptr; + void (*omnitrace_set_mpi_f)(bool, bool) = nullptr; + void (*omnitrace_register_source_f)(const char*, const char*, size_t, size_t, + const char*) = nullptr; + void (*omnitrace_register_coverage_f)(const char*, const char*, size_t) = nullptr; + void (*omnitrace_push_trace_f)(const char*) = nullptr; + void (*omnitrace_pop_trace_f)(const char*) = nullptr; + int (*omnitrace_push_region_f)(const char*) = nullptr; + int (*omnitrace_pop_region_f)(const char*) = nullptr; + int (*omnitrace_push_category_region_f)(omnitrace_category_t, const char*, + omnitrace_annotation_t*, size_t) = nullptr; + int (*omnitrace_pop_category_region_f)(omnitrace_category_t, const char*, + omnitrace_annotation_t*, size_t) = nullptr; + void (*omnitrace_progress_f)(const char*) = nullptr; + void (*omnitrace_annotated_progress_f)(const char*, omnitrace_annotation_t*, + size_t) = nullptr; + + // librocprof-sys-user functions + int (*omnitrace_user_configure_f)(int, user_cb_t, user_cb_t*) = nullptr; + + // KokkosP functions + void (*kokkosp_print_help_f)(char*) = nullptr; + void (*kokkosp_parse_args_f)(int, char**) = nullptr; + void (*kokkosp_declare_metadata_f)(const char*, const char*) = nullptr; + void (*kokkosp_request_tool_settings_f)(const uint32_t, + Kokkos_Tools_ToolSettings*) = nullptr; + void (*kokkosp_init_library_f)(const int, const uint64_t, const uint32_t, + void*) = nullptr; + void (*kokkosp_finalize_library_f)() = nullptr; + void (*kokkosp_begin_parallel_for_f)(const char*, uint32_t, uint64_t*) = nullptr; + void (*kokkosp_end_parallel_for_f)(uint64_t) = nullptr; + void (*kokkosp_begin_parallel_reduce_f)(const char*, uint32_t, uint64_t*) = nullptr; + void (*kokkosp_end_parallel_reduce_f)(uint64_t) = nullptr; + void (*kokkosp_begin_parallel_scan_f)(const char*, uint32_t, uint64_t*) = nullptr; + void (*kokkosp_end_parallel_scan_f)(uint64_t) = nullptr; + void (*kokkosp_begin_fence_f)(const char*, uint32_t, uint64_t*) = nullptr; + void (*kokkosp_end_fence_f)(uint64_t) = nullptr; + void (*kokkosp_push_profile_region_f)(const char*) = nullptr; + void (*kokkosp_pop_profile_region_f)() = nullptr; + void (*kokkosp_create_profile_section_f)(const char*, uint32_t*) = nullptr; + void (*kokkosp_destroy_profile_section_f)(uint32_t) = nullptr; + void (*kokkosp_start_profile_section_f)(uint32_t) = nullptr; + void (*kokkosp_stop_profile_section_f)(uint32_t) = nullptr; + void (*kokkosp_allocate_data_f)(const SpaceHandle, const char*, const void* const, + const uint64_t) = nullptr; + void (*kokkosp_deallocate_data_f)(const SpaceHandle, const char*, const void* const, + const uint64_t) = nullptr; + void (*kokkosp_begin_deep_copy_f)(SpaceHandle, const char*, const void*, SpaceHandle, + const char*, const void*, uint64_t) = nullptr; + void (*kokkosp_end_deep_copy_f)() = nullptr; + void (*kokkosp_profile_event_f)(const char*) = nullptr; + void (*kokkosp_dual_view_sync_f)(const char*, const void* const, bool) = nullptr; + void (*kokkosp_dual_view_modify_f)(const char*, const void* const, bool) = nullptr; + + // HSA functions +#if OMNITRACE_USE_ROCTRACER > 0 + bool (*hsa_on_load_f)(HsaApiTable*, uint64_t, uint64_t, const char* const*) = nullptr; + void (*hsa_on_unload_f)() = nullptr; +#endif + + // ROCP functions +#if OMNITRACE_USE_ROCPROFILER > 0 + void (*rocp_on_load_tool_prop_f)(void* settings) = nullptr; + void (*rocp_on_unload_tool_f)() = nullptr; +#endif + + // OpenMP functions +#if defined(OMNITRACE_USE_OMPT) && OMNITRACE_USE_OMPT > 0 + ompt_start_tool_result_t* (*ompt_start_tool_f)(unsigned int, const char*); +#endif + + auto get_omni_library() const { return m_omnilib; } + auto get_user_library() const { return m_userlib; } + auto get_dl_library() const { return m_dllib; } + +private: + void* m_omnihandle = nullptr; + void* m_userhandle = nullptr; + std::string m_omnilib = {}; + std::string m_dllib = {}; + std::string m_userlib = {}; +}; + +inline indirect& +get_indirect() OMNITRACE_INTERNAL_API; + +indirect& +get_indirect() +{ + omnitrace_preinit_library(); + + static auto _libomni = get_env("OMNITRACE_LIBRARY", "librocprof-sys.so"); + static auto _libuser = get_env("OMNITRACE_USER_LIBRARY", "librocprof-sys-user.so"); + static auto _libdlib = get_env("OMNITRACE_DL_LIBRARY", "librocprof-sys-dl.so"); + static auto* _v = new indirect{ _libomni, _libuser, _libdlib }; + return *_v; +} + +auto& +get_inited() +{ + static bool* _v = new bool{ false }; + return *_v; +} + +auto& +get_finied() +{ + static bool* _v = new bool{ false }; + return *_v; +} + +auto& +get_active() +{ + static bool* _v = new bool{ false }; + return *_v; +} + +auto& +get_enabled() +{ + static auto* _v = new std::atomic{ get_env("OMNITRACE_INIT_ENABLED", true) }; + return *_v; +} + +auto& +get_thread_enabled() +{ + static thread_local bool _v = get_enabled(); + return _v; +} + +auto& +get_thread_count() +{ + static thread_local int64_t _v = 0; + return _v; +} + +auto& +get_thread_status() +{ + static thread_local bool _v = false; + return _v; +} + +InstrumentMode& +get_instrumented() +{ + static auto _v = get_env("OMNITRACE_INSTRUMENT_MODE", InstrumentMode::None); + return _v; +} + +// ensure finalization is called +bool _omnitrace_dl_fini = (std::atexit([]() { + if(get_active()) omnitrace_finalize(); + }), + true); +} // namespace +} // namespace dl +} // namespace omnitrace + +//--------------------------------------------------------------------------------------// + +#define OMNITRACE_DL_INVOKE(...) \ + ::omnitrace::common::invoke(__FUNCTION__, ::omnitrace::dl::_omnitrace_dl_verbose, \ + (::omnitrace::dl::get_thread_status() = false), \ + __VA_ARGS__) + +#define OMNITRACE_DL_IGNORE(...) \ + ::omnitrace::common::ignore(__FUNCTION__, ::omnitrace::dl::_omnitrace_dl_verbose, \ + __VA_ARGS__) + +#define OMNITRACE_DL_INVOKE_STATUS(STATUS, ...) \ + ::omnitrace::common::invoke(__FUNCTION__, ::omnitrace::dl::_omnitrace_dl_verbose, \ + STATUS, __VA_ARGS__) + +#define OMNITRACE_DL_LOG(LEVEL, ...) \ + if(::omnitrace::dl::_omnitrace_dl_verbose >= LEVEL) \ + { \ + fflush(stderr); \ + OMNITRACE_COMMON_LIBRARY_LOG_START \ + fprintf(stderr, "[omnitrace][" OMNITRACE_COMMON_LIBRARY_NAME "][%i] ", \ + getpid()); \ + fprintf(stderr, __VA_ARGS__); \ + OMNITRACE_COMMON_LIBRARY_LOG_END \ + fflush(stderr); \ + } + +using omnitrace::dl::get_indirect; +namespace dl = omnitrace::dl; + +extern "C" +{ + void omnitrace_preinit_library(void) + { + if(omnitrace::common::get_env("OMNITRACE_MONOCHROME", tim::log::monochrome())) + tim::log::monochrome() = true; + } + + int omnitrace_preload_library(void) + { + return (::omnitrace::dl::get_omnitrace_preload()) ? 1 : 0; + } + + void omnitrace_init_library(void) + { + OMNITRACE_DL_INVOKE(get_indirect().omnitrace_init_library_f); + } + + void omnitrace_init_tooling(void) + { + OMNITRACE_DL_INVOKE(get_indirect().omnitrace_init_tooling_f); + } + + void omnitrace_init(const char* a, bool b, const char* c) + { + if(dl::get_inited() && dl::get_finied()) + { + OMNITRACE_DL_LOG( + 2, "%s(%s) ignored :: already initialized and finalized\n", __FUNCTION__, + ::omnitrace::join(::omnitrace::QuoteStrings{}, ", ", a, b, c).c_str()); + return; + } + else if(dl::get_inited() && dl::get_active()) + { + OMNITRACE_DL_LOG( + 2, "%s(%s) ignored :: already initialized and active\n", __FUNCTION__, + ::omnitrace::join(::omnitrace::QuoteStrings{}, ", ", a, b, c).c_str()); + return; + } + + if(dl::get_instrumented() < dl::InstrumentMode::PythonProfile) + dl::omnitrace_preinit(); + + bool _invoked = false; + OMNITRACE_DL_INVOKE_STATUS(_invoked, get_indirect().omnitrace_init_f, a, b, c); + if(_invoked) + { + dl::get_active() = true; + dl::get_inited() = true; + dl::_omnitrace_dl_verbose = dl::get_omnitrace_dl_env(); + if(dl::get_instrumented() < dl::InstrumentMode::PythonProfile) + dl::omnitrace_postinit((c) ? std::string{ c } : std::string{}); + } + } + + void omnitrace_finalize(void) + { + if(dl::get_inited() && dl::get_finied()) + { + OMNITRACE_DL_LOG(2, "%s() ignored :: already initialized and finalized\n", + __FUNCTION__); + return; + } + else if(dl::get_finied() && !dl::get_active()) + { + OMNITRACE_DL_LOG(2, "%s() ignored :: already finalized but not active\n", + __FUNCTION__); + return; + } + + bool _invoked = false; + OMNITRACE_DL_INVOKE_STATUS(_invoked, get_indirect().omnitrace_finalize_f); + if(_invoked) + { + dl::get_active() = false; + dl::get_finied() = true; + } + } + + void omnitrace_push_trace(const char* name) + { + if(!dl::get_active()) return; + if(dl::get_thread_enabled()) + { + OMNITRACE_DL_INVOKE(get_indirect().omnitrace_push_trace_f, name); + } + else + { + ++dl::get_thread_count(); + } + } + + void omnitrace_pop_trace(const char* name) + { + if(!dl::get_active()) return; + if(dl::get_thread_enabled()) + { + OMNITRACE_DL_INVOKE(get_indirect().omnitrace_pop_trace_f, name); + } + else + { + if(dl::get_thread_count()-- == 0) omnitrace_user_start_thread_trace_dl(); + } + } + + int omnitrace_push_region(const char* name) + { + if(!dl::get_active()) return 0; + if(dl::get_thread_enabled()) + { + return OMNITRACE_DL_INVOKE(get_indirect().omnitrace_push_region_f, name); + } + else + { + ++dl::get_thread_count(); + } + return 0; + } + + int omnitrace_pop_region(const char* name) + { + if(!dl::get_active()) return 0; + if(dl::get_thread_enabled()) + { + return OMNITRACE_DL_INVOKE(get_indirect().omnitrace_pop_region_f, name); + } + else + { + if(dl::get_thread_count()-- == 0) omnitrace_user_start_thread_trace_dl(); + } + return 0; + } + + int omnitrace_push_category_region(omnitrace_category_t _category, const char* name, + omnitrace_annotation_t* _annotations, + size_t _annotation_count) + { + if(!dl::get_active()) return 0; + if(dl::get_thread_enabled()) + { + return OMNITRACE_DL_INVOKE(get_indirect().omnitrace_push_category_region_f, + _category, name, _annotations, _annotation_count); + } + else + { + ++dl::get_thread_count(); + } + return 0; + } + + int omnitrace_pop_category_region(omnitrace_category_t _category, const char* name, + omnitrace_annotation_t* _annotations, + size_t _annotation_count) + { + if(!dl::get_active()) return 0; + if(dl::get_thread_enabled()) + { + return OMNITRACE_DL_INVOKE(get_indirect().omnitrace_pop_category_region_f, + _category, name, _annotations, _annotation_count); + } + else + { + ++dl::get_thread_count(); + } + return 0; + } + + void omnitrace_set_env(const char* a, const char* b) + { + if(dl::get_inited() && dl::get_active()) + { + OMNITRACE_DL_IGNORE(2, "already initialized and active", a, b); + return; + } + OMNITRACE_DL_LOG(2, "%s(%s, %s)\n", __FUNCTION__, a, b); + setenv(a, b, 0); + // OMNITRACE_DL_INVOKE(get_indirect().omnitrace_set_env_f, a, b); + } + + void omnitrace_set_mpi(bool a, bool b) + { + if(dl::get_inited() && dl::get_active()) + { + OMNITRACE_DL_IGNORE(2, "already initialized and active", a, b); + return; + } + OMNITRACE_DL_INVOKE(get_indirect().omnitrace_set_mpi_f, a, b); + } + + void omnitrace_register_source(const char* file, const char* func, size_t line, + size_t address, const char* source) + { + OMNITRACE_DL_LOG(3, "%s(\"%s\", \"%s\", %zu, %zu, \"%s\")\n", __FUNCTION__, file, + func, line, address, source); + OMNITRACE_DL_INVOKE(get_indirect().omnitrace_register_source_f, file, func, line, + address, source); + } + + void omnitrace_register_coverage(const char* file, const char* func, size_t address) + { + OMNITRACE_DL_INVOKE(get_indirect().omnitrace_register_coverage_f, file, func, + address); + } + + int omnitrace_user_start_trace_dl(void) + { + dl::get_enabled().store(true); + return omnitrace_user_start_thread_trace_dl(); + } + + int omnitrace_user_stop_trace_dl(void) + { + dl::get_enabled().store(false); + return omnitrace_user_stop_thread_trace_dl(); + } + + int omnitrace_user_start_thread_trace_dl(void) + { + dl::get_thread_enabled() = true; + return 0; + } + + int omnitrace_user_stop_thread_trace_dl(void) + { + dl::get_thread_enabled() = false; + return 0; + } + + int omnitrace_user_push_region_dl(const char* name) + { + if(!dl::get_active()) return 0; + return OMNITRACE_DL_INVOKE(get_indirect().omnitrace_push_region_f, name); + } + + int omnitrace_user_pop_region_dl(const char* name) + { + if(!dl::get_active()) return 0; + return OMNITRACE_DL_INVOKE(get_indirect().omnitrace_pop_region_f, name); + } + + int omnitrace_user_progress_dl(const char* name) + { + OMNITRACE_DL_INVOKE(get_indirect().omnitrace_progress_f, name); + return 0; + } + + int omnitrace_user_push_annotated_region_dl(const char* name, + omnitrace_annotation_t* _annotations, + size_t _annotation_count) + { + if(!dl::get_active()) return 0; + return OMNITRACE_DL_INVOKE(get_indirect().omnitrace_push_category_region_f, + OMNITRACE_CATEGORY_USER, name, _annotations, + _annotation_count); + } + + int omnitrace_user_pop_annotated_region_dl(const char* name, + omnitrace_annotation_t* _annotations, + size_t _annotation_count) + { + if(!dl::get_active()) return 0; + return OMNITRACE_DL_INVOKE(get_indirect().omnitrace_pop_category_region_f, + OMNITRACE_CATEGORY_USER, name, _annotations, + _annotation_count); + } + + int omnitrace_user_annotated_progress_dl(const char* name, + omnitrace_annotation_t* _annotations, + size_t _annotation_count) + { + OMNITRACE_DL_INVOKE(get_indirect().omnitrace_annotated_progress_f, name, + _annotations, _annotation_count); + return 0; + } + + void omnitrace_progress(const char* _name) + { + return OMNITRACE_DL_INVOKE(get_indirect().omnitrace_progress_f, _name); + } + + void omnitrace_annotated_progress(const char* _name, + omnitrace_annotation_t* _annotations, + size_t _annotation_count) + { + return OMNITRACE_DL_INVOKE(get_indirect().omnitrace_annotated_progress_f, _name, + _annotations, _annotation_count); + } + + void omnitrace_set_instrumented(int _mode) + { + OMNITRACE_DL_LOG(2, "%s(%i)\n", __FUNCTION__, _mode); + auto _mode_v = static_cast(_mode); + if(_mode_v < dl::InstrumentMode::None || _mode_v >= dl::InstrumentMode::Last) + { + OMNITRACE_DL_LOG(-127, + "%s(mode=%i) invoked with invalid instrumentation mode. " + "mode should be %i >= mode < %i\n", + __FUNCTION__, _mode, + static_cast(dl::InstrumentMode::None), + static_cast(dl::InstrumentMode::Last)); + } + dl::get_instrumented() = _mode_v; + } + + //----------------------------------------------------------------------------------// + // + // KokkosP + // + //----------------------------------------------------------------------------------// + + void kokkosp_print_help(char* argv0) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_print_help_f, argv0); + } + + void kokkosp_parse_args(int argc, char** argv) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_parse_args_f, argc, argv); + } + + void kokkosp_declare_metadata(const char* key, const char* value) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_declare_metadata_f, key, value); + } + + void kokkosp_request_tool_settings(const uint32_t version, + Kokkos_Tools_ToolSettings* settings) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_request_tool_settings_f, + version, settings); + } + + void kokkosp_init_library(const int loadSeq, const uint64_t interfaceVer, + const uint32_t devInfoCount, void* deviceInfo) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_init_library_f, loadSeq, + interfaceVer, devInfoCount, deviceInfo); + } + + void kokkosp_finalize_library() + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_finalize_library_f); + } + + void kokkosp_begin_parallel_for(const char* name, uint32_t devid, uint64_t* kernid) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_begin_parallel_for_f, name, + devid, kernid); + } + + void kokkosp_end_parallel_for(uint64_t kernid) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_end_parallel_for_f, kernid); + } + + void kokkosp_begin_parallel_reduce(const char* name, uint32_t devid, uint64_t* kernid) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_begin_parallel_reduce_f, name, + devid, kernid); + } + + void kokkosp_end_parallel_reduce(uint64_t kernid) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_end_parallel_reduce_f, kernid); + } + + void kokkosp_begin_parallel_scan(const char* name, uint32_t devid, uint64_t* kernid) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_begin_parallel_scan_f, name, + devid, kernid); + } + + void kokkosp_end_parallel_scan(uint64_t kernid) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_end_parallel_scan_f, kernid); + } + + void kokkosp_begin_fence(const char* name, uint32_t devid, uint64_t* kernid) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_begin_fence_f, name, devid, + kernid); + } + + void kokkosp_end_fence(uint64_t kernid) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_end_fence_f, kernid); + } + + void kokkosp_push_profile_region(const char* name) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_push_profile_region_f, name); + } + + void kokkosp_pop_profile_region() + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_pop_profile_region_f); + } + + void kokkosp_create_profile_section(const char* name, uint32_t* secid) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_create_profile_section_f, name, + secid); + } + + void kokkosp_destroy_profile_section(uint32_t secid) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_destroy_profile_section_f, + secid); + } + + void kokkosp_start_profile_section(uint32_t secid) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_start_profile_section_f, secid); + } + + void kokkosp_stop_profile_section(uint32_t secid) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_stop_profile_section_f, secid); + } + + void kokkosp_allocate_data(const SpaceHandle space, const char* label, + const void* const ptr, const uint64_t size) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_allocate_data_f, space, label, + ptr, size); + } + + void kokkosp_deallocate_data(const SpaceHandle space, const char* label, + const void* const ptr, const uint64_t size) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_deallocate_data_f, space, label, + ptr, size); + } + + void kokkosp_begin_deep_copy(SpaceHandle dst_handle, const char* dst_name, + const void* dst_ptr, SpaceHandle src_handle, + const char* src_name, const void* src_ptr, uint64_t size) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_begin_deep_copy_f, dst_handle, + dst_name, dst_ptr, src_handle, src_name, src_ptr, + size); + } + + void kokkosp_end_deep_copy() + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_end_deep_copy_f); + } + + void kokkosp_profile_event(const char* name) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_profile_event_f, name); + } + + void kokkosp_dual_view_sync(const char* label, const void* const data, bool is_device) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_dual_view_sync_f, label, data, + is_device); + } + + void kokkosp_dual_view_modify(const char* label, const void* const data, + bool is_device) + { + return OMNITRACE_DL_INVOKE(get_indirect().kokkosp_dual_view_modify_f, label, data, + is_device); + } + + //----------------------------------------------------------------------------------// + // + // HSA + // + //----------------------------------------------------------------------------------// + +#if OMNITRACE_USE_ROCTRACER > 0 + bool OnLoad(HsaApiTable* table, uint64_t runtime_version, uint64_t failed_tool_count, + const char* const* failed_tool_names) + { + return OMNITRACE_DL_INVOKE(get_indirect().hsa_on_load_f, table, runtime_version, + failed_tool_count, failed_tool_names); + } + + void OnUnload() { return OMNITRACE_DL_INVOKE(get_indirect().hsa_on_unload_f); } +#endif + + //----------------------------------------------------------------------------------// + // + // ROCP + // + //----------------------------------------------------------------------------------// + +#if OMNITRACE_USE_ROCPROFILER > 0 + void OnLoadToolProp(void* settings) + { + OMNITRACE_DL_LOG(-16, + "invoking %s(rocprofiler_settings_t*) within librocprof-sys-dl.so " + "will cause a silent failure for rocprofiler. ROCP_TOOL_LIB " + "should be set to librocprof-sys.so\n", + __FUNCTION__); + abort(); + return OMNITRACE_DL_INVOKE(get_indirect().rocp_on_load_tool_prop_f, settings); + } + + void OnUnloadTool() + { + return OMNITRACE_DL_INVOKE(get_indirect().rocp_on_unload_tool_f); + } +#endif + + //----------------------------------------------------------------------------------// + // + // OMPT + // + //----------------------------------------------------------------------------------// +#if OMNITRACE_USE_OMPT > 0 + ompt_start_tool_result_t* ompt_start_tool(unsigned int omp_version, + const char* runtime_version) + { + return OMNITRACE_DL_INVOKE(get_indirect().ompt_start_tool_f, omp_version, + runtime_version); + } +#endif +} + +namespace omnitrace +{ +namespace dl +{ +namespace +{ +bool +omnitrace_preload() OMNITRACE_INTERNAL_API; + +std::vector +get_link_map(const char*, + std::vector&& = { (RTLD_LAZY | RTLD_NOLOAD) }) OMNITRACE_INTERNAL_API; + +const char* +get_default_mode() OMNITRACE_INTERNAL_API; + +void +verify_instrumented_preloaded() OMNITRACE_INTERNAL_API; + +std::vector +get_link_map(const char* _name, std::vector&& _open_modes) +{ + void* _handle = nullptr; + bool _noload = false; + for(auto _mode : _open_modes) + { + _handle = dlopen(_name, _mode); + _noload = (_mode & RTLD_NOLOAD) == RTLD_NOLOAD; + if(_handle) break; + } + + auto _chain = std::vector{}; + if(_handle) + { + struct link_map* _link_map = nullptr; + dlinfo(_handle, RTLD_DI_LINKMAP, &_link_map); + struct link_map* _next = _link_map->l_next; + while(_next) + { + if(_next->l_name != nullptr && !std::string_view{ _next->l_name }.empty()) + { + _chain.emplace_back(_next->l_name); + } + _next = _next->l_next; + } + + if(_noload == false) dlclose(_handle); + } + return _chain; +} + +const char* +get_default_mode() +{ + if(get_env("OMNITRACE_USE_CAUSAL", false)) return "causal"; + + auto _link_map = get_link_map(nullptr); + for(const auto& itr : _link_map) + { + if(itr.find("librocprof-sys-rt.so") != std::string::npos || + itr.find("libdyninstAPI_RT.so") != std::string::npos) + return "trace"; + } + + return "sampling"; +} + +void +omnitrace_preinit() +{ + switch(get_instrumented()) + { + case InstrumentMode::None: + case InstrumentMode::BinaryRewrite: + case InstrumentMode::ProcessCreate: + case InstrumentMode::ProcessAttach: + { + auto _use_mpip = get_env("OMNITRACE_USE_MPIP", false); + auto _use_mpi = get_env("OMNITRACE_USE_MPI", _use_mpip); + auto _causal = get_env("OMNITRACE_USE_CAUSAL", false); + auto _mode = get_env("OMNITRACE_MODE", get_default_mode()); + + if(_use_mpi && !(_causal && _mode == "causal")) + { + // only make this call if true bc otherwise, if + // false, it will disable the MPIP component and + // we may intercept the MPI init call later. + // If _use_mpi defaults to true above, calling this + // will override can current env or config value for + // OMNITRACE_USE_PID. + omnitrace_set_mpi(_use_mpi, dl::get_instrumented() == + dl::InstrumentMode::ProcessAttach); + } + break; + } + case InstrumentMode::PythonProfile: + case InstrumentMode::Last: break; + } +} + +void +omnitrace_postinit(std::string _exe) +{ + switch(get_instrumented()) + { + case InstrumentMode::None: + case InstrumentMode::BinaryRewrite: + case InstrumentMode::ProcessCreate: + case InstrumentMode::ProcessAttach: + { + if(_exe.empty()) + _exe = tim::filepath::readlink(join('/', "/proc", getpid(), "exe")); + + omnitrace_init_tooling(); + if(_exe.empty()) + omnitrace_push_trace("main"); + else + omnitrace_push_trace(basename(_exe.c_str())); + break; + } + case InstrumentMode::PythonProfile: + { + omnitrace_init_tooling(); + break; + } + case InstrumentMode::Last: break; + } +} + +bool +omnitrace_preload() +{ + auto _preload = get_omnitrace_is_preloaded() && get_omnitrace_preload() && + get_env("OMNITRACE_ENABLED", true); + + auto _link_map = get_link_map(nullptr); + auto _instr_mode = + get_env("OMNITRACE_INSTRUMENT_MODE", dl::InstrumentMode::BinaryRewrite); + for(const auto& itr : _link_map) + { + if(itr.find("librocprof-sys-rt.so") != std::string::npos || + itr.find("libdyninstAPI_RT.so") != std::string::npos) + { + omnitrace_set_instrumented(static_cast(_instr_mode)); + break; + } + } + + verify_instrumented_preloaded(); + + static bool _once = false; + if(_once) return _preload; + _once = true; + + if(_preload) + { + reset_omnitrace_preload(); + omnitrace_preinit_library(); + } + + return _preload; +} + +void +verify_instrumented_preloaded() +{ + // if preloaded then we are fine + if(get_omnitrace_is_preloaded()) return; + + // value returned by get_instrumented is set by either: + // - the search of the linked libraries + // - via the instrumenter + // if binary rewrite or runtime instrumentation, there is an opportunity for + // LD_PRELOAD + switch(dl::get_instrumented()) + { + case dl::InstrumentMode::None: + case dl::InstrumentMode::ProcessAttach: + case dl::InstrumentMode::ProcessCreate: + case dl::InstrumentMode::PythonProfile: + { + return; + } + case dl::InstrumentMode::BinaryRewrite: + { + break; + } + case dl::InstrumentMode::Last: + { + throw std::runtime_error( + "Invalid instrumentation type: InstrumentMode::Last"); + } + } + + static const char* _notice = R"notice( + + NNNNNNNN NNNNNNNN OOOOOOOOO TTTTTTTTTTTTTTTTTTTTTTTIIIIIIIIII CCCCCCCCCCCCCEEEEEEEEEEEEEEEEEEEEEE + N:::::::N N::::::N OO:::::::::OO T:::::::::::::::::::::TI::::::::I CCC::::::::::::CE::::::::::::::::::::E + N::::::::N N::::::N OO:::::::::::::OO T:::::::::::::::::::::TI::::::::I CC:::::::::::::::CE::::::::::::::::::::E + N:::::::::N N::::::NO:::::::OOO:::::::OT:::::TT:::::::TT:::::TII::::::IIC:::::CCCCCCCC::::CEE::::::EEEEEEEEE::::E + N::::::::::N N::::::NO::::::O O::::::OTTTTTT T:::::T TTTTTT I::::I C:::::C CCCCCC E:::::E EEEEEE + N:::::::::::N N::::::NO:::::O O:::::O T:::::T I::::IC:::::C E:::::E + N:::::::N::::N N::::::NO:::::O O:::::O T:::::T I::::IC:::::C E::::::EEEEEEEEEE + N::::::N N::::N N::::::NO:::::O O:::::O T:::::T I::::IC:::::C E:::::::::::::::E + N::::::N N::::N:::::::NO:::::O O:::::O T:::::T I::::IC:::::C E:::::::::::::::E + N::::::N N:::::::::::NO:::::O O:::::O T:::::T I::::IC:::::C E::::::EEEEEEEEEE + N::::::N N::::::::::NO:::::O O:::::O T:::::T I::::IC:::::C E:::::E + N::::::N N:::::::::NO::::::O O::::::O T:::::T I::::I C:::::C CCCCCC E:::::E EEEEEE + N::::::N N::::::::NO:::::::OOO:::::::O TT:::::::TT II::::::IIC:::::CCCCCCCC::::CEE::::::EEEEEEEE:::::E + N::::::N N:::::::N OO:::::::::::::OO T:::::::::T I::::::::I CC:::::::::::::::CE::::::::::::::::::::E + N::::::N N::::::N OO:::::::::OO T:::::::::T I::::::::I CCC::::::::::::CE::::::::::::::::::::E + NNNNNNNN NNNNNNN OOOOOOOOO TTTTTTTTTTT IIIIIIIIII CCCCCCCCCCCCCEEEEEEEEEEEEEEEEEEEEEE + + _ _ _____ ______ + | | | |/ ____| ____| + | | | | (___ | |__ + | | | |\___ \| __| + | |__| |____) | |____ + \____/|_____/|______| + + ____ __ __ _ _ _____ _______ _____ _____ ______ _____ _ _ _ _ + / __ \| \/ | \ | |_ _|__ __| __ \ /\ / ____| ____| | __ \| | | | \ | | + | | | | \ / | \| | | | | | | |__) | / \ | | | |__ ______| |__) | | | | \| | + | | | | |\/| | . ` | | | | | | _ / / /\ \| | | __|______| _ /| | | | . ` | + | |__| | | | | |\ |_| |_ | | | | \ \ / ____ \ |____| |____ | | \ \| |__| | |\ | + \____/|_| |_|_| \_|_____| |_| |_| \_\/_/ \_\_____|______| |_| \_\\____/|_| \_| + + + Due to a variety of edge cases we've encountered, OmniTrace now requires that binary rewritten executables and libraries be launched + with the 'omnitrace-run' executable. + + In order to launch the executable with 'omnitrace-run', prefix the current command with 'omnitrace-run' and a standalone double hyphen ('--'). + For MPI applications, place 'omnitrace-run --' after the MPI command. + E.g.: + + + mpirun -n 2 + + should be: + + omnitrace-run -- + mpirun -n 2 omnitrace-run -- + + Note: the command-line arguments passed to 'omnitrace-run' (which are specified before the double hyphen) will override configuration variables + and/or any configuration values specified to 'omnitrace-instrument' via the '--config' or '--env' options. + E.g.: + + $ omnitrace-instrument -o ./sleep.inst --env OMNITRACE_SAMPLING_DELAY=5.0 -- sleep + $ echo "OMNITRACE_SAMPLING_FREQ = 500" > omnitrace.cfg + $ export OMNITRACE_CONFIG_FILE=omnitrace.cfg + $ omnitrace-run --sampling-freq=100 --sampling-delay=1.0 -- ./sleep.inst 10 + + In the first command, a default sampling delay of 5 seconds in embedded into the instrumented 'sleep.inst'. + In the second command, the sampling frequency will be set to 500 interrupts per second when OmniTrace reads the config file + In the fourth command, the sampling frequency and sampling delay are overridden to 100 interrupts per second and 1 second, respectively, when sleep.inst runs + + Thanks for using OmniTrace and happy optimizing! + )notice"; + + // emit notice + std::cerr << _notice << std::endl; + + std::quick_exit(EXIT_FAILURE); +} + +bool _handle_preload = omnitrace_preload(); +main_func_t main_real = nullptr; +} // namespace +} // namespace dl +} // namespace omnitrace + +extern "C" +{ + int omnitrace_main(int argc, char** argv, char** envp) OMNITRACE_INTERNAL_API; + void omnitrace_set_main(main_func_t) OMNITRACE_INTERNAL_API; + + void omnitrace_set_main(main_func_t _main_real) + { + ::omnitrace::dl::main_real = _main_real; + } + + int omnitrace_main(int argc, char** argv, char** envp) + { + OMNITRACE_DL_LOG(0, "%s\n", __FUNCTION__); + using ::omnitrace::common::get_env; + using ::omnitrace::dl::get_default_mode; + + // prevent re-entry + static int _reentry = 0; + if(_reentry > 0) return -1; + _reentry = 1; + + if(!::omnitrace::dl::main_real) + throw std::runtime_error("[omnitrace][dl] Unsuccessful wrapping of main: " + "nullptr to real main function"); + + if(envp) + { + size_t _idx = 0; + while(envp[_idx] != nullptr) + { + auto _env_v = std::string_view{ envp[_idx++] }; + if(_env_v.find("OMNITRACE") != 0 && + _env_v.find("librocprof-sys") == std::string_view::npos) + continue; + auto _pos = _env_v.find('='); + if(_pos < _env_v.length()) + { + auto _var = std::string{ _env_v }.substr(0, _pos); + auto _val = std::string{ _env_v }.substr(_pos + 1); + OMNITRACE_DL_LOG(1, "%s(%s, %s)\n", "omnitrace_set_env", _var.c_str(), + _val.c_str()); + setenv(_var.c_str(), _val.c_str(), 0); + } + } + } + + auto _mode = get_env("OMNITRACE_MODE", get_default_mode()); + omnitrace_init(_mode.c_str(), + dl::get_instrumented() == dl::InstrumentMode::BinaryRewrite, + argv[0]); + + int ret = (*::omnitrace::dl::main_real)(argc, argv, envp); + + omnitrace_pop_trace(basename(argv[0])); + omnitrace_finalize(); + + return ret; + } +} diff --git a/source/lib/omnitrace-user/omnitrace/types.h b/source/lib/omnitrace-user/omnitrace/types.h index 1a8498fe9..839e1caf9 100644 --- a/source/lib/omnitrace-user/omnitrace/types.h +++ b/source/lib/omnitrace-user/omnitrace/types.h @@ -99,7 +99,7 @@ extern "C" OMNITRACE_USER_ERROR_NO_BINDING, ///< Function pointer was not assigned OMNITRACE_USER_ERROR_BAD_VALUE, ///< Provided value was invalid OMNITRACE_USER_ERROR_INVALID_CATEGORY, ///< Invalid user binding category - OMNITRACE_USER_ERROR_INTERNAL, ///< Internal error occurred within libomnitrace + OMNITRACE_USER_ERROR_INTERNAL, ///< Internal error occurred within librocprof-sys OMNITRACE_USER_ERROR_LAST } omnitrace_user_error_t; diff --git a/source/lib/omnitrace/CMakeLists.txt b/source/lib/omnitrace/CMakeLists.txt index 4928a85e7..5faeef670 100644 --- a/source/lib/omnitrace/CMakeLists.txt +++ b/source/lib/omnitrace/CMakeLists.txt @@ -32,7 +32,7 @@ target_link_libraries( PRIVATE omnitrace::omnitrace-interface-library omnitrace::omnitrace-core omnitrace::omnitrace-binary) -set_target_properties(omnitrace-static-library PROPERTIES OUTPUT_NAME omnitrace) +set_target_properties(omnitrace-static-library PROPERTIES OUTPUT_NAME rocprof-sys) # ------------------------------------------------------------------------------# # @@ -51,7 +51,7 @@ target_link_libraries( set_target_properties( omnitrace-shared-library - PROPERTIES OUTPUT_NAME omnitrace + PROPERTIES OUTPUT_NAME rocprof-sys VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} INSTALL_RPATH "${OMNITRACE_LIB_INSTALL_RPATH}") diff --git a/source/lib/omnitrace/api.hpp b/source/lib/omnitrace/api.hpp index 4cb8debf5..e5a2d70bd 100644 --- a/source/lib/omnitrace/api.hpp +++ b/source/lib/omnitrace/api.hpp @@ -44,7 +44,7 @@ extern "C" /// shuts down all tooling and generates output void omnitrace_finalize(void) OMNITRACE_PUBLIC_API; - /// remove libomnitrace from LD_PRELOAD + /// remove librocprof-sys from LD_PRELOAD void omnitrace_reset_preload(void) OMNITRACE_PUBLIC_API; /// sets an environment variable diff --git a/source/lib/omnitrace/library.cpp b/source/lib/omnitrace/library.cpp index 1086989c0..e4f410412 100644 --- a/source/lib/omnitrace/library.cpp +++ b/source/lib/omnitrace/library.cpp @@ -647,12 +647,12 @@ omnitrace_reset_preload_hidden(void) { tim::set_env("OMNITRACE_PRELOAD", "0", 1); auto&& _preload_libs = common::get_env("LD_PRELOAD", std::string{}); - if(_preload_libs.find("libomnitrace") != std::string::npos) + if(_preload_libs.find("librocprof-sys") != std::string::npos) { auto _modified_preload = std::string{}; for(const auto& itr : delimit(_preload_libs, ":")) { - if(itr.find("libomnitrace") != std::string::npos) continue; + if(itr.find("librocprof-sys") != std::string::npos) continue; _modified_preload += common::join("", ":", itr); } if(!_modified_preload.empty() && _modified_preload.find(':') == 0) diff --git a/source/lib/omnitrace/library/causal/data.cpp b/source/lib/omnitrace/library/causal/data.cpp index b614add65..53c40b9c1 100644 --- a/source/lib/omnitrace/library/causal/data.cpp +++ b/source/lib/omnitrace/library/causal/data.cpp @@ -260,7 +260,7 @@ std::pair& get_cached_binary_info() { static auto _v = []() { - // get the linked binaries for the exe (excluding ones from libomnitrace) + // get the linked binaries for the exe (excluding ones from librocprof-sys) auto _link_map = binary::get_link_map(); auto _files = std::vector{}; _files.reserve(_link_map.size()); diff --git a/source/lib/omnitrace/library/kokkosp.cpp b/source/lib/omnitrace/library/kokkosp.cpp index 4464ef5f7..6b084460d 100644 --- a/source/lib/omnitrace/library/kokkosp.cpp +++ b/source/lib/omnitrace/library/kokkosp.cpp @@ -216,7 +216,7 @@ extern "C" { auto _kokkos_profile_lib = tim::get_env("KOKKOS_PROFILE_LIBRARY"); - if(_kokkos_profile_lib.find("libomnitrace.so") != std::string::npos) + if(_kokkos_profile_lib.find("librocprof-sys.so") != std::string::npos) { auto _maps = tim::procfs::read_maps(tim::process::get_id()); auto _libs = std::set{}; @@ -235,7 +235,7 @@ extern "C" for(const auto& litr : _libs) _libs_str << " " << litr << "\n"; OMNITRACE_ABORT( - "%s was invoked with libomnitrace.so as the " + "%s was invoked with librocprof-sys.so as the " "KOKKOS_PROFILE_LIBRARY.\n" "However, librocprof-sys-dl.so has already been loaded by " "the process.\nTo avoid duplicate collections culminating " diff --git a/source/python/libpyomnitrace.cpp b/source/python/libpyomnitrace.cpp index b2087c3a8..66832e405 100644 --- a/source/python/libpyomnitrace.cpp +++ b/source/python/libpyomnitrace.cpp @@ -162,7 +162,7 @@ PYBIND11_MODULE(libpyomnitrace, omni) // permit env override if default path fails/is wrong _libpath = tim::get_env("OMNITRACE_DL_LIBRARY", _libpath); // this is necessary when building with -static-libstdc++ - // without it, loading libomnitrace.so within librocprof-sys-dl.so segfaults + // without it, loading librocprof-sys.so within librocprof-sys-dl.so segfaults if(!dlopen(_libpath.c_str(), RTLD_NOW | RTLD_GLOBAL)) { auto _msg = diff --git a/tests/omnitrace-kokkos-tests.cmake b/tests/omnitrace-kokkos-tests.cmake index 962c82542..c610af60f 100644 --- a/tests/omnitrace-kokkos-tests.cmake +++ b/tests/omnitrace-kokkos-tests.cmake @@ -32,7 +32,7 @@ omnitrace_add_test( omnitrace_add_test( SKIP_RUNTIME SKIP_REWRITE - NAME lulesh-baseline-kokkosp-libomnitrace + NAME lulesh-baseline-kokkosp-librocprof-sys TARGET lulesh MPI ${LULESH_USE_MPI} GPU ${LULESH_USE_GPU} @@ -40,7 +40,7 @@ omnitrace_add_test( LABELS "kokkos;kokkos-profile-library" RUN_ARGS -i 10 -s 20 -p ENVIRONMENT - "${_base_environment};OMNITRACE_USE_KOKKOSP=ON;OMNITRACE_COUT_OUTPUT=ON;OMNITRACE_SAMPLING_FREQ=50;OMNITRACE_KOKKOSP_PREFIX=[kokkos];KOKKOS_PROFILE_LIBRARY=libomnitrace.so" + "${_base_environment};OMNITRACE_USE_KOKKOSP=ON;OMNITRACE_COUT_OUTPUT=ON;OMNITRACE_SAMPLING_FREQ=50;OMNITRACE_KOKKOSP_PREFIX=[kokkos];KOKKOS_PROFILE_LIBRARY=librocprof-sys.so" BASELINE_PASS_REGEX "\\|_\\[kokkos\\] [a-zA-Z]") omnitrace_add_test( From 7feae637a0c8e40c5bddb49da3e059245a631efc Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Fri, 13 Sep 2024 11:07:15 -0400 Subject: [PATCH 10/39] Format source Signed-off-by: David Galiffi --- source/lib/core/config.cpp | 5 +++-- source/lib/omnitrace-dl/dl.cpp | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/source/lib/core/config.cpp b/source/lib/core/config.cpp index 44cfc7d88..8d1ad6196 100644 --- a/source/lib/core/config.cpp +++ b/source/lib/core/config.cpp @@ -121,7 +121,7 @@ using utility::parse_numeric_range; [&]() { \ auto _ret = _config->insert( \ ENV_NAME, get_setting_name(ENV_NAME), DESCRIPTION, TYPE{ INITIAL_VALUE }, \ - std::set{ "custom", "omnitrace", "librocprof-sys", \ + std::set{ "custom", "omnitrace", "librocprof-sys", \ __VA_ARGS__ }); \ if(!_ret.second) \ { \ @@ -151,7 +151,8 @@ using utility::parse_numeric_range; [&]() { \ auto _ret = _config->insert( \ ENV_NAME, get_setting_name(ENV_NAME), DESCRIPTION, TYPE{ INITIAL_VALUE }, \ - std::set{ "custom", "omnitrace", "librocprof-sys", __VA_ARGS__ }, \ + std::set{ "custom", "omnitrace", "librocprof-sys", \ + __VA_ARGS__ }, \ std::vector{ CMD_LINE }); \ if(!_ret.second) \ { \ diff --git a/source/lib/omnitrace-dl/dl.cpp b/source/lib/omnitrace-dl/dl.cpp index 8844343a3..c285120d3 100644 --- a/source/lib/omnitrace-dl/dl.cpp +++ b/source/lib/omnitrace-dl/dl.cpp @@ -1086,11 +1086,12 @@ extern "C" #if OMNITRACE_USE_ROCPROFILER > 0 void OnLoadToolProp(void* settings) { - OMNITRACE_DL_LOG(-16, - "invoking %s(rocprofiler_settings_t*) within librocprof-sys-dl.so " - "will cause a silent failure for rocprofiler. ROCP_TOOL_LIB " - "should be set to librocprof-sys.so\n", - __FUNCTION__); + OMNITRACE_DL_LOG( + -16, + "invoking %s(rocprofiler_settings_t*) within librocprof-sys-dl.so " + "will cause a silent failure for rocprofiler. ROCP_TOOL_LIB " + "should be set to librocprof-sys.so\n", + __FUNCTION__); abort(); return OMNITRACE_DL_INVOKE(get_indirect().rocp_on_load_tool_prop_f, settings); } From 2040dd767238f5ffc1b1472972ecfd21881147fc Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Fri, 13 Sep 2024 17:21:47 -0400 Subject: [PATCH 11/39] Rename the omnitrace-avail binary --- .github/workflows/opensuse.yml | 8 +-- .github/workflows/ubuntu-focal.yml | 4 +- scripts/test-install.sh | 16 ++--- scripts/test-release.sh | 4 +- source/bin/omnitrace-avail/CMakeLists.txt | 3 +- source/bin/omnitrace-avail/avail.cpp | 6 +- source/bin/omnitrace-avail/common.cpp | 2 +- .../bin/omnitrace-avail/generate_config.cpp | 12 ++-- source/bin/omnitrace-sample/impl.cpp | 6 +- source/bin/tests/CMakeLists.txt | 72 +++++++++---------- source/lib/core/argparse.cpp | 10 +-- source/lib/core/config.cpp | 2 +- source/lib/core/config.hpp | 2 +- 13 files changed, 74 insertions(+), 73 deletions(-) diff --git a/.github/workflows/opensuse.yml b/.github/workflows/opensuse.yml index 34022181c..f23cc4714 100644 --- a/.github/workflows/opensuse.yml +++ b/.github/workflows/opensuse.yml @@ -111,10 +111,10 @@ jobs: run: | set -v export OMNITRACE_DEBUG=ON - which omnitrace-avail - ldd $(which omnitrace-avail) - omnitrace-avail --help - omnitrace-avail -a + which rocprof-sys-avail + ldd $(which rocprof-sys-avail) + rocprof-sys-avail --help + rocprof-sys-avail -a which omnitrace ldd $(which omnitrace) omnitrace-instrument --help diff --git a/.github/workflows/ubuntu-focal.yml b/.github/workflows/ubuntu-focal.yml index 5a4d53379..d231d5e1e 100644 --- a/.github/workflows/ubuntu-focal.yml +++ b/.github/workflows/ubuntu-focal.yml @@ -171,7 +171,7 @@ jobs: echo $(which omnitrace) ldd $(which omnitrace) omnitrace-instrument --help - omnitrace-avail --help + rocprof-sys-avail --help omnitrace-sample --help - name: Test Build-Tree Source Script @@ -183,7 +183,7 @@ jobs: echo $(which omnitrace) ldd $(which omnitrace) omnitrace-instrument --help - omnitrace-avail --help + rocprof-sys-avail --help omnitrace-sample --help - name: Install diff --git a/scripts/test-install.sh b/scripts/test-install.sh index 943603c08..5ecb3770c 100755 --- a/scripts/test-install.sh +++ b/scripts/test-install.sh @@ -49,7 +49,7 @@ usage() echo "Options:" print_option source-dir "" "Location of source directory" "${SOURCE_DIR}" print_option test-omnitrace-instrument "0|1" "Enable testing omnitrace-instrument exe" "${ENABLE_OMNITRACE_INSTRUMENT}" - print_option test-omnitrace-avail "0|1" "Enable testing omnitrace-avail" "${ENABLE_OMNITRACE_AVAIL}" + print_option test-rocprof-sys-avail "0|1" "Enable testing rocprof-sys-avail" "${ENABLE_OMNITRACE_AVAIL}" print_option test-omnitrace-sample "0|1" "Enable testing omnitrace-sample" "${ENABLE_OMNITRACE_SAMPLE}" print_option test-omnitrace-python "0|1" "Enable testing omnitrace-python" "${ENABLE_OMNITRACE_PYTHON}" print_option test-omnitrace-rewrite "0|1" "Enable testing omnitrace-instrument binary rewrite" "${ENABLE_OMNITRACE_REWRITE}" @@ -104,7 +104,7 @@ do ENABLE_OMNITRACE_INSTRUMENT=${VAL} continue ;; - --test-omnitrace-avail) + --test-rocprof-sys-avail) ENABLE_OMNITRACE_AVAIL=${VAL} continue ;; @@ -143,12 +143,12 @@ test-omnitrace() verbose-run omnitrace-instrument --help } -test-omnitrace-avail() +test-rocprof-sys-avail() { - verbose-run which omnitrace-avail - verbose-run ldd $(which omnitrace-avail) - verbose-run omnitrace-avail --help - verbose-run omnitrace-avail -a + verbose-run which rocprof-sys-avail + verbose-run ldd $(which rocprof-sys-avail) + verbose-run rocprof-sys-avail --help + verbose-run rocprof-sys-avail -a } test-omnitrace-sample() @@ -199,7 +199,7 @@ test-omnitrace-runtime() } if [ "${ENABLE_OMNITRACE_INSTRUMENT}" -ne 0 ]; then verbose-run test-omnitrace; fi -if [ "${ENABLE_OMNITRACE_AVAIL}" -ne 0 ]; then verbose-run test-omnitrace-avail; fi +if [ "${ENABLE_OMNITRACE_AVAIL}" -ne 0 ]; then verbose-run test-rocprof-sys-avail; fi if [ "${ENABLE_OMNITRACE_SAMPLE}" -ne 0 ]; then verbose-run test-omnitrace-sample; fi if [ "${ENABLE_OMNITRACE_PYTHON}" -ne 0 ]; then verbose-run test-omnitrace-python; fi if [ "${ENABLE_OMNITRACE_REWRITE}" -ne 0 ]; then verbose-run test-omnitrace-rewrite; fi diff --git a/scripts/test-release.sh b/scripts/test-release.sh index d1bb6bbee..56842bf5e 100755 --- a/scripts/test-release.sh +++ b/scripts/test-release.sh @@ -97,8 +97,8 @@ setup-env() test-install() { verbose-run omnitrace-instrument --help - verbose-run omnitrace-avail --help - verbose-run omnitrace-avail --all + verbose-run rocprof-sys-avail --help + verbose-run rocprof-sys-avail --all if [ -d "${1}/lib/python/site-packages/omnitrace" ]; then verbose-run omnitrace-python --help fi diff --git a/source/bin/omnitrace-avail/CMakeLists.txt b/source/bin/omnitrace-avail/CMakeLists.txt index 2cec5b5ca..7ccc74e23 100644 --- a/source/bin/omnitrace-avail/CMakeLists.txt +++ b/source/bin/omnitrace-avail/CMakeLists.txt @@ -30,7 +30,8 @@ target_link_libraries( omnitrace::omnitrace-interface-library omnitrace::libomnitrace-static) set_target_properties( omnitrace-avail PROPERTIES BUILD_RPATH "\$ORIGIN:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}" - INSTALL_RPATH "${OMNITRACE_EXE_INSTALL_RPATH}") + INSTALL_RPATH "${OMNITRACE_EXE_INSTALL_RPATH}" + OUTPUT_NAME rocprof-sys-avail) omnitrace_strip_target(omnitrace-avail) diff --git a/source/bin/omnitrace-avail/avail.cpp b/source/bin/omnitrace-avail/avail.cpp index 8085a5065..b41c328ed 100644 --- a/source/bin/omnitrace-avail/avail.cpp +++ b/source/bin/omnitrace-avail/avail.cpp @@ -193,7 +193,7 @@ main(int argc, char** argv) std::string file = {}; - parser_t parser("omnitrace-avail"); + parser_t parser("rocprof-sys-avail"); parser.set_help_width(40); auto _cols = std::get<0>(tim::utility::console::get_columns()); @@ -202,7 +202,7 @@ main(int argc, char** argv) std::min(_cols - parser.get_help_width() - 8, 120)); parser.enable_help(); - parser.enable_version("omnitrace-avail", OMNITRACE_ARGPARSE_VERSION_INFO); + parser.enable_version("rocprof-sys-avail", OMNITRACE_ARGPARSE_VERSION_INFO); parser.start_group("DEBUG"); @@ -556,7 +556,7 @@ main(int argc, char** argv) generate_config(_config_file, _config_fmts, options); } catch(std::runtime_error& _e) { - std::cerr << "[omnitrace-avail] " << _e.what() << std::endl; + std::cerr << "[rocprof-sys-avail] " << _e.what() << std::endl; return EXIT_FAILURE; } return EXIT_SUCCESS; diff --git a/source/bin/omnitrace-avail/common.cpp b/source/bin/omnitrace-avail/common.cpp index 4c7ea56e5..ba6f8d47c 100644 --- a/source/bin/omnitrace-avail/common.cpp +++ b/source/bin/omnitrace-avail/common.cpp @@ -362,7 +362,7 @@ dump_log() void dump_log_abort(int _v) { - fprintf(stderr, "\n[omnitrace-avail] Exiting with signal %i...\n", _v); + fprintf(stderr, "\n[rocprof-sys-avail] Exiting with signal %i...\n", _v); debug_msg = true; dump_log(); } diff --git a/source/bin/omnitrace-avail/generate_config.cpp b/source/bin/omnitrace-avail/generate_config.cpp index cdb71029a..91be4651a 100644 --- a/source/bin/omnitrace-avail/generate_config.cpp +++ b/source/bin/omnitrace-avail/generate_config.cpp @@ -260,12 +260,12 @@ generate_config(std::string _config_file, const std::set& _config_f if(force_config) { if(settings::verbose() >= 1) - std::cout << "[omnitrace-avail] File '" << _fname + std::cout << "[rocprof-sys-avail] File '" << _fname << "' exists. Overwrite force...\n"; } else { - std::cout << "[omnitrace-avail] File '" << _fname + std::cout << "[rocprof-sys-avail] File '" << _fname << "' exists. Overwrite? " << std::flush; std::string _response = {}; std::cin >> _response; @@ -276,7 +276,7 @@ generate_config(std::string _config_file, const std::set& _config_f if(filepath::open(_ofs, _fname)) { if(settings::verbose() >= 0) - printf("[omnitrace-avail] Outputting %s configuration file '%s'...\n", + printf("[rocprof-sys-avail] Outputting %s configuration file '%s'...\n", _type.c_str(), _fname.c_str()); } else @@ -423,7 +423,7 @@ generate_config(std::string _config_file, const std::set& _config_f true, _output_dir); std::ofstream ofs{}; _open(ofs, _fname, "text") - << "# auto-generated by omnitrace-avail (version " << OMNITRACE_VERSION_STRING + << "# auto-generated by rocprof-sys-avail (version " << OMNITRACE_VERSION_STRING << ") on " << tim::get_local_datetime("%F @ %H:%M", &_time) << "\n\n" << _ss.str(); } @@ -440,7 +440,7 @@ update_choices(const std::shared_ptr& _settings) std::vector _info = get_component_info(); if(_settings->get_verbose() >= 2 || _settings->get_debug()) - printf("[omnitrace-avail] # of component found: %zu\n", _info.size()); + printf("[rocprof-sys-avail] # of component found: %zu\n", _info.size()); _info.erase(std::remove_if(_info.begin(), _info.end(), [](const auto& itr) { @@ -463,7 +463,7 @@ update_choices(const std::shared_ptr& _settings) for(const auto& itr : _info) _component_choices.emplace_back(itr.id_type()); if(_settings->get_verbose() >= 2 || _settings->get_debug()) - printf("[omnitrace-avail] # of component choices: %zu\n", + printf("[rocprof-sys-avail] # of component choices: %zu\n", _component_choices.size()); _settings->find("OMNITRACE_TIMEMORY_COMPONENTS") ->second->set_choices(_component_choices); diff --git a/source/bin/omnitrace-sample/impl.cpp b/source/bin/omnitrace-sample/impl.cpp index cb89a0942..0cb7916eb 100644 --- a/source/bin/omnitrace-sample/impl.cpp +++ b/source/bin/omnitrace-sample/impl.cpp @@ -837,11 +837,11 @@ parse_args(int argc, char** argv, std::vector& _env) remove_env(_env, "KOKKOS_PROFILE_LIBRARY"); }); - parser.start_group("HARDWARE COUNTER OPTIONS", "See also: omnitrace-avail -H"); + parser.start_group("HARDWARE COUNTER OPTIONS", "See also: rocprof-sys-avail -H"); parser .add_argument({ "-C", "--cpu-events" }, "Set the CPU hardware counter events to record (ref: " - "`omnitrace-avail -H -c CPU`)") + "`rocprof-sys-avail -H -c CPU`)") .action([&](parser_t& p) { auto _events = join(array_config{ "," }, p.get>("cpu-events")); @@ -852,7 +852,7 @@ parse_args(int argc, char** argv, std::vector& _env) parser .add_argument({ "-G", "--gpu-events" }, "Set the GPU hardware counter events to record (ref: " - "`omnitrace-avail -H -c GPU`)") + "`rocprof-sys-avail -H -c GPU`)") .action([&](parser_t& p) { auto _events = join(array_config{ "," }, p.get>("gpu-events")); diff --git a/source/bin/tests/CMakeLists.txt b/source/bin/tests/CMakeLists.txt index bb1123ac8..62b1d9456 100644 --- a/source/bin/tests/CMakeLists.txt +++ b/source/bin/tests/CMakeLists.txt @@ -209,66 +209,66 @@ omnitrace_add_bin_test( FAIL_REGEX "No such file or directory|not found|OMNITRACE_ABORT_FAIL_REGEX") omnitrace_add_bin_test( - NAME omnitrace-avail-help + NAME rocprof-sys-avail-help TARGET omnitrace-avail ARGS --help - LABELS "omnitrace-avail" + LABELS "rocprof-sys-avail" TIMEOUT 45 PASS_REGEX - ".*\\\[omnitrace-avail\\\] Usage:.*\\\[DEBUG OPTIONS\\\].*\\\[INFO OPTIONS\\\].*\\\[FILTER OPTIONS\\\].*\\\[COLUMN OPTIONS\\\].*\\\[DISPLAY OPTIONS\\\].*\\\[OUTPUT OPTIONS\\\].*" + ".*\\\[rocprof-sys-avail\\\] Usage:.*\\\[DEBUG OPTIONS\\\].*\\\[INFO OPTIONS\\\].*\\\[FILTER OPTIONS\\\].*\\\[COLUMN OPTIONS\\\].*\\\[DISPLAY OPTIONS\\\].*\\\[OUTPUT OPTIONS\\\].*" ) omnitrace_add_bin_test( - NAME omnitrace-avail-all + NAME rocprof-sys-avail-all TARGET omnitrace-avail ARGS --all - LABELS "omnitrace-avail" + LABELS "rocprof-sys-avail" TIMEOUT 45) omnitrace_add_bin_test( - NAME omnitrace-avail-all-expand-keys + NAME rocprof-sys-avail-all-expand-keys TARGET omnitrace-avail ARGS --all --expand-keys - LABELS "omnitrace-avail" + LABELS "rocprof-sys-avail" TIMEOUT 45 FAIL_REGEX "%[a-zA-Z_]%|OMNITRACE_ABORT_FAIL_REGEX") omnitrace_add_bin_test( - NAME omnitrace-avail-all-only-available-alphabetical + NAME rocprof-sys-avail-all-only-available-alphabetical TARGET omnitrace-avail ARGS --all --available --alphabetical --debug --output - ${CMAKE_CURRENT_BINARY_DIR}/omnitrace-avail-all-only-available-alphabetical.log - LABELS "omnitrace-avail" + ${CMAKE_CURRENT_BINARY_DIR}/rocprof-sys-avail-all-only-available-alphabetical.log + LABELS "rocprof-sys-avail" TIMEOUT 45 PROPERTIES ATTACHED_FILES - ${CMAKE_CURRENT_BINARY_DIR}/omnitrace-avail-all-only-available-alphabetical.log) + ${CMAKE_CURRENT_BINARY_DIR}/rocprof-sys-avail-all-only-available-alphabetical.log) omnitrace_add_bin_test( - NAME omnitrace-avail-all-csv + NAME rocprof-sys-avail-all-csv TARGET omnitrace-avail ARGS --all --csv --csv-separator "#" - LABELS "omnitrace-avail" + LABELS "rocprof-sys-avail" TIMEOUT 45 PASS_REGEX "COMPONENT#AVAILABLE#VALUE_TYPE#STRING_IDS#FILENAME#DESCRIPTION#CATEGORY#.*ENVIRONMENT VARIABLE#VALUE#DATA TYPE#DESCRIPTION#CATEGORIES#.*HARDWARE COUNTER#DEVICE#AVAILABLE#DESCRIPTION#" ) omnitrace_add_bin_test( - NAME omnitrace-avail-filter-wall-clock-available + NAME rocprof-sys-avail-filter-wall-clock-available TARGET omnitrace-avail ARGS -r wall_clock -C --available - LABELS "omnitrace-avail" + LABELS "rocprof-sys-avail" TIMEOUT 45 PASS_REGEX "\\\|[-]+\\\|\n\\\|[ ]+COMPONENT[ ]+\\\|\n\\\|[-]+\\\|\n\\\| (wall_clock)[ ]+\\\|\n\\\|[-]+\\\|" ) omnitrace_add_bin_test( - NAME omnitrace-avail-category-filter-omnitrace + NAME rocprof-sys-avail-category-filter-omnitrace TARGET omnitrace-avail ARGS --categories settings::omnitrace --brief - LABELS "omnitrace-avail" + LABELS "rocprof-sys-avail" TIMEOUT 45 PASS_REGEX "OMNITRACE_(SETTINGS_DESC|OUTPUT_FILE|OUTPUT_PREFIX)" FAIL_REGEX @@ -276,17 +276,17 @@ omnitrace_add_bin_test( ) omnitrace_add_bin_test( - NAME omnitrace-avail-category-filter-timemory + NAME rocprof-sys-avail-category-filter-timemory TARGET omnitrace-avail ARGS --categories settings::timemory --brief --advanced - LABELS "omnitrace-avail" + LABELS "rocprof-sys-avail" TIMEOUT 45 PASS_REGEX "OMNITRACE_(ADD_SECONDARY|SCIENTIFIC|PRECISION|MEMORY_PRECISION|TIMING_PRECISION)" FAIL_REGEX "OMNITRACE_(SETTINGS_DESC|OUTPUT_FILE)|OMNITRACE_ABORT_FAIL_REGEX") omnitrace_add_bin_test( - NAME omnitrace-avail-regex-negation + NAME rocprof-sys-avail-regex-negation TARGET omnitrace-avail ARGS -R omnitrace @@ -299,20 +299,20 @@ omnitrace_add_bin_test( --csv --brief --advanced - LABELS "omnitrace-avail" + LABELS "rocprof-sys-avail" TIMEOUT 45 PASS_REGEX "ENVIRONMENT VARIABLE,[ \n]+OMNITRACE_THREAD_POOL_SIZE,[ \n]+OMNITRACE_USE_PID,[ \n]+" FAIL_REGEX "OMNITRACE_TRACE|OMNITRACE_ABORT_FAIL_REGEX") string(REPLACE "+" "\\\+" _AVAIL_CFG_PATH - "${PROJECT_BINARY_DIR}/omnitrace-tests-output/omnitrace-avail/omnitrace-") + "${PROJECT_BINARY_DIR}/omnitrace-tests-output/rocprof-sys-avail/rocprof-sys-") # use of TWD == Test Working Directory (added by function) omnitrace_add_bin_test( - NAME omnitrace-avail-write-config + NAME rocprof-sys-avail-write-config TARGET omnitrace-avail ARGS -G - %env{TWD}%/omnitrace-tests-output/omnitrace-avail/omnitrace-test.cfg + %env{TWD}%/omnitrace-tests-output/rocprof-sys-avail/rocprof-sys-test.cfg -F txt json @@ -322,53 +322,53 @@ omnitrace_add_bin_test( -c omnitrace TIMEOUT 45 - LABELS "omnitrace-avail" + LABELS "rocprof-sys-avail" PASS_REGEX "Outputting JSON configuration file '${_AVAIL_CFG_PATH}test\\\.json'(.*)Outputting XML configuration file '${_AVAIL_CFG_PATH}test\\\.xml'(.*)Outputting text configuration file '${_AVAIL_CFG_PATH}test\\\.cfg'(.*)" ) omnitrace_add_bin_test( - NAME omnitrace-avail-write-config-tweak + NAME rocprof-sys-avail-write-config-tweak TARGET omnitrace-avail - ARGS -G %env{TWD}%/omnitrace-tests-output/omnitrace-avail/omnitrace-tweak.cfg -F txt + ARGS -G %env{TWD}%/omnitrace-tests-output/rocprof-sys-avail/rocprof-sys-tweak.cfg -F txt json xml --force TIMEOUT 45 - LABELS "omnitrace-avail" + LABELS "rocprof-sys-avail" ENVIRONMENT "OMNITRACE_TRACE=OFF;OMNITRACE_PROFILE=ON" PASS_REGEX "Outputting JSON configuration file '${_AVAIL_CFG_PATH}tweak\\\.json'(.*)Outputting XML configuration file '${_AVAIL_CFG_PATH}tweak\\\.xml'(.*)Outputting text configuration file '${_AVAIL_CFG_PATH}tweak\\\.cfg'(.*)" ) omnitrace_add_bin_test( - NAME omnitrace-avail-list-keys + NAME rocprof-sys-avail-list-keys TARGET omnitrace-avail ARGS --list-keys --expand-keys TIMEOUT 45 - LABELS "omnitrace-avail" + LABELS "rocprof-sys-avail" PASS_REGEX "Output Keys:\n(.*)%argv%(.*)%argv_hash%") omnitrace_add_bin_test( - NAME omnitrace-avail-list-keys-markdown + NAME rocprof-sys-avail-list-keys-markdown TARGET omnitrace-avail ARGS --list-keys --expand-keys --markdown TIMEOUT 45 - LABELS "omnitrace-avail;markdown" + LABELS "rocprof-sys-avail;markdown" PASS_REGEX "(.*)`%argv%`(.*)`%argv_hash%`") omnitrace_add_bin_test( - NAME omnitrace-avail-list-categories + NAME rocprof-sys-avail-list-categories TARGET omnitrace-avail ARGS --list-categories TIMEOUT 45 - LABELS "omnitrace-avail" + LABELS "rocprof-sys-avail" PASS_REGEX " component::(.*) hw_counters::(.*) settings::") omnitrace_add_bin_test( - NAME omnitrace-avail-core-categories + NAME rocprof-sys-avail-core-categories TARGET omnitrace-avail ARGS -c core TIMEOUT 45 - LABELS "omnitrace-avail" + LABELS "rocprof-sys-avail" PASS_REGEX "OMNITRACE_CONFIG_FILE(.*)OMNITRACE_ENABLED(.*)OMNITRACE_SUPPRESS_CONFIG(.*)OMNITRACE_SUPPRESS_PARSING(.*)OMNITRACE_VERBOSE" ) diff --git a/source/lib/core/argparse.cpp b/source/lib/core/argparse.cpp index e294644e7..72db8b399 100644 --- a/source/lib/core/argparse.cpp +++ b/source/lib/core/argparse.cpp @@ -1191,14 +1191,14 @@ add_core_arguments(parser_t& _parser, parser_data& _data) add_group_arguments(_parser, "sampling", _data); - _parser.start_group("HARDWARE COUNTER OPTIONS", "See also: omnitrace-avail -H"); + _parser.start_group("HARDWARE COUNTER OPTIONS", "See also: rocprof-sys-avail -H"); if(_data.environ_filter("cpu_events", _data)) { _parser .add_argument({ "-C", "--cpu-events" }, "Set the CPU hardware counter events to record (ref: " - "`omnitrace-avail -H -c CPU`)") + "`rocprof-sys-avail -H -c CPU`)") .min_count(1) .dtype("[EVENT ...]") .action([&](parser_t& p) { @@ -1216,7 +1216,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) _parser .add_argument({ "-G", "--gpu-events" }, "Set the GPU hardware counter events to record (ref: " - "`omnitrace-avail -H -c GPU`)") + "`rocprof-sys-avail -H -c GPU`)") .min_count(1) .dtype("[EVENT ...]") .action([&](parser_t& p) { @@ -1353,7 +1353,7 @@ add_group_arguments(parser_t& _parser, const std::string& _group_name, parser_da }), _choices.end()); _choices.emplace_back( - "... run `omnitrace-avail -H -c CPU` for full list ..."); + "... run `rocprof-sys-avail -H -c CPU` for full list ..."); itr.second->set_choices(_choices); } } @@ -1414,7 +1414,7 @@ add_extended_arguments(parser_t& _parser, parser_data& _data) }), _choices.end()); _choices.emplace_back( - "... run `omnitrace-avail -H -c CPU` for full list ..."); + "... run `rocprof-sys-avail -H -c CPU` for full list ..."); itr.second->set_choices(_choices); } diff --git a/source/lib/core/config.cpp b/source/lib/core/config.cpp index 8d1ad6196..7c9525386 100644 --- a/source/lib/core/config.cpp +++ b/source/lib/core/config.cpp @@ -716,7 +716,7 @@ configure_settings(bool _init) OMNITRACE_CONFIG_SETTING( std::string, "OMNITRACE_TIMEMORY_COMPONENTS", - "List of components to collect via timemory (see `omnitrace-avail -C`)", + "List of components to collect via timemory (see `rocprof-sys-avail -C`)", "wall_clock", "timemory", "component"); OMNITRACE_CONFIG_SETTING(std::string, "OMNITRACE_OUTPUT_FILE", diff --git a/source/lib/core/config.hpp b/source/lib/core/config.hpp index dac62fc3f..89d7e11e0 100644 --- a/source/lib/core/config.hpp +++ b/source/lib/core/config.hpp @@ -278,7 +278,7 @@ get_trace_hsa_api_types(); std::string& get_perfetto_backend(); -// make this visible so omnitrace-avail can call it +// make this visible so rocprof-sys-avail can call it std::string get_perfetto_output_filename(); From 3fcd2b3d8fc3404be1829cb3ba5b25e9d7e04ea0 Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Fri, 13 Sep 2024 17:24:46 -0400 Subject: [PATCH 12/39] Format CMake files --- source/bin/omnitrace-avail/CMakeLists.txt | 7 ++++--- source/bin/tests/CMakeLists.txt | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/source/bin/omnitrace-avail/CMakeLists.txt b/source/bin/omnitrace-avail/CMakeLists.txt index 7ccc74e23..bc4d5eeb8 100644 --- a/source/bin/omnitrace-avail/CMakeLists.txt +++ b/source/bin/omnitrace-avail/CMakeLists.txt @@ -29,9 +29,10 @@ target_link_libraries( PRIVATE omnitrace::omnitrace-compile-definitions omnitrace::omnitrace-interface-library omnitrace::libomnitrace-static) set_target_properties( - omnitrace-avail PROPERTIES BUILD_RPATH "\$ORIGIN:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}" - INSTALL_RPATH "${OMNITRACE_EXE_INSTALL_RPATH}" - OUTPUT_NAME rocprof-sys-avail) + omnitrace-avail + PROPERTIES BUILD_RPATH "\$ORIGIN:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}" + INSTALL_RPATH "${OMNITRACE_EXE_INSTALL_RPATH}" + OUTPUT_NAME rocprof-sys-avail) omnitrace_strip_target(omnitrace-avail) diff --git a/source/bin/tests/CMakeLists.txt b/source/bin/tests/CMakeLists.txt index 62b1d9456..202fa51e1 100644 --- a/source/bin/tests/CMakeLists.txt +++ b/source/bin/tests/CMakeLists.txt @@ -305,8 +305,9 @@ omnitrace_add_bin_test( "ENVIRONMENT VARIABLE,[ \n]+OMNITRACE_THREAD_POOL_SIZE,[ \n]+OMNITRACE_USE_PID,[ \n]+" FAIL_REGEX "OMNITRACE_TRACE|OMNITRACE_ABORT_FAIL_REGEX") -string(REPLACE "+" "\\\+" _AVAIL_CFG_PATH - "${PROJECT_BINARY_DIR}/omnitrace-tests-output/rocprof-sys-avail/rocprof-sys-") +string( + REPLACE "+" "\\\+" _AVAIL_CFG_PATH + "${PROJECT_BINARY_DIR}/omnitrace-tests-output/rocprof-sys-avail/rocprof-sys-") # use of TWD == Test Working Directory (added by function) omnitrace_add_bin_test( NAME rocprof-sys-avail-write-config @@ -330,8 +331,8 @@ omnitrace_add_bin_test( omnitrace_add_bin_test( NAME rocprof-sys-avail-write-config-tweak TARGET omnitrace-avail - ARGS -G %env{TWD}%/omnitrace-tests-output/rocprof-sys-avail/rocprof-sys-tweak.cfg -F txt - json xml --force + ARGS -G %env{TWD}%/omnitrace-tests-output/rocprof-sys-avail/rocprof-sys-tweak.cfg -F + txt json xml --force TIMEOUT 45 LABELS "rocprof-sys-avail" ENVIRONMENT "OMNITRACE_TRACE=OFF;OMNITRACE_PROFILE=ON" From 40485964805802c7b98c5afc19b0941d12644590 Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Fri, 13 Sep 2024 21:37:26 -0400 Subject: [PATCH 13/39] Remove omnitrace-exe Signed-off-by: David Galiffi --- source/bin/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/bin/CMakeLists.txt b/source/bin/CMakeLists.txt index 859b729fc..fa8306f06 100644 --- a/source/bin/CMakeLists.txt +++ b/source/bin/CMakeLists.txt @@ -19,9 +19,8 @@ add_subdirectory(omnitrace-causal) add_subdirectory(omnitrace-sample) add_subdirectory(omnitrace-instrument) add_subdirectory(omnitrace-run) -# omnitrace-exe is deprecated -add_subdirectory(omnitrace-exe) +# tests if(OMNITRACE_BUILD_TESTING OR "$ENV{OMNITRACE_CI}" MATCHES "[1-9]+|ON|on|y|yes") add_subdirectory(tests) endif() From 4a47eecb6e822be3432c2da48119566a8fa66e28 Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Fri, 13 Sep 2024 22:39:13 -0400 Subject: [PATCH 14/39] Rename the omnitrace-sample binary --- .github/workflows/ubuntu-focal.yml | 4 ++-- scripts/test-install.sh | 16 ++++++++-------- source/bin/omnitrace-causal/impl.cpp | 2 +- source/bin/omnitrace-sample/CMakeLists.txt | 3 ++- source/bin/omnitrace-sample/impl.cpp | 2 +- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ubuntu-focal.yml b/.github/workflows/ubuntu-focal.yml index d231d5e1e..8d708d076 100644 --- a/.github/workflows/ubuntu-focal.yml +++ b/.github/workflows/ubuntu-focal.yml @@ -172,7 +172,7 @@ jobs: ldd $(which omnitrace) omnitrace-instrument --help rocprof-sys-avail --help - omnitrace-sample --help + rocprof-sys-sample --help - name: Test Build-Tree Source Script timeout-minutes: 45 @@ -184,7 +184,7 @@ jobs: ldd $(which omnitrace) omnitrace-instrument --help rocprof-sys-avail --help - omnitrace-sample --help + rocprof-sys-sample --help - name: Install timeout-minutes: 10 diff --git a/scripts/test-install.sh b/scripts/test-install.sh index 5ecb3770c..57b101d3b 100755 --- a/scripts/test-install.sh +++ b/scripts/test-install.sh @@ -50,7 +50,7 @@ usage() print_option source-dir "" "Location of source directory" "${SOURCE_DIR}" print_option test-omnitrace-instrument "0|1" "Enable testing omnitrace-instrument exe" "${ENABLE_OMNITRACE_INSTRUMENT}" print_option test-rocprof-sys-avail "0|1" "Enable testing rocprof-sys-avail" "${ENABLE_OMNITRACE_AVAIL}" - print_option test-omnitrace-sample "0|1" "Enable testing omnitrace-sample" "${ENABLE_OMNITRACE_SAMPLE}" + print_option test-rocprof-sys-sample "0|1" "Enable testing rocprof-sys-sample" "${ENABLE_OMNITRACE_SAMPLE}" print_option test-omnitrace-python "0|1" "Enable testing omnitrace-python" "${ENABLE_OMNITRACE_PYTHON}" print_option test-omnitrace-rewrite "0|1" "Enable testing omnitrace-instrument binary rewrite" "${ENABLE_OMNITRACE_REWRITE}" print_option test-omnitrace-runtime "0|1" "Enable testing omnitrace-instrument runtime instrumentation" "${ENABLE_OMNITRACE_RUNTIME}" @@ -108,7 +108,7 @@ do ENABLE_OMNITRACE_AVAIL=${VAL} continue ;; - --test-omnitrace-sample) + --test-rocprof-sys-sample) ENABLE_OMNITRACE_SAMPLE=${VAL} continue ;; @@ -151,12 +151,12 @@ test-rocprof-sys-avail() verbose-run rocprof-sys-avail -a } -test-omnitrace-sample() +test-rocprof-sys-sample() { - verbose-run which omnitrace-sample - verbose-run ldd $(which omnitrace-sample) - verbose-run omnitrace-sample --help - verbose-run omnitrace-sample --cputime 100 --realtime 50 --hsa-interrupt 0 -TPH -- python3 ${SOURCE_DIR}/examples/python/external.py -n 5 -v 20 + verbose-run which rocprof-sys-sample + verbose-run ldd $(which rocprof-sys-sample) + verbose-run rocprof-sys-sample --help + verbose-run rocprof-sys-sample --cputime 100 --realtime 50 --hsa-interrupt 0 -TPH -- python3 ${SOURCE_DIR}/examples/python/external.py -n 5 -v 20 } test-omnitrace-python() @@ -200,7 +200,7 @@ test-omnitrace-runtime() if [ "${ENABLE_OMNITRACE_INSTRUMENT}" -ne 0 ]; then verbose-run test-omnitrace; fi if [ "${ENABLE_OMNITRACE_AVAIL}" -ne 0 ]; then verbose-run test-rocprof-sys-avail; fi -if [ "${ENABLE_OMNITRACE_SAMPLE}" -ne 0 ]; then verbose-run test-omnitrace-sample; fi +if [ "${ENABLE_OMNITRACE_SAMPLE}" -ne 0 ]; then verbose-run test-rocprof-sys-sample; fi if [ "${ENABLE_OMNITRACE_PYTHON}" -ne 0 ]; then verbose-run test-omnitrace-python; fi if [ "${ENABLE_OMNITRACE_REWRITE}" -ne 0 ]; then verbose-run test-omnitrace-rewrite; fi if [ "${ENABLE_OMNITRACE_RUNTIME}" -ne 0 ]; then verbose-run test-omnitrace-runtime; fi diff --git a/source/bin/omnitrace-causal/impl.cpp b/source/bin/omnitrace-causal/impl.cpp index 722ab0ca5..8ed3648d8 100644 --- a/source/bin/omnitrace-causal/impl.cpp +++ b/source/bin/omnitrace-causal/impl.cpp @@ -433,7 +433,7 @@ parse_args(int argc, char** argv, std::vector& _env, - Insert progress points at hotspots in your code or use omnitrace's runtime instrumentation - Note: binary rewrite will produce a incompatible new binary - Collect a flat profile via sampling - - E.g., omnitrace-sample -F -- + - E.g., rocprof-sys-sample -F -- - Inspect sampling_wall_clock.txt and sampling_cpu_clock.txt for functions to target - Run omnitrace-causal in "function" mode first (does not require debug info) - Run omnitrace-causal in "line" mode when you are targeting one function (requires debug info) diff --git a/source/bin/omnitrace-sample/CMakeLists.txt b/source/bin/omnitrace-sample/CMakeLists.txt index 8fe6e61dd..f8cd13154 100644 --- a/source/bin/omnitrace-sample/CMakeLists.txt +++ b/source/bin/omnitrace-sample/CMakeLists.txt @@ -15,7 +15,8 @@ target_link_libraries( omnitrace::omnitrace-common-library) set_target_properties( omnitrace-sample PROPERTIES BUILD_RPATH "\$ORIGIN:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}" - INSTALL_RPATH "${OMNITRACE_EXE_INSTALL_RPATH}") + INSTALL_RPATH "${OMNITRACE_EXE_INSTALL_RPATH}" + OUTPUT_NAME "rocprof-sys-sample") omnitrace_strip_target(omnitrace-sample) diff --git a/source/bin/omnitrace-sample/impl.cpp b/source/bin/omnitrace-sample/impl.cpp index 0cb7916eb..797179f2e 100644 --- a/source/bin/omnitrace-sample/impl.cpp +++ b/source/bin/omnitrace-sample/impl.cpp @@ -372,7 +372,7 @@ parse_args(int argc, char** argv, std::vector& _env) parser.set_use_color(true); parser.enable_help(); - parser.enable_version("omnitrace-sample", OMNITRACE_ARGPARSE_VERSION_INFO); + parser.enable_version("rocprof-sys-sample", OMNITRACE_ARGPARSE_VERSION_INFO); auto _cols = std::get<0>(tim::utility::console::get_columns()); if(_cols > parser.get_help_width() + 8) From 20b3905f3cb6a70235c5328e060074cb5ca414d1 Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Fri, 13 Sep 2024 23:35:26 -0400 Subject: [PATCH 15/39] Rename the omntrace-causal binary --- cmake/ConfigInstall.cmake | 4 ++-- source/bin/omnitrace-causal/CMakeLists.txt | 3 ++- source/bin/omnitrace-causal/impl.cpp | 24 +++++++++---------- .../bin/omnitrace-causal/omnitrace-causal.hpp | 2 +- source/lib/omnitrace/library/causal/data.cpp | 4 ++-- source/python/gui/README.md | 4 ++-- source/python/gui/setup.cfg | 4 ++-- source/python/gui/setup.py | 10 ++++---- source/python/gui/source/__main__.py | 8 +++---- tests/omnitrace-causal-tests.cmake | 2 +- 10 files changed, 33 insertions(+), 32 deletions(-) diff --git a/cmake/ConfigInstall.cmake b/cmake/ConfigInstall.cmake index 691a41014..c3d5d26db 100644 --- a/cmake/ConfigInstall.cmake +++ b/cmake/ConfigInstall.cmake @@ -45,9 +45,9 @@ export(PACKAGE ${PROJECT_NAME}) # configure_file( ${PROJECT_SOURCE_DIR}/tests/validate-causal-json.py - ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/omnitrace-causal-print COPYONLY) + ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/rocprof-sys-causal-print COPYONLY) -install(PROGRAMS ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/omnitrace-causal-print +install(PROGRAMS ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/rocprof-sys-causal-print DESTINATION ${CMAKE_INSTALL_BINDIR}) # ------------------------------------------------------------------------------# diff --git a/source/bin/omnitrace-causal/CMakeLists.txt b/source/bin/omnitrace-causal/CMakeLists.txt index 0d0ed3763..6714158f7 100644 --- a/source/bin/omnitrace-causal/CMakeLists.txt +++ b/source/bin/omnitrace-causal/CMakeLists.txt @@ -17,7 +17,8 @@ target_link_libraries( omnitrace::omnitrace-common-library omnitrace::omnitrace-core) set_target_properties( omnitrace-causal PROPERTIES BUILD_RPATH "\$ORIGIN:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}" - INSTALL_RPATH "${OMNITRACE_EXE_INSTALL_RPATH}") + INSTALL_RPATH "${OMNITRACE_EXE_INSTALL_RPATH}" + OUTPUT_NAME "rocprof-sys-causal") omnitrace_strip_target(omnitrace-causal) diff --git a/source/bin/omnitrace-causal/impl.cpp b/source/bin/omnitrace-causal/impl.cpp index 8ed3648d8..93f2f1b9c 100644 --- a/source/bin/omnitrace-causal/impl.cpp +++ b/source/bin/omnitrace-causal/impl.cpp @@ -202,7 +202,7 @@ get_initial_environment() update_env(_env, "OMNITRACE_USE_PROCESS_SAMPLING", false); update_env(_env, "OMNITRACE_THREAD_POOL_SIZE", get_env("OMNITRACE_THREAD_POOL_SIZE", 0)); - update_env(_env, "OMNITRACE_LAUNCHER", "omnitrace-causal"); + update_env(_env, "OMNITRACE_LAUNCHER", "rocprof-sys-causal"); return _env; } @@ -228,7 +228,7 @@ prepare_command_for_run(char* _exe, std::vector& _argv) if(!_injected) { throw std::runtime_error( - join("", "omnitrace-causal was unable to match \"", launcher, + join("", "rocprof-sys-causal was unable to match \"", launcher, "\" to any arguments on the command line: \"", join(array_config{ " ", "", "" }, _argv), "\"")); } @@ -419,13 +419,13 @@ parse_args(int argc, char** argv, std::vector& _env, This executable is designed to streamline that process. For example (assume all commands end with '-- '): - omnitrace-causal -n 5 -- # runs 5x with causal profiling enabled + rocprof-sys-causal -n 5 -- # runs 5x with causal profiling enabled - omnitrace-causal -s 0 5,10,15,20 # runs 2x with virtual speedups: + rocprof-sys-causal -s 0 5,10,15,20 # runs 2x with virtual speedups: # - 0 # - randomly selected from 5, 10, 15, and 20 - omnitrace-causal -F func_A func_B func_(A|B) # runs 3x with the function scope limited to: + rocprof-sys-causal -F func_A func_B func_(A|B) # runs 3x with the function scope limited to: # 1. func_A # 2. func_B # 3. func_A or func_B @@ -435,8 +435,8 @@ parse_args(int argc, char** argv, std::vector& _env, - Collect a flat profile via sampling - E.g., rocprof-sys-sample -F -- - Inspect sampling_wall_clock.txt and sampling_cpu_clock.txt for functions to target - - Run omnitrace-causal in "function" mode first (does not require debug info) - - Run omnitrace-causal in "line" mode when you are targeting one function (requires debug info) + - Run rocprof-sys-causal in "function" mode first (does not require debug info) + - Run rocprof-sys-causal in "line" mode when you are targeting one function (requires debug info) - Preferably, use predictions from the "function" mode to determine which function to target - Limit the virtual speedups to a smaller pool, e.g., 0,5,10,25,50, to get reliable predictions quicker - Make use of the binary, source, and function scope to limit the functions/lines selected for experiments @@ -451,7 +451,7 @@ parse_args(int argc, char** argv, std::vector& _env, }); parser.enable_help(); - parser.enable_version("omnitrace-causal", OMNITRACE_ARGPARSE_VERSION_INFO); + parser.enable_version("rocprof-sys-causal", OMNITRACE_ARGPARSE_VERSION_INFO); auto _cols = std::get<0>(console::get_columns()); if(_cols > parser.get_help_width() + 8) @@ -483,7 +483,7 @@ parse_args(int argc, char** argv, std::vector& _env, }); std::string _config_file = {}; - std::string _config_folder = "omnitrace-causal-config"; + std::string _config_folder = "rocprof-sys-causal-config"; bool _generate_configs = false; bool _add_defaults = true; @@ -498,10 +498,10 @@ parse_args(int argc, char** argv, std::vector& _env, parser .add_argument( { "-l", "--launcher" }, - "When running MPI jobs, omnitrace-causal needs to be *before* the executable " + "When running MPI jobs, rocprof-sys-causal needs to be *before* the executable " "which launches the MPI processes (i.e. before `mpirun`, `srun`, etc.). Pass " "the name of the target executable (or a regex for matching to the name of " - "the target) for causal profiling, e.g., `omnitrace-causal -l foo -- mpirun " + "the target) for causal profiling, e.g., `rocprof-sys-causal -l foo -- mpirun " "-n 4 foo`. This ensures that the omnitrace library is LD_PRELOADed on the " "proper target") .count(1) @@ -511,7 +511,7 @@ parse_args(int argc, char** argv, std::vector& _env, .add_argument({ "-g", "--generate-configs" }, "Generate config files instead of passing environment variables " "directly. If no arguments are provided, the config files will be " - "placed in ${PWD}/omnitrace-causal-config folder") + "placed in ${PWD}/rocprof-sys-causal-config folder") .min_count(0) .max_count(1) .dtype("folder") diff --git a/source/bin/omnitrace-causal/omnitrace-causal.hpp b/source/bin/omnitrace-causal/omnitrace-causal.hpp index 9e0dc529f..3e54e67de 100644 --- a/source/bin/omnitrace-causal/omnitrace-causal.hpp +++ b/source/bin/omnitrace-causal/omnitrace-causal.hpp @@ -22,7 +22,7 @@ #pragma once -#define TIMEMORY_PROJECT_NAME "omnitrace-causal" +#define TIMEMORY_PROJECT_NAME "rocprof-sys-causal" #include #include diff --git a/source/lib/omnitrace/library/causal/data.cpp b/source/lib/omnitrace/library/causal/data.cpp index 53c40b9c1..25dbeebb5 100644 --- a/source/lib/omnitrace/library/causal/data.cpp +++ b/source/lib/omnitrace/library/causal/data.cpp @@ -634,11 +634,11 @@ perform_experiment_impl(std::shared_ptr> _started) // NOLINT } std::cerr << std::flush; - // if launched via omnitrace-causal, allow end-to-end runs that do not + // if launched via rocprof-sys-causal, allow end-to-end runs that do not // start experiments auto _omni_causal_launcher = get_env("OMNITRACE_LAUNCHER", "", false) == - "omnitrace-causal"; + "rocprof-sys-causal"; if(!(get_causal_end_to_end() && _omni_causal_launcher)) { diff --git a/source/python/gui/README.md b/source/python/gui/README.md index 0851fb127..369f3bdc0 100644 --- a/source/python/gui/README.md +++ b/source/python/gui/README.md @@ -13,13 +13,13 @@ python -m pip install . #### Console Script ```console -omnitrace-causal-plot +rocprof-sys-causal-plot ``` #### Module ```console -python -m omnitrace_causal_viewer +python -m rocprof-sys_causal_viewer ``` ### From source tree diff --git a/source/python/gui/setup.cfg b/source/python/gui/setup.cfg index b4d1b3f00..eb115be50 100644 --- a/source/python/gui/setup.cfg +++ b/source/python/gui/setup.cfg @@ -1,5 +1,5 @@ [metadata] -name = omnitrace-causal-viewer +name = rocprof-sys-causal-viewer url = https://github.com/ROCm/omnitrace download_url = https://github.com/ROCm/omnitrace.git maintainer = AMD Research @@ -22,7 +22,7 @@ classifiers = Programming Language :: Python :: 3 [options] -packages = omnitrace_causal_viewer +packages = rocprof_sys_causal_viewer zip_safe = true include_package_data = true diff --git a/source/python/gui/setup.py b/source/python/gui/setup.py index e35d58260..6cf40b6ac 100644 --- a/source/python/gui/setup.py +++ b/source/python/gui/setup.py @@ -47,16 +47,16 @@ def parse_requirements(fname="requirements.txt"): setup( - name="omnitrace-causal-viewer", + name="rocprof-sys-causal-viewer", version=get_project_version(), description="GUI for viewing causal profilers", long_description=get_long_description(), long_description_content_type="text/markdown", author="AMD Research", - packages=["omnitrace_causal_viewer"], - package_dir={"omnitrace_causal_viewer": "source"}, + packages=["rocprof_sys_causal_viewer"], + package_dir={"rocprof_sys_causal_viewer": "source"}, package_data={ - "omnitrace_causal_viewer": [ + "rocprof_sys_causal_viewer": [ "source/assets/*", "source/workloads/*", "source/VERSION", @@ -65,6 +65,6 @@ def parse_requirements(fname="requirements.txt"): install_requires=parse_requirements(), python_requires=">=3.6", entry_points={ - "console_scripts": ["omnitrace-causal-plot=omnitrace_causal_viewer.__main__:main"] + "console_scripts": ["rocprof-sys-causal-plot=rocprof_sys_causal_viewer.__main__:main"] }, ) diff --git a/source/python/gui/source/__main__.py b/source/python/gui/source/__main__.py index fa17d6e51..22426e5e4 100644 --- a/source/python/gui/source/__main__.py +++ b/source/python/gui/source/__main__.py @@ -118,7 +118,7 @@ def main(): for itr in [ settings_path, - os.path.join(os.environ.get("HOME"), ".omnitrace-causal-plot.json"), + os.path.join(os.environ.get("HOME"), ".rocprof-sys-causal-plot.json"), ]: if os.path.exists(itr): with open(itr, "r") as f: @@ -150,11 +150,11 @@ def main(): prog, max_help_position=40 ), usage=""" - omnitrace-causal-plot [ARGS...] + rocprof-sys-causal-plot [ARGS...] ------------------------------------------------------------------------------- Examples: - \tomnitrace-causal-plot --path workloads/toy -n 0 + \trocprof-sys-causal-plot --path workloads/toy -n 0 ------------------------------------------------------------------------------- """, ) @@ -162,7 +162,7 @@ def main(): my_parser.add_argument( "--version", action="version", - version="OmniTrace Causal Viewer v{}\n".format(f"{__version__}".strip("\n")), + version="ROCm Systems Profiler Causal Viewer v{}\n".format(f"{__version__}".strip("\n")), ) my_parser.add_argument( diff --git a/tests/omnitrace-causal-tests.cmake b/tests/omnitrace-causal-tests.cmake index d223da828..ef63cf887 100644 --- a/tests/omnitrace-causal-tests.cmake +++ b/tests/omnitrace-causal-tests.cmake @@ -108,7 +108,7 @@ macro( _V30 _TOL # tolerance for virtual speedup ) - # arguments to omnitrace-causal + # arguments to rocprof-sys-causal set(${_NAME}_args "${_causal_common_args} ${_MODE} ${_EXPER}") # arguments to validate-causal-json.py From c6252b9b499eec2191fe605641c5877866a256b2 Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Fri, 13 Sep 2024 23:38:57 -0400 Subject: [PATCH 16/39] Rename omnitrace-capchk binary --- tests/omnitrace-capchk.cpp | 6 +++--- tests/omnitrace-testing.cmake | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/omnitrace-capchk.cpp b/tests/omnitrace-capchk.cpp index 7f2d441c0..d70686179 100644 --- a/tests/omnitrace-capchk.cpp +++ b/tests/omnitrace-capchk.cpp @@ -353,7 +353,7 @@ int main(int argc, char** argv) { const auto* _usage = R"usage( -usage: omnitrace-capchk +usage: rocprof-sys-capchk Description: Simple tool for checking the effective capabilities of a running process @@ -382,10 +382,10 @@ usage: omnitrace-capchk 3 if the capability set name is not supported Examples: - $ omnitrace-capchk CAP_SYS_ADMIN + $ rocprof-sys-capchk CAP_SYS_ADMIN Check if this exe (self) has CAP_SYS_ADMIN capability in the (default) effective capability set - $ omnitrace-capchk sys_admin bounding 423032 + $ rocprof-sys-capchk sys_admin bounding 423032 Check if process 423032 has CAP_SYS_ADMIN capability in the bounding capability set )usage"; diff --git a/tests/omnitrace-testing.cmake b/tests/omnitrace-testing.cmake index 32250900b..99a2dbaf3 100644 --- a/tests/omnitrace-testing.cmake +++ b/tests/omnitrace-testing.cmake @@ -195,20 +195,20 @@ endif() execute_process( COMMAND ${CMAKE_CXX_COMPILER} -O2 -g -std=c++17 - ${CMAKE_CURRENT_LIST_DIR}/omnitrace-capchk.cpp -o omnitrace-capchk + ${CMAKE_CURRENT_LIST_DIR}/omnitrace-capchk.cpp -o rocprof-sys-capchk WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/bin RESULT_VARIABLE _capchk_compile OUTPUT_QUIET ERROR_QUIET) if(_capchk_compile EQUAL 0) execute_process( - COMMAND ${PROJECT_BINARY_DIR}/bin/omnitrace-capchk CAP_SYS_ADMIN effective + COMMAND ${PROJECT_BINARY_DIR}/bin/rocprof-sys-capchk CAP_SYS_ADMIN effective WORKING_DIRECTORY ${PROJECT_BINARY_DIR} RESULT_VARIABLE omnitrace_cap_sys_admin OUTPUT_QUIET ERROR_QUIET) execute_process( - COMMAND ${PROJECT_BINARY_DIR}/bin/omnitrace-capchk CAP_PERFMON effective + COMMAND ${PROJECT_BINARY_DIR}/bin/rocprof-sys-capchk CAP_PERFMON effective WORKING_DIRECTORY ${PROJECT_BINARY_DIR} RESULT_VARIABLE omnitrace_cap_perfmon OUTPUT_QUIET ERROR_QUIET) From 0622844b0dcd5877794a4ea1fc16bca70230ec50 Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Sat, 14 Sep 2024 10:33:50 -0400 Subject: [PATCH 17/39] Rename omnitrace-instrument binary --- scripts/test-release.sh | 2 +- source/bin/omnitrace-exe/CMakeLists.txt | 3 +- source/bin/omnitrace-exe/omnitrace.cpp | 6 ++-- .../bin/omnitrace-instrument/CMakeLists.txt | 3 +- .../omnitrace-instrument.cpp | 4 +-- source/bin/tests/CMakeLists.txt | 28 +++++++++---------- source/lib/omnitrace-dl/dl.cpp | 4 +-- 7 files changed, 26 insertions(+), 24 deletions(-) diff --git a/scripts/test-release.sh b/scripts/test-release.sh index 56842bf5e..3f8901b39 100755 --- a/scripts/test-release.sh +++ b/scripts/test-release.sh @@ -96,7 +96,7 @@ setup-env() test-install() { - verbose-run omnitrace-instrument --help + verbose-run rocprof-sys-instrument --help verbose-run rocprof-sys-avail --help verbose-run rocprof-sys-avail --all if [ -d "${1}/lib/python/site-packages/omnitrace" ]; then diff --git a/source/bin/omnitrace-exe/CMakeLists.txt b/source/bin/omnitrace-exe/CMakeLists.txt index 576efbdfe..09b12ce41 100644 --- a/source/bin/omnitrace-exe/CMakeLists.txt +++ b/source/bin/omnitrace-exe/CMakeLists.txt @@ -1,6 +1,7 @@ # ------------------------------------------------------------------------------# # -# omnitrace-exe target (deprecated 'omnitrace' executable, now 'omnitrace-instrument') +# TODO: [DFG] Remove this file after 'rocprof-sys' rebranding is complete +# omnitrace-exe target (deprecated 'omnitrace' executable, now 'rocprof-sys-instrument') # # ------------------------------------------------------------------------------# diff --git a/source/bin/omnitrace-exe/omnitrace.cpp b/source/bin/omnitrace-exe/omnitrace.cpp index 215d5b505..25dbd0f9c 100644 --- a/source/bin/omnitrace-exe/omnitrace.cpp +++ b/source/bin/omnitrace-exe/omnitrace.cpp @@ -66,10 +66,10 @@ main(int argc, char** argv) gggggg - OmniTrace has renamed the "omnitrace" executable to "omnitrace-instrument" to reduce confusion. + OmniTrace has renamed the "omnitrace" executable to "rocprof-sys-instrument" to reduce confusion. This executable only exists to provide this deprecation warning and maintain backwards compatibility for a few releases. - This executable will soon invoke "omnitrace-instrument" with the arguments you just provided after we've given you + This executable will soon invoke "rocprof-sys-instrument" with the arguments you just provided after we've given you a chance to read this message. If you are running this job interactively, please acknowledge that you've read this message and whether you want to continue. @@ -96,7 +96,7 @@ main(int argc, char** argv) _emit_warning(); std::cerr << "[" << argv[0] << "] Detected " << _env_var << " environment variable. Exiting to prevent consuming CI resources. " - "Use \"omnitrace-instrument\" executable instead of \"omnitrace\" " + "Use \"rocprof-sys-instrument\" executable instead of \"omnitrace\" " "to prevent this error." << std::endl; std::exit(EXIT_FAILURE); diff --git a/source/bin/omnitrace-instrument/CMakeLists.txt b/source/bin/omnitrace-instrument/CMakeLists.txt index ffed45638..195104b51 100644 --- a/source/bin/omnitrace-instrument/CMakeLists.txt +++ b/source/bin/omnitrace-instrument/CMakeLists.txt @@ -39,7 +39,8 @@ set_target_properties( omnitrace-instrument PROPERTIES BUILD_RPATH "\$ORIGIN:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}" INSTALL_RPATH "${OMNITRACE_EXE_INSTALL_RPATH}" - INSTALL_RPATH_USE_LINK_PATH ON) + INSTALL_RPATH_USE_LINK_PATH ON + OUTPUT_NAME "rocprof-sys-instrument") if(OMNITRACE_BUILD_DYNINST) target_compile_definitions(omnitrace-instrument PRIVATE OMNITRACE_BUILD_DYNINST=1) diff --git a/source/bin/omnitrace-instrument/omnitrace-instrument.cpp b/source/bin/omnitrace-instrument/omnitrace-instrument.cpp index 264604398..93c2c3c41 100644 --- a/source/bin/omnitrace-instrument/omnitrace-instrument.cpp +++ b/source/bin/omnitrace-instrument/omnitrace-instrument.cpp @@ -466,11 +466,11 @@ 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("omnitrace-instrument"); + parser_t parser("rocprof-sys-instrument"); string_t extra_help = "-- "; parser.enable_help(); - parser.enable_version("omnitrace-instrument", OMNITRACE_ARGPARSE_VERSION_INFO); + parser.enable_version("rocprof-sys-instrument", OMNITRACE_ARGPARSE_VERSION_INFO); parser.add_argument({ "" }, ""); parser.add_argument({ "[DEBUG OPTIONS]" }, ""); diff --git a/source/bin/tests/CMakeLists.txt b/source/bin/tests/CMakeLists.txt index 202fa51e1..32478225d 100644 --- a/source/bin/tests/CMakeLists.txt +++ b/source/bin/tests/CMakeLists.txt @@ -111,13 +111,13 @@ function(OMNITRACE_ADD_BIN_TEST) endfunction() omnitrace_add_bin_test( - NAME omnitrace-instrument-help + NAME rocprof-sys-instrument-help TARGET omnitrace-instrument ARGS --help - LABELS omnitrace-instrument + LABELS rocprof-sys-instrument TIMEOUT 45 PASS_REGEX - ".*\\\[omnitrace-instrument\\\] Usage:.*\\\[DEBUG OPTIONS\\\].*\\\[MODE OPTIONS\\\].*\\\[LIBRARY OPTIONS\\\].*\\\[SYMBOL SELECTION OPTIONS\\\].*\\\[RUNTIME OPTIONS\\\].*\\\[GRANULARITY OPTIONS\\\].*\\\[DYNINST OPTIONS\\\].*" + ".*\\\[rocprof-sys-instrument\\\] Usage:.*\\\[DEBUG OPTIONS\\\].*\\\[MODE OPTIONS\\\].*\\\[LIBRARY OPTIONS\\\].*\\\[SYMBOL SELECTION OPTIONS\\\].*\\\[RUNTIME OPTIONS\\\].*\\\[GRANULARITY OPTIONS\\\].*\\\[DYNINST OPTIONS\\\].*" ) # on RedHat, /usr/bin/ls is a script for `coreutils --coreutils-prog=ls` @@ -130,7 +130,7 @@ else() endif() omnitrace_add_bin_test( - NAME omnitrace-instrument-simulate-ls + NAME rocprof-sys-instrument-simulate-ls TARGET omnitrace-instrument ARGS --simulate --print-format @@ -147,16 +147,16 @@ omnitrace_add_bin_test( TIMEOUT 240) omnitrace_add_bin_test( - NAME omnitrace-instrument-simulate-ls-check - DEPENDS omnitrace-instrument-simulate-ls - COMMAND ls omnitrace-tests-output/omnitrace-instrument-simulate-ls/instrumentation + NAME rocprof-sys-instrument-simulate-ls-check + DEPENDS rocprof-sys-instrument-simulate-ls + COMMAND ls omnitrace-tests-output/rocprof-sys-instrument-simulate-ls/instrumentation TIMEOUT 60 PASS_REGEX ".*available.json.*available.txt.*available.xml.*excluded.json.*excluded.txt.*excluded.xml.*instrumented.json.*instrumented.txt.*instrumented.xml.*overlapping.json.*overlapping.txt.*overlapping.xml.*" FAIL_REGEX "No such file or directory|not found|OMNITRACE_ABORT_FAIL_REGEX") omnitrace_add_bin_test( - NAME omnitrace-instrument-simulate-lib + NAME rocprof-sys-instrument-simulate-lib TARGET omnitrace-instrument ARGS --print-available functions -v 2 -- $ LABELS "simulate" @@ -168,14 +168,14 @@ omnitrace_add_bin_test( file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/omnitrace-tests-output/tmp) omnitrace_add_bin_test( - NAME omnitrace-instrument-simulate-lib-basename + NAME rocprof-sys-instrument-simulate-lib-basename TARGET omnitrace-instrument ARGS --print-available functions -v 2 -o - ${PROJECT_BINARY_DIR}/omnitrace-tests-output/omnitrace-instrument-simulate-lib-basename/${CMAKE_SHARED_LIBRARY_PREFIX}$${CMAKE_SHARED_LIBRARY_SUFFIX} + ${PROJECT_BINARY_DIR}/omnitrace-tests-output/rocprof-sys-instrument-simulate-lib-basename/${CMAKE_SHARED_LIBRARY_PREFIX}$${CMAKE_SHARED_LIBRARY_SUFFIX} -- ${CMAKE_SHARED_LIBRARY_PREFIX}$${CMAKE_SHARED_LIBRARY_SUFFIX} LABELS "simulate" @@ -183,7 +183,7 @@ omnitrace_add_bin_test( WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/omnitrace-tests-output/tmp) omnitrace_add_bin_test( - NAME omnitrace-instrument-write-log + NAME rocprof-sys-instrument-write-log TARGET omnitrace-instrument ARGS --print-instrumented functions @@ -199,10 +199,10 @@ omnitrace_add_bin_test( PASS_REGEX "Opening .*/instrumentation/user.log") omnitrace_add_bin_test( - NAME omnitrace-instrument-write-log-check - DEPENDS omnitrace-instrument-write-log + NAME rocprof-sys-instrument-write-log-check + DEPENDS rocprof-sys-instrument-write-log COMMAND ls - omnitrace-tests-output/omnitrace-instrument-write-log/instrumentation/user.log + omnitrace-tests-output/rocprof-sys-instrument-write-log/instrumentation/user.log LABELS "log" TIMEOUT 60 PASS_REGEX "user.log" diff --git a/source/lib/omnitrace-dl/dl.cpp b/source/lib/omnitrace-dl/dl.cpp index c285120d3..6683500e9 100644 --- a/source/lib/omnitrace-dl/dl.cpp +++ b/source/lib/omnitrace-dl/dl.cpp @@ -1361,10 +1361,10 @@ verify_instrumented_preloaded() mpirun -n 2 omnitrace-run -- Note: the command-line arguments passed to 'omnitrace-run' (which are specified before the double hyphen) will override configuration variables - and/or any configuration values specified to 'omnitrace-instrument' via the '--config' or '--env' options. + and/or any configuration values specified to 'rocprof-sys-instrument' via the '--config' or '--env' options. E.g.: - $ omnitrace-instrument -o ./sleep.inst --env OMNITRACE_SAMPLING_DELAY=5.0 -- sleep + $ rocprof-sys-instrument -o ./sleep.inst --env OMNITRACE_SAMPLING_DELAY=5.0 -- sleep $ echo "OMNITRACE_SAMPLING_FREQ = 500" > omnitrace.cfg $ export OMNITRACE_CONFIG_FILE=omnitrace.cfg $ omnitrace-run --sampling-freq=100 --sampling-delay=1.0 -- ./sleep.inst 10 From 2f52e2f9afa3125369cfff3023f35afdc54280fb Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Sat, 14 Sep 2024 10:41:22 -0400 Subject: [PATCH 18/39] Update test-install test names --- .github/workflows/opensuse.yml | 10 ++++---- .github/workflows/redhat.yml | 2 +- .github/workflows/ubuntu-focal.yml | 12 ++++----- .github/workflows/ubuntu-jammy.yml | 2 +- scripts/test-install.sh | 40 +++++++++++++++--------------- 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/.github/workflows/opensuse.yml b/.github/workflows/opensuse.yml index f23cc4714..3d292468d 100644 --- a/.github/workflows/opensuse.yml +++ b/.github/workflows/opensuse.yml @@ -117,14 +117,14 @@ jobs: rocprof-sys-avail -a which omnitrace ldd $(which omnitrace) - omnitrace-instrument --help - omnitrace-instrument -e -v 1 -o ls.inst --simulate -- ls + rocprof-sys-instrument --help + rocprof-sys-instrument -e -v 1 -o ls.inst --simulate -- ls for i in $(find omnitrace-ls.inst-output -type f); do echo -e "\n\n --> ${i} \n\n"; cat ${i}; done - omnitrace-instrument -e -v 1 -o ls.inst -- ls + rocprof-sys-instrument -e -v 1 -o ls.inst -- ls omnitrace-run -- ./ls.inst - omnitrace-instrument -e -v 1 --simulate -- ls + rocprof-sys-instrument -e -v 1 --simulate -- ls for i in $(find omnitrace-ls-output -type f); do echo -e "\n\n --> ${i} \n\n"; cat ${i}; done - omnitrace-instrument -e -v 1 -- ls + rocprof-sys-instrument -e -v 1 -- ls - name: Test User API timeout-minutes: 10 diff --git a/.github/workflows/redhat.yml b/.github/workflows/redhat.yml index 474dac56a..43aa7b844 100644 --- a/.github/workflows/redhat.yml +++ b/.github/workflows/redhat.yml @@ -138,7 +138,7 @@ jobs: run: | set -v source /opt/omnitrace/share/omnitrace/setup-env.sh - ./scripts/test-install.sh --test-omnitrace-{instrument,avail,sample,rewrite,runtime,python}=1 + ./scripts/test-install.sh --test-rocprof-sys-{instrument,avail,sample,rewrite,runtime,python}=1 - name: Test User API timeout-minutes: 10 diff --git a/.github/workflows/ubuntu-focal.yml b/.github/workflows/ubuntu-focal.yml index 8d708d076..a44512e18 100644 --- a/.github/workflows/ubuntu-focal.yml +++ b/.github/workflows/ubuntu-focal.yml @@ -170,7 +170,7 @@ jobs: module load omnitrace echo $(which omnitrace) ldd $(which omnitrace) - omnitrace-instrument --help + rocprof-sys-instrument --help rocprof-sys-avail --help rocprof-sys-sample --help @@ -182,7 +182,7 @@ jobs: source ./share/omnitrace/setup-env.sh echo $(which omnitrace) ldd $(which omnitrace) - omnitrace-instrument --help + rocprof-sys-instrument --help rocprof-sys-avail --help rocprof-sys-sample --help @@ -199,7 +199,7 @@ jobs: module use /opt/omnitrace/share/modulefiles module avail module load omnitrace - ./scripts/test-install.sh --test-omnitrace-{instrument,avail,sample,rewrite,runtime}=1 --test-omnitrace-python=${{ matrix.python }} + ./scripts/test-install.sh --test-rocprof-sys-{instrument,avail,sample,rewrite,runtime}=1 --test-omnitrace-python=${{ matrix.python }} - name: Test User API timeout-minutes: 10 @@ -359,7 +359,7 @@ jobs: shell: bash run: | source /opt/omnitrace/share/omnitrace/setup-env.sh - ./scripts/test-install.sh --test-omnitrace-{instrument,avail,sample,python,rewrite,runtime}=1 + ./scripts/test-install.sh --test-rocprof-sys-{instrument,avail,sample,python,rewrite,runtime}=1 - name: Test User API timeout-minutes: 10 @@ -523,7 +523,7 @@ jobs: run: | set -v source /opt/omnitrace/share/omnitrace/setup-env.sh - ${{ github.workspace }}/scripts/test-install.sh --test-omnitrace-{instrument,avail,sample,python,rewrite,runtime}=1 + ${{ github.workspace }}/scripts/test-install.sh --test-rocprof-sys-{instrument,avail,sample,python,rewrite,runtime}=1 - name: Test Install with Modulefile timeout-minutes: 15 @@ -532,7 +532,7 @@ jobs: source /usr/share/modules/init/$(basename ${SHELL}) module use /opt/omnitrace/share/modulefiles module load omnitrace - ${{ github.workspace }}/scripts/test-install.sh --test-omnitrace-{instrument,avail,sample,python,rewrite,runtime}=1 + ${{ github.workspace }}/scripts/test-install.sh --test-rocprof-sys-{instrument,avail,sample,python,rewrite,runtime}=1 - name: Test User API timeout-minutes: 10 diff --git a/.github/workflows/ubuntu-jammy.yml b/.github/workflows/ubuntu-jammy.yml index edaae62e9..ec8713775 100644 --- a/.github/workflows/ubuntu-jammy.yml +++ b/.github/workflows/ubuntu-jammy.yml @@ -220,7 +220,7 @@ jobs: module use /opt/omnitrace/share/modulefiles module avail module load omnitrace - ./scripts/test-install.sh --test-omnitrace-{instrument,avail,sample,python,rewrite,runtime}=1 + ./scripts/test-install.sh --test-rocprof-sys-{instrument,avail,sample,python,rewrite,runtime}=1 - name: Test User API timeout-minutes: 10 diff --git a/scripts/test-install.sh b/scripts/test-install.sh index 57b101d3b..ced990e8a 100755 --- a/scripts/test-install.sh +++ b/scripts/test-install.sh @@ -45,15 +45,15 @@ fi usage() { - print_option() { printf " --%-10s %-24s %s (default: %s)\n" "${1}" "${2}" "${3}" "${4}"; } + print_option() { printf " --%-10s %-30s %s (default: %s)\n" "${1}" "${2}" "${3}" "${4}"; } echo "Options:" print_option source-dir "" "Location of source directory" "${SOURCE_DIR}" - print_option test-omnitrace-instrument "0|1" "Enable testing omnitrace-instrument exe" "${ENABLE_OMNITRACE_INSTRUMENT}" + print_option test-rocprof-sys-instrument "0|1" "Enable testing rocprof-sys-instrument exe" "${ENABLE_OMNITRACE_INSTRUMENT}" print_option test-rocprof-sys-avail "0|1" "Enable testing rocprof-sys-avail" "${ENABLE_OMNITRACE_AVAIL}" print_option test-rocprof-sys-sample "0|1" "Enable testing rocprof-sys-sample" "${ENABLE_OMNITRACE_SAMPLE}" - print_option test-omnitrace-python "0|1" "Enable testing omnitrace-python" "${ENABLE_OMNITRACE_PYTHON}" - print_option test-omnitrace-rewrite "0|1" "Enable testing omnitrace-instrument binary rewrite" "${ENABLE_OMNITRACE_REWRITE}" - print_option test-omnitrace-runtime "0|1" "Enable testing omnitrace-instrument runtime instrumentation" "${ENABLE_OMNITRACE_RUNTIME}" + print_option test-rocprof-sys-python "0|1" "Enable testing rocprof-sys-python" "${ENABLE_OMNITRACE_PYTHON}" + print_option test-rocprof-sys-rewrite "0|1" "Enable testing rocprof-sys-instrument binary rewrite" "${ENABLE_OMNITRACE_REWRITE}" + print_option test-rocprof-sys-runtime "0|1" "Enable testing rocprof-sys-instrument runtime instrumentation" "${ENABLE_OMNITRACE_RUNTIME}" } cat << EOF > ${CONFIG_DIR}/omnitrace.cfg @@ -100,7 +100,7 @@ do fi case "${ARG}" in - --test-omnitrace-instrument) + --test-rocprof-sys-instrument) ENABLE_OMNITRACE_INSTRUMENT=${VAL} continue ;; @@ -112,15 +112,15 @@ do ENABLE_OMNITRACE_SAMPLE=${VAL} continue ;; - --test-omnitrace-python) + --test-rocprof-sys-python) ENABLE_OMNITRACE_PYTHON=${VAL} continue ;; - --test-omnitrace-rewrite) + --test-rocprof-sys-rewrite) ENABLE_OMNITRACE_REWRITE=${VAL} continue ;; - --test-omnitrace-runtime) + --test-rocprof-sys-runtime) ENABLE_OMNITRACE_RUNTIME=${VAL} continue ;; @@ -140,7 +140,7 @@ test-omnitrace() { verbose-run which omnitrace verbose-run ldd $(which omnitrace) - verbose-run omnitrace-instrument --help + verbose-run rocprof-sys-instrument --help } test-rocprof-sys-avail() @@ -159,7 +159,7 @@ test-rocprof-sys-sample() verbose-run rocprof-sys-sample --cputime 100 --realtime 50 --hsa-interrupt 0 -TPH -- python3 ${SOURCE_DIR}/examples/python/external.py -n 5 -v 20 } -test-omnitrace-python() +test-rocprof-sys-python() { verbose-run which omnitrace-python verbose-run omnitrace-python --help @@ -169,7 +169,7 @@ test-omnitrace-python() verbose-run python3 ${SOURCE_DIR}/examples/python/source.py -n 5 -v 5 } -test-omnitrace-rewrite() +test-rocprof-sys-rewrite() { if [ -f /usr/bin/coreutils ]; then local LS_NAME=coreutils @@ -178,13 +178,13 @@ test-omnitrace-rewrite() local LS_NAME=ls local LS_ARGS="" fi - verbose-run omnitrace-instrument -e -v 1 -o ${CONFIG_DIR}/ls.inst --simulate -- ${LS_NAME} + verbose-run rocprof-sys-instrument -e -v 1 -o ${CONFIG_DIR}/ls.inst --simulate -- ${LS_NAME} for i in $(find ${CONFIG_DIR}/omnitrace-tests-output/ls.inst -type f); do verbose-run ls ${i}; done - verbose-run omnitrace-instrument -e -v 1 -o ${CONFIG_DIR}/ls.inst -- ${LS_NAME} + verbose-run rocprof-sys-instrument -e -v 1 -o ${CONFIG_DIR}/ls.inst -- ${LS_NAME} verbose-run omnitrace-run -- ${CONFIG_DIR}/ls.inst ${LS_ARGS} } -test-omnitrace-runtime() +test-rocprof-sys-runtime() { if [ -f /usr/bin/coreutils ]; then local LS_NAME=coreutils @@ -193,14 +193,14 @@ test-omnitrace-runtime() local LS_NAME=ls local LS_ARGS="" fi - verbose-run omnitrace-instrument -e -v 1 --simulate -- ${LS_NAME} ${LS_ARGS} + verbose-run rocprof-sys-instrument -e -v 1 --simulate -- ${LS_NAME} ${LS_ARGS} for i in $(find ${CONFIG_DIR}/omnitrace-tests-output/$(basename ${LS_NAME}) -type f); do verbose-run ls ${i}; done - verbose-run omnitrace-instrument -e -v 1 -- ${LS_NAME} ${LS_ARGS} + verbose-run rocprof-sys-instrument -e -v 1 -- ${LS_NAME} ${LS_ARGS} } if [ "${ENABLE_OMNITRACE_INSTRUMENT}" -ne 0 ]; then verbose-run test-omnitrace; fi if [ "${ENABLE_OMNITRACE_AVAIL}" -ne 0 ]; then verbose-run test-rocprof-sys-avail; fi if [ "${ENABLE_OMNITRACE_SAMPLE}" -ne 0 ]; then verbose-run test-rocprof-sys-sample; fi -if [ "${ENABLE_OMNITRACE_PYTHON}" -ne 0 ]; then verbose-run test-omnitrace-python; fi -if [ "${ENABLE_OMNITRACE_REWRITE}" -ne 0 ]; then verbose-run test-omnitrace-rewrite; fi -if [ "${ENABLE_OMNITRACE_RUNTIME}" -ne 0 ]; then verbose-run test-omnitrace-runtime; fi +if [ "${ENABLE_OMNITRACE_PYTHON}" -ne 0 ]; then verbose-run test-rocprof-sys-python; fi +if [ "${ENABLE_OMNITRACE_REWRITE}" -ne 0 ]; then verbose-run test-rocprof-sys-rewrite; fi +if [ "${ENABLE_OMNITRACE_RUNTIME}" -ne 0 ]; then verbose-run test-rocprof-sys-runtime; fi From 4050dfd451c434dd3b1caaa81888b99f0cd8d5a1 Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Sat, 14 Sep 2024 11:39:02 -0400 Subject: [PATCH 19/39] Update tests Instead of using `$(which omnitrace)` use `$(which rocprof-sys-instrument)`, since the solo `omnitrace` binary has been deprecated. --- .github/workflows/opensuse.yml | 4 ++-- .github/workflows/ubuntu-focal.yml | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/opensuse.yml b/.github/workflows/opensuse.yml index 3d292468d..a859169c3 100644 --- a/.github/workflows/opensuse.yml +++ b/.github/workflows/opensuse.yml @@ -115,8 +115,8 @@ jobs: ldd $(which rocprof-sys-avail) rocprof-sys-avail --help rocprof-sys-avail -a - which omnitrace - ldd $(which omnitrace) + which rocprof-sys-instrument + ldd $(which rocprof-sys-instrument) rocprof-sys-instrument --help rocprof-sys-instrument -e -v 1 -o ls.inst --simulate -- ls for i in $(find omnitrace-ls.inst-output -type f); do echo -e "\n\n --> ${i} \n\n"; cat ${i}; done diff --git a/.github/workflows/ubuntu-focal.yml b/.github/workflows/ubuntu-focal.yml index a44512e18..db8fcdff9 100644 --- a/.github/workflows/ubuntu-focal.yml +++ b/.github/workflows/ubuntu-focal.yml @@ -168,8 +168,8 @@ jobs: module use ./share/modulefiles module avail module load omnitrace - echo $(which omnitrace) - ldd $(which omnitrace) + echo $(which rocprof-sys-instrument) + ldd $(which rocprof-sys-instrument) rocprof-sys-instrument --help rocprof-sys-avail --help rocprof-sys-sample --help @@ -180,8 +180,8 @@ jobs: run: | cd build source ./share/omnitrace/setup-env.sh - echo $(which omnitrace) - ldd $(which omnitrace) + echo $(which rocprof-sys-instrument) + ldd $(which rocprof-sys-instrument) rocprof-sys-instrument --help rocprof-sys-avail --help rocprof-sys-sample --help From 13d1a3a043e228d3045663b6127911935db9748a Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Sat, 14 Sep 2024 13:24:14 -0400 Subject: [PATCH 20/39] Rename omnitrace-run binary --- .github/workflows/opensuse.yml | 2 +- scripts/test-install.sh | 2 +- source/bin/omnitrace-exe/omnitrace.cpp | 4 ++-- source/bin/omnitrace-run/CMakeLists.txt | 3 ++- source/bin/omnitrace-run/impl.cpp | 6 +++--- source/bin/tests/CMakeLists.txt | 10 +++++----- source/lib/omnitrace-dl/dl.cpp | 22 ++++++++++++---------- 7 files changed, 26 insertions(+), 23 deletions(-) diff --git a/.github/workflows/opensuse.yml b/.github/workflows/opensuse.yml index a859169c3..8defc8dad 100644 --- a/.github/workflows/opensuse.yml +++ b/.github/workflows/opensuse.yml @@ -121,7 +121,7 @@ jobs: rocprof-sys-instrument -e -v 1 -o ls.inst --simulate -- ls for i in $(find omnitrace-ls.inst-output -type f); do echo -e "\n\n --> ${i} \n\n"; cat ${i}; done rocprof-sys-instrument -e -v 1 -o ls.inst -- ls - omnitrace-run -- ./ls.inst + rocprof-sys-run -- ./ls.inst rocprof-sys-instrument -e -v 1 --simulate -- ls for i in $(find omnitrace-ls-output -type f); do echo -e "\n\n --> ${i} \n\n"; cat ${i}; done rocprof-sys-instrument -e -v 1 -- ls diff --git a/scripts/test-install.sh b/scripts/test-install.sh index ced990e8a..c759bfd97 100755 --- a/scripts/test-install.sh +++ b/scripts/test-install.sh @@ -181,7 +181,7 @@ test-rocprof-sys-rewrite() verbose-run rocprof-sys-instrument -e -v 1 -o ${CONFIG_DIR}/ls.inst --simulate -- ${LS_NAME} for i in $(find ${CONFIG_DIR}/omnitrace-tests-output/ls.inst -type f); do verbose-run ls ${i}; done verbose-run rocprof-sys-instrument -e -v 1 -o ${CONFIG_DIR}/ls.inst -- ${LS_NAME} - verbose-run omnitrace-run -- ${CONFIG_DIR}/ls.inst ${LS_ARGS} + verbose-run rocprof-sys-run -- ${CONFIG_DIR}/ls.inst ${LS_ARGS} } test-rocprof-sys-runtime() diff --git a/source/bin/omnitrace-exe/omnitrace.cpp b/source/bin/omnitrace-exe/omnitrace.cpp index 25dbd0f9c..ca2619ca5 100644 --- a/source/bin/omnitrace-exe/omnitrace.cpp +++ b/source/bin/omnitrace-exe/omnitrace.cpp @@ -66,7 +66,7 @@ main(int argc, char** argv) gggggg - OmniTrace has renamed the "omnitrace" executable to "rocprof-sys-instrument" to reduce confusion. + ROCm Systems Profiler has renamed the "omnitrace" executable to "rocprof-sys-instrument" to reduce confusion. This executable only exists to provide this deprecation warning and maintain backwards compatibility for a few releases. This executable will soon invoke "rocprof-sys-instrument" with the arguments you just provided after we've given you @@ -76,7 +76,7 @@ main(int argc, char** argv) If you are running this job non-interactively, we will resume executing after ~1 minute unless CI or OMNITRACE_CI is defined in the environment, in which case, we will throw an error. - Thanks for using OmniTrace and happy optimizing! + Thanks for using ROCm Systems Profiler and happy optimizing! )warning"; auto _completed = std::promise{}; diff --git a/source/bin/omnitrace-run/CMakeLists.txt b/source/bin/omnitrace-run/CMakeLists.txt index 63054bcc8..95bd80ec7 100644 --- a/source/bin/omnitrace-run/CMakeLists.txt +++ b/source/bin/omnitrace-run/CMakeLists.txt @@ -18,7 +18,8 @@ target_link_libraries( omnitrace::omnitrace-sanitizer) set_target_properties( omnitrace-run PROPERTIES BUILD_RPATH "\$ORIGIN:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}" - INSTALL_RPATH "${OMNITRACE_EXE_INSTALL_RPATH}") + INSTALL_RPATH "${OMNITRACE_EXE_INSTALL_RPATH}" + OUTPUT_NAME "rocprof-sys-run") omnitrace_strip_target(omnitrace-run) diff --git a/source/bin/omnitrace-run/impl.cpp b/source/bin/omnitrace-run/impl.cpp index ae3f486c2..1232e76f5 100644 --- a/source/bin/omnitrace-run/impl.cpp +++ b/source/bin/omnitrace-run/impl.cpp @@ -176,7 +176,7 @@ prepare_command_for_run(char* _exe, parser_data_t& _data) if(!_injected) { throw std::runtime_error( - join("", "omnitrace-run was unable to match \"", _data.launcher, + join("", "rocprof-sys-run was unable to match \"", _data.launcher, "\" to any arguments on the command line: \"", join(array_config{ " ", "", "" }, _data.command), "\"")); } @@ -292,8 +292,8 @@ parse_args(int argc, char** argv, parser_data_t& _parser_data, bool& _fork_exec) exit(EXIT_FAILURE); }); - parser.enable_help("", "Usage: omnitrace-run -- "); - parser.enable_version("omnitrace-run", OMNITRACE_ARGPARSE_VERSION_INFO); + parser.enable_help("", "Usage: rocprof-sys-run -- "); + parser.enable_version("rocprof-sys-run", OMNITRACE_ARGPARSE_VERSION_INFO); auto _cols = std::get<0>(console::get_columns()); if(_cols > parser.get_help_width() + 8) diff --git a/source/bin/tests/CMakeLists.txt b/source/bin/tests/CMakeLists.txt index 32478225d..8a6eee3f6 100644 --- a/source/bin/tests/CMakeLists.txt +++ b/source/bin/tests/CMakeLists.txt @@ -375,11 +375,11 @@ omnitrace_add_bin_test( ) omnitrace_add_bin_test( - NAME omnitrace-run-help + NAME rocprof-sys-run-help TARGET omnitrace-run ARGS --help TIMEOUT 45 - LABELS "omnitrace-run") + LABELS "rocprof-sys-run") file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/omnitrace-tests-config") file( @@ -396,7 +396,7 @@ set_target_properties( ${PROJECT_BINARY_DIR}/bin/testing) omnitrace_add_bin_test( - NAME omnitrace-run-args + NAME rocprof-sys-run-args TARGET omnitrace-run ARGS --monochrome --debug=false @@ -406,7 +406,7 @@ omnitrace_add_bin_test( %env{TWD}%/omnitrace-tests-config/empty.cfg -o omnitrace-tests-output - omnitrace-run-args-output/ + rocprof-sys-run-args-output/ -TPHD -S cputime @@ -489,4 +489,4 @@ omnitrace_add_bin_test( $ 5 TIMEOUT 45 - LABELS "omnitrace-run") + LABELS "rocprof-sys-run") diff --git a/source/lib/omnitrace-dl/dl.cpp b/source/lib/omnitrace-dl/dl.cpp index 6683500e9..014e40121 100644 --- a/source/lib/omnitrace-dl/dl.cpp +++ b/source/lib/omnitrace-dl/dl.cpp @@ -1345,11 +1345,13 @@ verify_instrumented_preloaded() \____/|_| |_|_| \_|_____| |_| |_| \_\/_/ \_\_____|______| |_| \_\\____/|_| \_| - Due to a variety of edge cases we've encountered, OmniTrace now requires that binary rewritten executables and libraries be launched - with the 'omnitrace-run' executable. + Due to a variety of edge cases we've encountered, ROCm Systems Profiller now requires that binary rewritten + executables and libraries be launched with the 'rocprof-sys-run' executable. - In order to launch the executable with 'omnitrace-run', prefix the current command with 'omnitrace-run' and a standalone double hyphen ('--'). - For MPI applications, place 'omnitrace-run --' after the MPI command. + In order to launch the executable with 'rocprof-sys-run', prefix the current command with 'rocprof-sys-run' + and a standalone double hyphen ('--'). + + For MPI applications, place 'rocprof-sys-run --' after the MPI command. E.g.: @@ -1357,23 +1359,23 @@ verify_instrumented_preloaded() should be: - omnitrace-run -- - mpirun -n 2 omnitrace-run -- + rocprof-sys-run -- + mpirun -n 2 rocprof-sys-run -- - Note: the command-line arguments passed to 'omnitrace-run' (which are specified before the double hyphen) will override configuration variables + Note: the command-line arguments passed to 'rocprof-sys-run' (which are specified before the double hyphen) will override configuration variables and/or any configuration values specified to 'rocprof-sys-instrument' via the '--config' or '--env' options. E.g.: $ rocprof-sys-instrument -o ./sleep.inst --env OMNITRACE_SAMPLING_DELAY=5.0 -- sleep $ echo "OMNITRACE_SAMPLING_FREQ = 500" > omnitrace.cfg $ export OMNITRACE_CONFIG_FILE=omnitrace.cfg - $ omnitrace-run --sampling-freq=100 --sampling-delay=1.0 -- ./sleep.inst 10 + $ rocprof-sys-run --sampling-freq=100 --sampling-delay=1.0 -- ./sleep.inst 10 In the first command, a default sampling delay of 5 seconds in embedded into the instrumented 'sleep.inst'. - In the second command, the sampling frequency will be set to 500 interrupts per second when OmniTrace reads the config file + In the second command, the sampling frequency will be set to 500 interrupts per second when ROCm Systems Profiller reads the config file In the fourth command, the sampling frequency and sampling delay are overridden to 100 interrupts per second and 1 second, respectively, when sleep.inst runs - Thanks for using OmniTrace and happy optimizing! + Thanks for using ROCm Systems Profiler and happy optimizing! )notice"; // emit notice From 49aa5877bd4bfb911f13044cde9815f0f5346d63 Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Mon, 23 Sep 2024 15:10:27 -0400 Subject: [PATCH 21/39] Rename omnitrace-python binary, python module, and tests Signed-off-by: David Galiffi --- .github/workflows/ubuntu-focal.yml | 2 +- examples/code-coverage/code-coverage.py | 14 +++++----- examples/python/fill.py | 8 +++--- examples/python/source-numpy.py | 8 +++--- examples/python/source.py | 8 +++--- scripts/test-install.sh | 20 +++++++------- source/python/CMakeLists.txt | 26 +++++++++---------- .../{omnitrace => rocprofsys}/__init__.py | 8 +++--- .../{omnitrace => rocprofsys}/__main__.py | 16 ++++++------ .../{omnitrace => rocprofsys}/common.py | 8 +++--- .../{omnitrace => rocprofsys}/profiler.py | 8 +++--- .../python/{omnitrace => rocprofsys}/user.py | 8 +++--- source/python/setup.cfg.in | 6 ++--- source/python/setup.py.in | 6 ++--- tests/omnitrace-testing.cmake | 4 +-- 15 files changed, 75 insertions(+), 75 deletions(-) rename source/python/{omnitrace => rocprofsys}/__init__.py (93%) rename source/python/{omnitrace => rocprofsys}/__main__.py (96%) rename source/python/{omnitrace => rocprofsys}/common.py (95%) rename source/python/{omnitrace => rocprofsys}/profiler.py (97%) rename source/python/{omnitrace => rocprofsys}/user.py (95%) diff --git a/.github/workflows/ubuntu-focal.yml b/.github/workflows/ubuntu-focal.yml index db8fcdff9..7b24c97d7 100644 --- a/.github/workflows/ubuntu-focal.yml +++ b/.github/workflows/ubuntu-focal.yml @@ -199,7 +199,7 @@ jobs: module use /opt/omnitrace/share/modulefiles module avail module load omnitrace - ./scripts/test-install.sh --test-rocprof-sys-{instrument,avail,sample,rewrite,runtime}=1 --test-omnitrace-python=${{ matrix.python }} + ./scripts/test-install.sh --test-rocprof-sys-{instrument,avail,sample,rewrite,runtime}=1 --test-rocprof-sys-python=${{ matrix.python }} - name: Test User API timeout-minutes: 10 diff --git a/examples/code-coverage/code-coverage.py b/examples/code-coverage/code-coverage.py index efd2f2da9..9dae8beef 100644 --- a/examples/code-coverage/code-coverage.py +++ b/examples/code-coverage/code-coverage.py @@ -1,6 +1,6 @@ #!@PYTHON_EXECUTABLE@ -import omnitrace +import rocprofsys import argparse if __name__ == "__main__": @@ -28,15 +28,15 @@ data = None for itr in args.input: - _summary, _details = omnitrace.coverage.load(itr) + _summary, _details = rocprofsys.coverage.load(itr) if data is None: data = _details else: - data = omnitrace.coverage.concat(data, _details) + data = rocprofsys.coverage.concat(data, _details) - summary = omnitrace.coverage.get_summary(data) - top = omnitrace.coverage.get_top(data) - bottom = omnitrace.coverage.get_bottom(data) + summary = rocprofsys.coverage.get_summary(data) + top = rocprofsys.coverage.get_top(data) + bottom = rocprofsys.coverage.get_bottom(data) print("Top code coverage:") for itr in top: @@ -51,4 +51,4 @@ ) print("\nSaving code coverage") - omnitrace.coverage.save(summary, data, args.output) + rocprofsys.coverage.save(summary, data, args.output) diff --git a/examples/python/fill.py b/examples/python/fill.py index 373e3f34f..c1d5de1bb 100755 --- a/examples/python/fill.py +++ b/examples/python/fill.py @@ -3,9 +3,9 @@ import os import sys import time -import omnitrace -from omnitrace.user import region as omni_user_region -from omnitrace.profiler import config as omni_config +import rocprofsys +from rocprofsys.user import region as omni_user_region +from rocprofsys.profiler import config as omni_config _prefix = "" @@ -14,7 +14,7 @@ def loop(n): pass -@omnitrace.profile() +@rocprofsys.profile() def run(i, n, v): for l in range(n * n): loop(v + l) diff --git a/examples/python/source-numpy.py b/examples/python/source-numpy.py index 2979ae26c..c00874924 100755 --- a/examples/python/source-numpy.py +++ b/examples/python/source-numpy.py @@ -3,8 +3,8 @@ import os import sys import time -import omnitrace -from omnitrace.user import region as omni_user_region +import rocprofsys +from rocprofsys.user import region as omni_user_region _prefix = "" @@ -50,7 +50,7 @@ def inefficient(n): return _ret -@omnitrace.profile() +@rocprofsys.profile() def run(n): _ret = 0 _ret += fib(n) @@ -78,6 +78,6 @@ def run(n): for i in range(args.num_iterations): with omni_user_region(f"main_loop"): if args.stop_profile > 0 and i == args.stop_profile: - omnitrace.user.stop_trace() + rocprofsys.user.stop_trace() ans = run(args.value) print(f"[{_prefix}] [{i}] result of run({args.value}) = {ans}\n") diff --git a/examples/python/source.py b/examples/python/source.py index 44efbe484..3ec7b9445 100755 --- a/examples/python/source.py +++ b/examples/python/source.py @@ -3,8 +3,8 @@ import os import sys import time -import omnitrace -from omnitrace.user import region as omni_user_region +import rocprofsys +from rocprofsys.user import region as omni_user_region import random _prefix = "" @@ -33,7 +33,7 @@ def inefficient(n): return _ret -@omnitrace.profile() +@rocprofsys.profile() def run(n): _ret = 0 _ret += fib(n) @@ -61,6 +61,6 @@ def run(n): for i in range(args.num_iterations): with omni_user_region(f"main_loop"): if args.stop_profile > 0 and i == args.stop_profile: - omnitrace.user.stop_trace() + rocprofsys.user.stop_trace() ans = run(args.value) print(f"[{_prefix}] [{i}] result of run({args.value}) = {ans}\n") diff --git a/scripts/test-install.sh b/scripts/test-install.sh index c759bfd97..cb19d35e6 100755 --- a/scripts/test-install.sh +++ b/scripts/test-install.sh @@ -48,7 +48,7 @@ usage() print_option() { printf " --%-10s %-30s %s (default: %s)\n" "${1}" "${2}" "${3}" "${4}"; } echo "Options:" print_option source-dir "" "Location of source directory" "${SOURCE_DIR}" - print_option test-rocprof-sys-instrument "0|1" "Enable testing rocprof-sys-instrument exe" "${ENABLE_OMNITRACE_INSTRUMENT}" + print_option test-rocprof-sys-instrument "0|1" "Enable testing rocprof-sys-instrument" "${ENABLE_OMNITRACE_INSTRUMENT}" print_option test-rocprof-sys-avail "0|1" "Enable testing rocprof-sys-avail" "${ENABLE_OMNITRACE_AVAIL}" print_option test-rocprof-sys-sample "0|1" "Enable testing rocprof-sys-sample" "${ENABLE_OMNITRACE_SAMPLE}" print_option test-rocprof-sys-python "0|1" "Enable testing rocprof-sys-python" "${ENABLE_OMNITRACE_PYTHON}" @@ -136,10 +136,10 @@ do esac done -test-omnitrace() +test-rocprof-sys-instrument() { - verbose-run which omnitrace - verbose-run ldd $(which omnitrace) + verbose-run which rocprof-sys-instrument + verbose-run ldd $(which rocprof-sys-instrument) verbose-run rocprof-sys-instrument --help } @@ -161,11 +161,11 @@ test-rocprof-sys-sample() test-rocprof-sys-python() { - verbose-run which omnitrace-python - verbose-run omnitrace-python --help - verbose-run omnitrace-python -b -- ${SOURCE_DIR}/examples/python/builtin.py -n 5 -v 5 - verbose-run omnitrace-python -b -- ${SOURCE_DIR}/examples/python/noprofile.py -n 5 -v 5 - verbose-run omnitrace-python -- ${SOURCE_DIR}/examples/python/external.py -n 5 -v 5 + verbose-run which rocprof-sys-python + verbose-run rocprof-sys-python --help + verbose-run rocprof-sys-python -b -- ${SOURCE_DIR}/examples/python/builtin.py -n 5 -v 5 + verbose-run rocprof-sys-python -b -- ${SOURCE_DIR}/examples/python/noprofile.py -n 5 -v 5 + verbose-run rocprof-sys-python -- ${SOURCE_DIR}/examples/python/external.py -n 5 -v 5 verbose-run python3 ${SOURCE_DIR}/examples/python/source.py -n 5 -v 5 } @@ -198,7 +198,7 @@ test-rocprof-sys-runtime() verbose-run rocprof-sys-instrument -e -v 1 -- ${LS_NAME} ${LS_ARGS} } -if [ "${ENABLE_OMNITRACE_INSTRUMENT}" -ne 0 ]; then verbose-run test-omnitrace; fi +if [ "${ENABLE_OMNITRACE_INSTRUMENT}" -ne 0 ]; then verbose-run test-rocprof-sys-instrument; fi if [ "${ENABLE_OMNITRACE_AVAIL}" -ne 0 ]; then verbose-run test-rocprof-sys-avail; fi if [ "${ENABLE_OMNITRACE_SAMPLE}" -ne 0 ]; then verbose-run test-rocprof-sys-sample; fi if [ "${ENABLE_OMNITRACE_PYTHON}" -ne 0 ]; then verbose-run test-rocprof-sys-python; fi diff --git a/source/python/CMakeLists.txt b/source/python/CMakeLists.txt index eaad46f97..4f5dbd128 100644 --- a/source/python/CMakeLists.txt +++ b/source/python/CMakeLists.txt @@ -28,16 +28,16 @@ function(OMNITRACE_CONFIGURE_PYTARGET _TARGET _VERSION) PROPERTIES PREFIX "" OUTPUT_NAME libpyomnitrace LIBRARY_OUTPUT_DIRECTORY - ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/omnitrace + ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys ARCHIVE_OUTPUT_DIRECTORY - ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/omnitrace + ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys RUNTIME_OUTPUT_DIRECTORY - ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/omnitrace + ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys PDB_OUTPUT_DIRECTORY - ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/omnitrace + ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys ${EXTRA_PROPERTIES}) - set(_PYLIB ${CMAKE_INSTALL_PYTHONDIR}/omnitrace) + set(_PYLIB ${CMAKE_INSTALL_PYTHONDIR}/rocprofsys) if(NOT IS_ABSOLUTE "${_PYLIB}") set(_PYLIB ${CMAKE_INSTALL_PREFIX}/${_PYLIB}) endif() @@ -54,7 +54,7 @@ function(OMNITRACE_CONFIGURE_PYTARGET _TARGET _VERSION) install( TARGETS ${_TARGET} - DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/omnitrace + DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/rocprofsys OPTIONAL) endfunction() @@ -92,23 +92,23 @@ omnitrace_target_compile_definitions(libpyomnitrace-interface add_custom_target(libpyomnitrace) -file(GLOB_RECURSE PYTHON_FILES ${CMAKE_CURRENT_SOURCE_DIR}/omnitrace/*.py) +file(GLOB_RECURSE PYTHON_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rocprofsys/*.py) foreach(_IN ${PYTHON_FILES}) - string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/omnitrace" - "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/omnitrace" _OUT + string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/rocprofsys" + "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys" _OUT "${_IN}") configure_file(${_IN} ${_OUT} @ONLY) install( FILES ${_OUT} - DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/omnitrace + DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/rocprofsys OPTIONAL) endforeach() -omnitrace_python_console_script("omnitrace-python" "omnitrace") +omnitrace_python_console_script("rocprof-sys-python" "rocprofsys") set(_INDEX 0) foreach(_VERSION ${OMNITRACE_PYTHON_VERSIONS}) - # add_library(libpyomnitrace MODULE ${pysources} ${pyheaders}) + # add_library(libpyrocprofsys MODULE ${pysources} ${pyheaders}) list(GET OMNITRACE_PYTHON_ROOT_DIRS ${_INDEX} Python3_ROOT_DIR) omnitrace_pybind11_add_module( libpyomnitrace-${_VERSION} MODULE @@ -118,7 +118,7 @@ foreach(_VERSION ${OMNITRACE_PYTHON_VERSIONS}) if(OMNITRACE_USE_PYTHON) omnitrace_python_console_script( - "omnitrace-python" "omnitrace" + "rocprof-sys-python" "rocprofsys" VERSION ${_VERSION} ROOT_DIR "${Python3_ROOT_DIR}") endif() diff --git a/source/python/omnitrace/__init__.py b/source/python/rocprofsys/__init__.py similarity index 93% rename from source/python/omnitrace/__init__.py rename to source/python/rocprofsys/__init__.py index 0773cbbeb..e4479dfde 100644 --- a/source/python/omnitrace/__init__.py +++ b/source/python/rocprofsys/__init__.py @@ -1,7 +1,7 @@ #!/usr/bin/env python@_VERSION@ # MIT License # -# Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2024 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,11 +23,11 @@ from __future__ import absolute_import -__author__ = "AMD Research" -__copyright__ = "Copyright 2022, Advanced Micro Devices, Inc." +__author__ = "AMD ROCm" +__copyright__ = "Copyright 2024, Advanced Micro Devices, Inc." __license__ = "MIT" __version__ = "@PROJECT_VERSION@" -__maintainer__ = "AMD Research" +__maintainer__ = "AMD ROCm" __status__ = "Development" """ diff --git a/source/python/omnitrace/__main__.py b/source/python/rocprofsys/__main__.py similarity index 96% rename from source/python/omnitrace/__main__.py rename to source/python/rocprofsys/__main__.py index a4f43ec4e..8bd99883a 100644 --- a/source/python/omnitrace/__main__.py +++ b/source/python/rocprofsys/__main__.py @@ -1,7 +1,7 @@ #!/usr/bin/env python@_VERSION@ # MIT License # -# Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2024 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,11 +23,11 @@ from __future__ import absolute_import -__author__ = "AMD Research" -__copyright__ = "Copyright 2022, Advanced Micro Devices, Inc." +__author__ = "AMD ROCm" +__copyright__ = "Copyright 2024, Advanced Micro Devices, Inc." __license__ = "MIT" __version__ = "@PROJECT_VERSION@" -__maintainer__ = "AMD Research" +__maintainer__ = "AMD ROCm" __status__ = "Development" """ @file __main__.py @@ -102,9 +102,9 @@ def str2bool(v): _default_label.append("line") parser = argparse.ArgumentParser( - "omnitrace", + "rocprofsys", add_help=True, - epilog="usage: {} -m omnitrace --