From 1567085e136b1000b2978d03041ce6f355bc79c8 Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Wed, 16 Oct 2024 14:18:21 -0400 Subject: [PATCH] Promote `amd-staging` to `amd-mainline` (#7) * Prepare for branch renaming. (#367) * Add `amd-staging` and `amd-mainline` to workflow * Update links in documentation to use amd-mainline --------- Signed-off-by: David Galiffi * Update VERSION to 1.12.0 (#387) Bumping version since rocm-rel-6.3.0.1 branched. * Add rocm tag to cpack.yml (#389) * Add rocm tag to cpack.yml * Update softprops/action-gh-release to v2 * Include note about known issue with Perfetto v47.0 and above. (#391) * Reference "Known Issue" next to references of Perfetto. (#393) * And provide workaround link to Perfetto v46.0 Co-authored-by: Peter Park * Rename to ROCm Systems Profiler (rocprof-sys) (#1) Rename to ROCm Systems Profiler (rocprof-sys) * Update documentation requirements (#402) (#5) * Bump rocm-docs-core to 1.8.2 * Remove empty package-ecosystem in dependabot Co-authored-by: Sam Wu <22262939+samjwu@users.noreply.github.com> * Rename Omnitrace to ROCm Systems Profiler (#4) The Omnitrace program is being renamed. Full name: "ROCm Systems Profiler" Package name: "rocprofiler-systems" Binary / Library names: "rocprof-sys-*" --------- Co-authored-by: Xuan Chen Signed-off-by: David Galiffi * External CI: enable CI triggers (#6) --------- Signed-off-by: David Galiffi Co-authored-by: Peter Park Co-authored-by: Sam Wu <22262939+samjwu@users.noreply.github.com> Co-authored-by: Daniel Su --- .azuredevops/rocm-ci.yml | 44 + .cmake-format.yaml | 36 +- .github/dependabot.yml | 5 - .github/workflows/containers.yml | 4 +- .github/workflows/cpack.yml | 8 +- .github/workflows/opensuse.yml | 74 +- .github/workflows/redhat.yml | 44 +- .github/workflows/release.yml | 4 +- .github/workflows/ubuntu-focal.yml | 238 +-- .github/workflows/ubuntu-jammy.yml | 62 +- .gitignore | 4 +- CMakeLists.txt | 296 ++-- LICENSE | 2 +- README.md | 184 +-- cmake/BuildSettings.cmake | 285 ++-- cmake/Compilers.cmake | 46 +- cmake/ConfigCPack.cmake | 137 +- cmake/ConfigInstall.cmake | 32 +- cmake/ElfUtils.cmake | 12 +- cmake/Formatting.cmake | 65 +- cmake/MacroUtilities.cmake | 222 +-- cmake/Modules/FindMPI-Headers.cmake | 2 +- cmake/Modules/FindRCCL-Headers.cmake | 4 +- cmake/Modules/FindROCmVersion.cmake | 4 +- cmake/PAPI.cmake | 206 +-- cmake/Packages.cmake | 529 +++--- cmake/Perfetto.cmake | 144 +- cmake/Templates/args.gn.in | 6 +- cmake/Templates/console-script.in | 2 +- cmake/Templates/modulefile.in | 10 +- ...g.cmake.in => rocprof-sys-config.cmake.in} | 0 ...nstall.py.in => rocprof-sys-install.py.in} | 22 +- cmake/Templates/setup-env.sh.in | 20 +- docs/doxygen/Doxyfile | 16 +- docs/sphinx/requirements.in | 2 +- docs/sphinx/requirements.txt | 50 +- examples/CMakeLists.txt | 15 +- examples/causal-helpers.cmake | 46 +- examples/causal/CMakeLists.txt | 18 +- examples/causal/causal.hpp | 12 +- examples/causal/impl.cpp | 6 +- examples/code-coverage/CMakeLists.txt | 16 +- examples/code-coverage/code-coverage.py | 14 +- examples/fork/CMakeLists.txt | 11 +- examples/fork/fork.cpp | 18 +- examples/lulesh/CMakeLists.txt | 14 +- examples/mpi/CMakeLists.txt | 27 +- examples/openmp/CMakeLists.txt | 29 +- examples/parallel-overhead/CMakeLists.txt | 12 +- examples/python/CMakeLists.txt | 12 +- examples/python/fill.py | 8 +- examples/python/source-numpy.py | 8 +- examples/python/source.py | 8 +- examples/rccl/CMakeLists.txt | 27 +- examples/rewrite-caller/CMakeLists.txt | 12 +- examples/trace-time-window/CMakeLists.txt | 12 +- examples/transpose/CMakeLists.txt | 22 +- examples/transpose/transpose.cpp | 4 +- examples/user-api/CMakeLists.txt | 20 +- examples/user-api/user-api.cpp | 46 +- scripts/build-release.sh | 24 +- scripts/check_copyright.sh | 223 +++ scripts/dl-gen.py | 20 +- scripts/gperftools-cpu-profile.sh | 2 +- ...h-compiler => rocprof-sys-launch-compiler} | 32 +- ...itrace-leak.supp => rocprof-sys-leak.supp} | 0 ...ce-thread.supp => rocprof-sys-thread.supp} | 2 +- scripts/run-ci.py | 11 +- scripts/run-ci.sh | 8 +- scripts/test-find-package.sh | 18 +- scripts/test-install.sh | 152 +- scripts/test-release.sh | 44 +- ....cmake => write-rocprof-sys-install.cmake} | 11 +- source/CMakeLists.txt | 14 +- source/bin/CMakeLists.txt | 25 +- source/bin/omnitrace-causal/CMakeLists.txt | 27 - source/bin/omnitrace-exe/CMakeLists.txt | 23 - .../bin/omnitrace-instrument/CMakeLists.txt | 60 - source/bin/omnitrace-run/CMakeLists.txt | 28 - source/bin/omnitrace-sample/CMakeLists.txt | 25 - .../CMakeLists.txt | 28 +- .../avail.cpp | 26 +- .../avail.hpp | 0 .../common.cpp | 12 +- .../common.hpp | 16 +- .../component_categories.hpp | 0 .../defines.hpp | 0 .../enumerated_list.hpp | 0 .../generate_config.cpp | 45 +- .../generate_config.hpp | 0 .../get_availability.hpp | 0 .../get_categories.hpp | 0 .../info_type.cpp | 0 .../info_type.hpp | 0 source/bin/rocprof-sys-causal/CMakeLists.txt | 31 + .../impl.cpp | 162 +- .../rocprof-sys-causal.cpp} | 4 +- .../rocprof-sys-causal.hpp} | 4 +- source/bin/rocprof-sys-exe/CMakeLists.txt | 25 + .../rocprof-sys.cpp} | 23 +- .../bin/rocprof-sys-instrument/CMakeLists.txt | 62 + .../details.cpp | 36 +- .../function_signature.cpp | 0 .../function_signature.hpp | 0 .../fwd.hpp | 18 +- .../info.hpp | 20 +- .../internal_libs.cpp | 18 +- .../internal_libs.hpp | 0 .../log.cpp | 0 .../log.hpp | 6 +- .../module_function.cpp | 64 +- .../module_function.hpp | 0 .../rocprof-sys-instrument.cpp} | 295 ++-- .../rocprof-sys-instrument.hpp} | 102 +- source/bin/rocprof-sys-run/CMakeLists.txt | 32 + .../impl.cpp | 38 +- .../rocprof-sys-run.cpp} | 17 +- .../rocprof-sys-run.hpp} | 4 +- source/bin/rocprof-sys-sample/CMakeLists.txt | 28 + .../impl.cpp | 236 +-- .../rocprof-sys-sample.cpp} | 4 +- .../rocprof-sys-sample.hpp} | 0 source/bin/tests/CMakeLists.txt | 302 ++-- ...-perfetto.png => rocprof-sys-perfetto.png} | Bin ...ocm-flow.png => rocprof-sys-rocm-flow.png} | Bin ...mnitrace-rocm.png => rocprof-sys-rocm.png} | Bin ...-user-api.png => rocprof-sys-user-api.png} | Bin .../{omnitrace.dox.in => rocprof-sys.dox.in} | 0 source/lib/CMakeLists.txt | 80 +- source/lib/binary/CMakeLists.txt | 16 +- source/lib/binary/address_multirange.cpp | 6 +- source/lib/binary/address_multirange.hpp | 10 +- source/lib/binary/analysis.cpp | 21 +- source/lib/binary/analysis.hpp | 6 +- source/lib/binary/binary_info.hpp | 6 +- source/lib/binary/dwarf_entry.cpp | 34 +- source/lib/binary/dwarf_entry.hpp | 8 +- source/lib/binary/link_map.cpp | 14 +- source/lib/binary/link_map.hpp | 12 +- source/lib/binary/scope_filter.cpp | 6 +- source/lib/binary/scope_filter.hpp | 8 +- source/lib/binary/symbol.cpp | 8 +- source/lib/binary/symbol.hpp | 6 +- source/lib/common/CMakeLists.txt | 17 +- source/lib/common/defines.h.in | 159 +- source/lib/common/delimit.hpp | 6 +- source/lib/common/environment.hpp | 51 +- source/lib/common/invoke.hpp | 42 +- source/lib/common/join.hpp | 18 +- source/lib/common/path.hpp | 96 +- source/lib/common/setup.hpp | 97 +- source/lib/core/CMakeLists.txt | 50 +- source/lib/core/argparse.cpp | 271 ++- source/lib/core/argparse.hpp | 6 +- source/lib/core/binary/CMakeLists.txt | 3 +- source/lib/core/binary/address_range.cpp | 6 +- source/lib/core/binary/address_range.hpp | 12 +- source/lib/core/binary/fwd.hpp | 6 +- source/lib/core/categories.cpp | 18 +- source/lib/core/categories.hpp | 212 +-- source/lib/core/common.hpp | 26 +- source/lib/core/components/CMakeLists.txt | 3 +- source/lib/core/components/fwd.hpp | 189 +-- source/lib/core/concepts.hpp | 12 +- source/lib/core/config.cpp | 1455 ++++++++-------- source/lib/core/config.hpp | 46 +- source/lib/core/constraint.cpp | 52 +- source/lib/core/constraint.hpp | 12 +- source/lib/core/containers/CMakeLists.txt | 3 +- .../core/containers/aligned_static_vector.hpp | 16 +- source/lib/core/containers/c_array.hpp | 10 +- source/lib/core/containers/operators.hpp | 44 +- source/lib/core/containers/stable_vector.hpp | 14 +- source/lib/core/containers/static_vector.hpp | 8 +- source/lib/core/debug.cpp | 10 +- source/lib/core/debug.hpp | 656 ++++---- source/lib/core/defines.hpp.in | 12 +- source/lib/core/dynamic_library.cpp | 21 +- source/lib/core/dynamic_library.hpp | 8 +- source/lib/core/exception.cpp | 6 +- source/lib/core/exception.hpp | 6 +- source/lib/core/gpu.cpp | 416 ++--- source/lib/core/gpu.hpp | 6 +- source/lib/core/hip_runtime.hpp | 6 +- source/lib/core/locking.hpp | 6 +- source/lib/core/mproc.cpp | 8 +- source/lib/core/mproc.hpp | 6 +- source/lib/core/perf.cpp | 14 +- source/lib/core/perf.hpp | 6 +- source/lib/core/perfetto.cpp | 31 +- source/lib/core/perfetto.hpp | 20 +- source/lib/core/perfetto_fwd.hpp | 6 +- source/lib/core/rccl.hpp | 8 +- source/lib/core/redirect.hpp | 19 +- source/lib/core/state.cpp | 56 +- source/lib/core/state.hpp | 41 +- source/lib/core/timemory.cpp | 4 +- source/lib/core/timemory.hpp | 6 +- source/lib/core/utility.cpp | 10 +- source/lib/core/utility.hpp | 6 +- source/lib/omnitrace-dl/CMakeLists.txt | 50 - source/lib/omnitrace-dl/dl.cpp | 1448 ---------------- source/lib/omnitrace-dl/dl/dl.hpp | 211 --- source/lib/omnitrace-user/CMakeLists.txt | 54 - .../lib/omnitrace-user/omnitrace/categories.h | 191 --- source/lib/omnitrace-user/omnitrace/types.h | 117 -- source/lib/omnitrace-user/omnitrace/user.h | 158 -- source/lib/omnitrace/CMakeLists.txt | 64 - source/lib/omnitrace/api.cpp | 169 -- source/lib/omnitrace/api.hpp | 121 -- .../omnitrace/library/coverage/CMakeLists.txt | 5 - .../lib/omnitrace/library/rocm/CMakeLists.txt | 6 - .../omnitrace/library/tracing/CMakeLists.txt | 5 - source/lib/rocprof-sys-dl/CMakeLists.txt | 52 + source/lib/rocprof-sys-dl/dl.cpp | 1458 +++++++++++++++++ source/lib/rocprof-sys-dl/dl/dl.hpp | 212 +++ .../{omnitrace-dl => rocprof-sys-dl}/main.c | 54 +- .../CMakeLists.txt | 37 +- .../cmake/dynsysname | 0 .../cmake/platform.cmake | 6 +- .../cmake/sysname | 0 .../h/Types.h | 0 .../h/compiler_annotations.h | 0 .../h/dyninstAPI_RT.h | 0 .../h/dyninstRTExport.h | 0 .../h/dyntypes.h | 0 .../{omnitrace-rt => rocprof-sys-rt}/h/util.h | 0 .../src/DYNINSTAPI_RT_EXPORTS | 0 .../src/RTcommon.c | 0 .../src/RTcommon.h | 0 .../src/RTfreebsd.c | 0 .../src/RTheap-freebsd.c | 0 .../src/RTheap-linux.c | 0 .../src/RTheap-win.c | 0 .../src/RTheap.c | 0 .../src/RTheap.h | 0 .../src/RTlinux.c | 0 .../src/RTmemEmulator.c | 0 .../src/RTposix.c | 0 .../src/RTsigill-x86.S | 0 .../src/RTsignal-x86.S | 0 .../src/RTsignal-x86_64.S | 0 .../src/RTsignal.c | 0 .../src/RTspace-smallmem.s | 0 .../src/RTspace.S | 0 .../src/RTstatic_ctors_dtors-aarch64.c | 0 .../src/RTstatic_ctors_dtors-ppc32.c | 0 .../src/RTstatic_ctors_dtors-ppc64.c | 0 .../src/RTstatic_ctors_dtors-x86.c | 0 .../src/RTstatic_ctors_dtors_begin.c | 0 .../src/RTstatic_ctors_dtors_end.c | 0 .../src/RTthread-aarch64.c | 0 .../src/RTthread-power-asm.s | 0 .../src/RTthread-powerpc-asm.S | 0 .../src/RTthread-powerpc.c | 0 .../src/RTthread-x86-64.c | 0 .../src/RTthread-x86.c | 0 .../src/RTthread.c | 0 .../src/RTthread.h | 0 .../src/RTtlsgetaddr-x86.S | 0 .../src/RTtlsgetaddr-x86_64.S | 0 .../src/RTwinnt.c | 0 .../src/libSpace.s | 0 .../src/libSpace64.s | 0 source/lib/rocprof-sys-user/CMakeLists.txt | 60 + .../rocprofiler-systems/categories.h | 191 +++ .../rocprofiler-systems}/causal.h | 61 +- .../rocprofiler-systems/types.h | 118 ++ .../rocprofiler-systems/user.h | 159 ++ .../user.cpp | 86 +- source/lib/rocprof-sys/CMakeLists.txt | 73 + source/lib/rocprof-sys/api.cpp | 169 ++ source/lib/rocprof-sys/api.hpp | 121 ++ .../{omnitrace => rocprof-sys}/library.cpp | 340 ++-- .../library/CMakeLists.txt | 30 +- .../library/causal/CMakeLists.txt | 3 +- .../library/causal/components/CMakeLists.txt | 3 +- .../library/causal/components/backtrace.cpp | 20 +- .../library/causal/components/backtrace.hpp | 6 +- .../causal/components/blocking_gotcha.cpp | 16 +- .../causal/components/blocking_gotcha.hpp | 22 +- .../causal/components/causal_gotcha.cpp | 6 +- .../causal/components/causal_gotcha.hpp | 8 +- .../causal/components/progress_point.cpp | 8 +- .../causal/components/progress_point.hpp | 36 +- .../causal/components/unblocking_gotcha.cpp | 12 +- .../causal/components/unblocking_gotcha.hpp | 20 +- .../library/causal/data.cpp | 133 +- .../library/causal/data.hpp | 6 +- .../library/causal/delay.cpp | 22 +- .../library/causal/delay.hpp | 8 +- .../library/causal/experiment.cpp | 61 +- .../library/causal/experiment.hpp | 8 +- .../library/causal/fwd.hpp | 8 +- .../library/causal/sample_data.cpp | 6 +- .../library/causal/sample_data.hpp | 6 +- .../library/causal/sampling.cpp | 68 +- .../library/causal/sampling.hpp | 6 +- .../library/causal/selected_entry.cpp | 6 +- .../library/causal/selected_entry.hpp | 8 +- .../library/components/CMakeLists.txt | 16 +- .../library/components/backtrace.cpp | 18 +- .../library/components/backtrace.hpp | 8 +- .../library/components/backtrace_metrics.cpp | 34 +- .../library/components/backtrace_metrics.hpp | 22 +- .../components/backtrace_timestamp.cpp | 8 +- .../components/backtrace_timestamp.hpp | 6 +- .../library/components/callchain.cpp | 10 +- .../library/components/callchain.hpp | 8 +- .../library/components/category_region.hpp | 47 +- .../library/components/comm_data.cpp | 56 +- .../library/components/comm_data.hpp | 28 +- .../library/components/cpu_freq.cpp | 23 +- .../library/components/cpu_freq.hpp | 8 +- .../library/components/ensure_storage.hpp | 10 +- .../library/components/exit_gotcha.cpp | 32 +- .../library/components/exit_gotcha.hpp | 8 +- .../library/components/fork_gotcha.cpp | 48 +- .../library/components/fork_gotcha.hpp | 10 +- .../library/components/mpi_gotcha.cpp | 84 +- .../library/components/mpi_gotcha.hpp | 10 +- .../library/components/numa_gotcha.cpp | 8 +- .../library/components/numa_gotcha.hpp | 8 +- .../components/pthread_create_gotcha.cpp | 76 +- .../components/pthread_create_gotcha.hpp | 10 +- .../library/components/pthread_gotcha.cpp | 22 +- .../library/components/pthread_gotcha.hpp | 8 +- .../components/pthread_mutex_gotcha.cpp | 28 +- .../components/pthread_mutex_gotcha.hpp | 18 +- .../library/components/rcclp.cpp | 10 +- .../library/components/rcclp.hpp | 24 +- .../library/components/rocprofiler.cpp | 24 +- .../library/components/rocprofiler.hpp | 52 +- .../library/components/roctracer.cpp | 114 +- .../library/components/roctracer.hpp | 36 +- .../library/coverage.cpp | 67 +- .../library/coverage.hpp | 38 +- .../library/coverage/CMakeLists.txt | 6 + .../library/coverage/impl.hpp | 6 +- .../library/cpu_freq.cpp | 20 +- .../library/cpu_freq.hpp | 6 +- .../library/kokkosp.cpp | 154 +- .../library/ompt.cpp | 40 +- .../library/ompt.hpp | 6 +- .../library/perf.cpp | 106 +- .../library/perf.hpp | 6 +- .../library/process_sampler.cpp | 24 +- .../library/process_sampler.hpp | 6 +- .../library/ptl.cpp | 30 +- .../library/ptl.hpp | 6 +- .../library/rcclp.cpp | 8 +- .../library/rcclp.hpp | 8 +- .../library/rocm.cpp | 114 +- .../library/rocm.hpp | 18 +- .../rocprof-sys/library/rocm/CMakeLists.txt | 7 + .../library/rocm/hsa_rsrc_factory.cpp | 4 +- .../library/rocm/hsa_rsrc_factory.hpp | 6 +- .../library/rocm_smi.cpp | 110 +- .../library/rocm_smi.hpp | 42 +- .../library/rocprofiler.cpp | 50 +- .../library/rocprofiler.hpp | 8 +- .../library/roctracer.cpp | 86 +- .../library/roctracer.hpp | 12 +- .../library/runtime.cpp | 35 +- .../library/runtime.hpp | 14 +- .../library/sampling.cpp | 213 +-- .../library/sampling.hpp | 6 +- .../library/thread_data.hpp | 12 +- .../library/thread_deleter.cpp | 8 +- .../library/thread_deleter.hpp | 6 +- .../library/thread_info.cpp | 55 +- .../library/thread_info.hpp | 18 +- .../library/tpls/mpi/mpi.h | 0 .../library/tpls/mpi/mpi_portable_platform.h | 0 .../library/tpls/rccl/rccl/rccl.h | 0 .../library/tracing.cpp | 28 +- .../library/tracing.hpp | 46 +- .../library/tracing/CMakeLists.txt | 6 + .../library/tracing/annotation.cpp | 12 +- .../library/tracing/annotation.hpp | 69 +- .../{omnitrace => rocprof-sys}/progress.cpp | 18 +- .../{omnitrace => rocprof-sys}/regions.cpp | 58 +- .../{omnitrace => rocprof-sys}/timeout.cpp | 54 +- source/python/CMakeLists.txt | 101 +- source/python/cmake/ConfigPython.cmake | 18 +- source/python/cmake/PyBind11Tools.cmake | 16 +- source/python/gui/MANIFEST.in | 2 +- source/python/gui/README.md | 6 +- source/python/gui/setup.cfg | 10 +- source/python/gui/setup.py | 12 +- source/python/gui/source/__main__.py | 16 +- source/python/gui/source/parser.py | 16 +- ...libpyomnitrace.cpp => libpyrocprofsys.cpp} | 127 +- ...libpyomnitrace.hpp => libpyrocprofsys.hpp} | 7 +- .../{omnitrace => rocprofsys}/__init__.py | 24 +- .../{omnitrace => rocprofsys}/__main__.py | 50 +- .../{omnitrace => rocprofsys}/common.py | 20 +- .../{omnitrace => rocprofsys}/profiler.py | 30 +- .../python/{omnitrace => rocprofsys}/user.py | 26 +- source/python/setup.cfg.in | 2 +- source/python/setup.py.in | 2 +- tests/CMakeLists.txt | 38 +- ...cmake => rocprof-sys-annotate-tests.cmake} | 30 +- ...s.cmake => rocprof-sys-attach-tests.cmake} | 12 +- ...race-capchk.cpp => rocprof-sys-capchk.cpp} | 6 +- ...s.cmake => rocprof-sys-causal-tests.cmake} | 34 +- ... => rocprof-sys-code-coverage-tests.cmake} | 8 +- ...s.cmake => rocprof-sys-config-tests.cmake} | 18 +- ...sts.cmake => rocprof-sys-fork-tests.cmake} | 10 +- ...ake => rocprof-sys-instrument-tests.cmake} | 10 +- ...s.cmake => rocprof-sys-kokkos-tests.cmake} | 30 +- ...ests.cmake => rocprof-sys-mpi-tests.cmake} | 58 +- ...s.cmake => rocprof-sys-openmp-tests.cmake} | 59 +- ...cmake => rocprof-sys-overflow-tests.cmake} | 22 +- ....cmake => rocprof-sys-pthread-tests.cmake} | 8 +- ...s.cmake => rocprof-sys-python-tests.cmake} | 84 +- ...sts.cmake => rocprof-sys-rccl-tests.cmake} | 2 +- ...sts.cmake => rocprof-sys-rocm-tests.cmake} | 22 +- ...esting.cmake => rocprof-sys-testing.cmake} | 443 ++--- ...ke => rocprof-sys-time-window-tests.cmake} | 25 +- ...cmake => rocprof-sys-user-api-tests.cmake} | 2 +- ...mnitrace-pid.sh => run-rocprof-sys-pid.sh} | 6 +- tests/source/CMakeLists.txt | 19 +- tests/validate-causal-json.py | 4 +- 424 files changed, 10567 insertions(+), 10024 deletions(-) create mode 100644 .azuredevops/rocm-ci.yml rename cmake/Templates/{omnitrace-config.cmake.in => rocprof-sys-config.cmake.in} (100%) rename cmake/Templates/{omnitrace-install.py.in => rocprof-sys-install.py.in} (89%) create mode 100755 scripts/check_copyright.sh rename scripts/{omnitrace-launch-compiler => rocprof-sys-launch-compiler} (68%) rename scripts/{omnitrace-leak.supp => rocprof-sys-leak.supp} (100%) rename scripts/{omnitrace-thread.supp => rocprof-sys-thread.supp} (92%) rename scripts/{write-omnitrace-install.cmake => write-rocprof-sys-install.cmake} (51%) delete mode 100644 source/bin/omnitrace-causal/CMakeLists.txt delete mode 100644 source/bin/omnitrace-exe/CMakeLists.txt delete mode 100644 source/bin/omnitrace-instrument/CMakeLists.txt delete mode 100644 source/bin/omnitrace-run/CMakeLists.txt delete mode 100644 source/bin/omnitrace-sample/CMakeLists.txt rename source/bin/{omnitrace-avail => rocprof-sys-avail}/CMakeLists.txt (53%) rename source/bin/{omnitrace-avail => rocprof-sys-avail}/avail.cpp (98%) rename source/bin/{omnitrace-avail => rocprof-sys-avail}/avail.hpp (100%) rename source/bin/{omnitrace-avail => rocprof-sys-avail}/common.cpp (96%) rename source/bin/{omnitrace-avail => rocprof-sys-avail}/common.hpp (93%) rename source/bin/{omnitrace-avail => rocprof-sys-avail}/component_categories.hpp (100%) rename source/bin/{omnitrace-avail => rocprof-sys-avail}/defines.hpp (100%) rename source/bin/{omnitrace-avail => rocprof-sys-avail}/enumerated_list.hpp (100%) rename source/bin/{omnitrace-avail => rocprof-sys-avail}/generate_config.cpp (91%) rename source/bin/{omnitrace-avail => rocprof-sys-avail}/generate_config.hpp (100%) rename source/bin/{omnitrace-avail => rocprof-sys-avail}/get_availability.hpp (100%) rename source/bin/{omnitrace-avail => rocprof-sys-avail}/get_categories.hpp (100%) rename source/bin/{omnitrace-avail => rocprof-sys-avail}/info_type.cpp (100%) rename source/bin/{omnitrace-avail => rocprof-sys-avail}/info_type.hpp (100%) create mode 100644 source/bin/rocprof-sys-causal/CMakeLists.txt rename source/bin/{omnitrace-causal => rocprof-sys-causal}/impl.cpp (82%) rename source/bin/{omnitrace-causal/omnitrace-causal.cpp => rocprof-sys-causal/rocprof-sys-causal.cpp} (97%) rename source/bin/{omnitrace-causal/omnitrace-causal.hpp => rocprof-sys-causal/rocprof-sys-causal.hpp} (95%) create mode 100644 source/bin/rocprof-sys-exe/CMakeLists.txt rename source/bin/{omnitrace-exe/omnitrace.cpp => rocprof-sys-exe/rocprof-sys.cpp} (90%) create mode 100644 source/bin/rocprof-sys-instrument/CMakeLists.txt rename source/bin/{omnitrace-instrument => rocprof-sys-instrument}/details.cpp (95%) rename source/bin/{omnitrace-instrument => rocprof-sys-instrument}/function_signature.cpp (100%) rename source/bin/{omnitrace-instrument => rocprof-sys-instrument}/function_signature.hpp (100%) rename source/bin/{omnitrace-instrument => rocprof-sys-instrument}/fwd.hpp (95%) rename source/bin/{omnitrace-instrument => rocprof-sys-instrument}/info.hpp (92%) rename source/bin/{omnitrace-instrument => rocprof-sys-instrument}/internal_libs.cpp (97%) rename source/bin/{omnitrace-instrument => rocprof-sys-instrument}/internal_libs.hpp (100%) rename source/bin/{omnitrace-instrument => rocprof-sys-instrument}/log.cpp (100%) rename source/bin/{omnitrace-instrument => rocprof-sys-instrument}/log.hpp (94%) rename source/bin/{omnitrace-instrument => rocprof-sys-instrument}/module_function.cpp (93%) rename source/bin/{omnitrace-instrument => rocprof-sys-instrument}/module_function.hpp (100%) rename source/bin/{omnitrace-instrument/omnitrace-instrument.cpp => rocprof-sys-instrument/rocprof-sys-instrument.cpp} (90%) rename source/bin/{omnitrace-instrument/omnitrace-instrument.hpp => rocprof-sys-instrument/rocprof-sys-instrument.hpp} (80%) create mode 100644 source/bin/rocprof-sys-run/CMakeLists.txt rename source/bin/{omnitrace-run => rocprof-sys-run}/impl.cpp (88%) rename source/bin/{omnitrace-run/omnitrace-run.cpp => rocprof-sys-run/rocprof-sys-run.cpp} (86%) rename source/bin/{omnitrace-run/omnitrace-run.hpp => rocprof-sys-run/rocprof-sys-run.hpp} (92%) create mode 100644 source/bin/rocprof-sys-sample/CMakeLists.txt rename source/bin/{omnitrace-sample => rocprof-sys-sample}/impl.cpp (78%) rename source/bin/{omnitrace-sample/omnitrace-sample.cpp => rocprof-sys-sample/rocprof-sys-sample.cpp} (94%) rename source/bin/{omnitrace-sample/omnitrace-sample.hpp => rocprof-sys-sample/rocprof-sys-sample.hpp} (100%) rename source/docs/images/{omnitrace-perfetto.png => rocprof-sys-perfetto.png} (100%) rename source/docs/images/{omnitrace-rocm-flow.png => rocprof-sys-rocm-flow.png} (100%) rename source/docs/images/{omnitrace-rocm.png => rocprof-sys-rocm.png} (100%) rename source/docs/images/{omnitrace-user-api.png => rocprof-sys-user-api.png} (100%) rename source/docs/{omnitrace.dox.in => rocprof-sys.dox.in} (100%) delete mode 100644 source/lib/omnitrace-dl/CMakeLists.txt delete mode 100644 source/lib/omnitrace-dl/dl.cpp delete mode 100644 source/lib/omnitrace-dl/dl/dl.hpp delete mode 100644 source/lib/omnitrace-user/CMakeLists.txt delete mode 100644 source/lib/omnitrace-user/omnitrace/categories.h delete mode 100644 source/lib/omnitrace-user/omnitrace/types.h delete mode 100644 source/lib/omnitrace-user/omnitrace/user.h delete mode 100644 source/lib/omnitrace/CMakeLists.txt delete mode 100644 source/lib/omnitrace/api.cpp delete mode 100644 source/lib/omnitrace/api.hpp delete mode 100644 source/lib/omnitrace/library/coverage/CMakeLists.txt delete mode 100644 source/lib/omnitrace/library/rocm/CMakeLists.txt delete mode 100644 source/lib/omnitrace/library/tracing/CMakeLists.txt create mode 100644 source/lib/rocprof-sys-dl/CMakeLists.txt create mode 100644 source/lib/rocprof-sys-dl/dl.cpp create mode 100644 source/lib/rocprof-sys-dl/dl/dl.hpp rename source/lib/{omnitrace-dl => rocprof-sys-dl}/main.c (62%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/CMakeLists.txt (80%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/cmake/dynsysname (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/cmake/platform.cmake (96%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/cmake/sysname (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/h/Types.h (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/h/compiler_annotations.h (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/h/dyninstAPI_RT.h (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/h/dyninstRTExport.h (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/h/dyntypes.h (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/h/util.h (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/DYNINSTAPI_RT_EXPORTS (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTcommon.c (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTcommon.h (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTfreebsd.c (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTheap-freebsd.c (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTheap-linux.c (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTheap-win.c (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTheap.c (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTheap.h (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTlinux.c (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTmemEmulator.c (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTposix.c (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTsigill-x86.S (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTsignal-x86.S (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTsignal-x86_64.S (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTsignal.c (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTspace-smallmem.s (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTspace.S (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTstatic_ctors_dtors-aarch64.c (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTstatic_ctors_dtors-ppc32.c (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTstatic_ctors_dtors-ppc64.c (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTstatic_ctors_dtors-x86.c (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTstatic_ctors_dtors_begin.c (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTstatic_ctors_dtors_end.c (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTthread-aarch64.c (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTthread-power-asm.s (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTthread-powerpc-asm.S (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTthread-powerpc.c (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTthread-x86-64.c (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTthread-x86.c (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTthread.c (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTthread.h (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTtlsgetaddr-x86.S (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTtlsgetaddr-x86_64.S (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/RTwinnt.c (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/libSpace.s (100%) rename source/lib/{omnitrace-rt => rocprof-sys-rt}/src/libSpace64.s (100%) create mode 100644 source/lib/rocprof-sys-user/CMakeLists.txt create mode 100644 source/lib/rocprof-sys-user/rocprofiler-systems/categories.h rename source/lib/{omnitrace-user/omnitrace => rocprof-sys-user/rocprofiler-systems}/causal.h (52%) create mode 100644 source/lib/rocprof-sys-user/rocprofiler-systems/types.h create mode 100644 source/lib/rocprof-sys-user/rocprofiler-systems/user.h rename source/lib/{omnitrace-user => rocprof-sys-user}/user.cpp (63%) create mode 100644 source/lib/rocprof-sys/CMakeLists.txt create mode 100644 source/lib/rocprof-sys/api.cpp create mode 100644 source/lib/rocprof-sys/api.hpp rename source/lib/{omnitrace => rocprof-sys}/library.cpp (69%) rename source/lib/{omnitrace => rocprof-sys}/library/CMakeLists.txt (71%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/CMakeLists.txt (78%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/components/CMakeLists.txt (77%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/components/backtrace.cpp (92%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/components/backtrace.hpp (96%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/components/blocking_gotcha.cpp (94%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/components/blocking_gotcha.hpp (85%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/components/causal_gotcha.cpp (95%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/components/causal_gotcha.hpp (90%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/components/progress_point.cpp (97%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/components/progress_point.hpp (81%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/components/unblocking_gotcha.cpp (92%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/components/unblocking_gotcha.hpp (81%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/data.cpp (89%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/data.hpp (94%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/delay.cpp (89%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/delay.hpp (92%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/experiment.cpp (92%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/experiment.hpp (97%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/fwd.hpp (90%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/sample_data.cpp (94%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/sample_data.hpp (94%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/sampling.cpp (89%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/sampling.hpp (93%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/selected_entry.cpp (93%) rename source/lib/{omnitrace => rocprof-sys}/library/causal/selected_entry.hpp (92%) rename source/lib/{omnitrace => rocprof-sys}/library/components/CMakeLists.txt (78%) rename source/lib/{omnitrace => rocprof-sys}/library/components/backtrace.cpp (92%) rename source/lib/{omnitrace => rocprof-sys}/library/components/backtrace.hpp (93%) rename source/lib/{omnitrace => rocprof-sys}/library/components/backtrace_metrics.cpp (92%) rename source/lib/{omnitrace => rocprof-sys}/library/components/backtrace_metrics.hpp (89%) rename source/lib/{omnitrace => rocprof-sys}/library/components/backtrace_timestamp.cpp (89%) rename source/lib/{omnitrace => rocprof-sys}/library/components/backtrace_timestamp.hpp (95%) rename source/lib/{omnitrace => rocprof-sys}/library/components/callchain.cpp (96%) rename source/lib/{omnitrace => rocprof-sys}/library/components/callchain.hpp (94%) rename source/lib/{omnitrace => rocprof-sys}/library/components/category_region.hpp (90%) rename source/lib/{omnitrace => rocprof-sys}/library/components/comm_data.cpp (89%) rename source/lib/{omnitrace => rocprof-sys}/library/components/comm_data.hpp (91%) rename source/lib/{omnitrace => rocprof-sys}/library/components/cpu_freq.cpp (89%) rename source/lib/{omnitrace => rocprof-sys}/library/components/cpu_freq.hpp (95%) rename source/lib/{omnitrace => rocprof-sys}/library/components/ensure_storage.hpp (89%) rename source/lib/{omnitrace => rocprof-sys}/library/components/exit_gotcha.cpp (72%) rename source/lib/{omnitrace => rocprof-sys}/library/components/exit_gotcha.hpp (93%) rename source/lib/{omnitrace => rocprof-sys}/library/components/fork_gotcha.cpp (76%) rename source/lib/{omnitrace => rocprof-sys}/library/components/fork_gotcha.hpp (89%) rename source/lib/{omnitrace => rocprof-sys}/library/components/mpi_gotcha.cpp (79%) rename source/lib/{omnitrace => rocprof-sys}/library/components/mpi_gotcha.hpp (93%) rename source/lib/{omnitrace => rocprof-sys}/library/components/numa_gotcha.cpp (97%) rename source/lib/{omnitrace => rocprof-sys}/library/components/numa_gotcha.hpp (95%) rename source/lib/{omnitrace => rocprof-sys}/library/components/pthread_create_gotcha.cpp (89%) rename source/lib/{omnitrace => rocprof-sys}/library/components/pthread_create_gotcha.hpp (93%) rename source/lib/{omnitrace => rocprof-sys}/library/components/pthread_gotcha.cpp (81%) rename source/lib/{omnitrace => rocprof-sys}/library/components/pthread_gotcha.hpp (90%) rename source/lib/{omnitrace => rocprof-sys}/library/components/pthread_mutex_gotcha.cpp (90%) rename source/lib/{omnitrace => rocprof-sys}/library/components/pthread_mutex_gotcha.hpp (84%) rename source/lib/{omnitrace => rocprof-sys}/library/components/rcclp.cpp (95%) rename source/lib/{omnitrace => rocprof-sys}/library/components/rcclp.hpp (82%) rename source/lib/{omnitrace => rocprof-sys}/library/components/rocprofiler.cpp (88%) rename source/lib/{omnitrace => rocprof-sys}/library/components/rocprofiler.hpp (81%) rename source/lib/{omnitrace => rocprof-sys}/library/components/roctracer.cpp (74%) rename source/lib/{omnitrace => rocprof-sys}/library/components/roctracer.hpp (72%) rename source/lib/{omnitrace => rocprof-sys}/library/coverage.cpp (81%) rename source/lib/{omnitrace => rocprof-sys}/library/coverage.hpp (86%) create mode 100644 source/lib/rocprof-sys/library/coverage/CMakeLists.txt rename source/lib/{omnitrace => rocprof-sys}/library/coverage/impl.hpp (97%) rename source/lib/{omnitrace => rocprof-sys}/library/cpu_freq.cpp (94%) rename source/lib/{omnitrace => rocprof-sys}/library/cpu_freq.hpp (90%) rename source/lib/{omnitrace => rocprof-sys}/library/kokkosp.cpp (79%) rename source/lib/{omnitrace => rocprof-sys}/library/ompt.cpp (79%) rename source/lib/{omnitrace => rocprof-sys}/library/ompt.hpp (90%) rename source/lib/{omnitrace => rocprof-sys}/library/perf.cpp (84%) rename source/lib/{omnitrace => rocprof-sys}/library/perf.hpp (98%) rename source/lib/{omnitrace => rocprof-sys}/library/process_sampler.cpp (91%) rename source/lib/{omnitrace => rocprof-sys}/library/process_sampler.hpp (95%) rename source/lib/{omnitrace => rocprof-sys}/library/ptl.cpp (85%) rename source/lib/{omnitrace => rocprof-sys}/library/ptl.hpp (94%) rename source/lib/{omnitrace => rocprof-sys}/library/rcclp.cpp (91%) rename source/lib/{omnitrace => rocprof-sys}/library/rcclp.hpp (89%) rename source/lib/{omnitrace => rocprof-sys}/library/rocm.cpp (61%) rename source/lib/{omnitrace => rocprof-sys}/library/rocm.hpp (75%) create mode 100644 source/lib/rocprof-sys/library/rocm/CMakeLists.txt rename source/lib/{omnitrace => rocprof-sys}/library/rocm/hsa_rsrc_factory.cpp (99%) rename source/lib/{omnitrace => rocprof-sys}/library/rocm/hsa_rsrc_factory.hpp (98%) rename source/lib/{omnitrace => rocprof-sys}/library/rocm_smi.cpp (78%) rename source/lib/{omnitrace => rocprof-sys}/library/rocm_smi.hpp (76%) rename source/lib/{omnitrace => rocprof-sys}/library/rocprofiler.cpp (94%) rename source/lib/{omnitrace => rocprof-sys}/library/rocprofiler.hpp (91%) rename source/lib/{omnitrace => rocprof-sys}/library/roctracer.cpp (92%) rename source/lib/{omnitrace => rocprof-sys}/library/roctracer.hpp (89%) rename source/lib/{omnitrace => rocprof-sys}/library/runtime.cpp (87%) rename source/lib/{omnitrace => rocprof-sys}/library/runtime.hpp (91%) rename source/lib/{omnitrace => rocprof-sys}/library/sampling.cpp (88%) rename source/lib/{omnitrace => rocprof-sys}/library/sampling.hpp (93%) rename source/lib/{omnitrace => rocprof-sys}/library/thread_data.hpp (98%) rename source/lib/{omnitrace => rocprof-sys}/library/thread_deleter.cpp (90%) rename source/lib/{omnitrace => rocprof-sys}/library/thread_deleter.hpp (92%) rename source/lib/{omnitrace => rocprof-sys}/library/thread_info.cpp (84%) rename source/lib/{omnitrace => rocprof-sys}/library/thread_info.hpp (89%) rename source/lib/{omnitrace => rocprof-sys}/library/tpls/mpi/mpi.h (100%) rename source/lib/{omnitrace => rocprof-sys}/library/tpls/mpi/mpi_portable_platform.h (100%) rename source/lib/{omnitrace => rocprof-sys}/library/tpls/rccl/rccl/rccl.h (100%) rename source/lib/{omnitrace => rocprof-sys}/library/tracing.cpp (87%) rename source/lib/{omnitrace => rocprof-sys}/library/tracing.hpp (93%) create mode 100644 source/lib/rocprof-sys/library/tracing/CMakeLists.txt rename source/lib/{omnitrace => rocprof-sys}/library/tracing/annotation.cpp (82%) rename source/lib/{omnitrace => rocprof-sys}/library/tracing/annotation.hpp (79%) rename source/lib/{omnitrace => rocprof-sys}/progress.cpp (68%) rename source/lib/{omnitrace => rocprof-sys}/regions.cpp (68%) rename source/lib/{omnitrace => rocprof-sys}/timeout.cpp (81%) rename source/python/{libpyomnitrace.cpp => libpyrocprofsys.cpp} (89%) rename source/python/{libpyomnitrace.hpp => libpyrocprofsys.hpp} (91%) rename source/python/{omnitrace => rocprofsys}/__init__.py (79%) rename source/python/{omnitrace => rocprofsys}/__main__.py (88%) rename source/python/{omnitrace => rocprofsys}/common.py (86%) rename source/python/{omnitrace => rocprofsys}/profiler.py (89%) rename source/python/{omnitrace => rocprofsys}/user.py (85%) rename tests/{omnitrace-annotate-tests.cmake => rocprof-sys-annotate-tests.cmake} (74%) rename tests/{omnitrace-attach-tests.cmake => rocprof-sys-attach-tests.cmake} (77%) rename tests/{omnitrace-capchk.cpp => rocprof-sys-capchk.cpp} (98%) rename tests/{omnitrace-causal-tests.cmake => rocprof-sys-causal-tests.cmake} (84%) rename tests/{omnitrace-code-coverage-tests.cmake => rocprof-sys-code-coverage-tests.cmake} (96%) rename tests/{omnitrace-config-tests.cmake => rocprof-sys-config-tests.cmake} (58%) rename tests/{omnitrace-fork-tests.cmake => rocprof-sys-fork-tests.cmake} (62%) rename tests/{omnitrace-instrument-tests.cmake => rocprof-sys-instrument-tests.cmake} (81%) rename tests/{omnitrace-kokkos-tests.cmake => rocprof-sys-kokkos-tests.cmake} (68%) rename tests/{omnitrace-mpi-tests.cmake => rocprof-sys-mpi-tests.cmake} (68%) rename tests/{omnitrace-openmp-tests.cmake => rocprof-sys-openmp-tests.cmake} (69%) rename tests/{omnitrace-overflow-tests.cmake => rocprof-sys-overflow-tests.cmake} (58%) rename tests/{omnitrace-pthread-tests.cmake => rocprof-sys-pthread-tests.cmake} (77%) rename tests/{omnitrace-python-tests.cmake => rocprof-sys-python-tests.cmake} (72%) rename tests/{omnitrace-rccl-tests.cmake => rocprof-sys-rccl-tests.cmake} (97%) rename tests/{omnitrace-rocm-tests.cmake => rocprof-sys-rocm-tests.cmake} (80%) rename tests/{omnitrace-testing.cmake => rocprof-sys-testing.cmake} (67%) rename tests/{omnitrace-time-window-tests.cmake => rocprof-sys-time-window-tests.cmake} (81%) rename tests/{omnitrace-user-api-tests.cmake => rocprof-sys-user-api-tests.cmake} (96%) rename tests/{run-omnitrace-pid.sh => run-rocprof-sys-pid.sh} (80%) diff --git a/.azuredevops/rocm-ci.yml b/.azuredevops/rocm-ci.yml new file mode 100644 index 00000000..1bac3aa3 --- /dev/null +++ b/.azuredevops/rocm-ci.yml @@ -0,0 +1,44 @@ +resources: + repositories: + - repository: pipelines_repo + type: github + endpoint: ROCm + name: ROCm/ROCm + +variables: +- group: common +- template: /.azuredevops/variables-global.yml@pipelines_repo + +trigger: + batch: true + branches: + include: + - amd-staging + - amd-mainline + paths: + exclude: + - .github + - docs + - '.*.y*ml' + - '*.md' + - LICENSE + - VERSION + +pr: + autoCancel: true + branches: + include: + - amd-staging + - amd-mainline + paths: + exclude: + - .github + - docs + - '.*.y*ml' + - '*.md' + - LICENSE + - VERSION + drafts: false + +jobs: + - template: ${{ variables.CI_COMPONENT_PATH }}/rocprofiler-systems.yml@pipelines_repo diff --git a/.cmake-format.yaml b/.cmake-format.yaml index 7d99a627..5eab3b50 100644 --- a/.cmake-format.yaml +++ b/.cmake-format.yaml @@ -1,6 +1,6 @@ parse: additional_commands: - omnitrace_checkout_git_submodule: + rocprofiler_systems_checkout_git_submodule: flags: - RECURSIVE kwargs: @@ -10,15 +10,15 @@ parse: REPO_URL: '*' REPO_BRANCH: '*' ADDITIONAL_COMMANDS: '*' - omnitrace_save_variables: + rocprofiler_systems_save_variables: kwargs: VARIABLES: '*' CONDITION: '*' - omnitrace_restore_variables: + rocprofiler_systems_restore_variables: kwargs: VARIABLES: '*' CONDITION: '*' - omnitrace_add_test: + rocprofiler_systems_add_test: flags: - SKIP_BASELINE - SKIP_SAMPLING @@ -50,7 +50,7 @@ parse: BASELINE_FAIL_REGEX: '*' REWRITE_RUN_PASS_REGEX: '*' REWRITE_RUN_FAIL_REGEX: '*' - omnitrace_add_causal_test: + rocprofiler_systems_add_causal_test: flags: - SKIP_BASELINE kwargs: @@ -72,12 +72,12 @@ parse: BASELINE_FAIL_REGEX: '*' CAUSAL_VALIDATE_PASS_REGEX: '*' CAUSAL_VALIDATE_FAIL_REGEX: '*' - omnitrace_target_compile_definitions: + rocprofiler_systems_target_compile_definitions: kwargs: PUBLIC: '*' PRIVATE: '*' INTERFACE: '*' - omnitrace_add_bin_test: + rocprofiler_systems_add_bin_test: flags: - WILL_FAIL kwargs: @@ -94,7 +94,7 @@ parse: PASS_REGEX: '*' FAIL_REGEX: '*' SKIP_REGEX: '*' - omnitrace_add_python_test: + rocprofiler_systems_add_python_test: flags: - STANDALONE kwargs: @@ -113,7 +113,7 @@ parse: PASS_REGEX: '*' FAIL_REGEX: '*' SKIP_REGEX: '*' - omnitrace_add_python_validation_test: + rocprofiler_systems_add_python_validation_test: kwargs: NAME: '*' ARGS: '*' @@ -128,7 +128,7 @@ parse: - SEND_ERROR - FATAL_ERROR - AUTHOR_WARNING - omnitrace_find_python: + rocprofiler_systems_find_python: flags: - REQUIRED - QUIET @@ -136,11 +136,11 @@ parse: VERSION: '*' ROOT_DIR: '*' COMPONENTS: '*' - omnitrace_python_console_script: + rocprofiler_systems_python_console_script: kwargs: VERSION: '*' ROOT_DIR: '*' - omnitrace_pybind11_add_module: + rocprofiler_systems_pybind11_add_module: flags: - MODULE - SHARED @@ -153,7 +153,7 @@ parse: PYTHON_VERSION: '*' CXX_STANDARD: '*' VISIBILITY: '*' - omnitrace_directory: + rocprofiler_systems_directory: flags: - MKDIR - FAIL @@ -162,14 +162,14 @@ parse: OUTPUT_VARIABLE: '*' WORKING_DIRECTORY: '*' PATHS: '*' - omnitrace_check_python_dirs_and_versions: + rocprofiler_systems_check_python_dirs_and_versions: flags: - UNSET - FAIL kwargs: RESULT_VARIABLE: '*' OUTPUT_VARIABLE: '*' - omnitrace_find_static_library: + rocprofiler_systems_find_static_library: flags: - NO_CACHE - REQUIRED @@ -188,7 +188,7 @@ parse: PATHS: '*' PATH_SUFFIXES: '*' DOC: '*' - omnitrace_find_shared_library: + rocprofiler_systems_find_shared_library: flags: - NO_CACHE - REQUIRED @@ -207,14 +207,14 @@ parse: PATHS: '*' PATH_SUFFIXES: '*' DOC: '*' - omnitrace_causal_example_executable: + rocprofiler_systems_causal_example_executable: kwargs: TAG: '*' SOURCES: '*' DEFINITIONS: '*' LINK_LIBRARIES: '*' INCLUDE_DIRECTORIES: '*' - omnitrace_add_validation_test: + rocprofiler_systems_add_validation_test: kwargs: NAME: '*' ARGS: '*' diff --git a/.github/dependabot.yml b/.github/dependabot.yml index fe22a4c3..d24c82f8 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,11 +5,6 @@ version: 2 updates: - - package-ecosystem: "" # See documentation for possible values - directory: "/" # Location of package manifests - schedule: - interval: "weekly" - - package-ecosystem: "pip" # See documentation for possible values directory: "/docs/sphinx" # Location of package manifests open-pull-requests-limit: 10 diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml index db5441d7..b256c04f 100644 --- a/.github/workflows/containers.yml +++ b/.github/workflows/containers.yml @@ -20,7 +20,7 @@ env: GIT_DISCOVERY_ACROSS_FILESYSTEM: 1 jobs: - omnitrace-ci: + rocprofiler-systemss-ci: if: github.repository == 'ROCm/omnitrace' runs-on: ubuntu-20.04 @@ -73,7 +73,7 @@ jobs: ./build-docker-ci.sh --distro ${{ matrix.distro }} --versions ${{ matrix.version }} --user ${{ secrets.DOCKERHUB_USERNAME }} --push --jobs 2 --elfutils-version 0.186 --boost-version 1.79.0 popd - omnitrace-release: + rocprofiler-systems-release: if: github.repository == 'ROCm/omnitrace' runs-on: ubuntu-20.04 diff --git a/.github/workflows/cpack.yml b/.github/workflows/cpack.yml index a564b689..c4f5c9b6 100644 --- a/.github/workflows/cpack.yml +++ b/.github/workflows/cpack.yml @@ -286,7 +286,7 @@ jobs: timeout-minutes: 10 uses: actions/upload-artifact@v4 with: - name: omnitrace-stgz-${{ matrix.os-distro }}-${{ matrix.os-version }}-rocm-${{ matrix.rocm-version }}-installer + name: rocprofiler-systems-stgz-${{ matrix.os-distro }}-${{ matrix.os-version }}-rocm-${{ matrix.rocm-version }}-installer path: | build-release/stgz/*.sh @@ -297,13 +297,13 @@ jobs: shopt -s nullglob for i in $(find build-release -type f | egrep '/(stgz|deb|rpm)/.*\.(sh|deb|rpm)$'); do mv ${i} ./; done sudo rm -rf build-release - sudo rm -rf /opt/omnitrace + sudo rm -rf /opt/rocprofiler-systems - name: Test STGZ Install timeout-minutes: 20 run: | set -v - for i in omnitrace-*.sh + for i in rocprofiler-systems-*.sh do ./docker/test-docker-release.sh --distro ${{ matrix.os-distro }} --versions ${{ matrix.os-version }} --rocm-versions ${{ matrix.rocm-version }} -- --stgz ${i} done @@ -314,4 +314,4 @@ jobs: with: fail_on_unmatched_files: True files: | - omnitrace-*.sh + rocprofiler-systems-*.sh diff --git a/.github/workflows/opensuse.yml b/.github/workflows/opensuse.yml index ecec47ec..e6e787a0 100644 --- a/.github/workflows/opensuse.yml +++ b/.github/workflows/opensuse.yml @@ -32,8 +32,8 @@ concurrency: cancel-in-progress: true env: - OMNITRACE_CI: ON - OMNITRACE_TMPDIR: "%env{PWD}%/testing-tmp" + ROCPROFSYS_CI: ON + ROCPROFSYS_TMPDIR: "%env{PWD}%/testing-tmp" jobs: opensuse: @@ -69,8 +69,8 @@ jobs: run: echo "CC=$(echo '${{ matrix.compiler }}' | sed 's/+/c/g')" >> $GITHUB_ENV && echo "CXX=${{ matrix.compiler }}" >> $GITHUB_ENV && - echo "/opt/omnitrace/bin:${HOME}/.local/bin" >> $GITHUB_PATH && - echo "LD_LIBRARY_PATH=/opt/omnitrace/lib:${LD_LIBRARY_PATH}" >> $GITHUB_ENV + echo "/opt/rocprofiler-systems/bin:${HOME}/.local/bin" >> $GITHUB_PATH && + echo "LD_LIBRARY_PATH=/opt/rocprofiler-systems/lib:${LD_LIBRARY_PATH}" >> $GITHUB_ENV - name: Configure, Build, and Test timeout-minutes: 115 @@ -86,20 +86,20 @@ jobs: -DCMAKE_C_COMPILER=$(echo '${{ matrix.compiler }}' | sed 's/+/c/g') -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} - -DCMAKE_INSTALL_PREFIX=/opt/omnitrace - -DOMNITRACE_BUILD_TESTING=ON - -DOMNITRACE_USE_MPI=OFF - -DOMNITRACE_USE_HIP=OFF - -DOMNITRACE_USE_OMPT=OFF - -DOMNITRACE_USE_PYTHON=ON - -DOMNITRACE_INSTALL_PERFETTO_TOOLS=OFF - -DOMNITRACE_USE_MPI_HEADERS=ON - -DOMNITRACE_PYTHON_PREFIX=/opt/conda/envs - -DOMNITRACE_PYTHON_ENVS="py3.6;py3.7;py3.8;py3.9;py3.10;py3.11" - -DOMNITRACE_CI_MPI_RUN_AS_ROOT=ON - -DOMNITRACE_MAX_THREADS=64 - -DOMNITRACE_DISABLE_EXAMPLES="transpose;rccl" - -DOMNITRACE_BUILD_NUMBER=${{ github.run_attempt }} + -DCMAKE_INSTALL_PREFIX=/opt/rocprofiler-systems + -DROCPROFSYS_BUILD_TESTING=ON + -DROCPROFSYS_USE_MPI=OFF + -DROCPROFSYS_USE_HIP=OFF + -DROCPROFSYS_USE_OMPT=OFF + -DROCPROFSYS_USE_PYTHON=ON + -DROCPROFSYS_INSTALL_PERFETTO_TOOLS=OFF + -DROCPROFSYS_USE_MPI_HEADERS=ON + -DROCPROFSYS_PYTHON_PREFIX=/opt/conda/envs + -DROCPROFSYS_PYTHON_ENVS="py3.6;py3.7;py3.8;py3.9;py3.10;py3.11" + -DROCPROFSYS_CI_MPI_RUN_AS_ROOT=ON + -DROCPROFSYS_MAX_THREADS=64 + -DROCPROFSYS_DISABLE_EXAMPLES="transpose;rccl" + -DROCPROFSYS_BUILD_NUMBER=${{ github.run_attempt }} - name: Install timeout-minutes: 10 @@ -110,27 +110,27 @@ jobs: timeout-minutes: 10 run: | set -v - export OMNITRACE_DEBUG=ON - which omnitrace-avail - ldd $(which omnitrace-avail) - omnitrace-avail --help - omnitrace-avail -a - which omnitrace - ldd $(which omnitrace) - omnitrace-instrument --help - omnitrace-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 - omnitrace-run -- ./ls.inst - omnitrace-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 + export ROCPROFSYS_DEBUG=ON + which rocprof-sys-avail + ldd $(which rocprof-sys-avail) + rocprof-sys-avail --help + rocprof-sys-avail -a + 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 rocprofsys-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 + rocprof-sys-run -- ./ls.inst + rocprof-sys-instrument -e -v 1 --simulate -- ls + for i in $(find rocprofsys-ls-output -type f); do echo -e "\n\n --> ${i} \n\n"; cat ${i}; done + rocprof-sys-instrument -e -v 1 -- ls - name: Test User API timeout-minutes: 10 run: | set -v - ./scripts/test-find-package.sh --install-dir /opt/omnitrace + ./scripts/test-find-package.sh --install-dir /opt/rocprofiler-systems - name: CTest Artifacts if: failure() @@ -148,9 +148,9 @@ jobs: with: name: data-${{ github.job }}-${{ strategy.job-index }}-files path: | - build/omnitrace-tests-config/*.cfg - build/omnitrace-tests-output/**/*.txt - build/omnitrace-tests-output/**/*-instr*.json + build/rocprofsys-tests-config/*.cfg + build/rocprofsys-tests-output/**/*.txt + build/rocprofsys-tests-output/**/*-instr*.json - name: Kill Perfetto if: success() || failure() diff --git a/.github/workflows/redhat.yml b/.github/workflows/redhat.yml index 0a3869d8..c7a402b7 100644 --- a/.github/workflows/redhat.yml +++ b/.github/workflows/redhat.yml @@ -32,8 +32,8 @@ concurrency: cancel-in-progress: true env: - OMNITRACE_CI: ON - OMNITRACE_TMPDIR: "%env{PWD}%/testing-tmp" + ROCPROFSYS_CI: ON + ROCPROFSYS_TMPDIR: "%env{PWD}%/testing-tmp" jobs: rhel: @@ -110,20 +110,20 @@ jobs: -DCMAKE_C_COMPILER=$(echo '${{ matrix.compiler }}' | sed 's/+/c/g') -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} - -DCMAKE_INSTALL_PREFIX=/opt/omnitrace - -DOMNITRACE_BUILD_TESTING=ON - -DOMNITRACE_USE_MPI=OFF - -DOMNITRACE_USE_HIP=${USE_HIP} - -DOMNITRACE_USE_OMPT=OFF - -DOMNITRACE_USE_PYTHON=ON - -DOMNITRACE_USE_MPI_HEADERS=ON - -DOMNITRACE_CI_MPI_RUN_AS_ROOT=ON - -DOMNITRACE_MAX_THREADS=64 - -DOMNITRACE_INSTALL_PERFETTO_TOOLS=OFF - -DOMNITRACE_PYTHON_PREFIX=/opt/conda/envs - -DOMNITRACE_PYTHON_ENVS="py3.6;py3.7;py3.8;py3.9;py3.10;py3.11" - -DOMNITRACE_DISABLE_EXAMPLES="transpose;rccl" - -DOMNITRACE_BUILD_NUMBER=${{ github.run_attempt }} + -DCMAKE_INSTALL_PREFIX=/opt/rocprofiler-systems + -DROCPROFSYS_BUILD_TESTING=ON + -DROCPROFSYS_USE_MPI=OFF + -DROCPROFSYS_USE_HIP=${USE_HIP} + -DROCPROFSYS_USE_OMPT=OFF + -DROCPROFSYS_USE_PYTHON=ON + -DROCPROFSYS_USE_MPI_HEADERS=ON + -DROCPROFSYS_CI_MPI_RUN_AS_ROOT=ON + -DROCPROFSYS_MAX_THREADS=64 + -DROCPROFSYS_INSTALL_PERFETTO_TOOLS=OFF + -DROCPROFSYS_PYTHON_PREFIX=/opt/conda/envs + -DROCPROFSYS_PYTHON_ENVS="py3.6;py3.7;py3.8;py3.9;py3.10;py3.11" + -DROCPROFSYS_DISABLE_EXAMPLES="transpose;rccl" + -DROCPROFSYS_BUILD_NUMBER=${{ github.run_attempt }} -- -LE "transpose|rccl" @@ -137,14 +137,14 @@ jobs: shell: bash run: | set -v - source /opt/omnitrace/share/omnitrace/setup-env.sh - ./scripts/test-install.sh --test-omnitrace-{instrument,avail,sample,rewrite,runtime,python}=1 + source /opt/rocprofiler-systems/share/rocprofiler-systems/setup-env.sh + ./scripts/test-install.sh --test-rocprof-sys-{instrument,avail,sample,rewrite,runtime,python}=1 - name: Test User API timeout-minutes: 10 run: | set -v - ./scripts/test-find-package.sh --install-dir /opt/omnitrace + ./scripts/test-find-package.sh --install-dir /opt/rocprofiler-systems - name: CTest Artifacts if: failure() @@ -162,9 +162,9 @@ jobs: with: name: data-${{ github.job }}-${{ strategy.job-index }}-files path: | - build/omnitrace-tests-config/*.cfg - build/omnitrace-tests-output/**/*.txt - build/omnitrace-tests-output/**/*-instr*.json + build/rocprofsys-tests-config/*.cfg + build/rocprofsys-tests-output/**/*.txt + build/rocprofsys-tests-output/**/*-instr*.json - name: Kill Perfetto if: success() || failure() diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 085c884b..57d68ac1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,7 +28,7 @@ jobs: run: | sudo apt-get update sudo apt-get install -y cmake - cmake -D OUTPUT_DIR=${PWD} -P scripts/write-omnitrace-install.cmake + cmake -D OUTPUT_DIR=${PWD} -P scripts/write-rocprof-sys-install.cmake - name: Generate Release uses: softprops/action-gh-release@v1 with: @@ -36,4 +36,4 @@ jobs: generate_release_notes: True fail_on_unmatched_files: True files: | - omnitrace-install.py + rocprofiler-systems-install.py diff --git a/.github/workflows/ubuntu-focal.yml b/.github/workflows/ubuntu-focal.yml index 5be371a0..a307b8ad 100644 --- a/.github/workflows/ubuntu-focal.yml +++ b/.github/workflows/ubuntu-focal.yml @@ -32,8 +32,8 @@ concurrency: cancel-in-progress: true env: - OMNITRACE_CI: ON - OMNITRACE_TMPDIR: "%env{PWD}%/testing-tmp" + ROCPROFSYS_CI: ON + ROCPROFSYS_TMPDIR: "%env{PWD}%/testing-tmp" jobs: ubuntu-focal-external: @@ -140,23 +140,23 @@ jobs: -DCMAKE_C_COMPILER=$(echo '${{ matrix.compiler }}' | sed 's/+/c/g') -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} - -DCMAKE_INSTALL_PREFIX=/opt/omnitrace - -DOMNITRACE_BUILD_TESTING=ON - -DOMNITRACE_USE_MPI=OFF - -DOMNITRACE_USE_HIP=OFF - -DOMNITRACE_USE_OMPT=OFF - -DOMNITRACE_USE_PAPI=OFF - -DOMNITRACE_USE_PYTHON=${{ matrix.python }} - -DOMNITRACE_USE_MPI_HEADERS=${{ matrix.mpi-headers }} - -DOMNITRACE_STRIP_LIBRARIES=${{ matrix.strip }} - -DOMNITRACE_BUILD_LTO=${{ matrix.lto }} - -DOMNITRACE_BUILD_STATIC_LIBGCC=${{ matrix.static-libgcc }} - -DOMNITRACE_BUILD_STATIC_LIBSTDCXX=${{ matrix.static-libstdcxx }} - -DOMNITRACE_PYTHON_PREFIX=/opt/conda/envs - -DOMNITRACE_PYTHON_ENVS="py3.6;py3.7;py3.8;py3.9;py3.10;py3.11" - -DOMNITRACE_MAX_THREADS=64 - -DOMNITRACE_DISABLE_EXAMPLES="transpose;rccl" - -DOMNITRACE_BUILD_NUMBER=${{ github.run_attempt }} + -DCMAKE_INSTALL_PREFIX=/opt/rocprofiler-systems + -DROCPROFSYS_BUILD_TESTING=ON + -DROCPROFSYS_USE_MPI=OFF + -DROCPROFSYS_USE_HIP=OFF + -DROCPROFSYS_USE_OMPT=OFF + -DROCPROFSYS_USE_PAPI=OFF + -DROCPROFSYS_USE_PYTHON=${{ matrix.python }} + -DROCPROFSYS_USE_MPI_HEADERS=${{ matrix.mpi-headers }} + -DROCPROFSYS_STRIP_LIBRARIES=${{ matrix.strip }} + -DROCPROFSYS_BUILD_LTO=${{ matrix.lto }} + -DROCPROFSYS_BUILD_STATIC_LIBGCC=${{ matrix.static-libgcc }} + -DROCPROFSYS_BUILD_STATIC_LIBSTDCXX=${{ matrix.static-libstdcxx }} + -DROCPROFSYS_PYTHON_PREFIX=/opt/conda/envs + -DROCPROFSYS_PYTHON_ENVS="py3.6;py3.7;py3.8;py3.9;py3.10;py3.11" + -DROCPROFSYS_MAX_THREADS=64 + -DROCPROFSYS_DISABLE_EXAMPLES="transpose;rccl" + -DROCPROFSYS_BUILD_NUMBER=${{ github.run_attempt }} -DMPI_HEADERS_ALLOW_MPICH=OFF - name: Test Build-Tree Module @@ -167,24 +167,24 @@ jobs: source /usr/share/modules/init/$(basename ${SHELL}) module use ./share/modulefiles module avail - module load omnitrace - echo $(which omnitrace) - ldd $(which omnitrace) - omnitrace-instrument --help - omnitrace-avail --help - omnitrace-sample --help + module load rocprofiler-systems + echo $(which rocprof-sys-instrument) + ldd $(which rocprof-sys-instrument) + rocprof-sys-instrument --help + rocprof-sys-avail --help + rocprof-sys-sample --help - name: Test Build-Tree Source Script timeout-minutes: 45 shell: bash run: | cd build - source ./share/omnitrace/setup-env.sh - echo $(which omnitrace) - ldd $(which omnitrace) - omnitrace-instrument --help - omnitrace-avail --help - omnitrace-sample --help + source ./share/rocprofiler-systems/setup-env.sh + echo $(which rocprof-sys-instrument) + ldd $(which rocprof-sys-instrument) + rocprof-sys-instrument --help + rocprof-sys-avail --help + rocprof-sys-sample --help - name: Install timeout-minutes: 10 @@ -196,16 +196,16 @@ jobs: shell: bash run: | source /usr/share/modules/init/$(basename ${SHELL}) - module use /opt/omnitrace/share/modulefiles + module use /opt/rocprofiler-systems/share/modulefiles module avail - module load omnitrace - ./scripts/test-install.sh --test-omnitrace-{instrument,avail,sample,rewrite,runtime}=1 --test-omnitrace-python=${{ matrix.python }} + module load rocprofiler-systems + ./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 run: | set -v - ./scripts/test-find-package.sh --install-dir /opt/omnitrace + ./scripts/test-find-package.sh --install-dir /opt/rocprofiler-systems - name: CTest Artifacts if: failure() @@ -223,9 +223,9 @@ jobs: with: name: data-${{ github.job }}-${{ strategy.job-index }}-files path: | - build/omnitrace-tests-config/*.cfg - build/omnitrace-tests-output/**/*.txt - build/omnitrace-tests-output/**/*-instr*.json + build/rocprofsys-tests-config/*.cfg + build/rocprofsys-tests-output/**/*.txt + build/rocprofsys-tests-output/**/*-instr*.json - name: Kill Perfetto if: success() || failure() @@ -294,20 +294,20 @@ jobs: echo "CMAKE_PREFIX_PATH=/opt/dyninst:${CMAKE_PREFIX_PATH}" >> $GITHUB_ENV echo "LD_LIBRARY_PATH=/opt/rocm/lib:/usr/local/lib:${LD_LIBRARY_PATH}" >> $GITHUB_ENV cat << EOF > test-install.cfg - OMNITRACE_PROFILE = ON - OMNITRACE_TRACE = ON - OMNITRACE_USE_PID = OFF - OMNITRACE_USE_SAMPLING = OFF - OMNITRACE_USE_PROCESS_SAMPLING = OFF - OMNITRACE_COUT_OUTPUT = ON - OMNITRACE_TIME_OUTPUT = OFF - OMNITRACE_TIMEMORY_COMPONENTS = cpu_clock cpu_util current_peak_rss kernel_mode_time monotonic_clock monotonic_raw_clock network_stats num_io_in num_io_out num_major_page_faults num_minor_page_faults page_rss peak_rss priority_context_switch process_cpu_clock process_cpu_util read_bytes read_char system_clock thread_cpu_clock thread_cpu_util timestamp trip_count user_clock user_mode_time virtual_memory voluntary_context_switch wall_clock written_bytes written_char - OMNITRACE_OUTPUT_PATH = omnitrace-tests-output - OMNITRACE_OUTPUT_PREFIX = %tag%/ - OMNITRACE_DEBUG = OFF - OMNITRACE_VERBOSE = 3 - OMNITRACE_DL_VERBOSE = 3 - OMNITRACE_PERFETTO_BACKEND = system + ROCPROFSYS_PROFILE = ON + ROCPROFSYS_TRACE = ON + ROCPROFSYS_USE_PID = OFF + ROCPROFSYS_USE_SAMPLING = OFF + ROCPROFSYS_USE_PROCESS_SAMPLING = OFF + ROCPROFSYS_COUT_OUTPUT = ON + ROCPROFSYS_TIME_OUTPUT = OFF + ROCPROFSYS_TIMEMORY_COMPONENTS = cpu_clock cpu_util current_peak_rss kernel_mode_time monotonic_clock monotonic_raw_clock network_stats num_io_in num_io_out num_major_page_faults num_minor_page_faults page_rss peak_rss priority_context_switch process_cpu_clock process_cpu_util read_bytes read_char system_clock thread_cpu_clock thread_cpu_util timestamp trip_count user_clock user_mode_time virtual_memory voluntary_context_switch wall_clock written_bytes written_char + ROCPROFSYS_OUTPUT_PATH = rocprofsys-tests-output + ROCPROFSYS_OUTPUT_PREFIX = %tag%/ + ROCPROFSYS_DEBUG = OFF + ROCPROFSYS_VERBOSE = 3 + ROCPROFSYS_DL_VERBOSE = 3 + ROCPROFSYS_PERFETTO_BACKEND = system EOF realpath test-install.cfg cat test-install.cfg @@ -328,25 +328,25 @@ jobs: -DCMAKE_C_COMPILER=$(echo '${{ matrix.compiler }}' | sed 's/+/c/g') -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} - -DCMAKE_INSTALL_PREFIX=/opt/omnitrace - -DOMNITRACE_BUILD_TESTING=ON - -DOMNITRACE_BUILD_DEVELOPER=ON - -DOMNITRACE_BUILD_EXTRA_OPTIMIZATIONS=OFF - -DOMNITRACE_BUILD_LTO=OFF - -DOMNITRACE_USE_MPI=OFF - -DOMNITRACE_USE_HIP=ON - -DOMNITRACE_MAX_THREADS=64 - -DOMNITRACE_USE_PAPI=OFF - -DOMNITRACE_USE_OMPT=OFF - -DOMNITRACE_USE_PYTHON=ON - -DOMNITRACE_USE_MPI_HEADERS=${{ matrix.mpi-headers }} - -DOMNITRACE_USE_SANITIZER=OFF - -DOMNITRACE_PYTHON_PREFIX=/opt/conda/envs - -DOMNITRACE_PYTHON_ENVS="py3.6;py3.7;py3.8;py3.9;py3.10;py3.11" - -DOMNITRACE_CI_MPI_RUN_AS_ROOT=${{ matrix.mpi-headers }} - -DOMNITRACE_CI_GPU=OFF + -DCMAKE_INSTALL_PREFIX=/opt/rocprofiler-systems + -DROCPROFSYS_BUILD_TESTING=ON + -DROCPROFSYS_BUILD_DEVELOPER=ON + -DROCPROFSYS_BUILD_EXTRA_OPTIMIZATIONS=OFF + -DROCPROFSYS_BUILD_LTO=OFF + -DROCPROFSYS_USE_MPI=OFF + -DROCPROFSYS_USE_HIP=ON + -DROCPROFSYS_MAX_THREADS=64 + -DROCPROFSYS_USE_PAPI=OFF + -DROCPROFSYS_USE_OMPT=OFF + -DROCPROFSYS_USE_PYTHON=ON + -DROCPROFSYS_USE_MPI_HEADERS=${{ matrix.mpi-headers }} + -DROCPROFSYS_USE_SANITIZER=OFF + -DROCPROFSYS_PYTHON_PREFIX=/opt/conda/envs + -DROCPROFSYS_PYTHON_ENVS="py3.6;py3.7;py3.8;py3.9;py3.10;py3.11" + -DROCPROFSYS_CI_MPI_RUN_AS_ROOT=${{ matrix.mpi-headers }} + -DROCPROFSYS_CI_GPU=OFF -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=OFF - -DOMNITRACE_BUILD_NUMBER=${{ github.run_attempt }} + -DROCPROFSYS_BUILD_NUMBER=${{ github.run_attempt }} -- ${{ matrix.ctest-exclude }} @@ -358,14 +358,14 @@ jobs: timeout-minutes: 15 shell: bash run: | - source /opt/omnitrace/share/omnitrace/setup-env.sh - ./scripts/test-install.sh --test-omnitrace-{instrument,avail,sample,python,rewrite,runtime}=1 + source /opt/rocprofiler-systems/share/rocprofiler-systems/setup-env.sh + ./scripts/test-install.sh --test-rocprof-sys-{instrument,avail,sample,python,rewrite,runtime}=1 - name: Test User API timeout-minutes: 10 run: | set -v - ./scripts/test-find-package.sh --install-dir /opt/omnitrace + ./scripts/test-find-package.sh --install-dir /opt/rocprofiler-systems - name: CTest Artifacts if: failure() @@ -383,10 +383,10 @@ jobs: with: name: data-${{ github.job }}-${{ strategy.job-index }}-files path: | - omnitrace-tests-output/**/*.txt - build/omnitrace-tests-config/*.cfg - build/omnitrace-tests-output/**/*.txt - build/omnitrace-tests-output/**/*-instr*.json + rocprofsys-tests-output/**/*.txt + build/rocprofsys-tests-config/*.cfg + build/rocprofsys-tests-output/**/*.txt + build/rocprofsys-tests-output/**/*-instr*.json - name: Kill Perfetto if: success() || failure() @@ -476,14 +476,14 @@ jobs: -DCMAKE_C_COMPILER=$(echo '${{ matrix.compiler }}' | sed 's/+/c/g') -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} - -DCMAKE_INSTALL_PREFIX=/opt/omnitrace - -DOMNITRACE_BUILD_TESTING=ON - -DOMNITRACE_BUILD_DYNINST=ON - -DOMNITRACE_USE_MPI=${USE_MPI} - -DOMNITRACE_USE_HIP=OFF - -DOMNITRACE_USE_PYTHON=${{ matrix.python }} - -DOMNITRACE_USE_OMPT=${{ matrix.ompt }} - -DOMNITRACE_USE_PAPI=${{ matrix.papi }} + -DCMAKE_INSTALL_PREFIX=/opt/rocprofiler-systems + -DROCPROFSYS_BUILD_TESTING=ON + -DROCPROFSYS_BUILD_DYNINST=ON + -DROCPROFSYS_USE_MPI=${USE_MPI} + -DROCPROFSYS_USE_HIP=OFF + -DROCPROFSYS_USE_PYTHON=${{ matrix.python }} + -DROCPROFSYS_USE_OMPT=${{ matrix.ompt }} + -DROCPROFSYS_USE_PAPI=${{ matrix.papi }} -DDYNINST_BUILD_ELFUTILS=ON -DDYNINST_BUILD_LIBIBERTY=ON -DDYNINST_BUILD_TBB=${{ matrix.tbb }} @@ -491,9 +491,9 @@ jobs: -DDYNINST_BUILD_SHARED_LIBS=ON -DDYNINST_BUILD_STATIC_LIBS=OFF -DDYNINST_ELFUTILS_DOWNLOAD_VERSION=${{ env.ELFUTILS_DOWNLOAD_VERSION }} - -DOMNITRACE_MAX_THREADS=64 - -DOMNITRACE_DISABLE_EXAMPLES="transpose;rccl" - -DOMNITRACE_BUILD_NUMBER=${{ github.run_attempt }} + -DROCPROFSYS_MAX_THREADS=64 + -DROCPROFSYS_DISABLE_EXAMPLES="transpose;rccl" + -DROCPROFSYS_BUILD_NUMBER=${{ github.run_attempt }} -DMPI_HEADERS_ALLOW_MPICH=ON - name: Test Build-Tree Env @@ -502,43 +502,43 @@ jobs: source /usr/share/modules/init/$(basename ${SHELL}) module use ${{ github.workspace }}/build/share/modulefiles module avail - module load omnitrace + module load rocprofiler-systems module list env - module unload omnitrace + module unload rocprofiler-systems module list env - source ${{ github.workspace }}/build/share/omnitrace/setup-env.sh + source ${{ github.workspace }}/build/share/rocprofiler-systems/setup-env.sh env - name: Install working-directory: ${{ github.workspace }}/build run: | cpack -G STGZ - mkdir -p /opt/omnitrace - ./omnitrace-*.sh --prefix=/opt/omnitrace --exclude-subdir --skip-license + mkdir -p /opt/rocprofiler-systems + ./rocprofiler-systems-*.sh --prefix=/opt/rocprofiler-systems --exclude-subdir --skip-license - name: Test Install with setup-env.sh timeout-minutes: 15 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 + source /opt/rocprofiler-systems/share/rocprofiler-systems/setup-env.sh + ${{ github.workspace }}/scripts/test-install.sh --test-rocprof-sys-{instrument,avail,sample,python,rewrite,runtime}=1 - name: Test Install with Modulefile timeout-minutes: 15 run: | set -v 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 + module use /opt/rocprofiler-systems/share/modulefiles + module load rocprofiler-systems + ${{ github.workspace }}/scripts/test-install.sh --test-rocprof-sys-{instrument,avail,sample,python,rewrite,runtime}=1 - name: Test User API timeout-minutes: 10 run: | set -v - ${{ github.workspace }}/scripts/test-find-package.sh --install-dir /opt/omnitrace + ${{ github.workspace }}/scripts/test-find-package.sh --install-dir /opt/rocprofiler-systems - name: CTest Artifacts if: failure() @@ -556,9 +556,9 @@ jobs: with: name: data-${{ github.job }}-${{ strategy.job-index }}-files path: | - ${{ github.workspace }}/build/omnitrace-tests-config/*.cfg - ${{ github.workspace }}/build/omnitrace-tests-output/**/*.txt - ${{ github.workspace }}/build/omnitrace-tests-output/**/*-instr*.json + ${{ github.workspace }}/build/rocprof-sys-tests-config/*.cfg + ${{ github.workspace }}/build/rocprof-sys-tests-output/**/*.txt + ${{ github.workspace }}/build/rocprof-sys-tests-output/**/*-instr*.json - name: Kill Perfetto if: success() || failure() @@ -576,8 +576,8 @@ jobs: options: --cap-add CAP_SYS_ADMIN env: - OMNITRACE_VERBOSE: 2 - OMNITRACE_CAUSAL_BACKEND: perf + ROCPROFSYS_VERBOSE: 2 + ROCPROFSYS_CAUSAL_BACKEND: perf steps: - uses: actions/checkout@v4 @@ -618,18 +618,18 @@ jobs: --site GitHub --coverage -- - -DCMAKE_INSTALL_PREFIX=/opt/omnitrace - -DOMNITRACE_BUILD_CI=OFF - -DOMNITRACE_BUILD_TESTING=ON - -DOMNITRACE_BUILD_DYNINST=OFF - -DOMNITRACE_BUILD_DEBUG=OFF - -DOMNITRACE_BUILD_HIDDEN_VISIBILITY=OFF - -DOMNITRACE_USE_MPI=ON - -DOMNITRACE_USE_PYTHON=ON - -DOMNITRACE_USE_OMPT=ON - -DOMNITRACE_USE_PAPI=ON - -DOMNITRACE_USE_HIP=OFF - -DOMNITRACE_USE_RCCL=OFF - -DOMNITRACE_MAX_THREADS=64 - -DOMNITRACE_DISABLE_EXAMPLES="transpose;rccl" - -DOMNITRACE_BUILD_NUMBER=${{ github.run_attempt }} + -DCMAKE_INSTALL_PREFIX=/opt/rocprofiler-systems + -DROCPROFSYS_BUILD_CI=OFF + -DROCPROFSYS_BUILD_TESTING=ON + -DROCPROFSYS_BUILD_DYNINST=OFF + -DROCPROFSYS_BUILD_DEBUG=OFF + -DROCPROFSYS_BUILD_HIDDEN_VISIBILITY=OFF + -DROCPROFSYS_USE_MPI=ON + -DROCPROFSYS_USE_PYTHON=ON + -DROCPROFSYS_USE_OMPT=ON + -DROCPROFSYS_USE_PAPI=ON + -DROCPROFSYS_USE_HIP=OFF + -DROCPROFSYS_USE_RCCL=OFF + -DROCPROFSYS_MAX_THREADS=64 + -DROCPROFSYS_DISABLE_EXAMPLES="transpose;rccl" + -DROCPROFSYS_BUILD_NUMBER=${{ github.run_attempt }} diff --git a/.github/workflows/ubuntu-jammy.yml b/.github/workflows/ubuntu-jammy.yml index a7d1d533..603a1517 100644 --- a/.github/workflows/ubuntu-jammy.yml +++ b/.github/workflows/ubuntu-jammy.yml @@ -32,8 +32,8 @@ concurrency: cancel-in-progress: true env: - OMNITRACE_CI: ON - OMNITRACE_TMPDIR: "%env{PWD}%/testing-tmp" + ROCPROFSYS_CI: ON + ROCPROFSYS_TMPDIR: "%env{PWD}%/testing-tmp" jobs: ubuntu-jammy-external: @@ -93,7 +93,7 @@ jobs: env: OMPI_ALLOW_RUN_AS_ROOT: 1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1 - OMNITRACE_CI: 'ON' + ROCPROFSYS_CI: 'ON' steps: - uses: actions/checkout@v4 @@ -178,25 +178,25 @@ jobs: -DCMAKE_C_COMPILER=$(echo '${{ matrix.compiler }}' | sed 's/+/c/g') -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} - -DCMAKE_INSTALL_PREFIX=/opt/omnitrace-dev - -DOMNITRACE_BUILD_TESTING=ON - -DOMNITRACE_USE_MPI=${{ matrix.mpi }} - -DOMNITRACE_USE_HIP=${{ matrix.hip }} - -DOMNITRACE_USE_OMPT=${{ matrix.ompt }} - -DOMNITRACE_USE_PAPI=${{ matrix.papi }} - -DOMNITRACE_USE_PYTHON=${{ matrix.python }} - -DOMNITRACE_USE_MPI_HEADERS=${{ matrix.mpi-headers }} - -DOMNITRACE_BUILD_LTO=${{ matrix.lto }} - -DOMNITRACE_BUILD_DYNINST=${{ matrix.build-dyninst }} - -DOMNITRACE_BUILD_HIDDEN_VISIBILITY=${{ matrix.hidden }} - -DOMNITRACE_BUILD_STATIC_LIBGCC=${{ matrix.static-libgcc }} - -DOMNITRACE_BUILD_STATIC_LIBSTDCXX=${{ matrix.static-libstdcxx }} - -DOMNITRACE_PYTHON_PREFIX=/opt/conda/envs - -DOMNITRACE_PYTHON_ENVS="py3.7;py3.8;py3.9;py3.10;py3.11" - -DOMNITRACE_STRIP_LIBRARIES=${{ matrix.strip }} - -DOMNITRACE_MAX_THREADS=64 - -DOMNITRACE_DISABLE_EXAMPLES="transpose;rccl" - -DOMNITRACE_BUILD_NUMBER=${{ github.run_attempt }} + -DCMAKE_INSTALL_PREFIX=/opt/rocprofiler-systems-dev + -DROCPROFSYS_BUILD_TESTING=ON + -DROCPROFSYS_USE_MPI=${{ matrix.mpi }} + -DROCPROFSYS_USE_HIP=${{ matrix.hip }} + -DROCPROFSYS_USE_OMPT=${{ matrix.ompt }} + -DROCPROFSYS_USE_PAPI=${{ matrix.papi }} + -DROCPROFSYS_USE_PYTHON=${{ matrix.python }} + -DROCPROFSYS_USE_MPI_HEADERS=${{ matrix.mpi-headers }} + -DROCPROFSYS_BUILD_LTO=${{ matrix.lto }} + -DROCPROFSYS_BUILD_DYNINST=${{ matrix.build-dyninst }} + -DROCPROFSYS_BUILD_HIDDEN_VISIBILITY=${{ matrix.hidden }} + -DROCPROFSYS_BUILD_STATIC_LIBGCC=${{ matrix.static-libgcc }} + -DROCPROFSYS_BUILD_STATIC_LIBSTDCXX=${{ matrix.static-libstdcxx }} + -DROCPROFSYS_PYTHON_PREFIX=/opt/conda/envs + -DROCPROFSYS_PYTHON_ENVS="py3.7;py3.8;py3.9;py3.10;py3.11" + -DROCPROFSYS_STRIP_LIBRARIES=${{ matrix.strip }} + -DROCPROFSYS_MAX_THREADS=64 + -DROCPROFSYS_DISABLE_EXAMPLES="transpose;rccl" + -DROCPROFSYS_BUILD_NUMBER=${{ github.run_attempt }} -DUSE_CLANG_OMP=OFF - name: Install @@ -208,8 +208,8 @@ jobs: run: | cd build cpack -G STGZ - mkdir -p /opt/omnitrace - ./omnitrace-*.sh --prefix=/opt/omnitrace --exclude-subdir --skip-license + mkdir -p /opt/rocprofiler-systems + ./rocprofiler-systems-*.sh --prefix=/opt/rocprofiler-systems --exclude-subdir --skip-license - name: Test Install with Modulefile timeout-minutes: 15 @@ -217,16 +217,16 @@ jobs: run: | set -v source /usr/share/modules/init/$(basename ${SHELL}) - module use /opt/omnitrace/share/modulefiles + module use /opt/rocprofiler-systems/share/modulefiles module avail - module load omnitrace - ./scripts/test-install.sh --test-omnitrace-{instrument,avail,sample,python,rewrite,runtime}=1 + module load rocprofiler-systems + ./scripts/test-install.sh --test-rocprof-sys-{instrument,avail,sample,python,rewrite,runtime}=1 - name: Test User API timeout-minutes: 10 run: | set -v - ./scripts/test-find-package.sh --install-dir /opt/omnitrace + ./scripts/test-find-package.sh --install-dir /opt/rocprofiler-systems - name: CTest Artifacts if: failure() @@ -244,6 +244,6 @@ jobs: with: name: data-${{ github.job }}-${{ strategy.job-index }}-files path: | - build/omnitrace-tests-config/*.cfg - build/omnitrace-tests-output/**/*.txt - build/omnitrace-tests-output/**/*-instr*.json + build/rocprofsys-tests-config/*.cfg + build/rocprofsys-tests-output/**/*.txt + build/rocprofsys-tests-output/**/*-instr*.json diff --git a/.gitignore b/.gitignore index 03f124eb..ca63de3f 100644 --- a/.gitignore +++ b/.gitignore @@ -46,5 +46,5 @@ _toc.yml /.cache /.clangd /compile_commands.json -/omnitrace-install.py -/scripts/omnitrace-install.py +/rocprof-sys-install.py +/scripts/rocprof-sys-install.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d7bf08e..bd161996 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,53 +12,57 @@ endif() if(NOT UNIX OR APPLE) message( AUTHOR_WARNING - "omnitrace only supports Linux. Configure and/or build is likely to fail") + "rocprofiler-systems only supports Linux. Configure and/or build is likely to fail" + ) endif() file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" FULL_VERSION_STRING LIMIT_COUNT 1) string(REGEX REPLACE "(\n|\r)" "" FULL_VERSION_STRING "${FULL_VERSION_STRING}") -string(REGEX REPLACE "([0-9]+)\.([0-9]+)\.([0-9]+)(.*)" "\\1.\\2.\\3" OMNITRACE_VERSION +string(REGEX REPLACE "([0-9]+)\.([0-9]+)\.([0-9]+)(.*)" "\\1.\\2.\\3" ROCPROFSYS_VERSION "${FULL_VERSION_STRING}") project( - omnitrace + rocprofiler-systems LANGUAGES C CXX - VERSION ${OMNITRACE_VERSION} + VERSION ${ROCPROFSYS_VERSION} DESCRIPTION "CPU/GPU Application tracing with static/dynamic binary instrumentation" - HOMEPAGE_URL "https://github.com/ROCm/omnitrace") + HOMEPAGE_URL "https://github.com/ROCm/rocprofiler-systems") +set(PROJECT_NAME_UNDERSCORED "rocprofiler_systems") + +set(BINARY_NAME_PREFIX "rocprof-sys") find_package(Git) if(Git_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") execute_process( COMMAND ${GIT_EXECUTABLE} describe --tags - OUTPUT_VARIABLE OMNITRACE_GIT_DESCRIBE + OUTPUT_VARIABLE ROCPROFSYS_GIT_DESCRIBE OUTPUT_STRIP_TRAILING_WHITESPACE RESULT_VARIABLE _GIT_DESCRIBE_RESULT ERROR_QUIET) if(NOT _GIT_DESCRIBE_RESULT EQUAL 0) execute_process( COMMAND ${GIT_EXECUTABLE} describe - OUTPUT_VARIABLE OMNITRACE_GIT_DESCRIBE + OUTPUT_VARIABLE ROCPROFSYS_GIT_DESCRIBE OUTPUT_STRIP_TRAILING_WHITESPACE RESULT_VARIABLE _GIT_DESCRIBE_RESULT ERROR_QUIET) endif() execute_process( COMMAND ${GIT_EXECUTABLE} rev-parse HEAD - OUTPUT_VARIABLE OMNITRACE_GIT_REVISION + OUTPUT_VARIABLE ROCPROFSYS_GIT_REVISION OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) else() - set(OMNITRACE_GIT_DESCRIBE "v${OMNITRACE_VERSION}") - set(OMNITRACE_GIT_REVISION "") + set(ROCPROFSYS_GIT_DESCRIBE "v${ROCPROFSYS_VERSION}") + set(ROCPROFSYS_GIT_REVISION "") endif() message( STATUS "[${PROJECT_NAME}] version ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} (${FULL_VERSION_STRING})" ) -message(STATUS "[${PROJECT_NAME}] git revision: ${OMNITRACE_GIT_REVISION}") -message(STATUS "[${PROJECT_NAME}] git describe: ${OMNITRACE_GIT_DESCRIBE}") +message(STATUS "[${PROJECT_NAME}] git revision: ${ROCPROFSYS_GIT_REVISION}") +message(STATUS "[${PROJECT_NAME}] git describe: ${ROCPROFSYS_GIT_DESCRIBE}") set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${PROJECT_SOURCE_DIR}/cmake/Modules ${PROJECT_SOURCE_DIR}/source/python/cmake ${CMAKE_MODULE_PATH}) set(BUILD_SHARED_LIBS @@ -104,8 +108,8 @@ if(DEFINED CMAKE_INSTALL_LIBDIR AND NOT DEFINED CMAKE_DEFAULT_INSTALL_LIBDIR) CACHE STRING "Object code libraries" FORCE) endif() -if(NOT "$ENV{OMNITRACE_CI}" STREQUAL "") - set(CI_BUILD $ENV{OMNITRACE_CI}) +if(NOT "$ENV{ROCPROFSYS_CI}" STREQUAL "") + set(CI_BUILD $ENV{ROCPROFSYS_CI}) else() set(CI_BUILD OFF) endif() @@ -114,30 +118,33 @@ include(GNUInstallDirs) # install directories include(MacroUtilities) # various functions and macros if(CI_BUILD) - omnitrace_add_option(OMNITRACE_BUILD_CI "Enable internal asserts, etc." ON ADVANCED - NO_FEATURE) - omnitrace_add_option(OMNITRACE_BUILD_TESTING "Enable building the testing suite" ON - ADVANCED) - omnitrace_add_option(OMNITRACE_BUILD_DEBUG - "Enable building with extensive debug symbols" OFF ADVANCED) - omnitrace_add_option( - OMNITRACE_BUILD_HIDDEN_VISIBILITY + rocprofiler_systems_add_option(ROCPROFSYS_BUILD_CI "Enable internal asserts, etc." ON + ADVANCED NO_FEATURE) + rocprofiler_systems_add_option(ROCPROFSYS_BUILD_TESTING + "Enable building the testing suite" ON ADVANCED) + rocprofiler_systems_add_option( + ROCPROFSYS_BUILD_DEBUG "Enable building with extensive debug symbols" OFF + ADVANCED) + rocprofiler_systems_add_option( + ROCPROFSYS_BUILD_HIDDEN_VISIBILITY "Build with hidden visibility (disable for Debug builds)" OFF ADVANCED) - omnitrace_add_option(OMNITRACE_STRIP_LIBRARIES "Strip the libraries" OFF ADVANCED) + rocprofiler_systems_add_option(ROCPROFSYS_STRIP_LIBRARIES "Strip the libraries" OFF + ADVANCED) else() - omnitrace_add_option(OMNITRACE_BUILD_CI "Enable internal asserts, etc." OFF ADVANCED - NO_FEATURE) - omnitrace_add_option(OMNITRACE_BUILD_EXAMPLES "Enable building the examples" OFF - ADVANCED) - omnitrace_add_option(OMNITRACE_BUILD_TESTING "Enable building the testing suite" OFF - ADVANCED) - omnitrace_add_option(OMNITRACE_BUILD_DEBUG - "Enable building with extensive debug symbols" OFF ADVANCED) - omnitrace_add_option( - OMNITRACE_BUILD_HIDDEN_VISIBILITY + rocprofiler_systems_add_option(ROCPROFSYS_BUILD_CI "Enable internal asserts, etc." + OFF ADVANCED NO_FEATURE) + rocprofiler_systems_add_option(ROCPROFSYS_BUILD_EXAMPLES + "Enable building the examples" OFF ADVANCED) + rocprofiler_systems_add_option(ROCPROFSYS_BUILD_TESTING + "Enable building the testing suite" OFF ADVANCED) + rocprofiler_systems_add_option( + ROCPROFSYS_BUILD_DEBUG "Enable building with extensive debug symbols" OFF + ADVANCED) + rocprofiler_systems_add_option( + ROCPROFSYS_BUILD_HIDDEN_VISIBILITY "Build with hidden visibility (disable for Debug builds)" ON ADVANCED) - omnitrace_add_option(OMNITRACE_STRIP_LIBRARIES "Strip the libraries" - ${_STRIP_LIBRARIES_DEFAULT} ADVANCED) + rocprofiler_systems_add_option(ROCPROFSYS_STRIP_LIBRARIES "Strip the libraries" + ${_STRIP_LIBRARIES_DEFAULT} ADVANCED) endif() include(Compilers) # compiler identification @@ -150,139 +157,146 @@ set(CMAKE_CXX_STANDARD 17 CACHE STRING "CXX language standard") -omnitrace_add_feature(CMAKE_BUILD_TYPE "Build optimization level") -omnitrace_add_feature(CMAKE_INSTALL_PREFIX "Installation prefix") -omnitrace_add_feature(CMAKE_CXX_COMPILER "C++ compiler") -omnitrace_add_feature(CMAKE_CXX_STANDARD "CXX language standard") -omnitrace_add_option(CMAKE_CXX_STANDARD_REQUIRED "Require C++ language standard" ON) -omnitrace_add_option(CMAKE_CXX_EXTENSIONS "Compiler specific language extensions" OFF) -omnitrace_add_option(CMAKE_INSTALL_RPATH_USE_LINK_PATH "Enable rpath to linked libraries" - ON) +rocprofiler_systems_add_feature(CMAKE_BUILD_TYPE "Build optimization level") +rocprofiler_systems_add_feature(CMAKE_INSTALL_PREFIX "Installation prefix") +rocprofiler_systems_add_feature(CMAKE_CXX_COMPILER "C++ compiler") +rocprofiler_systems_add_feature(CMAKE_CXX_STANDARD "CXX language standard") +rocprofiler_systems_add_option(CMAKE_CXX_STANDARD_REQUIRED + "Require C++ language standard" ON) +rocprofiler_systems_add_option(CMAKE_CXX_EXTENSIONS + "Compiler specific language extensions" OFF) +rocprofiler_systems_add_option(CMAKE_INSTALL_RPATH_USE_LINK_PATH + "Enable rpath to linked libraries" ON) set(CMAKE_INSTALL_MESSAGE "LAZY" CACHE STRING "Installation message") mark_as_advanced(CMAKE_INSTALL_MESSAGE) -omnitrace_add_option(OMNITRACE_USE_CLANG_TIDY "Enable clang-tidy" OFF) -omnitrace_add_option(OMNITRACE_USE_BFD - "Enable BFD support (map call-stack samples to LOC)" ON) -omnitrace_add_option(OMNITRACE_USE_MPI "Enable MPI support" OFF) -omnitrace_add_option(OMNITRACE_USE_HIP "Enable HIP support" ON) -omnitrace_add_option(OMNITRACE_USE_PAPI "Enable HW counter support via PAPI" ON) -omnitrace_add_option(OMNITRACE_USE_ROCTRACER "Enable roctracer support" - ${OMNITRACE_USE_HIP}) -omnitrace_add_option(OMNITRACE_USE_ROCPROFILER "Enable rocprofiler support" - ${OMNITRACE_USE_HIP}) -omnitrace_add_option( - OMNITRACE_USE_ROCM_SMI "Enable rocm-smi support for power/temp/etc. sampling" - ${OMNITRACE_USE_HIP}) -omnitrace_add_option(OMNITRACE_USE_RCCL "Enable RCCL support" ${OMNITRACE_USE_HIP}) -omnitrace_add_option(OMNITRACE_USE_MPI_HEADERS - "Enable wrapping MPI functions w/o enabling MPI dependency" ON) -omnitrace_add_option(OMNITRACE_USE_OMPT "Enable OpenMP tools support" ON) -omnitrace_add_option(OMNITRACE_USE_PYTHON "Enable Python support" OFF) -omnitrace_add_option(OMNITRACE_BUILD_DYNINST "Build dyninst from submodule" OFF) -omnitrace_add_option(OMNITRACE_BUILD_LIBUNWIND "Build libunwind from submodule" ON) -omnitrace_add_option(OMNITRACE_BUILD_CODECOV "Build for code coverage" OFF) -omnitrace_add_option(OMNITRACE_INSTALL_PERFETTO_TOOLS - "Install perfetto tools (i.e. traced, perfetto, etc.)" OFF) - -if(OMNITRACE_USE_PAPI) - omnitrace_add_option(OMNITRACE_BUILD_PAPI "Build PAPI from submodule" ON) +rocprofiler_systems_add_option(ROCPROFSYS_USE_CLANG_TIDY "Enable clang-tidy" OFF) +rocprofiler_systems_add_option(ROCPROFSYS_USE_BFD + "Enable BFD support (map call-stack samples to LOC)" ON) +rocprofiler_systems_add_option(ROCPROFSYS_USE_MPI "Enable MPI support" OFF) +rocprofiler_systems_add_option(ROCPROFSYS_USE_HIP "Enable HIP support" ON) +rocprofiler_systems_add_option(ROCPROFSYS_USE_PAPI "Enable HW counter support via PAPI" + ON) +rocprofiler_systems_add_option(ROCPROFSYS_USE_ROCTRACER "Enable roctracer support" + ${ROCPROFSYS_USE_HIP}) +rocprofiler_systems_add_option(ROCPROFSYS_USE_ROCPROFILER "Enable rocprofiler support" + ${ROCPROFSYS_USE_HIP}) +rocprofiler_systems_add_option( + ROCPROFSYS_USE_ROCM_SMI "Enable rocm-smi support for power/temp/etc. sampling" + ${ROCPROFSYS_USE_HIP}) +rocprofiler_systems_add_option(ROCPROFSYS_USE_RCCL "Enable RCCL support" + ${ROCPROFSYS_USE_HIP}) +rocprofiler_systems_add_option( + ROCPROFSYS_USE_MPI_HEADERS + "Enable wrapping MPI functions w/o enabling MPI dependency" ON) +rocprofiler_systems_add_option(ROCPROFSYS_USE_OMPT "Enable OpenMP tools support" ON) +rocprofiler_systems_add_option(ROCPROFSYS_USE_PYTHON "Enable Python support" OFF) +rocprofiler_systems_add_option(ROCPROFSYS_BUILD_DYNINST "Build dyninst from submodule" + OFF) +rocprofiler_systems_add_option(ROCPROFSYS_BUILD_LIBUNWIND + "Build libunwind from submodule" ON) +rocprofiler_systems_add_option(ROCPROFSYS_BUILD_CODECOV "Build for code coverage" OFF) +rocprofiler_systems_add_option(ROCPROFSYS_INSTALL_PERFETTO_TOOLS + "Install perfetto tools (i.e. traced, perfetto, etc.)" OFF) + +if(ROCPROFSYS_USE_PAPI) + rocprofiler_systems_add_option(ROCPROFSYS_BUILD_PAPI "Build PAPI from submodule" ON) endif() -if(OMNITRACE_USE_PYTHON) - omnitrace_add_option(OMNITRACE_BUILD_PYTHON - "Build python bindings with internal pybind11" ON) -elseif("$ENV{OMNITRACE_CI}") +if(ROCPROFSYS_USE_PYTHON) + rocprofiler_systems_add_option(ROCPROFSYS_BUILD_PYTHON + "Build python bindings with internal pybind11" ON) +elseif("$ENV{ROCPROFSYS_CI}") # quiet warnings in dashboard - if(OMNITRACE_PYTHON_ENVS OR OMNITRACE_PYTHON_PREFIX) - omnitrace_message( + if(ROCPROFSYS_PYTHON_ENVS OR ROCPROFSYS_PYTHON_PREFIX) + rocprofiler_systems_message( STATUS - "Ignoring values of OMNITRACE_PYTHON_ENVS and/or OMNITRACE_PYTHON_PREFIX") + "Ignoring values of ROCPROFSYS_PYTHON_ENVS and/or ROCPROFSYS_PYTHON_PREFIX") endif() endif() -if(NOT OMNITRACE_USE_HIP) - set(OMNITRACE_USE_ROCTRACER +if(NOT ROCPROFSYS_USE_HIP) + set(ROCPROFSYS_USE_ROCTRACER OFF - CACHE BOOL "Disabled via OMNITRACE_USE_HIP=OFF" FORCE) - set(OMNITRACE_USE_ROCPROFILER + CACHE BOOL "Disabled via ROCPROFSYS_USE_HIP=OFF" FORCE) + set(ROCPROFSYS_USE_ROCPROFILER OFF - CACHE BOOL "Disabled via OMNITRACE_USE_HIP=OFF" FORCE) - set(OMNITRACE_USE_ROCM_SMI + CACHE BOOL "Disabled via ROCPROFSYS_USE_HIP=OFF" FORCE) + set(ROCPROFSYS_USE_ROCM_SMI OFF - CACHE BOOL "Disabled via OMNITRACE_USE_HIP=OFF" FORCE) - set(OMNITRACE_USE_RCCL + CACHE BOOL "Disabled via ROCPROFSYS_USE_HIP=OFF" FORCE) + set(ROCPROFSYS_USE_RCCL OFF - CACHE BOOL "Disabled via OMNITRACE_USE_HIP=OFF" FORCE) + CACHE BOOL "Disabled via ROCPROFSYS_USE_HIP=OFF" FORCE) elseif( - OMNITRACE_USE_HIP - AND NOT OMNITRACE_USE_ROCTRACER - AND NOT OMNITRACE_USE_ROCPROFILER - AND NOT OMNITRACE_USE_ROCM_SMI - AND NOT OMNITRACE_USE_RCCL) - omnitrace_message( + ROCPROFSYS_USE_HIP + AND NOT ROCPROFSYS_USE_ROCTRACER + AND NOT ROCPROFSYS_USE_ROCPROFILER + AND NOT ROCPROFSYS_USE_ROCM_SMI + AND NOT ROCPROFSYS_USE_RCCL) + rocprofiler_systems_message( AUTHOR_WARNING - "Setting OMNITRACE_USE_HIP=OFF because roctracer, rocprofiler, rccl, and rocm-smi options are disabled" + "Setting ROCPROFSYS_USE_HIP=OFF because roctracer, rocprofiler, rccl, and rocm-smi options are disabled" ) - set(OMNITRACE_USE_HIP OFF) + set(ROCPROFSYS_USE_HIP OFF) endif() -if(OMNITRACE_BUILD_TESTING) - set(OMNITRACE_BUILD_EXAMPLES +if(ROCPROFSYS_BUILD_TESTING) + set(ROCPROFSYS_BUILD_EXAMPLES ON CACHE BOOL "Enable building the examples" FORCE) endif() include(ProcessorCount) -processorcount(OMNITRACE_PROCESSOR_COUNT) +processorcount(ROCPROFSYS_PROCESSOR_COUNT) -if(OMNITRACE_PROCESSOR_COUNT LESS 8) - set(OMNITRACE_THREAD_COUNT 128) +if(ROCPROFSYS_PROCESSOR_COUNT LESS 8) + set(ROCPROFSYS_THREAD_COUNT 128) else() - math(EXPR OMNITRACE_THREAD_COUNT "16 * ${OMNITRACE_PROCESSOR_COUNT}") - compute_pow2_ceil(OMNITRACE_THREAD_COUNT "16 * ${OMNITRACE_PROCESSOR_COUNT}") + math(EXPR ROCPROFSYS_THREAD_COUNT "16 * ${ROCPROFSYS_PROCESSOR_COUNT}") + compute_pow2_ceil(ROCPROFSYS_THREAD_COUNT "16 * ${ROCPROFSYS_PROCESSOR_COUNT}") # set the default to 2048 if it could not be calculated - if(OMNITRACE_THREAD_COUNT LESS 2) - set(OMNITRACE_THREAD_COUNT 2048) + if(ROCPROFSYS_THREAD_COUNT LESS 2) + set(ROCPROFSYS_THREAD_COUNT 2048) endif() endif() -set(OMNITRACE_MAX_THREADS - "${OMNITRACE_THREAD_COUNT}" +set(ROCPROFSYS_MAX_THREADS + "${ROCPROFSYS_THREAD_COUNT}" CACHE STRING "Maximum number of threads in the host application. Likely only needs to be increased if host app does not use thread-pool but creates many threads" ) -omnitrace_add_feature( - OMNITRACE_MAX_THREADS +rocprofiler_systems_add_feature( + ROCPROFSYS_MAX_THREADS "Maximum number of total threads supported in the host application (default: max of 128 or 16 * nproc)" ) -compute_pow2_ceil(_MAX_THREADS "${OMNITRACE_MAX_THREADS}") +compute_pow2_ceil(_MAX_THREADS "${ROCPROFSYS_MAX_THREADS}") -if(_MAX_THREADS GREATER 0 AND NOT OMNITRACE_MAX_THREADS EQUAL _MAX_THREADS) - omnitrace_message( +if(_MAX_THREADS GREATER 0 AND NOT ROCPROFSYS_MAX_THREADS EQUAL _MAX_THREADS) + rocprofiler_systems_message( FATAL_ERROR - "Error! OMNITRACE_MAX_THREADS must be a power of 2. Recommendation: ${_MAX_THREADS}" + "Error! ROCPROFSYS_MAX_THREADS must be a power of 2. Recommendation: ${_MAX_THREADS}" ) -elseif(NOT OMNITRACE_MAX_THREADS EQUAL _MAX_THREADS) - omnitrace_message( +elseif(NOT ROCPROFSYS_MAX_THREADS EQUAL _MAX_THREADS) + rocprofiler_systems_message( AUTHOR_WARNING - "OMNITRACE_MAX_THREADS (=${OMNITRACE_MAX_THREADS}) must be a power of 2. We were unable to verify it so we are emitting this warning instead. Estimate resulted in: ${_MAX_THREADS}" + "ROCPROFSYS_MAX_THREADS (=${ROCPROFSYS_MAX_THREADS}) must be a power of 2. We were unable to verify it so we are emitting this warning instead. Estimate resulted in: ${_MAX_THREADS}" ) endif() -set(OMNITRACE_MAX_UNWIND_DEPTH +set(ROCPROFSYS_MAX_UNWIND_DEPTH "64" CACHE STRING "Maximum call-stack depth to search during call-stack unwinding. Decreasing this value will result in sampling consuming less memory" ) -omnitrace_add_feature( - OMNITRACE_MAX_UNWIND_DEPTH +rocprofiler_systems_add_feature( + ROCPROFSYS_MAX_UNWIND_DEPTH "Maximum call-stack depth to search during call-stack unwinding. Decreasing this value will result in sampling consuming less memory" ) @@ -301,16 +315,16 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) include(Formatting) # format target include(Packages) # finds third-party libraries -omnitrace_activate_clang_tidy() +rocprofiler_systems_activate_clang_tidy() # custom visibility settings -if(OMNITRACE_BUILD_HIDDEN_VISIBILITY) +if(ROCPROFSYS_BUILD_HIDDEN_VISIBILITY) set(CMAKE_C_VISIBILITY_PRESET "internal") set(CMAKE_CXX_VISIBILITY_PRESET "internal") set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) endif() -if(OMNITRACE_BUILD_TESTING OR "$ENV{OMNITRACE_CI}" MATCHES "[1-9]+|ON|on|y|yes") +if(ROCPROFSYS_BUILD_TESTING OR "$ENV{ROCPROFSYS_CI}" MATCHES "[1-9]+|ON|on|y|yes") enable_testing() include(CTest) endif() @@ -323,11 +337,13 @@ endif() set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME core) -if(OMNITRACE_BUILD_CODECOV) - omnitrace_save_variables(CODECOV_FLAGS VARIABLES CMAKE_C_FLAGS CMAKE_CXX_FLAGS) +if(ROCPROFSYS_BUILD_CODECOV) + rocprofiler_systems_save_variables(CODECOV_FLAGS VARIABLES CMAKE_C_FLAGS + CMAKE_CXX_FLAGS) foreach(_BUILD_TYPE DEBUG MINSIZEREL RELWITHDEBINFO RELEASE) - omnitrace_save_variables(CODECOV_FLAGS VARIABLES CMAKE_C_FLAGS_${_BUILD_TYPE} - CMAKE_CXX_FLAGS_${_BUILD_TYPE}) + rocprofiler_systems_save_variables( + CODECOV_FLAGS VARIABLES CMAKE_C_FLAGS_${_BUILD_TYPE} + CMAKE_CXX_FLAGS_${_BUILD_TYPE}) endforeach() foreach(_BUILD_TYPE DEBUG MINSIZEREL RELWITHDEBINFO RELEASE) @@ -345,11 +361,12 @@ endif() add_subdirectory(source) -if(OMNITRACE_BUILD_CODECOV) - omnitrace_restore_variables(CODECOV_FLAGS VARIABLES CMAKE_C_FLAGS CMAKE_CXX_FLAGS) +if(ROCPROFSYS_BUILD_CODECOV) + rocprofiler_systems_restore_variables(CODECOV_FLAGS VARIABLES CMAKE_C_FLAGS + CMAKE_CXX_FLAGS) foreach(_BUILD_TYPE DEBUG MINSIZEREL RELWITHDEBINFO RELEASE) - omnitrace_restore_variables( + rocprofiler_systems_restore_variables( CODECOV_FLAGS VARIABLES CMAKE_C_FLAGS_${_BUILD_TYPE} CMAKE_CXX_FLAGS_${_BUILD_TYPE}) endforeach() @@ -361,14 +378,19 @@ endif() # # ------------------------------------------------------------------------------# -if(NOT OMNITRACE_USE_ROCTRACER AND NOT OMNITRACE_USE_ROCPROFILER) - set(OMNITRACE_HSA_ENV "# ") +if(NOT ROCPROFSYS_USE_ROCTRACER AND NOT ROCPROFSYS_USE_ROCPROFILER) + set(ROCPROFSYS_HSA_ENV "# ") endif() -if(NOT OMNITRACE_USE_ROCPROFILER) - set(OMNITRACE_ROCP_ENV "# ") +if(NOT ROCPROFSYS_USE_ROCPROFILER) + set(ROCPROFSYS_ROCP_ENV "# ") endif() +configure_file( + ${PROJECT_SOURCE_DIR}/LICENSE + ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}/LICENSE + COPYONLY) + configure_file( ${PROJECT_SOURCE_DIR}/perfetto.cfg ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/perfetto.cfg @@ -380,7 +402,7 @@ configure_file( configure_file( ${PROJECT_SOURCE_DIR}/cmake/Templates/modulefile.in - ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/modulefiles/${PROJECT_NAME}/${OMNITRACE_VERSION} + ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/modulefiles/${PROJECT_NAME}/${ROCPROFSYS_VERSION} @ONLY) install( @@ -391,13 +413,13 @@ install( install( FILES - ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/modulefiles/${PROJECT_NAME}/${OMNITRACE_VERSION} + ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/modulefiles/${PROJECT_NAME}/${ROCPROFSYS_VERSION} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/modulefiles/${PROJECT_NAME} COMPONENT setup) install( - FILES ${PROJECT_SOURCE_DIR}/LICENSE - DESTINATION ${CMAKE_INSTALL_DOCDIR} + FILES ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}/LICENSE + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME} COMPONENT setup) # ------------------------------------------------------------------------------# @@ -415,7 +437,7 @@ include(ConfigInstall) # # ------------------------------------------------------------------------------# -if(OMNITRACE_BUILD_EXAMPLES) +if(ROCPROFSYS_BUILD_EXAMPLES) set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME examples) add_subdirectory(examples) endif() @@ -426,7 +448,7 @@ endif() # # ------------------------------------------------------------------------------# -if(OMNITRACE_BUILD_TESTING) +if(ROCPROFSYS_BUILD_TESTING) set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME testing) add_subdirectory(tests) endif() @@ -446,4 +468,4 @@ include(ConfigCPack) # # ------------------------------------------------------------------------------# -omnitrace_print_features() +rocprofiler_systems_print_features() diff --git a/LICENSE b/LICENSE index 54770490..c92488b4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ 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 diff --git a/README.md b/README.md index 9abe9c8c..a5a4612c 100755 --- a/README.md +++ b/README.md @@ -1,30 +1,30 @@ -# Omnitrace: Application Profiling, Tracing, and Analysis +# ROCm Systems Profiler: Application Profiling, Tracing, and Analysis -[![Ubuntu 20.04 with GCC, ROCm, and MPI](https://github.com/ROCm/omnitrace/actions/workflows/ubuntu-focal.yml/badge.svg)](https://github.com/ROCm/omnitrace/actions/workflows/ubuntu-focal.yml) -[![Ubuntu 22.04 (GCC, Python, ROCm)](https://github.com/ROCm/omnitrace/actions/workflows/ubuntu-jammy.yml/badge.svg)](https://github.com/ROCm/omnitrace/actions/workflows/ubuntu-jammy.yml) -[![OpenSUSE 15.x with GCC](https://github.com/ROCm/omnitrace/actions/workflows/opensuse.yml/badge.svg)](https://github.com/ROCm/omnitrace/actions/workflows/opensuse.yml) -[![RedHat Linux (GCC, Python, ROCm)](https://github.com/ROCm/omnitrace/actions/workflows/redhat.yml/badge.svg)](https://github.com/ROCm/omnitrace/actions/workflows/redhat.yml) -[![Installer Packaging (CPack)](https://github.com/ROCm/omnitrace/actions/workflows/cpack.yml/badge.svg)](https://github.com/ROCm/omnitrace/actions/workflows/cpack.yml) -[![Documentation](https://github.com/ROCm/omnitrace/actions/workflows/docs.yml/badge.svg)](https://github.com/ROCm/omnitrace/actions/workflows/docs.yml) +[![Ubuntu 20.04 with GCC, ROCm, and MPI](https://github.com/ROCm/rocprofiler-systems/actions/workflows/ubuntu-focal.yml/badge.svg)](https://github.com/ROCm/rocprofiler-systems/actions/workflows/ubuntu-focal.yml) +[![Ubuntu 22.04 (GCC, Python, ROCm)](https://github.com/ROCm/rocprofiler-systems/actions/workflows/ubuntu-jammy.yml/badge.svg)](https://github.com/ROCm/rocprofiler-systems/actions/workflows/ubuntu-jammy.yml) +[![OpenSUSE 15.x with GCC](https://github.com/ROCm/rocprofiler-systems/actions/workflows/opensuse.yml/badge.svg)](https://github.com/ROCm/rocprofiler-systems/actions/workflows/opensuse.yml) +[![RedHat Linux (GCC, Python, ROCm)](https://github.com/ROCm/rocprofiler-systems/actions/workflows/redhat.yml/badge.svg)](https://github.com/ROCm/rocprofiler-systems/actions/workflows/redhat.yml) +[![Installer Packaging (CPack)](https://github.com/ROCm/rocprofiler-systems/actions/workflows/cpack.yml/badge.svg)](https://github.com/ROCm/rocprofiler-systems/actions/workflows/cpack.yml) +[![Documentation](https://github.com/ROCm/rocprofiler-systems/actions/workflows/docs.yml/badge.svg)](https://github.com/ROCm/rocprofiler-systems/actions/workflows/docs.yml) > [!NOTE] > Perfetto validation is done with trace_processor v46.0, as there is a known issue with v47.0. If you are experiencing problems viewing your trace in the latest version of [Perfetto](http://ui.perfetto.dev), then try using [Perfetto UI v46.0](https://ui.perfetto.dev/v46.0-35b3d9845/#!/). -## Overview +> [!NOTE] +> Perfetto validation is done with trace_processor v46.0, as there is a known issue with v47.0. +If you are experiencing problems viewing your trace in the latest version of [Perfetto](http://ui.perfetto.dev), then try using [Perfetto UI v46.0](https://ui.perfetto.dev/v46.0-35b3d9845/#!/). -AMD Research is seeking to improve observability and performance analysis for software running on AMD heterogeneous systems. -If you are familiar with [rocprof](https://rocm.docs.amd.com/projects/rocprofiler/en/latest/how-to/using-rocprof.html) and/or [uProf](https://developer.amd.com/amd-uprof/), -you will find many of the capabilities of these tools available via Omnitrace in addition to many new capabilities. +## Overview -Omnitrace is a comprehensive profiling and tracing tool for parallel applications written in C, C++, Fortran, HIP, OpenCL, and Python which execute on the CPU or CPU+GPU. +ROCm Systems Profiler (rocprofiler-systems), formerly Omnitrace, is a comprehensive profiling and tracing tool for parallel applications written in C, C++, Fortran, HIP, OpenCL, and Python which execute on the CPU or CPU+GPU. It is capable of gathering the performance information of functions through any combination of binary instrumentation, call-stack sampling, user-defined regions, and Python interpreter hooks. -Omnitrace supports interactive visualization of comprehensive traces in the web browser in addition to high-level summary profiles with mean/min/max/stddev statistics. -In addition to runtimes, omnitrace supports the collection of system-level metrics such as the CPU frequency, GPU temperature, and GPU utilization, process-level metrics +ROCm Systems Profiler supports interactive visualization of comprehensive traces in the web browser in addition to high-level summary profiles with mean/min/max/stddev statistics. +In addition to runtimes, ROCm Systems Profiler supports the collection of system-level metrics such as the CPU frequency, GPU temperature, and GPU utilization, process-level metrics such as the memory usage, page-faults, and context-switches, and thread-level metrics such as memory usage, CPU time, and numerous hardware counters. > [!NOTE] -> Full documentation is available at [Omnitrace documentation](https://rocm.docs.amd.com/projects/omnitrace/en/latest/index.html) in an organized, easy-to-read, searchable format. +> Full documentation is available at [ROCm Systems Profiler documentation](https://rocm.docs.amd.com/projects/omnitrace/en/latest/index.html) in an organized, easy-to-read, searchable format. The documentation source files reside in the [`/docs`](/docs) folder of this repository. For information on contributing to the documentation, see [Contribute to ROCm documentation](https://rocm.docs.amd.com/en/latest/contribute/contributing.html) @@ -95,91 +95,91 @@ The documentation source files reside in the [`/docs`](/docs) folder of this rep ### Installation -- Visit [Releases](https://github.com/ROCm/omnitrace/releases) page +- Visit [Releases](https://github.com/ROCm/rocprofiler-systems/releases) page - Select appropriate installer (recommendation: `.sh` scripts do not require super-user priviledges unlike the DEB/RPM installers) - If targeting a ROCm application, find the installer script with the matching ROCm version - - If you are unsure about your Linux distro, check `/etc/os-release` or use the `omnitrace-install.py` script + - If you are unsure about your Linux distro, check `/etc/os-release` or use the `rocprofiler-systems-install.py` script -If the above recommendation is not desired, download the `omnitrace-install.py` and specify `--prefix ` when +If the above recommendation is not desired, download the `rocprofiler-systems-install.py` and specify `--prefix ` when executing it. This script will attempt to auto-detect a compatible OS distribution and version. If ROCm support is desired, specify `--rocm X.Y` where `X` is the ROCm major version and `Y` is the ROCm minor version, e.g. `--rocm 5.4`. ```console -wget https://github.com/ROCm/omnitrace/releases/latest/download/omnitrace-install.py -python3 ./omnitrace-install.py --prefix /opt/omnitrace/rocm-5.4 --rocm 5.4 +wget https://github.com/ROCm/rocprofiler-systems/releases/latest/download/rocprofiler-systems-install.py +python3 ./rocprofiler-systems-install.py --prefix /opt/rocprofiler-systems/rocm-5.4 --rocm 5.4 ``` -See the [Omnitrace installation guide](https://rocm.docs.amd.com/projects/omnitrace/en/latest/install/install.html) for detailed information. +See the [ROCm Systems Profiler installation guide](https://rocm.docs.amd.com/projects/omnitrace/en/latest/install/install.html) for detailed information. ### Setup -> NOTE: Replace `/opt/omnitrace` below with installation prefix as necessary. +> NOTE: Replace `/opt/rocprofiler-systems` below with installation prefix as necessary. - Option 1: Source `setup-env.sh` script ```bash -source /opt/omnitrace/share/omnitrace/setup-env.sh +source /opt/rocprofiler-systems/share/rocprofiler-systems/setup-env.sh ``` - Option 2: Load modulefile ```bash -module use /opt/omnitrace/share/modulefiles -module load omnitrace +module use /opt/rocprofiler-systems/share/modulefiles +module load rocprofiler-systems ``` - Option 3: Manual ```bash -export PATH=/opt/omnitrace/bin:${PATH} -export LD_LIBRARY_PATH=/opt/omnitrace/lib:${LD_LIBRARY_PATH} +export PATH=/opt/rocprofiler-systems/bin:${PATH} +export LD_LIBRARY_PATH=/opt/rocprofiler-systems/lib:${LD_LIBRARY_PATH} ``` -### Omnitrace Settings +### ROCm Systems Profiler Settings -Generate an omnitrace configuration file using `omnitrace-avail -G omnitrace.cfg`. Optionally, use `omnitrace-avail -G omnitrace.cfg --all` for +Generate a rocprofiler-systems configuration file using `rocprof-sys-avail -G rocprof-sys.cfg`. Optionally, use `rocprof-sys-avail -G rocprof-sys.cfg --all` for a verbose configuration file with descriptions, categories, etc. Modify the configuration file as desired, e.g. enable [perfetto](https://perfetto.dev/), [timemory](https://github.com/NERSC/timemory), sampling, and process-level sampling by default and tweak some sampling default values: ```console # ... -OMNITRACE_TRACE = true -OMNITRACE_PROFILE = true -OMNITRACE_USE_SAMPLING = true -OMNITRACE_USE_PROCESS_SAMPLING = true +ROCPROFSYS_TRACE = true +ROCPROFSYS_PROFILE = true +ROCPROFSYS_USE_SAMPLING = true +ROCPROFSYS_USE_PROCESS_SAMPLING = true # ... -OMNITRACE_SAMPLING_FREQ = 50 -OMNITRACE_SAMPLING_CPUS = all -OMNITRACE_SAMPLING_GPUS = $env:HIP_VISIBLE_DEVICES +ROCPROFSYS_SAMPLING_FREQ = 50 +ROCPROFSYS_SAMPLING_CPUS = all +ROCPROFSYS_SAMPLING_GPUS = $env:HIP_VISIBLE_DEVICES ``` -Once the configuration file is adjusted to your preferences, either export the path to this file via `OMNITRACE_CONFIG_FILE=/path/to/omnitrace.cfg` -or place this file in `${HOME}/.omnitrace.cfg` to ensure these values are always read as the default. If you wish to change any of these settings, -you can override them via environment variables or by specifying an alternative `OMNITRACE_CONFIG_FILE`. +Once the configuration file is adjusted to your preferences, either export the path to this file via `ROCPROFSYS_CONFIG_FILE=/path/to/rocprof-sys.cfg` +or place this file in `${HOME}/.rocprof-sys.cfg` to ensure these values are always read as the default. If you wish to change any of these settings, +you can override them via environment variables or by specifying an alternative `ROCPROFSYS_CONFIG_FILE`. ### Call-Stack Sampling -The `omnitrace-sample` executable is used to execute call-stack sampling on a target application without binary instrumentation. -Use a double-hypen (`--`) to separate the command-line arguments for `omnitrace-sample` from the target application and it's arguments. +The `rocprof-sys-sample` executable is used to execute call-stack sampling on a target application without binary instrumentation. +Use a double-hypen (`--`) to separate the command-line arguments for `rocprof-sys-sample` from the target application and it's arguments. ```shell -omnitrace-sample --help -omnitrace-sample -- -omnitrace-sample -f 1000 -- ls -la +rocprof-sys-sample --help +rocprof-sys-sample -- +rocprof-sys-sample -f 1000 -- ls -la ``` ### Binary Instrumentation -The `omnitrace` executable is used to instrument an existing binary. Call-stack sampling can be enabled alongside -the execution an instrumented binary, to help "fill in the gaps" between the instrumentation via setting the `OMNITRACE_USE_SAMPLING` +The `rocprof-sys-instrument` executable is used to instrument an existing binary. Call-stack sampling can be enabled alongside +the execution an instrumented binary, to help "fill in the gaps" between the instrumentation via setting the `ROCPROFSYS_USE_SAMPLING` configuration variable to `ON`. -Similar to `omnitrace-sample`, use a double-hypen (`--`) to separate the command-line arguments for `omnitrace` from the target application and it's arguments. +Similar to `rocprof-sys-sample`, use a double-hypen (`--`) to separate the command-line arguments for `rocprof-sys-instrument` from the target application and it's arguments. ```shell -omnitrace-instrument --help -omnitrace-instrument -- +rocprof-sys-instrument --help +rocprof-sys-instrument -- ``` #### Binary Rewrite @@ -187,7 +187,7 @@ omnitrace-instrument -- Rewrite the text section of an executable or library with instrumentation: ```shell -omnitrace-instrument -o app.inst -- /path/to/app +rocprof-sys-instrument -o app.inst -- /path/to/app ``` In binary rewrite mode, if you also want instrumentation in the linked libraries, you must also rewrite those libraries. @@ -195,7 +195,7 @@ Example of rewriting the functions starting with `"hip"` with instrumentation in ```shell mkdir -p ./lib -omnitrace-instrument -R '^hip' -o ./lib/libamdhip64.so.4 -- /opt/rocm/lib/libamdhip64.so.4 +rocprof-sys-instrument -R '^hip' -o ./lib/libamdhip64.so.4 -- /opt/rocm/lib/libamdhip64.so.4 export LD_LIBRARY_PATH=${PWD}/lib:${LD_LIBRARY_PATH} ``` @@ -206,33 +206,33 @@ Once you have rewritten your executable and/or libraries with instrumentation, y or exectuable which loads the instrumented libraries normally, e.g.: ```shell -omnitrace-run -- ./app.inst +rocprof-sys-run -- ./app.inst ``` -If you want to re-define certain settings to new default in a binary rewrite, use the `--env` option. This `omnitrace` option -will set the environment variable to the given value but will not override it. E.g. the default value of `OMNITRACE_PERFETTO_BUFFER_SIZE_KB` +If you want to re-define certain settings to new default in a binary rewrite, use the `--env` option. This `rocprof-sys` option +will set the environment variable to the given value but will not override it. E.g. the default value of `ROCPROFSYS_PERFETTO_BUFFER_SIZE_KB` is 1024000 KB (1 GiB): ```shell # buffer size defaults to 1024000 -omnitrace-instrument -o app.inst -- /path/to/app -omnitrace-run -- ./app.inst +rocprof-sys-instrument -o app.inst -- /path/to/app +rocprof-sys-run -- ./app.inst ``` -Passing `--env OMNITRACE_PERFETTO_BUFFER_SIZE_KB=5120000` will change the default value in `app.inst` to 5120000 KiB (5 GiB): +Passing `--env ROCPROFSYS_PERFETTO_BUFFER_SIZE_KB=5120000` will change the default value in `app.inst` to 5120000 KiB (5 GiB): ```shell # defaults to 5 GiB buffer size -omnitrace-instrument -o app.inst --env OMNITRACE_PERFETTO_BUFFER_SIZE_KB=5120000 -- /path/to/app -omnitrace-run -- ./app.inst +rocprof-sys-instrument -o app.inst --env ROCPROFSYS_PERFETTO_BUFFER_SIZE_KB=5120000 -- /path/to/app +rocprof-sys-run -- ./app.inst ``` ```shell # override default 5 GiB buffer size to 200 MB via command-line -omnitrace-run --trace-buffer-size=200000 -- ./app.inst +rocprof-sys-run --trace-buffer-size=200000 -- ./app.inst # override default 5 GiB buffer size to 200 MB via environment -export OMNITRACE_PERFETTO_BUFFER_SIZE_KB=200000 -omnitrace-run -- ./app.inst +export ROCPROFSYS_PERFETTO_BUFFER_SIZE_KB=200000 +rocprof-sys-run -- ./app.inst ``` #### Runtime Instrumentation @@ -242,35 +242,35 @@ linked libraries. Thus, it may be useful to exclude those libraries via the `-ME or exclude specific functions with the `-E` regex option. ```shell -omnitrace-instrument -- /path/to/app -omnitrace-instrument -ME '^(libhsa-runtime64|libz\\.so)' -- /path/to/app -omnitrace-instrument -E 'rocr::atomic|rocr::core|rocr::HSA' -- /path/to/app +rocprof-sys-instrument -- /path/to/app +rocprof-sys-instrument -ME '^(libhsa-runtime64|libz\\.so)' -- /path/to/app +rocprof-sys-instrument -E 'rocr::atomic|rocr::core|rocr::HSA' -- /path/to/app ``` ### Python Profiling and Tracing -Use the `omnitrace-python` script to profile/trace Python interpreter function calls. -Use a double-hypen (`--`) to separate the command-line arguments for `omnitrace-python` from the target script and it's arguments. +Use the `rocprof-sys-python` script to profile/trace Python interpreter function calls. +Use a double-hypen (`--`) to separate the command-line arguments for `rocprof-sys-python` from the target script and it's arguments. ```shell -omnitrace-python --help -omnitrace-python -- -omnitrace-python -- ./script.py +rocprof-sys-python --help +rocprof-sys-python -- +rocprof-sys-python -- ./script.py ``` -Please note, the first argument after the double-hyphen *must be a Python script*, e.g. `omnitrace-python -- ./script.py`. +Please note, the first argument after the double-hyphen *must be a Python script*, e.g. `rocprof-sys-python -- ./script.py`. -If you need to specify a specific python interpreter version, use `omnitrace-python-X.Y` where `X.Y` is the Python +If you need to specify a specific python interpreter version, use `rocprof-sys-python-X.Y` where `X.Y` is the Python major and minor version: ```shell -omnitrace-python-3.8 -- ./script.py +rpcprof-sys-python-3.8 -- ./script.py ``` If you need to specify the full path to a Python interpreter, set the `PYTHON_EXECUTABLE` environment variable: ```shell -PYTHON_EXECUTABLE=/opt/conda/bin/python omnitrace-python -- ./script.py +PYTHON_EXECUTABLE=/opt/conda/bin/python rocprof-sys-python -- ./script.py ``` If you want to restrict the data collection to specific function(s) and its callees, pass the `-b` / `--builtin` option after decorating the @@ -297,51 +297,51 @@ for `foo` via the direct call within `spam`. There will be no entries for `bar` - Visit [ui.perfetto.dev](https://ui.perfetto.dev) in the web-browser - Select "Open trace file" from panel on the left -- Locate the omnitrace perfetto output (extension: `.proto`) +- Locate the rocprofiler-systems perfetto output (extension: `.proto`) -![omnitrace-perfetto](docs/data/omnitrace-perfetto.png) +![rocprof-sys-perfetto](docs/data/omnitrace-perfetto.png) -![omnitrace-rocm](docs/data/omnitrace-rocm.png) +![rocprof-sys-rocm](docs/data/omnitrace-rocm.png) -![omnitrace-rocm-flow](docs/data/omnitrace-rocm-flow.png) +![rocprof-sys-rocm-flow](docs/data/omnitrace-rocm-flow.png) -![omnitrace-user-api](docs/data/omnitrace-user-api.png) +![rocprof-sys-user-api](docs/data/omnitrace-user-api.png) ## Using Perfetto tracing with System Backend Perfetto tracing with the system backend supports multiple processes writing to the same -output file. Thus, it is a useful technique if Omnitrace is built with partial MPI support +output file. Thus, it is a useful technique if rocprofiler-systems is built with partial MPI support because all the perfetto output will be coalesced into a single file. The installation docs for perfetto can be found [here](https://perfetto.dev/docs/contributing/build-instructions). -If you are building omnitrace from source, you can configure CMake with `OMNITRACE_INSTALL_PERFETTO_TOOLS=ON` +If you are building rocprofiler-systems from source, you can configure CMake with `ROCPROFSYS_INSTALL_PERFETTO_TOOLS=ON` and the `perfetto` and `traced` applications will be installed as part of the build process. However, it should be noted that to prevent this option from accidentally overwriting an existing perfetto install, -all the perfetto executables installed by omnitrace are prefixed with `omnitrace-perfetto-`, except for the `perfetto` -executable, which is just renamed `omnitrace-perfetto`. +all the perfetto executables installed by ROCm Systems Profiler are prefixed with `rocprof-sys-perfetto-`, except +for the `perfetto` executable, which is just renamed `rocprof-sys-perfetto`. Enable `traced` and `perfetto` in the background: ```shell pkill traced traced --background -perfetto --out ./omnitrace-perfetto.proto --txt -c ${OMNITRACE_ROOT}/share/perfetto.cfg --background +perfetto --out ./rocprof-sys-perfetto.proto --txt -c ${ROCPROFSYS_ROOT}/share/perfetto.cfg --background ``` -> ***NOTE: if the perfetto tools were installed by omnitrace, replace `traced` with `omnitrace-perfetto-traced` and*** -> ***`perfetto` with `omnitrace-perfetto`.*** +> ***NOTE: if the perfetto tools were installed by rocprofiler-systems, replace `traced` with `rocprof-sys-perfetto-traced` and*** +> ***`perfetto` with `rocprof-sys-perfetto`.*** -Configure omnitrace to use the perfetto system backend via the `--perfetto-backend` option of `omnitrace-run`: +Configure rocprofiler-systems to use the perfetto system backend via the `--perfetto-backend` option of `rocprof-sys-run`: ```shell # enable sampling on the uninstrumented binary -omnitrace-run --sample --trace --perfetto-backend=system -- ./myapp +rocprof-sys-run --sample --trace --perfetto-backend=system -- ./myapp # trace the instrument the binary -omnitrace-instrument -o ./myapp.inst -- ./myapp -omnitrace-run --trace --perfetto-backend=system -- ./myapp.inst +rocprof-sys-instrument -o ./myapp.inst -- ./myapp +rocprof-sys-run --trace --perfetto-backend=system -- ./myapp.inst ``` -or via the `--env` option of `omnitrace-instrument` + runtime instrumentation: +or via the `--env` option of `rocprof-sys-instrument` + runtime instrumentation: ```shell -omnitrace-instrument --env OMNITRACE_PERFETTO_BACKEND=system -- ./myapp +rocprof-sys-instrument --env ROCPROFSYS_PERFETTO_BACKEND=system -- ./myapp ``` diff --git a/cmake/BuildSettings.cmake b/cmake/BuildSettings.cmake index c4a91ad4..b2469a6a 100644 --- a/cmake/BuildSettings.cmake +++ b/cmake/BuildSettings.cmake @@ -12,49 +12,55 @@ include(Compilers) include(FindPackageHandleStandardArgs) include(MacroUtilities) -omnitrace_add_option( - OMNITRACE_BUILD_DEVELOPER "Extra build flags for development like -Werror" - ${OMNITRACE_BUILD_CI}) -omnitrace_add_option(OMNITRACE_BUILD_RELEASE "Build with minimal debug line info" OFF) -omnitrace_add_option(OMNITRACE_BUILD_EXTRA_OPTIMIZATIONS "Extra optimization flags" OFF) -omnitrace_add_option(OMNITRACE_BUILD_LTO "Build with link-time optimization" OFF) -omnitrace_add_option(OMNITRACE_USE_COMPILE_TIMING - "Build with timing metrics for compilation" OFF) -omnitrace_add_option(OMNITRACE_USE_SANITIZER - "Build with -fsanitze=\${OMNITRACE_SANITIZER_TYPE}" OFF) -omnitrace_add_option(OMNITRACE_BUILD_STATIC_LIBGCC - "Build with -static-libgcc if possible" OFF) -omnitrace_add_option(OMNITRACE_BUILD_STATIC_LIBSTDCXX - "Build with -static-libstdc++ if possible" OFF) -omnitrace_add_option(OMNITRACE_BUILD_STACK_PROTECTOR "Build with -fstack-protector" ON) -omnitrace_add_cache_option( - OMNITRACE_BUILD_LINKER - "If set to a non-empty value, pass -fuse-ld=\${OMNITRACE_BUILD_LINKER}" STRING "bfd") -omnitrace_add_cache_option(OMNITRACE_BUILD_NUMBER "Internal CI use" STRING "0" ADVANCED - NO_FEATURE) - -omnitrace_add_interface_library(omnitrace-static-libgcc - "Link to static version of libgcc") -omnitrace_add_interface_library(omnitrace-static-libstdcxx - "Link to static version of libstdc++") -omnitrace_add_interface_library(omnitrace-static-libgcc-optional - "Link to static version of libgcc") -omnitrace_add_interface_library(omnitrace-static-libstdcxx-optional - "Link to static version of libstdc++") - -target_compile_definitions(omnitrace-compile-options INTERFACE $<$:DEBUG>) - -set(OMNITRACE_SANITIZER_TYPE +rocprofiler_systems_add_option( + ROCPROFSYS_BUILD_DEVELOPER "Extra build flags for development like -Werror" + ${ROCPROFSYS_BUILD_CI}) +rocprofiler_systems_add_option(ROCPROFSYS_BUILD_RELEASE + "Build with minimal debug line info" OFF) +rocprofiler_systems_add_option(ROCPROFSYS_BUILD_EXTRA_OPTIMIZATIONS + "Extra optimization flags" OFF) +rocprofiler_systems_add_option(ROCPROFSYS_BUILD_LTO "Build with link-time optimization" + OFF) +rocprofiler_systems_add_option(ROCPROFSYS_USE_COMPILE_TIMING + "Build with timing metrics for compilation" OFF) +rocprofiler_systems_add_option(ROCPROFSYS_USE_SANITIZER + "Build with -fsanitze=\${ROCPROFSYS_SANITIZER_TYPE}" OFF) +rocprofiler_systems_add_option(ROCPROFSYS_BUILD_STATIC_LIBGCC + "Build with -static-libgcc if possible" OFF) +rocprofiler_systems_add_option(ROCPROFSYS_BUILD_STATIC_LIBSTDCXX + "Build with -static-libstdc++ if possible" OFF) +rocprofiler_systems_add_option(ROCPROFSYS_BUILD_STACK_PROTECTOR + "Build with -fstack-protector" ON) +rocprofiler_systems_add_cache_option( + ROCPROFSYS_BUILD_LINKER + "If set to a non-empty value, pass -fuse-ld=\${ROCPROFSYS_BUILD_LINKER}" STRING "bfd") +rocprofiler_systems_add_cache_option(ROCPROFSYS_BUILD_NUMBER "Internal CI use" STRING "0" + ADVANCED NO_FEATURE) + +rocprofiler_systems_add_interface_library(rocprofiler-systems-static-libgcc + "Link to static version of libgcc") +rocprofiler_systems_add_interface_library(rocprofiler-systems-static-libstdcxx + "Link to static version of libstdc++") +rocprofiler_systems_add_interface_library(rocprofiler-systems-static-libgcc-optional + "Link to static version of libgcc") +rocprofiler_systems_add_interface_library(rocprofiler-systems-static-libstdcxx-optional + "Link to static version of libstdc++") + +target_compile_definitions(rocprofiler-systems-compile-options + INTERFACE $<$:DEBUG>) + +set(ROCPROFSYS_SANITIZER_TYPE "leak" CACHE STRING "Sanitizer type") -if(OMNITRACE_USE_SANITIZER) - omnitrace_add_feature(OMNITRACE_SANITIZER_TYPE - "Sanitizer type, e.g. leak, thread, address, memory, etc.") +if(ROCPROFSYS_USE_SANITIZER) + rocprofiler_systems_add_feature( + ROCPROFSYS_SANITIZER_TYPE + "Sanitizer type, e.g. leak, thread, address, memory, etc.") endif() -if(OMNITRACE_BUILD_CI) - omnitrace_target_compile_definitions(${LIBNAME}-compile-options - INTERFACE OMNITRACE_CI) +if(ROCPROFSYS_BUILD_CI) + rocprofiler_systems_target_compile_definitions(${LIBNAME}-compile-options + INTERFACE ROCPROFSYS_CI) endif() # ----------------------------------------------------------------------------------------# @@ -78,7 +84,7 @@ find_package_handle_standard_args(rt-library REQUIRED_VARS rt_LIBRARY) # find_package_handle_standard_args(dw-library REQUIRED_VARS dw_LIBRARY) if(dl_LIBRARY) - target_link_libraries(omnitrace-compile-options INTERFACE ${dl_LIBRARY}) + target_link_libraries(rocprofiler-systems-compile-options INTERFACE ${dl_LIBRARY}) endif() # ----------------------------------------------------------------------------------------# @@ -88,7 +94,7 @@ add_flag_if_avail( "-W" "-Wall" "-Wno-unknown-pragmas" "-Wno-unused-function" "-Wno-ignored-attributes" "-Wno-attributes" "-Wno-missing-field-initializers" "-Wno-interference-size") -if(OMNITRACE_BUILD_DEBUG) +if(ROCPROFSYS_BUILD_DEBUG) add_flag_if_avail("-g3" "-fno-omit-frame-pointer") endif() @@ -104,58 +110,59 @@ endif() # ----------------------------------------------------------------------------------------# # extra flags for debug information in debug or optimized binaries # -omnitrace_add_interface_library( - omnitrace-compile-debuginfo +rocprofiler_systems_add_interface_library( + rocprofiler-systems-compile-debuginfo "Attempts to set best flags for more expressive profiling information in debug or optimized binaries" ) -add_target_flag_if_avail(omnitrace-compile-debuginfo "-g3" "-fno-omit-frame-pointer" - "-fno-optimize-sibling-calls") +add_target_flag_if_avail(rocprofiler-systems-compile-debuginfo "-g3" + "-fno-omit-frame-pointer" "-fno-optimize-sibling-calls") if(CMAKE_CUDA_COMPILER_IS_NVIDIA) - add_target_cuda_flag(omnitrace-compile-debuginfo "-lineinfo") + add_target_cuda_flag(rocprofiler-systems-compile-debuginfo "-lineinfo") endif() target_compile_options( - omnitrace-compile-debuginfo + rocprofiler-systems-compile-debuginfo INTERFACE $<$:$<$:-rdynamic>> $<$:$<$:-rdynamic>>) if(NOT APPLE) - target_link_options(omnitrace-compile-debuginfo INTERFACE + target_link_options(rocprofiler-systems-compile-debuginfo INTERFACE $<$:-rdynamic>) endif() if(CMAKE_CUDA_COMPILER_IS_NVIDIA) target_compile_options( - omnitrace-compile-debuginfo + rocprofiler-systems-compile-debuginfo INTERFACE $<$:$<$:-Xcompiler=-rdynamic>>) endif() if(dl_LIBRARY) - target_link_libraries(omnitrace-compile-debuginfo INTERFACE ${dl_LIBRARY}) + target_link_libraries(rocprofiler-systems-compile-debuginfo INTERFACE ${dl_LIBRARY}) endif() if(rt_LIBRARY) - target_link_libraries(omnitrace-compile-debuginfo INTERFACE ${rt_LIBRARY}) + target_link_libraries(rocprofiler-systems-compile-debuginfo INTERFACE ${rt_LIBRARY}) endif() # ----------------------------------------------------------------------------------------# # non-debug optimizations # -omnitrace_add_interface_library(omnitrace-compile-extra "Extra optimization flags") -if(NOT OMNITRACE_BUILD_CODECOV AND OMNITRACE_BUILD_EXTRA_OPTIMIZATIONS) +rocprofiler_systems_add_interface_library(rocprofiler-systems-compile-extra + "Extra optimization flags") +if(NOT ROCPROFSYS_BUILD_CODECOV AND ROCPROFSYS_BUILD_EXTRA_OPTIMIZATIONS) add_target_flag_if_avail( - omnitrace-compile-extra "-finline-functions" "-funroll-loops" "-ftree-vectorize" - "-ftree-loop-optimize" "-ftree-loop-vectorize") + rocprofiler-systems-compile-extra "-finline-functions" "-funroll-loops" + "-ftree-vectorize" "-ftree-loop-optimize" "-ftree-loop-vectorize") endif() if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" - AND OMNITRACE_BUILD_EXTRA_OPTIMIZATIONS - AND NOT OMNITRACE_BUILD_CODECOV) - target_link_libraries(omnitrace-compile-options - INTERFACE $) + AND ROCPROFSYS_BUILD_EXTRA_OPTIMIZATIONS + AND NOT ROCPROFSYS_BUILD_CODECOV) + target_link_libraries(rocprofiler-systems-compile-options + INTERFACE $) add_flag_if_avail( "-fno-signaling-nans" "-fno-trapping-math" "-fno-signed-zeros" "-ffinite-math-only" "-fno-math-errno" "-fpredictive-commoning" @@ -168,103 +175,106 @@ endif() # add_cxx_flag_if_avail("-faligned-new") -omnitrace_add_interface_library(omnitrace-lto "Adds link-time-optimization flags") +rocprofiler_systems_add_interface_library(rocprofiler-systems-lto + "Adds link-time-optimization flags") -if(NOT OMNITRACE_BUILD_CODECOV) - omnitrace_save_variables(FLTO VARIABLES CMAKE_CXX_FLAGS) +if(NOT ROCPROFSYS_BUILD_CODECOV) + rocprofiler_systems_save_variables(FLTO VARIABLES CMAKE_CXX_FLAGS) set(_CXX_FLAGS "${CMAKE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "-flto=thin ${_CXX_FLAGS}") - add_target_flag_if_avail(omnitrace-lto "-flto=thin") - if(NOT cxx_omnitrace_lto_flto_thin) + add_target_flag_if_avail(rocprofiler-systems-lto "-flto=thin") + if(NOT cxx_rocprofiler_systems_lto_flto_thin) set(CMAKE_CXX_FLAGS "-flto ${_CXX_FLAGS}") - add_target_flag_if_avail(omnitrace-lto "-flto") - if(NOT cxx_omnitrace_lto_flto) - set(OMNITRACE_BUILD_LTO OFF) + add_target_flag_if_avail(rocprofiler-systems-lto "-flto") + if(NOT cxx_rocprofiler_systems_lto_flto) + set(ROCPROFSYS_BUILD_LTO OFF) else() - target_link_options(omnitrace-lto INTERFACE -flto) + target_link_options(rocprofiler-systems-lto INTERFACE -flto) endif() - add_target_flag_if_avail(omnitrace-lto "-fno-fat-lto-objects") - if(cxx_omnitrace_lto_fno_fat_lto_objects) - target_link_options(omnitrace-lto INTERFACE -fno-fat-lto-objects) + add_target_flag_if_avail(rocprofiler-systems-lto "-fno-fat-lto-objects") + if(cxx_rocprofiler_systems_lto_fno_fat_lto_objects) + target_link_options(rocprofiler-systems-lto INTERFACE -fno-fat-lto-objects) endif() else() - target_link_options(omnitrace-lto INTERFACE -flto=thin) + target_link_options(rocprofiler-systems-lto INTERFACE -flto=thin) endif() - omnitrace_restore_variables(FLTO VARIABLES CMAKE_CXX_FLAGS) + rocprofiler_systems_restore_variables(FLTO VARIABLES CMAKE_CXX_FLAGS) endif() # ----------------------------------------------------------------------------------------# # print compilation timing reports (Clang compiler) # -omnitrace_add_interface_library( - omnitrace-compile-timing +rocprofiler_systems_add_interface_library( + rocprofiler-systems-compile-timing "Adds compiler flags which report compilation timing metrics") if(CMAKE_CXX_COMPILER_IS_CLANG) - add_target_flag_if_avail(omnitrace-compile-timing "-ftime-trace") - if(NOT cxx_omnitrace_compile_timing_ftime_trace) - add_target_flag_if_avail(omnitrace-compile-timing "-ftime-report") + add_target_flag_if_avail(rocprofiler-systems-compile-timing "-ftime-trace") + if(NOT cxx_rocprofiler_systems_compile_timing_ftime_trace) + add_target_flag_if_avail(rocprofiler-systems-compile-timing "-ftime-report") endif() else() - add_target_flag_if_avail(omnitrace-compile-timing "-ftime-report") + add_target_flag_if_avail(rocprofiler-systems-compile-timing "-ftime-report") endif() -if(OMNITRACE_USE_COMPILE_TIMING) - target_link_libraries(omnitrace-compile-options INTERFACE omnitrace-compile-timing) +if(ROCPROFSYS_USE_COMPILE_TIMING) + target_link_libraries(rocprofiler-systems-compile-options + INTERFACE rocprofiler-systems-compile-timing) endif() # ----------------------------------------------------------------------------------------# # fstack-protector # -omnitrace_add_interface_library(omnitrace-stack-protector - "Adds stack-protector compiler flags") -add_target_flag_if_avail(omnitrace-stack-protector "-fstack-protector-strong" +rocprofiler_systems_add_interface_library(rocprofiler-systems-stack-protector + "Adds stack-protector compiler flags") +add_target_flag_if_avail(rocprofiler-systems-stack-protector "-fstack-protector-strong" "-Wstack-protector") -if(OMNITRACE_BUILD_STACK_PROTECTOR) - target_link_libraries(omnitrace-compile-options INTERFACE omnitrace-stack-protector) +if(ROCPROFSYS_BUILD_STACK_PROTECTOR) + target_link_libraries(rocprofiler-systems-compile-options + INTERFACE rocprofiler-systems-stack-protector) endif() # ----------------------------------------------------------------------------------------# # developer build flags # -if(OMNITRACE_BUILD_DEVELOPER) +if(ROCPROFSYS_BUILD_DEVELOPER) add_target_flag_if_avail( - omnitrace-compile-options "-Werror" "-Wdouble-promotion" "-Wshadow" "-Wextra" - "-Wpedantic" "-Wstack-usage=524288" # 512 KB + rocprofiler-systems-compile-options "-Werror" "-Wdouble-promotion" "-Wshadow" + "-Wextra" "-Wpedantic" "-Wstack-usage=524288" # 512 KB "/showIncludes") - if(OMNITRACE_BUILD_NUMBER GREATER 2) - add_target_flag_if_avail(omnitrace-compile-options "-gsplit-dwarf") + if(ROCPROFSYS_BUILD_NUMBER GREATER 2) + add_target_flag_if_avail(rocprofiler-systems-compile-options "-gsplit-dwarf") endif() endif() -if(OMNITRACE_BUILD_LINKER) +if(ROCPROFSYS_BUILD_LINKER) target_link_options( - omnitrace-compile-options INTERFACE - $<$:-fuse-ld=${OMNITRACE_BUILD_LINKER}> - $<$:-fuse-ld=${OMNITRACE_BUILD_LINKER}>) + rocprofiler-systems-compile-options INTERFACE + $<$:-fuse-ld=${ROCPROFSYS_BUILD_LINKER}> + $<$:-fuse-ld=${ROCPROFSYS_BUILD_LINKER}>) endif() # ----------------------------------------------------------------------------------------# # release build flags # -if(OMNITRACE_BUILD_RELEASE AND NOT OMNITRACE_BUILD_DEBUG) +if(ROCPROFSYS_BUILD_RELEASE AND NOT ROCPROFSYS_BUILD_DEBUG) add_target_flag_if_avail( - omnitrace-compile-options "-g1" "-feliminate-unused-debug-symbols" + rocprofiler-systems-compile-options "-g1" "-feliminate-unused-debug-symbols" "-gno-column-info" "-gno-variable-location-views" "-gline-tables-only") endif() # ----------------------------------------------------------------------------------------# # visibility build flags # -omnitrace_add_interface_library(omnitrace-default-visibility - "Adds -fvisibility=default compiler flag") -omnitrace_add_interface_library(omnitrace-hidden-visibility - "Adds -fvisibility=hidden compiler flag") +rocprofiler_systems_add_interface_library(rocprofiler-systems-default-visibility + "Adds -fvisibility=default compiler flag") +rocprofiler_systems_add_interface_library(rocprofiler-systems-hidden-visibility + "Adds -fvisibility=hidden compiler flag") -add_target_flag_if_avail(omnitrace-default-visibility "-fvisibility=default") -add_target_flag_if_avail(omnitrace-hidden-visibility "-fvisibility=hidden" +add_target_flag_if_avail(rocprofiler-systems-default-visibility "-fvisibility=default") +add_target_flag_if_avail(rocprofiler-systems-hidden-visibility "-fvisibility=hidden" "-fvisibility-inlines-hidden") # ----------------------------------------------------------------------------------------# @@ -280,7 +290,7 @@ endif() # ----------------------------------------------------------------------------------------# # sanitizer # -set(OMNITRACE_SANITIZER_TYPES +set(ROCPROFSYS_SANITIZER_TYPES address memory thread @@ -290,76 +300,77 @@ set(OMNITRACE_SANITIZER_TYPES null bounds alignment) -set_property(CACHE OMNITRACE_SANITIZER_TYPE PROPERTY STRINGS - "${OMNITRACE_SANITIZER_TYPES}") -omnitrace_add_interface_library(omnitrace-sanitizer-compile-options - "Adds compiler flags for sanitizers") -omnitrace_add_interface_library( - omnitrace-sanitizer - "Adds compiler flags to enable ${OMNITRACE_SANITIZER_TYPE} sanitizer (-fsanitizer=${OMNITRACE_SANITIZER_TYPE})" +set_property(CACHE ROCPROFSYS_SANITIZER_TYPE PROPERTY STRINGS + "${ROCPROFSYS_SANITIZER_TYPES}") +rocprofiler_systems_add_interface_library(rocprofiler-systems-sanitizer-compile-options + "Adds compiler flags for sanitizers") +rocprofiler_systems_add_interface_library( + rocprofiler-systems-sanitizer + "Adds compiler flags to enable ${ROCPROFSYS_SANITIZER_TYPE} sanitizer (-fsanitizer=${ROCPROFSYS_SANITIZER_TYPE})" ) set(COMMON_SANITIZER_FLAGS "-fno-optimize-sibling-calls" "-fno-omit-frame-pointer" "-fno-inline-functions") -add_target_flag(omnitrace-sanitizer-compile-options ${COMMON_SANITIZER_FLAGS}) +add_target_flag(rocprofiler-systems-sanitizer-compile-options ${COMMON_SANITIZER_FLAGS}) -foreach(_TYPE ${OMNITRACE_SANITIZER_TYPES}) +foreach(_TYPE ${ROCPROFSYS_SANITIZER_TYPES}) set(_FLAG "-fsanitize=${_TYPE}") - omnitrace_add_interface_library( - omnitrace-${_TYPE}-sanitizer + rocprofiler_systems_add_interface_library( + rocprofiler-systems-${_TYPE}-sanitizer "Adds compiler flags to enable ${_TYPE} sanitizer (${_FLAG})") - add_target_flag(omnitrace-${_TYPE}-sanitizer ${_FLAG}) - target_link_libraries(omnitrace-${_TYPE}-sanitizer - INTERFACE omnitrace-sanitizer-compile-options) - set_property(TARGET omnitrace-${_TYPE}-sanitizer + add_target_flag(rocprofiler-systems-${_TYPE}-sanitizer ${_FLAG}) + target_link_libraries(rocprofiler-systems-${_TYPE}-sanitizer + INTERFACE rocprofiler-systems-sanitizer-compile-options) + set_property(TARGET rocprofiler-systems-${_TYPE}-sanitizer PROPERTY INTERFACE_LINK_OPTIONS ${_FLAG} ${COMMON_SANITIZER_FLAGS}) endforeach() unset(_FLAG) unset(COMMON_SANITIZER_FLAGS) -if(OMNITRACE_USE_SANITIZER) - foreach(_TYPE ${OMNITRACE_SANITIZER_TYPE}) - if(TARGET omnitrace-${_TYPE}-sanitizer) - target_link_libraries(omnitrace-sanitizer - INTERFACE omnitrace-${_TYPE}-sanitizer) +if(ROCPROFSYS_USE_SANITIZER) + foreach(_TYPE ${ROCPROFSYS_SANITIZER_TYPE}) + if(TARGET rocprofiler-systems-${_TYPE}-sanitizer) + target_link_libraries(rocprofiler-systems-sanitizer + INTERFACE rocprofiler-systems-${_TYPE}-sanitizer) else() message( - FATAL_ERROR "Error! Target 'omnitrace-${_TYPE}-sanitizer' does not exist!" + FATAL_ERROR + "Error! Target 'rocprofiler-systems-${_TYPE}-sanitizer' does not exist!" ) endif() endforeach() else() - set(OMNITRACE_USE_SANITIZER OFF) + set(ROCPROFSYS_USE_SANITIZER OFF) endif() # ----------------------------------------------------------------------------------------# # static lib flags # target_compile_options( - omnitrace-static-libgcc + rocprofiler-systems-static-libgcc INTERFACE $<$:$<$:-static-libgcc>> $<$:$<$:-static-libgcc>>) target_link_options( - omnitrace-static-libgcc INTERFACE + rocprofiler-systems-static-libgcc INTERFACE $<$:$<$:-static-libgcc>> $<$:$<$:-static-libgcc>>) target_compile_options( - omnitrace-static-libstdcxx + rocprofiler-systems-static-libstdcxx INTERFACE $<$:$<$:-static-libstdc++>>) target_link_options( - omnitrace-static-libstdcxx INTERFACE + rocprofiler-systems-static-libstdcxx INTERFACE $<$:$<$:-static-libstdc++>>) -if(OMNITRACE_BUILD_STATIC_LIBGCC) - target_link_libraries(omnitrace-static-libgcc-optional - INTERFACE omnitrace-static-libgcc) +if(ROCPROFSYS_BUILD_STATIC_LIBGCC) + target_link_libraries(rocprofiler-systems-static-libgcc-optional + INTERFACE rocprofiler-systems-static-libgcc) endif() -if(OMNITRACE_BUILD_STATIC_LIBSTDCXX) - target_link_libraries(omnitrace-static-libstdcxx-optional - INTERFACE omnitrace-static-libstdcxx) +if(ROCPROFSYS_BUILD_STATIC_LIBSTDCXX) + target_link_libraries(rocprofiler-systems-static-libstdcxx-optional + INTERFACE rocprofiler-systems-static-libstdcxx) endif() # ----------------------------------------------------------------------------------------# @@ -368,5 +379,5 @@ endif() get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) if(NOT APPLE OR "$ENV{CONDA_PYTHON_EXE}" STREQUAL "") - add_user_flags(omnitrace-compile-options "CXX") + add_user_flags(rocprofiler-systems-compile-options "CXX") endif() diff --git a/cmake/Compilers.cmake b/cmake/Compilers.cmake index b1507b0e..9d02fcfa 100644 --- a/cmake/Compilers.cmake +++ b/cmake/Compilers.cmake @@ -30,7 +30,7 @@ if("${LIBNAME}" STREQUAL "") endif() if(NOT TARGET ${LIBNAME}-compile-options) - omnitrace_add_interface_library( + rocprofiler_systems_add_interface_library( ${LIBNAME}-compile-options "Adds the standard set of compiler flags used by timemory") endif() @@ -88,12 +88,12 @@ endmacro(set_no_duplicates _VAR) # ----------------------------------------------------------------------------------------# # call before running check_{c,cxx}_compiler_flag # ----------------------------------------------------------------------------------------# -macro(omnitrace_begin_flag_check) - if(OMNITRACE_QUIET_CONFIG) +macro(rocprofiler_systems_begin_flag_check) + if(ROCPROFSYS_QUIET_CONFIG) if(NOT DEFINED CMAKE_REQUIRED_QUIET) set(CMAKE_REQUIRED_QUIET OFF) endif() - omnitrace_save_variables(FLAG_CHECK VARIABLES CMAKE_REQUIRED_QUIET) + rocprofiler_systems_save_variables(FLAG_CHECK VARIABLES CMAKE_REQUIRED_QUIET) set(CMAKE_REQUIRED_QUIET ON) endif() endmacro() @@ -101,9 +101,9 @@ endmacro() # ----------------------------------------------------------------------------------------# # call after running check_{c,cxx}_compiler_flag # ----------------------------------------------------------------------------------------# -macro(omnitrace_end_flag_check) - if(OMNITRACE_QUIET_CONFIG) - omnitrace_restore_variables(FLAG_CHECK VARIABLES CMAKE_REQUIRED_QUIET) +macro(rocprofiler_systems_end_flag_check) + if(ROCPROFSYS_QUIET_CONFIG) + rocprofiler_systems_restore_variables(FLAG_CHECK VARIABLES CMAKE_REQUIRED_QUIET) endif() endmacro() @@ -125,7 +125,7 @@ macro(ADD_TARGET_C_FLAG _TARG) endif() string(REPLACE "-" "_" _MAKE_TARG "${_TARG}") - list(APPEND OMNITRACE_MAKE_TARGETS ${_MAKE_TARG}) + list(APPEND ROCPROFSYS_MAKE_TARGETS ${_MAKE_TARG}) target_compile_options(${_TARG} ${_SCOPE} $<$:${ARGN}>) list(APPEND ${_MAKE_TARG}_C_FLAGS ${ARGN}) @@ -159,7 +159,7 @@ endmacro() # ----------------------------------------------------------------------------------------# macro(ADD_C_FLAG_IF_AVAIL FLAG) set(_ENABLE ON) - if(DEFINED OMNITRACE_BUILD_C AND NOT OMNITRACE_BUILD_C) + if(DEFINED ROCPROFSYS_BUILD_C AND NOT ROCPROFSYS_BUILD_C) set(_ENABLE OFF) endif() set(_TARG) @@ -174,17 +174,17 @@ macro(ADD_C_FLAG_IF_AVAIL FLAG) string(REPLACE "-" "_" FLAG_NAME "${FLAG_NAME}") string(REPLACE " " "_" FLAG_NAME "${FLAG_NAME}") string(REPLACE "=" "_" FLAG_NAME "${FLAG_NAME}") - if(NOT OMNITRACE_BUILD_C) + if(NOT ROCPROFSYS_BUILD_C) set(${FLAG_NAME} ON) else() - omnitrace_begin_flag_check() + rocprofiler_systems_begin_flag_check() check_c_compiler_flag("-Werror" c_werror) if(c_werror) check_c_compiler_flag("${FLAG} -Werror" ${FLAG_NAME}) else() check_c_compiler_flag("${FLAG}" ${FLAG_NAME}) endif() - omnitrace_end_flag_check() + rocprofiler_systems_end_flag_check() if(${FLAG_NAME}) if("${_LTARG}" STREQUAL "") list(APPEND ${PROJECT_NAME}_C_FLAGS "${FLAG}") @@ -227,7 +227,7 @@ macro(ADD_TARGET_CXX_FLAG _TARG) endif() string(REPLACE "-" "_" _MAKE_TARG "${_TARG}") - list(APPEND OMNITRACE_MAKE_TARGETS ${_MAKE_TARG}) + list(APPEND ROCPROFSYS_MAKE_TARGETS ${_MAKE_TARG}) target_compile_options(${_TARG} ${_SCOPE} $<$:${ARGN}>) list(APPEND ${_MAKE_TARG}_CXX_FLAGS ${ARGN}) @@ -282,14 +282,14 @@ macro(ADD_CXX_FLAG_IF_AVAIL FLAG) string(REPLACE " " "_" FLAG_NAME "${FLAG_NAME}") string(REPLACE "=" "_" FLAG_NAME "${FLAG_NAME}") string(REPLACE "/" "_" FLAG_NAME "${FLAG_NAME}") - omnitrace_begin_flag_check() + rocprofiler_systems_begin_flag_check() check_cxx_compiler_flag("-Werror" cxx_werror) if(cxx_werror) check_cxx_compiler_flag("${FLAG} -Werror" ${FLAG_NAME}) else() check_cxx_compiler_flag("${FLAG}" ${FLAG_NAME}) endif() - omnitrace_end_flag_check() + rocprofiler_systems_end_flag_check() if(${FLAG_NAME}) if("${_LTARG}" STREQUAL "") list(APPEND ${PROJECT_NAME}_CXX_FLAGS "${FLAG}") @@ -362,7 +362,7 @@ endmacro() # ----------------------------------------------------------------------------------------# # check flag # ----------------------------------------------------------------------------------------# -function(OMNITRACE_TARGET_FLAG _TARG_TARGET) +function(ROCPROFILER_SYSTEMS_TARGET_FLAG _TARG_TARGET) cmake_parse_arguments(_TARG "IF_AVAIL" "MODE" "FLAGS;LANGUAGES" ${ARGN}) if(NOT _TARG_MODE) @@ -391,14 +391,14 @@ function(OMNITRACE_TARGET_FLAG _TARG_TARGET) string(REPLACE "-" "_" FLAG_NAME "${FLAG_NAME}") string(REPLACE " " "_" FLAG_NAME "${FLAG_NAME}") string(REPLACE "=" "_" FLAG_NAME "${FLAG_NAME}") - omnitrace_begin_flag_check() + rocprofiler_systems_begin_flag_check() check_c_compiler_flag("-Werror" c_werror) if(c_werror) check_c_compiler_flag("${FLAG} -Werror" ${FLAG_NAME}) else() check_c_compiler_flag("${FLAG}" ${FLAG_NAME}) endif() - omnitrace_end_flag_check() + rocprofiler_systems_end_flag_check() if(${FLAG_NAME}) target_compile_options(${_TARG_TARGET} ${_TARG_MODE} $<$:${_FLAG}>) @@ -409,14 +409,14 @@ function(OMNITRACE_TARGET_FLAG _TARG_TARGET) string(REPLACE "-" "_" FLAG_NAME "${FLAG_NAME}") string(REPLACE " " "_" FLAG_NAME "${FLAG_NAME}") string(REPLACE "=" "_" FLAG_NAME "${FLAG_NAME}") - omnitrace_begin_flag_check() + rocprofiler_systems_begin_flag_check() check_cxx_compiler_flag("-Werror" cxx_werror) if(cxx_werror) check_cxx_compiler_flag("${FLAG} -Werror" ${FLAG_NAME}) else() check_cxx_compiler_flag("${FLAG}" ${FLAG_NAME}) endif() - omnitrace_end_flag_check() + rocprofiler_systems_end_flag_check() if(${FLAG_NAME}) target_compile_options(${_TARG_TARGET} ${_TARG_MODE} $<$:${_FLAG}>) @@ -439,7 +439,7 @@ endfunction() # ----------------------------------------------------------------------------------------# macro(ADD_TARGET_CUDA_FLAG _TARG) string(REPLACE "-" "_" _MAKE_TARG "${_TARG}") - list(APPEND OMNITRACE_MAKE_TARGETS ${_MAKE_TARG}) + list(APPEND ROCPROFSYS_MAKE_TARGETS ${_MAKE_TARG}) target_compile_options(${_TARG} INTERFACE $<$:${ARGN}>) list(APPEND ${_MAKE_TARG}_CUDA_FLAGS ${ARGN}) @@ -470,9 +470,9 @@ endfunction() # ----------------------------------------------------------------------------------------# # add compiler definition # ----------------------------------------------------------------------------------------# -function(OMNITRACE_TARGET_COMPILE_DEFINITIONS _TARG _VIS) +function(ROCPROFILER_SYSTEMS_TARGET_COMPILE_DEFINITIONS _TARG _VIS) foreach(_DEF ${ARGN}) - if(NOT "${_DEF}" MATCHES "[A-Za-z_]+=.*" AND "${_DEF}" MATCHES "^OMNITRACE_") + if(NOT "${_DEF}" MATCHES "[A-Za-z_]+=.*" AND "${_DEF}" MATCHES "^ROCPROFSYS_") set(_DEF "${_DEF}=1") endif() target_compile_definitions(${_TARG} ${_VIS} $<$:${_DEF}>) diff --git a/cmake/ConfigCPack.cmake b/cmake/ConfigCPack.cmake index 82c354b5..14ed2fcc 100644 --- a/cmake/ConfigCPack.cmake +++ b/cmake/ConfigCPack.cmake @@ -1,6 +1,6 @@ # configure packaging -function(omnitrace_parse_release) +function(rocprofiler_systems_parse_release) if(EXISTS /etc/lsb-release AND NOT IS_DIRECTORY /etc/lsb-release) file(READ /etc/lsb-release _LSB_RELEASE) if(_LSB_RELEASE) @@ -27,7 +27,7 @@ function(omnitrace_parse_release) endfunction() # parse either /etc/lsb-release or /etc/os-release -omnitrace_parse_release() +rocprofiler_systems_parse_release() if(NOT _SYSTEM_NAME) set(_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}") @@ -42,83 +42,83 @@ set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}") set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}") -set(CPACK_PACKAGE_CONTACT "jonathan.madsen@amd.com") +set(CPACK_PACKAGE_CONTACT "https://github.com/ROCm/rocprofiler-systems") set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF) -set(OMNITRACE_CPACK_SYSTEM_NAME +set(ROCPROFSYS_CPACK_SYSTEM_NAME "${_SYSTEM_NAME}" CACHE STRING "System name, e.g. Linux or Ubuntu-20.04") -set(OMNITRACE_CPACK_PACKAGE_SUFFIX "") +set(ROCPROFSYS_CPACK_PACKAGE_SUFFIX "") -if(OMNITRACE_USE_HIP - OR OMNITRACE_USE_ROCTRACER - OR OMNITRACE_USE_ROCM_SMI) - set(OMNITRACE_CPACK_PACKAGE_SUFFIX - "${OMNITRACE_CPACK_PACKAGE_SUFFIX}-ROCm-${ROCmVersion_NUMERIC_VERSION}") +if(ROCPROFSYS_USE_HIP + OR ROCPROFSYS_USE_ROCTRACER + OR ROCPROFSYS_USE_ROCM_SMI) + set(ROCPROFSYS_CPACK_PACKAGE_SUFFIX + "${ROCPROFSYS_CPACK_PACKAGE_SUFFIX}-ROCm-${ROCmVersion_NUMERIC_VERSION}") endif() -if(OMNITRACE_USE_PAPI) - set(OMNITRACE_CPACK_PACKAGE_SUFFIX "${OMNITRACE_CPACK_PACKAGE_SUFFIX}-PAPI") +if(ROCPROFSYS_USE_PAPI) + set(ROCPROFSYS_CPACK_PACKAGE_SUFFIX "${ROCPROFSYS_CPACK_PACKAGE_SUFFIX}-PAPI") endif() -if(OMNITRACE_USE_OMPT) - set(OMNITRACE_CPACK_PACKAGE_SUFFIX "${OMNITRACE_CPACK_PACKAGE_SUFFIX}-OMPT") +if(ROCPROFSYS_USE_OMPT) + set(ROCPROFSYS_CPACK_PACKAGE_SUFFIX "${ROCPROFSYS_CPACK_PACKAGE_SUFFIX}-OMPT") endif() -if(OMNITRACE_USE_MPI) +if(ROCPROFSYS_USE_MPI) set(VALID_MPI_IMPLS "mpich" "openmpi") if("${MPI_C_COMPILER_INCLUDE_DIRS};${MPI_C_HEADER_DIR}" MATCHES "openmpi") - set(OMNITRACE_MPI_IMPL "openmpi") + set(ROCPROFSYS_MPI_IMPL "openmpi") elseif("${MPI_C_COMPILER_INCLUDE_DIRS};${MPI_C_HEADER_DIR}" MATCHES "mpich") - set(OMNITRACE_MPI_IMPL "mpich") + set(ROCPROFSYS_MPI_IMPL "mpich") else() message( WARNING - "MPI implementation could not be determined. Please set OMNITRACE_MPI_IMPL to one of the following for CPack: ${VALID_MPI_IMPLS}" + "MPI implementation could not be determined. Please set ROCPROFSYS_MPI_IMPL to one of the following for CPack: ${VALID_MPI_IMPLS}" ) endif() - if(OMNITRACE_MPI_IMPL AND NOT "${OMNITRACE_MPI_IMPL}" IN_LIST VALID_MPI_IMPLS) + if(ROCPROFSYS_MPI_IMPL AND NOT "${ROCPROFSYS_MPI_IMPL}" IN_LIST VALID_MPI_IMPLS) message( SEND_ERROR - "Invalid OMNITRACE_MPI_IMPL (${OMNITRACE_MPI_IMPL}). Should be one of: ${VALID_MPI_IMPLS}" + "Invalid ROCPROFSYS_MPI_IMPL (${ROCPROFSYS_MPI_IMPL}). Should be one of: ${VALID_MPI_IMPLS}" ) else() - omnitrace_add_feature(OMNITRACE_MPI_IMPL - "MPI implementation for CPack DEBIAN depends") + rocprofiler_systems_add_feature(ROCPROFSYS_MPI_IMPL + "MPI implementation for CPack DEBIAN depends") endif() - if("${OMNITRACE_MPI_IMPL}" STREQUAL "openmpi") - set(OMNITRACE_MPI_IMPL_UPPER "OpenMPI") - elseif("${OMNITRACE_MPI_IMPL}" STREQUAL "mpich") - set(OMNITRACE_MPI_IMPL_UPPER "MPICH") + if("${ROCPROFSYS_MPI_IMPL}" STREQUAL "openmpi") + set(ROCPROFSYS_MPI_IMPL_UPPER "OpenMPI") + elseif("${ROCPROFSYS_MPI_IMPL}" STREQUAL "mpich") + set(ROCPROFSYS_MPI_IMPL_UPPER "MPICH") else() - set(OMNITRACE_MPI_IMPL_UPPER "MPI") + set(ROCPROFSYS_MPI_IMPL_UPPER "MPI") endif() - set(OMNITRACE_CPACK_PACKAGE_SUFFIX - "${OMNITRACE_CPACK_PACKAGE_SUFFIX}-${OMNITRACE_MPI_IMPL_UPPER}") + set(ROCPROFSYS_CPACK_PACKAGE_SUFFIX + "${ROCPROFSYS_CPACK_PACKAGE_SUFFIX}-${ROCPROFSYS_MPI_IMPL_UPPER}") endif() -if(OMNITRACE_USE_PYTHON) - set(_OMNITRACE_PYTHON_NAME "Python3") - foreach(_VER ${OMNITRACE_PYTHON_VERSIONS}) +if(ROCPROFSYS_USE_PYTHON) + set(_ROCPROFSYS_PYTHON_NAME "Python3") + foreach(_VER ${ROCPROFSYS_PYTHON_VERSIONS}) if("${_VER}" VERSION_LESS 3.0.0) - set(_OMNITRACE_PYTHON_NAME "Python") + set(_ROCPROFSYS_PYTHON_NAME "Python") endif() endforeach() - set(OMNITRACE_CPACK_PACKAGE_SUFFIX "${OMNITRACE_CPACK_PACKAGE_SUFFIX}-Python3") + set(ROCPROFSYS_CPACK_PACKAGE_SUFFIX "${ROCPROFSYS_CPACK_PACKAGE_SUFFIX}-Python3") endif() set(CPACK_PACKAGE_FILE_NAME - "${CPACK_PACKAGE_NAME}-${OMNITRACE_VERSION}-${OMNITRACE_CPACK_SYSTEM_NAME}${OMNITRACE_CPACK_PACKAGE_SUFFIX}" + "${CPACK_PACKAGE_NAME}-${ROCPROFSYS_VERSION}-${ROCPROFSYS_CPACK_SYSTEM_NAME}${ROCPROFSYS_CPACK_PACKAGE_SUFFIX}" ) if(DEFINED ENV{CPACK_PACKAGE_FILE_NAME}) set(CPACK_PACKAGE_FILE_NAME $ENV{CPACK_PACKAGE_FILE_NAME}) endif() -set(OMNITRACE_PACKAGE_FILE_NAME - ${CPACK_PACKAGE_NAME}-${OMNITRACE_VERSION}-${OMNITRACE_CPACK_SYSTEM_NAME}${OMNITRACE_CPACK_PACKAGE_SUFFIX} +set(ROCPROFSYS_PACKAGE_FILE_NAME + ${CPACK_PACKAGE_NAME}-${ROCPROFSYS_VERSION}-${ROCPROFSYS_CPACK_SYSTEM_NAME}${ROCPROFSYS_CPACK_PACKAGE_SUFFIX} ) -omnitrace_add_feature(OMNITRACE_PACKAGE_FILE_NAME "CPack filename") +rocprofiler_systems_add_feature(ROCPROFSYS_PACKAGE_FILE_NAME "CPack filename") # -------------------------------------------------------------------------------------- # # @@ -126,9 +126,9 @@ omnitrace_add_feature(OMNITRACE_PACKAGE_FILE_NAME "CPack filename") # # -------------------------------------------------------------------------------------- # -set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/ROCm/omnitrace") +set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/ROCm/rocprofiler-systems") set(CPACK_DEBIAN_PACKAGE_RELEASE - "${OMNITRACE_CPACK_SYSTEM_NAME}${OMNITRACE_CPACK_PACKAGE_SUFFIX}") + "${ROCPROFSYS_CPACK_SYSTEM_NAME}${ROCPROFSYS_CPACK_PACKAGE_SUFFIX}") string(REGEX REPLACE "([a-zA-Z])-([0-9])" "\\1\\2" CPACK_DEBIAN_PACKAGE_RELEASE "${CPACK_DEBIAN_PACKAGE_RELEASE}") string(REPLACE "-" "~" CPACK_DEBIAN_PACKAGE_RELEASE "${CPACK_DEBIAN_PACKAGE_RELEASE}") @@ -137,10 +137,10 @@ set(_DEBIAN_PACKAGE_DEPENDS "") if(DYNINST_USE_OpenMP) list(APPEND _DEBIAN_PACKAGE_DEPENDS libgomp1) endif() -if(OMNITRACE_USE_PAPI AND NOT OMNITRACE_BUILD_PAPI) +if(ROCPROFSYS_USE_PAPI AND NOT ROCPROFSYS_BUILD_PAPI) list(APPEND _DEBIAN_PACKAGE_DEPENDS libpapi-dev libpfm4) endif() -if(NOT OMNITRACE_BUILD_DYNINST) +if(NOT ROCPROFSYS_BUILD_DYNINST) if(NOT DYNINST_BUILD_BOOST) foreach(_BOOST_COMPONENT atomic system thread date-time filesystem timer) list(APPEND _DEBIAN_PACKAGE_DEPENDS @@ -160,19 +160,19 @@ if(ROCmVersion_FOUND) set(_ROCM_SMI_SUFFIX " (>= ${ROCmVersion_MAJOR_VERSION}.0.0.${ROCmVersion_NUMERIC_VERSION})") endif() -if(OMNITRACE_USE_ROCM_SMI) +if(ROCPROFSYS_USE_ROCM_SMI) list(APPEND _DEBIAN_PACKAGE_DEPENDS "rocm-smi-lib${_ROCM_SMI_SUFFIX}") endif() -if(OMNITRACE_USE_ROCTRACER) +if(ROCPROFSYS_USE_ROCTRACER) list(APPEND _DEBIAN_PACKAGE_DEPENDS "roctracer-dev${_ROCTRACER_SUFFIX}") endif() -if(OMNITRACE_USE_ROCPROFILER) +if(ROCPROFSYS_USE_ROCPROFILER) list(APPEND _DEBIAN_PACKAGE_DEPENDS "rocprofiler-dev${_ROCPROFILER_SUFFIX}") endif() -if(OMNITRACE_USE_MPI) - if("${OMNITRACE_MPI_IMPL}" STREQUAL "openmpi") +if(ROCPROFSYS_USE_MPI) + if("${ROCPROFSYS_MPI_IMPL}" STREQUAL "openmpi") list(APPEND _DEBIAN_PACKAGE_DEPENDS "libopenmpi-dev") - elseif("${OMNITRACE_MPI_IMPL}" STREQUAL "mpich") + elseif("${ROCPROFSYS_MPI_IMPL}" STREQUAL "mpich") list(APPEND _DEBIAN_PACKAGE_DEPENDS "libmpich-dev") endif() endif() @@ -195,14 +195,14 @@ if(DEFINED CPACK_PACKAGING_INSTALL_PREFIX) endif() set(CPACK_RPM_PACKAGE_RELEASE - "${OMNITRACE_CPACK_SYSTEM_NAME}${OMNITRACE_CPACK_PACKAGE_SUFFIX}") + "${ROCPROFSYS_CPACK_SYSTEM_NAME}${ROCPROFSYS_CPACK_PACKAGE_SUFFIX}") string(REGEX REPLACE "([a-zA-Z])-([0-9])" "\\1\\2" CPACK_RPM_PACKAGE_RELEASE "${CPACK_RPM_PACKAGE_RELEASE}") string(REPLACE "-" "~" CPACK_RPM_PACKAGE_RELEASE "${CPACK_RPM_PACKAGE_RELEASE}") set(_RPM_PACKAGE_PROVIDES "") -if(OMNITRACE_BUILD_LIBUNWIND) +if(ROCPROFSYS_BUILD_LIBUNWIND) list(APPEND _RPM_PACKAGE_PROVIDES "libunwind.so.99()(64bit)") list(APPEND _RPM_PACKAGE_PROVIDES "libunwind-x86_64.so.99()(64bit)") list(APPEND _RPM_PACKAGE_PROVIDES "libunwind-setjmp.so.0()(64bit)") @@ -241,22 +241,25 @@ if(DEFINED ENV{CPACK_RPM_PACKAGE_RELEASE}) set(CPACK_RPM_PACKAGE_RELEASE $ENV{CPACK_RPM_PACKAGE_RELEASE}) endif() -omnitrace_add_feature(CPACK_PACKAGE_NAME "Package name") -omnitrace_add_feature(CPACK_PACKAGE_VERSION "Package version") -omnitrace_add_feature(CPACK_PACKAGING_INSTALL_PREFIX "Package installation prefix") - -omnitrace_add_feature(CPACK_DEBIAN_FILE_NAME "Debian file name") -omnitrace_add_feature(CPACK_DEBIAN_PACKAGE_RELEASE "Debian package release version") -omnitrace_add_feature(CPACK_DEBIAN_PACKAGE_DEPENDS "Debian package dependencies") -omnitrace_add_feature(CPACK_DEBIAN_PACKAGE_SHLIBDEPS - "Debian package shared library dependencies") - -omnitrace_add_feature(CPACK_RPM_FILE_NAME "RPM file name") -omnitrace_add_feature(CPACK_RPM_PACKAGE_RELEASE "RPM package release version") -omnitrace_add_feature(CPACK_RPM_PACKAGE_REQUIRES "RPM package dependencies") -omnitrace_add_feature(CPACK_RPM_PACKAGE_AUTOREQPROV - "RPM package auto generate requires and provides") -omnitrace_add_feature(CPACK_RPM_PACKAGE_REQUIRES "RPM package requires") -omnitrace_add_feature(CPACK_RPM_PACKAGE_PROVIDES "RPM package provides") +rocprofiler_systems_add_feature(CPACK_PACKAGE_NAME "Package name") +rocprofiler_systems_add_feature(CPACK_PACKAGE_VERSION "Package version") +rocprofiler_systems_add_feature(CPACK_PACKAGING_INSTALL_PREFIX + "Package installation prefix") + +rocprofiler_systems_add_feature(CPACK_DEBIAN_FILE_NAME "Debian file name") +rocprofiler_systems_add_feature(CPACK_DEBIAN_PACKAGE_RELEASE + "Debian package release version") +rocprofiler_systems_add_feature(CPACK_DEBIAN_PACKAGE_DEPENDS + "Debian package dependencies") +rocprofiler_systems_add_feature(CPACK_DEBIAN_PACKAGE_SHLIBDEPS + "Debian package shared library dependencies") + +rocprofiler_systems_add_feature(CPACK_RPM_FILE_NAME "RPM file name") +rocprofiler_systems_add_feature(CPACK_RPM_PACKAGE_RELEASE "RPM package release version") +rocprofiler_systems_add_feature(CPACK_RPM_PACKAGE_REQUIRES "RPM package dependencies") +rocprofiler_systems_add_feature(CPACK_RPM_PACKAGE_AUTOREQPROV + "RPM package auto generate requires and provides") +rocprofiler_systems_add_feature(CPACK_RPM_PACKAGE_REQUIRES "RPM package requires") +rocprofiler_systems_add_feature(CPACK_RPM_PACKAGE_PROVIDES "RPM package provides") include(CPack) diff --git a/cmake/ConfigInstall.cmake b/cmake/ConfigInstall.cmake index 691a4101..a102e26a 100644 --- a/cmake/ConfigInstall.cmake +++ b/cmake/ConfigInstall.cmake @@ -6,10 +6,10 @@ include(CMakePackageConfigHelpers) set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME config) install( - EXPORT omnitrace-library-targets - FILE omnitrace-library-targets.cmake - NAMESPACE omnitrace:: - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/omnitrace) + EXPORT rocprofiler-systems-library-targets + FILE ${PROJECT_NAME}-library-targets.cmake + NAMESPACE rocprofiler-systems:: + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/${PROJECT_NAME}) # ------------------------------------------------------------------------------# # install tree @@ -20,9 +20,9 @@ set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}) set(PROJECT_BUILD_TARGETS user) configure_package_config_file( - ${PROJECT_SOURCE_DIR}/cmake/Templates/${PROJECT_NAME}-config.cmake.in + ${PROJECT_SOURCE_DIR}/cmake/Templates/rocprof-sys-config.cmake.in ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}-config.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/omnitrace + INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/${PROJECT_NAME} INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} PATH_VARS PROJECT_INSTALL_DIR INCLUDE_INSTALL_DIR LIB_INSTALL_DIR) @@ -45,16 +45,16 @@ 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}) # ------------------------------------------------------------------------------# # build tree # set(_BUILDTREE_EXPORT_DIR - "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/cmake/omnitrace") + "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/cmake/${PROJECT_NAME}") if(NOT EXISTS "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}") file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}") @@ -64,15 +64,15 @@ if(NOT EXISTS "${_BUILDTREE_EXPORT_DIR}") file(MAKE_DIRECTORY "${_BUILDTREE_EXPORT_DIR}") endif() -if(NOT EXISTS "${_BUILDTREE_EXPORT_DIR}/omnitrace-library-targets.cmake") - file(TOUCH "${_BUILDTREE_EXPORT_DIR}/omnitrace-library-targets.cmake") +if(NOT EXISTS "${_BUILDTREE_EXPORT_DIR}/${PROJECT_NAME}-library-targets.cmake") + file(TOUCH "${_BUILDTREE_EXPORT_DIR}/${PROJECT_NAME}-library-targets.cmake") endif() export( - EXPORT omnitrace-library-targets - NAMESPACE omnitrace:: - FILE "${_BUILDTREE_EXPORT_DIR}/omnitrace-library-targets.cmake") + EXPORT ${PROJECT_NAME}-library-targets + NAMESPACE rocprofiler-systems:: + FILE "${_BUILDTREE_EXPORT_DIR}/${PROJECT_NAME}-library-targets.cmake") -set(omnitrace_DIR +set(${PROJECT_NAME}_DIR "${_BUILDTREE_EXPORT_DIR}" - CACHE PATH "omnitrace" FORCE) + CACHE PATH "${PROJECT_NAME}" FORCE) diff --git a/cmake/ElfUtils.cmake b/cmake/ElfUtils.cmake index df6a9a99..8a829557 100644 --- a/cmake/ElfUtils.cmake +++ b/cmake/ElfUtils.cmake @@ -1,7 +1,7 @@ # ====================================================================================== # elfutils.cmake # -# Configure elfutils for omnitrace +# Configure elfutils for rocprofiler-systems # # ---------------------------------------- # @@ -38,7 +38,7 @@ set(ElfUtils_MIN_VERSION CACHE STRING "Minimum acceptable elfutils version") if(${ElfUtils_MIN_VERSION} VERSION_LESS ${_min_version}) - omnitrace_message( + rocprofiler_systems_message( FATAL_ERROR "Requested version ${ElfUtils_MIN_VERSION} is less than minimum supported version (${_min_version})" ) @@ -51,7 +51,7 @@ set(ElfUtils_DOWNLOAD_VERSION # make sure we are not downloading a version less than minimum if(${ElfUtils_DOWNLOAD_VERSION} VERSION_LESS ${ElfUtils_MIN_VERSION}) - omnitrace_message( + rocprofiler_systems_message( FATAL_ERROR "elfutils download version is set to ${ElfUtils_DOWNLOAD_VERSION} but elfutils minimum version is set to ${ElfUtils_MIN_VERSION}" ) @@ -85,7 +85,7 @@ find_program( PATH_SUFFIXES bin) if(NOT ElfUtils_C_COMPILER OR NOT ElfUtils_CXX_COMPILER) - omnitrace_message( + rocprofiler_systems_message( FATAL_ERROR "ElfUtils requires the GNU C and C++ compilers. ElfUtils_C_COMPILER: ${ElfUtils_C_COMPILER}, ElfUtils_CXX_COMPILER: ${ElfUtils_CXX_COMPILER}" ) @@ -100,7 +100,7 @@ set(_eu_build_byproducts "${_eu_root}/lib/libdw${CMAKE_STATIC_LIBRARY_SUFFIX}" "${_eu_root}/lib/libelf${CMAKE_STATIC_LIBRARY_SUFFIX}") externalproject_add( - omnitrace-elfutils-build + rocprofiler-systems-elfutils-build PREFIX ${PROJECT_BINARY_DIR}/external/elfutils URL ${ElfUtils_DOWNLOAD_URL} "https://sourceware.org/elfutils/ftp/${ElfUtils_DOWNLOAD_VERSION}/elfutils-${ElfUtils_DOWNLOAD_VERSION}.tar.bz2" @@ -119,7 +119,7 @@ externalproject_add( # target for re-executing the installation add_custom_target( - omnitrace-elfutils-install + rocprofiler-systems-elfutils-install COMMAND ${MAKE_COMMAND} install -s WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/external/elfutils/src/ElfUtils-External COMMENT "Installing ElfUtils...") diff --git a/cmake/Formatting.cmake b/cmake/Formatting.cmake index 52c17d12..94aa0029 100644 --- a/cmake/Formatting.cmake +++ b/cmake/Formatting.cmake @@ -7,14 +7,14 @@ include_guard(DIRECTORY) # ----------------------------------------------------------------------------------------# # clang-tidy -macro(OMNITRACE_ACTIVATE_CLANG_TIDY) - if(OMNITRACE_USE_CLANG_TIDY) +macro(ROCPROFILER_SYSTEMS_ACTIVATE_CLANG_TIDY) + if(ROCPROFSYS_USE_CLANG_TIDY) find_program(CLANG_TIDY_COMMAND NAMES clang-tidy) - omnitrace_add_feature(CLANG_TIDY_COMMAND "Path to clang-tidy command") + rocprofiler_systems_add_feature(CLANG_TIDY_COMMAND "Path to clang-tidy command") if(NOT CLANG_TIDY_COMMAND) timemory_message( - WARNING "OMNITRACE_USE_CLANG_TIDY is ON but clang-tidy is not found!") - set(OMNITRACE_USE_CLANG_TIDY OFF) + WARNING "ROCPROFSYS_USE_CLANG_TIDY is ON but clang-tidy is not found!") + set(ROCPROFSYS_USE_CLANG_TIDY OFF) else() set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_COMMAND}) @@ -37,13 +37,13 @@ endmacro() # # ------------------------------------------------------------------------------# -find_program(OMNITRACE_CLANG_FORMAT_EXE NAMES clang-format-11 clang-format-mp-11 - clang-format) +find_program(ROCPROFSYS_CLANG_FORMAT_EXE NAMES clang-format-11 clang-format-mp-11 + clang-format) -find_program(OMNITRACE_CMAKE_FORMAT_EXE NAMES cmake-format) -find_program(OMNITRACE_BLACK_FORMAT_EXE NAMES black) +find_program(ROCPROFSYS_CMAKE_FORMAT_EXE NAMES cmake-format) +find_program(ROCPROFSYS_BLACK_FORMAT_EXE NAMES black) -add_custom_target(format-omnitrace) +add_custom_target(format-rocprofiler-systems) if(NOT TARGET format) add_custom_target(format) endif() @@ -53,9 +53,9 @@ foreach(_TYPE source python cmake) endif() endforeach() -if(OMNITRACE_CLANG_FORMAT_EXE - OR OMNITRACE_BLACK_FORMAT_EXE - OR OMNITRACE_CMAKE_FORMAT_EXE) +if(ROCPROFSYS_CLANG_FORMAT_EXE + OR ROCPROFSYS_BLACK_FORMAT_EXE + OR ROCPROFSYS_CMAKE_FORMAT_EXE) file(GLOB_RECURSE sources ${PROJECT_SOURCE_DIR}/source/*.cpp ${PROJECT_SOURCE_DIR}/source/*.c) file(GLOB_RECURSE headers ${PROJECT_SOURCE_DIR}/source/*.hpp @@ -84,30 +84,34 @@ if(OMNITRACE_CLANG_FORMAT_EXE list(REMOVE_ITEM cmake_files ${external}) endif() - if(OMNITRACE_CLANG_FORMAT_EXE) + if(ROCPROFSYS_CLANG_FORMAT_EXE) add_custom_target( - format-omnitrace-source - ${OMNITRACE_CLANG_FORMAT_EXE} -i ${sources} ${headers} ${examples} + format-rocprofiler-systems-source + ${ROCPROFSYS_CLANG_FORMAT_EXE} -i ${sources} ${headers} ${examples} ${tests_source} - COMMENT "[omnitrace] Running C++ formatter ${OMNITRACE_CLANG_FORMAT_EXE}...") + COMMENT + "[rocprofiler-systems] Running C++ formatter ${ROCPROFSYS_CLANG_FORMAT_EXE}..." + ) endif() - if(OMNITRACE_BLACK_FORMAT_EXE) + if(ROCPROFSYS_BLACK_FORMAT_EXE) add_custom_target( - format-omnitrace-python - ${OMNITRACE_BLACK_FORMAT_EXE} -q ${PROJECT_SOURCE_DIR} + format-rocprofiler-systems-python + ${ROCPROFSYS_BLACK_FORMAT_EXE} -q ${PROJECT_SOURCE_DIR} COMMENT - "[omnitrace] Running Python formatter ${OMNITRACE_BLACK_FORMAT_EXE}...") + "[rocprofiler-systems] Running Python formatter ${ROCPROFSYS_BLACK_FORMAT_EXE}..." + ) if(NOT TARGET format-python) add_custom_target(format-python) endif() endif() - if(OMNITRACE_CMAKE_FORMAT_EXE) + if(ROCPROFSYS_CMAKE_FORMAT_EXE) add_custom_target( - format-omnitrace-cmake - ${OMNITRACE_CMAKE_FORMAT_EXE} -i ${cmake_files} - COMMENT "[omnitrace] Running CMake formatter ${OMNITRACE_CMAKE_FORMAT_EXE}..." + format-rocprofiler-systems-cmake + ${ROCPROFSYS_CMAKE_FORMAT_EXE} -i ${cmake_files} + COMMENT + "[rocprofiler-systems] Running CMake formatter ${ROCPROFSYS_CMAKE_FORMAT_EXE}..." ) if(NOT TARGET format-cmake) add_custom_target(format-cmake) @@ -115,15 +119,16 @@ if(OMNITRACE_CLANG_FORMAT_EXE endif() foreach(_TYPE source python cmake) - if(TARGET format-omnitrace-${_TYPE}) - add_dependencies(format-omnitrace format-omnitrace-${_TYPE}) - add_dependencies(format-${_TYPE} format-omnitrace-${_TYPE}) + if(TARGET format-rocprofiler-systems-${_TYPE}) + add_dependencies(format-rocprofiler-systems + format-rocprofiler-systems-${_TYPE}) + add_dependencies(format-${_TYPE} format-rocprofiler-systems-${_TYPE}) endif() endforeach() foreach(_TYPE source python) - if(TARGET format-omnitrace-${_TYPE}) - add_dependencies(format format-omnitrace-${_TYPE}) + if(TARGET format-rocprofiler-systems-${_TYPE}) + add_dependencies(format format-rocprofiler-systems-${_TYPE}) endif() endforeach() else() diff --git a/cmake/MacroUtilities.cmake b/cmake/MacroUtilities.cmake index af48a551..4c2c5b6d 100644 --- a/cmake/MacroUtilities.cmake +++ b/cmake/MacroUtilities.cmake @@ -12,19 +12,19 @@ include(CMakeDependentOption) include(CMakeParseArguments) # ----------------------------------------------------------------------- -# message which handles OMNITRACE_QUIET_CONFIG settings +# message which handles ROCPROFSYS_QUIET_CONFIG settings # ----------------------------------------------------------------------- # -function(OMNITRACE_MESSAGE TYPE) - if(NOT OMNITRACE_QUIET_CONFIG) - message(${TYPE} "[omnitrace] ${ARGN}") +function(ROCPROFILER_SYSTEMS_MESSAGE TYPE) + if(NOT ROCPROFSYS_QUIET_CONFIG) + message(${TYPE} "[rocprofiler-systems] ${ARGN}") endif() endfunction() # ----------------------------------------------------------------------- # Save a set of variables with the given prefix # ----------------------------------------------------------------------- -macro(OMNITRACE_SAVE_VARIABLES _PREFIX) +macro(ROCPROFILER_SYSTEMS_SAVE_VARIABLES _PREFIX) # parse args cmake_parse_arguments( SAVE @@ -58,7 +58,7 @@ endmacro() # ----------------------------------------------------------------------- # Restore a set of variables with the given prefix # ----------------------------------------------------------------------- -macro(OMNITRACE_RESTORE_VARIABLES _PREFIX) +macro(ROCPROFILER_SYSTEMS_RESTORE_VARIABLES _PREFIX) # parse args cmake_parse_arguments( RESTORE @@ -92,10 +92,10 @@ macro(OMNITRACE_RESTORE_VARIABLES _PREFIX) endmacro() # ----------------------------------------------------------------------- -# function - omnitrace_capitalize - make a string capitalized (first letter is capital) -# usage: capitalize("SHARED" CShared) message(STATUS "-- CShared is \"${CShared}\"") $ -- -# CShared is "Shared" -function(OMNITRACE_CAPITALIZE str var) +# function - rocprofiler_systems_capitalize - make a string capitalized (first letter is +# capital) usage: capitalize("SHARED" CShared) message(STATUS "-- CShared is +# \"${CShared}\"") $ -- CShared is "Shared" +function(ROCPROFILER_SYSTEMS_CAPITALIZE str var) # make string lower string(TOLOWER "${str}" str) string(SUBSTRING "${str}" 0 1 _first) @@ -108,11 +108,11 @@ function(OMNITRACE_CAPITALIZE str var) endfunction() # ------------------------------------------------------------------------------# -# function omnitrace_strip_target( [FORCE] [EXPLICIT]) +# function rocprofiler_systems_strip_target( [FORCE] [EXPLICIT]) # # Creates a post-build command which strips a binary. FORCE flag will override # -function(OMNITRACE_STRIP_TARGET) +function(ROCPROFILER_SYSTEMS_STRIP_TARGET) cmake_parse_arguments(STRIP "FORCE;EXPLICIT" "" "ARGS" ${ARGN}) list(LENGTH STRIP_UNPARSED_ARGUMENTS NUM_UNPARSED) @@ -120,17 +120,18 @@ function(OMNITRACE_STRIP_TARGET) if(NUM_UNPARSED EQUAL 1) set(_TARGET "${STRIP_UNPARSED_ARGUMENTS}") else() - omnitrace_message(FATAL_ERROR - "omnitrace_strip_target cannot deduce target from \"${ARGN}\"") + rocprofiler_systems_message( + FATAL_ERROR + "rocprofiler_systems_strip_target cannot deduce target from \"${ARGN}\"") endif() if(NOT TARGET "${_TARGET}") - omnitrace_message( + rocprofiler_systems_message( FATAL_ERROR - "omnitrace_strip_target not provided valid target: \"${_TARGET}\"") + "rocprofiler_systems_strip_target not provided valid target: \"${_TARGET}\"") endif() - if(CMAKE_STRIP AND (STRIP_FORCE OR OMNITRACE_STRIP_LIBRARIES)) + if(CMAKE_STRIP AND (STRIP_FORCE OR ROCPROFSYS_STRIP_LIBRARIES)) if(STRIP_EXPLICIT) add_custom_command( TARGET ${_TARGET} @@ -143,16 +144,16 @@ function(OMNITRACE_STRIP_TARGET) TARGET ${_TARGET} POST_BUILD COMMAND - ${CMAKE_STRIP} -w --keep-symbol="omnitrace_init" - --keep-symbol="omnitrace_finalize" - --keep-symbol="omnitrace_push_trace" - --keep-symbol="omnitrace_pop_trace" - --keep-symbol="omnitrace_push_region" - --keep-symbol="omnitrace_pop_region" --keep-symbol="omnitrace_set_env" - --keep-symbol="omnitrace_set_mpi" - --keep-symbol="omnitrace_reset_preload" - --keep-symbol="omnitrace_set_instrumented" - --keep-symbol="omnitrace_user_*" --keep-symbol="ompt_start_tool" + ${CMAKE_STRIP} -w --keep-symbol="rocprofsys_init" + --keep-symbol="rocprofsys_finalize" + --keep-symbol="rocprofsys_push_trace" + --keep-symbol="rocprofsys_pop_trace" + --keep-symbol="rocprofsys_push_region" + --keep-symbol="rocprofsys_pop_region" + --keep-symbol="rocprofsys_set_env" --keep-symbol="rocprofsys_set_mpi" + --keep-symbol="rocprofsys_reset_preload" + --keep-symbol="rocprofsys_set_instrumented" + --keep-symbol="rocprofsys_user_*" --keep-symbol="ompt_start_tool" --keep-symbol="kokkosp_*" --keep-symbol="OnLoad" --keep-symbol="OnUnload" --keep-symbol="OnLoadToolProp" --keep-symbol="OnUnloadTool" --keep-symbol="__libc_start_main" @@ -164,22 +165,17 @@ function(OMNITRACE_STRIP_TARGET) endfunction() # ------------------------------------------------------------------------------# -# function add_omnitrace_test_target() +# function add_rocprofiler_systems_test_target() # # Creates a target which runs ctest but depends on all the tests being built. # -function(ADD_OMNITRACE_TEST_TARGET) - if(NOT TARGET omnitrace-test) - add_custom_target( - omnitrace-test - COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR} --target test - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} - COMMENT "Running tests...") - endif() -endfunction() +# function(ADD_ROCPROFSYS_TEST_TARGET) if(NOT TARGET rocprofiler-systems-test) +# add_custom_target( rocprofiler-systems-test COMMAND ${CMAKE_COMMAND} --build +# ${PROJECT_BINARY_DIR} --target test WORKING_DIRECTORY ${PROJECT_BINARY_DIR} COMMENT +# "Running tests...") endif() endfunction() # ----------------------------------------------------------------------------------------# -# macro omnitrace_checkout_git_submodule() +# macro rocprofiler_systems_checkout_git_submodule() # # Run "git submodule update" if a file in a submodule does not exist # @@ -188,7 +184,7 @@ endfunction() # value) -- (default: PROJECT_SOURCE_DIR) TEST_FILE (one value) -- file to check for # (default: CMakeLists.txt) ADDITIONAL_CMDS (many value) -- any addition commands to pass # -function(OMNITRACE_CHECKOUT_GIT_SUBMODULE) +function(ROCPROFILER_SYSTEMS_CHECKOUT_GIT_SUBMODULE) # parse args cmake_parse_arguments( CHECKOUT "RECURSIVE" @@ -257,7 +253,7 @@ function(OMNITRACE_CHECKOUT_GIT_SUBMODULE) if(RET GREATER 0) set(_CMD "${GIT_EXECUTABLE} submodule update --init ${_RECURSE} ${CHECKOUT_ADDITIONAL_CMDS} ${CHECKOUT_RELATIVE_PATH}") - message(STATUS "function(omnitrace_checkout_git_submodule) failed.") + message(STATUS "function(rocprofiler_systems_checkout_git_submodule) failed.") message(FATAL_ERROR "Command: \"${_CMD}\"") else() set(_TEST_FILE_EXISTS ON) @@ -297,7 +293,7 @@ function(OMNITRACE_CHECKOUT_GIT_SUBMODULE) "${GIT_EXECUTABLE} clone -b ${CHECKOUT_REPO_BRANCH} ${CHECKOUT_ADDITIONAL_CMDS} ${CHECKOUT_REPO_URL} ${CHECKOUT_RELATIVE_PATH}" ) - message(STATUS "function(omnitrace_checkout_git_submodule) failed.") + message(STATUS "function(rocprofiler_systems_checkout_git_submodule) failed.") message(FATAL_ERROR "Command: \"${_CMD}\"") else() set(_TEST_FILE_EXISTS ON) @@ -315,10 +311,10 @@ endfunction() # ----------------------------------------------------------------------------------------# # try to find a package quietly # -function(OMNITRACE_TEST_FIND_PACKAGE PACKAGE_NAME OUTPUT_VAR) +function(ROCPROFILER_SYSTEMS_TEST_FIND_PACKAGE PACKAGE_NAME OUTPUT_VAR) cmake_parse_arguments(PACKAGE "" "" "UNSET" ${ARGN}) - find_package(${PACKAGE_NAME} QUIET ${PACKAGE_UNPARSED_ARGUMENTS}) - if(NOT ${PACKAGE_NAME}_FOUND) + find_package(${PROJECT_NAME} QUIET ${PACKAGE_UNPARSED_ARGUMENTS}) + if(NOT ${PROJECT_NAME}_FOUND) set(${OUTPUT_VAR} OFF PARENT_SCOPE) @@ -327,7 +323,7 @@ function(OMNITRACE_TEST_FIND_PACKAGE PACKAGE_NAME OUTPUT_VAR) ON PARENT_SCOPE) endif() - foreach(_ARG ${PACKAGE_UNSET} FIND_PACKAGE_MESSAGE_DETAILS_${PACKAGE_NAME}) + foreach(_ARG ${PACKAGE_UNSET} FIND_PACKAGE_MESSAGE_DETAILS_${PROJECT_NAME}) unset(${_ARG} CACHE) endforeach() endfunction() @@ -335,7 +331,7 @@ endfunction() # ----------------------------------------------------------------------------------------# # macro to add an interface lib # -macro(OMNITRACE_ADD_INTERFACE_LIBRARY _TARGET) +macro(ROCPROFILER_SYSTEMS_ADD_INTERFACE_LIBRARY _TARGET) add_library(${_TARGET} INTERFACE) add_library(${PROJECT_NAME}::${_TARGET} ALIAS ${_TARGET}) install( @@ -355,7 +351,7 @@ endmacro() # specified by the existence of the variable , to the list of enabled/disabled # features, plus a docstring describing the feature # -function(OMNITRACE_ADD_FEATURE _var _description) +function(ROCPROFILER_SYSTEMS_ADD_FEATURE _var _description) set(EXTRA_DESC "") foreach(currentArg ${ARGN}) if(NOT "${currentArg}" STREQUAL "${_var}" @@ -372,12 +368,12 @@ function(OMNITRACE_ADD_FEATURE _var _description) if("CMAKE_DEFINE" IN_LIST ARGN) set_property(GLOBAL APPEND PROPERTY ${PROJECT_NAME}_CMAKE_DEFINES "${_var} @${_var}@") - if(OMNITRACE_BUILD_DOCS) + if(ROCPROFSYS_BUILD_DOCS) set_property( GLOBAL APPEND PROPERTY ${PROJECT_NAME}_CMAKE_OPTIONS_DOC "${_var}` | ${_description}${EXTRA_DESC} |") endif() - elseif("DOC" IN_LIST ARGN AND OMNITRACE_BUILD_DOCS) + elseif("DOC" IN_LIST ARGN AND ROCPROFSYS_BUILD_DOCS) set_property(GLOBAL APPEND PROPERTY ${PROJECT_NAME}_CMAKE_OPTIONS_DOC "${_var}` | ${_description}${EXTRA_DESC} |") endif() @@ -387,13 +383,13 @@ endfunction() # function add_option( [NO_FEATURE]) Add an # option and add as a feature if NO_FEATURE is not provided # -function(OMNITRACE_ADD_OPTION _NAME _MESSAGE _DEFAULT) +function(ROCPROFILER_SYSTEMS_ADD_OPTION _NAME _MESSAGE _DEFAULT) option(${_NAME} "${_MESSAGE}" ${_DEFAULT}) if("NO_FEATURE" IN_LIST ARGN) mark_as_advanced(${_NAME}) else() - omnitrace_add_feature(${_NAME} "${_MESSAGE}") - if(OMNITRACE_BUILD_DOCS) + rocprofiler_systems_add_feature(${_NAME} "${_MESSAGE}") + if(ROCPROFSYS_BUILD_DOCS) set_property(GLOBAL APPEND PROPERTY ${PROJECT_NAME}_CMAKE_OPTIONS_DOC "${_NAME}` | ${_MESSAGE} |") endif() @@ -407,10 +403,10 @@ function(OMNITRACE_ADD_OPTION _NAME _MESSAGE _DEFAULT) endfunction() # ----------------------------------------------------------------------------------------# -# function omnitrace_add_cache_option( -# [NO_FEATURE] [ADVANCED] [CMAKE_DEFINE]) +# function rocprofiler_systems_add_cache_option( +# [NO_FEATURE] [ADVANCED] [CMAKE_DEFINE]) # -function(OMNITRACE_ADD_CACHE_OPTION _NAME _MESSAGE _TYPE _DEFAULT) +function(ROCPROFILER_SYSTEMS_ADD_CACHE_OPTION _NAME _MESSAGE _TYPE _DEFAULT) set(_FORCE) if("FORCE" IN_LIST ARGN) set(_FORCE FORCE) @@ -423,9 +419,9 @@ function(OMNITRACE_ADD_CACHE_OPTION _NAME _MESSAGE _TYPE _DEFAULT) if("NO_FEATURE" IN_LIST ARGN) mark_as_advanced(${_NAME}) else() - omnitrace_add_feature(${_NAME} "${_MESSAGE}") + rocprofiler_systems_add_feature(${_NAME} "${_MESSAGE}") - if(OMNITRACE_BUILD_DOCS) + if(ROCPROFSYS_BUILD_DOCS) set_property(GLOBAL APPEND PROPERTY ${PROJECT_NAME}_CMAKE_OPTIONS_DOC "${_NAME}` | ${_MESSAGE} |") endif() @@ -441,9 +437,9 @@ function(OMNITRACE_ADD_CACHE_OPTION _NAME _MESSAGE _TYPE _DEFAULT) endfunction() # ----------------------------------------------------------------------------------------# -# function omnitrace_report_feature_changes() :: print changes in features +# function rocprofiler_systems_report_feature_changes() :: print changes in features # -function(OMNITRACE_REPORT_FEATURE_CHANGES) +function(ROCPROFILER_SYSTEMS_REPORT_FEATURE_CHANGES) get_property(_features GLOBAL PROPERTY ${PROJECT_NAME}_FEATURES) if(NOT "${_features}" STREQUAL "") list(REMOVE_DUPLICATES _features) @@ -451,9 +447,9 @@ function(OMNITRACE_REPORT_FEATURE_CHANGES) endif() foreach(_feature ${_features}) if("${ARGN}" STREQUAL "") - omnitrace_watch_for_change(${_feature}) + rocprofiler_systems_watch_for_change(${_feature}) elseif("${_feature}" IN_LIST ARGN) - omnitrace_watch_for_change(${_feature}) + rocprofiler_systems_watch_for_change(${_feature}) endif() endforeach() endfunction() @@ -461,7 +457,7 @@ endfunction() # ----------------------------------------------------------------------------------------# # function print_enabled_features() Print enabled features plus their docstrings. # -function(OMNITRACE_PRINT_ENABLED_FEATURES) +function(ROCPROFILER_SYSTEMS_PRINT_ENABLED_FEATURES) set(_basemsg "The following features are defined/enabled (+):") set(_currentFeatureText "${_basemsg}") get_property(_features GLOBAL PROPERTY ${PROJECT_NAME}_FEATURES) @@ -485,7 +481,7 @@ function(OMNITRACE_PRINT_ENABLED_FEATURES) string(REGEX REPLACE "^${PROJECT_NAME}_USE_" "" _feature_tmp "${_feature}") string(TOLOWER "${_feature_tmp}" _feature_tmp_l) - omnitrace_capitalize("${_feature_tmp}" _feature_tmp_c) + rocprofiler_systems_capitalize("${_feature_tmp}" _feature_tmp_c) foreach(_var _feature _feature_tmp _feature_tmp_l _feature_tmp_c) set(_ver "${${${_var}}_VERSION}") if(NOT "${_ver}" STREQUAL "") @@ -509,7 +505,7 @@ endfunction() # ----------------------------------------------------------------------------------------# # function print_disabled_features() Print disabled features plus their docstrings. # -function(OMNITRACE_PRINT_DISABLED_FEATURES) +function(ROCPROFILER_SYSTEMS_PRINT_DISABLED_FEATURES) set(_basemsg "The following features are NOT defined/enabled (-):") set(_currentFeatureText "${_basemsg}") get_property(_features GLOBAL PROPERTY ${PROJECT_NAME}_FEATURES) @@ -538,10 +534,10 @@ endfunction() # ----------------------------------------------------------------------------------------# # function print_features() Print all features plus their docstrings. # -function(OMNITRACE_PRINT_FEATURES) - omnitrace_report_feature_changes() - omnitrace_print_enabled_features() - omnitrace_print_disabled_features() +function(ROCPROFILER_SYSTEMS_PRINT_FEATURES) + rocprofiler_systems_report_feature_changes() + rocprofiler_systems_print_enabled_features() + rocprofiler_systems_print_disabled_features() endfunction() # ----------------------------------------------------------------------------------------# @@ -551,26 +547,29 @@ endfunction() # source files DIRECTORY --> all files in directory PROJECT --> all files/targets in # a project/subproject # -function(omnitrace_custom_compilation) +function(rocprofiler_systems_custom_compilation) cmake_parse_arguments(COMP "GLOBAL;PROJECT" "COMPILER" "DIRECTORY;TARGET;SOURCE" ${ARGN}) - # find omnitrace-launch-compiler + # find rocprof-sys-launch-compiler find_program( - OMNITRACE_COMPILE_LAUNCHER - NAMES omnitrace-launch-compiler + ROCPROFSYS_COMPILE_LAUNCHER + NAMES rocprof-sys-launch-compiler HINTS ${PROJECT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} PATHS ${PROJECT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} PATH_SUFFIXES scripts bin) + message(STATUS "rocprof_sys_compile_launcher: ${ROCPROFSYS_COMPILE_LAUNCHER}") + if(NOT COMP_COMPILER) - message(FATAL_ERROR "omnitrace_custom_compilation not provided COMPILER argument") + message( + FATAL_ERROR "rocprof_sys_custom_compilation not provided COMPILER argument") endif() - if(NOT OMNITRACE_COMPILE_LAUNCHER) + if(NOT ROCPROFSYS_COMPILE_LAUNCHER) message( FATAL_ERROR - "omnitrace could not find 'omnitrace-launch-compiler'. Please set '-DOMNITRACE_COMPILE_LAUNCHER=/path/to/launcher'" + "rocprofiler-systems could not find 'rocprof-sys-launch-compiler'. Please set '-DROCPROFSYS_COMPILE_LAUNCHER=/path/to/launcher'" ) endif() @@ -580,16 +579,16 @@ function(omnitrace_custom_compilation) GLOBAL PROPERTY RULE_LAUNCH_COMPILE - "${OMNITRACE_COMPILE_LAUNCHER} ${COMP_COMPILER} ${CMAKE_CXX_COMPILER}") + "${ROCPROFSYS_COMPILE_LAUNCHER} ${COMP_COMPILER} ${CMAKE_CXX_COMPILER}") set_property( GLOBAL PROPERTY RULE_LAUNCH_LINK - "${OMNITRACE_COMPILE_LAUNCHER} ${COMP_COMPILER} ${CMAKE_CXX_COMPILER}") + "${ROCPROFSYS_COMPILE_LAUNCHER} ${COMP_COMPILER} ${CMAKE_CXX_COMPILER}") else() foreach(_TYPE PROJECT DIRECTORY TARGET SOURCE) # make project/subproject scoping easy, e.g. - # omnitrace_custom_compilation(PROJECT) after project(...) + # rocprofiler_systems_custom_compilation(PROJECT) after project(...) if("${_TYPE}" STREQUAL "PROJECT" AND COMP_${_TYPE}) list(APPEND COMP_DIRECTORY ${PROJECT_SOURCE_DIR}) unset(COMP_${_TYPE}) @@ -601,13 +600,13 @@ function(omnitrace_custom_compilation) ${_TYPE} ${_VAL} PROPERTY RULE_LAUNCH_COMPILE - "${OMNITRACE_COMPILE_LAUNCHER} ${COMP_COMPILER} ${CMAKE_CXX_COMPILER}" + "${ROCPROFSYS_COMPILE_LAUNCHER} ${COMP_COMPILER} ${CMAKE_CXX_COMPILER}" ) set_property( ${_TYPE} ${_VAL} PROPERTY RULE_LAUNCH_LINK - "${OMNITRACE_COMPILE_LAUNCHER} ${COMP_COMPILER} ${CMAKE_CXX_COMPILER}" + "${ROCPROFSYS_COMPILE_LAUNCHER} ${COMP_COMPILER} ${CMAKE_CXX_COMPILER}" ) endforeach() endif() @@ -615,7 +614,7 @@ function(omnitrace_custom_compilation) endif() endfunction() -function(OMNITRACE_WATCH_FOR_CHANGE _var) +function(ROCPROFILER_SYSTEMS_WATCH_FOR_CHANGE _var) list(LENGTH ARGN _NUM_EXTRA_ARGS) if(_NUM_EXTRA_ARGS EQUAL 1) set(_VAR ${ARGN}) @@ -633,42 +632,43 @@ function(OMNITRACE_WATCH_FOR_CHANGE _var) update_var(OFF) - set(_omnitrace_watch_var_name OMNITRACE_WATCH_VALUE_${_var}) - if(DEFINED ${_omnitrace_watch_var_name}) - if("${${_var}}" STREQUAL "${${_omnitrace_watch_var_name}}") + set(_rocprofiler_systems_watch_var_name ROCPROFSYS_WATCH_VALUE_${_var}) + if(DEFINED ${_rocprofiler_systems_watch_var_name}) + if("${${_var}}" STREQUAL "${${_rocprofiler_systems_watch_var_name}}") return() else() - omnitrace_message( + rocprofiler_systems_message( STATUS - "${_var} changed :: ${${_omnitrace_watch_var_name}} --> ${${_var}}") + "${_var} changed :: ${${_rocprofiler_systems_watch_var_name}} --> ${${_var}}" + ) update_var(ON) endif() else() if(NOT "${${_var}}" STREQUAL "") - omnitrace_message(STATUS "${_var} :: ${${_var}}") + rocprofiler_systems_message(STATUS "${_var} :: ${${_var}}") update_var(ON) endif() endif() # store the value for the next run - set(${_omnitrace_watch_var_name} + set(${_rocprofiler_systems_watch_var_name} "${${_var}}" CACHE INTERNAL "Last value of ${_var}" FORCE) endfunction() -function(OMNITRACE_DIRECTORY) +function(ROCPROFILER_SYSTEMS_DIRECTORY) cmake_parse_arguments(F "MKDIR;FAIL;FORCE" "PREFIX;OUTPUT_VARIABLE;WORKING_DIRECTORY" "PATHS" ${ARGN}) if(F_PREFIX AND NOT IS_ABSOLUTE "${F_PREFIX}") if(F_WORKING_DIRECTORY) - omnitrace_message( + rocprofiler_systems_message( STATUS "PREFIX was specified as a relative path, using working directory + prefix :: '${F_WORKING_DIRECTORY}/${F_PREFIX}'..." ) set(F_PREFIX ${F_WORKING_DIRECTORY}/${F_PREFIX}) else() - omnitrace_message( + rocprofiler_systems_message( FATAL_ERROR "PREFIX was specified but it is not an absolute path: ${F_PREFIX}") endif() @@ -690,9 +690,10 @@ function(OMNITRACE_DIRECTORY) endif() if(NOT EXISTS "${_PATH}" AND F_FAIL) - omnitrace_message(FATAL_ERROR "Directory '${_PATH}' does not exist") + rocprofiler_systems_message(FATAL_ERROR "Directory '${_PATH}' does not exist") elseif(NOT IS_DIRECTORY "${_PATH}" AND F_FAIL) - omnitrace_message(FATAL_ERROR "'${_PATH}' exists but is not a directory") + rocprofiler_systems_message(FATAL_ERROR + "'${_PATH}' exists but is not a directory") elseif(NOT EXISTS "${_PATH}" AND F_MKDIR) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${_PATH} WORKING_DIRECTORY ${F_WORKING_DIRECTORY}) @@ -716,11 +717,11 @@ function(OMNITRACE_DIRECTORY) endif() endfunction() -function(OMNITRACE_CHECK_PYTHON_DIRS_AND_VERSIONS) +function(ROCPROFILER_SYSTEMS_CHECK_PYTHON_DIRS_AND_VERSIONS) cmake_parse_arguments(F "FAIL;UNSET" "RESULT_VARIABLE;OUTPUT_VARIABLE" "" ${ARGN}) - list(LENGTH OMNITRACE_PYTHON_VERSIONS _NUM_PYTHON_VERSIONS) - list(LENGTH OMNITRACE_PYTHON_ROOT_DIRS _NUM_PYTHON_ROOT_DIRS) + list(LENGTH ROCPROFSYS_PYTHON_VERSIONS _NUM_PYTHON_VERSIONS) + list(LENGTH ROCPROFSYS_PYTHON_ROOT_DIRS _NUM_PYTHON_ROOT_DIRS) if(NOT _NUM_PYTHON_VERSIONS EQUAL _NUM_PYTHON_ROOT_DIRS) set(_RET 1) @@ -741,20 +742,20 @@ function(OMNITRACE_CHECK_PYTHON_DIRS_AND_VERSIONS) if(NOT ${_RET} EQUAL 0) if(F_FAIL) - omnitrace_message( + rocprofiler_systems_message( WARNING - "Error! Number of python versions : ${_NUM_PYTHON_VERSIONS}. VERSIONS :: ${OMNITRACE_PYTHON_VERSIONS}" + "Error! Number of python versions : ${_NUM_PYTHON_VERSIONS}. VERSIONS :: ${ROCPROFSYS_PYTHON_VERSIONS}" ) - omnitrace_message( + rocprofiler_systems_message( WARNING - "Error! Number of python root directories : ${_NUM_PYTHON_ROOT_DIRS}. ROOT DIRS :: ${OMNITRACE_PYTHON_ROOT_DIRS}" + "Error! Number of python root directories : ${_NUM_PYTHON_ROOT_DIRS}. ROOT DIRS :: ${ROCPROFSYS_PYTHON_ROOT_DIRS}" ) - omnitrace_message( + rocprofiler_systems_message( FATAL_ERROR "Error! Number of python versions != number of python root directories") elseif(F_UNSET) - unset(OMNITRACE_PYTHON_VERSIONS CACHE) - unset(OMNITRACE_PYTHON_ROOT_DIRS CACHE) + unset(ROCPROFSYS_PYTHON_VERSIONS CACHE) + unset(ROCPROFSYS_PYTHON_ROOT_DIRS CACHE) if(F_OUTPUT_VARIABLE) set(${F_OUTPUT_VARIABLE} 0) endif() @@ -765,7 +766,7 @@ endfunction() # ---------------------------------------------------------------------------- # Console scripts # -function(OMNITRACE_PYTHON_CONSOLE_SCRIPT SCRIPT_NAME SCRIPT_SUBMODULE) +function(ROCPROFILER_SYSTEMS_PYTHON_CONSOLE_SCRIPT SCRIPT_NAME SCRIPT_SUBMODULE) set(options) set(args VERSION ROOT_DIR) set(kwargs) @@ -786,7 +787,7 @@ function(OMNITRACE_PYTHON_CONSOLE_SCRIPT SCRIPT_NAME SCRIPT_SUBMODULE) OPTIONAL) endif() - if(OMNITRACE_BUILD_TESTING OR OMNITRACE_BUILD_PYTHON) + if(ROCPROFSYS_BUILD_TESTING OR ROCPROFSYS_BUILD_PYTHON) add_test( NAME ${SCRIPT_NAME}-console-script-test-${ARG_VERSION} COMMAND ${PROJECT_BINARY_DIR}/bin/${SCRIPT_NAME}-${ARG_VERSION} --help @@ -819,17 +820,17 @@ function(OMNITRACE_PYTHON_CONSOLE_SCRIPT SCRIPT_NAME SCRIPT_SUBMODULE) endif() endfunction() -function(OMNITRACE_FIND_STATIC_LIBRARY) +function(ROCPROFILER_SYSTEMS_FIND_STATIC_LIBRARY) set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX}) find_library(${ARGN}) endfunction() -function(OMNITRACE_FIND_SHARED_LIBRARY) +function(ROCPROFILER_SYSTEMS_FIND_SHARED_LIBRARY) set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX}) find_library(${ARGN}) endfunction() -function(OMNITRACE_BUILDTREE_TPL _TPL_TARGET _NEW_NAME _BUILD_TREE_DIR) +function(ROCPROFILER_SYSTEMS_BUILDTREE_TPL _TPL_TARGET _NEW_NAME _BUILD_TREE_DIR) get_target_property(_TPL_VERSION ${_TPL_TARGET} VERSION) get_target_property(_TPL_SOVERSION ${_TPL_TARGET} SOVERSION) get_target_property(_TPL_NAME ${_TPL_TARGET} OUTPUT_NAME) @@ -862,7 +863,7 @@ function(OMNITRACE_BUILDTREE_TPL _TPL_TARGET _NEW_NAME _BUILD_TREE_DIR) COMMENT "Creating ${_NEW_NAME} from ${_TPL_TARGET}...") endfunction() -function(OMNITRACE_INSTALL_TPL _TPL_TARGET _NEW_NAME _BUILD_TREE_DIR _COMPONENT) +function(ROCPROFILER_SYSTEMS_INSTALL_TPL _TPL_TARGET _NEW_NAME _BUILD_TREE_DIR _COMPONENT) get_target_property(_TPL_VERSION ${_TPL_TARGET} VERSION) get_target_property(_TPL_SOVERSION ${_TPL_TARGET} SOVERSION) get_target_property(_TPL_NAME ${_TPL_TARGET} OUTPUT_NAME) @@ -876,7 +877,8 @@ function(OMNITRACE_INSTALL_TPL _TPL_TARGET _NEW_NAME _BUILD_TREE_DIR _COMPONENT) endforeach() # build tree symbolic links - omnitrace_buildtree_tpl("${_TPL_TARGET}" "${_NEW_NAME}" "${_BUILD_TREE_DIR}" ${ARGN}) + rocprofiler_systems_buildtree_tpl("${_TPL_TARGET}" "${_NEW_NAME}" + "${_BUILD_TREE_DIR}" ${ARGN}) install( FILES $ diff --git a/cmake/Modules/FindMPI-Headers.cmake b/cmake/Modules/FindMPI-Headers.cmake index e9d846a2..2417d3f1 100644 --- a/cmake/Modules/FindMPI-Headers.cmake +++ b/cmake/Modules/FindMPI-Headers.cmake @@ -10,7 +10,7 @@ set(MPI_HEADERS_VENDOR_INTERNAL "OpenMPI" CACHE STRING "Distribution type of internal mpi.h") set(MPI_HEADERS_INCLUDE_DIR_INTERNAL - "${PROJECT_SOURCE_DIR}/source/lib/omnitrace/library/tpls/mpi" + "${PROJECT_SOURCE_DIR}/source/lib/rocprof-sys/library/tpls/mpi" CACHE PATH "Path to internal ${MPI_HEADERS_VENDOR_INTERNAL} mpi.h") mark_as_advanced(MPI_HEADERS_VENDOR_INTERNAL) mark_as_advanced(MPI_HEADERS_INCLUDE_DIR_INTERNAL) diff --git a/cmake/Modules/FindRCCL-Headers.cmake b/cmake/Modules/FindRCCL-Headers.cmake index f7087683..8d0befed 100644 --- a/cmake/Modules/FindRCCL-Headers.cmake +++ b/cmake/Modules/FindRCCL-Headers.cmake @@ -6,7 +6,7 @@ include(FindPackageHandleStandardArgs) # ----------------------------------------------------------------------------------------# set(RCCL-Headers_INCLUDE_DIR_INTERNAL - "${PROJECT_SOURCE_DIR}/source/lib/omnitrace/library/tpls/rccl" + "${PROJECT_SOURCE_DIR}/source/lib/rocprof-sys/library/tpls/rccl" CACHE PATH "Path to internal rccl.h") # ----------------------------------------------------------------------------------------# @@ -60,7 +60,7 @@ else() endif() if(NOT EXISTS "${RCCL-Headers_INCLUDE_DIR}/${_RCCL-Headers_FILE}") - omnitrace_message( + rocprofiler_systems_message( AUTHOR_WARNING "RCCL header (${RCCL-Headers_INCLUDE_DIR}/${_RCCL-Headers_FILE}) does not exist! Setting RCCL-Headers_INCLUDE_DIR to internal RCCL include directory: ${RCCL-Headers_INCLUDE_DIR_INTERNAL}" ) diff --git a/cmake/Modules/FindROCmVersion.cmake b/cmake/Modules/FindROCmVersion.cmake index 18e6fcde..0d792b73 100644 --- a/cmake/Modules/FindROCmVersion.cmake +++ b/cmake/Modules/FindROCmVersion.cmake @@ -226,7 +226,7 @@ function(ROCM_VERSION_PARSE_VERSION_FILES) # convert env to cache if not defined foreach(_PATH ROCmVersion_DIR ROCmVersion_ROOT ROCmVersion_ROOT_DIR - OMNITRACE_DEFAULT_ROCM_PATH ROCM_PATH) + ROCPROFSYS_DEFAULT_ROCM_PATH ROCM_PATH) if(NOT DEFINED ${_PATH} AND DEFINED ENV{${_PATH}}) set(_VAL "$ENV{${_PATH}}") get_filename_component(_VAL "${_VAL}" REALPATH) @@ -243,7 +243,7 @@ function(ROCM_VERSION_PARSE_VERSION_FILES) foreach( _DIR ${ROCmVersion_DIR} ${ROCmVersion_ROOT} ${ROCmVersion_ROOT_DIR} - $ENV{CMAKE_PREFIX_PATH} ${CMAKE_PREFIX_PATH} ${OMNITRACE_DEFAULT_ROCM_PATH} + $ENV{CMAKE_PREFIX_PATH} ${CMAKE_PREFIX_PATH} ${ROCPROFSYS_DEFAULT_ROCM_PATH} ${ROCM_PATH} /opt/rocm) if(EXISTS ${_DIR}) get_filename_component(_ABS_DIR "${_DIR}" REALPATH) diff --git a/cmake/PAPI.cmake b/cmake/PAPI.cmake index af8a207e..5d0d0f45 100644 --- a/cmake/PAPI.cmake +++ b/cmake/PAPI.cmake @@ -1,13 +1,13 @@ # ====================================================================================== # PAPI.cmake # -# Configure papi for omnitrace +# Configure papi for rocprofiler-systems # # ====================================================================================== include_guard(GLOBAL) -omnitrace_checkout_git_submodule( +rocprofiler_systems_checkout_git_submodule( RELATIVE_PATH external/papi WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} REPO_URL https://bitbucket.org/icl/papi.git @@ -18,38 +18,39 @@ set(PAPI_LIBPFM_SOVERSION "4.11.1" CACHE STRING "libpfm.so version") -set(OMNITRACE_PAPI_SOURCE_DIR ${PROJECT_BINARY_DIR}/external/papi/source) -set(OMNITRACE_PAPI_INSTALL_DIR ${PROJECT_BINARY_DIR}/external/papi/install) +set(ROCPROFSYS_PAPI_SOURCE_DIR ${PROJECT_BINARY_DIR}/external/papi/source) +set(ROCPROFSYS_PAPI_INSTALL_DIR ${PROJECT_BINARY_DIR}/external/papi/install) -if(NOT EXISTS "${OMNITRACE_PAPI_SOURCE_DIR}") +if(NOT EXISTS "${ROCPROFSYS_PAPI_SOURCE_DIR}") execute_process( COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/external/papi - ${OMNITRACE_PAPI_SOURCE_DIR}) + ${ROCPROFSYS_PAPI_SOURCE_DIR}) endif() -if(NOT EXISTS "${OMNITRACE_PAPI_INSTALL_DIR}") +if(NOT EXISTS "${ROCPROFSYS_PAPI_INSTALL_DIR}") execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory - ${OMNITRACE_PAPI_INSTALL_DIR}) + ${ROCPROFSYS_PAPI_INSTALL_DIR}) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory - ${OMNITRACE_PAPI_INSTALL_DIR}/include) + ${ROCPROFSYS_PAPI_INSTALL_DIR}/include) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory - ${OMNITRACE_PAPI_INSTALL_DIR}/lib) + ${ROCPROFSYS_PAPI_INSTALL_DIR}/lib) execute_process( COMMAND - ${CMAKE_COMMAND} -E touch ${OMNITRACE_PAPI_INSTALL_DIR}/lib/libpapi.a - ${OMNITRACE_PAPI_INSTALL_DIR}/lib/libpfm.a - ${OMNITRACE_PAPI_INSTALL_DIR}/lib/libpfm.so) - set(_OMNITRACE_PAPI_BUILD_BYPRODUCTS - ${OMNITRACE_PAPI_INSTALL_DIR}/lib/libpapi.a - ${OMNITRACE_PAPI_INSTALL_DIR}/lib/libpfm.a - ${OMNITRACE_PAPI_INSTALL_DIR}/lib/libpfm.so) + ${CMAKE_COMMAND} -E touch ${ROCPROFSYS_PAPI_INSTALL_DIR}/lib/libpapi.a + ${ROCPROFSYS_PAPI_INSTALL_DIR}/lib/libpfm.a + ${ROCPROFSYS_PAPI_INSTALL_DIR}/lib/libpfm.so) + set(_ROCPROFSYS_PAPI_BUILD_BYPRODUCTS + ${ROCPROFSYS_PAPI_INSTALL_DIR}/lib/libpapi.a + ${ROCPROFSYS_PAPI_INSTALL_DIR}/lib/libpfm.a + ${ROCPROFSYS_PAPI_INSTALL_DIR}/lib/libpfm.so) endif() -omnitrace_add_option(OMNITRACE_PAPI_AUTO_COMPONENTS "Automatically enable components" OFF) +rocprofiler_systems_add_option(ROCPROFSYS_PAPI_AUTO_COMPONENTS + "Automatically enable components" OFF) # -------------- PACKAGES ----------------------------------------------------- -set(_OMNITRACE_VALID_PAPI_COMPONENTS +set(_ROCPROFSYS_VALID_PAPI_COMPONENTS appio bgpm coretemp @@ -86,13 +87,13 @@ set(_OMNITRACE_VALID_PAPI_COMPONENTS stealtime sysdetect vmware) -set(OMNITRACE_VALID_PAPI_COMPONENTS - "${_OMNITRACE_VALID_PAPI_COMPONENTS}" +set(ROCPROFSYS_VALID_PAPI_COMPONENTS + "${_ROCPROFSYS_VALID_PAPI_COMPONENTS}" CACHE STRING "Valid PAPI components") -mark_as_advanced(OMNITRACE_VALID_PAPI_COMPONENTS) +mark_as_advanced(ROCPROFSYS_VALID_PAPI_COMPONENTS) # default components which do not require 3rd-party headers or libraries -set(_OMNITRACE_PAPI_COMPONENTS +set(_ROCPROFSYS_PAPI_COMPONENTS appio coretemp io @@ -104,73 +105,73 @@ set(_OMNITRACE_PAPI_COMPONENTS # rapl stealtime ) -if(OMNITRACE_PAPI_AUTO_COMPONENTS) +if(ROCPROFSYS_PAPI_AUTO_COMPONENTS) # rocm - if(OMNITRACE_USE_HIP - OR OMNITRACE_USE_ROCTRACER - OR OMNITRACE_USE_ROCM_SMI) - list(APPEND _OMNITRACE_PAPI_COMPONENTS rocm) + if(ROCPROFSYS_USE_HIP + OR ROCPROFSYS_USE_ROCTRACER + OR ROCPROFSYS_USE_ROCM_SMI) + list(APPEND _ROCPROFSYS_PAPI_COMPONENTS rocm) endif() # lmsensors - find_path(OMNITRACE_PAPI_LMSENSORS_ROOT_DIR NAMES include/sensors/sensors.h - include/sensors.h) + find_path(ROCPROFSYS_PAPI_LMSENSORS_ROOT_DIR NAMES include/sensors/sensors.h + include/sensors.h) - if(OMNITRACE_PAPI_LMSENSORS_ROOT_DIR) - list(APPEND _OMNITRACE_PAPI_COMPONENTS lmsensors) + if(ROCPROFSYS_PAPI_LMSENSORS_ROOT_DIR) + list(APPEND _ROCPROFSYS_PAPI_COMPONENTS lmsensors) endif() # pcp - find_path(OMNITRACE_PAPI_PCP_ROOT_DIR NAMES include/pcp/impl.h) + find_path(ROCPROFSYS_PAPI_PCP_ROOT_DIR NAMES include/pcp/impl.h) find_library( - OMNITRACE_PAPI_PCP_LIBRARY + ROCPROFSYS_PAPI_PCP_LIBRARY NAMES pcp PATH_SUFFIXES lib lib64) - if(OMNITRACE_PAPI_PCP_ROOT_DIR AND OMNITRACE_PAPI_PCP_LIBRARY) - list(APPEND _OMNITRACE_PAPI_COMPONENTS pcp) + if(ROCPROFSYS_PAPI_PCP_ROOT_DIR AND ROCPROFSYS_PAPI_PCP_LIBRARY) + list(APPEND _ROCPROFSYS_PAPI_COMPONENTS pcp) endif() endif() -# set the OMNITRACE_PAPI_COMPONENTS cache variable -set(OMNITRACE_PAPI_COMPONENTS - "${_OMNITRACE_PAPI_COMPONENTS}" +# set the ROCPROFSYS_PAPI_COMPONENTS cache variable +set(ROCPROFSYS_PAPI_COMPONENTS + "${_ROCPROFSYS_PAPI_COMPONENTS}" CACHE STRING "PAPI components") -omnitrace_add_feature(OMNITRACE_PAPI_COMPONENTS "PAPI components") -string(REPLACE ";" "\ " _OMNITRACE_PAPI_COMPONENTS "${OMNITRACE_PAPI_COMPONENTS}") -set(OMNITRACE_PAPI_EXTRA_ENV) - -foreach(_COMP ${OMNITRACE_PAPI_COMPONENTS}) - string(REPLACE ";" ", " _OMNITRACE_VALID_PAPI_COMPONENTS_MSG - "${OMNITRACE_VALID_PAPI_COMPONENTS}") - if(NOT "${_COMP}" IN_LIST OMNITRACE_VALID_PAPI_COMPONENTS) - omnitrace_message( +rocprofiler_systems_add_feature(ROCPROFSYS_PAPI_COMPONENTS "PAPI components") +string(REPLACE ";" "\ " _ROCPROFSYS_PAPI_COMPONENTS "${ROCPROFSYS_PAPI_COMPONENTS}") +set(ROCPROFSYS_PAPI_EXTRA_ENV) + +foreach(_COMP ${ROCPROFSYS_PAPI_COMPONENTS}) + string(REPLACE ";" ", " _ROCPROFSYS_VALID_PAPI_COMPONENTS_MSG + "${ROCPROFSYS_VALID_PAPI_COMPONENTS}") + if(NOT "${_COMP}" IN_LIST ROCPROFSYS_VALID_PAPI_COMPONENTS) + rocprofiler_systems_message( AUTHOR_WARNING - "OMNITRACE_PAPI_COMPONENTS contains an unknown component '${_COMP}'. Known components: ${_OMNITRACE_VALID_PAPI_COMPONENTS_MSG}" + "ROCPROFSYS_PAPI_COMPONENTS contains an unknown component '${_COMP}'. Known components: ${_ROCPROFSYS_VALID_PAPI_COMPONENTS_MSG}" ) endif() - unset(_OMNITRACE_VALID_PAPI_COMPONENTS_MSG) + unset(_ROCPROFSYS_VALID_PAPI_COMPONENTS_MSG) endforeach() -if("rocm" IN_LIST OMNITRACE_PAPI_COMPONENTS) +if("rocm" IN_LIST ROCPROFSYS_PAPI_COMPONENTS) find_package(ROCmVersion REQUIRED) - list(APPEND OMNITRACE_PAPI_EXTRA_ENV PAPI_ROCM_ROOT=${ROCmVersion_DIR}) + list(APPEND ROCPROFSYS_PAPI_EXTRA_ENV PAPI_ROCM_ROOT=${ROCmVersion_DIR}) endif() -if("lmsensors" IN_LIST OMNITRACE_PAPI_COMPONENTS AND OMNITRACE_PAPI_LMSENSORS_ROOT_DIR) - list(APPEND OMNITRACE_PAPI_EXTRA_ENV - PAPI_LMSENSORS_ROOT=${OMNITRACE_PAPI_LMSENSORS_ROOT_DIR}) +if("lmsensors" IN_LIST ROCPROFSYS_PAPI_COMPONENTS AND ROCPROFSYS_PAPI_LMSENSORS_ROOT_DIR) + list(APPEND ROCPROFSYS_PAPI_EXTRA_ENV + PAPI_LMSENSORS_ROOT=${ROCPROFSYS_PAPI_LMSENSORS_ROOT_DIR}) endif() -if("pcp" IN_LIST OMNITRACE_PAPI_COMPONENTS AND OMNITRACE_PAPI_PCP_ROOT_DIR) - list(APPEND OMNITRACE_PAPI_EXTRA_ENV PAPI_PCP_ROOT=${OMNITRACE_PAPI_PCP_ROOT_DIR}) +if("pcp" IN_LIST ROCPROFSYS_PAPI_COMPONENTS AND ROCPROFSYS_PAPI_PCP_ROOT_DIR) + list(APPEND ROCPROFSYS_PAPI_EXTRA_ENV PAPI_PCP_ROOT=${ROCPROFSYS_PAPI_PCP_ROOT_DIR}) endif() -if("perf_event_uncore" IN_LIST OMNITRACE_PAPI_COMPONENTS AND NOT "perf_event" IN_LIST - OMNITRACE_PAPI_COMPONENTS) - omnitrace_message( +if("perf_event_uncore" IN_LIST ROCPROFSYS_PAPI_COMPONENTS AND NOT "perf_event" IN_LIST + ROCPROFSYS_PAPI_COMPONENTS) + rocprofiler_systems_message( FATAL_ERROR - "OMNITRACE_PAPI_COMPONENTS :: 'perf_event_uncore' requires 'perf_event' component" + "ROCPROFSYS_PAPI_COMPONENTS :: 'perf_event_uncore' requires 'perf_event' component" ) endif() @@ -180,7 +181,7 @@ find_program( PATH_SUFFIXES bin) if(NOT MAKE_EXECUTABLE) - omnitrace_message( + rocprofiler_systems_message( FATAL_ERROR "make/gmake executable not found. Please re-run with -DMAKE_EXECUTABLE=/path/to/make" ) @@ -188,9 +189,9 @@ endif() set(_PAPI_C_COMPILER ${CMAKE_C_COMPILER}) if(CMAKE_C_COMPILER_IS_CLANG) - find_program(OMNITRACE_GNU_C_COMPILER NAMES gcc) - if(OMNITRACE_GNU_C_COMPILER) - set(_PAPI_C_COMPILER ${OMNITRACE_GNU_C_COMPILER}) + find_program(ROCPROFSYS_GNU_C_COMPILER NAMES gcc) + if(ROCPROFSYS_GNU_C_COMPILER) + set(_PAPI_C_COMPILER ${ROCPROFSYS_GNU_C_COMPILER}) endif() endif() set(PAPI_C_COMPILER @@ -199,74 +200,77 @@ set(PAPI_C_COMPILER include(ExternalProject) externalproject_add( - omnitrace-papi-build + rocprofiler-systems-papi-build PREFIX ${PROJECT_BINARY_DIR}/external/papi - SOURCE_DIR ${OMNITRACE_PAPI_SOURCE_DIR}/src + SOURCE_DIR ${ROCPROFSYS_PAPI_SOURCE_DIR}/src BUILD_IN_SOURCE 1 PATCH_COMMAND ${CMAKE_COMMAND} -E env CC=${PAPI_C_COMPILER} CFLAGS=-fPIC\ -O3\ -Wno-stringop-truncation LIBS=-lrt LDFLAGS=-lrt - ${OMNITRACE_PAPI_EXTRA_ENV} /configure --quiet - --prefix=${OMNITRACE_PAPI_INSTALL_DIR} --with-static-lib=yes --with-shared-lib=no - --with-perf-events --with-tests=no --with-components=${_OMNITRACE_PAPI_COMPONENTS} + ${ROCPROFSYS_PAPI_EXTRA_ENV} /configure --quiet + --prefix=${ROCPROFSYS_PAPI_INSTALL_DIR} --with-static-lib=yes --with-shared-lib=no + --with-perf-events --with-tests=no + --with-components=${_ROCPROFSYS_PAPI_COMPONENTS} CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env CFLAGS=-fPIC\ -O3\ -Wno-stringop-truncation - ${OMNITRACE_PAPI_EXTRA_ENV} ${MAKE_EXECUTABLE} static install -s + ${ROCPROFSYS_PAPI_EXTRA_ENV} ${MAKE_EXECUTABLE} static install -s BUILD_COMMAND ${CMAKE_COMMAND} -E env CFLAGS=-fPIC\ -O3\ -Wno-stringop-truncation - ${OMNITRACE_PAPI_EXTRA_ENV} ${MAKE_EXECUTABLE} utils install-utils -s + ${ROCPROFSYS_PAPI_EXTRA_ENV} ${MAKE_EXECUTABLE} utils install-utils -s INSTALL_COMMAND "" - BUILD_BYPRODUCTS "${_OMNITRACE_PAPI_BUILD_BYPRODUCTS}") + BUILD_BYPRODUCTS "${_ROCPROFSYS_PAPI_BUILD_BYPRODUCTS}") # target for re-executing the installation add_custom_target( - omnitrace-papi-install + rocprofiler-systems-papi-install COMMAND ${CMAKE_COMMAND} -E env CFLAGS=-fPIC\ -O3\ -Wno-stringop-truncation - ${OMNITRACE_PAPI_EXTRA_ENV} ${MAKE_EXECUTABLE} static install -s + ${ROCPROFSYS_PAPI_EXTRA_ENV} ${MAKE_EXECUTABLE} static install -s COMMAND ${CMAKE_COMMAND} -E env CFLAGS=-fPIC\ -O3\ -Wno-stringop-truncation - ${OMNITRACE_PAPI_EXTRA_ENV} ${MAKE_EXECUTABLE} utils install-utils -s - WORKING_DIRECTORY ${OMNITRACE_PAPI_SOURCE_DIR}/src + ${ROCPROFSYS_PAPI_EXTRA_ENV} ${MAKE_EXECUTABLE} utils install-utils -s + WORKING_DIRECTORY ${ROCPROFSYS_PAPI_SOURCE_DIR}/src COMMENT "Installing PAPI...") add_custom_target( - omnitrace-papi-clean + rocprofiler-systems-papi-clean COMMAND ${MAKE_EXECUTABLE} distclean - COMMAND ${CMAKE_COMMAND} -E rm -rf ${OMNITRACE_PAPI_INSTALL_DIR}/include/* - COMMAND ${CMAKE_COMMAND} -E rm -rf ${OMNITRACE_PAPI_INSTALL_DIR}/lib/* + COMMAND ${CMAKE_COMMAND} -E rm -rf ${ROCPROFSYS_PAPI_INSTALL_DIR}/include/* + COMMAND ${CMAKE_COMMAND} -E rm -rf ${ROCPROFSYS_PAPI_INSTALL_DIR}/lib/* COMMAND - ${CMAKE_COMMAND} -E touch ${OMNITRACE_PAPI_INSTALL_DIR}/lib/libpapi.a - ${OMNITRACE_PAPI_INSTALL_DIR}/lib/libpfm.a - ${OMNITRACE_PAPI_INSTALL_DIR}/lib/libpfm.so - WORKING_DIRECTORY ${OMNITRACE_PAPI_SOURCE_DIR}/src + ${CMAKE_COMMAND} -E touch ${ROCPROFSYS_PAPI_INSTALL_DIR}/lib/libpapi.a + ${ROCPROFSYS_PAPI_INSTALL_DIR}/lib/libpfm.a + ${ROCPROFSYS_PAPI_INSTALL_DIR}/lib/libpfm.so + WORKING_DIRECTORY ${ROCPROFSYS_PAPI_SOURCE_DIR}/src COMMENT "Cleaning PAPI...") set(PAPI_ROOT_DIR - ${OMNITRACE_PAPI_INSTALL_DIR} + ${ROCPROFSYS_PAPI_INSTALL_DIR} CACHE PATH "Root PAPI installation" FORCE) set(PAPI_INCLUDE_DIR - ${OMNITRACE_PAPI_INSTALL_DIR}/include + ${ROCPROFSYS_PAPI_INSTALL_DIR}/include CACHE PATH "PAPI include folder" FORCE) set(PAPI_LIBRARY - ${OMNITRACE_PAPI_INSTALL_DIR}/lib/libpapi.a + ${ROCPROFSYS_PAPI_INSTALL_DIR}/lib/libpapi.a CACHE FILEPATH "PAPI library" FORCE) set(PAPI_pfm_LIBRARY - ${OMNITRACE_PAPI_INSTALL_DIR}/lib/libpfm.so + ${ROCPROFSYS_PAPI_INSTALL_DIR}/lib/libpfm.so CACHE FILEPATH "PAPI library" FORCE) set(PAPI_STATIC_LIBRARY - ${OMNITRACE_PAPI_INSTALL_DIR}/lib/libpapi.a + ${ROCPROFSYS_PAPI_INSTALL_DIR}/lib/libpapi.a CACHE FILEPATH "PAPI library" FORCE) set(PAPI_pfm_STATIC_LIBRARY - ${OMNITRACE_PAPI_INSTALL_DIR}/lib/libpfm.a + ${ROCPROFSYS_PAPI_INSTALL_DIR}/lib/libpfm.a CACHE FILEPATH "PAPI library" FORCE) -target_include_directories(omnitrace-papi SYSTEM +target_include_directories(rocprofiler-systems-papi SYSTEM INTERFACE $) -target_link_libraries(omnitrace-papi INTERFACE $ - $) -omnitrace_target_compile_definitions( - omnitrace-papi INTERFACE OMNITRACE_USE_PAPI $) +target_link_libraries( + rocprofiler-systems-papi INTERFACE $ + $) +rocprofiler_systems_target_compile_definitions( + rocprofiler-systems-papi INTERFACE ROCPROFSYS_USE_PAPI + $) install( - DIRECTORY ${OMNITRACE_PAPI_INSTALL_DIR}/lib/ - DESTINATION ${CMAKE_INSTALL_LIBDIR}/omnitrace + DIRECTORY ${ROCPROFSYS_PAPI_INSTALL_DIR}/lib/ + DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME} COMPONENT papi FILES_MATCHING PATTERN "*.so*") @@ -289,7 +293,7 @@ foreach( papi_version papi_xml_event_info) - string(REPLACE "_" "-" _UTIL_EXE_INSTALL_NAME "omnitrace-${_UTIL_EXE}") + string(REPLACE "_" "-" _UTIL_EXE_INSTALL_NAME "${BINARY_NAME_PREFIX}-${_UTIL_EXE}") # RPM installer on RedHat/RockyLinux throws error that #!/usr/bin/python should either # be #!/usr/bin/python2 or #!/usr/bin/python3 @@ -300,14 +304,14 @@ foreach( _HL_OUTPUT_WRITER) string(REPLACE "#!/usr/bin/python\n" "#!/usr/bin/python3\n" _HL_OUTPUT_WRITER "${_HL_OUTPUT_WRITER}") - file(MAKE_DIRECTORY "${OMNITRACE_PAPI_INSTALL_DIR}/bin") - file(WRITE "${OMNITRACE_PAPI_INSTALL_DIR}/bin/${_UTIL_EXE}3" + file(MAKE_DIRECTORY "${ROCPROFSYS_PAPI_INSTALL_DIR}/bin") + file(WRITE "${ROCPROFSYS_PAPI_INSTALL_DIR}/bin/${_UTIL_EXE}3" "${_HL_OUTPUT_WRITER}") set(_UTIL_EXE "${_UTIL_EXE}3") endif() install( - PROGRAMS ${OMNITRACE_PAPI_INSTALL_DIR}/bin/${_UTIL_EXE} + PROGRAMS ${ROCPROFSYS_PAPI_INSTALL_DIR}/bin/${_UTIL_EXE} DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME ${_UTIL_EXE_INSTALL_NAME} COMPONENT papi diff --git a/cmake/Packages.cmake b/cmake/Packages.cmake index a391408b..f3383505 100644 --- a/cmake/Packages.cmake +++ b/cmake/Packages.cmake @@ -7,73 +7,87 @@ include_guard(DIRECTORY) # # ######################################################################################## -omnitrace_add_interface_library( - omnitrace-headers "Provides minimal set of include flags to compile with omnitrace") -omnitrace_add_interface_library(omnitrace-threading "Enables multithreading support") -omnitrace_add_interface_library( - omnitrace-dyninst +rocprofiler_systems_add_interface_library( + rocprofiler-systems-headers + "Provides minimal set of include flags to compile with rocprofiler-systems") +rocprofiler_systems_add_interface_library(rocprofiler-systems-threading + "Enables multithreading support") +rocprofiler_systems_add_interface_library( + rocprofiler-systems-dyninst "Provides flags and libraries for Dyninst (dynamic instrumentation)") -omnitrace_add_interface_library(omnitrace-hip "Provides flags and libraries for HIP") -omnitrace_add_interface_library(omnitrace-roctracer - "Provides flags and libraries for roctracer") -omnitrace_add_interface_library(omnitrace-rocprofiler - "Provides flags and libraries for rocprofiler") -omnitrace_add_interface_library(omnitrace-rocm-smi - "Provides flags and libraries for rocm-smi") -omnitrace_add_interface_library( - omnitrace-rccl "Provides flags for ROCm Communication Collectives Library (RCCL)") -omnitrace_add_interface_library(omnitrace-mpi "Provides MPI or MPI headers") -omnitrace_add_interface_library(omnitrace-bfd "Provides Binary File Descriptor (BFD)") -omnitrace_add_interface_library(omnitrace-ptl "Enables PTL support (tasking)") -omnitrace_add_interface_library(omnitrace-papi "Enable PAPI support") -omnitrace_add_interface_library(omnitrace-ompt "Enable OMPT support") -omnitrace_add_interface_library(omnitrace-python "Enables Python support") -omnitrace_add_interface_library(omnitrace-elfutils "Provides ElfUtils") -omnitrace_add_interface_library(omnitrace-perfetto "Enables Perfetto support") -omnitrace_add_interface_library(omnitrace-timemory "Provides timemory libraries") -omnitrace_add_interface_library(omnitrace-timemory-config - "CMake interface library applied to all timemory targets") -omnitrace_add_interface_library(omnitrace-compile-definitions "Compile definitions") +rocprofiler_systems_add_interface_library(rocprofiler-systems-hip + "Provides flags and libraries for HIP") +rocprofiler_systems_add_interface_library(rocprofiler-systems-roctracer + "Provides flags and libraries for roctracer") +rocprofiler_systems_add_interface_library(rocprofiler-systems-rocprofiler + "Provides flags and libraries for rocprofiler") +rocprofiler_systems_add_interface_library(rocprofiler-systems-rocm-smi + "Provides flags and libraries for rocm-smi") +rocprofiler_systems_add_interface_library( + rocprofiler-systems-rccl + "Provides flags for ROCm Communication Collectives Library (RCCL)") +rocprofiler_systems_add_interface_library(rocprofiler-systems-mpi + "Provides MPI or MPI headers") +rocprofiler_systems_add_interface_library(rocprofiler-systems-bfd + "Provides Binary File Descriptor (BFD)") +rocprofiler_systems_add_interface_library(rocprofiler-systems-ptl + "Enables PTL support (tasking)") +rocprofiler_systems_add_interface_library(rocprofiler-systems-papi "Enable PAPI support") +rocprofiler_systems_add_interface_library(rocprofiler-systems-ompt "Enable OMPT support") +rocprofiler_systems_add_interface_library(rocprofiler-systems-python + "Enables Python support") +rocprofiler_systems_add_interface_library(rocprofiler-systems-elfutils + "Provides ElfUtils") +rocprofiler_systems_add_interface_library(rocprofiler-systems-perfetto + "Enables Perfetto support") +rocprofiler_systems_add_interface_library(rocprofiler-systems-timemory + "Provides timemory libraries") +rocprofiler_systems_add_interface_library( + rocprofiler-systems-timemory-config + "CMake interface library applied to all timemory targets") +rocprofiler_systems_add_interface_library(rocprofiler-systems-compile-definitions + "Compile definitions") # libraries with relevant compile definitions -set(OMNITRACE_EXTENSION_LIBRARIES - omnitrace::omnitrace-hip - omnitrace::omnitrace-roctracer - omnitrace::omnitrace-rocprofiler - omnitrace::omnitrace-rocm-smi - omnitrace::omnitrace-rccl - omnitrace::omnitrace-bfd - omnitrace::omnitrace-mpi - omnitrace::omnitrace-ptl - omnitrace::omnitrace-ompt - omnitrace::omnitrace-papi - omnitrace::omnitrace-perfetto) +set(ROCPROFSYS_EXTENSION_LIBRARIES + rocprofiler-systems::rocprofiler-systems-hip + rocprofiler-systems::rocprofiler-systems-roctracer + rocprofiler-systems::rocprofiler-systems-rocprofiler + rocprofiler-systems::rocprofiler-systems-rocm-smi + rocprofiler-systems::rocprofiler-systems-rccl + rocprofiler-systems::rocprofiler-systems-bfd + rocprofiler-systems::rocprofiler-systems-mpi + rocprofiler-systems::rocprofiler-systems-ptl + rocprofiler-systems::rocprofiler-systems-ompt + rocprofiler-systems::rocprofiler-systems-papi + rocprofiler-systems::rocprofiler-systems-perfetto) target_include_directories( - omnitrace-headers + rocprofiler-systems-headers INTERFACE $ $ $ - $ - $ - $) + $ + $ + $) # include threading because of rooflines -target_link_libraries(omnitrace-headers INTERFACE omnitrace::omnitrace-threading) +target_link_libraries(rocprofiler-systems-headers + INTERFACE rocprofiler-systems::rocprofiler-systems-threading) # ensure the env overrides the appending /opt/rocm later string(REPLACE ":" ";" CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH};${CMAKE_PREFIX_PATH}") -set(OMNITRACE_DEFAULT_ROCM_PATH +set(ROCPROFSYS_DEFAULT_ROCM_PATH /opt/rocm CACHE PATH "Default search path for ROCM") -if(EXISTS ${OMNITRACE_DEFAULT_ROCM_PATH}) - get_filename_component(_OMNITRACE_DEFAULT_ROCM_PATH "${OMNITRACE_DEFAULT_ROCM_PATH}" - REALPATH) +if(EXISTS ${ROCPROFSYS_DEFAULT_ROCM_PATH}) + get_filename_component(_ROCPROFSYS_DEFAULT_ROCM_PATH + "${ROCPROFSYS_DEFAULT_ROCM_PATH}" REALPATH) - if(NOT "${_OMNITRACE_DEFAULT_ROCM_PATH}" STREQUAL "${OMNITRACE_DEFAULT_ROCM_PATH}") - set(OMNITRACE_DEFAULT_ROCM_PATH - "${_OMNITRACE_DEFAULT_ROCM_PATH}" + if(NOT "${_ROCPROFSYS_DEFAULT_ROCM_PATH}" STREQUAL "${ROCPROFSYS_DEFAULT_ROCM_PATH}") + set(ROCPROFSYS_DEFAULT_ROCM_PATH + "${_ROCPROFSYS_DEFAULT_ROCM_PATH}" CACHE PATH "Default search path for ROCM" FORCE) endif() endif() @@ -94,11 +108,12 @@ find_library(pthread_LIBRARY NAMES pthread pthreads) find_package_handle_standard_args(pthread-library REQUIRED_VARS pthread_LIBRARY) if(pthread_LIBRARY) - target_link_libraries(omnitrace-threading INTERFACE ${pthread_LIBRARY}) + target_link_libraries(rocprofiler-systems-threading INTERFACE ${pthread_LIBRARY}) else() - find_package(Threads ${omnitrace_FIND_QUIETLY} ${omnitrace_FIND_REQUIREMENT}) + find_package(Threads ${rocprofiler_systems_FIND_QUIETLY} + ${rocprofiler_systems_FIND_REQUIREMENT}) if(Threads_FOUND) - target_link_libraries(omnitrace-threading INTERFACE Threads::Threads) + target_link_libraries(rocprofiler-systems-threading INTERFACE Threads::Threads) endif() endif() @@ -106,7 +121,7 @@ foreach(_LIB dl rt) find_library(${_LIB}_LIBRARY NAMES ${_LIB}) find_package_handle_standard_args(${_LIB}-library REQUIRED_VARS ${_LIB}_LIBRARY) if(${_LIB}_LIBRARY) - target_link_libraries(omnitrace-threading INTERFACE ${${_LIB}_LIBRARY}) + target_link_libraries(rocprofiler-systems-threading INTERFACE ${${_LIB}_LIBRARY}) endif() endforeach() @@ -116,15 +131,16 @@ endforeach() # # ----------------------------------------------------------------------------------------# -if(OMNITRACE_USE_HIP - OR OMNITRACE_USE_ROCTRACER - OR OMNITRACE_USE_ROCPROFILER - OR OMNITRACE_USE_ROCM_SMI) +if(ROCPROFSYS_USE_HIP + OR ROCPROFSYS_USE_ROCTRACER + OR ROCPROFSYS_USE_ROCPROFILER + OR ROCPROFSYS_USE_ROCM_SMI) find_package(ROCmVersion) if(NOT ROCmVersion_FOUND) - find_package(hip ${omnitrace_FIND_QUIETLY} REQUIRED HINTS - ${OMNITRACE_DEFAULT_ROCM_PATH} PATHS ${OMNITRACE_DEFAULT_ROCM_PATH}) + find_package( + hip ${rocprofiler_systems_FIND_QUIETLY} REQUIRED HINTS + ${ROCPROFSYS_DEFAULT_ROCM_PATH} PATHS ${ROCPROFSYS_DEFAULT_ROCM_PATH}) if(SPACK_BUILD) find_package(ROCmVersion HINTS ${ROCM_PATH} PATHS ${ROCM_PATH}) else() @@ -147,14 +163,14 @@ if(OMNITRACE_USE_HIP list(APPEND CMAKE_PREFIX_PATH ${ROCmVersion_DIR}) endif() - set(OMNITRACE_ROCM_VERSION ${ROCmVersion_FULL_VERSION}) - set(OMNITRACE_HIP_VERSION_MAJOR ${ROCmVersion_MAJOR_VERSION}) - set(OMNITRACE_HIP_VERSION_MINOR ${ROCmVersion_MINOR_VERSION}) - set(OMNITRACE_HIP_VERSION_PATCH ${ROCmVersion_PATCH_VERSION}) - set(OMNITRACE_HIP_VERSION ${ROCmVersion_TRIPLE_VERSION}) + set(ROCPROFSYS_ROCM_VERSION ${ROCmVersion_FULL_VERSION}) + set(ROCPROFSYS_HIP_VERSION_MAJOR ${ROCmVersion_MAJOR_VERSION}) + set(ROCPROFSYS_HIP_VERSION_MINOR ${ROCmVersion_MINOR_VERSION}) + set(ROCPROFSYS_HIP_VERSION_PATCH ${ROCmVersion_PATCH_VERSION}) + set(ROCPROFSYS_HIP_VERSION ${ROCmVersion_TRIPLE_VERSION}) - if(OMNITRACE_HIP_VERSION_MAJOR GREATER_EQUAL 4 AND OMNITRACE_HIP_VERSION_MINOR - GREATER 3) + if(ROCPROFSYS_HIP_VERSION_MAJOR GREATER_EQUAL 4 AND ROCPROFSYS_HIP_VERSION_MINOR + GREATER 3) set(roctracer_kfdwrapper_LIBRARY) endif() @@ -162,12 +178,13 @@ if(OMNITRACE_USE_HIP set(roctracer_kfdwrapper_LIBRARY) endif() - omnitrace_add_feature(OMNITRACE_ROCM_VERSION "ROCm version used by omnitrace") + rocprofiler_systems_add_feature(ROCPROFSYS_ROCM_VERSION + "ROCm version used by rocprofiler-systems") else() - set(OMNITRACE_HIP_VERSION "0.0.0") - set(OMNITRACE_HIP_VERSION_MAJOR 0) - set(OMNITRACE_HIP_VERSION_MINOR 0) - set(OMNITRACE_HIP_VERSION_PATCH 0) + set(ROCPROFSYS_HIP_VERSION "0.0.0") + set(ROCPROFSYS_HIP_VERSION_MAJOR 0) + set(ROCPROFSYS_HIP_VERSION_MINOR 0) + set(ROCPROFSYS_HIP_VERSION_PATCH 0) endif() # ----------------------------------------------------------------------------------------# @@ -176,10 +193,11 @@ endif() # # ----------------------------------------------------------------------------------------# -if(OMNITRACE_USE_HIP) - find_package(hip ${omnitrace_FIND_QUIETLY} REQUIRED) - omnitrace_target_compile_definitions(omnitrace-hip INTERFACE OMNITRACE_USE_HIP) - target_link_libraries(omnitrace-hip INTERFACE hip::host) +if(ROCPROFSYS_USE_HIP) + find_package(hip ${rocprofiler_systems_FIND_QUIETLY} REQUIRED) + rocprofiler_systems_target_compile_definitions(rocprofiler-systems-hip + INTERFACE ROCPROFSYS_USE_HIP) + target_link_libraries(rocprofiler-systems-hip INTERFACE hip::host) endif() # ----------------------------------------------------------------------------------------# @@ -188,12 +206,13 @@ endif() # # ----------------------------------------------------------------------------------------# -if(OMNITRACE_USE_ROCTRACER) - find_package(roctracer ${omnitrace_FIND_QUIETLY} REQUIRED) - omnitrace_target_compile_definitions(omnitrace-roctracer - INTERFACE OMNITRACE_USE_ROCTRACER) - target_link_libraries(omnitrace-roctracer INTERFACE roctracer::roctracer - omnitrace::omnitrace-hip) +if(ROCPROFSYS_USE_ROCTRACER) + find_package(roctracer ${rocprofiler_systems_FIND_QUIETLY} REQUIRED) + rocprofiler_systems_target_compile_definitions(rocprofiler-systems-roctracer + INTERFACE ROCPROFSYS_USE_ROCTRACER) + target_link_libraries( + rocprofiler-systems-roctracer + INTERFACE roctracer::roctracer rocprofiler-systems::rocprofiler-systems-hip) endif() # ----------------------------------------------------------------------------------------# @@ -201,11 +220,12 @@ endif() # rocprofiler # # ----------------------------------------------------------------------------------------# -if(OMNITRACE_USE_ROCPROFILER) - find_package(rocprofiler ${omnitrace_FIND_QUIETLY} REQUIRED) - omnitrace_target_compile_definitions(omnitrace-rocprofiler - INTERFACE OMNITRACE_USE_ROCPROFILER) - target_link_libraries(omnitrace-rocprofiler INTERFACE rocprofiler::rocprofiler) +if(ROCPROFSYS_USE_ROCPROFILER) + find_package(rocprofiler ${rocprofiler_systems_FIND_QUIETLY} REQUIRED) + rocprofiler_systems_target_compile_definitions(rocprofiler-systems-rocprofiler + INTERFACE ROCPROFSYS_USE_ROCPROFILER) + target_link_libraries(rocprofiler-systems-rocprofiler + INTERFACE rocprofiler::rocprofiler) endif() # ----------------------------------------------------------------------------------------# @@ -214,11 +234,11 @@ endif() # # ----------------------------------------------------------------------------------------# -if(OMNITRACE_USE_ROCM_SMI) - find_package(rocm-smi ${omnitrace_FIND_QUIETLY} REQUIRED) - omnitrace_target_compile_definitions(omnitrace-rocm-smi - INTERFACE OMNITRACE_USE_ROCM_SMI) - target_link_libraries(omnitrace-rocm-smi INTERFACE rocm-smi::rocm-smi) +if(ROCPROFSYS_USE_ROCM_SMI) + find_package(rocm-smi ${rocprofiler_systems_FIND_QUIETLY} REQUIRED) + rocprofiler_systems_target_compile_definitions(rocprofiler-systems-rocm-smi + INTERFACE ROCPROFSYS_USE_ROCM_SMI) + target_link_libraries(rocprofiler-systems-rocm-smi INTERFACE rocm-smi::rocm-smi) endif() # ----------------------------------------------------------------------------------------# @@ -227,10 +247,11 @@ endif() # # ----------------------------------------------------------------------------------------# -if(OMNITRACE_USE_RCCL) - find_package(RCCL-Headers ${omnitrace_FIND_QUIETLY} REQUIRED) - target_link_libraries(omnitrace-rccl INTERFACE roc::rccl-headers) - omnitrace_target_compile_definitions(omnitrace-rccl INTERFACE OMNITRACE_USE_RCCL) +if(ROCPROFSYS_USE_RCCL) + find_package(RCCL-Headers ${rocprofiler_systems_FIND_QUIETLY} REQUIRED) + target_link_libraries(rocprofiler-systems-rccl INTERFACE roc::rccl-headers) + rocprofiler_systems_target_compile_definitions(rocprofiler-systems-rccl + INTERFACE ROCPROFSYS_USE_RCCL) endif() # ----------------------------------------------------------------------------------------# @@ -240,18 +261,19 @@ endif() # ----------------------------------------------------------------------------------------# # suppress warning during CI that MPI_HEADERS_ALLOW_MPICH was unused -set(_OMNITRACE_MPI_HEADERS_ALLOW_MPICH ${MPI_HEADERS_ALLOW_MPICH}) - -if(OMNITRACE_USE_MPI) - find_package(MPI ${omnitrace_FIND_QUIETLY} REQUIRED) - target_link_libraries(omnitrace-mpi INTERFACE MPI::MPI_C MPI::MPI_CXX) - omnitrace_target_compile_definitions(omnitrace-mpi INTERFACE TIMEMORY_USE_MPI=1 - OMNITRACE_USE_MPI) -elseif(OMNITRACE_USE_MPI_HEADERS) - find_package(MPI-Headers ${omnitrace_FIND_QUIETLY} REQUIRED) - omnitrace_target_compile_definitions( - omnitrace-mpi INTERFACE TIMEMORY_USE_MPI_HEADERS=1 OMNITRACE_USE_MPI_HEADERS) - target_link_libraries(omnitrace-mpi INTERFACE MPI::MPI_HEADERS) +set(_ROCPROFSYS_MPI_HEADERS_ALLOW_MPICH ${MPI_HEADERS_ALLOW_MPICH}) + +if(ROCPROFSYS_USE_MPI) + find_package(MPI ${rocprofiler_systems_FIND_QUIETLY} REQUIRED) + target_link_libraries(rocprofiler-systems-mpi INTERFACE MPI::MPI_C MPI::MPI_CXX) + rocprofiler_systems_target_compile_definitions( + rocprofiler-systems-mpi INTERFACE TIMEMORY_USE_MPI=1 ROCPROFSYS_USE_MPI) +elseif(ROCPROFSYS_USE_MPI_HEADERS) + find_package(MPI-Headers ${rocprofiler_systems_FIND_QUIETLY} REQUIRED) + rocprofiler_systems_target_compile_definitions( + rocprofiler-systems-mpi INTERFACE TIMEMORY_USE_MPI_HEADERS=1 + ROCPROFSYS_USE_MPI_HEADERS) + target_link_libraries(rocprofiler-systems-mpi INTERFACE MPI::MPI_HEADERS) endif() # ----------------------------------------------------------------------------------------# @@ -260,8 +282,8 @@ endif() # # ----------------------------------------------------------------------------------------# -omnitrace_target_compile_definitions( - omnitrace-ompt INTERFACE OMNITRACE_USE_OMPT=$) +rocprofiler_systems_target_compile_definitions( + rocprofiler-systems-ompt INTERFACE ROCPROFSYS_USE_OMPT=$) # ----------------------------------------------------------------------------------------# # @@ -271,10 +293,11 @@ omnitrace_target_compile_definitions( include(ElfUtils) -target_include_directories(omnitrace-elfutils SYSTEM INTERFACE ${ElfUtils_INCLUDE_DIRS}) -target_compile_definitions(omnitrace-elfutils INTERFACE ${ElfUtils_DEFINITIONS}) -target_link_directories(omnitrace-elfutils INTERFACE ${ElfUtils_LIBRARY_DIRS}) -target_link_libraries(omnitrace-elfutils INTERFACE ${ElfUtils_LIBRARIES}) +target_include_directories(rocprofiler-systems-elfutils SYSTEM + INTERFACE ${ElfUtils_INCLUDE_DIRS}) +target_compile_definitions(rocprofiler-systems-elfutils INTERFACE ${ElfUtils_DEFINITIONS}) +target_link_directories(rocprofiler-systems-elfutils INTERFACE ${ElfUtils_LIBRARY_DIRS}) +target_link_libraries(rocprofiler-systems-elfutils INTERFACE ${ElfUtils_LIBRARIES}) # ----------------------------------------------------------------------------------------# # @@ -282,8 +305,8 @@ target_link_libraries(omnitrace-elfutils INTERFACE ${ElfUtils_LIBRARIES}) # # ----------------------------------------------------------------------------------------# -if(OMNITRACE_BUILD_DYNINST) - omnitrace_checkout_git_submodule( +if(ROCPROFSYS_BUILD_DYNINST) + rocprofiler_systems_checkout_git_submodule( RELATIVE_PATH external/dyninst WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} REPO_URL https://github.com/jrmadsen/dyninst.git @@ -316,21 +339,22 @@ if(OMNITRACE_BUILD_DYNINST) set(CMAKE_BUILD_RPATH "") endif() - omnitrace_save_variables( + rocprofiler_systems_save_variables( PIC VARIABLES CMAKE_POSITION_INDEPENDENT_CODE CMAKE_INSTALL_RPATH CMAKE_BUILD_RPATH CMAKE_INSTALL_RPATH_USE_LINK_PATH) set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH OFF) - set(CMAKE_BUILD_RPATH "\$ORIGIN:\$ORIGIN/omnitrace") - set(CMAKE_INSTALL_RPATH "\$ORIGIN:\$ORIGIN/omnitrace") + + set(CMAKE_BUILD_RPATH "\$ORIGIN:\$ORIGIN/${PROJECT_NAME}") + set(CMAKE_INSTALL_RPATH "\$ORIGIN:\$ORIGIN/${PROJECT_NAME}") set(DYNINST_TPL_INSTALL_PREFIX - "omnitrace" + "${PROJECT_NAME}" CACHE PATH "Third-party library install-tree install prefix" FORCE) set(DYNINST_TPL_INSTALL_LIB_DIR - "omnitrace" + "${PROJECT_NAME}" CACHE PATH "Third-party library install-tree install library prefix" FORCE) add_subdirectory(external/dyninst EXCLUDE_FROM_ALL) - omnitrace_restore_variables( + rocprofiler_systems_restore_variables( PIC VARIABLES CMAKE_POSITION_INDEPENDENT_CODE CMAKE_INSTALL_RPATH CMAKE_BUILD_RPATH CMAKE_INSTALL_RPATH_USE_LINK_PATH) @@ -354,35 +378,37 @@ if(OMNITRACE_BUILD_DYNINST) if(TARGET ${_LIB}) install( TARGETS ${_LIB} - DESTINATION ${CMAKE_INSTALL_LIBDIR}/omnitrace + DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME} COMPONENT dyninst - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/omnitrace/dyninst) + PUBLIC_HEADER + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/dyninst) endif() endforeach() # for packaging install( DIRECTORY ${DYNINST_TPL_STAGING_PREFIX}/lib/ - DESTINATION ${CMAKE_INSTALL_LIBDIR}/omnitrace + DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME} COMPONENT dyninst FILES_MATCHING PATTERN "*${CMAKE_SHARED_LIBRARY_SUFFIX}*") - target_link_libraries(omnitrace-dyninst INTERFACE Dyninst::Dyninst) + target_link_libraries(rocprofiler-systems-dyninst INTERFACE Dyninst::Dyninst) else() - find_package(Dyninst ${omnitrace_FIND_QUIETLY} REQUIRED + find_package(Dyninst ${rocprofiler_systems_FIND_QUIETLY} REQUIRED COMPONENTS dyninstAPI parseAPI instructionAPI symtabAPI) if(TARGET Dyninst::Dyninst) # updated Dyninst CMake system was found - target_link_libraries(omnitrace-dyninst INTERFACE Dyninst::Dyninst) + target_link_libraries(rocprofiler-systems-dyninst INTERFACE Dyninst::Dyninst) else() # updated Dyninst CMake system was not found set(_BOOST_COMPONENTS atomic system thread date_time) - set(omnitrace_BOOST_COMPONENTS + set(rocprofiler_systems_BOOST_COMPONENTS "${_BOOST_COMPONENTS}" - CACHE STRING "Boost components used by Dyninst in omnitrace") + CACHE STRING "Boost components used by Dyninst in rocprofiler-systems") set(Boost_NO_BOOST_CMAKE ON) - find_package(Boost QUIET REQUIRED COMPONENTS ${omnitrace_BOOST_COMPONENTS}) + find_package(Boost QUIET REQUIRED + COMPONENTS ${rocprofiler_systems_BOOST_COMPONENTS}) # some installs of dyninst don't set this properly if(EXISTS "${DYNINST_INCLUDE_DIR}" AND NOT DYNINST_HEADER_DIR) @@ -413,8 +439,8 @@ else() PATH_SUFFIXES include) endif() - target_link_libraries(omnitrace-dyninst INTERFACE ${DYNINST_LIBRARIES} - ${Boost_LIBRARIES}) + target_link_libraries(rocprofiler-systems-dyninst INTERFACE ${DYNINST_LIBRARIES} + ${Boost_LIBRARIES}) foreach( _TARG dyninst @@ -429,18 +455,20 @@ else() date_time TBB) if(TARGET Dyninst::${_TARG}) - target_link_libraries(omnitrace-dyninst INTERFACE Dyninst::${_TARG}) + target_link_libraries(rocprofiler-systems-dyninst + INTERFACE Dyninst::${_TARG}) elseif(TARGET Boost::${_TARG}) - target_link_libraries(omnitrace-dyninst INTERFACE Boost::${_TARG}) + target_link_libraries(rocprofiler-systems-dyninst + INTERFACE Boost::${_TARG}) elseif(TARGET ${_TARG}) - target_link_libraries(omnitrace-dyninst INTERFACE ${_TARG}) + target_link_libraries(rocprofiler-systems-dyninst INTERFACE ${_TARG}) endif() endforeach() target_include_directories( - omnitrace-dyninst SYSTEM INTERFACE ${TBB_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} - ${DYNINST_HEADER_DIR}) - omnitrace_target_compile_definitions(omnitrace-dyninst - INTERFACE OMNITRACE_USE_DYNINST) + rocprofiler-systems-dyninst SYSTEM + INTERFACE ${TBB_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${DYNINST_HEADER_DIR}) + rocprofiler_systems_target_compile_definitions(rocprofiler-systems-dyninst + INTERFACE ROCPROFSYS_USE_DYNINST) endif() endif() @@ -450,25 +478,25 @@ endif() # # ----------------------------------------------------------------------------------------# -if(OMNITRACE_BUILD_STATIC_LIBGCC) +if(ROCPROFSYS_BUILD_STATIC_LIBGCC) if(CMAKE_C_COMPILER_ID MATCHES "GNU") - omnitrace_save_variables(STATIC_LIBGCC_C VARIABLES CMAKE_C_FLAGS) + rocprofiler_systems_save_variables(STATIC_LIBGCC_C VARIABLES CMAKE_C_FLAGS) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc") endif() if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") - omnitrace_save_variables(STATIC_LIBGCC_CXX VARIABLES CMAKE_CXX_FLAGS) + rocprofiler_systems_save_variables(STATIC_LIBGCC_CXX VARIABLES CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc") else() - set(OMNITRACE_BUILD_STATIC_LIBGCC OFF) + set(ROCPROFSYS_BUILD_STATIC_LIBGCC OFF) endif() endif() -if(OMNITRACE_BUILD_STATIC_LIBSTDCXX) +if(ROCPROFSYS_BUILD_STATIC_LIBSTDCXX) if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") - omnitrace_save_variables(STATIC_LIBSTDCXX_CXX VARIABLES CMAKE_CXX_FLAGS) + rocprofiler_systems_save_variables(STATIC_LIBSTDCXX_CXX VARIABLES CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++") else() - set(OMNITRACE_BUILD_STATIC_LIBSTDCXX OFF) + set(ROCPROFSYS_BUILD_STATIC_LIBSTDCXX OFF) endif() endif() @@ -479,7 +507,7 @@ endif() # ----------------------------------------------------------------------------------------# set(perfetto_DIR ${PROJECT_SOURCE_DIR}/external/perfetto) -omnitrace_checkout_git_submodule( +rocprofiler_systems_checkout_git_submodule( RELATIVE_PATH external/perfetto WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} REPO_URL https://github.com/google/perfetto.git @@ -494,8 +522,8 @@ include(Perfetto) # # ----------------------------------------------------------------------------------------# -if(OMNITRACE_BUILD_DEVICETRACE) - omnitrace_checkout_git_submodule( +if(ROCPROFSYS_BUILD_DEVICETRACE) + rocprofiler_systems_checkout_git_submodule( RELATIVE_PATH external/elfio WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} REPO_URL https://github.com/jrmadsen/ELFIO.git @@ -510,7 +538,7 @@ endif() # # ----------------------------------------------------------------------------------------# -if(OMNITRACE_USE_PAPI AND OMNITRACE_BUILD_PAPI) +if(ROCPROFSYS_USE_PAPI AND ROCPROFSYS_BUILD_PAPI) include(PAPI) endif() @@ -521,22 +549,23 @@ endif() # ----------------------------------------------------------------------------------------# target_compile_definitions( - omnitrace-timemory-config + rocprofiler-systems-timemory-config INTERFACE TIMEMORY_PAPI_ARRAY_SIZE=12 TIMEMORY_USE_ROOFLINE=0 TIMEMORY_USE_ERT=0 TIMEMORY_USE_CONTAINERS=0 TIMEMORY_USE_ERT_EXTERN=0 TIMEMORY_USE_CONTAINERS_EXTERN=0) -if(OMNITRACE_BUILD_STACK_PROTECTOR) - add_target_flag_if_avail(omnitrace-timemory-config "-fstack-protector-strong" - "-Wstack-protector") +if(ROCPROFSYS_BUILD_STACK_PROTECTOR) + add_target_flag_if_avail(rocprofiler-systems-timemory-config + "-fstack-protector-strong" "-Wstack-protector") endif() -if(OMNITRACE_BUILD_DEBUG) - add_target_flag_if_avail(omnitrace-timemory-config "-fno-omit-frame-pointer" "-g3") +if(ROCPROFSYS_BUILD_DEBUG) + add_target_flag_if_avail(rocprofiler-systems-timemory-config + "-fno-omit-frame-pointer" "-g3") endif() set(TIMEMORY_EXTERNAL_INTERFACE_LIBRARY - omnitrace-timemory-config + rocprofiler-systems-timemory-config CACHE STRING "timemory configuration interface library") set(TIMEMORY_INSTALL_HEADERS OFF @@ -571,7 +600,7 @@ set(TIMEMORY_QUIET_CONFIG # timemory feature settings set(TIMEMORY_USE_MPI - ${OMNITRACE_USE_MPI} + ${ROCPROFSYS_USE_MPI} CACHE BOOL "Enable MPI support in timemory" FORCE) set(TIMEMORY_USE_GOTCHA ON @@ -580,13 +609,13 @@ set(TIMEMORY_USE_PERFETTO OFF CACHE BOOL "Disable perfetto support in timemory") set(TIMEMORY_USE_OMPT - ${OMNITRACE_USE_OMPT} + ${ROCPROFSYS_USE_OMPT} CACHE BOOL "Enable OMPT support in timemory" FORCE) set(TIMEMORY_USE_PAPI - ${OMNITRACE_USE_PAPI} + ${ROCPROFSYS_USE_PAPI} CACHE BOOL "Enable PAPI support in timemory" FORCE) set(TIMEMORY_USE_BFD - ${OMNITRACE_USE_BFD} + ${ROCPROFSYS_USE_BFD} CACHE BOOL "Enable BFD support in timemory" FORCE) set(TIMEMORY_USE_LIBUNWIND ON @@ -595,14 +624,14 @@ set(TIMEMORY_USE_VISIBILITY OFF CACHE BOOL "Enable/disable using visibility decorations") set(TIMEMORY_USE_SANITIZER - ${OMNITRACE_USE_SANITIZER} - CACHE BOOL "Build with -fsanitze=\${OMNITRACE_SANITIZER_TYPE}" FORCE) + ${ROCPROFSYS_USE_SANITIZER} + CACHE BOOL "Build with -fsanitze=\${ROCPROFSYS_SANITIZER_TYPE}" FORCE) set(TIMEMORY_SANITIZER_TYPE - ${OMNITRACE_SANITIZER_TYPE} + ${ROCPROFSYS_SANITIZER_TYPE} CACHE STRING "Sanitizer type, e.g. leak, thread, address, memory, etc." FORCE) if(DEFINED TIMEMORY_BUILD_GOTCHA AND NOT TIMEMORY_BUILD_GOTCHA) - omnitrace_message( + rocprofiler_systems_message( FATAL_ERROR "Using an external gotcha is not allowed due to known bug that has not been accepted upstream" ) @@ -613,10 +642,10 @@ set(TIMEMORY_BUILD_GOTCHA ON CACHE BOOL "Enable building GOTCHA library from submodule" FORCE) set(TIMEMORY_BUILD_LIBUNWIND - ${OMNITRACE_BUILD_LIBUNWIND} + ${ROCPROFSYS_BUILD_LIBUNWIND} CACHE BOOL "Enable building libunwind library from submodule" FORCE) set(TIMEMORY_BUILD_EXTRA_OPTIMIZATIONS - ${OMNITRACE_BUILD_EXTRA_OPTIMIZATIONS} + ${ROCPROFSYS_BUILD_EXTRA_OPTIMIZATIONS} CACHE BOOL "Enable building GOTCHA library from submodule" FORCE) set(TIMEMORY_BUILD_ERT OFF @@ -630,13 +659,13 @@ set(TIMEMORY_TLS_MODEL "global-dynamic" CACHE STRING "Thread-local static model" FORCE) set(TIMEMORY_MAX_THREADS - "${OMNITRACE_MAX_THREADS}" + "${ROCPROFSYS_MAX_THREADS}" CACHE STRING "Max statically-allocated threads" FORCE) set(TIMEMORY_SETTINGS_PREFIX - "OMNITRACE_" + "ROCPROFSYS_" CACHE STRING "Prefix used for settings and environment variables") set(TIMEMORY_PROJECT_NAME - "omnitrace" + "rocprofiler-systems" CACHE STRING "Name for configuration") set(TIMEMORY_CXX_LIBRARY_EXCLUDE "kokkosp.cpp;pthread.cpp;timemory_c.cpp;trace.cpp;weak.cpp;library.cpp" @@ -645,13 +674,13 @@ set(TIMEMORY_CXX_LIBRARY_EXCLUDE mark_as_advanced(TIMEMORY_SETTINGS_PREFIX) mark_as_advanced(TIMEMORY_PROJECT_NAME) -omnitrace_checkout_git_submodule( +rocprofiler_systems_checkout_git_submodule( RELATIVE_PATH external/timemory WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} REPO_URL https://github.com/NERSC/timemory.git REPO_BRANCH omnitrace) -omnitrace_save_variables( +rocprofiler_systems_save_variables( BUILD_CONFIG VARIABLES BUILD_SHARED_LIBS BUILD_STATIC_LIBS CMAKE_POSITION_INDEPENDENT_CODE CMAKE_PREFIX_PATH) @@ -673,45 +702,47 @@ add_subdirectory(external/timemory EXCLUDE_FROM_ALL) install( TARGETS gotcha - DESTINATION ${CMAKE_INSTALL_LIBDIR}/omnitrace + DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME} COMPONENT gotcha) -if(OMNITRACE_BUILD_LIBUNWIND) +if(ROCPROFSYS_BUILD_LIBUNWIND) install( DIRECTORY ${PROJECT_BINARY_DIR}/external/timemory/external/libunwind/install/lib/ - DESTINATION ${CMAKE_INSTALL_LIBDIR}/omnitrace + DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME} COMPONENT libunwind FILES_MATCHING PATTERN "*${CMAKE_SHARED_LIBRARY_SUFFIX}*") endif() -omnitrace_restore_variables( +rocprofiler_systems_restore_variables( BUILD_CONFIG VARIABLES BUILD_SHARED_LIBS BUILD_STATIC_LIBS CMAKE_POSITION_INDEPENDENT_CODE CMAKE_PREFIX_PATH) -if(TARGET omnitrace-papi-build) +if(TARGET rocprofiler-systems-papi-build) foreach(_TARGET PAPI::papi timemory-core timemory-common timemory-papi-component timemory-cxx) if(TARGET "${_TARGET}") - add_dependencies(${_TARGET} omnitrace-papi-build) + add_dependencies(${_TARGET} rocprofiler-systems-papi-build) endif() foreach(_LINK shared static) if(TARGET "${_TARGET}-${_LINK}") - add_dependencies(${_TARGET}-${_LINK} omnitrace-papi-build) + add_dependencies(${_TARGET}-${_LINK} rocprofiler-systems-papi-build) endif() endforeach() endforeach() endif() target_link_libraries( - omnitrace-timemory + rocprofiler-systems-timemory INTERFACE $ $ $) -target_link_libraries(omnitrace-bfd INTERFACE $) +target_link_libraries(rocprofiler-systems-bfd + INTERFACE $) -if(OMNITRACE_USE_BFD) - omnitrace_target_compile_definitions(omnitrace-bfd INTERFACE OMNITRACE_USE_BFD) +if(ROCPROFSYS_USE_BFD) + rocprofiler_systems_target_compile_definitions(rocprofiler-systems-bfd + INTERFACE ROCPROFSYS_USE_BFD) endif() # ----------------------------------------------------------------------------------------# @@ -722,7 +753,7 @@ endif() # timemory might provide PTL::ptl-shared if(NOT TARGET PTL::ptl-shared) - omnitrace_checkout_git_submodule( + rocprofiler_systems_checkout_git_submodule( RELATIVE_PATH external/PTL WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} REPO_URL https://github.com/jrmadsen/PTL.git @@ -736,7 +767,7 @@ if(NOT TARGET PTL::ptl-shared) if(NOT DEFINED BUILD_OBJECT_LIBS) set(BUILD_OBJECT_LIBS OFF) endif() - omnitrace_save_variables( + rocprofiler_systems_save_variables( BUILD_CONFIG VARIABLES BUILD_SHARED_LIBS BUILD_STATIC_LIBS BUILD_OBJECT_LIBS CMAKE_POSITION_INDEPENDENT_CODE CMAKE_CXX_VISIBILITY_PRESET @@ -751,18 +782,19 @@ if(NOT TARGET PTL::ptl-shared) add_subdirectory(external/PTL EXCLUDE_FROM_ALL) - omnitrace_restore_variables( + rocprofiler_systems_restore_variables( BUILD_CONFIG VARIABLES BUILD_SHARED_LIBS BUILD_STATIC_LIBS BUILD_OBJECT_LIBS CMAKE_POSITION_INDEPENDENT_CODE CMAKE_CXX_VISIBILITY_PRESET CMAKE_VISIBILITY_INLINES_HIDDEN) endif() -target_sources(omnitrace-ptl +target_sources(rocprofiler-systems-ptl INTERFACE $>) target_include_directories( - omnitrace-ptl INTERFACE $ - $) + rocprofiler-systems-ptl + INTERFACE $ + $) # ----------------------------------------------------------------------------------------# # @@ -773,23 +805,24 @@ target_include_directories( # override compiler macros include(Compilers) -if(OMNITRACE_BUILD_STATIC_LIBSTDCXX) +if(ROCPROFSYS_BUILD_STATIC_LIBSTDCXX) if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") - omnitrace_restore_variables(STATIC_LIBSTDCXX_CXX VARIABLES CMAKE_CXX_FLAGS) + rocprofiler_systems_restore_variables(STATIC_LIBSTDCXX_CXX + VARIABLES CMAKE_CXX_FLAGS) endif() endif() -if(OMNITRACE_BUILD_STATIC_LIBGCC) +if(ROCPROFSYS_BUILD_STATIC_LIBGCC) if(CMAKE_C_COMPILER_ID MATCHES "GNU") - omnitrace_restore_variables(STATIC_LIBGCC_C VARIABLES CMAKE_C_FLAGS) + rocprofiler_systems_restore_variables(STATIC_LIBGCC_C VARIABLES CMAKE_C_FLAGS) endif() if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") - omnitrace_restore_variables(STATIC_LIBGCC_CXX VARIABLES CMAKE_CXX_FLAGS) + rocprofiler_systems_restore_variables(STATIC_LIBGCC_CXX VARIABLES CMAKE_CXX_FLAGS) endif() endif() -omnitrace_add_feature(CMAKE_C_FLAGS "C compiler flags") -omnitrace_add_feature(CMAKE_CXX_FLAGS "C++ compiler flags") +rocprofiler_systems_add_feature(CMAKE_C_FLAGS "C compiler flags") +rocprofiler_systems_add_feature(CMAKE_CXX_FLAGS "C++ compiler flags") # ----------------------------------------------------------------------------------------# # @@ -797,64 +830,64 @@ omnitrace_add_feature(CMAKE_CXX_FLAGS "C++ compiler flags") # # ----------------------------------------------------------------------------------------# -if(OMNITRACE_USE_PYTHON) - if(OMNITRACE_USE_PYTHON AND NOT OMNITRACE_BUILD_PYTHON) +if(ROCPROFSYS_USE_PYTHON) + if(ROCPROFSYS_USE_PYTHON AND NOT ROCPROFSYS_BUILD_PYTHON) find_package(pybind11 REQUIRED) endif() include(ConfigPython) include(PyBind11Tools) - omnitrace_watch_for_change(OMNITRACE_PYTHON_ROOT_DIRS _PYTHON_DIRS_CHANGED) + rocprofiler_systems_watch_for_change(ROCPROFSYS_PYTHON_ROOT_DIRS _PYTHON_DIRS_CHANGED) if(_PYTHON_DIRS_CHANGED) - unset(OMNITRACE_PYTHON_VERSION CACHE) - unset(OMNITRACE_PYTHON_VERSIONS CACHE) - unset(OMNITRACE_INSTALL_PYTHONDIR CACHE) + unset(ROCPROFSYS_PYTHON_VERSION CACHE) + unset(ROCPROFSYS_PYTHON_VERSIONS CACHE) + unset(ROCPROFSYS_INSTALL_PYTHONDIR CACHE) else() foreach(_VAR PREFIX ENVS) - omnitrace_watch_for_change(OMNITRACE_PYTHON_${_VAR} _CHANGED) + rocprofiler_systems_watch_for_change(ROCPROFSYS_PYTHON_${_VAR} _CHANGED) if(_CHANGED) - unset(OMNITRACE_PYTHON_ROOT_DIRS CACHE) - unset(OMNITRACE_PYTHON_VERSIONS CACHE) - unset(OMNITRACE_INSTALL_PYTHONDIR CACHE) + unset(ROCPROFSYS_PYTHON_ROOT_DIRS CACHE) + unset(ROCPROFSYS_PYTHON_VERSIONS CACHE) + unset(ROCPROFSYS_INSTALL_PYTHONDIR CACHE) break() endif() endforeach() endif() - if(OMNITRACE_PYTHON_PREFIX AND OMNITRACE_PYTHON_ENVS) - omnitrace_directory( + if(ROCPROFSYS_PYTHON_PREFIX AND ROCPROFSYS_PYTHON_ENVS) + rocprofiler_systems_directory( FAIL - PREFIX ${OMNITRACE_PYTHON_PREFIX} - PATHS ${OMNITRACE_PYTHON_ENVS} + PREFIX ${ROCPROFSYS_PYTHON_PREFIX} + PATHS ${ROCPROFSYS_PYTHON_ENVS} OUTPUT_VARIABLE _PYTHON_ROOT_DIRS) - set(OMNITRACE_PYTHON_ROOT_DIRS + set(ROCPROFSYS_PYTHON_ROOT_DIRS "${_PYTHON_ROOT_DIRS}" CACHE INTERNAL "Root directories for python") endif() - if(NOT OMNITRACE_PYTHON_VERSIONS AND OMNITRACE_PYTHON_VERSION) - set(OMNITRACE_PYTHON_VERSIONS "${OMNITRACE_PYTHON_VERSION}") + if(NOT ROCPROFSYS_PYTHON_VERSIONS AND ROCPROFSYS_PYTHON_VERSION) + set(ROCPROFSYS_PYTHON_VERSIONS "${ROCPROFSYS_PYTHON_VERSION}") - if(NOT OMNITRACE_PYTHON_ROOT_DIRS) - omnitrace_find_python(_PY VERSION ${OMNITRACE_PYTHON_VERSION}) - set(OMNITRACE_PYTHON_ROOT_DIRS + if(NOT ROCPROFSYS_PYTHON_ROOT_DIRS) + rocprofiler_systems_find_python(_PY VERSION ${ROCPROFSYS_PYTHON_VERSION}) + set(ROCPROFSYS_PYTHON_ROOT_DIRS "${_PY_ROOT_DIR}" CACHE INTERNAL "" FORCE) endif() - unset(OMNITRACE_PYTHON_VERSION CACHE) - unset(OMNITRACE_INSTALL_PYTHONDIR CACHE) + unset(ROCPROFSYS_PYTHON_VERSION CACHE) + unset(ROCPROFSYS_INSTALL_PYTHONDIR CACHE) elseif( - NOT OMNITRACE_PYTHON_VERSIONS - AND NOT OMNITRACE_PYTHON_VERSION - AND OMNITRACE_PYTHON_ROOT_DIRS) + NOT ROCPROFSYS_PYTHON_VERSIONS + AND NOT ROCPROFSYS_PYTHON_VERSION + AND ROCPROFSYS_PYTHON_ROOT_DIRS) set(_PY_VERSIONS) - foreach(_DIR ${OMNITRACE_PYTHON_ROOT_DIRS}) - omnitrace_find_python(_PY ROOT_DIR ${_DIR}) + foreach(_DIR ${ROCPROFSYS_PYTHON_ROOT_DIRS}) + rocprofiler_systems_find_python(_PY ROOT_DIR ${_DIR}) if(NOT _PY_FOUND) continue() @@ -865,46 +898,46 @@ if(OMNITRACE_USE_PYTHON) endif() endforeach() - set(OMNITRACE_PYTHON_VERSIONS + set(ROCPROFSYS_PYTHON_VERSIONS "${_PY_VERSIONS}" CACHE INTERNAL "" FORCE) elseif( - NOT OMNITRACE_PYTHON_VERSIONS - AND NOT OMNITRACE_PYTHON_VERSION - AND NOT OMNITRACE_PYTHON_ROOT_DIRS) - omnitrace_find_python(_PY REQUIRED) - set(OMNITRACE_PYTHON_ROOT_DIRS + NOT ROCPROFSYS_PYTHON_VERSIONS + AND NOT ROCPROFSYS_PYTHON_VERSION + AND NOT ROCPROFSYS_PYTHON_ROOT_DIRS) + rocprofiler_systems_find_python(_PY REQUIRED) + set(ROCPROFSYS_PYTHON_ROOT_DIRS "${_PY_ROOT_DIR}" CACHE INTERNAL "" FORCE) - set(OMNITRACE_PYTHON_VERSIONS + set(ROCPROFSYS_PYTHON_VERSIONS "${_PY_VERSION}" CACHE INTERNAL "" FORCE) endif() - omnitrace_watch_for_change(OMNITRACE_PYTHON_ROOT_DIRS) - omnitrace_watch_for_change(OMNITRACE_PYTHON_VERSIONS) + rocprofiler_systems_watch_for_change(ROCPROFSYS_PYTHON_ROOT_DIRS) + rocprofiler_systems_watch_for_change(ROCPROFSYS_PYTHON_VERSIONS) - omnitrace_check_python_dirs_and_versions(FAIL) + rocprofiler_systems_check_python_dirs_and_versions(FAIL) - list(LENGTH OMNITRACE_PYTHON_VERSIONS _NUM_PYTHON_VERSIONS) + list(LENGTH ROCPROFSYS_PYTHON_VERSIONS _NUM_PYTHON_VERSIONS) if(_NUM_PYTHON_VERSIONS GREATER 1) - set(OMNITRACE_INSTALL_PYTHONDIR + set(ROCPROFSYS_INSTALL_PYTHONDIR "${CMAKE_INSTALL_LIBDIR}/python/site-packages" CACHE STRING "Installation prefix for python") else() - set(OMNITRACE_INSTALL_PYTHONDIR - "${CMAKE_INSTALL_LIBDIR}/python${OMNITRACE_PYTHON_VERSIONS}/site-packages" + set(ROCPROFSYS_INSTALL_PYTHONDIR + "${CMAKE_INSTALL_LIBDIR}/python${ROCPROFSYS_PYTHON_VERSIONS}/site-packages" CACHE STRING "Installation prefix for python") endif() else() - set(OMNITRACE_INSTALL_PYTHONDIR + set(ROCPROFSYS_INSTALL_PYTHONDIR "${CMAKE_INSTALL_LIBDIR}/python/site-packages" CACHE STRING "Installation prefix for python") endif() -omnitrace_watch_for_change(OMNITRACE_INSTALL_PYTHONDIR) -set(CMAKE_INSTALL_PYTHONDIR ${OMNITRACE_INSTALL_PYTHONDIR}) +rocprofiler_systems_watch_for_change(ROCPROFSYS_INSTALL_PYTHONDIR) +set(CMAKE_INSTALL_PYTHONDIR ${ROCPROFSYS_INSTALL_PYTHONDIR}) # ----------------------------------------------------------------------------------------# # @@ -912,19 +945,19 @@ set(CMAKE_INSTALL_PYTHONDIR ${OMNITRACE_INSTALL_PYTHONDIR}) # # ----------------------------------------------------------------------------------------# -if("${CMAKE_BUILD_TYPE}" MATCHES "Release" AND NOT OMNITRACE_BUILD_DEBUG) - add_target_flag_if_avail(omnitrace-compile-options "-g1") +if("${CMAKE_BUILD_TYPE}" MATCHES "Release" AND NOT ROCPROFSYS_BUILD_DEBUG) + add_target_flag_if_avail(rocprofiler-systems-compile-options "-g1") endif() -target_compile_definitions(omnitrace-compile-definitions - INTERFACE OMNITRACE_MAX_THREADS=${OMNITRACE_MAX_THREADS}) +target_compile_definitions(rocprofiler-systems-compile-definitions + INTERFACE ROCPROFSYS_MAX_THREADS=${ROCPROFSYS_MAX_THREADS}) -foreach(_LIB ${OMNITRACE_EXTENSION_LIBRARIES}) +foreach(_LIB ${ROCPROFSYS_EXTENSION_LIBRARIES}) get_target_property(_COMPILE_DEFS ${_LIB} INTERFACE_COMPILE_DEFINITIONS) if(_COMPILE_DEFS) foreach(_DEF ${_COMPILE_DEFS}) - if("${_DEF}" MATCHES "OMNITRACE_") - target_compile_definitions(omnitrace-compile-definitions + if("${_DEF}" MATCHES "ROCPROFSYS_") + target_compile_definitions(rocprofiler-systems-compile-definitions INTERFACE ${_DEF}) endif() endforeach() diff --git a/cmake/Perfetto.cmake b/cmake/Perfetto.cmake index aa1f11f2..c2eb3c97 100644 --- a/cmake/Perfetto.cmake +++ b/cmake/Perfetto.cmake @@ -1,7 +1,7 @@ # ====================================================================================== # Perfetto.cmake # -# Configure perfetto for omnitrace +# Configure perfetto for rocprofiler-systems # # ====================================================================================== @@ -17,17 +17,17 @@ include(ProcessorCount) # ---------------------------------------------------------------------------------------# find_program( - OMNITRACE_COPY_EXECUTABLE + ROCPROFSYS_COPY_EXECUTABLE NAMES cp PATH_SUFFIXES bin) find_program( - OMNITRACE_NINJA_EXECUTABLE + ROCPROFSYS_NINJA_EXECUTABLE NAMES ninja PATH_SUFFIXES bin) -mark_as_advanced(OMNITRACE_COPY_EXECUTABLE) -mark_as_advanced(OMNITRACE_NINJA_EXECUTABLE) +mark_as_advanced(ROCPROFSYS_COPY_EXECUTABLE) +mark_as_advanced(ROCPROFSYS_NINJA_EXECUTABLE) # ---------------------------------------------------------------------------------------# # @@ -43,44 +43,44 @@ elseif(_NUM_THREADS LESS 1) set(_NUM_THREADS 1) endif() -set(OMNITRACE_PERFETTO_SOURCE_DIR ${PROJECT_BINARY_DIR}/external/perfetto/source) -set(OMNITRACE_PERFETTO_TOOLS_DIR ${PROJECT_BINARY_DIR}/external/perfetto/source/tools) -set(OMNITRACE_PERFETTO_BINARY_DIR +set(ROCPROFSYS_PERFETTO_SOURCE_DIR ${PROJECT_BINARY_DIR}/external/perfetto/source) +set(ROCPROFSYS_PERFETTO_TOOLS_DIR ${PROJECT_BINARY_DIR}/external/perfetto/source/tools) +set(ROCPROFSYS_PERFETTO_BINARY_DIR ${PROJECT_BINARY_DIR}/external/perfetto/source/out/linux) -set(OMNITRACE_PERFETTO_INSTALL_DIR +set(ROCPROFSYS_PERFETTO_INSTALL_DIR ${PROJECT_BINARY_DIR}/external/perfetto/source/out/linux/stripped) -set(OMNITRACE_PERFETTO_LINK_FLAGS +set(ROCPROFSYS_PERFETTO_LINK_FLAGS "-static-libgcc" CACHE STRING "Link flags for perfetto") -set(OMNITRACE_PERFETTO_BUILD_THREADS +set(ROCPROFSYS_PERFETTO_BUILD_THREADS ${_NUM_THREADS} CACHE STRING "Number of threads to use when building perfetto tools") if(CMAKE_CXX_COMPILER_IS_CLANG) set(PERFETTO_IS_CLANG true) - set(OMNITRACE_PERFETTO_C_FLAGS + set(ROCPROFSYS_PERFETTO_C_FLAGS "" CACHE STRING "Perfetto C flags") - set(OMNITRACE_PERFETTO_CXX_FLAGS + set(ROCPROFSYS_PERFETTO_CXX_FLAGS "" CACHE STRING "Perfetto C++ flags") else() set(PERFETTO_IS_CLANG false) - set(OMNITRACE_PERFETTO_C_FLAGS + set(ROCPROFSYS_PERFETTO_C_FLAGS "-static-libgcc -Wno-maybe-uninitialized -Wno-stringop-overflow" CACHE STRING "Perfetto C flags") - set(OMNITRACE_PERFETTO_CXX_FLAGS + set(ROCPROFSYS_PERFETTO_CXX_FLAGS "-static-libgcc -Wno-maybe-uninitialized -Wno-stringop-overflow -Wno-mismatched-new-delete" CACHE STRING "Perfetto C++ flags") endif() -mark_as_advanced(OMNITRACE_PERFETTO_C_FLAGS) -mark_as_advanced(OMNITRACE_PERFETTO_CXX_FLAGS) -mark_as_advanced(OMNITRACE_PERFETTO_LINK_FLAGS) +mark_as_advanced(ROCPROFSYS_PERFETTO_C_FLAGS) +mark_as_advanced(ROCPROFSYS_PERFETTO_CXX_FLAGS) +mark_as_advanced(ROCPROFSYS_PERFETTO_LINK_FLAGS) -if(NOT OMNITRACE_NINJA_EXECUTABLE) - set(OMNITRACE_NINJA_EXECUTABLE - ${OMNITRACE_PERFETTO_TOOLS_DIR}/ninja +if(NOT ROCPROFSYS_NINJA_EXECUTABLE) + set(ROCPROFSYS_NINJA_EXECUTABLE + ${ROCPROFSYS_PERFETTO_TOOLS_DIR}/ninja CACHE FILEPATH "Ninja" FORCE) endif() @@ -90,13 +90,13 @@ endif() # # ---------------------------------------------------------------------------------------# -if(NOT EXISTS "${OMNITRACE_PERFETTO_SOURCE_DIR}") +if(NOT EXISTS "${ROCPROFSYS_PERFETTO_SOURCE_DIR}") execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/external/perfetto) # cmake -E copy_directory fails for some reason execute_process( - COMMAND ${OMNITRACE_COPY_EXECUTABLE} -r ${PROJECT_SOURCE_DIR}/external/perfetto/ - ${OMNITRACE_PERFETTO_SOURCE_DIR}) + COMMAND ${ROCPROFSYS_COPY_EXECUTABLE} -r ${PROJECT_SOURCE_DIR}/external/perfetto/ + ${ROCPROFSYS_PERFETTO_SOURCE_DIR}) endif() file(READ ${PROJECT_SOURCE_DIR}/external/perfetto/sdk/perfetto.h _PERFETTO_HEADER) @@ -107,21 +107,21 @@ string( " ::perfetto::internal::ValidateEventNameType" _PERFETTO_HEADER "${_PERFETTO_HEADER}") -if(OMNITRACE_USE_SANITIZER AND OMNITRACE_SANITIZER_TYPE MATCHES "address") +if(ROCPROFSYS_USE_SANITIZER AND ROCPROFSYS_SANITIZER_TYPE MATCHES "address") string(REPLACE "__asan_poison_memory_region((a), (s))" "" _PERFETTO_HEADER "${_PERFETTO_HEADER}") string(REPLACE "__asan_unpoison_memory_region((a), (s))" "" _PERFETTO_HEADER "${_PERFETTO_HEADER}") endif() -file(WRITE ${OMNITRACE_PERFETTO_SOURCE_DIR}/sdk/perfetto.h.tmp "${_PERFETTO_HEADER}") +file(WRITE ${ROCPROFSYS_PERFETTO_SOURCE_DIR}/sdk/perfetto.h.tmp "${_PERFETTO_HEADER}") -configure_file(${OMNITRACE_PERFETTO_SOURCE_DIR}/sdk/perfetto.h.tmp - ${OMNITRACE_PERFETTO_SOURCE_DIR}/sdk/perfetto.h COPYONLY) +configure_file(${ROCPROFSYS_PERFETTO_SOURCE_DIR}/sdk/perfetto.h.tmp + ${ROCPROFSYS_PERFETTO_SOURCE_DIR}/sdk/perfetto.h COPYONLY) configure_file(${PROJECT_SOURCE_DIR}/external/perfetto/sdk/perfetto.cc - ${OMNITRACE_PERFETTO_SOURCE_DIR}/sdk/perfetto.cc COPYONLY) + ${ROCPROFSYS_PERFETTO_SOURCE_DIR}/sdk/perfetto.cc COPYONLY) configure_file(${PROJECT_SOURCE_DIR}/cmake/Templates/args.gn.in - ${OMNITRACE_PERFETTO_BINARY_DIR}/args.gn @ONLY) + ${ROCPROFSYS_PERFETTO_BINARY_DIR}/args.gn @ONLY) # ---------------------------------------------------------------------------------------# # @@ -129,55 +129,56 @@ configure_file(${PROJECT_SOURCE_DIR}/cmake/Templates/args.gn.in # # ---------------------------------------------------------------------------------------# -if(OMNITRACE_INSTALL_PERFETTO_TOOLS) +if(ROCPROFSYS_INSTALL_PERFETTO_TOOLS) find_program( - OMNITRACE_CURL_EXECUTABLE + ROCPROFSYS_CURL_EXECUTABLE NAMES curl PATH_SUFFIXES bin) - if(NOT OMNITRACE_CURL_EXECUTABLE) - omnitrace_message( + if(NOT ROCPROFSYS_CURL_EXECUTABLE) + rocprofiler_systems_message( SEND_ERROR "curl executable cannot be found. install-build-deps script for perfetto will fail" ) endif() externalproject_add( - omnitrace-perfetto-build + rocprofiler-systems-perfetto-build PREFIX ${PROJECT_BINARY_DIR}/external/perfetto - SOURCE_DIR ${OMNITRACE_PERFETTO_SOURCE_DIR} + SOURCE_DIR ${ROCPROFSYS_PERFETTO_SOURCE_DIR} BUILD_IN_SOURCE 1 - PATCH_COMMAND ${OMNITRACE_PERFETTO_TOOLS_DIR}/install-build-deps - CONFIGURE_COMMAND ${OMNITRACE_PERFETTO_TOOLS_DIR}/gn gen - ${OMNITRACE_PERFETTO_BINARY_DIR} - BUILD_COMMAND ${OMNITRACE_NINJA_EXECUTABLE} -C ${OMNITRACE_PERFETTO_BINARY_DIR} -j - ${OMNITRACE_PERFETTO_BUILD_THREADS} + PATCH_COMMAND ${ROCPROFSYS_PERFETTO_TOOLS_DIR}/install-build-deps + CONFIGURE_COMMAND ${ROCPROFSYS_PERFETTO_TOOLS_DIR}/gn gen + ${ROCPROFSYS_PERFETTO_BINARY_DIR} + BUILD_COMMAND ${ROCPROFSYS_NINJA_EXECUTABLE} -C ${ROCPROFSYS_PERFETTO_BINARY_DIR} + -j ${ROCPROFSYS_PERFETTO_BUILD_THREADS} INSTALL_COMMAND "" - BUILD_BYPRODUCTS ${OMNITRACE_PERFETTO_BINARY_DIR}/args.gn) + BUILD_BYPRODUCTS ${ROCPROFSYS_PERFETTO_BINARY_DIR}/args.gn) add_custom_target( - omnitrace-perfetto-clean - COMMAND ${OMNITRACE_NINJA_EXECUTABLE} -t clean - COMMAND ${CMAKE_COMMAND} -E rm -rf - ${PROJECT_BINARY_DIR}/external/perfetto/src/omnitrace-perfetto-build-stamp - WORKING_DIRECTORY ${OMNITRACE_PERFETTO_BINARY_DIR} + rocprofiler-systems-perfetto-clean + COMMAND ${ROCPROFSYS_NINJA_EXECUTABLE} -t clean + COMMAND + ${CMAKE_COMMAND} -E rm -rf + ${PROJECT_BINARY_DIR}/external/perfetto/src/rocprof-sys-perfetto-build-stamp + WORKING_DIRECTORY ${ROCPROFSYS_PERFETTO_BINARY_DIR} COMMENT "Cleaning Perfetto...") install( - DIRECTORY ${OMNITRACE_PERFETTO_INSTALL_DIR}/ - DESTINATION ${CMAKE_INSTALL_LIBDIR}/omnitrace + DIRECTORY ${ROCPROFSYS_PERFETTO_INSTALL_DIR}/ + DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME} COMPONENT perfetto FILES_MATCHING PATTERN "*libperfetto.so*") foreach(_FILE perfetto traced tracebox traced_probes traced_perf trigger_perfetto) if("${_FILE}" STREQUAL "perfetto") - string(REPLACE "_" "-" _INSTALL_FILE "omnitrace-${_FILE}") + string(REPLACE "_" "-" _INSTALL_FILE "rocprof-sys-${_FILE}") else() - string(REPLACE "_" "-" _INSTALL_FILE "omnitrace-perfetto-${_FILE}") + string(REPLACE "_" "-" _INSTALL_FILE "rocprof-sys-perfetto-${_FILE}") endif() install( - PROGRAMS ${OMNITRACE_PERFETTO_INSTALL_DIR}/${_FILE} + PROGRAMS ${ROCPROFSYS_PERFETTO_INSTALL_DIR}/${_FILE} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT perfetto RENAME ${_INSTALL_FILE} @@ -191,31 +192,34 @@ endif() # # ---------------------------------------------------------------------------------------# -add_library(omnitrace-perfetto-library STATIC) -add_library(omnitrace::omnitrace-perfetto-library ALIAS omnitrace-perfetto-library) +add_library(rocprofiler-systems-perfetto-library STATIC) +add_library(rocprofiler-systems::rocprofiler-systems-perfetto-library ALIAS + rocprofiler-systems-perfetto-library) target_sources( - omnitrace-perfetto-library PRIVATE ${OMNITRACE_PERFETTO_SOURCE_DIR}/sdk/perfetto.cc - ${OMNITRACE_PERFETTO_SOURCE_DIR}/sdk/perfetto.h) + rocprofiler-systems-perfetto-library + PRIVATE ${ROCPROFSYS_PERFETTO_SOURCE_DIR}/sdk/perfetto.cc + ${ROCPROFSYS_PERFETTO_SOURCE_DIR}/sdk/perfetto.h) target_link_libraries( - omnitrace-perfetto-library - PRIVATE omnitrace::omnitrace-threading omnitrace::omnitrace-static-libgcc - omnitrace::omnitrace-static-libstdcxx) + rocprofiler-systems-perfetto-library + PRIVATE rocprofiler-systems::rocprofiler-systems-threading + rocprofiler-systems::rocprofiler-systems-static-libgcc + rocprofiler-systems::rocprofiler-systems-static-libstdcxx) set_target_properties( - omnitrace-perfetto-library + rocprofiler-systems-perfetto-library PROPERTIES OUTPUT_NAME perfetto - ARCHIVE_OUTPUT_DIRECTORY ${OMNITRACE_PERFETTO_BINARY_DIR} + ARCHIVE_OUTPUT_DIRECTORY ${ROCPROFSYS_PERFETTO_BINARY_DIR} POSITION_INDEPENDENT_CODE ON CXX_VISIBILITY_PRESET "internal") -set(perfetto_DIR ${OMNITRACE_PERFETTO_SOURCE_DIR}) +set(perfetto_DIR ${ROCPROFSYS_PERFETTO_SOURCE_DIR}) set(PERFETTO_ROOT_DIR - ${OMNITRACE_PERFETTO_SOURCE_DIR} + ${ROCPROFSYS_PERFETTO_SOURCE_DIR} CACHE PATH "Root Perfetto installation" FORCE) set(PERFETTO_INCLUDE_DIR - ${OMNITRACE_PERFETTO_SOURCE_DIR}/sdk + ${ROCPROFSYS_PERFETTO_SOURCE_DIR}/sdk CACHE PATH "Perfetto include folder" FORCE) set(PERFETTO_LIBRARY - ${OMNITRACE_PERFETTO_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}perfetto${CMAKE_STATIC_LIBRARY_SUFFIX} + ${ROCPROFSYS_PERFETTO_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}perfetto${CMAKE_STATIC_LIBRARY_SUFFIX} CACHE FILEPATH "Perfetto library" FORCE) mark_as_advanced(PERFETTO_ROOT_DIR) @@ -228,9 +232,11 @@ mark_as_advanced(PERFETTO_LIBRARY) # # ---------------------------------------------------------------------------------------# -omnitrace_target_compile_definitions(omnitrace-perfetto INTERFACE OMNITRACE_USE_PERFETTO) -target_include_directories(omnitrace-perfetto SYSTEM +rocprofiler_systems_target_compile_definitions(rocprofiler-systems-perfetto + INTERFACE ROCPROFSYS_USE_PERFETTO) +target_include_directories(rocprofiler-systems-perfetto SYSTEM INTERFACE $) target_link_libraries( - omnitrace-perfetto INTERFACE $ - $) + rocprofiler-systems-perfetto + INTERFACE $ + $) diff --git a/cmake/Templates/args.gn.in b/cmake/Templates/args.gn.in index 860a10a8..21c844b6 100644 --- a/cmake/Templates/args.gn.in +++ b/cmake/Templates/args.gn.in @@ -23,6 +23,6 @@ enable_perfetto_trace_processor_percentile = false enable_perfetto_trace_processor_sqlite = true enable_perfetto_ui = false -extra_cflags = "@OMNITRACE_PERFETTO_C_FLAGS@" -extra_cxxflags = "@OMNITRACE_PERFETTO_CXX_FLAGS@" -extra_ldflags = "@OMNITRACE_PERFETTO_LINK_FLAGS@ -Wl,-rpath=\\\$ORIGIN:\\\$ORIGIN/../lib:\\\$ORIGIN/../lib/omnitrace" +extra_cflags = "@ROCPROFSYS_PERFETTO_C_FLAGS@" +extra_cxxflags = "@ROCPROFSYS_PERFETTO_CXX_FLAGS@" +extra_ldflags = "@ROCPROFSYS_PERFETTO_LINK_FLAGS@ -Wl,-rpath=\\\$ORIGIN:\\\$ORIGIN/../lib:\\\$ORIGIN/../lib/rocprof-sys" diff --git a/cmake/Templates/console-script.in b/cmake/Templates/console-script.in index 146da14f..039de3e4 100755 --- a/cmake/Templates/console-script.in +++ b/cmake/Templates/console-script.in @@ -10,7 +10,7 @@ set -e run-script() { - echo -e "\n##### omnitrace :: executing '${@}'... #####\n" + echo -e "\n##### ${PROJECT_NAME} :: executing '${@}'... #####\n" eval $@ } diff --git a/cmake/Templates/modulefile.in b/cmake/Templates/modulefile.in index 5f138333..9e8b7c75 100644 --- a/cmake/Templates/modulefile.in +++ b/cmake/Templates/modulefile.in @@ -8,13 +8,13 @@ puts stderr "Loads @PROJECT_NAME@ v@PROJECT_VERSION@" set ROOT [file normalize [file dirname [file normalize ${ModulesCurrentModulefile}]]/../../..] -setenv @PROJECT_NAME@_ROOT "${ROOT}" +setenv @PROJECT_NAME_UNDERSCORED@_ROOT "${ROOT}" prepend-path CMAKE_PREFIX_PATH "${ROOT}" prepend-path PATH "${ROOT}/bin" prepend-path LD_LIBRARY_PATH "${ROOT}/@CMAKE_INSTALL_LIBDIR@" prepend-path PYTHONPATH "${ROOT}/@CMAKE_INSTALL_PYTHONDIR@" -setenv @PROJECT_NAME@_DIR "${ROOT}/@CMAKE_INSTALL_DATAROOTDIR@/cmake/@PROJECT_NAME@" +setenv @PROJECT_NAME_UNDERSCORED@_DIR "${ROOT}/@CMAKE_INSTALL_DATAROOTDIR@/cmake/@PROJECT_NAME@" -# @OMNITRACE_HSA_ENV@setenv HSA_TOOLS_LIB "${ROOT}/@CMAKE_INSTALL_LIBDIR@/@CMAKE_SHARED_LIBRARY_PREFIX@omnitrace@CMAKE_SHARED_LIBRARY_SUFFIX@" -# @OMNITRACE_HSA_ENV@setenv HSA_TOOLS_REPORT_LOAD_FAILURE 1 -# @OMNITRACE_ROCP_ENV@setenv ROCP_TOOL_LIB "${ROOT}/@CMAKE_INSTALL_LIBDIR@/@CMAKE_SHARED_LIBRARY_PREFIX@omnitrace@CMAKE_SHARED_LIBRARY_SUFFIX@" +# @ROCPROFSYS_HSA_ENV@setenv HSA_TOOLS_LIB "${ROOT}/@CMAKE_INSTALL_LIBDIR@/@CMAKE_SHARED_LIBRARY_PREFIX@rocprof-sys@CMAKE_SHARED_LIBRARY_SUFFIX@" +# @ROCPROFSYS_HSA_ENV@setenv HSA_TOOLS_REPORT_LOAD_FAILURE 1 +# @ROCPROFSYS_ROCP_ENV@setenv ROCP_TOOL_LIB "${ROOT}/@CMAKE_INSTALL_LIBDIR@/@CMAKE_SHARED_LIBRARY_PREFIX@rocprof-sys@CMAKE_SHARED_LIBRARY_SUFFIX@" diff --git a/cmake/Templates/omnitrace-config.cmake.in b/cmake/Templates/rocprof-sys-config.cmake.in similarity index 100% rename from cmake/Templates/omnitrace-config.cmake.in rename to cmake/Templates/rocprof-sys-config.cmake.in diff --git a/cmake/Templates/omnitrace-install.py.in b/cmake/Templates/rocprof-sys-install.py.in similarity index 89% rename from cmake/Templates/omnitrace-install.py.in rename to cmake/Templates/rocprof-sys-install.py.in index bcf94ffa..fad5473b 100755 --- a/cmake/Templates/omnitrace-install.py.in +++ b/cmake/Templates/rocprof-sys-install.py.in @@ -10,7 +10,7 @@ import subprocess as sp from urllib import request from urllib.error import HTTPError -omnitrace_version = "@OMNITRACE_VERSION@" +rocprofsys_version = "@ROCPROFSYS_VERSION@" _rocm_path = os.environ.get("ROCM_PATH", "/opt/rocm") _rocm_version = None @@ -155,11 +155,11 @@ if __name__ == "__main__": parser.add_argument( "--version", - help="Print omnitrace version which will be installed", + help="Print ROCm Systems Profiler version which will be installed", action="store_true", ) parser.add_argument( - "-p", "--prefix", help="Installation prefix", type=str, default="/opt/omnitrace" + "-p", "--prefix", help="Installation prefix", type=str, default="/opt/rocprof-sys" ) parser.add_argument( "-i", @@ -193,7 +193,7 @@ if __name__ == "__main__": ) parser.add_argument( "--rocm", - help="Install omnitrace with ROCm support. Accepts either a ROCm version (e.g. '5.4') or the root path to the ROCm install containing .info/version* file(s) (e.g. /opt/rocm if /opt/rocm/.info/version exists). If no argument is provided, the ROCm version will attempted to be deduced from $ENV{ROCM_PATH}/.info/version", + help="Install ROCm Systems Profiler with ROCm support. Accepts either a ROCm version (e.g. '6.2') or the root path to the ROCm install containing .info/version* file(s) (e.g. /opt/rocm if /opt/rocm/.info/version exists). If no argument is provided, the ROCm version will attempted to be deduced from $ENV{ROCM_PATH}/.info/version", nargs="?", default=None, const=True, @@ -204,7 +204,7 @@ if __name__ == "__main__": parser.add_argument( "-e", "--extensions", - help="Omnitrace extensions, e.g. PAPI, OMPT, and Python3", + help="ROCm Systems Profiler extensions, e.g. PAPI, OMPT, and Python3", nargs="*", default=("papi", "ompt", "python3"), choices=("papi", "ompt", "python3"), @@ -213,7 +213,7 @@ if __name__ == "__main__": args = parser.parse_args() if args.version: - print(f"omnitrace {omnitrace_version}") + print(f"ROCm Systems Profiler {rocprofsys_version}") sys.exit(0) os_distrib, os_version = get_os_info(args.os_distrib, args.os_version) @@ -231,10 +231,10 @@ if __name__ == "__main__": f"Error! ROCm version could not be determined from {_rocm_path}/.info/version*. Please provide a ROCm version or the root path to the ROCm install containing the .info directory, e.g. '--rocm 5.4' or '--rocm /path/to/rocm/install'" ) - script = f"omnitrace-{omnitrace_version}-{os_distrib}-{os_version}{rocm_version}{extensions}.sh" - url = f"https://github.com/ROCm/omnitrace/releases/download/v{omnitrace_version}/{script}" + script = f"rocprofiler-systems-{rocprofsys_version}-{os_distrib}-{os_version}{rocm_version}{extensions}.sh" + url = f"https://github.com/ROCm/rocprofiler-systems/releases/download/v{rocprofsys_version}/{script}" download_dir = ( - tempfile.mkdtemp(prefix="omnitrace-install-") + tempfile.mkdtemp(prefix="rocprof-sys-install-") if args.download_path is None else args.download_path ) @@ -275,12 +275,12 @@ if __name__ == "__main__": ["--exclude-subdir", "--skip-license"] if not args.interactive else [] ) - print_log(f"Installing omnitrace to {args.prefix} ...") + print_log(f"Installing ROCm Systems Profiler to {args.prefix} ...") run([install_script, f"--prefix={args.prefix}"] + install_args) print_log( - f"omnitrace v{omnitrace_version} installation to {args.prefix} succeeded!" + f"ROCm Systems Profiler v{rocprofsys_version} installation to {args.prefix} succeeded!" ) finally: diff --git a/cmake/Templates/setup-env.sh.in b/cmake/Templates/setup-env.sh.in index ced7faca..b6c4a97d 100644 --- a/cmake/Templates/setup-env.sh.in +++ b/cmake/Templates/setup-env.sh.in @@ -13,25 +13,25 @@ if [ ! -d "${BASEDIR}" ]; then return 1 fi -@PROJECT_NAME@_ROOT=${BASEDIR} +@PROJECT_NAME_UNDERSCORED@_ROOT=${BASEDIR} PATH=${BASEDIR}/bin:${PATH} LD_LIBRARY_PATH=${BASEDIR}/@CMAKE_INSTALL_LIBDIR@:${LD_LIBRARY_PATH} PYTHONPATH=${BASEDIR}/@CMAKE_INSTALL_PYTHONDIR@:${PYTHONPATH} CMAKE_PREFIX_PATH=${BASEDIR}:${CMAKE_PREFIX_PATH} -@PROJECT_NAME@_DIR=${BASEDIR}/@CMAKE_INSTALL_DATAROOTDIR@/cmake/@PROJECT_NAME@ +@PROJECT_NAME_UNDERSCORED@_DIR=${BASEDIR}/@CMAKE_INSTALL_DATAROOTDIR@/cmake/@PROJECT_NAME@ -export @PROJECT_NAME@_ROOT +export @PROJECT_NAME_UNDERSCORED@_ROOT export PATH export LD_LIBRARY_PATH export PYTHONPATH export CMAKE_PREFIX_PATH -export @PROJECT_NAME@_DIR +export @PROJECT_NAME_UNDERSCORED@_DIR # ROCm environment variables -# @OMNITRACE_HSA_ENV@HSA_TOOLS_LIB="${BASEDIR}/@CMAKE_INSTALL_LIBDIR@/@CMAKE_SHARED_LIBRARY_PREFIX@omnitrace-dl@CMAKE_SHARED_LIBRARY_SUFFIX@" -# @OMNITRACE_HSA_ENV@HSA_TOOLS_REPORT_LOAD_FAILURE=1 -# @OMNITRACE_ROCP_ENV@ROCP_TOOL_LIB="${BASEDIR}/@CMAKE_INSTALL_LIBDIR@/@CMAKE_SHARED_LIBRARY_PREFIX@omnitrace@CMAKE_SHARED_LIBRARY_SUFFIX@" +# @ROCPROFSYS_HSA_ENV@HSA_TOOLS_LIB="${BASEDIR}/@CMAKE_INSTALL_LIBDIR@/@CMAKE_SHARED_LIBRARY_PREFIX@rocprof-sys-dl@CMAKE_SHARED_LIBRARY_SUFFIX@" +# @ROCPROFSYS_HSA_ENV@HSA_TOOLS_REPORT_LOAD_FAILURE=1 +# @ROCPROFSYS_ROCP_ENV@ROCP_TOOL_LIB="${BASEDIR}/@CMAKE_INSTALL_LIBDIR@/@CMAKE_SHARED_LIBRARY_PREFIX@rocprof-sys@CMAKE_SHARED_LIBRARY_SUFFIX@" -# @OMNITRACE_HSA_ENV@export HSA_TOOLS_LIB -# @OMNITRACE_HSA_ENV@export HSA_TOOLS_REPORT_LOAD_FAILURE -# @OMNITRACE_ROCP_ENV@export ROCP_TOOL_LIB +# @ROCPROFSYS_HSA_ENV@export HSA_TOOLS_LIB +# @ROCPROFSYS_HSA_ENV@export HSA_TOOLS_REPORT_LOAD_FAILURE +# @ROCPROFSYS_ROCP_ENV@export ROCP_TOOL_LIB diff --git a/docs/doxygen/Doxyfile b/docs/doxygen/Doxyfile index d02eb3d9..19ede70a 100644 --- a/docs/doxygen/Doxyfile +++ b/docs/doxygen/Doxyfile @@ -138,10 +138,10 @@ EXCLUDE_PATTERNS = */.git/* \ ../../examples/* \ ../../tests/* EXCLUDE_SYMBOLS = "std::*" \ - "OMNITRACE_ATTRIBUTE" \ - "OMNITRACE_VISIBILITY" \ - "OMNITRACE_PUBLIC_API" \ - "OMNITRACE_HIDDEN_API" \ + "ROCPROFSYS_ATTRIBUTE" \ + "ROCPROFSYS_VISIBILITY" \ + "ROCPROFSYS_PUBLIC_API" \ + "ROCPROFSYS_HIDDEN_API" \ "SpaceHandle" \ "KokkosPDevice*" EXAMPLE_PATH = ../../examples @@ -314,10 +314,10 @@ SEARCH_INCLUDES = YES INCLUDE_PATH = ../../source/lib/omnitrace-user INCLUDE_FILE_PATTERNS = *.h \ *.hpp -PREDEFINED = OMNITRACE_PUBLIC_API= \ - OMNITRACE_HIDDEN_API= \ - "OMNITRACE_ATTRIBUTE(...)=" \ - "OMNITRACE_VISIBILITY(...)=" \ +PREDEFINED = ROCPROFSYS_PUBLIC_API= \ + ROCPROFSYS_HIDDEN_API= \ + "ROCPROFSYS_ATTRIBUTE(...)=" \ + "ROCPROFSYS_VISIBILITY(...)=" \ "__attribute__(x)=" \ "__declspec(x)=" \ "size_t=unsigned long" \ diff --git a/docs/sphinx/requirements.in b/docs/sphinx/requirements.in index b1eb2134..aa0042a5 100644 --- a/docs/sphinx/requirements.in +++ b/docs/sphinx/requirements.in @@ -1 +1 @@ -rocm-docs-core[api_reference]==1.4.1 +rocm-docs-core[api_reference]==1.8.2 diff --git a/docs/sphinx/requirements.txt b/docs/sphinx/requirements.txt index 5ba5428e..cd2e0a3d 100644 --- a/docs/sphinx/requirements.txt +++ b/docs/sphinx/requirements.txt @@ -6,9 +6,9 @@ # accessible-pygments==0.0.5 # via pydata-sphinx-theme -alabaster==0.7.16 +alabaster==1.0.0 # via sphinx -babel==2.15.0 +babel==2.16.0 # via # pydata-sphinx-theme # sphinx @@ -16,9 +16,9 @@ beautifulsoup4==4.12.3 # via pydata-sphinx-theme breathe==4.35.0 # via rocm-docs-core -certifi==2024.7.4 +certifi==2024.8.30 # via requests -cffi==1.16.0 +cffi==1.17.1 # via # cryptography # pynacl @@ -41,7 +41,7 @@ docutils==0.21.2 # myst-parser # pydata-sphinx-theme # sphinx -doxysphinx==3.3.9 +doxysphinx==3.3.10 # via rocm-docs-core fastjsonschema==2.20.0 # via rocm-docs-core @@ -49,7 +49,7 @@ gitdb==4.0.11 # via gitpython gitpython==3.1.43 # via rocm-docs-core -idna==3.7 +idna==3.10 # via requests imagesize==1.4.1 # via sphinx @@ -67,13 +67,13 @@ markdown-it-py==3.0.0 # myst-parser markupsafe==2.1.5 # via jinja2 -mdit-py-plugins==0.4.1 +mdit-py-plugins==0.4.2 # via myst-parser mdurl==0.1.2 # via markdown-it-py mpire==2.10.2 # via doxysphinx -myst-parser==3.0.1 +myst-parser==4.0.0 # via rocm-docs-core numpy==1.26.4 # via doxysphinx @@ -87,7 +87,7 @@ pydata-sphinx-theme==0.15.4 # via # rocm-docs-core # sphinx-book-theme -pygithub==2.3.0 +pygithub==2.4.0 # via rocm-docs-core pygments==2.18.0 # via @@ -97,13 +97,13 @@ pygments==2.18.0 # sphinx pyjson5==1.6.6 # via doxysphinx -pyjwt[crypto]==2.8.0 +pyjwt[crypto]==2.9.0 # via pygithub pynacl==1.5.0 # via pygithub -pyparsing==3.1.2 +pyparsing==3.1.4 # via doxysphinx -pyyaml==6.0.1 +pyyaml==6.0.2 # via # myst-parser # rocm-docs-core @@ -112,15 +112,15 @@ requests==2.32.3 # via # pygithub # sphinx -rocm-docs-core[api-reference]==1.4.1 +rocm-docs-core[api-reference]==1.8.2 # via -r requirements.in smmap==5.0.1 # via gitdb snowballstemmer==2.2.0 # via sphinx -soupsieve==2.5 +soupsieve==2.6 # via beautifulsoup4 -sphinx==7.3.7 +sphinx==8.0.2 # via # breathe # myst-parser @@ -135,33 +135,33 @@ sphinx-book-theme==1.1.3 # via rocm-docs-core sphinx-copybutton==0.5.2 # via rocm-docs-core -sphinx-design==0.6.0 +sphinx-design==0.6.1 # via rocm-docs-core sphinx-external-toc==1.0.1 # via rocm-docs-core -sphinx-notfound-page==1.0.2 +sphinx-notfound-page==1.0.4 # via rocm-docs-core -sphinxcontrib-applehelp==1.0.8 +sphinxcontrib-applehelp==2.0.0 # via sphinx -sphinxcontrib-devhelp==1.0.6 +sphinxcontrib-devhelp==2.0.0 # via sphinx -sphinxcontrib-htmlhelp==2.0.5 +sphinxcontrib-htmlhelp==2.1.0 # via sphinx sphinxcontrib-jsmath==1.0.1 # via sphinx -sphinxcontrib-qthelp==1.0.7 +sphinxcontrib-qthelp==2.0.0 # via sphinx -sphinxcontrib-serializinghtml==1.1.10 +sphinxcontrib-serializinghtml==2.0.0 # via sphinx -tomli==2.0.1 +tomli==2.0.2 # via sphinx -tqdm==4.66.4 +tqdm==4.66.5 # via mpire typing-extensions==4.12.2 # via # pydata-sphinx-theme # pygithub -urllib3==2.2.2 +urllib3==2.2.3 # via # pygithub # requests diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 8c8451e3..8415afa4 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR) -project(omnitrace-examples LANGUAGES C CXX) +project(rocprofiler-systems-examples LANGUAGES C CXX) if("${CMAKE_BUILD_TYPE}" STREQUAL "") set(CMAKE_BUILD_TYPE @@ -17,26 +17,27 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_CLANG_TIDY) set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME examples) -if(OMNITRACE_BUILD_DEBUG) +if(ROCPROFSYS_BUILD_DEBUG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -fno-omit-frame-pointer") endif() option(BUILD_SHARED_LIBS "Build dynamic libraries" ON) -if(CMAKE_PROJECT_NAME STREQUAL "omnitrace") +if(CMAKE_PROJECT_NAME STREQUAL "rocprofiler-systems") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) - omnitrace_add_option(OMNITRACE_INSTALL_EXAMPLES "Install omnitrace examples" OFF) + rocprofiler_systems_add_option(ROCPROFSYS_INSTALL_EXAMPLES + "Install rocprofiler-systems examples" OFF) else() - option(OMNITRACE_INSTALL_EXAMPLES "Install omnitrace examples" ON) + option(ROCPROFSYS_INSTALL_EXAMPLES "Install rocprofiler-systems examples" ON) endif() -if(OMNITRACE_INSTALL_EXAMPLES) +if(ROCPROFSYS_INSTALL_EXAMPLES) include(GNUInstallDirs) endif() -set(OMNITRACE_EXAMPLE_ROOT_DIR +set(ROCPROFSYS_EXAMPLE_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR} CACHE INTERNAL "") # defines function for creating causal profiling exes diff --git a/examples/causal-helpers.cmake b/examples/causal-helpers.cmake index 342d1aa6..ba21e367 100644 --- a/examples/causal-helpers.cmake +++ b/examples/causal-helpers.cmake @@ -3,8 +3,8 @@ # include_guard(DIRECTORY) -if(NOT TARGET omnitrace::omnitrace-user-library) - find_package(omnitrace REQUIRED COMPONENTS user) +if(NOT TARGET rocprofiler-systems::rocprofiler-systems-user-library) + find_package(rocprofiler-systems REQUIRED COMPONENTS user) endif() if(NOT coz-profiler_FOUND) @@ -15,11 +15,11 @@ if(NOT TARGET omni-causal-examples) add_custom_target(omni-causal-examples) endif() -function(omnitrace_causal_example_executable _NAME) +function(rocprofiler_systems_causal_example_executable _NAME) cmake_parse_arguments( CAUSAL "" "" "SOURCES;DEFINITIONS;INCLUDE_DIRECTORIES;LINK_LIBRARIES" ${ARGN}) - function(omnitrace_causal_example_interface _TARGET) + function(rocprofiler_systems_causal_example_interface _TARGET) if(NOT TARGET ${_TARGET}) find_package(Threads REQUIRED) add_library(${_TARGET} INTERFACE) @@ -27,8 +27,8 @@ function(omnitrace_causal_example_executable _NAME) endif() endfunction() - omnitrace_causal_example_interface(omni-causal-example-lib-debug) - omnitrace_causal_example_interface(omni-causal-example-lib-no-debug) + rocprofiler_systems_causal_example_interface(omni-causal-example-lib-debug) + rocprofiler_systems_causal_example_interface(omni-causal-example-lib-no-debug) target_compile_options(omni-causal-example-lib-debug INTERFACE -g3 -fno-omit-frame-pointer) @@ -37,48 +37,54 @@ function(omnitrace_causal_example_executable _NAME) add_executable(${_NAME} ${CAUSAL_SOURCES}) target_compile_definitions(${_NAME} PRIVATE USE_COZ=0 USE_OMNI=0 ${CAUSAL_DEFINITIONS}) - target_include_directories(${_NAME} PRIVATE ${OMNITRACE_EXAMPLE_ROOT_DIR}/causal + target_include_directories(${_NAME} PRIVATE ${ROCPROFSYS_EXAMPLE_ROOT_DIR}/causal ${CAUSAL_INCLUDE_DIRECTORIES}) target_link_libraries( - ${_NAME} PRIVATE ${CAUSAL_LINK_LIBRARIES} omnitrace::omnitrace-user-library - omni-causal-example-lib-debug) + ${_NAME} + PRIVATE ${CAUSAL_LINK_LIBRARIES} + rocprofiler-systems::rocprofiler-systems-user-library + omni-causal-example-lib-debug) add_executable(${_NAME}-omni ${CAUSAL_SOURCES}) target_compile_definitions(${_NAME}-omni PRIVATE USE_COZ=0 USE_OMNI=1 ${CAUSAL_DEFINITIONS}) - target_include_directories(${_NAME}-omni PRIVATE ${OMNITRACE_EXAMPLE_ROOT_DIR}/causal + target_include_directories(${_NAME}-omni PRIVATE ${ROCPROFSYS_EXAMPLE_ROOT_DIR}/causal ${CAUSAL_INCLUDE_DIRECTORIES}) target_link_libraries( - ${_NAME}-omni PRIVATE ${CAUSAL_LINK_LIBRARIES} omnitrace::omnitrace-user-library - omni-causal-example-lib-debug) + ${_NAME}-omni + PRIVATE ${CAUSAL_LINK_LIBRARIES} + rocprofiler-systems::rocprofiler-systems-user-library + omni-causal-example-lib-debug) add_executable(${_NAME}-ndebug ${CAUSAL_SOURCES}) target_compile_definitions(${_NAME}-ndebug PRIVATE USE_COZ=0 USE_OMNI=0 ${CAUSAL_DEFINITIONS}) target_include_directories( - ${_NAME}-ndebug PRIVATE ${OMNITRACE_EXAMPLE_ROOT_DIR}/causal + ${_NAME}-ndebug PRIVATE ${ROCPROFSYS_EXAMPLE_ROOT_DIR}/causal ${CAUSAL_INCLUDE_DIRECTORIES}) target_link_libraries( ${_NAME}-ndebug - PRIVATE ${CAUSAL_LINK_LIBRARIES} omnitrace::omnitrace-user-library + PRIVATE ${CAUSAL_LINK_LIBRARIES} + rocprofiler-systems::rocprofiler-systems-user-library omni-causal-example-lib-no-debug) add_executable(${_NAME}-omni-ndebug ${CAUSAL_SOURCES}) target_compile_definitions(${_NAME}-omni-ndebug PRIVATE USE_COZ=0 USE_OMNI=1 ${CAUSAL_DEFINITIONS}) target_include_directories( - ${_NAME}-omni-ndebug PRIVATE ${OMNITRACE_EXAMPLE_ROOT_DIR}/causal + ${_NAME}-omni-ndebug PRIVATE ${ROCPROFSYS_EXAMPLE_ROOT_DIR}/causal ${CAUSAL_INCLUDE_DIRECTORIES}) target_link_libraries( ${_NAME}-omni-ndebug - PRIVATE ${CAUSAL_LINK_LIBRARIES} omnitrace::omnitrace-user-library + PRIVATE ${CAUSAL_LINK_LIBRARIES} + rocprofiler-systems::rocprofiler-systems-user-library omni-causal-example-lib-no-debug) add_dependencies(omni-causal-examples ${_NAME} ${_NAME}-omni ${_NAME}-ndebug ${_NAME}-omni-ndebug) if(coz-profiler_FOUND) - omnitrace_causal_example_interface(omni-causal-example-lib-coz) + rocprofiler_systems_causal_example_interface(omni-causal-example-lib-coz) target_compile_options(omni-causal-example-lib-coz INTERFACE -g3 -gdwarf-3 -fno-omit-frame-pointer) @@ -86,7 +92,7 @@ function(omnitrace_causal_example_executable _NAME) target_compile_definitions(${_NAME}-coz PRIVATE USE_COZ=1 USE_OMNI=0 ${CAUSAL_DEFINITIONS}) target_include_directories( - ${_NAME}-coz PRIVATE ${OMNITRACE_EXAMPLE_ROOT_DIR}/causal + ${_NAME}-coz PRIVATE ${ROCPROFSYS_EXAMPLE_ROOT_DIR}/causal ${CAUSAL_INCLUDE_DIRECTORIES}) target_link_libraries(${_NAME}-coz PRIVATE ${CAUSAL_LINK_LIBRARIES} omni-causal-example-lib-coz coz::coz) @@ -94,11 +100,11 @@ function(omnitrace_causal_example_executable _NAME) add_dependencies(omni-causal-examples ${_NAME}-coz) endif() - if(OMNITRACE_INSTALL_EXAMPLES) + if(ROCPROFSYS_INSTALL_EXAMPLES) install( TARGETS ${_NAME} ${_NAME}-omni ${_NAME}-coz DESTINATION bin - COMPONENT omnitrace-examples + COMPONENT rocprofiler-systems-examples OPTIONAL) endif() endfunction() diff --git a/examples/causal/CMakeLists.txt b/examples/causal/CMakeLists.txt index a3bba08b..100f868b 100644 --- a/examples/causal/CMakeLists.txt +++ b/examples/causal/CMakeLists.txt @@ -1,20 +1,20 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR) -project(omnitrace-causal-example LANGUAGES CXX) +project(rocprofiler-systems-causal-example LANGUAGES CXX) -if(OMNITRACE_DISABLE_EXAMPLES) +if(ROCPROFSYS_DISABLE_EXAMPLES) get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME) - if(${PROJECT_NAME} IN_LIST OMNITRACE_DISABLE_EXAMPLES OR ${_DIR} IN_LIST - OMNITRACE_DISABLE_EXAMPLES) + if(${PROJECT_NAME} IN_LIST ROCPROFSYS_DISABLE_EXAMPLES OR ${_DIR} IN_LIST + ROCPROFSYS_DISABLE_EXAMPLES) return() endif() endif() set(CMAKE_BUILD_TYPE "Release") find_package(Threads REQUIRED) -if(NOT TARGET omnitrace::omnitrace-user-library) - find_package(omnitrace REQUIRED COMPONENTS user) +if(NOT TARGET rocprofiler-systems::rocprofiler-systems-user-library) + find_package(rocprofiler-systems REQUIRED COMPONENTS user) endif() add_library(causal-interface-library INTERFACE) @@ -23,19 +23,19 @@ target_compile_options(causal-interface-library INTERFACE -g3 -gdwarf-3 target_link_libraries(causal-interface-library INTERFACE Threads::Threads ${CMAKE_DL_LIBS}) -omnitrace_causal_example_executable( +rocprofiler_systems_causal_example_executable( "causal-both" SOURCES causal.cpp impl.cpp LINK_LIBRARIES causal-interface-library DEFINITIONS USE_RNG=1 USE_CPU=1) -omnitrace_causal_example_executable( +rocprofiler_systems_causal_example_executable( "causal-rng" SOURCES causal.cpp impl.cpp LINK_LIBRARIES causal-interface-library DEFINITIONS USE_RNG=1 USE_CPU=0) -omnitrace_causal_example_executable( +rocprofiler_systems_causal_example_executable( "causal-cpu" SOURCES causal.cpp impl.cpp LINK_LIBRARIES causal-interface-library diff --git a/examples/causal/causal.hpp b/examples/causal/causal.hpp index 8094cebf..00207c49 100644 --- a/examples/causal/causal.hpp +++ b/examples/causal/causal.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -27,11 +27,11 @@ #define CAUSAL_LABEL __FILE__ ":" CAUSAL_STR(__LINE__) #if defined(USE_OMNI) && USE_OMNI > 0 -# include -# define CAUSAL_PROGRESS OMNITRACE_CAUSAL_PROGRESS -# define CAUSAL_PROGRESS_NAMED(LABEL) OMNITRACE_CAUSAL_PROGRESS_NAMED(LABEL) -# define CAUSAL_BEGIN(LABEL) OMNITRACE_CAUSAL_BEGIN(LABEL) -# define CAUSAL_END(LABEL) OMNITRACE_CAUSAL_END(LABEL) +# include +# define CAUSAL_PROGRESS ROCPROFSYS_CAUSAL_PROGRESS +# define CAUSAL_PROGRESS_NAMED(LABEL) ROCPROFSYS_CAUSAL_PROGRESS_NAMED(LABEL) +# define CAUSAL_BEGIN(LABEL) ROCPROFSYS_CAUSAL_BEGIN(LABEL) +# define CAUSAL_END(LABEL) ROCPROFSYS_CAUSAL_END(LABEL) #elif defined(USE_COZ) && USE_COZ > 0 # include # define CAUSAL_PROGRESS COZ_PROGRESS_NAMED(CAUSAL_LABEL) diff --git a/examples/causal/impl.cpp b/examples/causal/impl.cpp index 1839715e..2c44480f 100644 --- a/examples/causal/impl.cpp +++ b/examples/causal/impl.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -61,7 +61,7 @@ get_clock_cpu_now() noexcept; } // namespace // -// This implementation works well for Omnitrace +// This implementation works well for rocprof-sys // while COZ makes poor predictions // template @@ -82,7 +82,7 @@ template bool rng_impl_func(int64_t, uint64_t); // // This implementation works well for COZ -// while Omnitrace makes poor predictions +// while rocprof-sys makes poor predictions // template bool diff --git a/examples/code-coverage/CMakeLists.txt b/examples/code-coverage/CMakeLists.txt index 94a265a9..536fb21a 100644 --- a/examples/code-coverage/CMakeLists.txt +++ b/examples/code-coverage/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR) -project(omnitrace-code-coverage-example LANGUAGES CXX) +project(rocprofiler-systems-code-coverage-example LANGUAGES CXX) -if(OMNITRACE_DISABLE_EXAMPLES) +if(ROCPROFSYS_DISABLE_EXAMPLES) get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME) - if(${PROJECT_NAME} IN_LIST OMNITRACE_DISABLE_EXAMPLES OR ${_DIR} IN_LIST - OMNITRACE_DISABLE_EXAMPLES) + if(${PROJECT_NAME} IN_LIST ROCPROFSYS_DISABLE_EXAMPLES OR ${_DIR} IN_LIST + ROCPROFSYS_DISABLE_EXAMPLES) return() endif() endif() @@ -19,11 +19,11 @@ add_executable(code-coverage code-coverage.cpp) target_link_libraries(code-coverage PRIVATE Threads::Threads) target_compile_options(code-coverage PRIVATE ${_FLAGS}) -if(OMNITRACE_INSTALL_EXAMPLES) +if(ROCPROFSYS_INSTALL_EXAMPLES) install( TARGETS code-coverage DESTINATION bin - COMPONENT omnitrace-examples) + COMPONENT rocprofiler-systems-examples) endif() set(PYTHON_FILES code-coverage.py) @@ -37,11 +37,11 @@ if(Python3_FOUND) configure_file(${PROJECT_SOURCE_DIR}/${_FILE} ${PROJECT_BINARY_DIR}/${_FILE} @ONLY) - if(OMNITRACE_INSTALL_EXAMPLES) + if(ROCPROFSYS_INSTALL_EXAMPLES) install( PROGRAMS ${PROJECT_BINARY_DIR}/${_FILE} DESTINATION bin - COMPONENT omnitrace-examples) + COMPONENT rocprofiler-systems-examples) endif() endforeach() endif() diff --git a/examples/code-coverage/code-coverage.py b/examples/code-coverage/code-coverage.py index efd2f2da..9dae8bee 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/fork/CMakeLists.txt b/examples/fork/CMakeLists.txt index 909b18bb..5245f69d 100644 --- a/examples/fork/CMakeLists.txt +++ b/examples/fork/CMakeLists.txt @@ -1,19 +1,20 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR) -project(omnitrace-fork LANGUAGES CXX) +project(rocprofiler-systems-fork LANGUAGES CXX) set(CMAKE_BUILD_TYPE "RelWithDebInfo") string(REPLACE " " ";" _FLAGS "${CMAKE_CXX_FLAGS_DEBUG}") find_package(Threads REQUIRED) -find_package(omnitrace REQUIRED COMPONENTS user) +find_package(rocprofiler-systems REQUIRED COMPONENTS user) add_executable(fork-example fork.cpp) -target_link_libraries(fork-example PRIVATE Threads::Threads omnitrace::omnitrace) +target_link_libraries(fork-example PRIVATE Threads::Threads + rocprofiler-systems::rocprofiler-systems) target_compile_options(fork-example PRIVATE ${_FLAGS}) -if(OMNITRACE_INSTALL_EXAMPLES) +if(ROCPROFSYS_INSTALL_EXAMPLES) install( TARGETS fork-example DESTINATION bin - COMPONENT omnitrace-examples) + COMPONENT rocprofiler-systems-examples) endif() diff --git a/examples/fork/fork.cpp b/examples/fork/fork.cpp index 15b3180d..632fe7f3 100644 --- a/examples/fork/fork.cpp +++ b/examples/fork/fork.cpp @@ -1,5 +1,5 @@ -#include +#include #include #include @@ -33,7 +33,7 @@ run(const char* _name, int nchildren) pthread_barrier_init(&_barrier, nullptr, nchildren + 1); for(int i = 0; i < nchildren; ++i) { - omnitrace_user_push_region("launch_child"); + rocprofsys_user_push_region("launch_child"); auto _run = [&_barrier, &_children, i, _name](uint64_t _nsec) { pthread_barrier_wait(&_barrier); _children.at(i) = fork(); @@ -43,13 +43,13 @@ run(const char* _name, int nchildren) print_info(_name); printf("[%s][%i] child job starting...\n", _name, getpid()); auto _sleep = [=]() { - omnitrace_user_push_region("child_process_child_thread"); + rocprofsys_user_push_region("child_process_child_thread"); std::this_thread::sleep_for(std::chrono::seconds{ _nsec }); - omnitrace_user_pop_region("child_process_child_thread"); + rocprofsys_user_pop_region("child_process_child_thread"); }; - omnitrace_user_push_region("child_process"); + rocprofsys_user_push_region("child_process"); std::thread{ _sleep }.join(); - omnitrace_user_push_region("child_process"); + rocprofsys_user_push_region("child_process"); printf("[%s][%i] child job complete\n", _name, getpid()); exit(EXIT_SUCCESS); } @@ -59,7 +59,7 @@ run(const char* _name, int nchildren) } }; _threads.emplace_back(_run, i + 1); - omnitrace_user_pop_region("launch_child"); + rocprofsys_user_pop_region("launch_child"); } // all child threads should start executing their fork once this returns @@ -67,7 +67,7 @@ run(const char* _name, int nchildren) // wait for the threads to successfully fork pthread_barrier_wait(&_barrier); - omnitrace_user_push_region("wait_for_children"); + rocprofsys_user_push_region("wait_for_children"); int _status = 0; pid_t _wait_pid = 0; @@ -110,7 +110,7 @@ run(const char* _name, int nchildren) for(auto& itr : _threads) itr.join(); - omnitrace_user_pop_region("wait_for_children"); + rocprofsys_user_pop_region("wait_for_children"); printf("[%s][%i] returning (error code: %i) ...\n", _name, getpid(), _status); return _status; diff --git a/examples/lulesh/CMakeLists.txt b/examples/lulesh/CMakeLists.txt index 8dd45dd2..9c5fe99a 100644 --- a/examples/lulesh/CMakeLists.txt +++ b/examples/lulesh/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR) -project(omnitrace-lulesh-example LANGUAGES C CXX) +project(rocprofiler-systems-lulesh-example LANGUAGES C CXX) -if(OMNITRACE_DISABLE_EXAMPLES) +if(ROCPROFSYS_DISABLE_EXAMPLES) get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME) - if(${PROJECT_NAME} IN_LIST OMNITRACE_DISABLE_EXAMPLES OR ${_DIR} IN_LIST - OMNITRACE_DISABLE_EXAMPLES) + if(${PROJECT_NAME} IN_LIST ROCPROFSYS_DISABLE_EXAMPLES OR ${_DIR} IN_LIST + ROCPROFSYS_DISABLE_EXAMPLES) return() endif() endif() @@ -65,18 +65,18 @@ endif() file(GLOB headers ${PROJECT_SOURCE_DIR}/*.h ${PROJECT_SOURCE_DIR}/*.hxx) file(GLOB sources ${PROJECT_SOURCE_DIR}/*.cc) -omnitrace_causal_example_executable( +rocprofiler_systems_causal_example_executable( "lulesh" SOURCES ${sources} ${headers} LINK_LIBRARIES Kokkos::kokkos lulesh-mpi INCLUDE_DIRECTORIES ${PROJECT_SOURCE_DIR}/includes) -if(OMNITRACE_INSTALL_EXAMPLES) +if(ROCPROFSYS_INSTALL_EXAMPLES) if(LULESH_BUILD_KOKKOS) install( TARGETS kokkoscore kokkoscontainers DESTINATION ${CMAKE_INSTALL_LIBDIR} - COMPONENT omnitrace-examples) + COMPONENT rocprofiler-systems-examples) set_target_properties(lulesh PROPERTIES INSTALL_RPATH "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") endif() diff --git a/examples/mpi/CMakeLists.txt b/examples/mpi/CMakeLists.txt index 4c945292..aec66705 100644 --- a/examples/mpi/CMakeLists.txt +++ b/examples/mpi/CMakeLists.txt @@ -1,24 +1,25 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR) -project(omnitrace-mpi-examples LANGUAGES C CXX) +project(rocprofiler-systems-mpi-examples LANGUAGES C CXX) -if(OMNITRACE_DISABLE_EXAMPLES) +if(ROCPROFSYS_DISABLE_EXAMPLES) get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME) - if(${PROJECT_NAME} IN_LIST OMNITRACE_DISABLE_EXAMPLES OR ${_DIR} IN_LIST - OMNITRACE_DISABLE_EXAMPLES) + if(${PROJECT_NAME} IN_LIST ROCPROFSYS_DISABLE_EXAMPLES OR ${_DIR} IN_LIST + ROCPROFSYS_DISABLE_EXAMPLES) return() endif() endif() find_package(MPI) if(NOT MPI_FOUND) - if("${CMAKE_PROJECT_NAME}" STREQUAL "omnitrace" AND "$ENV{OMNITRACE_CI}") + if("${CMAKE_PROJECT_NAME}" STREQUAL "rocprofiler-systems" AND "$ENV{ROCPROFSYS_CI}") set(_MSG_TYPE STATUS) # don't generate warnings during CI else() set(_MSG_TYPE AUTHOR_WARNING) endif() - message(${_MSG_TYPE} "MPI could not be found. Cannot build omnitrace-mpi target") + message(${_MSG_TYPE} + "MPI could not be found. Cannot build rocprofiler-systems-mpi target") return() endif() @@ -29,8 +30,9 @@ set(CMAKE_BUILD_TYPE "RelWithDebInfo") add_library(mpi-c-interface-library INTERFACE) target_link_libraries( mpi-c-interface-library - INTERFACE Threads::Threads MPI::MPI_C - $) + INTERFACE + Threads::Threads MPI::MPI_C + $) target_compile_options(mpi-c-interface-library INTERFACE -Wno-double-promotion) add_executable(mpi-allgather allgather.c) @@ -59,16 +61,17 @@ set(CMAKE_BUILD_TYPE "Release") add_library(mpi-cxx-interface-library INTERFACE) target_link_libraries( mpi-cxx-interface-library - INTERFACE Threads::Threads MPI::MPI_CXX - $) + INTERFACE + Threads::Threads MPI::MPI_CXX + $) add_executable(mpi-example mpi.cpp) target_link_libraries(mpi-example PRIVATE mpi-cxx-interface-library) -if(OMNITRACE_INSTALL_EXAMPLES) +if(ROCPROFSYS_INSTALL_EXAMPLES) install( TARGETS mpi-example mpi-allgather mpi-bcast mpi-all2all mpi-reduce mpi-scatter-gather mpi-send-recv DESTINATION bin - COMPONENT omnitrace-examples) + COMPONENT rocprofiler-systems-examples) endif() diff --git a/examples/openmp/CMakeLists.txt b/examples/openmp/CMakeLists.txt index f63893ab..a550dd17 100644 --- a/examples/openmp/CMakeLists.txt +++ b/examples/openmp/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR) -project(omnitrace-openmp LANGUAGES CXX) +project(rocprofiler-systems-openmp LANGUAGES CXX) file(GLOB common_source ${CMAKE_CURRENT_SOURCE_DIR}/common/*.cpp) add_library(openmp-common OBJECT ${common_source}) @@ -15,9 +15,9 @@ option(USE_CLANG_OMP "Use the clang OpenMP if available" ON) if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") find_package(OpenMP REQUIRED) target_link_libraries(openmp-common PUBLIC OpenMP::OpenMP_CXX) - set(OMNITRACE_OPENMP_USING_LIBOMP_LIBRARY + set(ROCPROFSYS_OPENMP_USING_LIBOMP_LIBRARY ON - CACHE INTERNAL "Used by omnitrace testing" FORCE) + CACHE INTERNAL "Used by rocprofiler-systems testing" FORCE) else() find_program(CLANGXX_EXECUTABLE NAMES clang++) find_library( @@ -25,31 +25,34 @@ else() NAMES omp omp5 ${CMAKE_SHARED_LIBRARY_PREFIX}omp${CMAKE_SHARED_LIBRARY_SUFFIX}.5) if(CLANGXX_EXECUTABLE AND LIBOMP_LIBRARY - AND COMMAND omnitrace_custom_compilation + AND COMMAND rocprofiler_systems_custom_compilation AND USE_CLANG_OMP) target_compile_options(openmp-common PUBLIC -W -Wall -fopenmp=libomp) target_link_libraries(openmp-common PUBLIC ${LIBOMP_LIBRARY}) - omnitrace_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE} TARGET openmp-common) - omnitrace_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE} TARGET openmp-cg) - omnitrace_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE} TARGET openmp-lu) - set(OMNITRACE_OPENMP_USING_LIBOMP_LIBRARY + rocprofiler_systems_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE} TARGET + openmp-common) + rocprofiler_systems_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE} TARGET + openmp-cg) + rocprofiler_systems_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE} TARGET + openmp-lu) + set(ROCPROFSYS_OPENMP_USING_LIBOMP_LIBRARY ON - CACHE INTERNAL "Used by omnitrace testing" FORCE) + CACHE INTERNAL "Used by rocprofiler-systems testing" FORCE) else() find_package(OpenMP REQUIRED) target_link_libraries(openmp-common PUBLIC OpenMP::OpenMP_CXX) - set(OMNITRACE_OPENMP_USING_LIBOMP_LIBRARY + set(ROCPROFSYS_OPENMP_USING_LIBOMP_LIBRARY OFF - CACHE INTERNAL "Used by omnitrace testing" FORCE) + CACHE INTERNAL "Used by rocprofiler-systems testing" FORCE) endif() endif() target_link_libraries(openmp-cg PRIVATE openmp-common) target_link_libraries(openmp-lu PRIVATE openmp-common) -if(OMNITRACE_INSTALL_EXAMPLES) +if(ROCPROFSYS_INSTALL_EXAMPLES) install( TARGETS openmp-cg openmp-lu DESTINATION bin - COMPONENT omnitrace-examples) + COMPONENT rocprofiler-systems-examples) endif() diff --git a/examples/parallel-overhead/CMakeLists.txt b/examples/parallel-overhead/CMakeLists.txt index 1458e138..f8afbfc7 100644 --- a/examples/parallel-overhead/CMakeLists.txt +++ b/examples/parallel-overhead/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR) -project(omnitrace-parallel-overhead-example LANGUAGES CXX) +project(rocprofiler-systems-parallel-overhead-example LANGUAGES CXX) -if(OMNITRACE_DISABLE_EXAMPLES) +if(ROCPROFSYS_DISABLE_EXAMPLES) get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME) - if(${PROJECT_NAME} IN_LIST OMNITRACE_DISABLE_EXAMPLES OR ${_DIR} IN_LIST - OMNITRACE_DISABLE_EXAMPLES) + if(${PROJECT_NAME} IN_LIST ROCPROFSYS_DISABLE_EXAMPLES OR ${_DIR} IN_LIST + ROCPROFSYS_DISABLE_EXAMPLES) return() endif() endif() @@ -26,9 +26,9 @@ target_link_libraries(parallel-overhead-locks PRIVATE Threads::Threads parallel-overhead-compile-options) target_compile_definitions(parallel-overhead-locks PRIVATE USE_LOCKS=1) -if(OMNITRACE_INSTALL_EXAMPLES) +if(ROCPROFSYS_INSTALL_EXAMPLES) install( TARGETS parallel-overhead parallel-overhead-locks DESTINATION bin - COMPONENT omnitrace-examples) + COMPONENT rocprofiler-systems-examples) endif() diff --git a/examples/python/CMakeLists.txt b/examples/python/CMakeLists.txt index 9f810ed3..b882031f 100644 --- a/examples/python/CMakeLists.txt +++ b/examples/python/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR) -project(omnitrace-python) +project(rocprofiler-systems-python) -if(OMNITRACE_DISABLE_EXAMPLES) +if(ROCPROFSYS_DISABLE_EXAMPLES) get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME) - if(${PROJECT_NAME} IN_LIST OMNITRACE_DISABLE_EXAMPLES OR ${_DIR} IN_LIST - OMNITRACE_DISABLE_EXAMPLES) + if(${PROJECT_NAME} IN_LIST ROCPROFSYS_DISABLE_EXAMPLES OR ${_DIR} IN_LIST + ROCPROFSYS_DISABLE_EXAMPLES) return() endif() endif() @@ -22,11 +22,11 @@ if(Python3_FOUND) configure_file(${PROJECT_SOURCE_DIR}/${_FILE} ${PROJECT_BINARY_DIR}/${_FILE} @ONLY) - if(OMNITRACE_INSTALL_EXAMPLES) + if(ROCPROFSYS_INSTALL_EXAMPLES) install( PROGRAMS ${PROJECT_BINARY_DIR}/${_FILE} DESTINATION bin - COMPONENT omnitrace-examples) + COMPONENT rocprofiler-systems-examples) endif() endforeach() endif() diff --git a/examples/python/fill.py b/examples/python/fill.py index 373e3f34..c1d5de1b 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 2979ae26..c0087492 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 44efbe48..3ec7b944 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/examples/rccl/CMakeLists.txt b/examples/rccl/CMakeLists.txt index 4b0d860d..004a6cbd 100644 --- a/examples/rccl/CMakeLists.txt +++ b/examples/rccl/CMakeLists.txt @@ -1,24 +1,24 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR) -project(omnitrace-rccl-example LANGUAGES CXX) +project(rocprofiler-systems-rccl-example LANGUAGES CXX) -if(OMNITRACE_DISABLE_EXAMPLES) +if(ROCPROFSYS_DISABLE_EXAMPLES) get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME) - if(${PROJECT_NAME} IN_LIST OMNITRACE_DISABLE_EXAMPLES OR ${_DIR} IN_LIST - OMNITRACE_DISABLE_EXAMPLES) + if(${PROJECT_NAME} IN_LIST ROCPROFSYS_DISABLE_EXAMPLES OR ${_DIR} IN_LIST + ROCPROFSYS_DISABLE_EXAMPLES) return() endif() endif() function(rccl_message _MSG_TYPE) - if("${CMAKE_PROJECT_NAME}" STREQUAL "omnitrace" - AND "$ENV{OMNITRACE_CI}" + if("${CMAKE_PROJECT_NAME}" STREQUAL "rocprofiler-systems" + AND "$ENV{ROCPROFSYS_CI}" AND "${_MSG_TYPE}" MATCHES "WARNING") set(_MSG_TYPE STATUS) # don't generate warnings during CI endif() - if("${CMAKE_PROJECT_NAME}" STREQUAL "omnitrace") - omnitrace_message(${_MSG_TYPE} ${ARGN}) + if("${CMAKE_PROJECT_NAME}" STREQUAL "rocprofiler-systems") + rocprofiler_systems_message(${_MSG_TYPE} ${ARGN}) else() message(${_MSG_TYPE} ${ARGN}) endif() @@ -31,10 +31,10 @@ if(NOT hip_FOUND) return() endif() -if("${CMAKE_PROJECT_NAME}" STREQUAL "omnitrace" - AND ("$ENV{OMNITRACE_CI}" - OR OMNITRACE_CI - OR OMNITRACE_BUILD_CI)) +if("${CMAKE_PROJECT_NAME}" STREQUAL "rocprofiler-systems" + AND ("$ENV{ROCPROFSYS_CI}" + OR ROCPROFSYS_CI + OR ROCPROFSYS_BUILD_CI)) find_package(rccl QUIET) # avoid generating warning in CI else() find_package(rccl) @@ -47,8 +47,7 @@ endif() if(hip_FOUND AND rccl_FOUND) include(FetchContent) - fetchcontent_declare( - rccl-tests GIT_REPOSITORY https://github.com/ROCmSoftwarePlatform/rccl-tests.git) + fetchcontent_declare(rccl-tests GIT_REPOSITORY https://github.com/ROCm/rccl-tests.git) # After the following call, the CMake targets defined by googletest and Catch2 will be # available to the rest of the build diff --git a/examples/rewrite-caller/CMakeLists.txt b/examples/rewrite-caller/CMakeLists.txt index 75f60d92..1245b823 100644 --- a/examples/rewrite-caller/CMakeLists.txt +++ b/examples/rewrite-caller/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR) -project(omnitrace-rewrite-caller-example LANGUAGES CXX) +project(rocprofiler-systems-rewrite-caller-example LANGUAGES CXX) -if(OMNITRACE_DISABLE_EXAMPLES) +if(ROCPROFSYS_DISABLE_EXAMPLES) get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME) - if(${PROJECT_NAME} IN_LIST OMNITRACE_DISABLE_EXAMPLES OR ${_DIR} IN_LIST - OMNITRACE_DISABLE_EXAMPLES) + if(${PROJECT_NAME} IN_LIST ROCPROFSYS_DISABLE_EXAMPLES OR ${_DIR} IN_LIST + ROCPROFSYS_DISABLE_EXAMPLES) return() endif() endif() @@ -16,9 +16,9 @@ set(CMAKE_BUILD_TYPE "Debug") add_executable(rewrite-caller rewrite-caller.cpp) target_compile_options(rewrite-caller PRIVATE ${_FLAGS}) -if(OMNITRACE_INSTALL_EXAMPLES) +if(ROCPROFSYS_INSTALL_EXAMPLES) install( TARGETS rewrite-caller DESTINATION bin - COMPONENT omnitrace-examples) + COMPONENT rocprofiler-systems-examples) endif() diff --git a/examples/trace-time-window/CMakeLists.txt b/examples/trace-time-window/CMakeLists.txt index fe68dc16..2ab3d671 100644 --- a/examples/trace-time-window/CMakeLists.txt +++ b/examples/trace-time-window/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR) -project(omnitrace-trace-time-window-example LANGUAGES CXX) +project(rocprofiler-systems-trace-time-window-example LANGUAGES CXX) -if(OMNITRACE_DISABLE_EXAMPLES) +if(ROCPROFSYS_DISABLE_EXAMPLES) get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME) - if(${PROJECT_NAME} IN_LIST OMNITRACE_DISABLE_EXAMPLES OR ${_DIR} IN_LIST - OMNITRACE_DISABLE_EXAMPLES) + if(${PROJECT_NAME} IN_LIST ROCPROFSYS_DISABLE_EXAMPLES OR ${_DIR} IN_LIST + ROCPROFSYS_DISABLE_EXAMPLES) return() endif() endif() @@ -16,9 +16,9 @@ set(CMAKE_BUILD_TYPE "Debug") add_executable(trace-time-window trace-time-window.cpp) target_compile_options(trace-time-window PRIVATE ${_FLAGS}) -if(OMNITRACE_INSTALL_EXAMPLES) +if(ROCPROFSYS_INSTALL_EXAMPLES) install( TARGETS trace-time-window DESTINATION bin - COMPONENT omnitrace-examples) + COMPONENT rocprofiler-systems-examples) endif() diff --git a/examples/transpose/CMakeLists.txt b/examples/transpose/CMakeLists.txt index 25792c92..cff00c42 100644 --- a/examples/transpose/CMakeLists.txt +++ b/examples/transpose/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR) -project(omnitrace-transpose-example LANGUAGES CXX) +project(rocprofiler-systems-transpose-example LANGUAGES CXX) -if(OMNITRACE_DISABLE_EXAMPLES) +if(ROCPROFSYS_DISABLE_EXAMPLES) get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME) - if(${PROJECT_NAME} IN_LIST OMNITRACE_DISABLE_EXAMPLES OR ${_DIR} IN_LIST - OMNITRACE_DISABLE_EXAMPLES) + if(${PROJECT_NAME} IN_LIST ROCPROFSYS_DISABLE_EXAMPLES OR ${_DIR} IN_LIST + ROCPROFSYS_DISABLE_EXAMPLES) return() endif() endif() @@ -36,7 +36,7 @@ endif() if((NOT CMAKE_CXX_COMPILER_IS_HIPCC OR (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT hip_FOUND)) - AND (NOT COMMAND omnitrace_custom_compilation AND NOT HIPCC_EXECUTABLE)) + AND (NOT COMMAND rocprofiler_systems_custom_compilation AND NOT HIPCC_EXECUTABLE)) message(AUTHOR_WARNING "transpose target could not be built") return() endif() @@ -56,8 +56,10 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT HIPCC_EXECUTABLE) target_link_libraries( transpose - PRIVATE $ - $ $) + PRIVATE + $ + $ + $) else() target_compile_options(transpose PRIVATE -W -Wall) endif() @@ -73,12 +75,12 @@ endif() if(NOT CMAKE_CXX_COMPILER_IS_HIPCC AND HIPCC_EXECUTABLE) # defined in MacroUtilities.cmake - omnitrace_custom_compilation(COMPILER ${HIPCC_EXECUTABLE} TARGET transpose) + rocprofiler_systems_custom_compilation(COMPILER ${HIPCC_EXECUTABLE} TARGET transpose) endif() -if(OMNITRACE_INSTALL_EXAMPLES) +if(ROCPROFSYS_INSTALL_EXAMPLES) install( TARGETS transpose DESTINATION bin - COMPONENT omnitrace-examples) + COMPONENT rocprofiler-systems-examples) endif() diff --git a/examples/transpose/transpose.cpp b/examples/transpose/transpose.cpp index 97c0f040..391a1423 100644 --- a/examples/transpose/transpose.cpp +++ b/examples/transpose/transpose.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2020 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-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 @@ -221,7 +221,7 @@ main(int argc, char** argv) #else (void) size; #endif - // this is a temporary workaround in omnitrace when HIP + MPI is enabled + // this is a temporary workaround in rocprof-sys when HIP + MPI is enabled int ndevice = 0; int devid = rank; HIP_API_CALL(hipGetDeviceCount(&ndevice)); diff --git a/examples/user-api/CMakeLists.txt b/examples/user-api/CMakeLists.txt index 754e08eb..19e1eee6 100644 --- a/examples/user-api/CMakeLists.txt +++ b/examples/user-api/CMakeLists.txt @@ -1,27 +1,29 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR) -project(omnitrace-user-api-example LANGUAGES CXX) +project(rocprofiler-systems-user-api-example LANGUAGES CXX) -if(OMNITRACE_DISABLE_EXAMPLES) +if(ROCPROFSYS_DISABLE_EXAMPLES) get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME) - if(${PROJECT_NAME} IN_LIST OMNITRACE_DISABLE_EXAMPLES OR ${_DIR} IN_LIST - OMNITRACE_DISABLE_EXAMPLES) + if(${PROJECT_NAME} IN_LIST ROCPROFSYS_DISABLE_EXAMPLES OR ${_DIR} IN_LIST + ROCPROFSYS_DISABLE_EXAMPLES) return() endif() endif() set(CMAKE_BUILD_TYPE "Debug") find_package(Threads REQUIRED) -if(NOT TARGET omnitrace::omnitrace-user-library) - find_package(omnitrace REQUIRED COMPONENTS user) +if(NOT TARGET rocprofiler-systems::rocprofiler-systems-user-library) + find_package(rocprofiler-systems REQUIRED COMPONENTS user) endif() add_executable(user-api user-api.cpp) -target_link_libraries(user-api PRIVATE Threads::Threads omnitrace::omnitrace-user-library) +target_link_libraries( + user-api PRIVATE Threads::Threads + rocprofiler-systems::rocprofiler-systems-user-library) -if(OMNITRACE_INSTALL_EXAMPLES) +if(ROCPROFSYS_INSTALL_EXAMPLES) install( TARGETS user-api DESTINATION bin - COMPONENT omnitrace-examples) + COMPONENT rocprofiler-systems-examples) endif() diff --git a/examples/user-api/user-api.cpp b/examples/user-api/user-api.cpp index e6908f64..54635a08 100644 --- a/examples/user-api/user-api.cpp +++ b/examples/user-api/user-api.cpp @@ -1,7 +1,7 @@ -#include "omnitrace/categories.h" -#include "omnitrace/types.h" -#include +#include +#include +#include #include #include @@ -26,52 +26,52 @@ custom_push_region(const char* name); namespace { -omnitrace_user_callbacks_t custom_callbacks = OMNITRACE_USER_CALLBACKS_INIT; -omnitrace_user_callbacks_t original_callbacks = OMNITRACE_USER_CALLBACKS_INIT; +rocprofsys_user_callbacks_t custom_callbacks = ROCPROFSYS_USER_CALLBACKS_INIT; +rocprofsys_user_callbacks_t original_callbacks = ROCPROFSYS_USER_CALLBACKS_INIT; } // namespace int main(int argc, char** argv) { custom_callbacks.push_region = &custom_push_region; - omnitrace_user_configure(OMNITRACE_USER_UNION_CONFIG, custom_callbacks, - &original_callbacks); + rocprofsys_user_configure(ROCPROFSYS_USER_UNION_CONFIG, custom_callbacks, + &original_callbacks); - omnitrace_user_push_region(argv[0]); - omnitrace_user_push_region("initialization"); + rocprofsys_user_push_region(argv[0]); + rocprofsys_user_push_region("initialization"); size_t nthread = std::min(16, std::thread::hardware_concurrency()); size_t nitr = 50000; long nfib = 10; if(argc > 1) nfib = atol(argv[1]); if(argc > 2) nthread = atol(argv[2]); if(argc > 3) nitr = atol(argv[3]); - omnitrace_user_pop_region("initialization"); + rocprofsys_user_pop_region("initialization"); printf("[%s] Threads: %zu\n[%s] Iterations: %zu\n[%s] fibonacci(%li)...\n", argv[0], nthread, argv[0], nitr, argv[0], nfib); - omnitrace_user_push_region("thread_creation"); + rocprofsys_user_push_region("thread_creation"); std::vector threads{}; threads.reserve(nthread); // disable instrumentation for child threads - omnitrace_user_stop_thread_trace(); + rocprofsys_user_stop_thread_trace(); for(size_t i = 0; i < nthread; ++i) { threads.emplace_back(&run, nitr, nfib); } // re-enable instrumentation - omnitrace_user_start_thread_trace(); - omnitrace_user_pop_region("thread_creation"); + rocprofsys_user_start_thread_trace(); + rocprofsys_user_pop_region("thread_creation"); - omnitrace_user_push_region("thread_wait"); + rocprofsys_user_push_region("thread_wait"); for(auto& itr : threads) itr.join(); - omnitrace_user_pop_region("thread_wait"); + rocprofsys_user_pop_region("thread_wait"); run(nitr, nfib); printf("[%s] fibonacci(%li) x %lu = %li\n", argv[0], nfib, nthread, total.load()); - omnitrace_user_pop_region(argv[0]); + rocprofsys_user_pop_region(argv[0]); return 0; } @@ -90,19 +90,19 @@ fib(long n) void run(size_t nitr, long n) { - omnitrace_user_push_region(RUN_LABEL); + rocprofsys_user_push_region(RUN_LABEL); long local = 0; for(size_t i = 0; i < nitr; ++i) local += fib(n); total += local; - omnitrace_user_pop_region(RUN_LABEL); + rocprofsys_user_pop_region(RUN_LABEL); } int custom_push_region(const char* name) { if(!original_callbacks.push_region || !original_callbacks.push_annotated_region) - return OMNITRACE_USER_ERROR_NO_BINDING; + return ROCPROFSYS_USER_ERROR_NO_BINDING; printf("Pushing custom region :: %s\n", name); @@ -113,13 +113,13 @@ custom_push_region(const char* name) char _buff[1024]; if(_err != 0) _msg = strerror_r(_err, _buff, sizeof(_buff)); - omnitrace_annotation_t _annotations[] = { - { "errno", OMNITRACE_INT32, &_err }, { "strerror", OMNITRACE_STRING, _msg } + rocprofsys_annotation_t _annotations[] = { + { "errno", ROCPROFSYS_INT32, &_err }, { "strerror", ROCPROFSYS_STRING, _msg } }; errno = 0; // reset errno return (*original_callbacks.push_annotated_region)( - name, _annotations, sizeof(_annotations) / sizeof(omnitrace_annotation_t)); + name, _annotations, sizeof(_annotations) / sizeof(rocprofsys_annotation_t)); } return (*original_callbacks.push_region)(name); diff --git a/scripts/build-release.sh b/scripts/build-release.sh index 53c27c79..699736df 100755 --- a/scripts/build-release.sh +++ b/scripts/build-release.sh @@ -196,12 +196,12 @@ NPROC=$(nproc) if [ ${NJOBS} -gt ${NPROC} ]; then NJOBS=${NPROC}; fi CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=OFF -DCPACK_GENERATOR=STGZ" -OMNITRACE_GENERAL_ARGS="-DOMNITRACE_CPACK_SYSTEM_NAME=${DISTRO} -DOMNITRACE_ROCM_VERSION=${ROCM_VERSION} -DOMNITRACE_MAX_THREADS=${MAX_THREADS} -DOMNITRACE_STRIP_LIBRARIES=${STRIP} -DOMNITRACE_INSTALL_PERFETTO_TOOLS=${PERFETTO_TOOLS}" -OMNITRACE_BUILD_ARGS="-DOMNITRACE_BUILD_TESTING=OFF -DOMNITRACE_BUILD_EXAMPLES=OFF -DOMNITRACE_BUILD_PAPI=ON -DOMNITRACE_BUILD_LTO=${LTO} -DOMNITRACE_BUILD_HIDDEN_VISIBILITY=${HIDDEN_VIZ} -DOMNITRACE_BUILD_STATIC_LIBGCC=${LIBGCC} -DOMNITRACE_BUILD_STATIC_LIBSTDCXX=${LIBSTDCXX} -DOMNITRACE_BUILD_RELEASE=ON" -OMNITRACE_USE_ARGS="-DOMNITRACE_USE_MPI_HEADERS=ON -DOMNITRACE_USE_OMPT=ON -DOMNITRACE_USE_PAPI=ON" +ROCPROFSYS_GENERAL_ARGS="-DROCPROFSYS_CPACK_SYSTEM_NAME=${DISTRO} -DROCPROFSYS_ROCM_VERSION=${ROCM_VERSION} -DROCPROFSYS_MAX_THREADS=${MAX_THREADS} -DROCPROFSYS_STRIP_LIBRARIES=${STRIP} -DROCPROFSYS_INSTALL_PERFETTO_TOOLS=${PERFETTO_TOOLS}" +ROCPROFSYS_BUILD_ARGS="-DROCPROFSYS_BUILD_TESTING=OFF -DROCPROFSYS_BUILD_EXAMPLES=OFF -DROCPROFSYS_BUILD_PAPI=ON -DROCPROFSYS_BUILD_LTO=${LTO} -DROCPROFSYS_BUILD_HIDDEN_VISIBILITY=${HIDDEN_VIZ} -DROCPROFSYS_BUILD_STATIC_LIBGCC=${LIBGCC} -DROCPROFSYS_BUILD_STATIC_LIBSTDCXX=${LIBSTDCXX} -DROCPROFSYS_BUILD_RELEASE=ON" +ROCPROFSYS_USE_ARGS="-DROCPROFSYS_USE_MPI_HEADERS=ON -DROCPROFSYS_USE_OMPT=ON -DROCPROFSYS_USE_PAPI=ON" TIMEMORY_ARGS="-DTIMEMORY_USE_LIBUNWIND=ON -DTIMEMORY_BUILD_LIBUNWIND=ON -DTIMEMORY_BUILD_PORTABLE=ON" -DYNINST_ARGS="-DOMNITRACE_BUILD_DYNINST=ON -DDYNINST_USE_OpenMP=ON $(echo -DDYNINST_BUILD_{TBB,BOOST,ELFUTILS,LIBIBERTY}=ON) -DDYNINST_BOOST_DOWNLOAD_VERSION=${BOOST_VERSION}" -STANDARD_ARGS="${CMAKE_ARGS} ${OMNITRACE_GENERAL_ARGS} ${OMNITRACE_USE_ARGS} ${OMNITRACE_BUILD_ARGS} ${TIMEMORY_ARGS} ${DYNINST_ARGS} ${EXTRA_ARGS}" +DYNINST_ARGS="-DROCPROFSYS_BUILD_DYNINST=ON -DDYNINST_USE_OpenMP=ON $(echo -DDYNINST_BUILD_{TBB,BOOST,ELFUTILS,LIBIBERTY}=ON) -DDYNINST_BOOST_DOWNLOAD_VERSION=${BOOST_VERSION}" +STANDARD_ARGS="${CMAKE_ARGS} ${ROCPROFSYS_GENERAL_ARGS} ${ROCPROFSYS_USE_ARGS} ${ROCPROFSYS_BUILD_ARGS} ${TIMEMORY_ARGS} ${DYNINST_ARGS} ${EXTRA_ARGS}" SCRIPT_DIR=$(realpath $(dirname ${BASH_SOURCE[0]})) cd $(dirname ${SCRIPT_DIR}) @@ -265,13 +265,13 @@ build-and-package-base() DEST="stgz" ;; DEB) - verbose-run cpack -G DEB -D CPACK_PACKAGING_INSTALL_PREFIX=/opt/omnitrace + verbose-run cpack -G DEB -D CPACK_PACKAGING_INSTALL_PREFIX=/opt/rocprof-sys EXT="deb" SEP="_" DEST="deb" ;; RPM) - verbose-run cpack -G RPM -D CPACK_PACKAGING_INSTALL_PREFIX=/opt/omnitrace + verbose-run cpack -G RPM -D CPACK_PACKAGING_INSTALL_PREFIX=/opt/rocprof-sys EXT="rpm" SEP="-" DEST="rpm" @@ -344,7 +344,7 @@ build-and-package-python() fi conda deactivate done - build-and-package-base ${DIR}-python $@ -DOMNITRACE_USE_PYTHON=ON -DOMNITRACE_BUILD_PYTHON=ON -DOMNITRACE_PYTHON_ROOT_DIRS=\"${_PYTHON_ENVS}\" + build-and-package-base ${DIR}-python $@ -DROCPROFSYS_USE_PYTHON=ON -DROCPROFSYS_BUILD_PYTHON=ON -DROCPROFSYS_PYTHON_ROOT_DIRS=\"${_PYTHON_ENVS}\" } build-and-package() @@ -372,7 +372,7 @@ if [ "${IS_DOCKER}" -ne 0 ]; then git config --global --add safe.directory ${PWD verbose-run echo "Build omnitrace installers with generators: ${GENERATORS}" -build-and-package ${WITH_CORE} ${DISTRO}-core -DOMNITRACE_USE_HIP=OFF -DOMNITRACE_USE_MPI=OFF -build-and-package ${WITH_MPI} ${DISTRO}-${MPI_IMPL} -DOMNITRACE_USE_HIP=OFF -DOMNITRACE_USE_MPI=ON -build-and-package ${WITH_ROCM} ${DISTRO}-rocm-${ROCM_VERSION} -DOMNITRACE_USE_HIP=ON -DOMNITRACE_USE_MPI=OFF -build-and-package ${WITH_ROCM_MPI} ${DISTRO}-rocm-${ROCM_VERSION}-${MPI_IMPL} -DOMNITRACE_USE_HIP=ON -DOMNITRACE_USE_MPI=ON +build-and-package ${WITH_CORE} ${DISTRO}-core -DROCPROFSYS_USE_HIP=OFF -DROCPROFSYS_USE_MPI=OFF +build-and-package ${WITH_MPI} ${DISTRO}-${MPI_IMPL} -DROCPROFSYS_USE_HIP=OFF -DROCPROFSYS_USE_MPI=ON +build-and-package ${WITH_ROCM} ${DISTRO}-rocm-${ROCM_VERSION} -DROCPROFSYS_USE_HIP=ON -DROCPROFSYS_USE_MPI=OFF +build-and-package ${WITH_ROCM_MPI} ${DISTRO}-rocm-${ROCM_VERSION}-${MPI_IMPL} -DROCPROFSYS_USE_HIP=ON -DROCPROFSYS_USE_MPI=ON diff --git a/scripts/check_copyright.sh b/scripts/check_copyright.sh new file mode 100755 index 00000000..6913f451 --- /dev/null +++ b/scripts/check_copyright.sh @@ -0,0 +1,223 @@ +#!/usr/bin/env bash + +# Start of configuration +preamble="Copyright +(\([cC]\) +)?" +postamble=",? +Advanced +Micro +Devices, +Inc\." +find_pattern="$preamble([0-9]{4}-)?[0-9]{4}$postamble" +# printf format string, receives the current year as a parameter +uptodate_pattern="$preamble([0-9]{4}-)?%d$postamble" +# / interpreted with sed syntax, also passed to printf +# printf interprets '\' escape sequences so they must be escaped +# The capture groups are as follows: +# - \1 is the whole preamble text +# - \3 is the start year, \2 is skipped because it is used for an optional part of the preamble +# - \5 is the end of the copyright statement after the end year, \4 would be the original end year +# as written in the file, it is replaced by the current year instead. +replace_pattern="($preamble)([0-9]{4})(-[0-9]{4})?($postamble)/\\\1\\\3-%d\\\5" +# End of configuration + +print_help() { printf -- \ +"\033[36musuage\033[0m: \033[33mcheck_year.sh [-h] [-u] [-a] [-d ] [-k] [-v]\033[0m +\033[36mdescription\033[0m: Checks for if the copyright year in the staged files is up to date and displays the files with out-of-date copyright statements. Exits with '0' if successful and with '1' if something is out of date. +\033[36moptions\033[0m: + \033[34m-h\033[0m Displays this message. + \033[34m-u\033[0m Automatically updates the copyright year + \033[34m-a\033[0m Automatically applies applies the changes to current staging environment. Implies '-u' and '-c'. + \033[34m-c\033[0m Compare files to the index instead of the working tree. + \033[34m-d \033[0m Compare using the diff of a hash. + \033[34m-k\033[0m Compare using the fork point: where this branch and 'remotes/origin/HEAD' diverge. + \033[34m-q\033[0m Suppress updates about progress. + \033[34m-v\033[0m Verbose output. +Use '\033[33mgit config --local hooks.updateCopyright \033[0m' to automatically apply copyright changes on commit. +" +} + +# argument parsing +apply=false +update=false +verbose=false +forkdiff=false +quiet=false +cached=false + +while getopts "auhvkqcd:" arg; do + case $arg in + a) update=true;apply=true;cached=true;; + u) update=true;; + v) verbose=true;; + k) forkdiff=true;; + q) quiet=true;; + c) cached=true;; + d) diff_hash=${OPTARG};; + h) print_help; exit;; + *) print help; exit 1;; + esac +done + +# If set, check all files changed since the fork point +if $forkdiff; then + branch="$(git rev-parse --abbrev-ref HEAD)" + remote="$(git config --local --get "branch.$branch.remote" || echo 'origin')" + source_commit="remotes/$remote/HEAD" + + # don't use fork-point for finding fork point (lol) + # see: https://stackoverflow.com/a/53981615 + diff_hash="$(git merge-base "$source_commit" "$branch")" +fi + +if [ -n "${diff_hash}" ]; then + $verbose && printf -- "Using base commit: %s\n" "${diff_hash}" +else + diff_hash="HEAD" +fi + +# Current year +year="$(date +%Y)" + +# Enable rename detection with full matches only, this skips copyright checks for file name only +# changes. +diff_opts=(-z --name-only '--diff-filter=MA' '--find-renames=100%') +git_grep_opts=(-z --extended-regexp --ignore-case --no-recursive -I) +if $cached; then + diff_opts+=(--cached) + git_grep_opts+=(--cached) +fi + +! $quiet && printf -- "Checking if copyright statements are up-to-date... " +mapfile -d $'\0' changed_files < <(git diff-index "${diff_opts[@]}" "$diff_hash" | LANG=C.UTF-8 sort -z) + +if ! (( ${#changed_files[@]} )); then + ! $quiet && printf -- "\033[32mDone!\033[0m\n" + $verbose && printf -- "\033[36mNo changed files found.\033[0m\n" + exit 0 +fi; + +mapfile -d $'\0' found_copyright < <( \ + git grep "${git_grep_opts[@]}" --files-with-matches -e "$find_pattern" \ + -- "${changed_files[@]}" | \ + LANG=C.UTF-8 sort -z) + +outdated_copyright=() +if (( ${#found_copyright[@]} )); then + # uptodate_pattern variable holds the format string using it as such is intentional + # shellcheck disable=SC2059 + printf -v uptodate_pattern -- "$uptodate_pattern" "$year" + mapfile -d $'\0' outdated_copyright < <( \ + git grep "${git_grep_opts[@]}" --files-without-match -e "$uptodate_pattern" \ + -- "${found_copyright[@]}" | \ + LANG=C.UTF-8 sort -z) +fi + +! $quiet && printf -- "\033[32mDone!\033[0m\n" +if $verbose; then + # Compute the files that don't have a copyright as the set difference of + # `changed_files and `found_copyright` + mapfile -d $'\0' notfound_copyright < <( \ + printf -- '%s\0' "${changed_files[@]}" | \ + LANG=C.UTF-8 comm -z -23 - <(printf -- '%s\0' "${found_copyright[@]}")) + + if (( ${#notfound_copyright[@]} )); then + printf -- "\033[36mCouldn't find a copyright statement in %d file(s):\033[0m\n" \ + "${#notfound_copyright[@]}" + printf -- ' - %q\n' "${notfound_copyright[@]}" + fi + + # Similarly the up-to-date files are the difference of `found_copyright` and `outdated_copyright` + mapfile -d $'\0' uptodate_copyright < <( \ + printf -- '%s\0' "${found_copyright[@]}" | \ + LANG=C.UTF-8 comm -z -23 - <(printf -- '%s\0' "${outdated_copyright[@]}")) + + if (( ${#uptodate_copyright[@]} )); then + printf -- "\033[36mThe copyright statement was already up to date in %d file(s):\033[0m\n" \ + "${#uptodate_copyright[@]}" + printf -- ' - %q\n' "${uptodate_copyright[@]}" + fi +fi + +if ! (( ${#outdated_copyright[@]} )); then + exit 0 +fi + +printf -- \ +"\033[31m==== COPYRIGHT OUT OF DATE ====\033[0m +\033[36m%d file(s) need(s) to be updated:\033[0m\n" "${#outdated_copyright[@]}" +printf -- ' - %q\n' "${outdated_copyright[@]}" + +# If we don't need to update, we early exit. +if ! $update; then + printf -- \ +"\nRun '\033[33m%s -u\033[0m' to update the copyright statement(s). See '-h' for more info, +or set '\033[33mgit config --local hooks.updateCopyright true\033[0m' to automatically update copyrights when committing.\n" \ +"${BASH_SOURCE[0]}" + exit 1 +fi + +if $apply; then + ! $quiet && printf -- "Updating copyrights and staging changes... " +else + ! $quiet && printf -- "Updating copyrights... " +fi + +# replace_pattern variable holds a format string, using it as such is intentional +# shellcheck disable=SC2059 +printf -v replace_pattern -- "$replace_pattern" "$year" +# Just update the files in place if only touching the working-tree +if ! $apply; then + sed --regexp-extended --separate "s/$replace_pattern/g" -i "${outdated_copyright[@]}" + printf -- "\033[32mDone!\033[0m\n" + exit 0 +fi + +generate_patch() { + # Sed command to create a hunk for a copyright statement fix + # expects input to be line number then copyright statement on the next line + to_hunk_cmd="{# Print hunk header, move to the next line + s/.+/@@ -&,1 +&,1 @@/;n + # Print removed line by prepending '-' to it + ;s/^/-/;p + # Print added line, replace the '-' with '+' and replace the copyright statement + s/^-/+/;s/$replace_pattern/g}" + + # Run file-names through git ls-files, just to get a (possibly) quoted name for each + mapfile -t -d $'\n' quoted_files < <(git ls-files --cached -- "${outdated_copyright[@]}") + for ((i = 0;i < ${#outdated_copyright[@]}; i++)); do + file="${outdated_copyright["$i"]}" + quoted="${quoted_files["$i"]}" + # Drop the quote from the start and end (to avoid quoting twice) + escaped="${quoted#\"}"; escaped="${escaped%\"}" + a="\"a/$escaped\"" + b="\"b/$escaped\"" + + printf -- "diff --git %s %s\n--- %s\n+++ %s\n" "$a" "$b" "$a" "$b" + + # Print line number and line for each line with a copyright statement + git cat-file blob ":$file" | \ + sed --quiet --regexp-extended "/$find_pattern/{=;p}" | \ + sed --regexp-extended "$to_hunk_cmd" + done +} + +patch_file="$(git rev-parse --git-dir)/copyright-fix.patch" +generate_patch > "$patch_file" + +# Cleanup patch file when the script exits +finish () { + rm -f "$patch_file" +} +# The trap will be invoked whenever the script exits, even due to a signal, this is a bash only +# feature +trap finish EXIT + +if ! git apply --unidiff-zero < "$patch_file"; then + printf -- "\033[31mFailed to apply changes to working tree. +Perhaps the fix is already applied, but not yet staged?\n\033[0m" + exit 1 +fi + +if ! git apply --cached --unidiff-zero < "$patch_file"; then + printf -- "\033[31mFailed to apply change to the index.\n\033[0m" + exit 1 +fi + +! $quiet && printf -- "\033[32mDone!\033[0m\n" +exit 0 diff --git a/scripts/dl-gen.py b/scripts/dl-gen.py index 60e63cd3..0f5894ff 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: @@ -18,13 +18,13 @@ ##### declaration: - bool OnLoad(HsaApiTable*, uint64_t, uint64_t, const char* const*) OMNITRACE_PUBLIC_API; - void OnUnload() OMNITRACE_PUBLIC_API; + bool OnLoad(HsaApiTable*, uint64_t, uint64_t, const char* const*) ROCPROFSYS_PUBLIC_API; + void OnUnload() ROCPROFSYS_PUBLIC_API; ##### dlsym: - OMNITRACE_DLSYM(OnLoad_f, m_omnihandle, "OnLoad"); - OMNITRACE_DLSYM(OnUnload_f, m_omnihandle, "OnUnload"); + ROCPROFSYS_DLSYM(OnLoad_f, m_omnihandle, "OnLoad"); + ROCPROFSYS_DLSYM(OnUnload_f, m_omnihandle, "OnUnload"); ##### member variables: @@ -35,12 +35,12 @@ 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().OnLoad_f, table, runtime_version, failed_tool_count, failed_tool_names); + return ROCPROFSYS_DL_INVOKE(get_indirect().OnLoad_f, table, runtime_version, failed_tool_count, failed_tool_names); } void OnUnload() { - return OMNITRACE_DL_INVOKE(get_indirect().OnUnload_f); + return ROCPROFSYS_DL_INVOKE(get_indirect().OnUnload_f); } """ @@ -69,18 +69,18 @@ def member_variables(self): ) def function_decl(self): - return " {} {}({}) OMNITRACE_PUBLIC_API;".format( + return " {} {}({}) ROCPROFSYS_PUBLIC_API;".format( self.return_type, self.func_name, ", ".join(self.param_types) ) def dlsym_function(self): - return ' OMNITRACE_DLSYM({0}_f, m_omnihandle, "{0}");'.format(self.func_name) + return ' ROCPROFSYS_DLSYM({0}_f, m_omnihandle, "{0}");'.format(self.func_name) def call_dlsym_function(self): _param_names = ", ".join(self.param_names) if _param_names and _param_names != ", ": _param_names = f", {_param_names}" - return " {} {}({})\n {}\n return OMNITRACE_DL_INVOKE(get_indirect().{}_f{});\n {}".format( + return " {} {}({})\n {}\n return ROCPROFSYS_DL_INVOKE(get_indirect().{}_f{});\n {}".format( self.return_type, self.func_name, ", ".join(self.params), diff --git a/scripts/gperftools-cpu-profile.sh b/scripts/gperftools-cpu-profile.sh index fabc5673..e11b6369 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/scripts/omnitrace-launch-compiler b/scripts/rocprof-sys-launch-compiler similarity index 68% rename from scripts/omnitrace-launch-compiler rename to scripts/rocprof-sys-launch-compiler index 5df1ecb3..cb5fc048 100755 --- a/scripts/omnitrace-launch-compiler +++ b/scripts/rocprof-sys-launch-compiler @@ -1,7 +1,7 @@ #!/bin/bash -e # # This script allows CMAKE_CXX_COMPILER to be a standard -# C++ compiler and omnitrace sets RULE_LAUNCH_COMPILE and +# C++ compiler and rocprofiler-systems sets RULE_LAUNCH_COMPILE and # RULE_LAUNCH_LINK in CMake so that all compiler and link # commands are prefixed with this script followed by the # C++ compiler. Thus if $1 == $2 then we know the command @@ -15,24 +15,24 @@ # emit a message about the underlying command executed : ${DEBUG:=0} -: ${OMNITRACE_DEBUG_LAUNCH_COMPILER:=${DEBUG}} +: ${ROCPROFSYS_DEBUG_LAUNCH_COMPILER:=${DEBUG}} debug-message() { - if [ "${OMNITRACE_DEBUG_LAUNCH_COMPILER}" -ne 0 ]; then + if [ "${ROCPROFSYS_DEBUG_LAUNCH_COMPILER}" -ne 0 ]; then echo -e "##### $(basename ${BASH_SOURCE[0]}) executing: \"$@\"... #####" fi } -# if omnitrace compiler is not passed, someone is probably trying to invoke it directly +# if rocprofiler-systems compiler is not passed, someone is probably trying to invoke it directly if [ -z "${1}" ]; then - echo -e "\n${BASH_SOURCE[0]} was invoked without the omnitrace compiler as the first argument." + echo -e "\n${BASH_SOURCE[0]} was invoked without the rocprofiler-systems compiler as the first argument." echo "This script is not indended to be directly invoked by any mechanism other" echo -e "than through a RULE_LAUNCH_COMPILE or RULE_LAUNCH_LINK property set in CMake.\n" exit 1 fi -# if omnitrace compiler is not passed, someone is probably trying to invoke it directly +# if rocprofiler-systems compiler is not passed, someone is probably trying to invoke it directly if [ -z "${2}" ]; then echo -e "\n${BASH_SOURCE[0]} was invoked without the C++ compiler as the second argument." echo "This script is not indended to be directly invoked by any mechanism other" @@ -43,10 +43,10 @@ fi # if there aren't two args, this isn't necessarily invalid, just a bit strange if [ -z "${3}" ]; then exit 0; fi -# store the omnitrace compiler -OMNITRACE_COMPILER=${1} +# store the rocprofiler-systems compiler +ROCPROFSYS_COMPILER=${1} -# remove the omnitrace compiler from the arguments +# remove the rocprofiler-systems compiler from the arguments shift # store the expected C++ compiler @@ -81,19 +81,19 @@ fi if [[ "${CXX_COMPILER}" != "${1}" ]]; then debug-message $@ - # the command does not depend on omnitrace so just execute the command w/o re-directing to ${OMNITRACE_COMPILER} + # the command does not depend on rocprofiler-systems so just execute the command w/o re-directing to ${ROCPROFSYS_COMPILER} eval $@ else - # the executable is the C++ compiler, so we need to re-direct to ${OMNITRACE_COMPILER} - if [ ! -f "${OMNITRACE_COMPILER}" ]; then - echo -e "\nError: the compiler redirect for omnitrace was not found at ${OMNITRACE_COMPILER}\n" + # the executable is the C++ compiler, so we need to re-direct to ${ROCPROFSYS_COMPILER} + if [ ! -f "${ROCPROFSYS_COMPILER}" ]; then + echo -e "\nError: the compiler redirect for rocprofiler-systems was not found at ${ROCPROFSYS_COMPILER}\n" exit 1 fi # discard the compiler from the command shift - debug-message ${OMNITRACE_COMPILER} $@ - # execute ${OMNITRACE_COMPILER} (again, usually nvcc_wrapper) - ${OMNITRACE_COMPILER} $@ + debug-message ${ROCPROFSYS_COMPILER} $@ + # execute ${ROCPROFSYS_COMPILER} (again, usually nvcc_wrapper) + ${ROCPROFSYS_COMPILER} $@ fi diff --git a/scripts/omnitrace-leak.supp b/scripts/rocprof-sys-leak.supp similarity index 100% rename from scripts/omnitrace-leak.supp rename to scripts/rocprof-sys-leak.supp diff --git a/scripts/omnitrace-thread.supp b/scripts/rocprof-sys-thread.supp similarity index 92% rename from scripts/omnitrace-thread.supp rename to scripts/rocprof-sys-thread.supp index a0422fa1..ddf08472 100644 --- a/scripts/omnitrace-thread.supp +++ b/scripts/rocprof-sys-thread.supp @@ -1,5 +1,5 @@ # false positive -race:omnitrace::component::pthread_create_gotcha::operator() +race:rocprofsys::component::pthread_create_gotcha::operator() race:pthread_create race:tim::impl::storage<*>::_data() race:tim::graph<*>::append_child diff --git a/scripts/run-ci.py b/scripts/run-ci.py index f77557ef..a725894a 100755 --- a/scripts/run-ci.py +++ b/scripts/run-ci.py @@ -39,7 +39,7 @@ def generate_custom(args, cmake_args, ctest_args): NAME = re.sub(r"(.*)-([0-9]+)/merge", "PR_\\2_\\1", NAME) return f""" - set(CTEST_PROJECT_NAME "Omnitrace") + set(CTEST_PROJECT_NAME "rocprofiler-systems") set(CTEST_NIGHTLY_START_TIME "05:00:00 UTC") set(CTEST_DROP_METHOD "http") @@ -66,7 +66,7 @@ def generate_custom(args, cmake_args, ctest_args): set(CTEST_BINARY_DIRECTORY {BINARY_DIR}) set(CTEST_UPDATE_COMMAND {GIT_CMD}) - set(CTEST_CONFIGURE_COMMAND "{CMAKE_CMD} -B {BINARY_DIR} {SOURCE_DIR} -DOMNITRACE_BUILD_CI=ON {CMAKE_ARGS}") + set(CTEST_CONFIGURE_COMMAND "{CMAKE_CMD} -B {BINARY_DIR} {SOURCE_DIR} -DROCPROFSYS_BUILD_CI=ON {CMAKE_ARGS}") set(CTEST_BUILD_COMMAND "{CMAKE_CMD} --build {BINARY_DIR} --target all --parallel {BUILD_JOBS}") set(CTEST_COVERAGE_COMMAND {GCOV_CMD}) """ @@ -138,7 +138,7 @@ def parse_cdash_args(args): BINARY_DIR = os.path.join(SOURCE_DIR, "build") SITE = socket.gethostname() NAME = None - SUBMIT_URL = "my.cdash.org/submit.php?project=Omnitrace" + SUBMIT_URL = "my.cdash.org/submit.php?project=rocprofiler-systems" CODECOV = False parser = argparse.ArgumentParser() @@ -219,7 +219,10 @@ def parse_args(args=None): cdash_args = parse_cdash_args(input_args) if cdash_args.coverage: - cmake_args += ["-DOMNITRACE_BUILD_CODECOV=ON", "-DOMNITRACE_STRIP_LIBRARIES=OFF"] + cmake_args += [ + "-DROCPROFSYS_BUILD_CODECOV=ON", + "-DROCPROFSYS_STRIP_LIBRARIES=OFF", + ] def get_repeat_val(_param): _value = getattr(cdash_args, f"repeat_{_param}".replace("-", "_")) diff --git a/scripts/run-ci.sh b/scripts/run-ci.sh index f66fa666..78b7cf97 100755 --- a/scripts/run-ci.sh +++ b/scripts/run-ci.sh @@ -20,7 +20,7 @@ toupper() : ${BINARY_DIR:=${PWD}/build} : ${SITE:=$(hostname)} : ${NAME:=""} -: ${SUBMIT_URL:="my.cdash.org/submit.php?project=Omnitrace"} +: ${SUBMIT_URL:="my.cdash.org/submit.php?project=rocprofiler-systems"} : ${CODECOV:=0} usage() @@ -159,7 +159,7 @@ export CMAKE_BUILD_PARALLEL_LEVEL if [ "${CODECOV}" -gt 0 ]; then GCOV_CMD=$(which gcov) - CMAKE_ARGS="${CMAKE_ARGS} -DOMNITRACE_BUILD_CODECOV=ON -DOMNITRACE_STRIP_LIBRARIES=OFF" + CMAKE_ARGS="${CMAKE_ARGS} -DROCPROFSYS_BUILD_CODECOV=ON -DROCPROFSYS_STRIP_LIBRARIES=OFF" fi GIT_CMD=$(which git) @@ -172,7 +172,7 @@ verbose-run mkdir -p ${BINARY_DIR} cat << EOF > ${BINARY_DIR}/CTestCustom.cmake -set(CTEST_PROJECT_NAME "Omnitrace") +set(CTEST_PROJECT_NAME "rocprofiler-systems") set(CTEST_NIGHTLY_START_TIME "05:00:00 UTC") set(CTEST_DROP_METHOD "http") @@ -199,7 +199,7 @@ set(CTEST_SOURCE_DIRECTORY ${SOURCE_DIR}) set(CTEST_BINARY_DIRECTORY ${BINARY_DIR}) set(CTEST_UPDATE_COMMAND ${GIT_CMD}) -set(CTEST_CONFIGURE_COMMAND "${CMAKE_CMD} -B ${BINARY_DIR} ${SOURCE_DIR} -DOMNITRACE_BUILD_CI=ON ${CMAKE_ARGS}") +set(CTEST_CONFIGURE_COMMAND "${CMAKE_CMD} -B ${BINARY_DIR} ${SOURCE_DIR} -DROCPROFSYS_BUILD_CI=ON ${CMAKE_ARGS}") set(CTEST_BUILD_COMMAND "${CMAKE_CMD} --build ${BINARY_DIR} --target all --parallel ${CMAKE_BUILD_PARALLEL_LEVEL}") set(CTEST_COVERAGE_COMMAND ${GCOV_CMD}) EOF diff --git a/scripts/test-find-package.sh b/scripts/test-find-package.sh index f397d770..d872a3e8 100755 --- a/scripts/test-find-package.sh +++ b/scripts/test-find-package.sh @@ -23,9 +23,9 @@ fi : ${EXAMPLE_DIR:=examples} : ${EXAMPLE_NAME:=user-api} -: ${SOURCE_DIR:=$(mktemp -t -d omnitrace-test-source-XXXX)} -: ${BINARY_DIR:=$(mktemp -t -d omnitrace-test-build-XXXX)} -: ${INSTALL_DIR:=$(mktemp -t -d omnitrace-install-XXXX)} +: ${SOURCE_DIR:=$(mktemp -t -d rocprof-sys-test-source-XXXX)} +: ${BINARY_DIR:=$(mktemp -t -d rocprof-sys-test-build-XXXX)} +: ${INSTALL_DIR:=$(mktemp -t -d rocprof-sys-install-XXXX)} : ${INSTALL_SCRIPT:=""} usage() @@ -36,7 +36,7 @@ usage() print_option example-dir "" "Directory containing example" "${EXAMPLE_DIR}" print_option source-dir "" "Location to copy example to" "${SOURCE_DIR}" print_option binary-dir "" "Location to build" "${BINARY_DIR}" - print_option install-dir "" "Location of omnitrace installation" "${INSTALL_DIR}" + print_option install-dir "" "Location of rocprofiler-systems installation" "${INSTALL_DIR}" print_option install-script "" "Absolute path to the installer script" "" } @@ -92,9 +92,9 @@ do esac done -if [ ! -f "${INSTALL_DIR}/include/omnitrace/user.h" ]; then +if [ ! -f "${INSTALL_DIR}/include/rocprofiler-systems/user.h" ]; then if [ -z "${INSTALL_SCRIPT}" ]; then - error-message "Unable to find \"omnitrace/user.h\" in \"${INSTALL_DIR}/include\" and installation script not provided" + error-message "Unable to find \"rocprofiler-systems/user.h\" in \"${INSTALL_DIR}/include\" and installation script not provided" elif [ ! -f "${INSTALL_SCRIPT}" ]; then error-message "Unable to locate \"${INSTALL_SCRIPT}\" in directory \"${PWD}\"" else @@ -122,10 +122,10 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON) -find_package(omnitrace REQUIRED COMPONENTS user) +find_package(rocprofiler-systems REQUIRED COMPONENTS user) find_package(Threads REQUIRED) -get_target_property(LIBS omnitrace::omnitrace INTERFACE_LINK_LIBRARIES) +get_target_property(LIBS rocprofiler-systems::rocprofiler-systems INTERFACE_LINK_LIBRARIES) foreach(_LIB \${LIBS}) foreach(_VAR LINK_LIBRARIES INCLUDE_DIRECTORIES) get_target_property(_VAL \${_LIB} INTERFACE_\${_VAR}) @@ -137,7 +137,7 @@ endforeach() file(GLOB sources \${CMAKE_CURRENT_LIST_DIR}/*.cpp \${CMAKE_CURRENT_LIST_DIR}/*.c) add_executable(app \${sources}) -target_link_libraries(app PRIVATE Threads::Threads omnitrace::omnitrace) +target_link_libraries(app PRIVATE Threads::Threads rocprofiler-systems::rocprofiler-systems) EOF export CMAKE_PREFIX_PATH=${INSTALL_DIR}:${CMAKE_PREFIX_PATH} diff --git a/scripts/test-install.sh b/scripts/test-install.sh index 943603c0..152db74f 100755 --- a/scripts/test-install.sh +++ b/scripts/test-install.sh @@ -34,46 +34,46 @@ if [ -d "$(realpath /tmp)" ]; then export TMPDIR fi -: ${CONFIG_DIR:=$(mktemp -t -d omnitrace-test-install-XXXX)} +: ${CONFIG_DIR:=$(mktemp -t -d rocprof-sys-test-install-XXXX)} : ${SOURCE_DIR:=$(dirname ${SCRIPT_DIR})} -: ${ENABLE_OMNITRACE_INSTRUMENT:=1} -: ${ENABLE_OMNITRACE_AVAIL:=1} -: ${ENABLE_OMNITRACE_SAMPLE:=1} -: ${ENABLE_OMNITRACE_PYTHON:=0} -: ${ENABLE_OMNITRACE_REWRITE:=1} -: ${ENABLE_OMNITRACE_RUNTIME:=1} +: ${ENABLE_ROCPROFSYS_INSTRUMENT:=1} +: ${ENABLE_ROCPROFSYS_AVAIL:=1} +: ${ENABLE_ROCPROFSYS_SAMPLE:=1} +: ${ENABLE_ROCPROFSYS_PYTHON:=0} +: ${ENABLE_ROCPROFSYS_REWRITE:=1} +: ${ENABLE_ROCPROFSYS_RUNTIME:=1} 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-omnitrace-avail "0|1" "Enable testing omnitrace-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}" - print_option test-omnitrace-runtime "0|1" "Enable testing omnitrace-instrument runtime instrumentation" "${ENABLE_OMNITRACE_RUNTIME}" + print_option test-rocprof-sys-instrument "0|1" "Enable testing rocprof-sys-instrument" "${ENABLE_ROCPROFSYS_INSTRUMENT}" + print_option test-rocprof-sys-avail "0|1" "Enable testing rocprof-sys-avail" "${ENABLE_ROCPROFSYS_AVAIL}" + print_option test-rocprof-sys-sample "0|1" "Enable testing rocprof-sys-sample" "${ENABLE_ROCPROFSYS_SAMPLE}" + print_option test-rocprof-sys-python "0|1" "Enable testing rocprof-sys-python" "${ENABLE_ROCPROFSYS_PYTHON}" + print_option test-rocprof-sys-rewrite "0|1" "Enable testing rocprof-sys-instrument binary rewrite" "${ENABLE_ROCPROFSYS_REWRITE}" + print_option test-rocprof-sys-runtime "0|1" "Enable testing rocprof-sys-instrument runtime instrumentation" "${ENABLE_ROCPROFSYS_RUNTIME}" } -cat << EOF > ${CONFIG_DIR}/omnitrace.cfg -OMNITRACE_VERBOSE = 2 -OMNITRACE_PROFILE = ON -OMNITRACE_TRACE = ON -OMNITRACE_USE_SAMPLING = ON -OMNITRACE_USE_PROCESS_SAMPLING = ON -OMNITRACE_OUTPUT_PATH = %env{CONFIG_DIR}%/omnitrace-tests-output -OMNITRACE_OUTPUT_PREFIX = %tag%/ -OMNITRACE_SAMPLING_FREQ = 100 -OMNITRACE_SAMPLING_DELAY = 0.05 -OMNITRACE_COUT_OUTPUT = ON -OMNITRACE_TIME_OUTPUT = OFF -OMNITRACE_USE_PID = OFF +cat << EOF > ${CONFIG_DIR}/rocprof-sys.cfg +ROCPROFSYS_VERBOSE = 2 +ROCPROFSYS_PROFILE = ON +ROCPROFSYS_TRACE = ON +ROCPROFSYS_USE_SAMPLING = ON +ROCPROFSYS_USE_PROCESS_SAMPLING = ON +ROCPROFSYS_OUTPUT_PATH = %env{CONFIG_DIR}%/rocprof-sys-tests-output +ROCPROFSYS_OUTPUT_PREFIX = %tag%/ +ROCPROFSYS_SAMPLING_FREQ = 100 +ROCPROFSYS_SAMPLING_DELAY = 0.05 +ROCPROFSYS_COUT_OUTPUT = ON +ROCPROFSYS_TIME_OUTPUT = OFF +ROCPROFSYS_USE_PID = OFF EOF export CONFIG_DIR -export OMNITRACE_CONFIG_FILE=${CONFIG_DIR}/omnitrace.cfg -verbose-run cat ${OMNITRACE_CONFIG_FILE} +export ROCPROFSYS_CONFIG_FILE=${CONFIG_DIR}/rocprof-sys.cfg +verbose-run cat ${ROCPROFSYS_CONFIG_FILE} while [[ $# -gt 0 ]] do @@ -100,28 +100,28 @@ do fi case "${ARG}" in - --test-omnitrace-instrument) - ENABLE_OMNITRACE_INSTRUMENT=${VAL} + --test-rocprof-sys-instrument) + ENABLE_ROCPROFSYS_INSTRUMENT=${VAL} continue ;; - --test-omnitrace-avail) - ENABLE_OMNITRACE_AVAIL=${VAL} + --test-rocprof-sys-avail) + ENABLE_ROCPROFSYS_AVAIL=${VAL} continue ;; - --test-omnitrace-sample) - ENABLE_OMNITRACE_SAMPLE=${VAL} + --test-rocprof-sys-sample) + ENABLE_ROCPROFSYS_SAMPLE=${VAL} continue ;; - --test-omnitrace-python) - ENABLE_OMNITRACE_PYTHON=${VAL} + --test-rocprof-sys-python) + ENABLE_ROCPROFSYS_PYTHON=${VAL} continue ;; - --test-omnitrace-rewrite) - ENABLE_OMNITRACE_REWRITE=${VAL} + --test-rocprof-sys-rewrite) + ENABLE_ROCPROFSYS_REWRITE=${VAL} continue ;; - --test-omnitrace-runtime) - ENABLE_OMNITRACE_RUNTIME=${VAL} + --test-rocprof-sys-runtime) + ENABLE_ROCPROFSYS_RUNTIME=${VAL} continue ;; --source-dir) @@ -136,40 +136,40 @@ do esac done -test-omnitrace() +test-rocprof-sys-instrument() { - verbose-run which omnitrace - verbose-run ldd $(which omnitrace) - verbose-run omnitrace-instrument --help + verbose-run which rocprof-sys-instrument + verbose-run ldd $(which rocprof-sys-instrument) + verbose-run rocprof-sys-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() +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() +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 } -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} - 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 omnitrace-run -- ${CONFIG_DIR}/ls.inst ${LS_ARGS} + verbose-run rocprof-sys-instrument -e -v 1 -o ${CONFIG_DIR}/ls.inst --simulate -- ${LS_NAME} + for i in $(find ${CONFIG_DIR}/rocprof-sys-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 rocprof-sys-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} - 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 --simulate -- ${LS_NAME} ${LS_ARGS} + for i in $(find ${CONFIG_DIR}/rocprof-sys-tests-output/$(basename ${LS_NAME}) -type f); do verbose-run ls ${i}; done + 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-omnitrace-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 -if [ "${ENABLE_OMNITRACE_RUNTIME}" -ne 0 ]; then verbose-run test-omnitrace-runtime; fi +if [ "${ENABLE_ROCPROFSYS_INSTRUMENT}" -ne 0 ]; then verbose-run test-rocprof-sys-instrument; fi +if [ "${ENABLE_ROCPROFSYS_AVAIL}" -ne 0 ]; then verbose-run test-rocprof-sys-avail; fi +if [ "${ENABLE_ROCPROFSYS_SAMPLE}" -ne 0 ]; then verbose-run test-rocprof-sys-sample; fi +if [ "${ENABLE_ROCPROFSYS_PYTHON}" -ne 0 ]; then verbose-run test-rocprof-sys-python; fi +if [ "${ENABLE_ROCPROFSYS_REWRITE}" -ne 0 ]; then verbose-run test-rocprof-sys-rewrite; fi +if [ "${ENABLE_ROCPROFSYS_RUNTIME}" -ne 0 ]; then verbose-run test-rocprof-sys-runtime; fi diff --git a/scripts/test-release.sh b/scripts/test-release.sh index d1bb6bbe..d47110b0 100755 --- a/scripts/test-release.sh +++ b/scripts/test-release.sh @@ -84,7 +84,7 @@ done remove-pycache() { - rm -rf ${1}/lib/python/site-packages/omnitrace/__pycache__ + rm -rf ${1}/lib/python/site-packages/rocprofsys/__pycache__ } setup-env() @@ -96,11 +96,11 @@ setup-env() test-install() { - verbose-run omnitrace-instrument --help - verbose-run omnitrace-avail --help - verbose-run omnitrace-avail --all - if [ -d "${1}/lib/python/site-packages/omnitrace" ]; then - verbose-run omnitrace-python --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/rocprofsys" ]; then + verbose-run rocprof-sys-python --help fi } @@ -121,12 +121,12 @@ test-stgz() if [ -z "${1}" ]; then return; fi local INSTALLER=$(change-directory ${1}) - mkdir /opt/omnitrace-stgz - setup-env /opt/omnitrace-stgz + mkdir /opt/rocprof-sys-stgz + setup-env /opt/rocprof-sys-stgz - verbose-run ${INSTALLER} --prefix=/opt/omnitrace-stgz --skip-license --exclude-dir + verbose-run ${INSTALLER} --prefix=/opt/rocprof-sys-stgz --skip-license --exclude-dir - test-install /opt/omnitrace-stgz + test-install /opt/rocprof-sys-stgz } test-deb() @@ -134,16 +134,16 @@ test-deb() if [ -z "${1}" ]; then return; fi local INSTALLER=$(change-directory ${1}) - setup-env /opt/omnitrace + setup-env /opt/rocprof-sys verbose-run ${SUDO_CMD} dpkg --contents ${INSTALLER} verbose-run ${SUDO_CMD} dpkg -i ${INSTALLER} - test-install /opt/omnitrace - remove-pycache /opt/omnitrace - verbose-run apt-get remove -y omnitrace - if [ -d /opt/omnitrace ]; then - find /opt/omnitrace -type f + test-install /opt/rocprof-sys + remove-pycache /opt/rocprof-sys + verbose-run apt-get remove -y rocprof-sys + if [ -d /opt/rocprof-sys ]; then + find /opt/rocprof-sys -type f fi } @@ -152,16 +152,16 @@ test-rpm() if [ -z "${1}" ]; then return; fi local INSTALLER=$(change-directory ${1}) - setup-env /opt/omnitrace + setup-env /opt/rocprof-sys verbose-run ${SUDO_CMD} rpm -ql -p ${INSTALLER} verbose-run ${SUDO_CMD} rpm -v -i -p ${INSTALLER} --nodeps - test-install /opt/omnitrace - remove-pycache /opt/omnitrace - verbose-run rpm -e omnitrace - if [ -d /opt/omnitrace ]; then - find /opt/omnitrace -type f + test-install /opt/rocprof-sys + remove-pycache /opt/rocprof-sys + verbose-run rpm -e rocprof-sys + if [ -d /opt/rocprof-sys ]; then + find /opt/rocprof-sys -type f fi } diff --git a/scripts/write-omnitrace-install.cmake b/scripts/write-rocprof-sys-install.cmake similarity index 51% rename from scripts/write-omnitrace-install.cmake rename to scripts/write-rocprof-sys-install.cmake index d823c570..6ee620d8 100644 --- a/scripts/write-omnitrace-install.cmake +++ b/scripts/write-rocprof-sys-install.cmake @@ -1,10 +1,10 @@ cmake_minimum_required(VERSION 3.8) -if(NOT DEFINED OMNITRACE_VERSION) +if(NOT DEFINED ROCPROFSYS_VERSION) file(READ "${CMAKE_CURRENT_LIST_DIR}/../VERSION" FULL_VERSION_STRING LIMIT_COUNT 1) string(REGEX REPLACE "(\n|\r)" "" FULL_VERSION_STRING "${FULL_VERSION_STRING}") string(REGEX REPLACE "([0-9]+)\.([0-9]+)\.([0-9]+)(.*)" "\\1.\\2.\\3" - OMNITRACE_VERSION "${FULL_VERSION_STRING}") + ROCPROFSYS_VERSION "${FULL_VERSION_STRING}") endif() if(NOT DEFINED OUTPUT_DIR) @@ -13,7 +13,8 @@ endif() message( STATUS - "Writing ${OUTPUT_DIR}/omnitrace-install.py for omnitrace v${OMNITRACE_VERSION}") + "Writing ${OUTPUT_DIR}/rocprofiler-systems-install.py for rocprofiler-systems v${ROCPROFSYS_VERSION}" + ) -configure_file(${CMAKE_CURRENT_LIST_DIR}/../cmake/Templates/omnitrace-install.py.in - ${OUTPUT_DIR}/omnitrace-install.py @ONLY) +configure_file(${CMAKE_CURRENT_LIST_DIR}/../cmake/Templates/rocprof-sys-install.py.in + ${OUTPUT_DIR}/rocprofiler-systems-install.py @ONLY) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index b93a14d8..a6cc9217 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -2,7 +2,7 @@ if(NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF) endif() -if(OMNITRACE_BUILD_LTO) +if(ROCPROFSYS_BUILD_LTO) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) endif() @@ -13,16 +13,16 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR} add_subdirectory(lib) add_subdirectory(bin) -if(OMNITRACE_USE_PYTHON) +if(ROCPROFSYS_USE_PYTHON) add_subdirectory(python) endif() -if(OMNITRACE_BUILD_DEVELOPER) - add_custom_target(omnitrace-precommit) - foreach(_TARGET format-omnitrace-source format-omnitrace-cmake format-timemory-source - format-timemory-cmake) +if(ROCPROFSYS_BUILD_DEVELOPER) + add_custom_target(rocprofiler-systems-precommit) + foreach(_TARGET format-rocprofiler-systems-source format-rocprofiler-systems-cmake + format-timemory-source format-timemory-cmake) if(TARGET ${_TARGET}) - add_dependencies(omnitrace-precommit ${_TARGET}) + add_dependencies(rocprofiler-systems-precommit ${_TARGET}) endif() endforeach() endif() diff --git a/source/bin/CMakeLists.txt b/source/bin/CMakeLists.txt index 859b729f..de27963d 100644 --- a/source/bin/CMakeLists.txt +++ b/source/bin/CMakeLists.txt @@ -1,27 +1,26 @@ # executable RPATH -if(OMNITRACE_USE_ROCPROFILER +if(ROCPROFSYS_USE_ROCPROFILER AND rocprofiler_LIBRARY_DIR AND ROCmVersion_TRIPLE_VERSION VERSION_LESS 5.2.0 AND NOT CMAKE_INSTALL_RPATH_USE_LINK_PATH) - set(OMNITRACE_EXE_INSTALL_RPATH - "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}/omnitrace:${rocprofiler_LIBRARY_DIR}" + set(ROCPROFSYS_EXE_INSTALL_RPATH + "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}:${rocprofiler_LIBRARY_DIR}" ) else() - set(OMNITRACE_EXE_INSTALL_RPATH - "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}/omnitrace" + set(ROCPROFSYS_EXE_INSTALL_RPATH + "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}" ) endif() # executables -add_subdirectory(omnitrace-avail) -add_subdirectory(omnitrace-causal) -add_subdirectory(omnitrace-sample) -add_subdirectory(omnitrace-instrument) -add_subdirectory(omnitrace-run) -# omnitrace-exe is deprecated -add_subdirectory(omnitrace-exe) +add_subdirectory(rocprof-sys-avail) +add_subdirectory(rocprof-sys-causal) +add_subdirectory(rocprof-sys-sample) +add_subdirectory(rocprof-sys-instrument) +add_subdirectory(rocprof-sys-run) -if(OMNITRACE_BUILD_TESTING OR "$ENV{OMNITRACE_CI}" MATCHES "[1-9]+|ON|on|y|yes") +# tests +if(ROCPROFSYS_BUILD_TESTING OR "$ENV{ROCPROFSYS_CI}" MATCHES "[1-9]+|ON|on|y|yes") add_subdirectory(tests) endif() diff --git a/source/bin/omnitrace-causal/CMakeLists.txt b/source/bin/omnitrace-causal/CMakeLists.txt deleted file mode 100644 index 0d0ed376..00000000 --- a/source/bin/omnitrace-causal/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -# ------------------------------------------------------------------------------# -# -# omnitrace-causal target -# -# ------------------------------------------------------------------------------# - -add_executable( - omnitrace-causal - ${CMAKE_CURRENT_LIST_DIR}/omnitrace-causal.cpp - ${CMAKE_CURRENT_LIST_DIR}/omnitrace-causal.hpp ${CMAKE_CURRENT_LIST_DIR}/impl.cpp) - -target_compile_definitions(omnitrace-causal PRIVATE TIMEMORY_CMAKE=1) -target_include_directories(omnitrace-causal PRIVATE ${CMAKE_CURRENT_LIST_DIR}) -target_link_libraries( - omnitrace-causal - PRIVATE omnitrace::omnitrace-compile-definitions omnitrace::omnitrace-headers - 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}") - -omnitrace_strip_target(omnitrace-causal) - -install( - TARGETS omnitrace-causal - DESTINATION ${CMAKE_INSTALL_BINDIR} - OPTIONAL) diff --git a/source/bin/omnitrace-exe/CMakeLists.txt b/source/bin/omnitrace-exe/CMakeLists.txt deleted file mode 100644 index 576efbdf..00000000 --- a/source/bin/omnitrace-exe/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -# ------------------------------------------------------------------------------# -# -# omnitrace-exe target (deprecated 'omnitrace' executable, now 'omnitrace-instrument') -# -# ------------------------------------------------------------------------------# - -add_executable(omnitrace-exe ${CMAKE_CURRENT_LIST_DIR}/omnitrace.cpp) - -target_link_libraries(omnitrace-exe PRIVATE omnitrace::omnitrace-threading) - -set_target_properties( - omnitrace-exe - PROPERTIES OUTPUT_NAME omnitrace - BUILD_RPATH "\$ORIGIN:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}" - INSTALL_RPATH "${OMNITRACE_EXE_INSTALL_RPATH}" - INSTALL_RPATH_USE_LINK_PATH ON) - -omnitrace_strip_target(omnitrace-exe) - -install( - TARGETS omnitrace-exe - DESTINATION ${CMAKE_INSTALL_BINDIR} - OPTIONAL) diff --git a/source/bin/omnitrace-instrument/CMakeLists.txt b/source/bin/omnitrace-instrument/CMakeLists.txt deleted file mode 100644 index ffed4563..00000000 --- a/source/bin/omnitrace-instrument/CMakeLists.txt +++ /dev/null @@ -1,60 +0,0 @@ -# ------------------------------------------------------------------------------# -# -# omnitrace-instrument target (formerly omnitrace-exe target prior to 1.8.1) -# -# ------------------------------------------------------------------------------# - -set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF) - -add_executable(omnitrace-instrument) - -target_sources( - omnitrace-instrument - PRIVATE ${CMAKE_CURRENT_LIST_DIR}/details.cpp - ${CMAKE_CURRENT_LIST_DIR}/function_signature.cpp - ${CMAKE_CURRENT_LIST_DIR}/function_signature.hpp - ${CMAKE_CURRENT_LIST_DIR}/fwd.hpp - ${CMAKE_CURRENT_LIST_DIR}/info.hpp - ${CMAKE_CURRENT_LIST_DIR}/internal_libs.cpp - ${CMAKE_CURRENT_LIST_DIR}/internal_libs.hpp - ${CMAKE_CURRENT_LIST_DIR}/log.cpp - ${CMAKE_CURRENT_LIST_DIR}/log.hpp - ${CMAKE_CURRENT_LIST_DIR}/module_function.cpp - ${CMAKE_CURRENT_LIST_DIR}/module_function.hpp - ${CMAKE_CURRENT_LIST_DIR}/omnitrace-instrument.cpp - ${CMAKE_CURRENT_LIST_DIR}/omnitrace-instrument.hpp) - -target_link_libraries( - omnitrace-instrument - PRIVATE omnitrace::omnitrace-headers - omnitrace::omnitrace-dyninst - omnitrace::omnitrace-compile-options - omnitrace::omnitrace-compile-definitions - omnitrace::omnitrace-sanitizer - timemory::timemory-headers - timemory::timemory-extensions - timemory::timemory-core) - -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) - -if(OMNITRACE_BUILD_DYNINST) - target_compile_definitions(omnitrace-instrument PRIVATE OMNITRACE_BUILD_DYNINST=1) -endif() - -add_target_flag_if_avail(omnitrace-instrument "-Wno-deprecated-declarations") - -omnitrace_strip_target(omnitrace-instrument) - -if(CMAKE_BUILD_TYPE MATCHES "^(DEBUG|Debug)") - string(REPLACE " " ";" _FLAGS "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") - target_compile_options(omnitrace-instrument PRIVATE ${_FLAGS}) -endif() - -install( - TARGETS omnitrace-instrument - DESTINATION ${CMAKE_INSTALL_BINDIR} - OPTIONAL) diff --git a/source/bin/omnitrace-run/CMakeLists.txt b/source/bin/omnitrace-run/CMakeLists.txt deleted file mode 100644 index 63054bcc..00000000 --- a/source/bin/omnitrace-run/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# ------------------------------------------------------------------------------# -# -# omnitrace-run target -# -# ------------------------------------------------------------------------------# - -add_executable( - omnitrace-run - ${CMAKE_CURRENT_LIST_DIR}/omnitrace-run.cpp - ${CMAKE_CURRENT_LIST_DIR}/omnitrace-run.hpp ${CMAKE_CURRENT_LIST_DIR}/impl.cpp) - -target_compile_definitions(omnitrace-run PRIVATE TIMEMORY_CMAKE=1) -target_include_directories(omnitrace-run PRIVATE ${CMAKE_CURRENT_LIST_DIR}) -target_link_libraries( - omnitrace-run - PRIVATE omnitrace::omnitrace-compile-definitions omnitrace::omnitrace-headers - omnitrace::omnitrace-common-library omnitrace::omnitrace-core - omnitrace::omnitrace-sanitizer) -set_target_properties( - omnitrace-run PROPERTIES BUILD_RPATH "\$ORIGIN:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}" - INSTALL_RPATH "${OMNITRACE_EXE_INSTALL_RPATH}") - -omnitrace_strip_target(omnitrace-run) - -install( - TARGETS omnitrace-run - DESTINATION ${CMAKE_INSTALL_BINDIR} - OPTIONAL) diff --git a/source/bin/omnitrace-sample/CMakeLists.txt b/source/bin/omnitrace-sample/CMakeLists.txt deleted file mode 100644 index 8fe6e61d..00000000 --- a/source/bin/omnitrace-sample/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -# ------------------------------------------------------------------------------# -# -# omnitrace-sample target -# -# ------------------------------------------------------------------------------# - -add_executable(omnitrace-sample ${CMAKE_CURRENT_LIST_DIR}/omnitrace-sample.cpp - ${CMAKE_CURRENT_LIST_DIR}/impl.cpp) - -target_compile_definitions(omnitrace-sample PRIVATE TIMEMORY_CMAKE=1) -target_include_directories(omnitrace-sample PRIVATE ${CMAKE_CURRENT_LIST_DIR}) -target_link_libraries( - omnitrace-sample - PRIVATE omnitrace::omnitrace-compile-definitions omnitrace::omnitrace-headers - omnitrace::omnitrace-common-library) -set_target_properties( - omnitrace-sample PROPERTIES BUILD_RPATH "\$ORIGIN:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}" - INSTALL_RPATH "${OMNITRACE_EXE_INSTALL_RPATH}") - -omnitrace_strip_target(omnitrace-sample) - -install( - TARGETS omnitrace-sample - DESTINATION ${CMAKE_INSTALL_BINDIR} - OPTIONAL) diff --git a/source/bin/omnitrace-avail/CMakeLists.txt b/source/bin/rocprof-sys-avail/CMakeLists.txt similarity index 53% rename from source/bin/omnitrace-avail/CMakeLists.txt rename to source/bin/rocprof-sys-avail/CMakeLists.txt index 2cec5b5c..427d34df 100644 --- a/source/bin/omnitrace-avail/CMakeLists.txt +++ b/source/bin/rocprof-sys-avail/CMakeLists.txt @@ -1,13 +1,13 @@ # ------------------------------------------------------------------------------# # -# omnitrace-avail target +# rocprofiler-systems-avail target # # ------------------------------------------------------------------------------# -add_executable(omnitrace-avail) +add_executable(rocprofiler-systems-avail) target_sources( - omnitrace-avail + rocprofiler-systems-avail PRIVATE ${CMAKE_CURRENT_LIST_DIR}/avail.cpp ${CMAKE_CURRENT_LIST_DIR}/avail.hpp ${CMAKE_CURRENT_LIST_DIR}/common.cpp @@ -22,19 +22,23 @@ target_sources( ${CMAKE_CURRENT_LIST_DIR}/info_type.cpp ${CMAKE_CURRENT_LIST_DIR}/info_type.hpp) -target_include_directories(omnitrace-avail PRIVATE ${CMAKE_CURRENT_LIST_DIR}) -target_compile_definitions(omnitrace-avail PRIVATE OMNITRACE_EXTERN_COMPONENTS=0) +target_include_directories(rocprofiler-systems-avail PRIVATE ${CMAKE_CURRENT_LIST_DIR}) +target_compile_definitions(rocprofiler-systems-avail + PRIVATE ROCPROFSYS_EXTERN_COMPONENTS=0) target_link_libraries( - omnitrace-avail - PRIVATE omnitrace::omnitrace-compile-definitions - omnitrace::omnitrace-interface-library omnitrace::libomnitrace-static) + rocprofiler-systems-avail + PRIVATE rocprofiler-systems::rocprofiler-systems-compile-definitions + rocprofiler-systems::rocprofiler-systems-interface-library + rocprofiler-systems::librocprofiler-systems-static) set_target_properties( - omnitrace-avail PROPERTIES BUILD_RPATH "\$ORIGIN:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}" - INSTALL_RPATH "${OMNITRACE_EXE_INSTALL_RPATH}") + rocprofiler-systems-avail + PROPERTIES BUILD_RPATH "\$ORIGIN:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}" + INSTALL_RPATH "${ROCPROFSYS_EXE_INSTALL_RPATH}" + OUTPUT_NAME ${BINARY_NAME_PREFIX}-avail) -omnitrace_strip_target(omnitrace-avail) +rocprofiler_systems_strip_target(rocprofiler-systems-avail) install( - TARGETS omnitrace-avail + TARGETS rocprofiler-systems-avail DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL) diff --git a/source/bin/omnitrace-avail/avail.cpp b/source/bin/rocprof-sys-avail/avail.cpp similarity index 98% rename from source/bin/omnitrace-avail/avail.cpp rename to source/bin/rocprof-sys-avail/avail.cpp index 5fe5c446..9f5d67a9 100644 --- a/source/bin/omnitrace-avail/avail.cpp +++ b/source/bin/rocprof-sys-avail/avail.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -118,8 +118,8 @@ write_hw_counter_info(std::ostream&, const array_t& = {}, namespace { -// initialize HIP before main so that libomnitrace is not HSA_TOOLS_LIB -int gpu_count = omnitrace::gpu::hip_device_count(); +// initialize HIP before main so that librocprof-sys is not HSA_TOOLS_LIB +int gpu_count = rocprofsys::gpu::hip_device_count(); // statically allocated shared_ptrs to prevent use after free errors auto timemory_manager = tim::manager::master_instance(); @@ -137,8 +137,8 @@ main(int argc, char** argv) (void) timemory_hash_aliases; // tim::unwind::set_bfd_verbose(3); - tim::set_env("OMNITRACE_INIT_TOOLING", "OFF", 1); - omnitrace_init_library(); + tim::set_env("ROCPROFSYS_INIT_TOOLING", "OFF", 1); + rocprofsys_init_library(); std::set _category_options = component_categories{}(); { @@ -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", ROCPROFSYS_ARGPARSE_VERSION_INFO); parser.start_group("DEBUG"); @@ -440,7 +440,7 @@ main(int argc, char** argv) "Dump a configuration to a specified file.") .max_count(1) .dtype("filename") - .set_default(std::string{ "omnitrace-config" }) + .set_default(std::string{ "rocprof-sys-config" }) .action([&_config_file](parser_t& _p) { auto _out = (_p.exists("output")) ? _p.get("output") : std::string{}; @@ -508,15 +508,15 @@ main(int argc, char** argv) return EXIT_FAILURE; } -#if OMNITRACE_USE_HIP > 0 +#if ROCPROFSYS_USE_HIP > 0 if(gpu_count > 0) { size_t _num_metrics = 0; try { - // call to rocm_metrics() will add choices to OMNITRACE_ROCM_EVENTS setting + // call to rocm_metrics() will add choices to ROCPROFSYS_ROCM_EVENTS setting // so always perform this call even if list of HW counters is not requested - _num_metrics = omnitrace::rocprofiler::rocm_metrics().size(); + _num_metrics = rocprofsys::rocprofiler::rocm_metrics().size(); } catch(std::runtime_error& _e) { verbprintf(0, "Retrieving the GPU HW counters failed: %s", _e.what()); @@ -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; @@ -1076,7 +1076,7 @@ write_hw_counter_info(std::ostream& os, const array_t& options, auto _papi_events = tim::papi::available_events_info(); auto _rocm_events = - (gpu_count > 0) ? omnitrace::rocprofiler::rocm_metrics() : hwcounter_info_t{}; + (gpu_count > 0) ? rocprofsys::rocprofiler::rocm_metrics() : hwcounter_info_t{}; if(alphabetical) { diff --git a/source/bin/omnitrace-avail/avail.hpp b/source/bin/rocprof-sys-avail/avail.hpp similarity index 100% rename from source/bin/omnitrace-avail/avail.hpp rename to source/bin/rocprof-sys-avail/avail.hpp diff --git a/source/bin/omnitrace-avail/common.cpp b/source/bin/rocprof-sys-avail/common.cpp similarity index 96% rename from source/bin/omnitrace-avail/common.cpp rename to source/bin/rocprof-sys-avail/common.cpp index 4c7ea56e..e7158299 100644 --- a/source/bin/omnitrace-avail/common.cpp +++ b/source/bin/rocprof-sys-avail/common.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -52,14 +52,14 @@ str_vec_t category_regex_keys = {}; str_set_t category_view = {}; std::stringstream lerr{}; -bool debug_msg = tim::get_env("OMNITRACE_DEBUG_AVAIL", settings::debug()); +bool debug_msg = tim::get_env("ROCPROFSYS_DEBUG_AVAIL", settings::debug()); int32_t verbose_level = - tim::get_env("OMNITRACE_VERBOSE_AVAIL", settings::verbose()); + tim::get_env("ROCPROFSYS_VERBOSE_AVAIL", settings::verbose()); // explicit setting names to exclude std::set settings_exclude = { - "OMNITRACE_ENVIRONMENT", - "OMNITRACE_COMMAND_LINE", + "ROCPROFSYS_ENVIRONMENT", + "ROCPROFSYS_COMMAND_LINE", "cereal_class_version", "settings", }; @@ -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/common.hpp b/source/bin/rocprof-sys-avail/common.hpp similarity index 93% rename from source/bin/omnitrace-avail/common.hpp rename to source/bin/rocprof-sys-avail/common.hpp index f448c784..86a8f60f 100644 --- a/source/bin/omnitrace-avail/common.hpp +++ b/source/bin/rocprof-sys-avail/common.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -109,11 +109,11 @@ extern std::stringstream lerr; // explicit setting names to exclude extern std::set settings_exclude; -// exclude some timemory settings which are not relevant to omnitrace -// exact matches, e.g. OMNITRACE_BANNER +// exclude some timemory settings which are not relevant to rocprof-sys +// exact matches, e.g. ROCPROFSYS_BANNER extern std::string settings_rexclude_exact; -// leading matches, e.g. OMNITRACE_MPI_[A-Z_]+ +// leading matches, e.g. ROCPROFSYS_MPI_[A-Z_]+ extern std::string settings_rexclude_begin; constexpr size_t max_error_message_buffer_length = 4096; @@ -156,12 +156,12 @@ file_exists(const std::string&); if(debug_msg || verbose_level >= LEVEL) \ { \ fprintf(stderr, "%s", tim::log::color::fatal()); \ - fprintf(stderr, "[omnitrace][avail] Error! " __VA_ARGS__); \ + fprintf(stderr, "[rocprof-sys][avail] Error! " __VA_ARGS__); \ fprintf(stderr, "%s", tim::log::color::end()); \ } \ char _buff[max_error_message_buffer_length]; \ snprintf(_buff, max_error_message_buffer_length, \ - "[omnitrace][avail] Error! " __VA_ARGS__); \ + "[rocprof-sys][avail] Error! " __VA_ARGS__); \ throw std::runtime_error(std::string{ _buff }); \ } \ else \ @@ -169,7 +169,7 @@ file_exists(const std::string&); if(debug_msg || verbose_level >= LEVEL) \ { \ fprintf(stderr, "%s", tim::log::color::warning()); \ - fprintf(stderr, "[omnitrace][avail] Warning! " __VA_ARGS__); \ + fprintf(stderr, "[rocprof-sys][avail] Warning! " __VA_ARGS__); \ fprintf(stderr, "%s", tim::log::color::end()); \ } \ } \ @@ -182,7 +182,7 @@ file_exists(const std::string&); if(debug_msg || verbose_level >= LEVEL) \ { \ fprintf(stderr, "%s", tim::log::color::info()); \ - fprintf(stderr, "[omnitrace][avail] " __VA_ARGS__); \ + fprintf(stderr, "[rocprof-sys][avail] " __VA_ARGS__); \ fprintf(stderr, "%s", tim::log::color::end()); \ } \ fflush(stderr); \ diff --git a/source/bin/omnitrace-avail/component_categories.hpp b/source/bin/rocprof-sys-avail/component_categories.hpp similarity index 100% rename from source/bin/omnitrace-avail/component_categories.hpp rename to source/bin/rocprof-sys-avail/component_categories.hpp diff --git a/source/bin/omnitrace-avail/defines.hpp b/source/bin/rocprof-sys-avail/defines.hpp similarity index 100% rename from source/bin/omnitrace-avail/defines.hpp rename to source/bin/rocprof-sys-avail/defines.hpp diff --git a/source/bin/omnitrace-avail/enumerated_list.hpp b/source/bin/rocprof-sys-avail/enumerated_list.hpp similarity index 100% rename from source/bin/omnitrace-avail/enumerated_list.hpp rename to source/bin/rocprof-sys-avail/enumerated_list.hpp diff --git a/source/bin/omnitrace-avail/generate_config.cpp b/source/bin/rocprof-sys-avail/generate_config.cpp similarity index 91% rename from source/bin/omnitrace-avail/generate_config.cpp rename to source/bin/rocprof-sys-avail/generate_config.cpp index cdb71029..ac2b7738 100644 --- a/source/bin/omnitrace-avail/generate_config.cpp +++ b/source/bin/rocprof-sys-avail/generate_config.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -163,9 +163,9 @@ struct setting_serialization, custom_setting_serializer> template void push(type_list) { - OMNITRACE_FOLD_EXPRESSION( + ROCPROFSYS_FOLD_EXPRESSION( settings::push_serialize_map_callback()); - OMNITRACE_FOLD_EXPRESSION( + ROCPROFSYS_FOLD_EXPRESSION( settings::push_serialize_data_callback( type_list{})); } @@ -173,9 +173,9 @@ void push(type_list) template void pop(type_list) { - OMNITRACE_FOLD_EXPRESSION( + ROCPROFSYS_FOLD_EXPRESSION( settings::pop_serialize_map_callback()); - OMNITRACE_FOLD_EXPRESSION( + ROCPROFSYS_FOLD_EXPRESSION( settings::pop_serialize_data_callback( type_list{})); } @@ -245,7 +245,7 @@ generate_config(std::string _config_file, const std::set& _config_f auto _serialize = [_settings](auto&& _ar) { _ar->setNextName(TIMEMORY_PROJECT_NAME); _ar->startNode(); - (*_ar)(cereal::make_nvp("version", std::string{ OMNITRACE_VERSION_STRING })); + (*_ar)(cereal::make_nvp("version", std::string{ ROCPROFSYS_VERSION_STRING })); (*_ar)(cereal::make_nvp("date", tim::get_local_datetime("%F_%H.%M", &_time))); settings::serialize_settings(*_ar, *_settings); _ar->finishNode(); @@ -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 @@ -332,16 +332,16 @@ generate_config(std::string _config_file, const std::set& _config_f { _settings->ordering(); std::sort(_data.begin(), _data.end(), [](auto _lhs, auto _rhs) { - auto _lomni = _lhs->get_categories().count("omnitrace") > 0; - auto _romni = _rhs->get_categories().count("omnitrace") > 0; + auto _lomni = _lhs->get_categories().count("rocprofsys") > 0; + auto _romni = _rhs->get_categories().count("rocprofsys") > 0; if(_lomni && !_romni) return true; if(_romni && !_lomni) return false; for(const auto* itr : - { "OMNITRACE_CONFIG", "OMNITRACE_MODE", "OMNITRACE_TRACE", - "OMNITRACE_PROFILE", "OMNITRACE_USE_SAMPLING", - "OMNITRACE_USE_PROCESS_SAMPLING", "OMNITRACE_USE_ROCTRACER", - "OMNITRACE_USE_ROCM_SMI", "OMNITRACE_USE_KOKKOSP", - "OMNITRACE_USE_OMPT", "OMNITRACE_USE", "OMNITRACE_OUTPUT" }) + { "ROCPROFSYS_CONFIG", "ROCPROFSYS_MODE", "ROCPROFSYS_TRACE", + "ROCPROFSYS_PROFILE", "ROCPROFSYS_USE_SAMPLING", + "ROCPROFSYS_USE_PROCESS_SAMPLING", "ROCPROFSYS_USE_ROCTRACER", + "ROCPROFSYS_USE_ROCM_SMI", "ROCPROFSYS_USE_KOKKOSP", + "ROCPROFSYS_USE_OMPT", "ROCPROFSYS_USE", "ROCPROFSYS_OUTPUT" }) { if(_lhs->get_env_name().find(itr) == 0 && _rhs->get_env_name().find(itr) != 0) @@ -351,7 +351,7 @@ generate_config(std::string _config_file, const std::set& _config_f return false; } for(const auto* itr : - { "OMNITRACE_SUPPRESS_PARSING", "OMNITRACE_SUPPRESS_CONFIG" }) + { "ROCPROFSYS_SUPPRESS_PARSING", "ROCPROFSYS_SUPPRESS_CONFIG" }) { if(_lhs->get_env_name().find(itr) == 0 && _rhs->get_env_name().find(itr) != 0) @@ -423,8 +423,9 @@ 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 - << ") on " << tim::get_local_datetime("%F @ %H:%M", &_time) << "\n\n" + << "# auto-generated by rocprof-sys-avail (version " + << ROCPROFSYS_VERSION_STRING << ") on " + << tim::get_local_datetime("%F @ %H:%M", &_time) << "\n\n" << _ss.str(); } @@ -440,7 +441,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,8 +464,8 @@ 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") + _settings->find("ROCPROFSYS_TIMEMORY_COMPONENTS") ->second->set_choices(_component_choices); } diff --git a/source/bin/omnitrace-avail/generate_config.hpp b/source/bin/rocprof-sys-avail/generate_config.hpp similarity index 100% rename from source/bin/omnitrace-avail/generate_config.hpp rename to source/bin/rocprof-sys-avail/generate_config.hpp diff --git a/source/bin/omnitrace-avail/get_availability.hpp b/source/bin/rocprof-sys-avail/get_availability.hpp similarity index 100% rename from source/bin/omnitrace-avail/get_availability.hpp rename to source/bin/rocprof-sys-avail/get_availability.hpp diff --git a/source/bin/omnitrace-avail/get_categories.hpp b/source/bin/rocprof-sys-avail/get_categories.hpp similarity index 100% rename from source/bin/omnitrace-avail/get_categories.hpp rename to source/bin/rocprof-sys-avail/get_categories.hpp diff --git a/source/bin/omnitrace-avail/info_type.cpp b/source/bin/rocprof-sys-avail/info_type.cpp similarity index 100% rename from source/bin/omnitrace-avail/info_type.cpp rename to source/bin/rocprof-sys-avail/info_type.cpp diff --git a/source/bin/omnitrace-avail/info_type.hpp b/source/bin/rocprof-sys-avail/info_type.hpp similarity index 100% rename from source/bin/omnitrace-avail/info_type.hpp rename to source/bin/rocprof-sys-avail/info_type.hpp diff --git a/source/bin/rocprof-sys-causal/CMakeLists.txt b/source/bin/rocprof-sys-causal/CMakeLists.txt new file mode 100644 index 00000000..8103a24c --- /dev/null +++ b/source/bin/rocprof-sys-causal/CMakeLists.txt @@ -0,0 +1,31 @@ +# ------------------------------------------------------------------------------# +# +# rocprofiler-systems-causal target +# +# ------------------------------------------------------------------------------# + +add_executable( + rocprofiler-systems-causal + ${CMAKE_CURRENT_LIST_DIR}/rocprof-sys-causal.cpp + ${CMAKE_CURRENT_LIST_DIR}/rocprof-sys-causal.hpp ${CMAKE_CURRENT_LIST_DIR}/impl.cpp) + +target_compile_definitions(rocprofiler-systems-causal PRIVATE TIMEMORY_CMAKE=1) +target_include_directories(rocprofiler-systems-causal PRIVATE ${CMAKE_CURRENT_LIST_DIR}) +target_link_libraries( + rocprofiler-systems-causal + PRIVATE rocprofiler-systems::rocprofiler-systems-compile-definitions + rocprofiler-systems::rocprofiler-systems-headers + rocprofiler-systems::rocprofiler-systems-common-library + rocprofiler-systems::rocprofiler-systems-core) +set_target_properties( + rocprofiler-systems-causal + PROPERTIES BUILD_RPATH "\$ORIGIN:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}" + INSTALL_RPATH "${ROCPROFSYS_EXE_INSTALL_RPATH}" + OUTPUT_NAME ${BINARY_NAME_PREFIX}-causal) + +rocprofiler_systems_strip_target(rocprofiler-systems-causal) + +install( + TARGETS rocprofiler-systems-causal + DESTINATION ${CMAKE_INSTALL_BINDIR} + OPTIONAL) diff --git a/source/bin/omnitrace-causal/impl.cpp b/source/bin/rocprof-sys-causal/impl.cpp similarity index 82% rename from source/bin/omnitrace-causal/impl.cpp rename to source/bin/rocprof-sys-causal/impl.cpp index 5e901fa4..be0da1ee 100644 --- a/source/bin/omnitrace-causal/impl.cpp +++ b/source/bin/rocprof-sys-causal/impl.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -20,7 +20,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include "omnitrace-causal.hpp" +#include "rocprof-sys-causal.hpp" #include "common/defines.h" #include "common/delimit.hpp" @@ -61,7 +61,7 @@ namespace filepath = ::tim::filepath; namespace console = ::tim::utility::console; namespace argparse = ::tim::argparse; using namespace ::timemory::join; -using ::omnitrace::utility::parse_numeric_range; +using ::rocprofsys::utility::parse_numeric_range; using ::tim::get_env; using ::tim::log::monochrome; using ::tim::log::stream; @@ -121,10 +121,10 @@ forward_signal(int sig) int get_verbose() { - verbose = get_env("OMNITRACE_CAUSAL_VERBOSE", - get_env("OMNITRACE_VERBOSE", verbose, false)); - auto _debug = - get_env("OMNITRACE_CAUSAL_DEBUG", get_env("OMNITRACE_DEBUG", false, false)); + verbose = get_env("ROCPROFSYS_CAUSAL_VERBOSE", + get_env("ROCPROFSYS_VERBOSE", verbose, false)); + auto _debug = get_env("ROCPROFSYS_CAUSAL_DEBUG", + get_env("ROCPROFSYS_DEBUG", false, false)); if(_debug) verbose += 8; return verbose; } @@ -151,13 +151,13 @@ remove_child_pid(pid_t _v) int wait_pid(pid_t _pid, int _opts) { - return ::omnitrace::mproc::wait_pid(_pid, _opts); + return ::rocprofsys::mproc::wait_pid(_pid, _opts); } int diagnose_status(pid_t _pid, int _status) { - return ::omnitrace::mproc::diagnose_status(_pid, _status, get_verbose()); + return ::rocprofsys::mproc::diagnose_status(_pid, _status, get_verbose()); } std::string @@ -194,15 +194,15 @@ get_initial_environment() } } - update_env(_env, "OMNITRACE_MODE", "causal"); - update_env(_env, "OMNITRACE_USE_CAUSAL", true); - update_env(_env, "OMNITRACE_USE_SAMPLING", false); - update_env(_env, "OMNITRACE_TRACE", false); - update_env(_env, "OMNITRACE_PROFILE", false); - 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, "ROCPROFSYS_MODE", "causal"); + update_env(_env, "ROCPROFSYS_USE_CAUSAL", true); + update_env(_env, "ROCPROFSYS_USE_SAMPLING", false); + update_env(_env, "ROCPROFSYS_TRACE", false); + update_env(_env, "ROCPROFSYS_PROFILE", false); + update_env(_env, "ROCPROFSYS_USE_PROCESS_SAMPLING", false); + update_env(_env, "ROCPROFSYS_THREAD_POOL_SIZE", + get_env("ROCPROFSYS_THREAD_POOL_SIZE", 0)); + update_env(_env, "ROCPROFSYS_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), "\"")); } @@ -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); } } @@ -256,7 +256,7 @@ get_internal_libpath(const std::string& _lib) auto _pos = _exe.find_last_of('/'); auto _dir = std::string{ "./" }; if(_pos != std::string_view::npos) _dir = _exe.substr(0, _pos); - return omnitrace::common::join("/", _dir, "..", "lib", _lib); + return rocprofsys::common::join("/", _dir, "..", "lib", _lib); } void @@ -277,7 +277,7 @@ print_updated_environment(std::vector _env, std::string_view _prefix) { if(itr == nullptr) continue; - auto _is_omni = (std::string_view{ itr }.find("OMNITRACE") == 0); + auto _is_omni = (std::string_view{ itr }.find("ROCPROFSYS") == 0); auto _updated = false; for(const auto& vitr : updated_envs) { @@ -343,13 +343,13 @@ update_env(std::vector& _environ, std::string_view _env_var, Tp&& _env_va else { free(itr); - itr = strdup(omnitrace::common::join('=', _env_var, _env_val).c_str()); + itr = strdup(rocprofsys::common::join('=', _env_var, _env_val).c_str()); } return; } } _environ.emplace_back( - strdup(omnitrace::common::join('=', _env_var, _env_val).c_str())); + strdup(rocprofsys::common::join('=', _env_var, _env_val).c_str())); } template @@ -365,7 +365,7 @@ add_default_env(std::vector& _environ, std::string_view _env_var, Tp&& _e updated_envs.emplace(_env_var); _environ.emplace_back( - strdup(omnitrace::common::join('=', _env_var, _env_val).c_str())); + strdup(rocprofsys::common::join('=', _env_var, _env_val).c_str())); } void @@ -419,24 +419,24 @@ 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 General tips: - - Insert progress points at hotspots in your code or use omnitrace's runtime instrumentation + - Insert progress points at hotspots in your code or use rocprof-sys'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) + - 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", ROCPROFSYS_ARGPARSE_VERSION_INFO); auto _cols = std::get<0>(console::get_columns()); if(_cols > parser.get_help_width() + 8) @@ -466,24 +466,24 @@ parse_args(int argc, char** argv, std::vector& _env, auto _monochrome = p.get("monochrome"); monochrome() = _monochrome; p.set_use_color(!_monochrome); - update_env(_env, "OMNITRACE_MONOCHROME", (_monochrome) ? "1" : "0"); + update_env(_env, "ROCPROFSYS_MONOCHROME", (_monochrome) ? "1" : "0"); update_env(_env, "MONOCHROME", (_monochrome) ? "1" : "0"); }); parser.add_argument({ "--debug" }, "Debug output") .max_count(1) .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_DEBUG", p.get("debug")); + update_env(_env, "ROCPROFSYS_DEBUG", p.get("debug")); }); parser.add_argument({ "-v", "--verbose" }, "Verbose output") .count(1) .action([&](parser_t& p) { auto _v = p.get("verbose"); verbose = _v; - update_env(_env, "OMNITRACE_VERBOSE", _v); + update_env(_env, "ROCPROFSYS_VERBOSE", _v); }); 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,11 +498,13 @@ 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 " - "-n 4 foo`. This ensures that the omnitrace library is LD_PRELOADed on the " + "the target) for causal profiling, e.g., `rocprof-sys-causal -l foo -- " + "mpirun " + "-n 4 foo`. This ensures that the rocprof-sys library is LD_PRELOADed on the " "proper target") .count(1) .dtype("executable") @@ -511,7 +513,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") @@ -526,7 +528,7 @@ parse_args(int argc, char** argv, std::vector& _env, "Do not activate default features which are recommended for causal " "profiling. For example: PID-tagging of output files and " "timestamped subdirectories are disabled by default. Kokkos tools " - "support is added by default (OMNITRACE_USE_KOKKOSP=ON) because, " + "support is added by default (ROCPROFSYS_USE_KOKKOSP=ON) because, " "for Kokkos applications, the Kokkos-Tools callbacks are used for " "progress points. Activation of OpenMP tools support is similar") .min_count(0) @@ -547,7 +549,7 @@ parse_args(int argc, char** argv, std::vector& _env, .choices({ "function", "line" }) .choice_alias("function", { "func" }) .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_CAUSAL_MODE", p.get("mode")); + update_env(_env, "ROCPROFSYS_CAUSAL_MODE", p.get("mode")); }); parser.add_argument({ "-b", "--backend" }, "Causal profiling sampling backend.") @@ -555,7 +557,7 @@ parse_args(int argc, char** argv, std::vector& _env, .dtype("string") .choices({ "auto", "perf", "timer" }) .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_CAUSAL_BACKEND", p.get("backend")); + update_env(_env, "ROCPROFSYS_CAUSAL_BACKEND", p.get("backend")); }); parser @@ -564,7 +566,7 @@ parse_args(int argc, char** argv, std::vector& _env, .min_count(1) .dtype("filename") .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_CAUSAL_FILE", p.get("output-name")); + update_env(_env, "ROCPROFSYS_CAUSAL_FILE", p.get("output-name")); }); bool _reset = false; @@ -582,7 +584,7 @@ parse_args(int argc, char** argv, std::vector& _env, .max_count(1) .dtype("bool") .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_CAUSAL_END_TO_END", p.get("end-to-end")); + update_env(_env, "ROCPROFSYS_CAUSAL_END_TO_END", p.get("end-to-end")); }); parser @@ -592,7 +594,7 @@ parse_args(int argc, char** argv, std::vector& _env, .count(1) .dtype("seconds") .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_CAUSAL_DELAY", p.get("wait")); + update_env(_env, "ROCPROFSYS_CAUSAL_DELAY", p.get("wait")); }); parser @@ -605,7 +607,7 @@ parse_args(int argc, char** argv, std::vector& _env, .count(1) .dtype("seconds") .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_CAUSAL_DURATION", p.get("duration")); + update_env(_env, "ROCPROFSYS_CAUSAL_DURATION", p.get("duration")); }); int64_t _niterations = 1; @@ -750,7 +752,7 @@ parse_args(int argc, char** argv, std::vector& _env, parser.end_group(); -#if OMNITRACE_HIP_VERSION > 0 && OMNITRACE_HIP_VERSION < 50300 +#if ROCPROFSYS_HIP_VERSION > 0 && ROCPROFSYS_HIP_VERSION < 50300 update_env(_env, "HSA_ENABLE_INTERRUPT", 0); #endif @@ -809,38 +811,38 @@ parse_args(int argc, char** argv, std::vector& _env, if(_add_defaults) { - add_default_env(_env, "OMNITRACE_TIME_OUTPUT", false); - add_default_env(_env, "OMNITRACE_USE_PID", false); - add_default_env(_env, "OMNITRACE_USE_KOKKOSP", true); + add_default_env(_env, "ROCPROFSYS_TIME_OUTPUT", false); + add_default_env(_env, "ROCPROFSYS_USE_PID", false); + add_default_env(_env, "ROCPROFSYS_USE_KOKKOSP", true); -#if defined(OMNITRACE_USE_OMPT) && OMNITRACE_USE_OMPT > 0 - add_default_env(_env, "OMNITRACE_USE_OMPT", true); +#if defined(ROCPROFSYS_USE_OMPT) && ROCPROFSYS_USE_OMPT > 0 + add_default_env(_env, "ROCPROFSYS_USE_OMPT", true); #endif -#if(defined(OMNITRACE_USE_MPI) && OMNITRACE_USE_MPI > 0) || \ - (defined(OMNITRACE_USE_MPI_HEADERS) && OMNITRACE_USE_MPI_HEADERS > 0) - add_default_env(_env, "OMNITRACE_USE_MPIP", true); +#if(defined(ROCPROFSYS_USE_MPI) && ROCPROFSYS_USE_MPI > 0) || \ + (defined(ROCPROFSYS_USE_MPI_HEADERS) && ROCPROFSYS_USE_MPI_HEADERS > 0) + add_default_env(_env, "ROCPROFSYS_USE_MPIP", true); #endif -#if defined(OMNITRACE_USE_ROCTRACER) && OMNITRACE_USE_ROCTRACER > 0 - add_default_env(_env, "OMNITRACE_ROCTRACER_HIP_API", true); - add_default_env(_env, "OMNITRACE_ROCTRACER_HSA_API", true); +#if defined(ROCPROFSYS_USE_ROCTRACER) && ROCPROFSYS_USE_ROCTRACER > 0 + add_default_env(_env, "ROCPROFSYS_ROCTRACER_HIP_API", true); + add_default_env(_env, "ROCPROFSYS_ROCTRACER_HSA_API", true); #endif -#if defined(OMNITRACE_USE_RCCL) && OMNITRACE_USE_RCCL > 0 - add_default_env(_env, "OMNITRACE_USE_RCCLP", true); +#if defined(ROCPROFSYS_USE_RCCL) && ROCPROFSYS_USE_RCCL > 0 + add_default_env(_env, "ROCPROFSYS_USE_RCCLP", true); #endif } - _fill("OMNITRACE_CAUSAL_BINARY_EXCLUDE", _binary_excludes, _generate_configs); - _fill("OMNITRACE_CAUSAL_SOURCE_EXCLUDE", _source_excludes, _generate_configs); - _fill("OMNITRACE_CAUSAL_FUNCTION_EXCLUDE", _function_excludes, _generate_configs); + _fill("ROCPROFSYS_CAUSAL_BINARY_EXCLUDE", _binary_excludes, _generate_configs); + _fill("ROCPROFSYS_CAUSAL_SOURCE_EXCLUDE", _source_excludes, _generate_configs); + _fill("ROCPROFSYS_CAUSAL_FUNCTION_EXCLUDE", _function_excludes, _generate_configs); - _fill("OMNITRACE_CAUSAL_BINARY_SCOPE", _binary_scopes, _generate_configs); - _fill("OMNITRACE_CAUSAL_SOURCE_SCOPE", _source_scopes, _generate_configs); - _fill("OMNITRACE_CAUSAL_FUNCTION_SCOPE", _function_scopes, _generate_configs); + _fill("ROCPROFSYS_CAUSAL_BINARY_SCOPE", _binary_scopes, _generate_configs); + _fill("ROCPROFSYS_CAUSAL_SOURCE_SCOPE", _source_scopes, _generate_configs); + _fill("ROCPROFSYS_CAUSAL_FUNCTION_SCOPE", _function_scopes, _generate_configs); - _fill("OMNITRACE_CAUSAL_FIXED_SPEEDUP", _virtual_speedups, false); + _fill("ROCPROFSYS_CAUSAL_FIXED_SPEEDUP", _virtual_speedups, false); // make sure at least one env exists if(_causal_envs_tmp.empty()) _causal_envs_tmp.emplace_back(); @@ -857,10 +859,10 @@ parse_args(int argc, char** argv, std::vector& _env, if(_generate_configs) { auto _is_omni_cfg = [](std::string_view itr) { - return (itr.find("OMNITRACE") == 0 && itr.find("OMNITRACE_MODE") != 0 && - itr.find("OMNITRACE_DEBUG_") != 0 && itr.find('=') < itr.length()); - // omnitrace has miscellaneous env options starting with OMNITRACE_DEBUG_ that - // are not official options + return (itr.find("ROCPROFSYS") == 0 && itr.find("ROCPROFSYS_MODE") != 0 && + itr.find("ROCPROFSYS_DEBUG_") != 0 && itr.find('=') < itr.length()); + // rocprof-sys has miscellaneous env options starting with ROCPROFSYS_DEBUG_ + // that are not official options }; auto _omni_env_m = std::map{}; @@ -879,9 +881,9 @@ parse_args(int argc, char** argv, std::vector& _env, _env.erase(std::remove_if(_env.begin(), _env.end(), _is_omni_cfg), _env.end()); auto _omni_env = std::vector>{}; - // make sure that OMNITRACE_CONFIG_FILE is the first entry + // make sure that ROCPROFSYS_CONFIG_FILE is the first entry { - auto citr = _omni_env_m.find("OMNITRACE_CONFIG_FILE"); + auto citr = _omni_env_m.find("ROCPROFSYS_CONFIG_FILE"); if(citr != _omni_env_m.end()) { _omni_env.emplace_back(citr->first, citr->second); @@ -903,12 +905,12 @@ parse_args(int argc, char** argv, std::vector& _env, for(const auto& itr : _data) _width = std::max(_width, itr.first.length()); - _os << "# omnitrace common settings\n"; + _os << "# rocprofsys common settings\n"; for(const auto& itr : _omni_env) _os << std::setw(_width + 1) << std::left << itr.first << " = " << itr.second << "\n"; - _os << "\n# omnitrace causal settings\n"; + _os << "\n# rocprofsys causal settings\n"; for(const auto& itr : _data) _os << std::setw(_width + 1) << std::left << itr.first << " = " << itr.second << "\n"; @@ -926,20 +928,20 @@ parse_args(int argc, char** argv, std::vector& _env, ? fname.str() : join(array_config{ ":" }, _config_file, fname.str()); auto _cfg = - std::map{ { "OMNITRACE_CONFIG_FILE", + std::map{ { "ROCPROFSYS_CONFIG_FILE", _cfg_name } }; _causal_envs.emplace_back(_cfg); } } if(_reset) - _causal_envs.front().emplace(std::string_view{ "OMNITRACE_CAUSAL_FILE_RESET" }, + _causal_envs.front().emplace(std::string_view{ "ROCPROFSYS_CAUSAL_FILE_RESET" }, std::string{ "true" }); return _outv; } -// explicit instantiation for usage in omnitrace-causal.cpp +// explicit instantiation for usage in rocprof-sys-causal.cpp template void update_env(std::vector&, std::string_view, const std::string& _env_val, bool _append, std::string_view); diff --git a/source/bin/omnitrace-causal/omnitrace-causal.cpp b/source/bin/rocprof-sys-causal/rocprof-sys-causal.cpp similarity index 97% rename from source/bin/omnitrace-causal/omnitrace-causal.cpp rename to source/bin/rocprof-sys-causal/rocprof-sys-causal.cpp index 3759d7eb..655c25c8 100644 --- a/source/bin/omnitrace-causal/omnitrace-causal.cpp +++ b/source/bin/rocprof-sys-causal/rocprof-sys-causal.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -20,7 +20,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include "omnitrace-causal.hpp" +#include "rocprof-sys-causal.hpp" #include diff --git a/source/bin/omnitrace-causal/omnitrace-causal.hpp b/source/bin/rocprof-sys-causal/rocprof-sys-causal.hpp similarity index 95% rename from source/bin/omnitrace-causal/omnitrace-causal.hpp rename to source/bin/rocprof-sys-causal/rocprof-sys-causal.hpp index 9e0dc529..a7277b1e 100644 --- a/source/bin/omnitrace-causal/omnitrace-causal.hpp +++ b/source/bin/rocprof-sys-causal/rocprof-sys-causal.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -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/bin/rocprof-sys-exe/CMakeLists.txt b/source/bin/rocprof-sys-exe/CMakeLists.txt new file mode 100644 index 00000000..329e8397 --- /dev/null +++ b/source/bin/rocprof-sys-exe/CMakeLists.txt @@ -0,0 +1,25 @@ +# ------------------------------------------------------------------------------# +# +# TODO: [DFG] Remove this file after 'rocprofsys' rebranding is complete +# rocprofiler-systems-exe target (deprecated 'omnitrace' executable, now 'rocprofiler-systems-instrument') +# +# ------------------------------------------------------------------------------# + +add_executable(rocprofiler-systems-exe ${CMAKE_CURRENT_LIST_DIR}/rocprof-sys.cpp) + +target_link_libraries(rocprofiler-systems-exe + PRIVATE rocprofiler-systems::rocprofiler-systems-threading) + +set_target_properties( + rocprofiler-systems-exe + PROPERTIES OUTPUT_NAME rocprof-sys + BUILD_RPATH "\$ORIGIN:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}" + INSTALL_RPATH "${ROCPROFSYS_EXE_INSTALL_RPATH}" + INSTALL_RPATH_USE_LINK_PATH ON) + +rocprofiler_systems_strip_target(rocprofiler-systems-exe) + +install( + TARGETS rocprofiler-systems-exe + DESTINATION ${CMAKE_INSTALL_BINDIR} + OPTIONAL) diff --git a/source/bin/omnitrace-exe/omnitrace.cpp b/source/bin/rocprof-sys-exe/rocprof-sys.cpp similarity index 90% rename from source/bin/omnitrace-exe/omnitrace.cpp rename to source/bin/rocprof-sys-exe/rocprof-sys.cpp index 215d5b50..5e9e1cdd 100644 --- a/source/bin/omnitrace-exe/omnitrace.cpp +++ b/source/bin/rocprof-sys-exe/rocprof-sys.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -66,17 +66,17 @@ main(int argc, char** argv) gggggg - OmniTrace has renamed the "omnitrace" executable to "omnitrace-instrument" to reduce confusion. + ROCm Systems Profiler has renamed the "rocprof-sys" executable to "rocprof-sys-instrument". 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. - If you are running this job non-interactively, we will resume executing after ~1 minute unless CI or OMNITRACE_CI is defined + If you are running this job non-interactively, we will resume executing after ~1 minute unless CI or ROCPROFSYS_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{}; @@ -94,11 +94,12 @@ main(int argc, char** argv) auto _env_failure = [_emit_warning, argv](std::string_view _env_var) { // emit warning _emit_warning(); - std::cerr << "[" << argv[0] << "] Detected " << _env_var - << " environment variable. Exiting to prevent consuming CI resources. " - "Use \"omnitrace-instrument\" executable instead of \"omnitrace\" " - "to prevent this error." - << std::endl; + std::cerr + << "[" << argv[0] << "] Detected " << _env_var + << " environment variable. Exiting to prevent consuming CI resources. " + "Use \"rocprof-sys-instrument\" executable instead of \"rocprof-sys\" " + "to prevent this error." + << std::endl; std::exit(EXIT_FAILURE); }; auto _wait_for_input = [&_completed, &_acknowledged, _emit_warning]() { @@ -116,7 +117,7 @@ main(int argc, char** argv) _completed.set_value(); }; - for(const auto* itr : { "CI", "OMNITRACE_CI" }) + for(const auto* itr : { "CI", "ROCPROFSYS_CI" }) { if(_get_env(itr)) _env_failure(itr); } diff --git a/source/bin/rocprof-sys-instrument/CMakeLists.txt b/source/bin/rocprof-sys-instrument/CMakeLists.txt new file mode 100644 index 00000000..ecacdbb9 --- /dev/null +++ b/source/bin/rocprof-sys-instrument/CMakeLists.txt @@ -0,0 +1,62 @@ +# ------------------------------------------------------------------------------# +# +# rocprofiler-systems-instrument target (formerly rocprofiler-systems-exe target prior to 1.8.1) +# +# ------------------------------------------------------------------------------# + +set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF) + +add_executable(rocprofiler-systems-instrument) + +target_sources( + rocprofiler-systems-instrument + PRIVATE ${CMAKE_CURRENT_LIST_DIR}/details.cpp + ${CMAKE_CURRENT_LIST_DIR}/function_signature.cpp + ${CMAKE_CURRENT_LIST_DIR}/function_signature.hpp + ${CMAKE_CURRENT_LIST_DIR}/fwd.hpp + ${CMAKE_CURRENT_LIST_DIR}/info.hpp + ${CMAKE_CURRENT_LIST_DIR}/internal_libs.cpp + ${CMAKE_CURRENT_LIST_DIR}/internal_libs.hpp + ${CMAKE_CURRENT_LIST_DIR}/log.cpp + ${CMAKE_CURRENT_LIST_DIR}/log.hpp + ${CMAKE_CURRENT_LIST_DIR}/module_function.cpp + ${CMAKE_CURRENT_LIST_DIR}/module_function.hpp + ${CMAKE_CURRENT_LIST_DIR}/rocprof-sys-instrument.cpp + ${CMAKE_CURRENT_LIST_DIR}/rocprof-sys-instrument.hpp) + +target_link_libraries( + rocprofiler-systems-instrument + PRIVATE rocprofiler-systems::rocprofiler-systems-headers + rocprofiler-systems::rocprofiler-systems-dyninst + rocprofiler-systems::rocprofiler-systems-compile-options + rocprofiler-systems::rocprofiler-systems-compile-definitions + rocprofiler-systems::rocprofiler-systems-sanitizer + timemory::timemory-headers + timemory::timemory-extensions + timemory::timemory-core) + +set_target_properties( + rocprofiler-systems-instrument + PROPERTIES BUILD_RPATH "\$ORIGIN:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}" + INSTALL_RPATH "${ROCPROFSYS_EXE_INSTALL_RPATH}" + INSTALL_RPATH_USE_LINK_PATH ON + OUTPUT_NAME ${BINARY_NAME_PREFIX}-instrument) + +if(ROCPROFSYS_BUILD_DYNINST) + target_compile_definitions(rocprofiler-systems-instrument + PRIVATE ROCPROFSYS_BUILD_DYNINST=1) +endif() + +add_target_flag_if_avail(rocprofiler-systems-instrument "-Wno-deprecated-declarations") + +rocprofiler_systems_strip_target(rocprofiler-systems-instrument) + +if(CMAKE_BUILD_TYPE MATCHES "^(DEBUG|Debug)") + string(REPLACE " " ";" _FLAGS "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") + target_compile_options(rocprofiler-systems-instrument PRIVATE ${_FLAGS}) +endif() + +install( + TARGETS rocprofiler-systems-instrument + DESTINATION ${CMAKE_INSTALL_BINDIR} + OPTIONAL) diff --git a/source/bin/omnitrace-instrument/details.cpp b/source/bin/rocprof-sys-instrument/details.cpp similarity index 95% rename from source/bin/omnitrace-instrument/details.cpp rename to source/bin/rocprof-sys-instrument/details.cpp index 24d231b6..eab3b610 100644 --- a/source/bin/omnitrace-instrument/details.cpp +++ b/source/bin/rocprof-sys-instrument/details.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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,7 +23,7 @@ #include "function_signature.hpp" #include "fwd.hpp" #include "log.hpp" -#include "omnitrace-instrument.hpp" +#include "rocprof-sys-instrument.hpp" #include #include @@ -216,7 +216,7 @@ get_func_file_line_info(module_t* module, procedure_t* func) { using address_t = Dyninst::Address; - OMNITRACE_ADD_LOG_ENTRY("Getting function line info for", get_name(func)); + ROCPROFSYS_ADD_LOG_ENTRY("Getting function line info for", get_name(func)); auto _file_name = get_name(module); auto _func_name = get_name(func); @@ -249,7 +249,7 @@ function_signature get_loop_file_line_info(module_t* module, procedure_t* func, flow_graph_t*, basic_loop_t* loopToInstrument) { - OMNITRACE_ADD_LOG_ENTRY("Getting loop line info for", get_name(func)); + ROCPROFSYS_ADD_LOG_ENTRY("Getting loop line info for", get_name(func)); auto basic_blocks = std::vector{}; loopToInstrument->getLoopBasicBlocksExclusive(basic_blocks); @@ -343,7 +343,7 @@ get_basic_block_file_line_info(module_t* module, procedure_t* func) std::map _data{}; if(!func) return _data; - OMNITRACE_ADD_LOG_ENTRY("Getting basic block line info for", get_name(func)); + ROCPROFSYS_ADD_LOG_ENTRY("Getting basic block line info for", get_name(func)); auto* _cfg = func->getCFG(); auto _basic_blocks = std::set{}; @@ -421,7 +421,7 @@ get_basic_block_file_line_info(module_t* module, procedure_t* func) std::vector get_source_code(module_t* module, procedure_t* func) { - OMNITRACE_ADD_LOG_ENTRY("Getting source code for", get_name(func)); + ROCPROFSYS_ADD_LOG_ENTRY("Getting source code for", get_name(func)); std::vector _lines{}; if(!module || !func) return _lines; @@ -523,15 +523,15 @@ is_text_file(const std::string& filename) // Get the realpath to this exe // std::string& -omnitrace_get_exe_realpath() +rocprofsys_get_exe_realpath() { static std::string _v = []() { auto _cmd_line = tim::read_command_line(tim::process::get_id()); if(!_cmd_line.empty()) { using array_config_t = timemory::join::array_config; - OMNITRACE_ADD_DETAILED_LOG_ENTRY(array_config_t{ " ", "[ ", " ]" }, - "cmdline:: ", _cmd_line); + ROCPROFSYS_ADD_DETAILED_LOG_ENTRY(array_config_t{ " ", "[ ", " ]" }, + "cmdline:: ", _cmd_line); return _cmd_line.front(); // return tim::filepath::realpath(_cmd_line.front(), nullptr, false); } @@ -545,8 +545,8 @@ omnitrace_get_exe_realpath() // Error callback routine. // std::vector -omnitrace_get_link_map(const char* _lib, const std::string& _exclude_linked_by, - const std::string& _exclude_re, std::vector&& _open_modes) +rocprofsys_get_link_map(const char* _lib, const std::string& _exclude_linked_by, + const std::string& _exclude_re, std::vector&& _open_modes) { if(_open_modes.empty()) _open_modes = { (RTLD_LAZY | RTLD_NOLOAD) }; @@ -573,7 +573,7 @@ omnitrace_get_link_map(const char* _lib, const std::string& _exclude_linked_by, { // only insert exe name if dlopened the exe and // empty name is first entry - _chain.emplace_back(omnitrace_get_exe_realpath()); + _chain.emplace_back(rocprofsys_get_exe_realpath()); } else if(!std::string_view{ _next->l_name }.empty()) { @@ -615,7 +615,7 @@ omnitrace_get_link_map(const char* _lib, const std::string& _exclude_linked_by, // Get the path of a loaded dynamic binary // std::optional -omnitrace_get_loaded_path(const char* _name, std::vector&& _open_modes) +rocprofsys_get_loaded_path(const char* _name, std::vector&& _open_modes) { if(_open_modes.empty()) _open_modes = { (RTLD_LAZY | RTLD_NOLOAD) }; @@ -647,7 +647,7 @@ omnitrace_get_loaded_path(const char* _name, std::vector&& _open_modes) // Get the path of a loaded dynamic binary // std::optional -omnitrace_get_origin(const char* _name, std::vector&& _open_modes) +rocprofsys_get_origin(const char* _name, std::vector&& _open_modes) { if(_open_modes.empty()) _open_modes = { (RTLD_LAZY | RTLD_NOLOAD) }; @@ -695,8 +695,8 @@ error_func_real(error_level_t level, int num, const char* const* params) const char* msg = bpatch->getEnglishErrorString(num); bpatch->formatErrorString(line, sizeof(line), msg, params); - OMNITRACE_ADD_LOG_ENTRY("Dyninst error function called with level", level, - ":: ID# =", num, "::", line) + ROCPROFSYS_ADD_LOG_ENTRY("Dyninst error function called with level", level, + ":: ID# =", num, "::", line) .force(level < BPatchInfo); if(num == 0) @@ -742,8 +742,8 @@ error_func_fake(error_level_t level, int num, const char* const* params) bpatch->formatErrorString(line, sizeof(line), msg, params); // just log it - OMNITRACE_ADD_LOG_ENTRY("Dyninst error function called with level", level, - ":: ID# =", num, "::", line) + ROCPROFSYS_ADD_LOG_ENTRY("Dyninst error function called with level", level, + ":: ID# =", num, "::", line) .force(level < BPatchInfo); } diff --git a/source/bin/omnitrace-instrument/function_signature.cpp b/source/bin/rocprof-sys-instrument/function_signature.cpp similarity index 100% rename from source/bin/omnitrace-instrument/function_signature.cpp rename to source/bin/rocprof-sys-instrument/function_signature.cpp diff --git a/source/bin/omnitrace-instrument/function_signature.hpp b/source/bin/rocprof-sys-instrument/function_signature.hpp similarity index 100% rename from source/bin/omnitrace-instrument/function_signature.hpp rename to source/bin/rocprof-sys-instrument/function_signature.hpp diff --git a/source/bin/omnitrace-instrument/fwd.hpp b/source/bin/rocprof-sys-instrument/fwd.hpp similarity index 95% rename from source/bin/omnitrace-instrument/fwd.hpp rename to source/bin/rocprof-sys-instrument/fwd.hpp index acff922b..6ddaf1f5 100644 --- a/source/bin/omnitrace-instrument/fwd.hpp +++ b/source/bin/rocprof-sys-instrument/fwd.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -162,7 +162,7 @@ constexpr auto SV_END_V = std::max({ SV_UNKNOWN, SV_DEFAULT, SV_INTERNAL, SV_HIDDEN, SV_PROTECTED }) + 1; void -omnitrace_prefork_callback(thread_t* parent, thread_t* child); +rocprofsys_prefork_callback(thread_t* parent, thread_t* child); enum CodeCoverageMode { @@ -268,19 +268,19 @@ extern std::unique_ptr log_ofs; { \ char _logmsgbuff[FUNCNAMELEN]; \ snprintf(_logmsgbuff, FUNCNAMELEN, __VA_ARGS__); \ - OMNITRACE_ADD_LOG_ENTRY(_logmsgbuff); \ + ROCPROFSYS_ADD_LOG_ENTRY(_logmsgbuff); \ if(werror || LEVEL < 0) \ { \ if(debug_print || verbose_level >= LEVEL) \ - fprintf(stderr, "[omnitrace][exe] Error! " __VA_ARGS__); \ + fprintf(stderr, "[rocprof-sys][exe] Error! " __VA_ARGS__); \ char _buff[FUNCNAMELEN]; \ - sprintf(_buff, "[omnitrace][exe] Error! " __VA_ARGS__); \ + sprintf(_buff, "[rocprof-sys][exe] Error! " __VA_ARGS__); \ throw std::runtime_error(std::string{ _buff }); \ } \ else \ { \ if(debug_print || verbose_level >= LEVEL) \ - fprintf(stderr, "[omnitrace][exe] Warning! " __VA_ARGS__); \ + fprintf(stderr, "[rocprof-sys][exe] Warning! " __VA_ARGS__); \ } \ fflush(stderr); \ } @@ -290,9 +290,9 @@ extern std::unique_ptr log_ofs; { \ char _logmsgbuff[FUNCNAMELEN]; \ snprintf(_logmsgbuff, FUNCNAMELEN, __VA_ARGS__); \ - OMNITRACE_ADD_LOG_ENTRY(_logmsgbuff); \ + ROCPROFSYS_ADD_LOG_ENTRY(_logmsgbuff); \ if(debug_print || verbose_level >= LEVEL) \ - fprintf(stdout, "[omnitrace][exe] " __VA_ARGS__); \ + fprintf(stdout, "[rocprof-sys][exe] " __VA_ARGS__); \ fflush(stdout); \ } @@ -300,7 +300,7 @@ extern std::unique_ptr log_ofs; { \ char _logmsgbuff[FUNCNAMELEN]; \ snprintf(_logmsgbuff, FUNCNAMELEN, __VA_ARGS__); \ - OMNITRACE_ADD_LOG_ENTRY(_logmsgbuff); \ + ROCPROFSYS_ADD_LOG_ENTRY(_logmsgbuff); \ if(debug_print || verbose_level >= LEVEL) fprintf(stdout, __VA_ARGS__); \ fflush(stdout); \ } diff --git a/source/bin/omnitrace-instrument/info.hpp b/source/bin/rocprof-sys-instrument/info.hpp similarity index 92% rename from source/bin/omnitrace-instrument/info.hpp rename to source/bin/rocprof-sys-instrument/info.hpp index 2b24223a..f2b756d0 100644 --- a/source/bin/omnitrace-instrument/info.hpp +++ b/source/bin/rocprof-sys-instrument/info.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -70,7 +70,7 @@ dump_info(const string_t& _label, string_t _oname, const string_t& _ext, _msg << "[dump_info] Error opening '" << _oname << " for output"; verbprintf(_level, "%s\n", _msg.str().c_str()); if(_fail) - throw std::runtime_error(std::string{ "[omnitrace][exe]" } + _msg.str()); + throw std::runtime_error(std::string{ "[rocprof-sys][exe]" } + _msg.str()); }; if(!debug_print && verbose_level < _level) return; @@ -97,7 +97,7 @@ dump_info(const string_t& _label, string_t _oname, const string_t& _ext, output_policy::indent() = true; auto ar = output_policy::get(oss); - ar->setNextName("omnitrace"); + ar->setNextName("rocprofsys"); ar->startNode(); ar->setNextName(_label.c_str()); ar->startNode(); @@ -125,7 +125,7 @@ dump_info(const string_t& _label, string_t _oname, const string_t& _ext, using output_policy = policy::output_archive; auto ar = output_policy::get(oss); - ar->setNextName("omnitrace"); + ar->setNextName("rocprofsys"); ar->startNode(); ar->setNextName(_label.c_str()); ar->startNode(); @@ -149,7 +149,7 @@ dump_info(const string_t& _label, string_t _oname, const string_t& _ext, else { throw std::runtime_error(TIMEMORY_JOIN( - "", "[omnitrace][exe] Error in ", __FUNCTION__, " :: filename '", _oname, + "", "[rocprof-sys][exe] Error in ", __FUNCTION__, " :: filename '", _oname, "' does not have one of recognized file extensions: txt, json, xml")); } } @@ -176,7 +176,7 @@ load_info(const string_t& _label, const string_t& _iname, fmodset_t& _data, int std::stringstream _msg{}; _msg << "[load_info] Error opening '" << _iname << " for input"; verbprintf(_level, "%s\n", _msg.str().c_str()); - throw std::runtime_error(std::string{ "[omnitrace][exe]" } + _msg.str()); + throw std::runtime_error(std::string{ "[rocprof-sys][exe]" } + _msg.str()); }; if(_ext == "xml") @@ -190,7 +190,7 @@ load_info(const string_t& _label, const string_t& _iname, fmodset_t& _data, int using input_policy = policy::input_archive; auto ar = input_policy::get(ifs); - ar->setNextName("omnitrace"); + ar->setNextName("rocprofsys"); ar->startNode(); ar->setNextName(_label.c_str()); ar->startNode(); @@ -212,7 +212,7 @@ load_info(const string_t& _label, const string_t& _iname, fmodset_t& _data, int using input_policy = policy::input_archive; auto ar = input_policy::get(ifs); - ar->setNextName("omnitrace"); + ar->setNextName("rocprofsys"); ar->startNode(); ar->setNextName(_label.c_str()); ar->startNode(); @@ -226,7 +226,7 @@ load_info(const string_t& _label, const string_t& _iname, fmodset_t& _data, int else { throw std::runtime_error(TIMEMORY_JOIN( - "", "[omnitrace][exe] Error in ", __FUNCTION__, " :: filename '", _iname, + "", "[rocprof-sys][exe] Error in ", __FUNCTION__, " :: filename '", _iname, "' does not have one of recognized extentions: txt, json, xml :: ", _ext)); } } @@ -257,7 +257,7 @@ load_info(const string_t& _inp, std::map& _data, int _l std::stringstream _msg{}; for(auto& itr : _exceptions) { - _msg << "[omnitrace][exe] " << itr << "\n"; + _msg << "[rocprof-sys][exe] " << itr << "\n"; } throw std::runtime_error(_msg.str()); } diff --git a/source/bin/omnitrace-instrument/internal_libs.cpp b/source/bin/rocprof-sys-instrument/internal_libs.cpp similarity index 97% rename from source/bin/omnitrace-instrument/internal_libs.cpp rename to source/bin/rocprof-sys-instrument/internal_libs.cpp index b8ebb7d0..3bda7669 100644 --- a/source/bin/omnitrace-instrument/internal_libs.cpp +++ b/source/bin/rocprof-sys-instrument/internal_libs.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -199,9 +199,9 @@ get_library_search_paths_impl() for(const auto& itr : delimit(get_env("LD_LIBRARY_PATH", std::string{}, false), ":")) _emplace_if_exists(itr); - for(const auto& itr : { get_env("OMNITRACE_ROCM_PATH", ""), + for(const auto& itr : { get_env("ROCPROFSYS_ROCM_PATH", ""), get_env("ROCM_PATH", ""), - std::string{ OMNITRACE_DEFAULT_ROCM_PATH } }) + std::string{ ROCPROFSYS_DEFAULT_ROCM_PATH } }) { if(!itr.empty()) { @@ -311,7 +311,7 @@ get_internal_basic_libs_impl() "libbz2.so", "liblzma.so" }; - // shared libraries used by omnitrace + // shared libraries used by rocprof-sys const auto _omni_libs = strview_init_t{ "libstdc++.so.6", "libgotcha.so", "libunwind-coredump.so", "libunwind-generic.so", "libunwind-ptrace.so", "libunwind-setjmp.so", @@ -411,16 +411,16 @@ get_internal_libs_data_impl() auto _libs = std::vector{}; _libs.assign(_libs_v.begin(), _libs_v.end()); - auto _omnitrace_base_path = filepath::dirname( + auto _rocprofsys_base_path = filepath::dirname( filepath::dirname(filepath::realpath("/proc/self/exe", nullptr, false))); - auto _omnitrace_lib_path = std::string{}; + auto _rocprofsys_lib_path = std::string{}; 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); + auto _libpath = join('/', _rocprofsys_base_path, itr, litr); if(filepath::exists(_libpath)) { _libs.emplace_back(filepath::realpath(_libpath, nullptr, false)); @@ -428,7 +428,7 @@ get_internal_libs_data_impl() } } - omnitrace::utility::filter_sort_unique( + rocprofsys::utility::filter_sort_unique( _libs, [](const auto& itr) { return itr.empty() || !filepath::exists(itr); }); auto _data = library_module_map_t{}; diff --git a/source/bin/omnitrace-instrument/internal_libs.hpp b/source/bin/rocprof-sys-instrument/internal_libs.hpp similarity index 100% rename from source/bin/omnitrace-instrument/internal_libs.hpp rename to source/bin/rocprof-sys-instrument/internal_libs.hpp diff --git a/source/bin/omnitrace-instrument/log.cpp b/source/bin/rocprof-sys-instrument/log.cpp similarity index 100% rename from source/bin/omnitrace-instrument/log.cpp rename to source/bin/rocprof-sys-instrument/log.cpp diff --git a/source/bin/omnitrace-instrument/log.hpp b/source/bin/rocprof-sys-instrument/log.hpp similarity index 94% rename from source/bin/omnitrace-instrument/log.hpp rename to source/bin/rocprof-sys-instrument/log.hpp index beb19528..30960de7 100644 --- a/source/bin/omnitrace-instrument/log.hpp +++ b/source/bin/rocprof-sys-instrument/log.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -81,12 +81,12 @@ struct log_entry bool); }; -#define OMNITRACE_ADD_LOG_ENTRY(...) \ +#define ROCPROFSYS_ADD_LOG_ENTRY(...) \ log_entry::add_log_entry( \ { log_entry::source_location{ __FUNCTION__, __FILE__, __LINE__ }, \ timemory::join::join(' ', __VA_ARGS__) }) -#define OMNITRACE_ADD_DETAILED_LOG_ENTRY(DELIM, ...) \ +#define ROCPROFSYS_ADD_DETAILED_LOG_ENTRY(DELIM, ...) \ log_entry::add_log_entry( \ { log_entry::source_location{ __FUNCTION__, __FILE__, __LINE__ }, \ timemory::join::join(DELIM, __VA_ARGS__) }) diff --git a/source/bin/omnitrace-instrument/module_function.cpp b/source/bin/rocprof-sys-instrument/module_function.cpp similarity index 93% rename from source/bin/omnitrace-instrument/module_function.cpp rename to source/bin/rocprof-sys-instrument/module_function.cpp index 5b857c17..12ec7afd 100644 --- a/source/bin/omnitrace-instrument/module_function.cpp +++ b/source/bin/rocprof-sys-instrument/module_function.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -25,7 +25,7 @@ #include "fwd.hpp" #include "internal_libs.hpp" #include "log.hpp" -#include "omnitrace-instrument.hpp" +#include "rocprof-sys-instrument.hpp" #include @@ -64,7 +64,8 @@ module_function::module_function(module_t* mod, procedure_t* proc) , module_name{ get_name(module) } , function_name{ get_name(function) } { - OMNITRACE_ADD_LOG_ENTRY("Adding function", function_name, "from module", module_name); + ROCPROFSYS_ADD_LOG_ENTRY("Adding function", function_name, "from module", + module_name); if(!function->isInstrumentable()) { @@ -444,16 +445,19 @@ module_function::is_internal_constrained() const auto _module_base = _basename(module_name); auto _module_real = _realpath(module_name); - if(std::regex_search(module_name, std::regex{ "lib(omnitrace|timemory|perfetto)" })) - return _report("Excluding", "module", "omnitrace", 3); + if(std::regex_search(module_name, + std::regex{ "lib(rocprof-sys|rocprofsys|timemory|perfetto)" })) + return _report("Excluding", "module", "rocprofsys", 3); else if(std::regex_match(module_name, std::regex{ ".*/source/lib/" - "(core|common|binary|omnitrace|omnitrace-dl|" - "omnitrace-user)/.*/.*\\.(h|c|cpp|hpp)$" })) - return _report("Excluding", "module", "omnitrace", 3); - - if(std::regex_search(function_name, std::regex{ "9omnitrace|omnitrace(::|_)" })) - return _report("Excluding", "function", "omnitrace", 3); + "(core|common|binary|" + "rocprofsys|rocprofsys-dl|" + "rocprofsys-user)/.*/.*\\.(h|c|cpp|hpp)$" })) + return _report("Excluding", "module", "rocprofsys", 3); + + if(std::regex_search(function_name, + std::regex{ "10rocprofsys|rocprofsys|rocprofsys(::|_)" })) + return _report("Excluding", "function", "rocprofsys", 3); else if(std::regex_search(function_name, std::regex{ "3tim|tim::|timemory(::|_)" })) return _report("Excluding", "function", "timemory", 3); else if(std::regex_search(function_name, std::regex{ "9perfetto|perfetto(::|_)" })) @@ -507,7 +511,8 @@ module_function::is_module_constrained() const static std::regex sys_build_regex{ "^(\\.\\./sysdeps/|/build/)", regex_opts }; static std::regex dyninst_regex{ "(dyninst|DYNINST|(^|/)RT[[:graph:]]+\\.c$)", regex_opts }; - static std::regex dependlib_regex{ "^(lib|)(omnitrace|pthread|caliper|gotcha|papi|" + static std::regex dependlib_regex{ "^(lib|)(rocprof-sys|rocprofsys|" + "pthread|caliper|gotcha|papi|" "cupti|TAU|likwid|pfm|nvperf|unwind)", regex_opts }; static std::regex core_cmod_regex{ @@ -529,12 +534,12 @@ module_function::is_module_constrained() const if(std::regex_search(module_name, dyninst_regex)) return _report("Excluding", "dyninst module", 3); - // modules used by omnitrace and dependent libraries + // modules used by rocprof-sys and dependent libraries if(std::regex_search(module_name, core_lib_regex) || std::regex_search(module_name, core_cmod_regex)) return _report("Excluding", "core module", 3); - // modules used by omnitrace and dependent libraries + // modules used by rocprof-sys and dependent libraries if(std::regex_search(module_name, dependlib_regex)) return _report("Excluding", "dependency module", 3); @@ -556,9 +561,9 @@ module_function::is_routine_constrained() const }; auto npos = std::string::npos; - if(function_name.find("omnitrace") != npos) + if(function_name.find("rocprofsys") != npos) { - return _report("Skipping", "omnitrace-function", 1); + return _report("Skipping", "rocprofsys-function", 1); } if(function_name.find("FunctionInfo") != npos || @@ -567,8 +572,9 @@ module_function::is_routine_constrained() const return _report("Skipping", "function-constraint", 2); } - static std::regex exclude( - "(omnitrace|tim::|MPI_Init|MPI_Finalize|dyninst|DYNINST|tm_clones)", regex_opts); + static std::regex exclude("(rocprofsys|rocprof-sys|tim::|MPI_Init|MPI_" + "Finalize|dyninst|DYNINST|tm_clones)", + regex_opts); // static std::regex exclude_printf("(|v|f)printf$", regex_opts); static std::regex exclude_cxx( "(std::_Sp_counted_base|std::(use|has)_facet|std::locale|::sentry|^std::_|::_(M|" @@ -866,8 +872,8 @@ module_function::operator()(address_space_t* _addr_space, procedure_t* _entr_tra if(!function || !module) return _count; auto _name = signature.get(); - auto _trace_entr = omnitrace_call_expr(_name.c_str()); - auto _trace_exit = omnitrace_call_expr(_name.c_str()); + auto _trace_entr = rocprofsys_call_expr(_name.c_str()); + auto _trace_exit = rocprofsys_call_expr(_name.c_str()); auto _entr = _trace_entr.get(_entr_trace); auto _exit = _trace_exit.get(_exit_trace); @@ -917,8 +923,8 @@ module_function::operator()(address_space_t* _addr_space, procedure_t* _entr_tra "loop-exit-point-trap-instrumentation", _lname)) continue; - auto _ltrace_entr = omnitrace_call_expr(_lname.c_str()); - auto _ltrace_exit = omnitrace_call_expr(_lname.c_str()); + auto _ltrace_entr = rocprofsys_call_expr(_lname.c_str()); + auto _ltrace_exit = rocprofsys_call_expr(_lname.c_str()); auto _lentr = _ltrace_entr.get(_entr_trace); auto _lexit = _ltrace_exit.get(_exit_trace); @@ -946,8 +952,8 @@ module_function::register_source(address_space_t* _addr_space, procedure_t* _ent { auto _name = signature.get_coverage(false); auto _trace_entr = - omnitrace_call_expr(signature.m_file, signature.m_name, - signature.m_row.first, start_address, _name); + rocprofsys_call_expr(signature.m_file, signature.m_name, + signature.m_row.first, start_address, _name); auto _entr = _trace_entr.get(_entr_trace); if(insert_instr(_addr_space, _entr_points, _entr, BPatch_entry)) @@ -965,8 +971,8 @@ module_function::register_source(address_space_t* _addr_space, procedure_t* _ent auto& _signature = itr.second.signature; auto _name = _signature.get_coverage(true); auto _trace_entr = - omnitrace_call_expr(_signature.m_file, _signature.m_name, - _signature.m_row.first, _start_addr, _name); + rocprofsys_call_expr(_signature.m_file, _signature.m_name, + _signature.m_row.first, _start_addr, _name); auto _entr = _trace_entr.get(_entr_trace); if(insert_instr(_addr_space, _entr_points, _entr, BPatch_entry)) @@ -991,7 +997,7 @@ module_function::register_coverage(address_space_t* _addr_space, case CODECOV_FUNCTION: { auto _trace_entr = - omnitrace_call_expr(signature.m_file, signature.m_name, start_address); + rocprofsys_call_expr(signature.m_file, signature.m_name, start_address); auto _entr = _trace_entr.get(_entr_trace); if(insert_instr(_addr_space, function, _entr, BPatch_entry)) @@ -1008,8 +1014,8 @@ module_function::register_coverage(address_space_t* _addr_space, { auto _start_addr = itr.second.start_address; auto& _signature = itr.second.signature; - auto _trace_entr = omnitrace_call_expr(_signature.m_file, - _signature.m_name, _start_addr); + auto _trace_entr = rocprofsys_call_expr(_signature.m_file, + _signature.m_name, _start_addr); auto _entr = _trace_entr.get(_entr_trace); if(insert_instr(_addr_space, _entr, BPatch_entry, itr.first)) diff --git a/source/bin/omnitrace-instrument/module_function.hpp b/source/bin/rocprof-sys-instrument/module_function.hpp similarity index 100% rename from source/bin/omnitrace-instrument/module_function.hpp rename to source/bin/rocprof-sys-instrument/module_function.hpp diff --git a/source/bin/omnitrace-instrument/omnitrace-instrument.cpp b/source/bin/rocprof-sys-instrument/rocprof-sys-instrument.cpp similarity index 90% rename from source/bin/omnitrace-instrument/omnitrace-instrument.cpp rename to source/bin/rocprof-sys-instrument/rocprof-sys-instrument.cpp index 91844e90..93a2da5a 100644 --- a/source/bin/omnitrace-instrument/omnitrace-instrument.cpp +++ b/source/bin/rocprof-sys-instrument/rocprof-sys-instrument.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -20,7 +20,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include "omnitrace-instrument.hpp" +#include "rocprof-sys-instrument.hpp" #include "common/defines.h" #include "common/join.hpp" #include "dl/dl.hpp" @@ -65,12 +65,12 @@ #include #include -#if !defined(OMNITRACE_USE_MPI) -# define OMNITRACE_USE_MPI 0 +#if !defined(ROCPROFSYS_USE_MPI) +# define ROCPROFSYS_USE_MPI 0 #endif -#if !defined(OMNITRACE_USE_MPI_HEADERS) -# define OMNITRACE_USE_MPI_HEADERS 0 +#if !defined(ROCPROFSYS_USE_MPI_HEADERS) +# define ROCPROFSYS_USE_MPI_HEADERS 0 #endif namespace @@ -79,7 +79,7 @@ auto get_default_min_instructions() { // default to 1024 - return tim::get_env("OMNITRACE_DEFAULT_MIN_INSTRUCTIONS", (1 << 10), false); + return tim::get_env("ROCPROFSYS_DEFAULT_MIN_INSTRUCTIONS", (1 << 10), false); } auto get_default_min_address_range() @@ -89,7 +89,7 @@ get_default_min_address_range() } } // namespace -using InstrumentMode = ::omnitrace::dl::InstrumentMode; +using InstrumentMode = ::rocprofsys::dl::InstrumentMode; bool use_return_info = false; bool use_args_info = false; @@ -111,9 +111,9 @@ bool instr_print = false; bool simulate = false; bool include_uninstr = false; bool include_internal_linked_libs = false; -int verbose_level = tim::get_env("OMNITRACE_VERBOSE_INSTRUMENT", 0); +int verbose_level = tim::get_env("ROCPROFSYS_VERBOSE_INSTRUMENT", 0); int num_log_entries = tim::get_env( - "OMNITRACE_LOG_COUNT", tim::get_env("OMNITRACE_CI", false) ? 20 : 50); + "ROCPROFSYS_LOG_COUNT", tim::get_env("ROCPROFSYS_CI", false) ? 20 : 50); string_t main_fname = "main"; string_t argv0 = {}; string_t cmdv0 = {}; @@ -195,7 +195,7 @@ get_internal_libpath() auto _pos = _exe.find_last_of('/'); auto _dir = std::string{ "./" }; if(_pos != std::string_view::npos) _dir = _exe.substr(0, _pos); - return omnitrace::common::join("/", _dir, "..", "lib"); + return rocprofsys::common::join("/", _dir, "..", "lib"); } strvec_t lib_search_paths = tim::delimit( @@ -206,7 +206,7 @@ strvec_t lib_search_paths = tim::delimit( strvec_t bin_search_paths = tim::delimit(tim::get_env("PATH"), ":"); auto _dyn_api_rt_paths = tim::delimit( - JOIN(":", get_internal_libpath(), JOIN("/", get_internal_libpath(), "omnitrace")), + JOIN(":", get_internal_libpath(), JOIN("/", get_internal_libpath(), "rocprofsys")), ":"); std::string @@ -250,7 +250,7 @@ activate_signal_handlers(const std::vector& _signals) if(_protect) return; _protect = true; TIMEMORY_PRINTF_FATAL( - stderr, "omnitrace exited with signal %i :: %s\n", nsig, + stderr, "rocprof-sys exited with signal %i :: %s\n", nsig, signal_settings::str(static_cast(nsig)).c_str()); // print any forced entries @@ -258,7 +258,7 @@ activate_signal_handlers(const std::vector& _signals) std::cerr, -1, [](const auto& _v) { return _v.forced(); }, []() { tim::log::stream(std::cerr, tim::log::color::info()) - << "\n[omnitrace][exe] Potentially important log entries:\n\n"; + << "\n[rocprof-sys][exe] Potentially important log entries:\n\n"; }); // print the last log entries @@ -267,8 +267,8 @@ activate_signal_handlers(const std::vector& _signals) TIMEMORY_PRINTF_FATAL(stderr, "\n"); TIMEMORY_PRINTF_FATAL( stderr, - "These were the last %i log entries from omnitrace. You can control the " - "number of log entries via the '--log ' option or OMNITRACE_LOG_COUNT " + "These were the last %i log entries from rocprof-sys. You can control the " + "number of log entries via the '--log ' option or ROCPROFSYS_LOG_COUNT " "env variable.\n", num_log_entries); @@ -311,40 +311,51 @@ main(int argc, char** argv) argv0 = argv[0]; auto _omni_root = tim::get_env( - "omnitrace_ROOT", tim::get_env("OMNITRACE_ROOT", "")); + "rocprofiler_systems_ROOT", tim::get_env("ROCPROFSYS_ROOT", "")); if(!_omni_root.empty() && exists(_omni_root)) { bin_search_paths.emplace_back(JOIN('/', _omni_root, "bin")); - bin_search_paths.emplace_back(JOIN('/', _omni_root, "lib", "omnitrace")); - bin_search_paths.emplace_back(JOIN('/', _omni_root, "lib", "omnitrace", "bin")); + bin_search_paths.emplace_back( + JOIN('/', _omni_root, "lib", "rocprofiler-systems")); + bin_search_paths.emplace_back( + JOIN('/', _omni_root, "lib", "rocprofiler-systems", "bin")); lib_search_paths.emplace_back(JOIN('/', _omni_root, "lib")); - lib_search_paths.emplace_back(JOIN('/', _omni_root, "lib", "omnitrace")); - lib_search_paths.emplace_back(JOIN('/', _omni_root, "lib", "omnitrace", "lib")); - lib_search_paths.emplace_back(JOIN('/', _omni_root, "lib", "omnitrace", "lib64")); - OMNITRACE_ADD_LOG_ENTRY(argv[0], "::", "omnitrace root path: ", _omni_root); + lib_search_paths.emplace_back( + JOIN('/', _omni_root, "lib", "rocprofiler-systems")); + lib_search_paths.emplace_back( + JOIN('/', _omni_root, "lib", "rocprofiler-systems", "lib")); + lib_search_paths.emplace_back( + JOIN('/', _omni_root, "lib", "rocprofiler-systems", "lib64")); + ROCPROFSYS_ADD_LOG_ENTRY(argv[0], + "::", "rocprofiler-systems root path: ", _omni_root); } auto _omni_exe_path = get_realpath(get_absolute_exe_filepath(argv[0])); if(!exists(_omni_exe_path)) _omni_exe_path = - get_realpath(get_absolute_exe_filepath(omnitrace_get_exe_realpath())); + get_realpath(get_absolute_exe_filepath(rocprofsys_get_exe_realpath())); bin_search_paths.emplace_back(filepath::dirname(_omni_exe_path)); auto _omni_lib_path = JOIN('/', filepath::dirname(filepath::dirname(_omni_exe_path)), "lib"); - bin_search_paths.emplace_back(JOIN('/', _omni_lib_path, "omnitrace")); - bin_search_paths.emplace_back(JOIN('/', _omni_lib_path, "omnitrace", "bin")); + bin_search_paths.emplace_back(JOIN('/', _omni_lib_path, "rocprofiler-systems")); + bin_search_paths.emplace_back( + JOIN('/', _omni_lib_path, "rocprofiler-systems", "bin")); lib_search_paths.emplace_back(_omni_lib_path); - lib_search_paths.emplace_back(JOIN('/', _omni_lib_path, "omnitrace")); - lib_search_paths.emplace_back(JOIN('/', _omni_lib_path, "omnitrace", "lib")); - lib_search_paths.emplace_back(JOIN('/', _omni_lib_path, "omnitrace", "lib64")); + lib_search_paths.emplace_back(JOIN('/', _omni_lib_path, "rocprofiler-systems")); + lib_search_paths.emplace_back( + JOIN('/', _omni_lib_path, "rocprofiler-systems", "lib")); + lib_search_paths.emplace_back( + JOIN('/', _omni_lib_path, "rocprofiler-systems", "lib64")); - OMNITRACE_ADD_LOG_ENTRY(argv[0], "::", "omnitrace bin path: ", _omni_exe_path); - OMNITRACE_ADD_LOG_ENTRY(argv[0], "::", "omnitrace lib path: ", _omni_lib_path); + ROCPROFSYS_ADD_LOG_ENTRY(argv[0], "::", "rocprofsys bin path: ", _omni_exe_path); + ROCPROFSYS_ADD_LOG_ENTRY(argv[0], "::", "rocprofsys lib path: ", _omni_lib_path); - for(const auto& itr : omnitrace_get_link_map(nullptr)) + for(const auto& itr : rocprofsys_get_link_map(nullptr)) { - if(itr.find("omnitrace") != std::string::npos || + if(itr.find("rocprofsys") != std::string::npos || + itr.find("rocprof-sys") != std::string::npos || + itr.find("rocprofiler-systems") != std::string::npos || std::regex_search( itr, std::regex{ "lib(dyninstAPI|stackwalk|pcontrol|patchAPI|parseAPI|" "instructionAPI|symtabAPI|dynDwarf|common|dynElf|tbb|" @@ -364,19 +375,19 @@ main(int argc, char** argv) for(const auto& itr : bin_search_paths) { - OMNITRACE_ADD_LOG_ENTRY("bin search path:", itr); + ROCPROFSYS_ADD_LOG_ENTRY("bin search path:", itr); } for(const auto& itr : lib_search_paths) { - OMNITRACE_ADD_LOG_ENTRY("lib search path:", itr); + ROCPROFSYS_ADD_LOG_ENTRY("lib search path:", itr); } address_space_t* addr_space = nullptr; 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 = {}; @@ -452,9 +463,9 @@ main(int argc, char** argv) if(verbose_level > 1) { - std::cout << "[omnitrace][exe][original]: " << cmd_string(argc, argv) + std::cout << "[rocprof-sys][exe][original]: " << cmd_string(argc, argv) << std::endl; - std::cout << "[omnitrace][exe][cfg-args]: " << cmd_string(_argc, _argv) + std::cout << "[rocprof-sys][exe][cfg-args]: " << cmd_string(_argc, _argv) << std::endl; } @@ -465,11 +476,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", ROCPROFSYS_ARGPARSE_VERSION_INFO); parser.add_argument({ "" }, ""); parser.add_argument({ "[DEBUG OPTIONS]" }, ""); @@ -597,9 +608,9 @@ main(int argc, char** argv) parser .add_argument({ "-o", "--output" }, "Enable generation of a new executable (binary-rewrite). If a " - "filename is not provided, omnitrace will use the basename and " + "filename is not provided, rocprof-sys will use the basename and " "output to the cwd, unless the target binary is in the cwd. In the " - "latter case, omnitrace will either use ${PWD}/.inst " + "latter case, rocprof-sys will either use ${PWD}/.inst " "(non-libraries) or ${PWD}/instrumented/ (libraries)") .min_count(0) .max_count(1) @@ -755,11 +766,11 @@ main(int argc, char** argv) "that match the provided regular-expressions"); parser.add_argument({ "--internal-function-include" }, "Regex(es) for including functions which are (likely) utilized " - "by omnitrace itself. Use this option with care."); + "by rocprof-sys itself. Use this option with care."); parser.add_argument( { "--internal-module-include" }, "Regex(es) for including modules/libraries which are (likely) utilized " - "by omnitrace itself. Use this option with care."); + "by rocprof-sys itself. Use this option with care."); parser.add_argument( { "--instruction-exclude" }, "Regex(es) for excluding functions containing certain instructions"); @@ -782,8 +793,8 @@ main(int argc, char** argv) parser .add_argument({ "--internal-library-append" }, - "Append to the list of libraries which omnitrace treats as being " - "used internally, e.g. OmniTrace will find all the symbols in " + "Append to the list of libraries which rocprof-sys treats as being " + "used internally, e.g. rocprof-sys will find all the symbols in " "this library and prevent them from being instrumented.") .action([](parser_t& p) { for(const auto& itr : p.get("internal-library-append")) @@ -793,7 +804,7 @@ main(int argc, char** argv) parser .add_argument({ "--internal-library-remove" }, "Remove the specified libraries from being treated as being " - "used internally, e.g. OmniTrace will permit all the symbols in " + "used internally, e.g. rocprof-sys will permit all the symbols in " "these libraries to be eligible for instrumentation.") .choices(_internal_libs) .action([](parser_t& p) { @@ -885,19 +896,19 @@ main(int argc, char** argv) "defaults in the executable"); parser.add_argument({ "--env" }, "Environment variables to add to the runtime in form " - "VARIABLE=VALUE. E.g. use '--env OMNITRACE_PROFILE=ON' to " + "VARIABLE=VALUE. E.g. use '--env ROCPROFSYS_PROFILE=ON' to " "default to using timemory instead of perfetto"); parser .add_argument({ "--mpi" }, - "Enable MPI support (requires omnitrace built w/ full or partial " + "Enable MPI support (requires rocprof-sys built w/ full or partial " "MPI support). NOTE: this will automatically be activated if " "MPI_Init, MPI_Init_thread, MPI_Finalize, MPI_Comm_rank, or " "MPI_Comm_size are found in the symbol table of target") .max_count(1) .action([](parser_t& p) { use_mpi = p.get("mpi"); -#if OMNITRACE_USE_MPI == 0 && OMNITRACE_USE_MPI_HEADERS == 0 - errprintf(0, "omnitrace was not built with full or partial MPI support\n"); +#if ROCPROFSYS_USE_MPI == 0 && ROCPROFSYS_USE_MPI_HEADERS == 0 + errprintf(0, "rocprof-sys was not built with full or partial MPI support\n"); use_mpi = false; #endif }); @@ -1004,8 +1015,10 @@ main(int argc, char** argv) parser .add_argument( { "--parse-all-modules" }, - "By default, omnitrace simply requests Dyninst to provide all the procedures " - "in the application image. If this option is enabled, omnitrace will iterate " + "By default, rocprof-sys simply requests Dyninst to provide all the " + "procedures " + "in the application image. If this option is enabled, rocprof-sys will " + "iterate " "over all the modules and extract the functions. Theoretically, it should be " "the same but the data is slightly different, possibly due to weak binding " "scopes. In general, enabling option will probably have no visible effect") @@ -1064,12 +1077,12 @@ main(int argc, char** argv) if(parser.exists("config")) { - struct omnitrace_env_config_s + struct rocprofsys_env_config_s {}; auto _configs = parser.get("config"); for(auto&& itr : _configs) { - auto _settings = tim::settings::push(); + auto _settings = tim::settings::push(); for(auto&& iitr : *_settings) { if(iitr.second->get_updated()) iitr.second->set_user_updated(); @@ -1092,7 +1105,7 @@ main(int argc, char** argv) verbprintf(1, "Exporting unknown config value :: %s\n", env_config_variables.back().c_str()); } - tim::settings::pop(); + tim::settings::pop(); } } @@ -1146,12 +1159,12 @@ main(int argc, char** argv) !parser.exists("min-instructions") && !parser.exists("min-address-range-loop")); - auto _omnitrace_exe_path = tim::dirname(::get_realpath("/proc/self/exe")); - verbprintf(4, "omnitrace exe path: %s\n", _omnitrace_exe_path.c_str()); + auto _rocprofsys_exe_path = tim::dirname(::get_realpath("/proc/self/exe")); + verbprintf(4, "rocprof-sys exe path: %s\n", _rocprofsys_exe_path.c_str()); if(_cmdv && _cmdv[0] && strlen(_cmdv[0]) > 0) { - auto _is_executable = omnitrace_get_is_executable(_cmdv[0], binary_rewrite); + auto _is_executable = rocprofsys_get_is_executable(_cmdv[0], binary_rewrite); std::string _cmdv_base = ::basename(_cmdv[0]); auto _has_lib_suffix = _cmdv_base.length() > 3 && (_cmdv_base.find(".so.") != std::string::npos || @@ -1163,10 +1176,10 @@ main(int argc, char** argv) { fflush(stdout); std::stringstream _separator{}; - // 18 is approximate length of '[omnitrace][exe] ' + // 20 is approximate length of '[rocprof-sys][exe] ' // 32 is approximate length of 'Warning! "" is not executable!' size_t _width = - std::min(std::get<0>(tim::utility::console::get_columns()) - 18, + std::min(std::get<0>(tim::utility::console::get_columns()) - 20, strlen(_cmdv[0]) + 32); _separator.fill('='); _separator << "#" << std::setw(_width - 2) << "" @@ -1225,12 +1238,12 @@ main(int argc, char** argv) { auto* _save = _cmdv[0]; _cmdv[0] = const_cast(outfile.c_str()); - tim::timemory_init(_cmdc, _cmdv, "omnitrace-"); + tim::timemory_init(_cmdc, _cmdv, "rocprofsys-"); _cmdv[0] = _save; } else { - tim::timemory_init(_cmdc, _cmdv, "omnitrace-"); + tim::timemory_init(_cmdc, _cmdv, "rocprofsys-"); } if(!logfile.empty()) @@ -1253,32 +1266,32 @@ main(int argc, char** argv) { // Helper function for adding regex expressions auto add_regex = [](auto& regex_array, const string_t& regex_expr) { - OMNITRACE_ADD_DETAILED_LOG_ENTRY("", "Adding regular expression \"", - regex_expr, "\" to regex_array@", - ®ex_array); + ROCPROFSYS_ADD_DETAILED_LOG_ENTRY("", "Adding regular expression \"", + regex_expr, "\" to regex_array@", + ®ex_array); if(!regex_expr.empty()) regex_array.emplace_back(std::regex(regex_expr, regex_opts)); }; - add_regex(func_include, tim::get_env("OMNITRACE_REGEX_INCLUDE", "")); - add_regex(func_exclude, tim::get_env("OMNITRACE_REGEX_EXCLUDE", "")); - add_regex(func_restrict, tim::get_env("OMNITRACE_REGEX_RESTRICT", "")); + add_regex(func_include, tim::get_env("ROCPROFSYS_REGEX_INCLUDE", "")); + add_regex(func_exclude, tim::get_env("ROCPROFSYS_REGEX_EXCLUDE", "")); + add_regex(func_restrict, tim::get_env("ROCPROFSYS_REGEX_RESTRICT", "")); add_regex(caller_include, - tim::get_env("OMNITRACE_REGEX_CALLER_INCLUDE")); + tim::get_env("ROCPROFSYS_REGEX_CALLER_INCLUDE")); add_regex(func_internal_include, - tim::get_env("OMNITRACE_REGEX_INTERNAL_INCLUDE", "")); + tim::get_env("ROCPROFSYS_REGEX_INTERNAL_INCLUDE", "")); add_regex(file_include, - tim::get_env("OMNITRACE_REGEX_MODULE_INCLUDE", "")); + tim::get_env("ROCPROFSYS_REGEX_MODULE_INCLUDE", "")); add_regex(file_exclude, - tim::get_env("OMNITRACE_REGEX_MODULE_EXCLUDE", "")); + tim::get_env("ROCPROFSYS_REGEX_MODULE_EXCLUDE", "")); add_regex(file_restrict, - tim::get_env("OMNITRACE_REGEX_MODULE_RESTRICT", "")); + tim::get_env("ROCPROFSYS_REGEX_MODULE_RESTRICT", "")); add_regex(file_internal_include, - tim::get_env("OMNITRACE_REGEX_MODULE_INTERNAL_INCLUDE", "")); + tim::get_env("ROCPROFSYS_REGEX_MODULE_INTERNAL_INCLUDE", "")); add_regex(instruction_exclude, - tim::get_env("OMNITRACE_REGEX_INSTRUCTION_EXCLUDE", "")); + tim::get_env("ROCPROFSYS_REGEX_INSTRUCTION_EXCLUDE", "")); // Helper function for parsing the regex options auto _parse_regex_option = [&parser, &add_regex](const string_t& _option, @@ -1362,8 +1375,8 @@ main(int argc, char** argv) { parser.print_help(extra_help); fprintf(stderr, "\nError! No command for dynamic instrumentation. Use " - "\n\tomnitrace -- \nE.g. " - "\n\tomnitrace -o foo.inst -- ./foo\nwill output an " + "\n\trocprof-sys-instrument -- \nE.g. " + "\n\trocprof-sys-instrument -o foo.inst -- ./foo\nwill output an " "instrumented version of 'foo' executable to 'foo.inst'\n"); return EXIT_FAILURE; } @@ -1403,16 +1416,16 @@ main(int argc, char** argv) env_vars.reserve(env_vars.size() + env_config_variables.size()); for(auto&& itr : env_config_variables) env_vars.emplace_back(itr); - env_vars.emplace_back(TIMEMORY_JOIN('=', "OMNITRACE_MODE", instr_mode)); + env_vars.emplace_back(TIMEMORY_JOIN('=', "ROCPROFSYS_MODE", instr_mode)); env_vars.emplace_back( - TIMEMORY_JOIN('=', "OMNITRACE_INSTRUMENT_MODE", instr_mode_v_int)); - env_vars.emplace_back(TIMEMORY_JOIN('=', "OMNITRACE_MPI_INIT", "OFF")); - env_vars.emplace_back(TIMEMORY_JOIN('=', "OMNITRACE_MPI_FINALIZE", "OFF")); - env_vars.emplace_back(TIMEMORY_JOIN('=', "OMNITRACE_USE_CODE_COVERAGE", + TIMEMORY_JOIN('=', "ROCPROFSYS_INSTRUMENT_MODE", instr_mode_v_int)); + env_vars.emplace_back(TIMEMORY_JOIN('=', "ROCPROFSYS_MPI_INIT", "OFF")); + env_vars.emplace_back(TIMEMORY_JOIN('=', "ROCPROFSYS_MPI_FINALIZE", "OFF")); + env_vars.emplace_back(TIMEMORY_JOIN('=', "ROCPROFSYS_USE_CODE_COVERAGE", (coverage_mode != CODECOV_NONE) ? "ON" : "OFF")); - addr_space = omnitrace_get_address_space(bpatch, _cmdc, _cmdv, env_vars, - binary_rewrite, _pid, mutname); + addr_space = rocprofsys_get_address_space(bpatch, _cmdc, _cmdv, env_vars, + binary_rewrite, _pid, mutname); // addr_space->allowTraps(instr_traps); @@ -1462,14 +1475,14 @@ main(int argc, char** argv) }; auto _add_overlapping = [](module_t* mitr, procedure_t* pitr) { - OMNITRACE_ADD_LOG_ENTRY("Checking if procedure", get_name(pitr), "in module", - get_name(mitr), "is overlapping"); + ROCPROFSYS_ADD_LOG_ENTRY("Checking if procedure", get_name(pitr), "in module", + get_name(mitr), "is overlapping"); if(!pitr->isInstrumentable()) return; std::vector _overlapping{}; if(pitr->findOverlapping(_overlapping)) { - OMNITRACE_ADD_LOG_ENTRY("Adding overlapping procedure", get_name(pitr), - "and module", get_name(mitr)); + ROCPROFSYS_ADD_LOG_ENTRY("Adding overlapping procedure", get_name(pitr), + "and module", get_name(mitr)); _insert_module_function(overlapping_module_functions, module_function{ mitr, pitr }); for(auto* oitr : _overlapping) @@ -1589,8 +1602,8 @@ main(int argc, char** argv) is_static_exe = addr_space->isStaticExecutable(); - OMNITRACE_ADD_LOG_ENTRY("address space is", (is_static_exe) ? "" : "not", - "a static executable"); + ROCPROFSYS_ADD_LOG_ENTRY("address space is", (is_static_exe) ? "" : "not", + "a static executable"); if(binary_rewrite) app_binary = static_cast(addr_space); else @@ -1598,7 +1611,7 @@ main(int argc, char** argv) is_attached = (_pid >= 0 && app_thread != nullptr); - OMNITRACE_ADD_LOG_ENTRY("address space is attached:", is_attached); + ROCPROFSYS_ADD_LOG_ENTRY("address space is attached:", is_attached); if(!app_binary && !app_thread) { @@ -1618,7 +1631,7 @@ main(int argc, char** argv) string_t _tried_libs; for(auto _libname : _libnames) { - OMNITRACE_ADD_LOG_ENTRY("Getting the absolute lib filepath to", _libname); + ROCPROFSYS_ADD_LOG_ENTRY("Getting the absolute lib filepath to", _libname); _libname = get_realpath(get_absolute_lib_filepath(_libname)); _tried_libs += string_t("|") + _libname; verbprintf(1, "loading library: '%s'...\n", _libname.c_str()); @@ -1627,7 +1640,7 @@ main(int argc, char** argv) (result) ? "success" : "failure"); if(result) { - OMNITRACE_ADD_LOG_ENTRY("Using library:", _libname); + ROCPROFSYS_ADD_LOG_ENTRY("Using library:", _libname); break; } } @@ -1656,7 +1669,7 @@ main(int argc, char** argv) }; for(auto& lname : lnames) lname = _get_library_ext(lname); - OMNITRACE_ADD_LOG_ENTRY("Using library:", lnames); + ROCPROFSYS_ADD_LOG_ENTRY("Using library:", lnames); return lnames; }; @@ -1668,11 +1681,11 @@ main(int argc, char** argv) //----------------------------------------------------------------------------------// auto* main_func = find_function(app_image, main_fname.c_str()); - auto* user_start_func = find_function(app_image, "omnitrace_user_start_trace", - { "omnitrace_user_start_thread_trace" }); - auto* user_stop_func = find_function(app_image, "omnitrace_user_stop_trace", - { "omnitrace_user_stop_thread_trace" }); -#if OMNITRACE_USE_MPI > 0 || OMNITRACE_USE_MPI_HEADERS > 0 + auto* user_start_func = find_function(app_image, "rocprofsys_user_start_trace", + { "rocprofsys_user_start_thread_trace" }); + auto* user_stop_func = find_function(app_image, "rocprofsys_user_stop_trace", + { "rocprofsys_user_stop_thread_trace" }); +#if ROCPROFSYS_USE_MPI > 0 || ROCPROFSYS_USE_MPI_HEADERS > 0 // if any of the below MPI functions are found, enable MPI support for(const auto* itr : { "MPI_Init", "MPI_Init_thread", "MPI_Finalize", "MPI_Comm_rank", "MPI_Comm_size" }) @@ -1705,15 +1718,15 @@ main(int argc, char** argv) verbprintf(0, "Finding instrumentation functions...\n"); - auto* init_func = find_function(app_image, "omnitrace_init"); - auto* fini_func = find_function(app_image, "omnitrace_finalize"); - auto* env_func = find_function(app_image, "omnitrace_set_env"); - auto* mpi_func = find_function(app_image, "omnitrace_set_mpi"); - auto* entr_trace = find_function(app_image, "omnitrace_push_trace"); - auto* exit_trace = find_function(app_image, "omnitrace_pop_trace"); - auto* reg_src_func = find_function(app_image, "omnitrace_register_source"); - auto* reg_cov_func = find_function(app_image, "omnitrace_register_coverage"); - auto* set_instr_func = find_function(app_image, "omnitrace_set_instrumented"); + auto* init_func = find_function(app_image, "rocprofsys_init"); + auto* fini_func = find_function(app_image, "rocprofsys_finalize"); + auto* env_func = find_function(app_image, "rocprofsys_set_env"); + auto* mpi_func = find_function(app_image, "rocprofsys_set_mpi"); + auto* entr_trace = find_function(app_image, "rocprofsys_push_trace"); + auto* exit_trace = find_function(app_image, "rocprofsys_pop_trace"); + auto* reg_src_func = find_function(app_image, "rocprofsys_register_source"); + auto* reg_cov_func = find_function(app_image, "rocprofsys_register_coverage"); + auto* set_instr_func = find_function(app_image, "rocprofsys_set_instrumented"); if(!main_func && main_fname == "main") main_func = find_function(app_image, "_main"); @@ -1757,9 +1770,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 +1781,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; @@ -1814,8 +1827,8 @@ main(int argc, char** argv) } // check standard function signature if no user-specified matches - if(add_instr_library(_name, TIMEMORY_JOIN("", "omnitrace_register_" + _name), - TIMEMORY_JOIN("", "omnitrace_deregister_" + _name))) + if(add_instr_library(_name, TIMEMORY_JOIN("", "rocprofsys_register_" + _name), + TIMEMORY_JOIN("", "rocprofsys_deregister_" + _name))) continue; found_instr_functions: @@ -1830,14 +1843,14 @@ main(int argc, char** argv) using pair_t = std::pair; - for(const auto& itr : { pair_t{ entr_trace, "omnitrace_push_trace" }, - pair_t{ exit_trace, "omnitrace_pop_trace" }, - pair_t{ init_func, "omnitrace_init" }, - pair_t{ fini_func, "omnitrace_finalize" }, - pair_t{ env_func, "omnitrace_set_env" }, - pair_t{ set_instr_func, "omnitrace_set_instrumented" }, - pair_t{ reg_src_func, "omnitrace_register_source" }, - pair_t{ reg_cov_func, "omnitrace_register_coverage" } }) + for(const auto& itr : { pair_t{ entr_trace, "rocprofsys_push_trace" }, + pair_t{ exit_trace, "rocprofsys_pop_trace" }, + pair_t{ init_func, "rocprofsys_init" }, + pair_t{ fini_func, "rocprofsys_finalize" }, + pair_t{ env_func, "rocprofsys_set_env" }, + pair_t{ set_instr_func, "rocprofsys_set_instrumented" }, + pair_t{ reg_src_func, "rocprofsys_register_source" }, + pair_t{ reg_cov_func, "rocprofsys_register_coverage" } }) { if(!itr.first) { @@ -1891,12 +1904,12 @@ main(int argc, char** argv) auto _init_arg0 = main_fname; if(main_func) main_sign.get(); - auto main_call_args = omnitrace_call_expr(main_sign.get()); - auto init_call_args = omnitrace_call_expr(instr_mode, binary_rewrite, ""); - auto fini_call_args = omnitrace_call_expr(); - auto umpi_call_args = omnitrace_call_expr(use_mpi, is_attached); - auto none_call_args = omnitrace_call_expr(); - auto set_instr_args = omnitrace_call_expr(instr_mode_v_int); + auto main_call_args = rocprofsys_call_expr(main_sign.get()); + auto init_call_args = rocprofsys_call_expr(instr_mode, binary_rewrite, ""); + auto fini_call_args = rocprofsys_call_expr(); + auto umpi_call_args = rocprofsys_call_expr(use_mpi, is_attached); + auto none_call_args = rocprofsys_call_expr(); + auto set_instr_args = rocprofsys_call_expr(instr_mode_v_int); verbprintf(2, "Done\n"); verbprintf(2, "Getting call snippets... "); @@ -1927,16 +1940,16 @@ 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(); env_vars.emplace_back( - TIMEMORY_JOIN('=', "OMNITRACE_INIT_ENABLED", + TIMEMORY_JOIN('=', "ROCPROFSYS_INIT_ENABLED", (user_start_func && user_stop_func) ? "OFF" : "ON")); - env_vars.emplace_back(TIMEMORY_JOIN('=', "OMNITRACE_USE_MPIP", + env_vars.emplace_back(TIMEMORY_JOIN('=', "ROCPROFSYS_USE_MPIP", (binary_rewrite && use_mpi) ? "ON" : "OFF")); - if(use_mpi) env_vars.emplace_back(TIMEMORY_JOIN('=', "OMNITRACE_USE_PID", "ON")); + if(use_mpi) env_vars.emplace_back(TIMEMORY_JOIN('=', "ROCPROFSYS_USE_PID", "ON")); for(auto& itr : env_vars) { @@ -1949,7 +1962,7 @@ main(int argc, char** argv) auto _var = itr.substr(0, _pos); auto _val = itr.substr(_pos + 1); tim::set_env(_var, _val); - auto _expr = omnitrace_call_expr(_var, _val); + auto _expr = rocprofsys_call_expr(_var, _val); env_variables.emplace_back(_expr.get(env_func)); } @@ -1959,7 +1972,7 @@ main(int argc, char** argv) // //----------------------------------------------------------------------------------// - // call into omnitrace-dl to notify that instrumentation is occurring + // call into rocprof-sys-dl to notify that instrumentation is occurring if(binary_rewrite) { init_names.emplace(init_names.begin(), set_instr_call.get()); @@ -2076,7 +2089,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", @@ -2424,7 +2437,7 @@ main(int argc, char** argv) for(auto& itr : cmdv_envp) ::free(itr); - if(perr != 0) perror("Error in omnitrace_fork"); + if(perr != 0) perror("Error in rocprofsys_fork"); for(const auto& itr : linked_libs) verbprintf(0, "\t%s\n", itr.c_str()); @@ -2450,7 +2463,7 @@ main(int argc, char** argv) auto _compute_exit_code = [app_thread, &code]() { if(app_thread->terminationStatus() == ExitedNormally) { - if(app_thread->isTerminated()) verbprintf(0, "End of omnitrace\n"); + if(app_thread->isTerminated()) verbprintf(0, "End of rocprof-sys\n"); } else if(app_thread->terminationStatus() == ExitedViaSignal) { @@ -2523,7 +2536,7 @@ main(int argc, char** argv) free(_cmdv[i]); delete[] _cmdv; - verbprintf(0, "End of omnitrace\n"); + verbprintf(0, "End of rocprof-sys\n"); verbprintf((code != 0) ? 0 : 1, "Exit code: %i\n", code); if(log_ofs) @@ -2684,7 +2697,7 @@ get_absolute_filepath(std::string _name, const strvec_t& _search_paths) if(!is_directory(itr) || is_file(itr)) itr = filepath::dirname(itr); auto _exists = false; - OMNITRACE_ADD_LOG_ENTRY("searching", itr, "for", _name); + ROCPROFSYS_ADD_LOG_ENTRY("searching", itr, "for", _name); for(const auto& pitr : { absolute(JOIN('/', itr, _name)), absolute(JOIN('/', itr, filepath::basename(_name))) }) @@ -2813,9 +2826,9 @@ using tim::dirname; void find_dyn_api_rt() { -#if defined(OMNITRACE_BUILD_DYNINST) +#if defined(ROCPROFSYS_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-instrument/omnitrace-instrument.hpp b/source/bin/rocprof-sys-instrument/rocprof-sys-instrument.hpp similarity index 80% rename from source/bin/omnitrace-instrument/omnitrace-instrument.hpp rename to source/bin/rocprof-sys-instrument/rocprof-sys-instrument.hpp index fd6b0d93..4a235693 100644 --- a/source/bin/omnitrace-instrument/omnitrace-instrument.hpp +++ b/source/bin/rocprof-sys-instrument/rocprof-sys-instrument.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -83,12 +83,12 @@ get_snippets(Args&&... args) // //======================================================================================// // -struct omnitrace_call_expr +struct rocprofsys_call_expr { using snippet_pointer_t = std::shared_ptr; template - omnitrace_call_expr(Args&&... args) + rocprofsys_call_expr(Args&&... args) : m_params(get_snippets(std::forward(args)...)) {} @@ -112,15 +112,15 @@ struct omnitrace_call_expr // //======================================================================================// // -struct omnitrace_snippet_vec +struct rocprofsys_snippet_vec { - using entry_type = std::vector; + using entry_type = std::vector; using value_type = std::vector; template void generate(procedure_t* func, Args&&... args) { - auto _expr = omnitrace_call_expr(std::forward(args)...); + auto _expr = rocprofsys_call_expr(std::forward(args)...); auto _call = _expr.get(func); if(_call) { @@ -144,7 +144,7 @@ struct omnitrace_snippet_vec //======================================================================================// // static inline bool -omnitrace_get_is_executable(std::string_view _cmd, bool _default_v) +rocprofsys_get_is_executable(std::string_view _cmd, bool _default_v) { bool _is_executable = _default_v; @@ -172,9 +172,9 @@ omnitrace_get_is_executable(std::string_view _cmd, bool _default_v) //======================================================================================// // static inline address_space_t* -omnitrace_get_address_space(patch_pointer_t& _bpatch, int _cmdc, char** _cmdv, - const std::vector& _cmdenv, bool _rewrite, - int _pid = -1, const std::string& _name = {}) +rocprofsys_get_address_space(patch_pointer_t& _bpatch, int _cmdc, char** _cmdv, + const std::vector& _cmdenv, bool _rewrite, + int _pid = -1, const std::string& _name = {}) { address_space_t* mutatee = nullptr; @@ -182,10 +182,10 @@ omnitrace_get_address_space(patch_pointer_t& _bpatch, int _cmdc, char** _cmdv, { if(is_text_file(_name)) { - errprintf( - -127, - "'%s' is a text file. OmniTrace only supports instrumenting binary files", - _name.c_str()); + errprintf(-127, + "'%s' is a text file. rocprof-sys only supports instrumenting " + "binary files", + _name.c_str()); } verbprintf(1, "Opening '%s' for binary rewrite... ", _name.c_str()); @@ -251,7 +251,7 @@ omnitrace_get_address_space(patch_pointer_t& _bpatch, int _cmdc, char** _cmdv, if(is_text_file(_cmdv[0])) { errprintf(-1, - "'%s' is a text file. OmniTrace only supports instrumenting " + "'%s' is a text file. rocprof-sys only supports instrumenting " "binary files", _cmdv[0]); } @@ -283,17 +283,17 @@ omnitrace_get_address_space(patch_pointer_t& _bpatch, int _cmdc, char** _cmdv, //======================================================================================// // TIMEMORY_NOINLINE inline void -omnitrace_thread_exit(thread_t* thread, BPatch_exitType exit_type) +rocprofsys_thread_exit(thread_t* thread, BPatch_exitType exit_type) { if(!thread) return; - OMNITRACE_ADD_LOG_ENTRY("Executing the thread callback"); + ROCPROFSYS_ADD_LOG_ENTRY("Executing the thread callback"); BPatch_process* app = thread->getProcess(); if(!terminate_expr) { - fprintf(stderr, "[omnitrace][exe] continuing execution\n"); + fprintf(stderr, "[rocprof-sys][exe] continuing execution\n"); app->continueExecution(); return; } @@ -302,18 +302,18 @@ omnitrace_thread_exit(thread_t* thread, BPatch_exitType exit_type) { case ExitedNormally: { - fprintf(stderr, "[omnitrace][exe] Thread exited normally\n"); + fprintf(stderr, "[rocprof-sys][exe] Thread exited normally\n"); break; } case ExitedViaSignal: { - fprintf(stderr, "[omnitrace][exe] Thread terminated unexpectedly\n"); + fprintf(stderr, "[rocprof-sys][exe] Thread terminated unexpectedly\n"); break; } case NoExit: default: { - fprintf(stderr, "[omnitrace][exe] %s invoked with NoExit\n", __FUNCTION__); + fprintf(stderr, "[rocprof-sys][exe] %s invoked with NoExit\n", __FUNCTION__); break; } } @@ -321,16 +321,16 @@ omnitrace_thread_exit(thread_t* thread, BPatch_exitType exit_type) // terminate_expr = nullptr; thread->oneTimeCode(*terminate_expr); - fprintf(stderr, "[omnitrace][exe] continuing execution\n"); + fprintf(stderr, "[rocprof-sys][exe] continuing execution\n"); app->continueExecution(); } // //======================================================================================// // TIMEMORY_NOINLINE inline void -omnitrace_fork_callback(thread_t* parent, thread_t* child) +rocprofsys_fork_callback(thread_t* parent, thread_t* child) { - OMNITRACE_ADD_LOG_ENTRY("Executing the fork callback"); + ROCPROFSYS_ADD_LOG_ENTRY("Executing the fork callback"); if(child) { @@ -360,16 +360,16 @@ omnitrace_fork_callback(thread_t* parent, thread_t* child) // path resolution helpers // std::string& -omnitrace_get_exe_realpath(); +rocprofsys_get_exe_realpath(); // std::optional -omnitrace_get_origin(const char* _name, - std::vector&& _open_modes = { (RTLD_LAZY | RTLD_NOLOAD) }); +rocprofsys_get_origin(const char* _name, + std::vector&& _open_modes = { (RTLD_LAZY | RTLD_NOLOAD) }); // std::vector -omnitrace_get_link_map(const char* _lib, const std::string& _exclude_linked_by = {}, - const std::string& _exclude_re = {}, - std::vector&& _open_modes = { (RTLD_LAZY | RTLD_NOLOAD) }); +rocprofsys_get_link_map(const char* _lib, const std::string& _exclude_linked_by = {}, + const std::string& _exclude_re = {}, + std::vector&& _open_modes = { (RTLD_LAZY | RTLD_NOLOAD) }); // //======================================================================================// // insert_instr -- insert instrumentation into a function @@ -388,8 +388,8 @@ insert_instr(address_space_t* mutatee, const std::vector& _points, Tp return _v; }(); - OMNITRACE_ADD_LOG_ENTRY("Inserting", _points.size(), - "instrumentation points into function(s)", _names); + ROCPROFSYS_ADD_LOG_ENTRY("Inserting", _points.size(), + "instrumentation points into function(s)", _names); auto _trace = traceFunc.get(); auto _traps = std::set{}; @@ -401,8 +401,8 @@ insert_instr(address_space_t* mutatee, const std::vector& _points, Tp } } - OMNITRACE_ADD_LOG_ENTRY("Found", _traps.size(), - "instrumentation points using traps in function(s)", _names); + ROCPROFSYS_ADD_LOG_ENTRY("Found", _traps.size(), + "instrumentation points using traps in function(s)", _names); size_t _n = 0; for(const auto& itr : _points) @@ -412,8 +412,8 @@ insert_instr(address_space_t* mutatee, const std::vector& _points, Tp ++_n; } - OMNITRACE_ADD_LOG_ENTRY("Inserted", _n, "instrumentation points in function(s)", - _names); + ROCPROFSYS_ADD_LOG_ENTRY("Inserted", _n, "instrumentation points in function(s)", + _names); return (_n > 0); } @@ -434,8 +434,8 @@ insert_instr(address_space_t* mutatee, procedure_t* funcToInstr, Tp traceFunc, std::vector* _points = nullptr; auto _trace = traceFunc.get(); - OMNITRACE_ADD_LOG_ENTRY("Searching for loop instrumentation points in function", - get_name(funcToInstr)); + ROCPROFSYS_ADD_LOG_ENTRY("Searching for loop instrumentation points in function", + get_name(funcToInstr)); if(!cfGraph) funcToInstr->getCFG(); if(cfGraph && loopToInstrument) @@ -453,9 +453,9 @@ insert_instr(address_space_t* mutatee, procedure_t* funcToInstr, Tp traceFunc, if(_points == nullptr) return false; if(_points->empty()) return false; - OMNITRACE_ADD_LOG_ENTRY("Inserting max of", _points->size(), - "loop instrumentation points in function", - get_name(funcToInstr)); + ROCPROFSYS_ADD_LOG_ENTRY("Inserting max of", _points->size(), + "loop instrumentation points in function", + get_name(funcToInstr)); std::set _traps{}; if(!allow_traps) @@ -466,9 +466,9 @@ insert_instr(address_space_t* mutatee, procedure_t* funcToInstr, Tp traceFunc, } } - OMNITRACE_ADD_LOG_ENTRY("Found", _traps.size(), - "loop instrumentation points using traps in function", - get_name(funcToInstr)); + ROCPROFSYS_ADD_LOG_ENTRY("Found", _traps.size(), + "loop instrumentation points using traps in function", + get_name(funcToInstr)); size_t _n = 0; for(auto& itr : *_points) @@ -478,8 +478,8 @@ insert_instr(address_space_t* mutatee, procedure_t* funcToInstr, Tp traceFunc, ++_n; } - OMNITRACE_ADD_LOG_ENTRY("Inserted", _n, "loop instrumentation points in function", - get_name(funcToInstr)); + ROCPROFSYS_ADD_LOG_ENTRY("Inserted", _n, "loop instrumentation points in function", + get_name(funcToInstr)); return (_n > 0); } @@ -497,7 +497,7 @@ insert_instr(address_space_t* mutatee, Tp traceFunc, procedure_loc_t traceLoc, point_t* _point = nullptr; auto _trace = traceFunc.get(); - OMNITRACE_ADD_LOG_ENTRY( + ROCPROFSYS_ADD_LOG_ENTRY( "Searching for basic-block entry and exit instrumentation points ::", *basicBlock); @@ -514,15 +514,15 @@ insert_instr(address_space_t* mutatee, Tp traceFunc, procedure_loc_t traceLoc, if(_point == nullptr) { - OMNITRACE_ADD_LOG_ENTRY("No instrumentation points were found in basic-block ", - *basicBlock); + ROCPROFSYS_ADD_LOG_ENTRY("No instrumentation points were found in basic-block ", + *basicBlock); return false; } if(!allow_traps && _point->usesTrap_NP()) { - OMNITRACE_ADD_LOG_ENTRY("Basic-block", *basicBlock, - "uses traps and traps are disallowed"); + ROCPROFSYS_ADD_LOG_ENTRY("Basic-block", *basicBlock, + "uses traps and traps are disallowed"); return false; } diff --git a/source/bin/rocprof-sys-run/CMakeLists.txt b/source/bin/rocprof-sys-run/CMakeLists.txt new file mode 100644 index 00000000..0a019450 --- /dev/null +++ b/source/bin/rocprof-sys-run/CMakeLists.txt @@ -0,0 +1,32 @@ +# ------------------------------------------------------------------------------# +# +# rocprofiler-systems-run target +# +# ------------------------------------------------------------------------------# + +add_executable( + rocprofiler-systems-run + ${CMAKE_CURRENT_LIST_DIR}/rocprof-sys-run.cpp + ${CMAKE_CURRENT_LIST_DIR}/rocprof-sys-run.hpp ${CMAKE_CURRENT_LIST_DIR}/impl.cpp) + +target_compile_definitions(rocprofiler-systems-run PRIVATE TIMEMORY_CMAKE=1) +target_include_directories(rocprofiler-systems-run PRIVATE ${CMAKE_CURRENT_LIST_DIR}) +target_link_libraries( + rocprofiler-systems-run + PRIVATE rocprofiler-systems::rocprofiler-systems-compile-definitions + rocprofiler-systems::rocprofiler-systems-headers + rocprofiler-systems::rocprofiler-systems-common-library + rocprofiler-systems::rocprofiler-systems-core + rocprofiler-systems::rocprofiler-systems-sanitizer) +set_target_properties( + rocprofiler-systems-run + PROPERTIES BUILD_RPATH "\$ORIGIN:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}" + INSTALL_RPATH "${ROCPROFSYS_EXE_INSTALL_RPATH}" + OUTPUT_NAME ${BINARY_NAME_PREFIX}-run) + +rocprofiler_systems_strip_target(rocprofiler-systems-run) + +install( + TARGETS rocprofiler-systems-run + DESTINATION ${CMAKE_INSTALL_BINDIR} + OPTIONAL) diff --git a/source/bin/omnitrace-run/impl.cpp b/source/bin/rocprof-sys-run/impl.cpp similarity index 88% rename from source/bin/omnitrace-run/impl.cpp rename to source/bin/rocprof-sys-run/impl.cpp index ae3f486c..5e4b62e8 100644 --- a/source/bin/omnitrace-run/impl.cpp +++ b/source/bin/rocprof-sys-run/impl.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -20,7 +20,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include "omnitrace-run.hpp" +#include "rocprof-sys-run.hpp" #include "common/defines.h" #include "common/delimit.hpp" @@ -66,7 +66,7 @@ namespace filepath = ::tim::filepath; // NOLINT namespace console = ::tim::utility::console; namespace argparse = ::tim::argparse; namespace signals = ::tim::signals; -using settings = ::omnitrace::settings; +using settings = ::rocprofsys::settings; using namespace ::timemory::join; using ::tim::get_env; using ::tim::log::stream; @@ -89,7 +89,7 @@ get_internal_libpath(const std::string& _lib) auto _pos = _exe.find_last_of('/'); auto _dir = std::string{ "./" }; if(_pos != std::string_view::npos) _dir = _exe.substr(0, _pos); - return omnitrace::common::join("/", _dir, "..", "lib", _lib); + return rocprofsys::common::join("/", _dir, "..", "lib", _lib); } parser_data_t& @@ -113,10 +113,10 @@ int get_verbose(parser_data_t& _data) { auto& verbose = _data.verbose; - verbose = get_env("OMNITRACE_CAUSAL_VERBOSE", - get_env("OMNITRACE_VERBOSE", verbose, false)); - auto _debug = - get_env("OMNITRACE_CAUSAL_DEBUG", get_env("OMNITRACE_DEBUG", false, false)); + verbose = get_env("ROCPROFSYS_CAUSAL_VERBOSE", + get_env("ROCPROFSYS_VERBOSE", verbose, false)); + auto _debug = get_env("ROCPROFSYS_CAUSAL_DEBUG", + get_env("ROCPROFSYS_DEBUG", false, false)); if(_debug) verbose += 8; return verbose; } @@ -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), "\"")); } @@ -190,8 +190,8 @@ prepare_environment_for_run(parser_data_t& _data) { if(_data.launcher.empty()) { - omnitrace::argparse::add_ld_preload(_data); - omnitrace::argparse::add_ld_library_path(_data); + rocprofsys::argparse::add_ld_preload(_data); + rocprofsys::argparse::add_ld_library_path(_data); } } @@ -218,7 +218,7 @@ print_updated_environment(parser_data_t& _data, std::string_view _prefix) { if(itr == nullptr) continue; - auto _is_omni = (std::string_view{ itr }.find("OMNITRACE") == 0); + auto _is_omni = (std::string_view{ itr }.find("ROCPROFSYS") == 0); auto _updated = false; for(const auto& vitr : _updated_envs) { @@ -270,7 +270,7 @@ parse_args(int argc, char** argv, parser_data_t& _parser_data, bool& _fork_exec) using parser_err_t = typename parser_t::result_type; toggle_suppression(initial_suppression); - omnitrace::argparse::init_parser(_parser_data); + rocprofsys::argparse::init_parser(_parser_data); // no need for backtraces signals::disable_signal_detection(signals::signal_settings::get_enabled()); @@ -282,7 +282,7 @@ parse_args(int argc, char** argv, parser_data_t& _parser_data, bool& _fork_exec) }; const auto* _desc = R"desc( - Command line interface to omnitrace configuration. + Command line interface to rocprof-sys configuration. )desc"; auto parser = parser_t{ basename(argv[0]), _desc }; @@ -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", ROCPROFSYS_ARGPARSE_VERSION_INFO); auto _cols = std::get<0>(console::get_columns()); if(_cols > parser.get_help_width() + 8) @@ -303,8 +303,8 @@ parse_args(int argc, char** argv, parser_data_t& _parser_data, bool& _fork_exec) // disable options related to causal profiling _parser_data.processed_groups.emplace("causal"); - omnitrace::argparse::add_core_arguments(parser, _parser_data); - omnitrace::argparse::add_extended_arguments(parser, _parser_data); + rocprofsys::argparse::add_core_arguments(parser, _parser_data); + rocprofsys::argparse::add_extended_arguments(parser, _parser_data); parser.start_group("EXECUTION OPTIONS", ""); parser.add_argument({ "--fork" }, "Execute via fork + execvpe instead of execvpe") @@ -352,7 +352,7 @@ parser_data_t& parse_command(int argc, char** argv, parser_data_t& _parser_data) { toggle_suppression(initial_suppression); - omnitrace::argparse::init_parser(_parser_data); + rocprofsys::argparse::init_parser(_parser_data); // no need for backtraces signals::disable_signal_detection(signals::signal_settings::get_enabled()); diff --git a/source/bin/omnitrace-run/omnitrace-run.cpp b/source/bin/rocprof-sys-run/rocprof-sys-run.cpp similarity index 86% rename from source/bin/omnitrace-run/omnitrace-run.cpp rename to source/bin/rocprof-sys-run/rocprof-sys-run.cpp index 789c0eab..d819f45c 100644 --- a/source/bin/omnitrace-run/omnitrace-run.cpp +++ b/source/bin/rocprof-sys-run/rocprof-sys-run.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -20,7 +20,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include "omnitrace-run.hpp" +#include "rocprof-sys-run.hpp" #include "core/mproc.hpp" #include @@ -71,8 +71,8 @@ main(int argc, char** argv) auto& _envp = _parse_data.current; if(!_argv.empty()) { - print_updated_environment(_parse_data, "OMNITRACE: "); - print_command(_parse_data, "OMNITRACE: "); + print_updated_environment(_parse_data, "ROCPROFSYS: "); + print_command(_parse_data, "ROCPROFSYS: "); _argv.emplace_back(nullptr); _envp.emplace_back(nullptr); @@ -87,8 +87,8 @@ main(int argc, char** argv) } else { - auto _status = omnitrace::mproc::wait_pid(_pid); - auto _ec = omnitrace::mproc::diagnose_status(_pid, _status); + auto _status = rocprofsys::mproc::wait_pid(_pid); + auto _ec = rocprofsys::mproc::diagnose_status(_pid, _status); if(_ec != 0 && _parse_data.verbose >= 0) { TIMEMORY_PRINTF_FATAL( @@ -98,8 +98,9 @@ main(int argc, char** argv) else if(_parse_data.verbose >= 2) { TIMEMORY_PRINTF_FATAL( - stderr, "omnitrace run in process %i completed. exit code: %i\n", - _pid, _ec); + stderr, + "rocprof-sys run in process %i completed. exit code: %i\n", _pid, + _ec); } return _ec; } diff --git a/source/bin/omnitrace-run/omnitrace-run.hpp b/source/bin/rocprof-sys-run/rocprof-sys-run.hpp similarity index 92% rename from source/bin/omnitrace-run/omnitrace-run.hpp rename to source/bin/rocprof-sys-run/rocprof-sys-run.hpp index cc7578d0..e711ea9a 100644 --- a/source/bin/omnitrace-run/omnitrace-run.hpp +++ b/source/bin/rocprof-sys-run/rocprof-sys-run.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -32,7 +32,7 @@ #include #include -using parser_data_t = omnitrace::argparse::parser_data; +using parser_data_t = rocprofsys::argparse::parser_data; void print_command(const parser_data_t&, std::string_view); diff --git a/source/bin/rocprof-sys-sample/CMakeLists.txt b/source/bin/rocprof-sys-sample/CMakeLists.txt new file mode 100644 index 00000000..7780a2cf --- /dev/null +++ b/source/bin/rocprof-sys-sample/CMakeLists.txt @@ -0,0 +1,28 @@ +# ------------------------------------------------------------------------------# +# +# rocprofiler-systems-sample target +# +# ------------------------------------------------------------------------------# + +add_executable(rocprofiler-systems-sample ${CMAKE_CURRENT_LIST_DIR}/rocprof-sys-sample.cpp + ${CMAKE_CURRENT_LIST_DIR}/impl.cpp) + +target_compile_definitions(rocprofiler-systems-sample PRIVATE TIMEMORY_CMAKE=1) +target_include_directories(rocprofiler-systems-sample PRIVATE ${CMAKE_CURRENT_LIST_DIR}) +target_link_libraries( + rocprofiler-systems-sample + PRIVATE rocprofiler-systems::rocprofiler-systems-compile-definitions + rocprofiler-systems::rocprofiler-systems-headers + rocprofiler-systems::rocprofiler-systems-common-library) +set_target_properties( + rocprofiler-systems-sample + PROPERTIES BUILD_RPATH "\$ORIGIN:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}" + INSTALL_RPATH "${ROCPROFSYS_EXE_INSTALL_RPATH}" + OUTPUT_NAME ${BINARY_NAME_PREFIX}-sample) + +rocprofiler_systems_strip_target(rocprofiler-systems-sample) + +install( + TARGETS rocprofiler-systems-sample + DESTINATION ${CMAKE_INSTALL_BINDIR} + OPTIONAL) diff --git a/source/bin/omnitrace-sample/impl.cpp b/source/bin/rocprof-sys-sample/impl.cpp similarity index 78% rename from source/bin/omnitrace-sample/impl.cpp rename to source/bin/rocprof-sys-sample/impl.cpp index 4833f9b5..da9da3a5 100644 --- a/source/bin/omnitrace-sample/impl.cpp +++ b/source/bin/rocprof-sys-sample/impl.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -20,7 +20,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include "omnitrace-sample.hpp" +#include "rocprof-sys-sample.hpp" #include "common/delimit.hpp" #include "common/environment.hpp" @@ -44,12 +44,12 @@ #include #include -#if !defined(OMNITRACE_USE_ROCTRACER) -# define OMNITRACE_USE_ROCTRACER 0 +#if !defined(ROCPROFSYS_USE_ROCTRACER) +# define ROCPROFSYS_USE_ROCTRACER 0 #endif -#if !defined(OMNITRACE_USE_ROCPROFILER) -# define OMNITRACE_USE_ROCPROFILER 0 +#if !defined(ROCPROFSYS_USE_ROCPROFILER) +# define ROCPROFSYS_USE_ROCPROFILER 0 #endif namespace color = tim::log::color; @@ -74,25 +74,25 @@ auto clock_id_choices = []() { return _v; }; -#define OMNITRACE_CLOCK_IDENTIFIER(VAL) \ +#define ROCPROFSYS_CLOCK_IDENTIFIER(VAL) \ std::make_tuple(clock_name(#VAL), VAL, std::string_view{ #VAL }) auto _choices = std::vector{}; auto _aliases = std::map>{}; - for(auto itr : { OMNITRACE_CLOCK_IDENTIFIER(CLOCK_REALTIME), - OMNITRACE_CLOCK_IDENTIFIER(CLOCK_MONOTONIC), - OMNITRACE_CLOCK_IDENTIFIER(CLOCK_PROCESS_CPUTIME_ID), - OMNITRACE_CLOCK_IDENTIFIER(CLOCK_MONOTONIC_RAW), - OMNITRACE_CLOCK_IDENTIFIER(CLOCK_REALTIME_COARSE), - OMNITRACE_CLOCK_IDENTIFIER(CLOCK_MONOTONIC_COARSE), - OMNITRACE_CLOCK_IDENTIFIER(CLOCK_BOOTTIME) }) + for(auto itr : { ROCPROFSYS_CLOCK_IDENTIFIER(CLOCK_REALTIME), + ROCPROFSYS_CLOCK_IDENTIFIER(CLOCK_MONOTONIC), + ROCPROFSYS_CLOCK_IDENTIFIER(CLOCK_PROCESS_CPUTIME_ID), + ROCPROFSYS_CLOCK_IDENTIFIER(CLOCK_MONOTONIC_RAW), + ROCPROFSYS_CLOCK_IDENTIFIER(CLOCK_REALTIME_COARSE), + ROCPROFSYS_CLOCK_IDENTIFIER(CLOCK_MONOTONIC_COARSE), + ROCPROFSYS_CLOCK_IDENTIFIER(CLOCK_BOOTTIME) }) { auto _choice = std::to_string(std::get<1>(itr)); _choices.emplace_back(_choice); _aliases[_choice] = { std::get<0>(itr), std::string{ std::get<2>(itr) } }; } -#undef OMNITRACE_CLOCK_IDENTIFIER +#undef ROCPROFSYS_CLOCK_IDENTIFIER return std::make_pair(_choices, _aliases); }(); @@ -130,28 +130,28 @@ 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); - auto _mode = get_env("OMNITRACE_MODE", "sampling", false); + auto _mode = get_env("ROCPROFSYS_MODE", "sampling", false); - update_env(_env, "OMNITRACE_USE_SAMPLING", (_mode != "causal")); + update_env(_env, "ROCPROFSYS_USE_SAMPLING", (_mode != "causal")); -#if defined(OMNITRACE_USE_ROCTRACER) || defined(OMNITRACE_USE_ROCPROFILER) +#if defined(ROCPROFSYS_USE_ROCTRACER) || defined(ROCPROFSYS_USE_ROCPROFILER) update_env(_env, "HSA_TOOLS_LIB", _dl_libpath); if(!getenv("HSA_TOOLS_REPORT_LOAD_FAILURE")) update_env(_env, "HSA_TOOLS_REPORT_LOAD_FAILURE", "1"); #endif -#if defined(OMNITRACE_USE_ROCPROFILER) +#if defined(ROCPROFSYS_USE_ROCPROFILER) update_env(_env, "ROCP_TOOL_LIB", _omni_libpath); if(!getenv("ROCP_HSA_INTERCEPT")) update_env(_env, "ROCP_HSA_INTERCEPT", "1"); #endif -#if defined(OMNITRACE_USE_OMPT) +#if defined(ROCPROFSYS_USE_OMPT) if(!getenv("OMP_TOOL_LIBRARIES")) update_env(_env, "OMP_TOOL_LIBRARIES", _dl_libpath, UPD_APPEND); #endif @@ -166,13 +166,13 @@ get_internal_libpath(const std::string& _lib) auto _pos = _exe.find_last_of('/'); auto _dir = std::string{ "./" }; if(_pos != std::string_view::npos) _dir = _exe.substr(0, _pos); - return omnitrace::common::join("/", _dir, "..", "lib", _lib); + return rocprofsys::common::join("/", _dir, "..", "lib", _lib); } void print_updated_environment(std::vector _env) { - if(get_env("OMNITRACE_VERBOSE", 0) < 0) return; + if(get_env("ROCPROFSYS_VERBOSE", 0) < 0) return; std::sort(_env.begin(), _env.end(), [](auto* _lhs, auto* _rhs) { if(!_lhs) return false; @@ -187,7 +187,7 @@ print_updated_environment(std::vector _env) { if(itr == nullptr) continue; - auto _is_omni = (std::string_view{ itr }.find("OMNITRACE") == 0); + auto _is_omni = (std::string_view{ itr }.find("ROCPROFSYS") == 0); auto _updated = false; for(const auto& vitr : updated_envs) { @@ -260,13 +260,13 @@ update_env(std::vector& _environ, std::string_view _env_var, Tp&& _env_va else { free(itr); - itr = strdup(omnitrace::common::join('=', _env_var, _env_val).c_str()); + itr = strdup(rocprofsys::common::join('=', _env_var, _env_val).c_str()); } return; } } _environ.emplace_back( - strdup(omnitrace::common::join('=', _env_var, _env_val).c_str())); + strdup(rocprofsys::common::join('=', _env_var, _env_val).c_str())); } void @@ -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]); @@ -361,7 +361,7 @@ parse_args(int argc, char** argv, std::vector& _env) ? std::vector{ "hsa-interrupt" } : std::vector{}; -#if OMNITRACE_USE_ROCTRACER == 0 && OMNITRACE_USE_ROCPROFILER == 0 +#if ROCPROFSYS_USE_ROCTRACER == 0 && ROCPROFSYS_USE_ROCPROFILER == 0 _realtime_reqs.clear(); #endif @@ -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", ROCPROFSYS_ARGPARSE_VERSION_INFO); auto _cols = std::get<0>(tim::utility::console::get_columns()); if(_cols > parser.get_help_width() + 8) @@ -387,20 +387,20 @@ parse_args(int argc, char** argv, std::vector& _env) auto _monochrome = p.get("monochrome"); monochrome() = _monochrome; p.set_use_color(!_monochrome); - update_env(_env, "OMNITRACE_MONOCHROME", (_monochrome) ? "1" : "0"); + update_env(_env, "ROCPROFSYS_MONOCHROME", (_monochrome) ? "1" : "0"); update_env(_env, "MONOCHROME", (_monochrome) ? "1" : "0"); }); parser.add_argument({ "--debug" }, "Debug output") .max_count(1) .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_DEBUG", p.get("debug")); + update_env(_env, "ROCPROFSYS_DEBUG", p.get("debug")); }); parser.add_argument({ "-v", "--verbose" }, "Verbose output") .count(1) .action([&](parser_t& p) { auto _v = p.get("verbose"); verbose = _v; - update_env(_env, "OMNITRACE_VERBOSE", _v); + update_env(_env, "ROCPROFSYS_VERBOSE", _v); }); parser.start_group("GENERAL OPTIONS", @@ -410,7 +410,7 @@ parse_args(int argc, char** argv, std::vector& _env) .dtype("filepath") .action([&](parser_t& p) { update_env( - _env, "OMNITRACE_CONFIG_FILE", + _env, "ROCPROFSYS_CONFIG_FILE", join(array_config{ ":" }, p.get>("config"))); }); parser @@ -421,14 +421,14 @@ parse_args(int argc, char** argv, std::vector& _env) .max_count(2) .action([&](parser_t& p) { auto _v = p.get>("output"); - update_env(_env, "OMNITRACE_OUTPUT_PATH", _v.at(0)); - if(_v.size() > 1) update_env(_env, "OMNITRACE_OUTPUT_PREFIX", _v.at(1)); + update_env(_env, "ROCPROFSYS_OUTPUT_PATH", _v.at(0)); + if(_v.size() > 1) update_env(_env, "ROCPROFSYS_OUTPUT_PREFIX", _v.at(1)); }); parser .add_argument({ "-T", "--trace" }, "Generate a detailed trace (perfetto output)") .max_count(1) .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_TRACE", p.get("trace")); + update_env(_env, "ROCPROFSYS_TRACE", p.get("trace")); }); parser .add_argument( @@ -437,7 +437,7 @@ parse_args(int argc, char** argv, std::vector& _env) .max_count(1) .conflicts({ "flat-profile" }) .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_PROFILE", p.get("profile")); + update_env(_env, "ROCPROFSYS_PROFILE", p.get("profile")); }); parser .add_argument({ "-F", "--flat-profile" }, @@ -445,8 +445,8 @@ parse_args(int argc, char** argv, std::vector& _env) .max_count(1) .conflicts({ "profile" }) .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_PROFILE", p.get("flat-profile")); - update_env(_env, "OMNITRACE_FLAT_PROFILE", p.get("flat-profile")); + update_env(_env, "ROCPROFSYS_PROFILE", p.get("flat-profile")); + update_env(_env, "ROCPROFSYS_FLAT_PROFILE", p.get("flat-profile")); }); parser .add_argument({ "-H", "--host" }, @@ -456,8 +456,8 @@ parse_args(int argc, char** argv, std::vector& _env) .action([&](parser_t& p) { auto _h = p.get("host"); auto _d = p.get("device"); - update_env(_env, "OMNITRACE_USE_PROCESS_SAMPLING", _h || _d); - update_env(_env, "OMNITRACE_CPU_FREQ_ENABLED", _h); + update_env(_env, "ROCPROFSYS_USE_PROCESS_SAMPLING", _h || _d); + update_env(_env, "ROCPROFSYS_CPU_FREQ_ENABLED", _h); }); parser .add_argument({ "-D", "--device" }, @@ -467,8 +467,8 @@ parse_args(int argc, char** argv, std::vector& _env) .action([&](parser_t& p) { auto _h = p.get("host"); auto _d = p.get("device"); - update_env(_env, "OMNITRACE_USE_PROCESS_SAMPLING", _h || _d); - update_env(_env, "OMNITRACE_USE_ROCM_SMI", _d); + update_env(_env, "ROCPROFSYS_USE_PROCESS_SAMPLING", _h || _d); + update_env(_env, "ROCPROFSYS_USE_ROCM_SMI", _d); }); parser .add_argument({ "-w", "--wait" }, @@ -476,8 +476,8 @@ parse_args(int argc, char** argv, std::vector& _env) "'--sampling-wait'. See the descriptions for those two options.") .count(1) .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_TRACE_DELAY", p.get("wait")); - update_env(_env, "OMNITRACE_SAMPLING_DELAY", p.get("wait")); + update_env(_env, "ROCPROFSYS_TRACE_DELAY", p.get("wait")); + update_env(_env, "ROCPROFSYS_SAMPLING_DELAY", p.get("wait")); }); parser .add_argument( @@ -486,8 +486,8 @@ parse_args(int argc, char** argv, std::vector& _env) "'--sampling-duration'. See the descriptions for those two options.") .count(1) .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_TRACE_DURATION", p.get("duration")); - update_env(_env, "OMNITRACE_SAMPLING_DURATION", p.get("duration")); + update_env(_env, "ROCPROFSYS_TRACE_DURATION", p.get("duration")); + update_env(_env, "ROCPROFSYS_SAMPLING_DURATION", p.get("duration")); }); parser.start_group("TRACING OPTIONS", "Specific options controlling tracing (i.e. " @@ -499,7 +499,8 @@ parse_args(int argc, char** argv, std::vector& _env) .count(1) .dtype("filepath") .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_PERFETTO_FILE", p.get("trace-file")); + update_env(_env, "ROCPROFSYS_PERFETTO_FILE", + p.get("trace-file")); }); parser .add_argument({ "--trace-buffer-size" }, @@ -507,14 +508,14 @@ parse_args(int argc, char** argv, std::vector& _env) .count(1) .dtype("KB") .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_PERFETTO_BUFFER_SIZE_KB", + update_env(_env, "ROCPROFSYS_PERFETTO_BUFFER_SIZE_KB", p.get("trace-buffer-size")); }); parser.add_argument({ "--trace-fill-policy" }, _trace_policy_desc) .count(1) .choices({ "discard", "ring_buffer" }) .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_PERFETTO_FILL_POLICY", + update_env(_env, "ROCPROFSYS_PERFETTO_FILL_POLICY", p.get("trace-fill-policy")); }); parser @@ -525,7 +526,7 @@ parse_args(int argc, char** argv, std::vector& _env) "but that can changed via --trace-clock-id.") .count(1) .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_TRACE_DELAY", p.get("trace-wait")); + update_env(_env, "ROCPROFSYS_TRACE_DELAY", p.get("trace-wait")); }); parser .add_argument({ "--trace-duration" }, @@ -534,7 +535,8 @@ parse_args(int argc, char** argv, std::vector& _env) "that can changed via --trace-clock-id.") .count(1) .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_TRACE_DURATION", p.get("trace-duration")); + update_env(_env, "ROCPROFSYS_TRACE_DURATION", + p.get("trace-duration")); }); parser .add_argument( @@ -544,7 +546,7 @@ parse_args(int argc, char** argv, std::vector& _env) "and/or :::.") .min_count(1) .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_TRACE_PERIODS", + update_env(_env, "ROCPROFSYS_TRACE_PERIODS", join(array_config{ ",", "", "" }, p.get>("trace-periods"))); }); @@ -556,10 +558,10 @@ parse_args(int argc, char** argv, std::vector& _env) "threads, i.e. 4 seconds of CPU-time for an application with 4 fully active " "threads would equate to ~1 second of realtime. If this proves to be " "difficult to handle in practice, please file a feature request for " - "omnitrace to auto-scale based on the number of threads.") + "rocprof-sys to auto-scale based on the number of threads.") .count(1) .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_TRACE_PERIOD_CLOCK_ID", + update_env(_env, "ROCPROFSYS_TRACE_PERIOD_CLOCK_ID", p.get("trace-clock-id")); }) .choices(clock_id_choices.first) @@ -575,12 +577,12 @@ parse_args(int argc, char** argv, std::vector& _env) .choices({ "text", "json", "console" }) .action([&](parser_t& p) { auto _v = p.get>("profile"); - update_env(_env, "OMNITRACE_PROFILE", true); + update_env(_env, "ROCPROFSYS_PROFILE", true); if(!_v.empty()) { - update_env(_env, "OMNITRACE_TEXT_OUTPUT", _v.count("text") != 0); - update_env(_env, "OMNITRACE_JSON_OUTPUT", _v.count("json") != 0); - update_env(_env, "OMNITRACE_COUT_OUTPUT", _v.count("console") != 0); + update_env(_env, "ROCPROFSYS_TEXT_OUTPUT", _v.count("text") != 0); + update_env(_env, "ROCPROFSYS_JSON_OUTPUT", _v.count("json") != 0); + update_env(_env, "ROCPROFSYS_COUT_OUTPUT", _v.count("console") != 0); } }); @@ -593,9 +595,9 @@ parse_args(int argc, char** argv, std::vector& _env) .max_count(2) .action([&](parser_t& p) { auto _v = p.get>("profile-diff"); - update_env(_env, "OMNITRACE_DIFF_OUTPUT", true); - update_env(_env, "OMNITRACE_INPUT_PATH", _v.at(0)); - if(_v.size() > 1) update_env(_env, "OMNITRACE_INPUT_PREFIX", _v.at(1)); + update_env(_env, "ROCPROFSYS_DIFF_OUTPUT", true); + update_env(_env, "ROCPROFSYS_INPUT_PATH", _v.at(0)); + if(_v.size() > 1) update_env(_env, "ROCPROFSYS_INPUT_PREFIX", _v.at(1)); }); parser.start_group( @@ -608,7 +610,7 @@ parse_args(int argc, char** argv, std::vector& _env) "(number of interrupts per second)") .count(1) .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_PROCESS_SAMPLING_FREQ", + update_env(_env, "ROCPROFSYS_PROCESS_SAMPLING_FREQ", p.get("process-freq")); }); parser @@ -617,7 +619,7 @@ parse_args(int argc, char** argv, std::vector& _env) "(in seconds of realtime)") .count(1) .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_PROCESS_SAMPLING_DELAY", + update_env(_env, "ROCPROFSYS_PROCESS_SAMPLING_DELAY", p.get("process-wait")); }); parser @@ -626,7 +628,7 @@ parse_args(int argc, char** argv, std::vector& _env) "Set the duration of the host/device sampling (in seconds of realtime)") .count(1) .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_SAMPLING_PROCESS_DURATION", + update_env(_env, "ROCPROFSYS_SAMPLING_PROCESS_DURATION", p.get("process-duration")); }); parser @@ -636,7 +638,7 @@ parse_args(int argc, char** argv, std::vector& _env) .required({ "host" }) .action([&](parser_t& p) { update_env( - _env, "OMNITRACE_SAMPLING_CPUS", + _env, "ROCPROFSYS_SAMPLING_CPUS", join(array_config{ "," }, p.get>("cpus"))); }); parser @@ -646,7 +648,7 @@ parse_args(int argc, char** argv, std::vector& _env) .required({ "device" }) .action([&](parser_t& p) { update_env( - _env, "OMNITRACE_SAMPLING_GPUS", + _env, "ROCPROFSYS_SAMPLING_GPUS", join(array_config{ "," }, p.get>("gpus"))); }); @@ -657,7 +659,7 @@ parse_args(int argc, char** argv, std::vector& _env) "(number of interrupts per second)") .count(1) .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_SAMPLING_FREQ", p.get("freq")); + update_env(_env, "ROCPROFSYS_SAMPLING_FREQ", p.get("freq")); }); parser .add_argument( @@ -667,7 +669,7 @@ parse_args(int argc, char** argv, std::vector& _env) "delay of 1 second for CPU-clock sampler may not equal 1 second of realtime") .count(1) .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_SAMPLING_DELAY", p.get("sampling-wait")); + update_env(_env, "ROCPROFSYS_SAMPLING_DELAY", p.get("sampling-wait")); }); parser .add_argument( @@ -677,7 +679,7 @@ parse_args(int argc, char** argv, std::vector& _env) "real-time duration... resulting in zero samples being taken") .count(1) .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_SAMPLING_DURATION", + update_env(_env, "ROCPROFSYS_SAMPLING_DURATION", p.get("sampling-duration")); }); parser @@ -687,7 +689,7 @@ parse_args(int argc, char** argv, std::vector& _env) "is assigned an atomically incrementing value.") .min_count(1) .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_SAMPLING_TIDS", + update_env(_env, "ROCPROFSYS_SAMPLING_TIDS", join(array_config{ ", " }, p.get>("tids"))); }); @@ -698,20 +700,20 @@ parse_args(int argc, char** argv, std::vector& _env) .min_count(0) .action([&](parser_t& p) { auto _v = p.get>("cputime"); - update_env(_env, "OMNITRACE_SAMPLING_CPUTIME", true); + update_env(_env, "ROCPROFSYS_SAMPLING_CPUTIME", true); if(!_v.empty()) { - update_env(_env, "OMNITRACE_SAMPLING_CPUTIME_FREQ", _v.front()); + update_env(_env, "ROCPROFSYS_SAMPLING_CPUTIME_FREQ", _v.front()); _v.pop_front(); } if(!_v.empty()) { - update_env(_env, "OMNITRACE_SAMPLING_CPUTIME_DELAY", _v.front()); + update_env(_env, "ROCPROFSYS_SAMPLING_CPUTIME_DELAY", _v.front()); _v.pop_front(); } if(!_v.empty()) { - update_env(_env, "OMNITRACE_SAMPLING_CPUTIME_TIDS", + update_env(_env, "ROCPROFSYS_SAMPLING_CPUTIME_TIDS", join(array_config{ "," }, _v)); } }); @@ -721,20 +723,20 @@ parse_args(int argc, char** argv, std::vector& _env) .required(std::move(_realtime_reqs)) .action([&](parser_t& p) { auto _v = p.get>("realtime"); - update_env(_env, "OMNITRACE_SAMPLING_REALTIME", true); + update_env(_env, "ROCPROFSYS_SAMPLING_REALTIME", true); if(!_v.empty()) { - update_env(_env, "OMNITRACE_SAMPLING_REALTIME_FREQ", _v.front()); + update_env(_env, "ROCPROFSYS_SAMPLING_REALTIME_FREQ", _v.front()); _v.pop_front(); } if(!_v.empty()) { - update_env(_env, "OMNITRACE_SAMPLING_REALTIME_DELAY", _v.front()); + update_env(_env, "ROCPROFSYS_SAMPLING_REALTIME_DELAY", _v.front()); _v.pop_front(); } if(!_v.empty()) { - update_env(_env, "OMNITRACE_SAMPLING_REALTIME_TIDS", + update_env(_env, "ROCPROFSYS_SAMPLING_REALTIME_TIDS", join(array_config{ "," }, _v)); } }); @@ -744,28 +746,28 @@ parse_args(int argc, char** argv, std::vector& _env) "roctracer", "rocprofiler", "roctx", "mutex-locks", "spin-locks", "rw-locks" }; -#if !defined(OMNITRACE_USE_MPI) && !defined(OMNITRACE_USE_MPI_HEADERS) +#if !defined(ROCPROFSYS_USE_MPI) && !defined(ROCPROFSYS_USE_MPI_HEADERS) _backend_choices.erase("mpip"); #endif -#if !defined(OMNITRACE_USE_OMPT) +#if !defined(ROCPROFSYS_USE_OMPT) _backend_choices.erase("ompt"); #endif -#if !defined(OMNITRACE_USE_RCCL) +#if !defined(ROCPROFSYS_USE_RCCL) _backend_choices.erase("rcclp"); #endif -#if !defined(OMNITRACE_USE_ROCM_SMI) +#if !defined(ROCPROFSYS_USE_ROCM_SMI) _backend_choices.erase("rocm-smi"); #endif -#if !defined(OMNITRACE_USE_ROCTRACER) +#if !defined(ROCPROFSYS_USE_ROCTRACER) _backend_choices.erase("roctracer"); _backend_choices.erase("roctx"); #endif -#if !defined(OMNITRACE_USE_ROCPROFILER) +#if !defined(ROCPROFSYS_USE_ROCPROFILER) _backend_choices.erase("rocprofiler"); #endif @@ -779,17 +781,17 @@ parse_args(int argc, char** argv, std::vector& _env) auto _update = [&](const auto& _opt, bool _cond) { if(_cond || _v.count("all") > 0) update_env(_env, _opt, true); }; - _update("OMNITRACE_USE_KOKKOSP", _v.count("kokkosp") > 0); - _update("OMNITRACE_USE_MPIP", _v.count("mpip") > 0); - _update("OMNITRACE_USE_OMPT", _v.count("ompt") > 0); - _update("OMNITRACE_USE_RCCLP", _v.count("rcclp") > 0); - _update("OMNITRACE_USE_ROCTX", _v.count("roctx") > 0); - _update("OMNITRACE_USE_ROCM_SMI", _v.count("rocm-smi") > 0); - _update("OMNITRACE_USE_ROCTRACER", _v.count("roctracer") > 0); - _update("OMNITRACE_USE_ROCPROFILER", _v.count("rocprofiler") > 0); - _update("OMNITRACE_TRACE_THREAD_LOCKS", _v.count("mutex-locks") > 0); - _update("OMNITRACE_TRACE_THREAD_RW_LOCKS", _v.count("rw-locks") > 0); - _update("OMNITRACE_TRACE_THREAD_SPIN_LOCKS", _v.count("spin-locks") > 0); + _update("ROCPROFSYS_USE_KOKKOSP", _v.count("kokkosp") > 0); + _update("ROCPROFSYS_USE_MPIP", _v.count("mpip") > 0); + _update("ROCPROFSYS_USE_OMPT", _v.count("ompt") > 0); + _update("ROCPROFSYS_USE_RCCLP", _v.count("rcclp") > 0); + _update("ROCPROFSYS_USE_ROCTX", _v.count("roctx") > 0); + _update("ROCPROFSYS_USE_ROCM_SMI", _v.count("rocm-smi") > 0); + _update("ROCPROFSYS_USE_ROCTRACER", _v.count("roctracer") > 0); + _update("ROCPROFSYS_USE_ROCPROFILER", _v.count("rocprofiler") > 0); + _update("ROCPROFSYS_TRACE_THREAD_LOCKS", _v.count("mutex-locks") > 0); + _update("ROCPROFSYS_TRACE_THREAD_RW_LOCKS", _v.count("rw-locks") > 0); + _update("ROCPROFSYS_TRACE_THREAD_SPIN_LOCKS", _v.count("spin-locks") > 0); if(_v.count("all") > 0 || _v.count("ompt") > 0) update_env(_env, "OMP_TOOL_LIBRARIES", _dl_libpath, UPD_APPEND); @@ -805,17 +807,17 @@ parse_args(int argc, char** argv, std::vector& _env) auto _update = [&](const auto& _opt, bool _cond) { if(_cond || _v.count("all") > 0) update_env(_env, _opt, false); }; - _update("OMNITRACE_USE_KOKKOSP", _v.count("kokkosp") > 0); - _update("OMNITRACE_USE_MPIP", _v.count("mpip") > 0); - _update("OMNITRACE_USE_OMPT", _v.count("ompt") > 0); - _update("OMNITRACE_USE_RCCLP", _v.count("rcclp") > 0); - _update("OMNITRACE_USE_ROCTX", _v.count("roctx") > 0); - _update("OMNITRACE_USE_ROCM_SMI", _v.count("rocm-smi") > 0); - _update("OMNITRACE_USE_ROCTRACER", _v.count("roctracer") > 0); - _update("OMNITRACE_USE_ROCPROFILER", _v.count("rocprofiler") > 0); - _update("OMNITRACE_TRACE_THREAD_LOCKS", _v.count("mutex-locks") > 0); - _update("OMNITRACE_TRACE_THREAD_RW_LOCKS", _v.count("rw-locks") > 0); - _update("OMNITRACE_TRACE_THREAD_SPIN_LOCKS", _v.count("spin-locks") > 0); + _update("ROCPROFSYS_USE_KOKKOSP", _v.count("kokkosp") > 0); + _update("ROCPROFSYS_USE_MPIP", _v.count("mpip") > 0); + _update("ROCPROFSYS_USE_OMPT", _v.count("ompt") > 0); + _update("ROCPROFSYS_USE_RCCLP", _v.count("rcclp") > 0); + _update("ROCPROFSYS_USE_ROCTX", _v.count("roctx") > 0); + _update("ROCPROFSYS_USE_ROCM_SMI", _v.count("rocm-smi") > 0); + _update("ROCPROFSYS_USE_ROCTRACER", _v.count("roctracer") > 0); + _update("ROCPROFSYS_USE_ROCPROFILER", _v.count("rocprofiler") > 0); + _update("ROCPROFSYS_TRACE_THREAD_LOCKS", _v.count("mutex-locks") > 0); + _update("ROCPROFSYS_TRACE_THREAD_RW_LOCKS", _v.count("rw-locks") > 0); + _update("ROCPROFSYS_TRACE_THREAD_SPIN_LOCKS", _v.count("spin-locks") > 0); if(_v.count("all") > 0 || (_v.count("roctracer") > 0 && _v.count("rocprofiler") > 0)) @@ -837,26 +839,26 @@ 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")); - update_env(_env, "OMNITRACE_PAPI_EVENTS", _events); + update_env(_env, "ROCPROFSYS_PAPI_EVENTS", _events); }); -#if defined(OMNITRACE_USE_ROCPROFILER) +#if defined(ROCPROFSYS_USE_ROCPROFILER) 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")); - update_env(_env, "OMNITRACE_ROCM_EVENTS", _events); + update_env(_env, "ROCPROFSYS_ROCM_EVENTS", _events); }); #endif @@ -866,7 +868,7 @@ parse_args(int argc, char** argv, std::vector& _env) "Include inline info in output when available") .max_count(1) .action([&](parser_t& p) { - update_env(_env, "OMNITRACE_SAMPLING_INCLUDE_INLINES", + update_env(_env, "ROCPROFSYS_SAMPLING_INCLUDE_INLINES", p.get("inlines")); }); @@ -906,7 +908,7 @@ parse_args(int argc, char** argv, std::vector& _env) throw std::runtime_error(_cerr.what()); if(parser.exists("realtime") && !parser.exists("cputime")) - update_env(_env, "OMNITRACE_SAMPLING_CPUTIME", false); + update_env(_env, "ROCPROFSYS_SAMPLING_CPUTIME", false); if(parser.exists("profile") && parser.exists("flat-profile")) throw std::runtime_error( "Error! '--profile' argument conflicts with '--flat-profile' argument"); diff --git a/source/bin/omnitrace-sample/omnitrace-sample.cpp b/source/bin/rocprof-sys-sample/rocprof-sys-sample.cpp similarity index 94% rename from source/bin/omnitrace-sample/omnitrace-sample.cpp rename to source/bin/rocprof-sys-sample/rocprof-sys-sample.cpp index f1cf7ac5..e68cd7ff 100644 --- a/source/bin/omnitrace-sample/omnitrace-sample.cpp +++ b/source/bin/rocprof-sys-sample/rocprof-sys-sample.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -20,7 +20,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include "omnitrace-sample.hpp" +#include "rocprof-sys-sample.hpp" #include #include diff --git a/source/bin/omnitrace-sample/omnitrace-sample.hpp b/source/bin/rocprof-sys-sample/rocprof-sys-sample.hpp similarity index 100% rename from source/bin/omnitrace-sample/omnitrace-sample.hpp rename to source/bin/rocprof-sys-sample/rocprof-sys-sample.hpp diff --git a/source/bin/tests/CMakeLists.txt b/source/bin/tests/CMakeLists.txt index bb1123ac..36d27823 100644 --- a/source/bin/tests/CMakeLists.txt +++ b/source/bin/tests/CMakeLists.txt @@ -1,10 +1,10 @@ -set(OMNITRACE_ABORT_FAIL_REGEX +set(ROCPROFSYS_ABORT_FAIL_REGEX "### ERROR ###|unknown-hash=|address of faulting memory reference|exiting with non-zero exit code|terminate called after throwing an instance|calling abort.. in |Exit code: [1-9]" CACHE INTERNAL "Regex to catch abnormal exits when a PASS_REGULAR_EXPRESSION is set" FORCE) # adds a ctest for executable -function(OMNITRACE_ADD_BIN_TEST) +function(ROCPROFILER_SYSTEMS_ADD_BIN_TEST) cmake_parse_arguments( TEST "" # options @@ -19,10 +19,10 @@ function(OMNITRACE_ADD_BIN_TEST) if(NOT TEST_ENVIRONMENT) set(TEST_ENVIRONMENT - "OMNITRACE_TRACE=ON" - "OMNITRACE_PROFILE=ON" - "OMNITRACE_USE_SAMPLING=ON" - "OMNITRACE_TIME_OUTPUT=OFF" + "ROCPROFSYS_TRACE=ON" + "ROCPROFSYS_PROFILE=ON" + "ROCPROFSYS_USE_SAMPLING=ON" + "ROCPROFSYS_TIME_OUTPUT=OFF" "LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}:$ENV{LD_LIBRARY_PATH}" ) endif() @@ -31,31 +31,31 @@ function(OMNITRACE_ADD_BIN_TEST) list( APPEND TEST_ENVIRONMENT - "OMNITRACE_CI=ON" - "OMNITRACE_CI_TIMEOUT=${TEST_TIMEOUT}" - "OMNITRACE_CONFIG_FILE=" - "OMNITRACE_OUTPUT_PATH=${PROJECT_BINARY_DIR}/omnitrace-tests-output" + "ROCPROFSYS_CI=ON" + "ROCPROFSYS_CI_TIMEOUT=${TEST_TIMEOUT}" + "ROCPROFSYS_CONFIG_FILE=" + "ROCPROFSYS_OUTPUT_PATH=${PROJECT_BINARY_DIR}/rocprof-sys-tests-output" "TWD=${TEST_WORKING_DIRECTORY}") # copy for inverse set(TEST_ENVIRONMENT_INV "${TEST_ENVIRONMENT}") # different for regular test and inverse test - list(APPEND TEST_ENVIRONMENT "OMNITRACE_OUTPUT_PREFIX=${TEST_NAME}/") - list(APPEND TEST_ENVIRONMENT_INV "OMNITRACE_OUTPUT_PREFIX=${TEST_NAME}-inverse/") + list(APPEND TEST_ENVIRONMENT "ROCPROFSYS_OUTPUT_PREFIX=${TEST_NAME}/") + list(APPEND TEST_ENVIRONMENT_INV "ROCPROFSYS_OUTPUT_PREFIX=${TEST_NAME}-inverse/") if(NOT "${TEST_PASS_REGEX}" STREQUAL "" AND NOT "${TEST_FAIL_REGEX}" STREQUAL "" - AND NOT "${TEST_FAIL_REGEX}" MATCHES "\\|OMNITRACE_ABORT_FAIL_REGEX") - omnitrace_message( + AND NOT "${TEST_FAIL_REGEX}" MATCHES "\\|ROCPROFSYS_ABORT_FAIL_REGEX") + rocprofiler_systems_message( FATAL_ERROR - "${TEST_NAME} has set pass and fail regexes but fail regex does not include '|OMNITRACE_ABORT_FAIL_REGEX'" + "${TEST_NAME} has set pass and fail regexes but fail regex does not include '|ROCPROFSYS_ABORT_FAIL_REGEX'" ) endif() if("${TEST_FAIL_REGEX}" STREQUAL "") - set(TEST_FAIL_REGEX "(${OMNITRACE_ABORT_FAIL_REGEX})") + set(TEST_FAIL_REGEX "(${ROCPROFSYS_ABORT_FAIL_REGEX})") else() - string(REPLACE "|OMNITRACE_ABORT_FAIL_REGEX" "|${OMNITRACE_ABORT_FAIL_REGEX}" + string(REPLACE "|ROCPROFSYS_ABORT_FAIL_REGEX" "|${ROCPROFSYS_ABORT_FAIL_REGEX}" TEST_FAIL_REGEX "${TEST_FAIL_REGEX}") endif() @@ -74,7 +74,7 @@ function(OMNITRACE_ADD_BIN_TEST) DEPENDS "${TEST_DEPENDS}" LABELS - "omnitrace-bin;${TEST_LABELS}" + "rocprofiler-systems-bin;${TEST_LABELS}" PASS_REGULAR_EXPRESSION "${TEST_PASS_REGEX}" FAIL_REGULAR_EXPRESSION @@ -97,7 +97,7 @@ function(OMNITRACE_ADD_BIN_TEST) DEPENDS "${TEST_DEPENDS}" LABELS - "omnitrace-bin;${TEST_LABELS}" + "rocprofiler-systems-bin;${TEST_LABELS}" PASS_REGULAR_EXPRESSION "${TEST_PASS_REGEX}" FAIL_REGULAR_EXPRESSION @@ -105,19 +105,19 @@ function(OMNITRACE_ADD_BIN_TEST) SKIP_REGULAR_EXPRESSION "${TEST_SKIP_REGEX}" ${TEST_PROPERTIES}) - elseif(OMNITRACE_BUILD_TESTING) + elseif(ROCPROFSYS_BUILD_TESTING) message(FATAL_ERROR "Error! ${TEST_TARGET} does not exist") endif() endfunction() -omnitrace_add_bin_test( - NAME omnitrace-instrument-help - TARGET omnitrace-instrument +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-instrument-help + TARGET rocprofiler-systems-instrument ARGS --help - LABELS omnitrace-instrument + LABELS rocprofiler-systems-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` @@ -129,9 +129,9 @@ else() set(LS_ARGS) endif() -omnitrace_add_bin_test( - NAME omnitrace-instrument-simulate-ls - TARGET omnitrace-instrument +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-instrument-simulate-ls + TARGET rocprofiler-systems-instrument ARGS --simulate --print-format json @@ -146,45 +146,48 @@ omnitrace_add_bin_test( LABELS "simulate" 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 +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-instrument-simulate-ls-check + DEPENDS rocprofiler-systems-instrument-simulate-ls + COMMAND + ls + rocprof-sys-tests-output/rocprofiler-systems-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") + FAIL_REGEX "No such file or directory|not found|ROCPROFSYS_ABORT_FAIL_REGEX") -omnitrace_add_bin_test( - NAME omnitrace-instrument-simulate-lib - TARGET omnitrace-instrument - ARGS --print-available functions -v 2 -- $ +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-instrument-simulate-lib + TARGET rocprofiler-systems-instrument + ARGS --print-available functions -v 2 -- + $ LABELS "simulate" TIMEOUT 120 PASS_REGEX - "\\\[omnitrace\\\]\\\[exe\\\] Runtime instrumentation is not possible!(.*)\n(.*)\\\[omnitrace\\\]\\\[exe\\\] Switching to binary rewrite mode and assuming '--simulate --all-functions'" + "\\\[rocprof-sys\\\]\\\[exe\\\] Runtime instrumentation is not possible!(.*)\n(.*)\\\[rocprof-sys\\\]\\\[exe\\\] Switching to binary rewrite mode and assuming '--simulate --all-functions'" ) -file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/omnitrace-tests-output/tmp) +file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/rocprof-sys-tests-output/tmp) -omnitrace_add_bin_test( - NAME omnitrace-instrument-simulate-lib-basename - TARGET omnitrace-instrument +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-instrument-simulate-lib-basename + TARGET rocprofiler-systems-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}/rocprof-sys-tests-output/rocprof-sys-instrument-simulate-lib-basename/${CMAKE_SHARED_LIBRARY_PREFIX}$${CMAKE_SHARED_LIBRARY_SUFFIX} -- - ${CMAKE_SHARED_LIBRARY_PREFIX}$${CMAKE_SHARED_LIBRARY_SUFFIX} + ${CMAKE_SHARED_LIBRARY_PREFIX}$${CMAKE_SHARED_LIBRARY_SUFFIX} LABELS "simulate" TIMEOUT 120 - WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/omnitrace-tests-output/tmp) + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/rocprof-sys-tests-output/tmp) -omnitrace_add_bin_test( - NAME omnitrace-instrument-write-log - TARGET omnitrace-instrument +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-instrument-write-log + TARGET rocprofiler-systems-instrument ARGS --print-instrumented functions -v @@ -198,98 +201,99 @@ omnitrace_add_bin_test( TIMEOUT 120 PASS_REGEX "Opening .*/instrumentation/user.log") -omnitrace_add_bin_test( - NAME omnitrace-instrument-write-log-check - DEPENDS omnitrace-instrument-write-log - COMMAND ls - omnitrace-tests-output/omnitrace-instrument-write-log/instrumentation/user.log +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-instrument-write-log-check + DEPENDS rocprofiler-systems-instrument-write-log + COMMAND + ls + rocprof-sys-tests-output/rocprofiler-systems-instrument-write-log/instrumentation/user.log LABELS "log" TIMEOUT 60 PASS_REGEX "user.log" - FAIL_REGEX "No such file or directory|not found|OMNITRACE_ABORT_FAIL_REGEX") + FAIL_REGEX "No such file or directory|not found|ROCPROFSYS_ABORT_FAIL_REGEX") -omnitrace_add_bin_test( - NAME omnitrace-avail-help - TARGET omnitrace-avail +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-avail-help + TARGET rocprofiler-systems-avail ARGS --help - LABELS "omnitrace-avail" + LABELS "rocprofiler-systems-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 - TARGET omnitrace-avail +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-avail-all + TARGET rocprofiler-systems-avail ARGS --all - LABELS "omnitrace-avail" + LABELS "rocprofiler-systems-avail" TIMEOUT 45) -omnitrace_add_bin_test( - NAME omnitrace-avail-all-expand-keys - TARGET omnitrace-avail +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-avail-all-expand-keys + TARGET rocprofiler-systems-avail ARGS --all --expand-keys - LABELS "omnitrace-avail" + LABELS "rocprofiler-systems-avail" TIMEOUT 45 - FAIL_REGEX "%[a-zA-Z_]%|OMNITRACE_ABORT_FAIL_REGEX") + FAIL_REGEX "%[a-zA-Z_]%|ROCPROFSYS_ABORT_FAIL_REGEX") -omnitrace_add_bin_test( - NAME omnitrace-avail-all-only-available-alphabetical - TARGET omnitrace-avail +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-avail-all-only-available-alphabetical + TARGET rocprofiler-systems-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 "rocprofiler-systems-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 - TARGET omnitrace-avail +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-avail-all-csv + TARGET rocprofiler-systems-avail ARGS --all --csv --csv-separator "#" - LABELS "omnitrace-avail" + LABELS "rocprofiler-systems-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 - TARGET omnitrace-avail +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-avail-filter-wall-clock-available + TARGET rocprofiler-systems-avail ARGS -r wall_clock -C --available - LABELS "omnitrace-avail" + LABELS "rocprofiler-systems-avail" TIMEOUT 45 PASS_REGEX "\\\|[-]+\\\|\n\\\|[ ]+COMPONENT[ ]+\\\|\n\\\|[-]+\\\|\n\\\| (wall_clock)[ ]+\\\|\n\\\|[-]+\\\|" ) -omnitrace_add_bin_test( - NAME omnitrace-avail-category-filter-omnitrace - TARGET omnitrace-avail - ARGS --categories settings::omnitrace --brief - LABELS "omnitrace-avail" +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-avail-category-filter-rocprofiler-systems + TARGET rocprofiler-systems-avail + ARGS --categories settings::rocprofsys --brief + LABELS "rocprofiler-systems-avail" TIMEOUT 45 - PASS_REGEX "OMNITRACE_(SETTINGS_DESC|OUTPUT_FILE|OUTPUT_PREFIX)" + PASS_REGEX "ROCPROFSYS_(SETTINGS_DESC|OUTPUT_FILE|OUTPUT_PREFIX)" FAIL_REGEX - "OMNITRACE_(ADD_SECONDARY|SCIENTIFIC|PRECISION|MEMORY_PRECISION|TIMING_PRECISION)|OMNITRACE_ABORT_FAIL_REGEX" + "ROCPROFSYS_(ADD_SECONDARY|SCIENTIFIC|PRECISION|MEMORY_PRECISION|TIMING_PRECISION)|ROCPROFSYS_ABORT_FAIL_REGEX" ) -omnitrace_add_bin_test( - NAME omnitrace-avail-category-filter-timemory - TARGET omnitrace-avail +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-avail-category-filter-timemory + TARGET rocprofiler-systems-avail ARGS --categories settings::timemory --brief --advanced - LABELS "omnitrace-avail" + LABELS "rocprofiler-systems-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") + "ROCPROFSYS_(ADD_SECONDARY|SCIENTIFIC|PRECISION|MEMORY_PRECISION|TIMING_PRECISION)" + FAIL_REGEX "ROCPROFSYS_(SETTINGS_DESC|OUTPUT_FILE)|ROCPROFSYS_ABORT_FAIL_REGEX") -omnitrace_add_bin_test( - NAME omnitrace-avail-regex-negation - TARGET omnitrace-avail +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-avail-regex-negation + TARGET rocprofiler-systems-avail ARGS -R - omnitrace + rocprofsys ~timemory -r _P @@ -299,20 +303,22 @@ omnitrace_add_bin_test( --csv --brief --advanced - LABELS "omnitrace-avail" + LABELS "rocprofiler-systems-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") + "ENVIRONMENT VARIABLE,[ \n]+ROCPROFSYS_THREAD_POOL_SIZE,[ \n]+ROCPROFSYS_USE_PID,[ \n]+" + FAIL_REGEX "ROCPROFSYS_TRACE|ROCPROFSYS_ABORT_FAIL_REGEX") -string(REPLACE "+" "\\\+" _AVAIL_CFG_PATH - "${PROJECT_BINARY_DIR}/omnitrace-tests-output/omnitrace-avail/omnitrace-") +string( + REPLACE + "+" "\\\+" _AVAIL_CFG_PATH + "${PROJECT_BINARY_DIR}/rocprof-sys-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 - TARGET omnitrace-avail +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-avail-write-config + TARGET rocprofiler-systems-avail ARGS -G - %env{TWD}%/omnitrace-tests-output/omnitrace-avail/omnitrace-test.cfg + %env{TWD}%/rocprof-sys-tests-output/rocprof-sys-avail/rocprof-sys-test.cfg -F txt json @@ -320,69 +326,69 @@ omnitrace_add_bin_test( --force --all -c - omnitrace + rocprofsys TIMEOUT 45 - LABELS "omnitrace-avail" + LABELS "rocprofiler-systems-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 - TARGET omnitrace-avail - ARGS -G %env{TWD}%/omnitrace-tests-output/omnitrace-avail/omnitrace-tweak.cfg -F txt - json xml --force +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-avail-write-config-tweak + TARGET rocprofiler-systems-avail + ARGS -G %env{TWD}%/rocprof-sys-tests-output/rocprof-sys-avail/rocprof-sys-tweak.cfg -F + txt json xml --force TIMEOUT 45 - LABELS "omnitrace-avail" - ENVIRONMENT "OMNITRACE_TRACE=OFF;OMNITRACE_PROFILE=ON" + LABELS "rocprofiler-systems-avail" + ENVIRONMENT "ROCPROFSYS_TRACE=OFF;ROCPROFSYS_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 - TARGET omnitrace-avail +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-avail-list-keys + TARGET rocprofiler-systems-avail ARGS --list-keys --expand-keys TIMEOUT 45 - LABELS "omnitrace-avail" + LABELS "rocprofiler-systems-avail" PASS_REGEX "Output Keys:\n(.*)%argv%(.*)%argv_hash%") -omnitrace_add_bin_test( - NAME omnitrace-avail-list-keys-markdown - TARGET omnitrace-avail +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-avail-list-keys-markdown + TARGET rocprofiler-systems-avail ARGS --list-keys --expand-keys --markdown TIMEOUT 45 - LABELS "omnitrace-avail;markdown" + LABELS "rocprofiler-systems-avail;markdown" PASS_REGEX "(.*)`%argv%`(.*)`%argv_hash%`") -omnitrace_add_bin_test( - NAME omnitrace-avail-list-categories - TARGET omnitrace-avail +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-avail-list-categories + TARGET rocprofiler-systems-avail ARGS --list-categories TIMEOUT 45 - LABELS "omnitrace-avail" + LABELS "rocprofiler-systems-avail" PASS_REGEX " component::(.*) hw_counters::(.*) settings::") -omnitrace_add_bin_test( - NAME omnitrace-avail-core-categories - TARGET omnitrace-avail +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-avail-core-categories + TARGET rocprofiler-systems-avail ARGS -c core TIMEOUT 45 - LABELS "omnitrace-avail" + LABELS "rocprofiler-systems-avail" PASS_REGEX - "OMNITRACE_CONFIG_FILE(.*)OMNITRACE_ENABLED(.*)OMNITRACE_SUPPRESS_CONFIG(.*)OMNITRACE_SUPPRESS_PARSING(.*)OMNITRACE_VERBOSE" + "ROCPROFSYS_CONFIG_FILE(.*)ROCPROFSYS_ENABLED(.*)ROCPROFSYS_SUPPRESS_CONFIG(.*)ROCPROFSYS_SUPPRESS_PARSING(.*)ROCPROFSYS_VERBOSE" ) -omnitrace_add_bin_test( - NAME omnitrace-run-help - TARGET omnitrace-run +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-run-help + TARGET rocprofiler-systems-run ARGS --help TIMEOUT 45 - LABELS "omnitrace-run") + LABELS "rocprofiler-systems-run") -file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/omnitrace-tests-config") +file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/rocprof-sys-tests-config") file( - WRITE "${PROJECT_BINARY_DIR}/omnitrace-tests-config/empty.cfg" + WRITE "${PROJECT_BINARY_DIR}/rocprof-sys-tests-config/empty.cfg" " # # empty config file @@ -394,18 +400,18 @@ set_target_properties( sleeper PROPERTIES BUILD_TYPE RelWithDebInfo RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin/testing) -omnitrace_add_bin_test( - NAME omnitrace-run-args - TARGET omnitrace-run +rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-run-args + TARGET rocprofiler-systems-run ARGS --monochrome --debug=false -v 1 -c - %env{TWD}%/omnitrace-tests-config/empty.cfg + %env{TWD}%/rocprof-sys-tests-config/empty.cfg -o - omnitrace-tests-output - omnitrace-run-args-output/ + rocprof-sys-tests-output + rocprofiler-systems-run-args-output/ -TPHD -S cputime @@ -469,7 +475,7 @@ omnitrace_add_bin_test( --kokkosp-name-length-max=1024 --kokkosp-prefix="[kokkos]" --tmpdir - ${CMAKE_BINARY_DIR}/omnitrace-tests-config/tmpdir + ${CMAKE_BINARY_DIR}/rocprof-sys-tests-config/tmpdir --perfetto-backend inprocess --use-pid @@ -488,4 +494,4 @@ omnitrace_add_bin_test( $ 5 TIMEOUT 45 - LABELS "omnitrace-run") + LABELS "rocprofiler-systems-run") diff --git a/source/docs/images/omnitrace-perfetto.png b/source/docs/images/rocprof-sys-perfetto.png similarity index 100% rename from source/docs/images/omnitrace-perfetto.png rename to source/docs/images/rocprof-sys-perfetto.png diff --git a/source/docs/images/omnitrace-rocm-flow.png b/source/docs/images/rocprof-sys-rocm-flow.png similarity index 100% rename from source/docs/images/omnitrace-rocm-flow.png rename to source/docs/images/rocprof-sys-rocm-flow.png diff --git a/source/docs/images/omnitrace-rocm.png b/source/docs/images/rocprof-sys-rocm.png similarity index 100% rename from source/docs/images/omnitrace-rocm.png rename to source/docs/images/rocprof-sys-rocm.png diff --git a/source/docs/images/omnitrace-user-api.png b/source/docs/images/rocprof-sys-user-api.png similarity index 100% rename from source/docs/images/omnitrace-user-api.png rename to source/docs/images/rocprof-sys-user-api.png diff --git a/source/docs/omnitrace.dox.in b/source/docs/rocprof-sys.dox.in similarity index 100% rename from source/docs/omnitrace.dox.in rename to source/docs/rocprof-sys.dox.in diff --git a/source/lib/CMakeLists.txt b/source/lib/CMakeLists.txt index e1a5d06f..6d93bf78 100644 --- a/source/lib/CMakeLists.txt +++ b/source/lib/CMakeLists.txt @@ -1,10 +1,10 @@ # ----------------------------------------------------------------------------- # # -# omnitrace: contains all instrumentation functionality +# rocprofiler-systems: contains all instrumentation functionality # -# omnitrace-dl: contains minimal symbols and dlopen's omnitrace +# rocprofiler-systems-dl: contains minimal symbols and dlopen's rocprofiler-systems # -# omnitrace-user: contains symbols for user API +# rocprofiler-systems-user: contains symbols for user API # # ----------------------------------------------------------------------------- # @@ -12,56 +12,58 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20) cmake_policy(SET CMP0115 NEW) endif() -if(OMNITRACE_USE_ROCPROFILER +if(ROCPROFSYS_USE_ROCPROFILER AND rocprofiler_LIBRARY_DIR AND ROCmVersion_TRIPLE_VERSION VERSION_LESS 5.2.0 AND NOT CMAKE_INSTALL_RPATH_USE_LINK_PATH) - set(OMNITRACE_LIB_INSTALL_RPATH - "\$ORIGIN:\$ORIGIN/omnitrace:${rocprofiler_LIBRARY_DIR}") + set(ROCPROFSYS_LIB_INSTALL_RPATH + "\$ORIGIN:\$ORIGIN/${PROJECT_NAME}:${rocprofiler_LIBRARY_DIR}") else() - set(OMNITRACE_LIB_INSTALL_RPATH "\$ORIGIN:\$ORIGIN/omnitrace") + set(ROCPROFSYS_LIB_INSTALL_RPATH "\$ORIGIN:\$ORIGIN/${PROJECT_NAME}") endif() # ------------------------------------------------------------------------------# # -# omnitrace interface library +# rocprofiler-systems interface library # # ------------------------------------------------------------------------------# -add_library(omnitrace-interface-library INTERFACE) -add_library(omnitrace::omnitrace-interface-library ALIAS omnitrace-interface-library) +add_library(rocprofiler-systems-interface-library INTERFACE) +add_library(rocprofiler-systems::rocprofiler-systems-interface-library ALIAS + rocprofiler-systems-interface-library) target_include_directories( - omnitrace-interface-library INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/omnitrace) + rocprofiler-systems-interface-library + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/rocprof-sys) target_link_libraries( - omnitrace-interface-library + rocprofiler-systems-interface-library INTERFACE - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $,omnitrace::omnitrace-lto,>>) + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $,rocprofiler-systems::rocprofiler-systems-lto,>> + ) # ------------------------------------------------------------------------------# # -# omnitrace internal libraries +# rocprofiler-systems internal libraries # # ------------------------------------------------------------------------------# @@ -71,11 +73,11 @@ add_subdirectory(binary) # ------------------------------------------------------------------------------# # -# omnitrace exported libraries +# rocprofiler-systems exported libraries # # ------------------------------------------------------------------------------# -add_subdirectory(omnitrace) -add_subdirectory(omnitrace-dl) -add_subdirectory(omnitrace-rt) -add_subdirectory(omnitrace-user) +add_subdirectory(rocprof-sys) +add_subdirectory(rocprof-sys-dl) +add_subdirectory(rocprof-sys-rt) +add_subdirectory(rocprof-sys-user) diff --git a/source/lib/binary/CMakeLists.txt b/source/lib/binary/CMakeLists.txt index 8eefb0a4..ede4912e 100644 --- a/source/lib/binary/CMakeLists.txt +++ b/source/lib/binary/CMakeLists.txt @@ -16,13 +16,17 @@ set(binary_headers ${CMAKE_CURRENT_LIST_DIR}/scope_filter.hpp ${CMAKE_CURRENT_LIST_DIR}/symbol.hpp) -add_library(omnitrace-binary-library STATIC) -add_library(omnitrace::omnitrace-binary ALIAS omnitrace-binary-library) +add_library(rocprofiler-systems-binary-library STATIC) +add_library(rocprofiler-systems::rocprofiler-systems-binary ALIAS + rocprofiler-systems-binary-library) -target_sources(omnitrace-binary-library PRIVATE ${binary_sources} ${binary_headers}) +target_sources(rocprofiler-systems-binary-library PRIVATE ${binary_sources} + ${binary_headers}) target_link_libraries( - omnitrace-binary-library PRIVATE omnitrace::omnitrace-interface-library - omnitrace::omnitrace-core) + rocprofiler-systems-binary-library + PRIVATE rocprofiler-systems::rocprofiler-systems-interface-library + rocprofiler-systems::rocprofiler-systems-core) -set_target_properties(omnitrace-binary-library PROPERTIES OUTPUT_NAME omnitrace-binary) +set_target_properties(rocprofiler-systems-binary-library + PROPERTIES OUTPUT_NAME ${BINARY_NAME_PREFIX}-binary) diff --git a/source/lib/binary/address_multirange.cpp b/source/lib/binary/address_multirange.cpp index 76507bed..1e4f96b8 100644 --- a/source/lib/binary/address_multirange.cpp +++ b/source/lib/binary/address_multirange.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -27,7 +27,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace binary { @@ -72,4 +72,4 @@ address_multirange::operator+=(address_range _v) return *this; } } // namespace binary -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/binary/address_multirange.hpp b/source/lib/binary/address_multirange.hpp index 4c5d62c8..a86a7a0b 100644 --- a/source/lib/binary/address_multirange.hpp +++ b/source/lib/binary/address_multirange.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -30,7 +30,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace binary { @@ -39,7 +39,7 @@ struct address_multirange struct coarse {}; - OMNITRACE_DEFAULT_OBJECT(address_multirange) + ROCPROFSYS_DEFAULT_OBJECT(address_multirange) address_multirange& operator+=(std::pair&&); address_multirange& operator+=(std::pair&& _v); @@ -61,7 +61,7 @@ struct address_multirange }; template -OMNITRACE_INLINE bool +ROCPROFSYS_INLINE bool address_multirange::contains(Tp&& _v) const { using type = concepts::unqualified_type_t; @@ -74,4 +74,4 @@ address_multirange::contains(Tp&& _v) const [_v](auto&& itr) { return itr.contains(_v); }); } } // namespace binary -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/binary/analysis.cpp b/source/lib/binary/analysis.cpp index bdc4204c..e580dfee 100644 --- a/source/lib/binary/analysis.cpp +++ b/source/lib/binary/analysis.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -26,7 +26,7 @@ # error "BFD support not enabled" #endif -#define PACKAGE "omnitrace" +#define PACKAGE "rocprofiler-systems" #include @@ -60,7 +60,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace binary { @@ -75,7 +75,8 @@ parse_line_info(const std::string& _name, bool _process_dwarf, bool _process_bfd auto& _bfd = _info.bfd; _bfd = std::make_shared(_name); - OMNITRACE_BASIC_VERBOSE(0, "[binary] Reading line info for '%s'...\n", _name.c_str()); + ROCPROFSYS_BASIC_VERBOSE(0, "[binary] Reading line info for '%s'...\n", + _name.c_str()); if(_bfd && _bfd->is_good()) { @@ -124,8 +125,8 @@ parse_line_info(const std::string& _name, bool _process_dwarf, bool _process_bfd _info.sort(); } - OMNITRACE_BASIC_VERBOSE(1, "[binary] Reading line info for '%s'... %zu entries\n", - _bfd->name.c_str(), _info.symbols.size()); + ROCPROFSYS_BASIC_VERBOSE(1, "[binary] Reading line info for '%s'... %zu entries\n", + _bfd->name.c_str(), _info.symbols.size()); return _info; } @@ -151,7 +152,7 @@ get_binary_info(const std::vector& _files, }; // filter function used by procfs::get_contiguous_maps - // ensures that we do not process omnitrace/gotcha/libunwind libraries + // ensures that we do not process rocprof-sys/gotcha/libunwind libraries // and do not process the libraries outside of the binary scope auto _filter = [&_satisfies_binary_filter](const procfs::maps& _v) { if(_v.pathname.empty()) return false; @@ -237,10 +238,10 @@ 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("libomnitrace-dl.so", "", "")) + for(const auto& itr : binary::get_link_map("librocprof-sys-dl.so", "", "")) _insert_exclude_range(itr.real()); return _exclude_range_v; @@ -305,4 +306,4 @@ lookup_ipaddr_entry(uintptr_t, unw_context_t*, tim::unwind::cache*); template std::optional lookup_ipaddr_entry(uintptr_t, unw_context_t*, tim::unwind::cache*); } // namespace binary -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/binary/analysis.hpp b/source/lib/binary/analysis.hpp index d70d58e2..2dc1d854 100644 --- a/source/lib/binary/analysis.hpp +++ b/source/lib/binary/analysis.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -44,7 +44,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace binary { @@ -62,4 +62,4 @@ template std::optional lookup_ipaddr_entry(uintptr_t, unw_context_t* = nullptr, tim::unwind::cache* = nullptr); } // namespace binary -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/binary/binary_info.hpp b/source/lib/binary/binary_info.hpp index b7f80daa..c9c5a5b3 100644 --- a/source/lib/binary/binary_info.hpp +++ b/source/lib/binary/binary_info.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -36,7 +36,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace binary { @@ -84,4 +84,4 @@ binary_info::filename() const return (bfd) ? std::string{ bfd->name } : std::string{}; } } // namespace binary -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/binary/dwarf_entry.cpp b/source/lib/binary/dwarf_entry.cpp index 8210f729..c0e30c2d 100644 --- a/source/lib/binary/dwarf_entry.cpp +++ b/source/lib/binary/dwarf_entry.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -28,7 +28,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace binary { @@ -206,20 +206,20 @@ template void dwarf_entry::serialize(ArchiveT& ar, const unsigned int) { -#define OMNITRACE_SERIALIZE_MEMBER(MEMBER) ar(::tim::cereal::make_nvp(#MEMBER, MEMBER)); - - OMNITRACE_SERIALIZE_MEMBER(file) - OMNITRACE_SERIALIZE_MEMBER(line) - OMNITRACE_SERIALIZE_MEMBER(col) - OMNITRACE_SERIALIZE_MEMBER(address) - OMNITRACE_SERIALIZE_MEMBER(discriminator) - // OMNITRACE_SERIALIZE_MEMBER(begin_statement) - // OMNITRACE_SERIALIZE_MEMBER(end_sequence) - // OMNITRACE_SERIALIZE_MEMBER(line_block) - // OMNITRACE_SERIALIZE_MEMBER(prologue_end) - // OMNITRACE_SERIALIZE_MEMBER(epilogue_begin) - // OMNITRACE_SERIALIZE_MEMBER(vliw_op_index) - // OMNITRACE_SERIALIZE_MEMBER(isa) +#define ROCPROFSYS_SERIALIZE_MEMBER(MEMBER) ar(::tim::cereal::make_nvp(#MEMBER, MEMBER)); + + ROCPROFSYS_SERIALIZE_MEMBER(file) + ROCPROFSYS_SERIALIZE_MEMBER(line) + ROCPROFSYS_SERIALIZE_MEMBER(col) + ROCPROFSYS_SERIALIZE_MEMBER(address) + ROCPROFSYS_SERIALIZE_MEMBER(discriminator) + // ROCPROFSYS_SERIALIZE_MEMBER(begin_statement) + // ROCPROFSYS_SERIALIZE_MEMBER(end_sequence) + // ROCPROFSYS_SERIALIZE_MEMBER(line_block) + // ROCPROFSYS_SERIALIZE_MEMBER(prologue_end) + // ROCPROFSYS_SERIALIZE_MEMBER(epilogue_begin) + // ROCPROFSYS_SERIALIZE_MEMBER(vliw_op_index) + // ROCPROFSYS_SERIALIZE_MEMBER(isa) } template void @@ -234,4 +234,4 @@ template void dwarf_entry::serialize(cereal::PrettyJSONOutputArchive&, const unsigned int); } // namespace binary -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/binary/dwarf_entry.hpp b/source/lib/binary/dwarf_entry.hpp index 3c4c4572..bd7fb023 100644 --- a/source/lib/binary/dwarf_entry.hpp +++ b/source/lib/binary/dwarf_entry.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -25,7 +25,7 @@ #include "core/binary/address_range.hpp" #include "core/binary/fwd.hpp" -namespace omnitrace +namespace rocprofsys { namespace binary { @@ -35,7 +35,7 @@ struct dwarf_entry using dwarf_tuple_t = std::tuple, std::vector, std::vector>; - OMNITRACE_DEFAULT_OBJECT(dwarf_entry) + ROCPROFSYS_DEFAULT_OBJECT(dwarf_entry) bool begin_statement = false; bool end_sequence = false; @@ -63,4 +63,4 @@ struct dwarf_entry void serialize(ArchiveT&, const unsigned int); }; } // namespace binary -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/binary/link_map.cpp b/source/lib/binary/link_map.cpp index ca7178ff..b3912a87 100644 --- a/source/lib/binary/link_map.cpp +++ b/source/lib/binary/link_map.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -35,7 +35,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace binary { @@ -138,14 +138,14 @@ get_link_map(const char* _lib, const std::string& _exclude_linked_by, auto _name = (!_lib) ? config::get_exe_realpath() : std::string{ _lib }; for(const auto& itr : _fini_chain) { - OMNITRACE_BASIC_VERBOSE(2, "[linkmap][%s]: %s\n", filepath::basename(_name), - itr.real().c_str()); + ROCPROFSYS_BASIC_VERBOSE(2, "[linkmap][%s]: %s\n", filepath::basename(_name), + itr.real().c_str()); } for(const auto& itr : _excl_chain) { - OMNITRACE_BASIC_VERBOSE(3, "[linkmap][%s]: %s\n", _exclude_linked_by.c_str(), - link_file{ itr }.real().c_str()); + ROCPROFSYS_BASIC_VERBOSE(3, "[linkmap][%s]: %s\n", _exclude_linked_by.c_str(), + link_file{ itr }.real().c_str()); } return _fini_chain; @@ -178,4 +178,4 @@ link_file::real() const return filepath::realpath(name, nullptr, false); } } // namespace binary -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/binary/link_map.hpp b/source/lib/binary/link_map.hpp index 2faee591..dcc57c61 100644 --- a/source/lib/binary/link_map.hpp +++ b/source/lib/binary/link_map.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -30,7 +30,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace binary { @@ -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 +} // namespace rocprofsys diff --git a/source/lib/binary/scope_filter.cpp b/source/lib/binary/scope_filter.cpp index 524eba45..3535d0a6 100644 --- a/source/lib/binary/scope_filter.cpp +++ b/source/lib/binary/scope_filter.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -25,7 +25,7 @@ #include -namespace omnitrace +namespace rocprofsys { namespace binary { @@ -43,4 +43,4 @@ scope_filter::operator()(std::string_view _value) const throw exception{ "invalid scope filter mode" }; } } // namespace binary -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/binary/scope_filter.hpp b/source/lib/binary/scope_filter.hpp index 047ba90c..d4fa2c70 100644 --- a/source/lib/binary/scope_filter.hpp +++ b/source/lib/binary/scope_filter.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -27,7 +27,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace binary { @@ -55,7 +55,7 @@ struct scope_filter template static bool satisfies_filter(const ContainerT&, filter_scope, - std::string_view) OMNITRACE_PURE; + std::string_view) ROCPROFSYS_PURE; }; template @@ -72,4 +72,4 @@ scope_filter::satisfies_filter(const ContainerT& _filters, filter_scope _scope, return true; } } // namespace binary -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/binary/symbol.cpp b/source/lib/binary/symbol.cpp index 6ff4531a..6582a6ea 100644 --- a/source/lib/binary/symbol.cpp +++ b/source/lib/binary/symbol.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -27,7 +27,7 @@ # error "BFD support not enabled" #endif -#define PACKAGE "omnitrace" +#define PACKAGE "rocprofiler-systems" #define L_LNNO_SIZE 4 #include @@ -49,7 +49,7 @@ #include -namespace omnitrace +namespace rocprofsys { namespace binary { @@ -404,4 +404,4 @@ template std::vector symbol::get_debug_line_info>( const std::vector& _filters) const; } // namespace binary -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/binary/symbol.hpp b/source/lib/binary/symbol.hpp index 5af78f18..38028240 100644 --- a/source/lib/binary/symbol.hpp +++ b/source/lib/binary/symbol.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -32,7 +32,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace binary { @@ -95,4 +95,4 @@ struct symbol : private tim::unwind::bfd_file::symbol std::vector dwarf_info = {}; }; } // namespace binary -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/common/CMakeLists.txt b/source/lib/common/CMakeLists.txt index 74b7b643..b9c6f191 100644 --- a/source/lib/common/CMakeLists.txt +++ b/source/lib/common/CMakeLists.txt @@ -1,18 +1,19 @@ # ------------------------------------------------------------------------------# # -# omnitrace common headers +# rocprofiler-systems common headers # # ------------------------------------------------------------------------------# -add_library(omnitrace-common-library INTERFACE) -add_library(omnitrace::common-library ALIAS omnitrace-common-library) -add_library(omnitrace::omnitrace-common-library ALIAS omnitrace-common-library) +add_library(rocprofiler-systems-common-library INTERFACE) +add_library(rocprofiler-systems::common-library ALIAS rocprofiler-systems-common-library) +add_library(rocprofiler-systems::rocprofiler-systems-common-library ALIAS + rocprofiler-systems-common-library) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/defines.h.in ${CMAKE_CURRENT_BINARY_DIR}/defines.h @ONLY) target_sources( - omnitrace-common-library + rocprofiler-systems-common-library INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/defines.h ${CMAKE_CURRENT_SOURCE_DIR}/delimit.hpp ${CMAKE_CURRENT_SOURCE_DIR}/environment.hpp @@ -24,11 +25,11 @@ get_filename_component(COMMON_SOURCE_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" D get_filename_component(COMMON_BINARY_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}" DIRECTORY) target_include_directories( - omnitrace-common-library + rocprofiler-systems-common-library INTERFACE $ $ $ $) -target_compile_definitions(omnitrace-common-library - INTERFACE $) +target_compile_definitions(rocprofiler-systems-common-library + INTERFACE $) diff --git a/source/lib/common/defines.h.in b/source/lib/common/defines.h.in index 334d419e..b8eff840 100644 --- a/source/lib/common/defines.h.in +++ b/source/lib/common/defines.h.in @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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,117 +23,118 @@ #pragma once // clang-format off -#define OMNITRACE_VERSION_STRING "@FULL_VERSION_STRING@" -#define OMNITRACE_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ -#define OMNITRACE_VERSION_MINOR @PROJECT_VERSION_MINOR@ -#define OMNITRACE_VERSION_PATCH @PROJECT_VERSION_PATCH@ -#define OMNITRACE_GIT_DESCRIBE "@OMNITRACE_GIT_DESCRIBE@" -#define OMNITRACE_GIT_REVISION "@OMNITRACE_GIT_REVISION@" +#define ROCPROFSYS_VERSION_STRING "@FULL_VERSION_STRING@" +#define ROCPROFSYS_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ +#define ROCPROFSYS_VERSION_MINOR @PROJECT_VERSION_MINOR@ +#define ROCPROFSYS_VERSION_PATCH @PROJECT_VERSION_PATCH@ +#define ROCPROFSYS_GIT_DESCRIBE "@ROCPROFSYS_GIT_DESCRIBE@" +#define ROCPROFSYS_GIT_REVISION "@ROCPROFSYS_GIT_REVISION@" // system info during compilation -#define OMNITRACE_LIBRARY_ARCH "@CMAKE_LIBRARY_ARCHITECTURE@" -#define OMNITRACE_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@" -#define OMNITRACE_SYSTEM_PROCESSOR "@CMAKE_SYSTEM_PROCESSOR@" -#define OMNITRACE_SYSTEM_VERSION "@CMAKE_SYSTEM_VERSION@" +#define ROCPROFSYS_LIBRARY_ARCH "@CMAKE_LIBRARY_ARCHITECTURE@" +#define ROCPROFSYS_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@" +#define ROCPROFSYS_SYSTEM_PROCESSOR "@CMAKE_SYSTEM_PROCESSOR@" +#define ROCPROFSYS_SYSTEM_VERSION "@CMAKE_SYSTEM_VERSION@" // compiler information -#define OMNITRACE_COMPILER_ID "@CMAKE_CXX_COMPILER_ID@" -#define OMNITRACE_COMPILER_VERSION "@CMAKE_CXX_COMPILER_VERSION@" -#define OMNITRACE_COMPILER_STRING OMNITRACE_COMPILER_ID " v" OMNITRACE_COMPILER_VERSION +#define ROCPROFSYS_COMPILER_ID "@CMAKE_CXX_COMPILER_ID@" +#define ROCPROFSYS_COMPILER_VERSION "@CMAKE_CXX_COMPILER_VERSION@" +#define ROCPROFSYS_COMPILER_STRING ROCPROFSYS_COMPILER_ID " v" ROCPROFSYS_COMPILER_VERSION -#define OMNITRACE_DEFAULT_ROCM_PATH "@ROCmVersion_DIR@" -#define OMNITRACE_HIP_VERSION_STRING "@OMNITRACE_HIP_VERSION@" -#define OMNITRACE_HIP_VERSION_MAJOR @OMNITRACE_HIP_VERSION_MAJOR@ -#define OMNITRACE_HIP_VERSION_MINOR @OMNITRACE_HIP_VERSION_MINOR@ -#define OMNITRACE_HIP_VERSION_PATCH @OMNITRACE_HIP_VERSION_PATCH@ +#define ROCPROFSYS_DEFAULT_ROCM_PATH "@ROCmVersion_DIR@" +#define ROCPROFSYS_HIP_VERSION_STRING "@ROCPROFSYS_HIP_VERSION@" +#define ROCPROFSYS_HIP_VERSION_MAJOR @ROCPROFSYS_HIP_VERSION_MAJOR@ +#define ROCPROFSYS_HIP_VERSION_MINOR @ROCPROFSYS_HIP_VERSION_MINOR@ +#define ROCPROFSYS_HIP_VERSION_PATCH @ROCPROFSYS_HIP_VERSION_PATCH@ // these can be set via defining the variable in CMake, e.g.: -// cmake -D OMNITRACE_CACHELINE_SIZE=N /path/to/source +// cmake -D ROCPROFSYS_CACHELINE_SIZE=N /path/to/source // if not defined when configuring cmake, these values fall back to // default values set in core/containers/aligned_static_vector.hpp. -// the OMNITRACE_CACHELINE_SIZE_MIN is used to ensure portability -#cmakedefine OMNITRACE_CACHELINE_SIZE @OMNITRACE_CACHELINE_SIZE@ -#cmakedefine OMNITRACE_CACHELINE_SIZE_MIN @OMNITRACE_CACHELINE_SIZE_MIN@ +// the ROCPROFSYS_CACHELINE_SIZE_MIN is used to ensure portability +#cmakedefine ROCPROFSYS_CACHELINE_SIZE @ROCPROFSYS_CACHELINE_SIZE@ +#cmakedefine ROCPROFSYS_CACHELINE_SIZE_MIN @ROCPROFSYS_CACHELINE_SIZE_MIN@ // misc definitions which can be configured by cmake to override the defaults -#cmakedefine OMNITRACE_ROCM_MAX_COUNTERS @OMNITRACE_ROCM_MAX_COUNTERS@ +#cmakedefine ROCPROFSYS_ROCM_MAX_COUNTERS @ROCPROFSYS_ROCM_MAX_COUNTERS@ // clang-format on -#define OMNITRACE_VERSION \ - ((10000 * OMNITRACE_VERSION_MAJOR) + (100 * OMNITRACE_VERSION_MINOR) + \ - OMNITRACE_VERSION_PATCH) +#define ROCPROFSYS_VERSION \ + ((10000 * ROCPROFSYS_VERSION_MAJOR) + (100 * ROCPROFSYS_VERSION_MINOR) + \ + ROCPROFSYS_VERSION_PATCH) -#define OMNITRACE_HIP_VERSION \ - ((10000 * OMNITRACE_HIP_VERSION_MAJOR) + (100 * OMNITRACE_HIP_VERSION_MINOR) + \ - OMNITRACE_HIP_VERSION_PATCH) +#define ROCPROFSYS_HIP_VERSION \ + ((10000 * ROCPROFSYS_HIP_VERSION_MAJOR) + (100 * ROCPROFSYS_HIP_VERSION_MINOR) + \ + ROCPROFSYS_HIP_VERSION_PATCH) -#if OMNITRACE_HIP_VERSION_MAJOR > 0 -# define OMNITRACE_HIP_VERSION_COMPAT_STRING \ - "v@OMNITRACE_HIP_VERSION_MAJOR@.@OMNITRACE_HIP_VERSION_MINOR@.x" +#if ROCPROFSYS_HIP_VERSION_MAJOR > 0 +# define ROCPROFSYS_HIP_VERSION_COMPAT_STRING \ + "v@ROCPROFSYS_HIP_VERSION_MAJOR@.@ROCPROFSYS_HIP_VERSION_MINOR@.x" #else -# define OMNITRACE_HIP_VERSION_COMPAT_STRING "" +# define ROCPROFSYS_HIP_VERSION_COMPAT_STRING "" #endif // this should be passed to argparse::argument_parser::enable_version // Example: -// parser.enable_version(, OMNITRACE_ARGPARSE_VERSION_INFO); -#if !defined(OMNITRACE_ARGPARSE_VERSION_INFO) -# define OMNITRACE_ARGPARSE_VERSION_INFO \ - "v" OMNITRACE_VERSION_STRING, OMNITRACE_GIT_DESCRIBE, OMNITRACE_GIT_REVISION, \ +// parser.enable_version(, ROCPROFSYS_ARGPARSE_VERSION_INFO); +#if !defined(ROCPROFSYS_ARGPARSE_VERSION_INFO) +# define ROCPROFSYS_ARGPARSE_VERSION_INFO \ + "v" ROCPROFSYS_VERSION_STRING, ROCPROFSYS_GIT_DESCRIBE, ROCPROFSYS_GIT_REVISION, \ { \ - { "", OMNITRACE_LIBRARY_ARCH }, { "compiler", OMNITRACE_COMPILER_STRING }, \ + { "", ROCPROFSYS_LIBRARY_ARCH }, { "compiler", ROCPROFSYS_COMPILER_STRING }, \ { \ - "rocm", OMNITRACE_HIP_VERSION_COMPAT_STRING \ + "rocm", ROCPROFSYS_HIP_VERSION_COMPAT_STRING \ } \ } #endif // clang-format off -#if !defined(OMNITRACE_MAX_THREADS) -# define OMNITRACE_MAX_THREADS @OMNITRACE_MAX_THREADS@ +#if !defined(ROCPROFSYS_MAX_THREADS) +# define ROCPROFSYS_MAX_THREADS @ROCPROFSYS_MAX_THREADS@ #endif -#if !defined(OMNITRACE_MAX_UNWIND_DEPTH) -# define OMNITRACE_MAX_UNWIND_DEPTH @OMNITRACE_MAX_UNWIND_DEPTH@ +#if !defined(ROCPROFSYS_MAX_UNWIND_DEPTH) +# define ROCPROFSYS_MAX_UNWIND_DEPTH @ROCPROFSYS_MAX_UNWIND_DEPTH@ #endif // clang-format on // in general, we want to make sure the cache line size is not less than // 64 bytes (most common cacheline size for x86-64 CPUs) so unless -// OMNITRACE_CACHELINE_SIZE was explicitly set, we set the min to 64 -// and use the max value of OMNITRACE_CACHELINE_SIZE and -// OMNITRACE_CACHELINE_SIZE_MIN to assure that false-sharing is well +// ROCPROFSYS_CACHELINE_SIZE was explicitly set, we set the min to 64 +// and use the max value of ROCPROFSYS_CACHELINE_SIZE and +// ROCPROFSYS_CACHELINE_SIZE_MIN to assure that false-sharing is well // guarded against -#if !defined(OMNITRACE_CACHELINE_SIZE_MIN) -# if defined(OMNITRACE_CACHELINE_SIZE) -# define OMNITRACE_CACHELINE_SIZE_MIN OMNITRACE_CACHELINE_SIZE +#if !defined(ROCPROFSYS_CACHELINE_SIZE_MIN) +# if defined(ROCPROFSYS_CACHELINE_SIZE) +# define ROCPROFSYS_CACHELINE_SIZE_MIN ROCPROFSYS_CACHELINE_SIZE # else -# define OMNITRACE_CACHELINE_SIZE_MIN 64 +# define ROCPROFSYS_CACHELINE_SIZE_MIN 64 # endif #endif -#if !defined(OMNITRACE_ROCM_MAX_COUNTERS) -# define OMNITRACE_ROCM_MAX_COUNTERS 25 +#if !defined(ROCPROFSYS_ROCM_MAX_COUNTERS) +# define ROCPROFSYS_ROCM_MAX_COUNTERS 25 #endif -#define OMNITRACE_ATTRIBUTE(...) __attribute__((__VA_ARGS__)) -#define OMNITRACE_VISIBILITY(MODE) OMNITRACE_ATTRIBUTE(visibility(MODE)) -#define OMNITRACE_PUBLIC_API OMNITRACE_VISIBILITY("default") -#define OMNITRACE_HIDDEN_API OMNITRACE_VISIBILITY("hidden") -#define OMNITRACE_INTERNAL_API OMNITRACE_VISIBILITY("internal") -#define OMNITRACE_INLINE OMNITRACE_ATTRIBUTE(always_inline) inline -#define OMNITRACE_NOINLINE OMNITRACE_ATTRIBUTE(noinline) -#define OMNITRACE_HOT OMNITRACE_ATTRIBUTE(hot) -#define OMNITRACE_COLD OMNITRACE_ATTRIBUTE(cold) -#define OMNITRACE_CONST OMNITRACE_ATTRIBUTE(const) -#define OMNITRACE_PURE OMNITRACE_ATTRIBUTE(pure) -#define OMNITRACE_WEAK OMNITRACE_ATTRIBUTE(weak) -#define OMNITRACE_PACKED OMNITRACE_ATTRIBUTE(__packed__) -#define OMNITRACE_PACKED_ALIGN(VAL) OMNITRACE_PACKED OMNITRACE_ATTRIBUTE(__aligned__(VAL)) -#define OMNITRACE_LIKELY(...) __builtin_expect((__VA_ARGS__), 1) -#define OMNITRACE_UNLIKELY(...) __builtin_expect((__VA_ARGS__), 0) - -#if defined(OMNITRACE_CI) && OMNITRACE_CI > 0 +#define ROCPROFSYS_ATTRIBUTE(...) __attribute__((__VA_ARGS__)) +#define ROCPROFSYS_VISIBILITY(MODE) ROCPROFSYS_ATTRIBUTE(visibility(MODE)) +#define ROCPROFSYS_PUBLIC_API ROCPROFSYS_VISIBILITY("default") +#define ROCPROFSYS_HIDDEN_API ROCPROFSYS_VISIBILITY("hidden") +#define ROCPROFSYS_INTERNAL_API ROCPROFSYS_VISIBILITY("internal") +#define ROCPROFSYS_INLINE ROCPROFSYS_ATTRIBUTE(always_inline) inline +#define ROCPROFSYS_NOINLINE ROCPROFSYS_ATTRIBUTE(noinline) +#define ROCPROFSYS_HOT ROCPROFSYS_ATTRIBUTE(hot) +#define ROCPROFSYS_COLD ROCPROFSYS_ATTRIBUTE(cold) +#define ROCPROFSYS_CONST ROCPROFSYS_ATTRIBUTE(const) +#define ROCPROFSYS_PURE ROCPROFSYS_ATTRIBUTE(pure) +#define ROCPROFSYS_WEAK ROCPROFSYS_ATTRIBUTE(weak) +#define ROCPROFSYS_PACKED ROCPROFSYS_ATTRIBUTE(__packed__) +#define ROCPROFSYS_PACKED_ALIGN(VAL) \ + ROCPROFSYS_PACKED ROCPROFSYS_ATTRIBUTE(__aligned__(VAL)) +#define ROCPROFSYS_LIKELY(...) __builtin_expect((__VA_ARGS__), 1) +#define ROCPROFSYS_UNLIKELY(...) __builtin_expect((__VA_ARGS__), 0) + +#if defined(ROCPROFSYS_CI) && ROCPROFSYS_CI > 0 # if defined(NDEBUG) # undef NDEBUG # endif @@ -147,15 +148,15 @@ # endif #endif -#define OMNITRACE_STRINGIZE(X) OMNITRACE_STRINGIZE2(X) -#define OMNITRACE_STRINGIZE2(X) #X -#define OMNITRACE_VAR_NAME_COMBINE(X, Y) X##Y -#define OMNITRACE_VARIABLE(X, Y) OMNITRACE_VAR_NAME_COMBINE(X, Y) -#define OMNITRACE_LINESTR OMNITRACE_STRINGIZE(__LINE__) -#define OMNITRACE_ESC(...) __VA_ARGS__ +#define ROCPROFSYS_STRINGIZE(X) ROCPROFSYS_STRINGIZE2(X) +#define ROCPROFSYS_STRINGIZE2(X) #X +#define ROCPROFSYS_VAR_NAME_COMBINE(X, Y) X##Y +#define ROCPROFSYS_VARIABLE(X, Y) ROCPROFSYS_VAR_NAME_COMBINE(X, Y) +#define ROCPROFSYS_LINESTR ROCPROFSYS_STRINGIZE(__LINE__) +#define ROCPROFSYS_ESC(...) __VA_ARGS__ #if defined(__cplusplus) -# if !defined(OMNITRACE_FOLD_EXPRESSION) -# define OMNITRACE_FOLD_EXPRESSION(...) ((__VA_ARGS__), ...) +# if !defined(ROCPROFSYS_FOLD_EXPRESSION) +# define ROCPROFSYS_FOLD_EXPRESSION(...) ((__VA_ARGS__), ...) # endif #endif diff --git a/source/lib/common/delimit.hpp b/source/lib/common/delimit.hpp index 1c683450..6a78ea31 100644 --- a/source/lib/common/delimit.hpp +++ b/source/lib/common/delimit.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -26,7 +26,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { inline namespace common { @@ -120,4 +120,4 @@ delimit(const std::string& line, const char* delimiters) } } // namespace } // namespace common -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/common/environment.hpp b/source/lib/common/environment.hpp index 9879825c..c8c63238 100644 --- a/source/lib/common/environment.hpp +++ b/source/lib/common/environment.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -34,47 +34,48 @@ #include #include -#if !defined(OMNITRACE_ENVIRON_LOG_NAME) -# if defined(OMNITRACE_COMMON_LIBRARY_NAME) -# define OMNITRACE_ENVIRON_LOG_NAME "[" OMNITRACE_COMMON_LIBRARY_NAME "]" +#if !defined(ROCPROFSYS_ENVIRON_LOG_NAME) +# if defined(ROCPROFSYS_COMMON_LIBRARY_NAME) +# define ROCPROFSYS_ENVIRON_LOG_NAME "[" ROCPROFSYS_COMMON_LIBRARY_NAME "]" # else -# define OMNITRACE_ENVIRON_LOG_NAME +# define ROCPROFSYS_ENVIRON_LOG_NAME # endif #endif -#if !defined(OMNITRACE_ENVIRON_LOG_START) -# if defined(OMNITRACE_COMMON_LIBRARY_LOG_START) -# define OMNITRACE_ENVIRON_LOG_START OMNITRACE_COMMON_LIBRARY_LOG_START +#if !defined(ROCPROFSYS_ENVIRON_LOG_START) +# if defined(ROCPROFSYS_COMMON_LIBRARY_LOG_START) +# define ROCPROFSYS_ENVIRON_LOG_START ROCPROFSYS_COMMON_LIBRARY_LOG_START # elif defined(TIMEMORY_LOG_COLORS_AVAILABLE) -# define OMNITRACE_ENVIRON_LOG_START \ +# define ROCPROFSYS_ENVIRON_LOG_START \ fprintf(stderr, "%s", ::tim::log::color::info()); # else -# define OMNITRACE_ENVIRON_LOG_START +# define ROCPROFSYS_ENVIRON_LOG_START # endif #endif -#if !defined(OMNITRACE_ENVIRON_LOG_END) -# if defined(OMNITRACE_COMMON_LIBRARY_LOG_END) -# define OMNITRACE_ENVIRON_LOG_END OMNITRACE_COMMON_LIBRARY_LOG_END +#if !defined(ROCPROFSYS_ENVIRON_LOG_END) +# if defined(ROCPROFSYS_COMMON_LIBRARY_LOG_END) +# define ROCPROFSYS_ENVIRON_LOG_END ROCPROFSYS_COMMON_LIBRARY_LOG_END # elif defined(TIMEMORY_LOG_COLORS_AVAILABLE) -# define OMNITRACE_ENVIRON_LOG_END fprintf(stderr, "%s", ::tim::log::color::end()); +# define ROCPROFSYS_ENVIRON_LOG_END \ + fprintf(stderr, "%s", ::tim::log::color::end()); # else -# define OMNITRACE_ENVIRON_LOG_END +# define ROCPROFSYS_ENVIRON_LOG_END # endif #endif -#define OMNITRACE_ENVIRON_LOG(CONDITION, ...) \ +#define ROCPROFSYS_ENVIRON_LOG(CONDITION, ...) \ if(CONDITION) \ { \ fflush(stderr); \ - OMNITRACE_ENVIRON_LOG_START \ - fprintf(stderr, "[omnitrace]" OMNITRACE_ENVIRON_LOG_NAME "[%i] ", getpid()); \ + ROCPROFSYS_ENVIRON_LOG_START \ + fprintf(stderr, "[rocprof-sys]" ROCPROFSYS_ENVIRON_LOG_NAME "[%i] ", getpid()); \ fprintf(stderr, __VA_ARGS__); \ - OMNITRACE_ENVIRON_LOG_END \ + ROCPROFSYS_ENVIRON_LOG_END \ fflush(stderr); \ } -namespace omnitrace +namespace rocprofsys { inline namespace common { @@ -108,7 +109,7 @@ get_env_impl(std::string_view env_id, int _default) } catch(std::exception& _e) { fprintf(stderr, - "[omnitrace][get_env] Exception thrown converting getenv(\"%s\") = " + "[rocprof-sys][get_env] Exception thrown converting getenv(\"%s\") = " "%s to integer :: %s. Using default value of %i\n", env_id.data(), env_var, _e.what(), _default); } @@ -162,7 +163,7 @@ get_env(std::string_view env_id, Tp&& _default) } } -struct OMNITRACE_INTERNAL_API env_config +struct ROCPROFSYS_INTERNAL_API env_config { std::string env_name = {}; std::string env_value = {}; @@ -171,10 +172,10 @@ struct OMNITRACE_INTERNAL_API env_config auto operator()(bool _verbose = false) const { if(env_name.empty()) return -1; - OMNITRACE_ENVIRON_LOG(_verbose, "setenv(\"%s\", \"%s\", %i)\n", env_name.c_str(), - env_value.c_str(), override); + ROCPROFSYS_ENVIRON_LOG(_verbose, "setenv(\"%s\", \"%s\", %i)\n", env_name.c_str(), + env_value.c_str(), override); return setenv(env_name.c_str(), env_value.c_str(), override); } }; } // namespace common -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/common/invoke.hpp b/source/lib/common/invoke.hpp index 9de2645c..715bd06b 100644 --- a/source/lib/common/invoke.hpp +++ b/source/lib/common/invoke.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -31,20 +31,20 @@ #include #include -#if !defined(OMNITRACE_COMMON_LIBRARY_NAME) -# define OMNITRACE_COMMON_LIBRARY_NAME "common" -# error OMNITRACE_COMMON_LIBRARY_NAME must be defined +#if !defined(ROCPROFSYS_COMMON_LIBRARY_NAME) +# define ROCPROFSYS_COMMON_LIBRARY_NAME "common" +# error ROCPROFSYS_COMMON_LIBRARY_NAME must be defined #endif -#if !defined(OMNITRACE_COMMON_LIBRARY_LOG_START) -# define OMNITRACE_COMMON_LIBRARY_LOG_START +#if !defined(ROCPROFSYS_COMMON_LIBRARY_LOG_START) +# define ROCPROFSYS_COMMON_LIBRARY_LOG_START #endif -#if !defined(OMNITRACE_COMMON_LIBRARY_LOG_END) -# define OMNITRACE_COMMON_LIBRARY_LOG_END +#if !defined(ROCPROFSYS_COMMON_LIBRARY_LOG_END) +# define ROCPROFSYS_COMMON_LIBRARY_LOG_END #endif -namespace omnitrace +namespace rocprofsys { inline namespace common { @@ -52,7 +52,7 @@ namespace { template inline auto -invoke(const char* _name, FuncT&& _func, Args... _args) OMNITRACE_HIDDEN_API; +invoke(const char* _name, FuncT&& _func, Args... _args) ROCPROFSYS_HIDDEN_API; inline int32_t& get_guard() @@ -77,7 +77,7 @@ ignore(const char* _name, int _verbose, int _value, const char* _reason, Args... { fflush(stderr); fprintf(stderr, - "[omnitrace][" OMNITRACE_COMMON_LIBRARY_NAME + "[rocprof-sys][" ROCPROFSYS_COMMON_LIBRARY_NAME "][%i][%li] %s(%s) was ignored :: %s\n", getpid(), get_thread_index(), _name, join(QuoteStrings{}, ", ", _args...).c_str(), _reason); @@ -107,13 +107,13 @@ invoke(const char* _name, int _verbose, bool& _toggle, FuncT&& _func, Args... _a if(_verbose >= 3) { fflush(stderr); - OMNITRACE_COMMON_LIBRARY_LOG_START + ROCPROFSYS_COMMON_LIBRARY_LOG_START fprintf(stderr, - "[omnitrace][" OMNITRACE_COMMON_LIBRARY_NAME + "[rocprof-sys][" ROCPROFSYS_COMMON_LIBRARY_NAME "][%i][%li][%i] %s(%s)\n", getpid(), get_thread_index(), _lk, _name, join(QuoteStrings{}, ", ", _args...).c_str()); - OMNITRACE_COMMON_LIBRARY_LOG_END + ROCPROFSYS_COMMON_LIBRARY_LOG_END fflush(stderr); } return std::invoke(std::forward(_func), _args...); @@ -121,25 +121,25 @@ invoke(const char* _name, int _verbose, bool& _toggle, FuncT&& _func, Args... _a else if(_verbose >= 2) { fflush(stderr); - OMNITRACE_COMMON_LIBRARY_LOG_START + ROCPROFSYS_COMMON_LIBRARY_LOG_START fprintf(stderr, - "[omnitrace][" OMNITRACE_COMMON_LIBRARY_NAME + "[rocprof-sys][" ROCPROFSYS_COMMON_LIBRARY_NAME "][%i][%li] %s(%s) was guarded :: value = %i\n", getpid(), get_thread_index(), _name, join(QuoteStrings{}, ", ", _args...).c_str(), _lk); - OMNITRACE_COMMON_LIBRARY_LOG_END + ROCPROFSYS_COMMON_LIBRARY_LOG_END fflush(stderr); } } else if(_verbose >= 0) { - OMNITRACE_COMMON_LIBRARY_LOG_START + ROCPROFSYS_COMMON_LIBRARY_LOG_START fprintf(stderr, - "[omnitrace][" OMNITRACE_COMMON_LIBRARY_NAME + "[rocprof-sys][" ROCPROFSYS_COMMON_LIBRARY_NAME "][%i][%li] %s(%s) ignored :: null function pointer\n", getpid(), get_thread_index(), _name, join(QuoteStrings{}, ", ", _args...).c_str()); - OMNITRACE_COMMON_LIBRARY_LOG_END + ROCPROFSYS_COMMON_LIBRARY_LOG_END } using return_type = decltype(std::invoke(std::forward(_func), _args...)); @@ -147,4 +147,4 @@ invoke(const char* _name, int _verbose, bool& _toggle, FuncT&& _func, Args... _a } } // namespace } // namespace common -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/common/join.hpp b/source/lib/common/join.hpp index f350e8dc..5fcac97b 100644 --- a/source/lib/common/join.hpp +++ b/source/lib/common/join.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -31,11 +31,11 @@ #include #include -#if !defined(OMNITRACE_FOLD_EXPRESSION) -# define OMNITRACE_FOLD_EXPRESSION(...) ((__VA_ARGS__), ...) +#if !defined(ROCPROFSYS_FOLD_EXPRESSION) +# define ROCPROFSYS_FOLD_EXPRESSION(...) ((__VA_ARGS__), ...) #endif -namespace omnitrace +namespace rocprofsys { inline namespace common { @@ -99,13 +99,13 @@ join(DelimT&& _delim, Args&&... _args) if constexpr(std::is_same::value) { const char _delim_c[2] = { _delim, '\0' }; - OMNITRACE_FOLD_EXPRESSION(_ss << _delim_c << _args); + ROCPROFSYS_FOLD_EXPRESSION(_ss << _delim_c << _args); auto _ret = _ss.str(); return (_ret.length() > 1) ? _ret.substr(1) : std::string{}; } else { - OMNITRACE_FOLD_EXPRESSION(_ss << _delim << _args); + ROCPROFSYS_FOLD_EXPRESSION(_ss << _delim << _args); auto _ret = _ss.str(); auto&& _len = std::string{ _delim }.length(); return (_ret.length() > _len) ? _ret.substr(_len) : std::string{}; @@ -127,13 +127,13 @@ join(QuoteStrings&&, DelimT&& _delim, Args&&... _args) if constexpr(std::is_same::value) { const char _delim_c[2] = { _delim, '\0' }; - OMNITRACE_FOLD_EXPRESSION(_ss << _delim_c << as_string(_args)); + ROCPROFSYS_FOLD_EXPRESSION(_ss << _delim_c << as_string(_args)); auto _ret = _ss.str(); return (_ret.length() > 1) ? _ret.substr(1) : std::string{}; } else { - OMNITRACE_FOLD_EXPRESSION(_ss << _delim << as_string(_args)); + ROCPROFSYS_FOLD_EXPRESSION(_ss << _delim << as_string(_args)); auto _ret = _ss.str(); auto&& _len = std::string{ _delim }.length(); return (_ret.length() > _len) ? _ret.substr(_len) : std::string{}; @@ -177,4 +177,4 @@ join(QuoteStrings&&, std::tuple&& _delim, Args&&... _arg } } // namespace } // namespace common -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/common/path.hpp b/source/lib/common/path.hpp index 767478ba..d427d147 100644 --- a/source/lib/common/path.hpp +++ b/source/lib/common/path.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -38,46 +38,47 @@ #include #include -#if !defined(OMNITRACE_PATH_LOG_NAME) -# if defined(OMNITRACE_COMMON_LIBRARY_NAME) -# define OMNITRACE_PATH_LOG_NAME "[" OMNITRACE_COMMON_LIBRARY_NAME "]" +#if !defined(ROCPROFSYS_PATH_LOG_NAME) +# if defined(ROCPROFSYS_COMMON_LIBRARY_NAME) +# define ROCPROFSYS_PATH_LOG_NAME "[" ROCPROFSYS_COMMON_LIBRARY_NAME "]" # else -# define OMNITRACE_PATH_LOG_NAME +# define ROCPROFSYS_PATH_LOG_NAME # endif #endif -#if !defined(OMNITRACE_PATH_LOG_START) -# if defined(OMNITRACE_COMMON_LIBRARY_LOG_START) -# define OMNITRACE_PATH_LOG_START OMNITRACE_COMMON_LIBRARY_LOG_START +#if !defined(ROCPROFSYS_PATH_LOG_START) +# if defined(ROCPROFSYS_COMMON_LIBRARY_LOG_START) +# define ROCPROFSYS_PATH_LOG_START ROCPROFSYS_COMMON_LIBRARY_LOG_START # elif defined(TIMEMORY_LOG_COLORS_AVAILABLE) -# define OMNITRACE_PATH_LOG_START fprintf(stderr, "%s", ::tim::log::color::info()); +# define ROCPROFSYS_PATH_LOG_START \ + fprintf(stderr, "%s", ::tim::log::color::info()); # else -# define OMNITRACE_PATH_LOG_START +# define ROCPROFSYS_PATH_LOG_START # endif #endif -#if !defined(OMNITRACE_PATH_LOG_END) -# if defined(OMNITRACE_COMMON_LIBRARY_LOG_END) -# define OMNITRACE_PATH_LOG_END OMNITRACE_COMMON_LIBRARY_LOG_END +#if !defined(ROCPROFSYS_PATH_LOG_END) +# if defined(ROCPROFSYS_COMMON_LIBRARY_LOG_END) +# define ROCPROFSYS_PATH_LOG_END ROCPROFSYS_COMMON_LIBRARY_LOG_END # elif defined(TIMEMORY_LOG_COLORS_AVAILABLE) -# define OMNITRACE_PATH_LOG_END fprintf(stderr, "%s", ::tim::log::color::end()); +# define ROCPROFSYS_PATH_LOG_END fprintf(stderr, "%s", ::tim::log::color::end()); # else -# define OMNITRACE_PATH_LOG_END +# define ROCPROFSYS_PATH_LOG_END # endif #endif -#define OMNITRACE_PATH_LOG(CONDITION, ...) \ +#define ROCPROFSYS_PATH_LOG(CONDITION, ...) \ if(CONDITION) \ { \ fflush(stderr); \ - OMNITRACE_PATH_LOG_START \ - fprintf(stderr, "[omnitrace]" OMNITRACE_PATH_LOG_NAME "[%i] ", getpid()); \ + ROCPROFSYS_PATH_LOG_START \ + fprintf(stderr, "[rocprof-sys]" ROCPROFSYS_PATH_LOG_NAME "[%i] ", getpid()); \ fprintf(stderr, __VA_ARGS__); \ - OMNITRACE_PATH_LOG_END \ + ROCPROFSYS_PATH_LOG_END \ fflush(stderr); \ } -namespace omnitrace +namespace rocprofsys { inline namespace common { @@ -85,45 +86,45 @@ namespace path { inline std::vector get_link_map(const char*, std::vector&& = { (RTLD_LAZY | RTLD_NOLOAD) }, - bool _include_self = false) OMNITRACE_INTERNAL_API; + bool _include_self = false) ROCPROFSYS_INTERNAL_API; inline auto get_link_map(const char* _name, bool&& _include_self, std::vector&& _open_modes = { - (RTLD_LAZY | RTLD_NOLOAD) }) OMNITRACE_INTERNAL_API; + (RTLD_LAZY | RTLD_NOLOAD) }) ROCPROFSYS_INTERNAL_API; inline std::string get_origin(const std::string&, - std::vector&& = { (RTLD_LAZY | RTLD_NOLOAD) }) OMNITRACE_INTERNAL_API; + std::vector&& = { (RTLD_LAZY | RTLD_NOLOAD) }) ROCPROFSYS_INTERNAL_API; inline bool -exists(const std::string& _fname) OMNITRACE_INTERNAL_API; +exists(const std::string& _fname) ROCPROFSYS_INTERNAL_API; template inline RetT -get_default_lib_search_paths() OMNITRACE_INTERNAL_API; +get_default_lib_search_paths() ROCPROFSYS_INTERNAL_API; inline std::string find_path(const std::string& _path, int _verbose, - const std::string& _search_paths = {}) OMNITRACE_INTERNAL_API; + const std::string& _search_paths = {}) ROCPROFSYS_INTERNAL_API; inline std::string -dirname(const std::string& _fname) OMNITRACE_INTERNAL_API; +dirname(const std::string& _fname) ROCPROFSYS_INTERNAL_API; inline std::string realpath(const std::string& _relpath, - std::string* _resolved = nullptr) OMNITRACE_INTERNAL_API; + std::string* _resolved = nullptr) ROCPROFSYS_INTERNAL_API; inline bool -is_text_file(const std::string& filename) OMNITRACE_INTERNAL_API; +is_text_file(const std::string& filename) ROCPROFSYS_INTERNAL_API; inline bool -is_link(const std::string& _path) OMNITRACE_INTERNAL_API; +is_link(const std::string& _path) ROCPROFSYS_INTERNAL_API; inline std::string -readlink(const std::string& _path) OMNITRACE_INTERNAL_API; +readlink(const std::string& _path) ROCPROFSYS_INTERNAL_API; -struct OMNITRACE_INTERNAL_API path_type +struct ROCPROFSYS_INTERNAL_API path_type { enum path_type_e { @@ -181,8 +182,9 @@ template RetT get_default_lib_search_paths() { - auto _paths = join(":", get_env("OMNITRACE_PATH", ""), get_env("LD_LIBRARY_PATH", ""), - get_env("LIBRARY_PATH", ""), get_env("PWD", ""), "."); + auto _paths = + join(":", get_env("ROCPROFSYS_PATH", ""), get_env("LD_LIBRARY_PATH", ""), + get_env("LIBRARY_PATH", ""), get_env("PWD", ""), "."); if constexpr(std::is_same::value) return _paths; else @@ -204,13 +206,13 @@ find_path(const std::string& _path, int _verbose, const std::string& _search_pat for(const auto& itr : _paths) { auto _f = join('/', itr, _path); - OMNITRACE_PATH_LOG(_verbose >= _verbose_lvl + 1, - "searching for '%s' in '%s' ...\n", _path.c_str(), - itr.c_str()); + ROCPROFSYS_PATH_LOG(_verbose >= _verbose_lvl + 1, + "searching for '%s' in '%s' ...\n", _path.c_str(), + itr.c_str()); if(exists(_f)) { - OMNITRACE_PATH_LOG(_verbose >= _verbose_lvl, "found '%s' in '%s' ...\n", - _path.c_str(), itr.c_str()); + ROCPROFSYS_PATH_LOG(_verbose >= _verbose_lvl, "found '%s' in '%s' ...\n", + _path.c_str(), itr.c_str()); return _f; } } @@ -224,14 +226,14 @@ find_path(const std::string& _path, int _verbose, const std::string& _search_pat for(const auto* sitr : { "lib", "lib64", "../lib", "../lib64" }) { auto _f = join('/', dirname(itr), sitr, _path); - OMNITRACE_PATH_LOG(_verbose >= _verbose_lvl + 1, - "searching for '%s' in '%s' ...\n", _path.c_str(), - common::join('/', itr, sitr).c_str()); + ROCPROFSYS_PATH_LOG(_verbose >= _verbose_lvl + 1, + "searching for '%s' in '%s' ...\n", _path.c_str(), + common::join('/', itr, sitr).c_str()); if(exists(_f)) { - OMNITRACE_PATH_LOG(_verbose >= _verbose_lvl, - "found '%s' in '%s' ...\n", _path.c_str(), - itr.c_str()); + ROCPROFSYS_PATH_LOG(_verbose >= _verbose_lvl, + "found '%s' in '%s' ...\n", _path.c_str(), + itr.c_str()); return _f; } } @@ -317,7 +319,7 @@ is_text_file(const std::string& filename) std::ifstream _file{ filename, std::ios::in | std::ios::binary }; if(!_file.is_open()) { - OMNITRACE_PATH_LOG(0, "Error! '%s' could not be opened...\n", filename.c_str()); + ROCPROFSYS_PATH_LOG(0, "Error! '%s' could not be opened...\n", filename.c_str()); return false; } @@ -411,4 +413,4 @@ get_origin(const std::string& _filename, std::vector&& _open_modes) } } // namespace path } // namespace common -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/common/setup.hpp b/source/lib/common/setup.hpp index 08546e52..0c2d1ad6 100644 --- a/source/lib/common/setup.hpp +++ b/source/lib/common/setup.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -41,54 +41,54 @@ #include #include -#if !defined(OMNITRACE_SETUP_LOG_NAME) -# if defined(OMNITRACE_COMMON_LIBRARY_NAME) -# define OMNITRACE_SETUP_LOG_NAME "[" OMNITRACE_COMMON_LIBRARY_NAME "]" +#if !defined(ROCPROFSYS_SETUP_LOG_NAME) +# if defined(ROCPROFSYS_COMMON_LIBRARY_NAME) +# define ROCPROFSYS_SETUP_LOG_NAME "[" ROCPROFSYS_COMMON_LIBRARY_NAME "]" # else -# define OMNITRACE_SETUP_LOG_NAME +# define ROCPROFSYS_SETUP_LOG_NAME # endif #endif -#if !defined(OMNITRACE_SETUP_LOG_START) -# if defined(OMNITRACE_COMMON_LIBRARY_LOG_START) -# define OMNITRACE_SETUP_LOG_START OMNITRACE_COMMON_LIBRARY_LOG_START +#if !defined(ROCPROFSYS_SETUP_LOG_START) +# if defined(ROCPROFSYS_COMMON_LIBRARY_LOG_START) +# define ROCPROFSYS_SETUP_LOG_START ROCPROFSYS_COMMON_LIBRARY_LOG_START # elif defined(TIMEMORY_LOG_COLORS_AVAILABLE) -# define OMNITRACE_SETUP_LOG_START \ +# define ROCPROFSYS_SETUP_LOG_START \ fprintf(stderr, "%s", ::tim::log::color::info()); # else -# define OMNITRACE_SETUP_LOG_START +# define ROCPROFSYS_SETUP_LOG_START # endif #endif -#if !defined(OMNITRACE_SETUP_LOG_END) -# if defined(OMNITRACE_COMMON_LIBRARY_LOG_END) -# define OMNITRACE_SETUP_LOG_END OMNITRACE_COMMON_LIBRARY_LOG_END +#if !defined(ROCPROFSYS_SETUP_LOG_END) +# if defined(ROCPROFSYS_COMMON_LIBRARY_LOG_END) +# define ROCPROFSYS_SETUP_LOG_END ROCPROFSYS_COMMON_LIBRARY_LOG_END # elif defined(TIMEMORY_LOG_COLORS_AVAILABLE) -# define OMNITRACE_SETUP_LOG_END fprintf(stderr, "%s", ::tim::log::color::end()); +# define ROCPROFSYS_SETUP_LOG_END fprintf(stderr, "%s", ::tim::log::color::end()); # else -# define OMNITRACE_SETUP_LOG_END +# define ROCPROFSYS_SETUP_LOG_END # endif #endif -#define OMNITRACE_SETUP_LOG(CONDITION, ...) \ +#define ROCPROFSYS_SETUP_LOG(CONDITION, ...) \ if(CONDITION) \ { \ fflush(stderr); \ - OMNITRACE_SETUP_LOG_START \ - fprintf(stderr, "[omnitrace]" OMNITRACE_SETUP_LOG_NAME "[%i] ", getpid()); \ + ROCPROFSYS_SETUP_LOG_START \ + fprintf(stderr, "[rocprof-sys]" ROCPROFSYS_SETUP_LOG_NAME "[%i] ", getpid()); \ fprintf(stderr, __VA_ARGS__); \ - OMNITRACE_SETUP_LOG_END \ + ROCPROFSYS_SETUP_LOG_END \ fflush(stderr); \ } -namespace omnitrace +namespace rocprofsys { 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 = "librocprof-sys.so", + std::string _omnilib_dl = "librocprof-sys-dl.so") { auto _data = std::vector{}; auto _omnilib_path = path::get_origin(_omnilib); @@ -109,17 +109,17 @@ get_environ(int _verbose, std::string _search_paths = {}, _omnilib = common::path::find_path(_omnilib, _verbose, _search_paths); _omnilib_dl = common::path::find_path(_omnilib_dl, _verbose, _search_paths); -#if defined(OMNITRACE_USE_ROCTRACER) && OMNITRACE_USE_ROCTRACER > 0 +#if defined(ROCPROFSYS_USE_ROCTRACER) && ROCPROFSYS_USE_ROCTRACER > 0 _data.emplace_back(env_config{ "HSA_TOOLS_LIB", _omnilib.c_str(), 0 }); #endif -#if defined(OMNITRACE_USE_ROCPROFILER) && OMNITRACE_USE_ROCPROFILER > 0 -# if OMNITRACE_HIP_VERSION >= 50200 +#if defined(ROCPROFSYS_USE_ROCPROFILER) && ROCPROFSYS_USE_ROCPROFILER > 0 +# if ROCPROFSYS_HIP_VERSION >= 50200 # define ROCPROFILER_METRICS_DIR "lib/rocprofiler" # else # define ROCPROFILER_METRICS_DIR "rocprofiler/lib" # endif -# if OMNITRACE_HIP_VERSION <= 50500 +# if ROCPROFSYS_HIP_VERSION <= 50500 # define ROCPROFILER_LIBNAME "librocprofiler64.so" # else # define ROCPROFILER_LIBNAME "librocprofiler64.so.1" @@ -133,7 +133,7 @@ get_environ(int _verbose, std::string _search_paths = {}, auto _possible_rocp_metrics = std::vector{}; auto _possible_rocprof_libs = std::vector{}; - for(const auto* itr : { "OMNITRACE_ROCM_PATH", "ROCM_PATH" }) + for(const auto* itr : { "ROCPROFSYS_ROCM_PATH", "ROCM_PATH" }) { if(getenv(itr)) { @@ -150,9 +150,9 @@ get_environ(int _verbose, std::string _search_paths = {}, // default path _possible_rocp_metrics.emplace_back( - common::join('/', OMNITRACE_DEFAULT_ROCM_PATH, "lib/rocprofiler")); + common::join('/', ROCPROFSYS_DEFAULT_ROCM_PATH, "lib/rocprofiler")); _possible_rocp_metrics.emplace_back( - common::join('/', OMNITRACE_DEFAULT_ROCM_PATH, "rocprofiler/lib")); + common::join('/', ROCPROFSYS_DEFAULT_ROCM_PATH, "rocprofiler/lib")); auto _realpath_and_unique = [](const auto& _inp_v) { auto _out_v = decltype(_inp_v){}; @@ -172,7 +172,7 @@ get_environ(int _verbose, std::string _search_paths = {}, if(path::exists(itr)) { _data.emplace_back( - env_config{ "OMNITRACE_ROCPROFILER_LIBRARY", itr.c_str(), 0 }); + env_config{ "ROCPROFSYS_ROCPROFILER_LIBRARY", itr.c_str(), 0 }); _possible_rocp_metrics.emplace( _possible_rocp_metrics.begin(), common::join('/', path::dirname(itr), "../../lib/rocprofiler")); @@ -195,7 +195,7 @@ get_environ(int _verbose, std::string _search_paths = {}, } auto _found_rocp_metrics = (!_env_rocp_metrics.empty()) - ? get_env("OMNITRACE_ROCP_METRICS_FORCE_VALID", false) + ? get_env("ROCPROFSYS_ROCP_METRICS_FORCE_VALID", false) : false; if(!_found_rocp_metrics) @@ -232,26 +232,27 @@ get_environ(int _verbose, std::string _search_paths = {}, << path::exists(_rocp_metrics_xml) << ") and/or gfx_metrics.xml (found: " << path::exists(_rocp_gfx_metrics_xml) << "). To ignore this error, set " - "OMNITRACE_ROCP_METRICS_FORCE_VALID=true in the environment"; + "ROCPROFSYS_ROCP_METRICS_FORCE_VALID=true in the environment"; } else { - _msg << "Error! ROCP_METRICS not set in environment and OmniTrace could not " - "find a suitable path. Please set ROCP_METRICS=/path/to/metrics.xml " - "in the environment. This file is typically located in the same " - "folder as the librocprofiler64.so library.\nAdditional note: " - "metrics.xml typically contains:\n\t#include " - "\"gfx_metrics.xml\"\nMake sure the provided path also contains this " - "file.\nExample:\n\texport ROCP_METRICS=" - << OMNITRACE_DEFAULT_ROCM_PATH << "/" << ROCPROFILER_METRICS_DIR - << "/metrics.xml\n"; + _msg + << "Error! ROCP_METRICS not set in environment and rocprof-sys could not " + "find a suitable path. Please set ROCP_METRICS=/path/to/metrics.xml " + "in the environment. This file is typically located in the same " + "folder as the librocprofiler64.so library.\nAdditional note: " + "metrics.xml typically contains:\n\t#include " + "\"gfx_metrics.xml\"\nMake sure the provided path also contains this " + "file.\nExample:\n\texport ROCP_METRICS=" + << ROCPROFSYS_DEFAULT_ROCM_PATH << "/" << ROCPROFILER_METRICS_DIR + << "/metrics.xml\n"; } throw std::runtime_error(_msg.str()); } #endif -#if defined(OMNITRACE_USE_OMPT) && OMNITRACE_USE_OMPT > 0 - if(get_env("OMNITRACE_USE_OMPT", true)) +#if defined(ROCPROFSYS_USE_OMPT) && ROCPROFSYS_USE_OMPT > 0 + if(get_env("ROCPROFSYS_USE_OMPT", true)) { std::string _omni_omp_libs = _omnilib_dl; const char* _omp_libs = getenv("OMP_TOOL_LIBRARIES"); @@ -262,8 +263,8 @@ get_environ(int _verbose, std::string _search_paths = {}, _override = 1; _omni_omp_libs = common::join(':', _omp_libs, _omnilib_dl); } - OMNITRACE_SETUP_LOG(_verbose >= 2, "setting OMP_TOOL_LIBRARIES to '%s'\n", - _omni_omp_libs.c_str()); + ROCPROFSYS_SETUP_LOG(_verbose >= 2, "setting OMP_TOOL_LIBRARIES to '%s'\n", + _omni_omp_libs.c_str()); _data.emplace_back( env_config{ "OMP_TOOL_LIBRARIES", _omni_omp_libs.c_str(), _override }); } @@ -274,8 +275,8 @@ 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 = "librocprof-sys.so", + std::string _omnilib_dl = "librocprof-sys-dl.so") { auto _data = get_environ(_verbose, _search_paths, std::move(_omnilib), std::move(_omnilib_dl)); @@ -283,4 +284,4 @@ setup_environ(int _verbose, const std::string& _search_paths = {}, itr(_verbose >= 3); } } // namespace common -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/CMakeLists.txt b/source/lib/core/CMakeLists.txt index bef6228c..6e3b5341 100644 --- a/source/lib/core/CMakeLists.txt +++ b/source/lib/core/CMakeLists.txt @@ -40,36 +40,40 @@ set(core_headers ${CMAKE_CURRENT_LIST_DIR}/timemory.hpp ${CMAKE_CURRENT_LIST_DIR}/utility.hpp) -add_library(omnitrace-core-library STATIC) -add_library(omnitrace::omnitrace-core ALIAS omnitrace-core-library) +add_library(rocprofiler-systems-core-library STATIC) +add_library(rocprofiler-systems::rocprofiler-systems-core ALIAS + rocprofiler-systems-core-library) -target_sources(omnitrace-core-library PRIVATE ${core_sources} ${core_headers} - ${CMAKE_CURRENT_BINARY_DIR}/defines.hpp) +target_sources( + rocprofiler-systems-core-library PRIVATE ${core_sources} ${core_headers} + ${CMAKE_CURRENT_BINARY_DIR}/defines.hpp) add_subdirectory(binary) add_subdirectory(components) add_subdirectory(containers) -target_include_directories(omnitrace-core-library BEFORE +target_include_directories(rocprofiler-systems-core-library BEFORE PRIVATE ${CMAKE_CURRENT_LIST_DIR}) -target_link_libraries(omnitrace-core-library - PRIVATE omnitrace::omnitrace-interface-library) +target_link_libraries(rocprofiler-systems-core-library + PRIVATE rocprofiler-systems::rocprofiler-systems-interface-library) target_link_libraries( - omnitrace-core-library + rocprofiler-systems-core-library PRIVATE - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $,omnitrace::omnitrace-lto,>>) + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $,rocprofiler-systems::rocprofiler-systems-lto,>> + ) -set_target_properties(omnitrace-core-library PROPERTIES OUTPUT_NAME omnitrace-core) +set_target_properties(rocprofiler-systems-core-library + PROPERTIES OUTPUT_NAME ${BINARY_NAME_PREFIX}-core) diff --git a/source/lib/core/argparse.cpp b/source/lib/core/argparse.cpp index c91ad674..ee195cb4 100644 --- a/source/lib/core/argparse.cpp +++ b/source/lib/core/argparse.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -32,7 +32,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace argparse { @@ -56,25 +56,25 @@ get_clock_id_choices() return _v; }; -#define OMNITRACE_CLOCK_IDENTIFIER(VAL) \ +#define ROCPROFSYS_CLOCK_IDENTIFIER(VAL) \ std::make_tuple(clock_name(#VAL), VAL, std::string_view{ #VAL }) auto _choices = strvec_t{}; auto _aliases = std::map{}; - for(auto itr : { OMNITRACE_CLOCK_IDENTIFIER(CLOCK_REALTIME), - OMNITRACE_CLOCK_IDENTIFIER(CLOCK_MONOTONIC), - OMNITRACE_CLOCK_IDENTIFIER(CLOCK_PROCESS_CPUTIME_ID), - OMNITRACE_CLOCK_IDENTIFIER(CLOCK_MONOTONIC_RAW), - OMNITRACE_CLOCK_IDENTIFIER(CLOCK_REALTIME_COARSE), - OMNITRACE_CLOCK_IDENTIFIER(CLOCK_MONOTONIC_COARSE), - OMNITRACE_CLOCK_IDENTIFIER(CLOCK_BOOTTIME) }) + for(auto itr : { ROCPROFSYS_CLOCK_IDENTIFIER(CLOCK_REALTIME), + ROCPROFSYS_CLOCK_IDENTIFIER(CLOCK_MONOTONIC), + ROCPROFSYS_CLOCK_IDENTIFIER(CLOCK_PROCESS_CPUTIME_ID), + ROCPROFSYS_CLOCK_IDENTIFIER(CLOCK_MONOTONIC_RAW), + ROCPROFSYS_CLOCK_IDENTIFIER(CLOCK_REALTIME_COARSE), + ROCPROFSYS_CLOCK_IDENTIFIER(CLOCK_MONOTONIC_COARSE), + ROCPROFSYS_CLOCK_IDENTIFIER(CLOCK_BOOTTIME) }) { auto _choice = std::to_string(std::get<1>(itr)); _choices.emplace_back(_choice); _aliases[_choice] = { std::get<0>(itr), std::string{ std::get<2>(itr) } }; } -#undef OMNITRACE_CLOCK_IDENTIFIER +#undef ROCPROFSYS_CLOCK_IDENTIFIER return std::make_pair(_choices, _aliases); } @@ -137,13 +137,13 @@ update_env(parser_data& _data, std::string_view _env_var, Tp&& _env_val, else { free(itr); - itr = strdup(omnitrace::common::join('=', _env_var, _env_val).c_str()); + itr = strdup(rocprofsys::common::join('=', _env_var, _env_val).c_str()); } return; } } _data.current.emplace_back( - strdup(omnitrace::common::join('=', _env_var, _env_val).c_str())); + strdup(rocprofsys::common::join('=', _env_var, _env_val).c_str())); } void @@ -171,7 +171,7 @@ get_internal_libpath(const std::string& _lib) auto _pos = _exe.find_last_of('/'); auto _dir = filepath::get_cwd(); if(_pos != std::string_view::npos) _dir = _exe.substr(0, _pos); - return filepath::realpath(omnitrace::common::join("/", _dir, "..", "lib", _lib), + return filepath::realpath(rocprofsys::common::join("/", _dir, "..", "lib", _lib), nullptr, false); } } // namespace @@ -219,21 +219,21 @@ init_parser(parser_data& _data) } } - _data.dl_libpath = get_realpath(get_internal_libpath("libomnitrace-dl.so").c_str()); - _data.omni_libpath = get_realpath(get_internal_libpath("libomnitrace.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("librocprof-sys.so").c_str()); -#if defined(OMNITRACE_USE_ROCTRACER) || defined(OMNITRACE_USE_ROCPROFILER) +#if defined(ROCPROFSYS_USE_ROCTRACER) || defined(ROCPROFSYS_USE_ROCPROFILER) update_env(_data, "HSA_TOOLS_LIB", _data.dl_libpath); if(!getenv("HSA_TOOLS_REPORT_LOAD_FAILURE")) update_env(_data, "HSA_TOOLS_REPORT_LOAD_FAILURE", "1"); #endif -#if defined(OMNITRACE_USE_ROCPROFILER) +#if defined(ROCPROFSYS_USE_ROCPROFILER) update_env(_data, "ROCP_TOOL_LIB", _data.omni_libpath); if(!getenv("ROCP_HSA_INTERCEPT")) update_env(_data, "ROCP_HSA_INTERCEPT", "1"); #endif -#if defined(OMNITRACE_USE_OMPT) +#if defined(ROCPROFSYS_USE_OMPT) if(!getenv("OMP_TOOL_LIBRARIES")) update_env(_data, "OMP_TOOL_LIBRARIES", _data.dl_libpath, UPD_PREPEND); #endif @@ -305,7 +305,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) ? strvec_t{ "hsa-interrupt" } : strvec_t{}; -#if OMNITRACE_USE_ROCTRACER == 0 && OMNITRACE_USE_ROCPROFILER == 0 +#if ROCPROFSYS_USE_ROCTRACER == 0 && ROCPROFSYS_USE_ROCPROFILER == 0 _realtime_reqs.clear(); #endif @@ -325,7 +325,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) auto _monochrome = p.get("monochrome"); _data.monochrome = _monochrome; p.set_use_color(!_monochrome); - update_env(_data, "OMNITRACE_MONOCHROME", (_monochrome) ? "1" : "0"); + update_env(_data, "ROCPROFSYS_MONOCHROME", (_monochrome) ? "1" : "0"); update_env(_data, "MONOCHROME", (_monochrome) ? "1" : "0"); }); @@ -337,7 +337,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) _parser.add_argument({ "--debug" }, "Debug output") .max_count(1) .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_DEBUG", p.get("debug")); + update_env(_data, "ROCPROFSYS_DEBUG", p.get("debug")); }); _data.processed_environs.emplace("debug"); @@ -351,7 +351,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .action([&](parser_t& p) { auto _v = p.get("verbose"); _data.verbose = _v; - update_env(_data, "OMNITRACE_VERBOSE", _v); + update_env(_data, "ROCPROFSYS_VERBOSE", _v); }); _data.processed_environs.emplace("verbose"); @@ -369,7 +369,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .min_count(1) .dtype("filepath") .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_CONFIG_FILE", + update_env(_data, "ROCPROFSYS_CONFIG_FILE", join(array_config_t{ ":" }, p.get("config"))); }); @@ -389,8 +389,8 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .dtype("path [prefix]") .action([&](parser_t& p) { auto _v = p.get("output"); - update_env(_data, "OMNITRACE_OUTPUT_PATH", _v.at(0)); - if(_v.size() > 1) update_env(_data, "OMNITRACE_OUTPUT_PREFIX", _v.at(1)); + update_env(_data, "ROCPROFSYS_OUTPUT_PATH", _v.at(0)); + if(_v.size() > 1) update_env(_data, "ROCPROFSYS_OUTPUT_PREFIX", _v.at(1)); }); _data.processed_environs.emplace("output"); @@ -405,7 +405,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) "Generate a detailed trace (perfetto output)") .max_count(1) .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_TRACE", p.get("trace")); + update_env(_data, "ROCPROFSYS_TRACE", p.get("trace")); }); _data.processed_environs.emplace("trace"); @@ -420,7 +420,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .max_count(1) .conflicts({ "flat-profile" }) .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_PROFILE", p.get("profile")); + update_env(_data, "ROCPROFSYS_PROFILE", p.get("profile")); }); _data.processed_environs.emplace("profile"); @@ -434,8 +434,8 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .max_count(1) .conflicts({ "profile" }) .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_PROFILE", p.get("flat-profile")); - update_env(_data, "OMNITRACE_FLAT_PROFILE", p.get("flat-profile")); + update_env(_data, "ROCPROFSYS_PROFILE", p.get("flat-profile")); + update_env(_data, "ROCPROFSYS_FLAT_PROFILE", p.get("flat-profile")); }); _data.processed_environs.emplace("flat_profile"); @@ -451,13 +451,13 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .dtype("timer-type") .choices({ "cputime", "realtime" }) .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_USE_SAMPLING", true); + update_env(_data, "ROCPROFSYS_USE_SAMPLING", true); auto _modes = p.get("sample"); if(!_modes.empty()) { - update_env(_data, "OMNITRACE_SAMPLING_CPUTIME", + update_env(_data, "ROCPROFSYS_SAMPLING_CPUTIME", _modes.count("cputime") > 0, UPD_WEAK); - update_env(_data, "OMNITRACE_SAMPLING_REALTIME", + update_env(_data, "ROCPROFSYS_SAMPLING_REALTIME", _modes.count("realtime") > 0, UPD_WEAK); } }); @@ -475,8 +475,8 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .action([&](parser_t& p) { auto _h = p.get("host"); auto _d = p.get("device"); - update_env(_data, "OMNITRACE_USE_PROCESS_SAMPLING", _h || _d); - update_env(_data, "OMNITRACE_CPU_FREQ_ENABLED", _h); + update_env(_data, "ROCPROFSYS_USE_PROCESS_SAMPLING", _h || _d); + update_env(_data, "ROCPROFSYS_CPU_FREQ_ENABLED", _h); }); _data.processed_environs.emplace("host"); @@ -494,8 +494,8 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .action([&](parser_t& p) { auto _h = p.get("host"); auto _d = p.get("device"); - update_env(_data, "OMNITRACE_USE_PROCESS_SAMPLING", _h || _d); - update_env(_data, "OMNITRACE_USE_ROCM_SMI", _d); + update_env(_data, "ROCPROFSYS_USE_PROCESS_SAMPLING", _h || _d); + update_env(_data, "ROCPROFSYS_USE_ROCM_SMI", _d); }); _data.processed_environs.emplace("device"); @@ -512,11 +512,11 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .count(1) .dtype("seconds") .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_TRACE_DELAY", p.get("wait"), + update_env(_data, "ROCPROFSYS_TRACE_DELAY", p.get("wait"), UPD_WEAK); - update_env(_data, "OMNITRACE_SAMPLING_DELAY", p.get("wait"), + update_env(_data, "ROCPROFSYS_SAMPLING_DELAY", p.get("wait"), UPD_WEAK); - update_env(_data, "OMNITRACE_CAUSAL_DELAY", p.get("wait"), + update_env(_data, "ROCPROFSYS_CAUSAL_DELAY", p.get("wait"), UPD_WEAK); }); @@ -533,11 +533,11 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .count(1) .dtype("seconds") .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_TRACE_DURATION", p.get("duration"), + update_env(_data, "ROCPROFSYS_TRACE_DURATION", p.get("duration"), UPD_WEAK); - update_env(_data, "OMNITRACE_SAMPLING_DURATION", + update_env(_data, "ROCPROFSYS_SAMPLING_DURATION", p.get("duration"), UPD_WEAK); - update_env(_data, "OMNITRACE_CAUSAL_DURATION", p.get("duration"), + update_env(_data, "ROCPROFSYS_CAUSAL_DURATION", p.get("duration"), UPD_WEAK); }); @@ -555,7 +555,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .dtype("period-spec(s)") .action([&](parser_t& p) { update_env( - _data, "OMNITRACE_TRACE_PERIODS", + _data, "ROCPROFSYS_TRACE_PERIODS", join(array_config_t{ " ", "", "" }, p.get("periods")), UPD_WEAK); }); @@ -567,28 +567,28 @@ add_core_arguments(parser_t& _parser, parser_data& _data) "rcclp", "rocm-smi", "roctracer", "rocprofiler", "roctx", "mutex-locks", "spin-locks", "rw-locks" }; -#if !defined(OMNITRACE_USE_MPI) && !defined(OMNITRACE_USE_MPI_HEADERS) +#if !defined(ROCPROFSYS_USE_MPI) && !defined(ROCPROFSYS_USE_MPI_HEADERS) _backend_choices.erase("mpip"); #endif -#if !defined(OMNITRACE_USE_OMPT) +#if !defined(ROCPROFSYS_USE_OMPT) _backend_choices.erase("ompt"); #endif -#if !defined(OMNITRACE_USE_RCCL) +#if !defined(ROCPROFSYS_USE_RCCL) _backend_choices.erase("rcclp"); #endif -#if !defined(OMNITRACE_USE_ROCM_SMI) +#if !defined(ROCPROFSYS_USE_ROCM_SMI) _backend_choices.erase("rocm-smi"); #endif -#if !defined(OMNITRACE_USE_ROCTRACER) +#if !defined(ROCPROFSYS_USE_ROCTRACER) _backend_choices.erase("roctracer"); _backend_choices.erase("roctx"); #endif -#if !defined(OMNITRACE_USE_ROCPROFILER) +#if !defined(ROCPROFSYS_USE_ROCPROFILER) _backend_choices.erase("rocprofiler"); #endif @@ -599,25 +599,25 @@ add_core_arguments(parser_t& _parser, parser_data& _data) _backend_choices.erase("roctracer"); _backend_choices.erase("rocprofiler"); -#if defined(OMNITRACE_USE_RCCL) - update_env(_data, "OMNITRACE_USE_RCCLP", false); +#if defined(ROCPROFSYS_USE_RCCL) + update_env(_data, "ROCPROFSYS_USE_RCCLP", false); #endif -#if defined(OMNITRACE_USE_ROCM_SMI) - update_env(_data, "OMNITRACE_USE_ROCM_SMI", false); +#if defined(ROCPROFSYS_USE_ROCM_SMI) + update_env(_data, "ROCPROFSYS_USE_ROCM_SMI", false); #endif -#if defined(OMNITRACE_USE_ROCTRACER) - update_env(_data, "OMNITRACE_USE_ROCTRACER", false); - update_env(_data, "OMNITRACE_USE_ROCTX", false); - update_env(_data, "OMNITRACE_ROCTRACER_HSA_ACTIVITY", false); - update_env(_data, "OMNITRACE_ROCTRACER_HIP_ACTIVITY", false); +#if defined(ROCPROFSYS_USE_ROCTRACER) + update_env(_data, "ROCPROFSYS_USE_ROCTRACER", false); + update_env(_data, "ROCPROFSYS_USE_ROCTX", false); + update_env(_data, "ROCPROFSYS_ROCTRACER_HSA_ACTIVITY", false); + update_env(_data, "ROCPROFSYS_ROCTRACER_HIP_ACTIVITY", false); _backend_choices.erase("roctracer"); _backend_choices.erase("roctx"); #endif -#if defined(OMNITRACE_USE_ROCPROFILER) - update_env(_data, "OMNITRACE_USE_ROCPROFILER", false); +#if defined(ROCPROFSYS_USE_ROCPROFILER) + update_env(_data, "ROCPROFSYS_USE_ROCPROFILER", false); #endif } @@ -637,17 +637,17 @@ add_core_arguments(parser_t& _parser, parser_data& _data) auto _update = [&](const auto& _opt, bool _cond) { if(_cond || _v.count("all") > 0) update_env(_data, _opt, true); }; - _update("OMNITRACE_USE_KOKKOSP", _v.count("kokkosp") > 0); - _update("OMNITRACE_USE_MPIP", _v.count("mpip") > 0); - _update("OMNITRACE_USE_OMPT", _v.count("ompt") > 0); - _update("OMNITRACE_USE_RCCLP", _v.count("rcclp") > 0); - _update("OMNITRACE_USE_ROCTX", _v.count("roctx") > 0); - _update("OMNITRACE_USE_ROCM_SMI", _v.count("rocm-smi") > 0); - _update("OMNITRACE_USE_ROCTRACER", _v.count("roctracer") > 0); - _update("OMNITRACE_USE_ROCPROFILER", _v.count("rocprofiler") > 0); - _update("OMNITRACE_TRACE_THREAD_LOCKS", _v.count("mutex-locks") > 0); - _update("OMNITRACE_TRACE_THREAD_RW_LOCKS", _v.count("rw-locks") > 0); - _update("OMNITRACE_TRACE_THREAD_SPIN_LOCKS", _v.count("spin-locks") > 0); + _update("ROCPROFSYS_USE_KOKKOSP", _v.count("kokkosp") > 0); + _update("ROCPROFSYS_USE_MPIP", _v.count("mpip") > 0); + _update("ROCPROFSYS_USE_OMPT", _v.count("ompt") > 0); + _update("ROCPROFSYS_USE_RCCLP", _v.count("rcclp") > 0); + _update("ROCPROFSYS_USE_ROCTX", _v.count("roctx") > 0); + _update("ROCPROFSYS_USE_ROCM_SMI", _v.count("rocm-smi") > 0); + _update("ROCPROFSYS_USE_ROCTRACER", _v.count("roctracer") > 0); + _update("ROCPROFSYS_USE_ROCPROFILER", _v.count("rocprofiler") > 0); + _update("ROCPROFSYS_TRACE_THREAD_LOCKS", _v.count("mutex-locks") > 0); + _update("ROCPROFSYS_TRACE_THREAD_RW_LOCKS", _v.count("rw-locks") > 0); + _update("ROCPROFSYS_TRACE_THREAD_SPIN_LOCKS", _v.count("spin-locks") > 0); if(_v.count("all") > 0 || _v.count("ompt") > 0) update_env(_data, "OMP_TOOL_LIBRARIES", _data.dl_libpath, @@ -673,17 +673,17 @@ add_core_arguments(parser_t& _parser, parser_data& _data) auto _update = [&](const auto& _opt, bool _cond) { if(_cond || _v.count("all") > 0) update_env(_data, _opt, false); }; - _update("OMNITRACE_USE_KOKKOSP", _v.count("kokkosp") > 0); - _update("OMNITRACE_USE_MPIP", _v.count("mpip") > 0); - _update("OMNITRACE_USE_OMPT", _v.count("ompt") > 0); - _update("OMNITRACE_USE_RCCLP", _v.count("rcclp") > 0); - _update("OMNITRACE_USE_ROCTX", _v.count("roctx") > 0); - _update("OMNITRACE_USE_ROCM_SMI", _v.count("rocm-smi") > 0); - _update("OMNITRACE_USE_ROCTRACER", _v.count("roctracer") > 0); - _update("OMNITRACE_USE_ROCPROFILER", _v.count("rocprofiler") > 0); - _update("OMNITRACE_TRACE_THREAD_LOCKS", _v.count("mutex-locks") > 0); - _update("OMNITRACE_TRACE_THREAD_RW_LOCKS", _v.count("rw-locks") > 0); - _update("OMNITRACE_TRACE_THREAD_SPIN_LOCKS", _v.count("spin-locks") > 0); + _update("ROCPROFSYS_USE_KOKKOSP", _v.count("kokkosp") > 0); + _update("ROCPROFSYS_USE_MPIP", _v.count("mpip") > 0); + _update("ROCPROFSYS_USE_OMPT", _v.count("ompt") > 0); + _update("ROCPROFSYS_USE_RCCLP", _v.count("rcclp") > 0); + _update("ROCPROFSYS_USE_ROCTX", _v.count("roctx") > 0); + _update("ROCPROFSYS_USE_ROCM_SMI", _v.count("rocm-smi") > 0); + _update("ROCPROFSYS_USE_ROCTRACER", _v.count("roctracer") > 0); + _update("ROCPROFSYS_USE_ROCPROFILER", _v.count("rocprofiler") > 0); + _update("ROCPROFSYS_TRACE_THREAD_LOCKS", _v.count("mutex-locks") > 0); + _update("ROCPROFSYS_TRACE_THREAD_RW_LOCKS", _v.count("rw-locks") > 0); + _update("ROCPROFSYS_TRACE_THREAD_SPIN_LOCKS", _v.count("spin-locks") > 0); if(_v.count("all") > 0 || (_v.count("roctracer") > 0 && _v.count("rocprofiler") > 0)) @@ -746,7 +746,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .count(1) .dtype("filepath") .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_PERFETTO_FILE", + update_env(_data, "ROCPROFSYS_PERFETTO_FILE", p.get("trace-file")); }); @@ -762,7 +762,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .count(1) .dtype("KB") .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_PERFETTO_BUFFER_SIZE_KB", + update_env(_data, "ROCPROFSYS_PERFETTO_BUFFER_SIZE_KB", p.get("trace-buffer-size")); }); @@ -777,7 +777,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .dtype("policy") .choices({ "discard", "ring_buffer" }) .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_PERFETTO_FILL_POLICY", + update_env(_data, "ROCPROFSYS_PERFETTO_FILL_POLICY", p.get("trace-fill-policy")); }); @@ -797,7 +797,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .count(1) .dtype("seconds") .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_TRACE_DELAY", p.get("trace-wait")); + update_env(_data, "ROCPROFSYS_TRACE_DELAY", p.get("trace-wait")); }); _data.processed_environs.emplace("trace_delay"); @@ -814,7 +814,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .count(1) .dtype("seconds") .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_TRACE_DURATION", + update_env(_data, "ROCPROFSYS_TRACE_DURATION", p.get("trace-duration")); }); @@ -833,7 +833,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .min_count(1) .dtype("period-spec(s)") .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_TRACE_PERIODS", + update_env(_data, "ROCPROFSYS_TRACE_PERIODS", join(array_config_t{ ",", "", "" }, p.get("trace-periods"))); }); @@ -855,11 +855,11 @@ add_core_arguments(parser_t& _parser, parser_data& _data) "active " "threads would equate to ~1 second of realtime. If this proves to be " "difficult to handle in practice, please file a feature request for " - "omnitrace to auto-scale based on the number of threads.") + "rocprof-sys to auto-scale based on the number of threads.") .count(1) .dtype("clock-id") .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_TRACE_PERIOD_CLOCK_ID", + update_env(_data, "ROCPROFSYS_TRACE_PERIOD_CLOCK_ID", p.get("trace-clock-id")); }) .choices(_clock_id_choices.first) @@ -883,12 +883,12 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .choices({ "text", "json", "console" }) .action([&](parser_t& p) { auto _v = p.get("profile-format"); - update_env(_data, "OMNITRACE_PROFILE", true); + update_env(_data, "ROCPROFSYS_PROFILE", true); if(!_v.empty()) { - update_env(_data, "OMNITRACE_TEXT_OUTPUT", _v.count("text") != 0); - update_env(_data, "OMNITRACE_JSON_OUTPUT", _v.count("json") != 0); - update_env(_data, "OMNITRACE_COUT_OUTPUT", _v.count("console") != 0); + update_env(_data, "ROCPROFSYS_TEXT_OUTPUT", _v.count("text") != 0); + update_env(_data, "ROCPROFSYS_JSON_OUTPUT", _v.count("json") != 0); + update_env(_data, "ROCPROFSYS_COUT_OUTPUT", _v.count("console") != 0); } }); @@ -911,9 +911,9 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .dtype("path [prefix]") .action([&](parser_t& p) { auto _v = p.get("profile-diff"); - update_env(_data, "OMNITRACE_DIFF_OUTPUT", true); - update_env(_data, "OMNITRACE_INPUT_PATH", _v.at(0)); - if(_v.size() > 1) update_env(_data, "OMNITRACE_INPUT_PREFIX", _v.at(1)); + update_env(_data, "ROCPROFSYS_DIFF_OUTPUT", true); + update_env(_data, "ROCPROFSYS_INPUT_PATH", _v.at(0)); + if(_v.size() > 1) update_env(_data, "ROCPROFSYS_INPUT_PREFIX", _v.at(1)); }); _data.processed_environs.emplace("profile_diff"); @@ -936,7 +936,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .count(1) .dtype("floating-point") .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_PROCESS_SAMPLING_FREQ", + update_env(_data, "ROCPROFSYS_PROCESS_SAMPLING_FREQ", p.get("process-freq")); }); @@ -953,7 +953,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .count(1) .dtype("seconds") .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_PROCESS_SAMPLING_DELAY", + update_env(_data, "ROCPROFSYS_PROCESS_SAMPLING_DELAY", p.get("process-wait")); }); @@ -970,7 +970,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .count(1) .dtype("seconds") .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_SAMPLING_PROCESS_DURATION", + update_env(_data, "ROCPROFSYS_SAMPLING_PROCESS_DURATION", p.get("process-duration")); }); @@ -987,7 +987,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .dtype("int and/or range") .required({ "host" }) .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_SAMPLING_CPUS", + update_env(_data, "ROCPROFSYS_SAMPLING_CPUS", join(array_config_t{ "," }, p.get("cpus"))); }); @@ -1003,7 +1003,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .dtype("int and/or range") .required({ "device" }) .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_SAMPLING_GPUS", + update_env(_data, "ROCPROFSYS_SAMPLING_GPUS", join(array_config_t{ "," }, p.get("gpus"))); }); @@ -1023,7 +1023,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .count(1) .dtype("floating-point") .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_SAMPLING_FREQ", + update_env(_data, "ROCPROFSYS_SAMPLING_FREQ", p.get("sampling-freq")); }); @@ -1042,7 +1042,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .dtype("int and/or range") .action([&](parser_t& p) { update_env( - _data, "OMNITRACE_SAMPLING_TIDS", + _data, "ROCPROFSYS_SAMPLING_TIDS", join(array_config_t{ ", " }, p.get>("tids"))); }); @@ -1063,7 +1063,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .count(1) .dtype("seconds") .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_SAMPLING_DELAY", + update_env(_data, "ROCPROFSYS_SAMPLING_DELAY", p.get("sampling-wait")); }); @@ -1082,7 +1082,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .count(1) .dtype("seconds") .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_SAMPLING_DURATION", + update_env(_data, "ROCPROFSYS_SAMPLING_DURATION", p.get("sampling-duration")); }); @@ -1100,20 +1100,20 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .dtype("[freq] [delay] [tids...]") .action([&](parser_t& p) { auto _v = p.get>("sample-cputime"); - update_env(_data, "OMNITRACE_SAMPLING_CPUTIME", true); + update_env(_data, "ROCPROFSYS_SAMPLING_CPUTIME", true); if(!_v.empty()) { - update_env(_data, "OMNITRACE_SAMPLING_CPUTIME_FREQ", _v.front()); + update_env(_data, "ROCPROFSYS_SAMPLING_CPUTIME_FREQ", _v.front()); _v.pop_front(); } if(!_v.empty()) { - update_env(_data, "OMNITRACE_SAMPLING_CPUTIME_DELAY", _v.front()); + update_env(_data, "ROCPROFSYS_SAMPLING_CPUTIME_DELAY", _v.front()); _v.pop_front(); } if(!_v.empty()) { - update_env(_data, "OMNITRACE_SAMPLING_CPUTIME_TIDS", + update_env(_data, "ROCPROFSYS_SAMPLING_CPUTIME_TIDS", join(array_config_t{ "," }, _v)); } }); @@ -1129,20 +1129,20 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .required(std::move(_realtime_reqs)) .action([&](parser_t& p) { auto _v = p.get>("sample-realtime"); - update_env(_data, "OMNITRACE_SAMPLING_REALTIME", true); + update_env(_data, "ROCPROFSYS_SAMPLING_REALTIME", true); if(!_v.empty()) { - update_env(_data, "OMNITRACE_SAMPLING_REALTIME_FREQ", _v.front()); + update_env(_data, "ROCPROFSYS_SAMPLING_REALTIME_FREQ", _v.front()); _v.pop_front(); } if(!_v.empty()) { - update_env(_data, "OMNITRACE_SAMPLING_REALTIME_DELAY", _v.front()); + update_env(_data, "ROCPROFSYS_SAMPLING_REALTIME_DELAY", _v.front()); _v.pop_front(); } if(!_v.empty()) { - update_env(_data, "OMNITRACE_SAMPLING_REALTIME_TIDS", + update_env(_data, "ROCPROFSYS_SAMPLING_REALTIME_TIDS", join(array_config_t{ "," }, _v)); } }); @@ -1157,7 +1157,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) .dtype("[event] [freq] [tids...]") .action([&](parser_t& p) { auto _v = p.get>("sample-overflow"); - update_env(_data, "OMNITRACE_SAMPLING_OVERFLOW", true); + update_env(_data, "ROCPROFSYS_SAMPLING_OVERFLOW", true); if(!_v.empty()) { @@ -1167,17 +1167,17 @@ add_core_arguments(parser_t& _parser, parser_data& _data) "", "'--sample-overflow ", _v.front(), " ...' conflicts with '--sampling-overflow-event ", p.get("sampling-overflow-event"), "' option")); - update_env(_data, "OMNITRACE_SAMPLING_OVERFLOW_EVENT", _v.front()); + update_env(_data, "ROCPROFSYS_SAMPLING_OVERFLOW_EVENT", _v.front()); _v.pop_front(); } if(!_v.empty()) { - update_env(_data, "OMNITRACE_SAMPLING_OVERFLOW_FREQ", _v.front()); + update_env(_data, "ROCPROFSYS_SAMPLING_OVERFLOW_FREQ", _v.front()); _v.pop_front(); } if(!_v.empty()) { - update_env(_data, "OMNITRACE_SAMPLING_OVERFLOW_TIDS", + update_env(_data, "ROCPROFSYS_SAMPLING_OVERFLOW_TIDS", join(array_config_t{ "," }, _v)); } }); @@ -1191,37 +1191,37 @@ 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) { auto _events = join(array_config_t{ "," }, p.get("cpu-events")); - update_env(_data, "OMNITRACE_PAPI_EVENTS", _events); + update_env(_data, "ROCPROFSYS_PAPI_EVENTS", _events); }); _data.processed_environs.emplace("cpu_events"); _data.processed_environs.emplace("papi_events"); } -#if defined(OMNITRACE_USE_ROCPROFILER) +#if defined(ROCPROFSYS_USE_ROCPROFILER) if(_data.environ_filter("gpu_events", _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) { auto _events = join(array_config_t{ "," }, p.get("gpu-events")); - update_env(_data, "OMNITRACE_ROCM_EVENTS", _events); + update_env(_data, "ROCPROFSYS_ROCM_EVENTS", _events); }); _data.processed_environs.emplace("gpu_events"); @@ -1244,7 +1244,7 @@ add_core_arguments(parser_t& _parser, parser_data& _data) "Include inline info in output when available") .max_count(1) .action([&](parser_t& p) { - update_env(_data, "OMNITRACE_SAMPLING_INCLUDE_INLINES", + update_env(_data, "ROCPROFSYS_SAMPLING_INCLUDE_INLINES", p.get("inlines")); }); @@ -1328,9 +1328,9 @@ add_group_arguments(parser_t& _parser, const std::string& _group_name, parser_da }; auto _settings = std::vector>{}; - for(auto& itr : *omnitrace::settings::instance()) + for(auto& itr : *rocprofsys::settings::instance()) { - if(itr.second->get_categories().count("omnitrace") == 0) continue; + if(itr.second->get_categories().count("rocprofsys") == 0) continue; if(itr.second->get_categories().count("deprecated") > 0) continue; if(itr.second->get_hidden()) continue; if(!_data.setting_filter(itr.second.get(), _data)) continue; @@ -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); } } @@ -1390,9 +1390,9 @@ add_extended_arguments(parser_t& _parser, parser_data& _data) { auto _category_count_map = std::unordered_map{}; auto _settings = std::vector>{}; - for(auto& itr : *omnitrace::settings::instance()) + for(auto& itr : *rocprofsys::settings::instance()) { - if(itr.second->get_categories().count("omnitrace") == 0) continue; + if(itr.second->get_categories().count("rocprofsys") == 0) continue; if(itr.second->get_categories().count("deprecated") > 0) continue; if(itr.second->get_hidden()) continue; if(!_data.setting_filter(itr.second.get(), _data)) continue; @@ -1414,15 +1414,14 @@ 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); } for(const auto& citr : itr.second->get_categories()) { - if(std::regex_search( - citr, std::regex{ - "omnitrace|timemory|^(native|custom|advanced|analysis)$" })) + if(std::regex_search(citr, std::regex{ "rocprofsys|timemory|^(" + "native|custom|advanced|analysis)$" })) continue; _category_count_map[citr] += 1; } @@ -1467,4 +1466,4 @@ add_extended_arguments(parser_t& _parser, parser_data& _data) return _data; } } // namespace argparse -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/argparse.hpp b/source/lib/core/argparse.hpp index 0e30463d..36648300 100644 --- a/source/lib/core/argparse.hpp +++ b/source/lib/core/argparse.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -31,7 +31,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace argparse { @@ -93,4 +93,4 @@ add_group_arguments(parser_t&, const std::string&, parser_data&, bool _add_group parser_data& add_extended_arguments(parser_t&, parser_data&); } // namespace argparse -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/binary/CMakeLists.txt b/source/lib/core/binary/CMakeLists.txt index 085125f3..a5fade49 100644 --- a/source/lib/core/binary/CMakeLists.txt +++ b/source/lib/core/binary/CMakeLists.txt @@ -4,4 +4,5 @@ set(binary_sources ${CMAKE_CURRENT_LIST_DIR}/address_range.cpp) set(binary_headers ${CMAKE_CURRENT_LIST_DIR}/address_range.hpp ${CMAKE_CURRENT_LIST_DIR}/fwd.hpp) -target_sources(omnitrace-core-library PRIVATE ${binary_sources} ${binary_headers}) +target_sources(rocprofiler-systems-core-library PRIVATE ${binary_sources} + ${binary_headers}) diff --git a/source/lib/core/binary/address_range.cpp b/source/lib/core/binary/address_range.cpp index 2d385889..285c1a37 100644 --- a/source/lib/core/binary/address_range.cpp +++ b/source/lib/core/binary/address_range.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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,7 +23,7 @@ #include "binary/address_range.hpp" #include "debug.hpp" -namespace omnitrace +namespace rocprofsys { namespace binary { @@ -187,4 +187,4 @@ address_range::hash() const : hash_value_t{ low }; } } // namespace binary -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/binary/address_range.hpp b/source/lib/core/binary/address_range.hpp index 96b5259e..4f4a1a63 100644 --- a/source/lib/core/binary/address_range.hpp +++ b/source/lib/core/binary/address_range.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -32,7 +32,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace binary { @@ -43,7 +43,7 @@ struct address_range uintptr_t low = std::numeric_limits::max(); uintptr_t high = std::numeric_limits::min(); - OMNITRACE_DEFAULT_OBJECT(address_range) + ROCPROFSYS_DEFAULT_OBJECT(address_range) explicit address_range(uintptr_t _v); address_range(uintptr_t _low, uintptr_t _high); @@ -89,14 +89,14 @@ operator+(uintptr_t _v, binary::address_range _lhs) { return (_lhs += _v); } -} // namespace omnitrace +} // namespace rocprofsys namespace std { template <> -struct hash<::omnitrace::binary::address_range> +struct hash<::rocprofsys::binary::address_range> { - using address_range_t = ::omnitrace::binary::address_range; + using address_range_t = ::rocprofsys::binary::address_range; auto operator()(const address_range_t& _v) const { return _v.hash(); } auto operator()(address_range_t&& _v) const { return _v.hash(); } diff --git a/source/lib/core/binary/fwd.hpp b/source/lib/core/binary/fwd.hpp index 8a245851..212fac6f 100644 --- a/source/lib/core/binary/fwd.hpp +++ b/source/lib/core/binary/fwd.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -43,7 +43,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace binary { @@ -59,4 +59,4 @@ struct symbol; struct dwarf_entry; struct binary_info; } // namespace binary -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/categories.cpp b/source/lib/core/categories.cpp index 27e19e1b..7b09a2c4 100644 --- a/source/lib/core/categories.cpp +++ b/source/lib/core/categories.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -31,7 +31,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace categories { @@ -44,8 +44,8 @@ configure_categories(bool _enable, const std::set& _categories) auto _name = trait::name::value; if(_categories.count(_name) > 0) { - OMNITRACE_VERBOSE_F(3, "%s category: %s\n", (_enable) ? "Enabling" : "Disabling", - _name); + ROCPROFSYS_VERBOSE_F(3, "%s category: %s\n", (_enable) ? "Enabling" : "Disabling", + _name); trait::runtime_enabled::set(_enable); } } @@ -61,11 +61,11 @@ configure_categories(bool _enable, const std::set& _categories, void configure_categories(bool _enable, const std::set& _categories) { - OMNITRACE_VERBOSE_F(1, "%s categories...\n", (_enable) ? "Enabling" : "Disabling"); + ROCPROFSYS_VERBOSE_F(1, "%s categories...\n", (_enable) ? "Enabling" : "Disabling"); configure_categories( _enable, _categories, - utility::make_index_sequence_range<1, OMNITRACE_CATEGORY_LAST>{}); + utility::make_index_sequence_range<1, ROCPROFSYS_CATEGORY_LAST>{}); } } // namespace @@ -74,7 +74,7 @@ enable_categories(const std::set& _categories) { configure_categories( true, _categories, - utility::make_index_sequence_range<1, OMNITRACE_CATEGORY_LAST>{}); + utility::make_index_sequence_range<1, ROCPROFSYS_CATEGORY_LAST>{}); } void @@ -82,7 +82,7 @@ disable_categories(const std::set& _categories) { configure_categories( false, _categories, - utility::make_index_sequence_range<1, OMNITRACE_CATEGORY_LAST>{}); + utility::make_index_sequence_range<1, ROCPROFSYS_CATEGORY_LAST>{}); } void @@ -138,4 +138,4 @@ shutdown() disable_categories(config::get_enabled_categories()); } } // namespace categories -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/categories.hpp b/source/lib/core/categories.hpp index ce3f6635..5eb633db 100644 --- a/source/lib/core/categories.hpp +++ b/source/lib/core/categories.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -24,7 +24,7 @@ #include "common/join.hpp" #include "defines.hpp" -#include "omnitrace/categories.h" // in omnitrace-user +#include "rocprofiler-systems/categories.h" // in rocprof-sys-user #if defined(TIMEMORY_PERFETTO_CATEGORIES) # error "TIMEMORY_PERFETTO_CATEGORIES is already defined. Please include \"" __FILE__ "\" before including any timemory files" @@ -35,7 +35,7 @@ #include #include -#define OMNITRACE_DEFINE_NAME_TRAIT(NAME, DESC, ...) \ +#define ROCPROFSYS_DEFINE_NAME_TRAIT(NAME, DESC, ...) \ namespace tim \ { \ namespace trait \ @@ -49,7 +49,7 @@ } \ } -namespace omnitrace +namespace rocprofsys { template struct category_type_id; @@ -59,10 +59,10 @@ struct category_enum_id; template using category_type_id_t = typename category_type_id::type; -} // namespace omnitrace +} // namespace rocprofsys -#define OMNITRACE_DEFINE_CATEGORY_TRAIT(TYPE, ENUM) \ - namespace omnitrace \ +#define ROCPROFSYS_DEFINE_CATEGORY_TRAIT(TYPE, ENUM) \ + namespace rocprofsys \ { \ template <> \ struct category_type_id \ @@ -76,61 +76,61 @@ using category_type_id_t = typename category_type_id::type; }; \ } -#define OMNITRACE_DECLARE_CATEGORY(NS, VALUE, ENUM, NAME, DESC) \ +#define ROCPROFSYS_DECLARE_CATEGORY(NS, VALUE, ENUM, NAME, DESC) \ TIMEMORY_DECLARE_NS_API(NS, VALUE) \ - OMNITRACE_DEFINE_NAME_TRAIT(NAME, DESC, NS::VALUE) \ - OMNITRACE_DEFINE_CATEGORY_TRAIT(::tim::NS::VALUE, ENUM) -#define OMNITRACE_DEFINE_CATEGORY(NS, VALUE, ENUM, NAME, DESC) \ + ROCPROFSYS_DEFINE_NAME_TRAIT(NAME, DESC, NS::VALUE) \ + ROCPROFSYS_DEFINE_CATEGORY_TRAIT(::tim::NS::VALUE, ENUM) +#define ROCPROFSYS_DEFINE_CATEGORY(NS, VALUE, ENUM, NAME, DESC) \ TIMEMORY_DEFINE_NS_API(NS, VALUE) \ - OMNITRACE_DEFINE_NAME_TRAIT(NAME, DESC, NS::VALUE) \ - OMNITRACE_DEFINE_CATEGORY_TRAIT(::tim::NS::VALUE, ENUM) + ROCPROFSYS_DEFINE_NAME_TRAIT(NAME, DESC, NS::VALUE) \ + ROCPROFSYS_DEFINE_CATEGORY_TRAIT(::tim::NS::VALUE, ENUM) // clang-format off -// these are defined by omnitrace -OMNITRACE_DEFINE_CATEGORY(project, omnitrace, OMNITRACE_CATEGORY_NONE, "omnitrace", "Omnitrace project") -OMNITRACE_DEFINE_CATEGORY(category, host, OMNITRACE_CATEGORY_HOST, "host", "Host-side function tracing") -OMNITRACE_DEFINE_CATEGORY(category, user, OMNITRACE_CATEGORY_USER, "user", "User-defined regions") -OMNITRACE_DEFINE_CATEGORY(category, python, OMNITRACE_CATEGORY_PYTHON, "python", "Python regions") -OMNITRACE_DEFINE_CATEGORY(category, device_hip, OMNITRACE_CATEGORY_DEVICE_HIP, "device_hip", "Device-side functions submitted via HIP API") -OMNITRACE_DEFINE_CATEGORY(category, device_hsa, OMNITRACE_CATEGORY_DEVICE_HSA, "device_hsa", "Device-side functions submitted via HSA API") -OMNITRACE_DEFINE_CATEGORY(category, rocm_hip, OMNITRACE_CATEGORY_ROCM_HIP, "rocm_hip", "Host-side HIP functions") -OMNITRACE_DEFINE_CATEGORY(category, rocm_hsa, OMNITRACE_CATEGORY_ROCM_HSA, "rocm_hsa", "Host-side HSA functions") -OMNITRACE_DEFINE_CATEGORY(category, rocm_roctx, OMNITRACE_CATEGORY_ROCM_ROCTX, "rocm_roctx", "ROCTx labels") -OMNITRACE_DEFINE_CATEGORY(category, rocm_smi, OMNITRACE_CATEGORY_ROCM_SMI, "rocm_smi", "rocm-smi data") -OMNITRACE_DEFINE_CATEGORY(category, rocm_smi_busy, OMNITRACE_CATEGORY_ROCM_SMI_BUSY, "device_busy", "Busy percentage of a GPU device") -OMNITRACE_DEFINE_CATEGORY(category, rocm_smi_temp, OMNITRACE_CATEGORY_ROCM_SMI_TEMP, "device_temp", "Temperature of a GPU device") -OMNITRACE_DEFINE_CATEGORY(category, rocm_smi_power, OMNITRACE_CATEGORY_ROCM_SMI_POWER, "device_power", "Power consumption of a GPU device") -OMNITRACE_DEFINE_CATEGORY(category, rocm_smi_memory_usage, OMNITRACE_CATEGORY_ROCM_SMI_MEMORY_USAGE, "device_memory_usage", "Memory usage of a GPU device") -OMNITRACE_DEFINE_CATEGORY(category, rocm_rccl, OMNITRACE_CATEGORY_ROCM_RCCL, "rccl", "ROCm Communication Collectives Library (RCCL) regions") -OMNITRACE_DEFINE_CATEGORY(category, roctracer, OMNITRACE_CATEGORY_ROCTRACER, "roctracer", "Kernel tracing provided by roctracer") -OMNITRACE_DEFINE_CATEGORY(category, rocprofiler, OMNITRACE_CATEGORY_ROCPROFILER, "rocprofiler", "HW counter data provided by rocprofiler") -OMNITRACE_DEFINE_CATEGORY(category, pthread, OMNITRACE_CATEGORY_PTHREAD, "pthread", "POSIX threading functions") -OMNITRACE_DEFINE_CATEGORY(category, kokkos, OMNITRACE_CATEGORY_KOKKOS, "kokkos", "KokkosTools regions") -OMNITRACE_DEFINE_CATEGORY(category, mpi, OMNITRACE_CATEGORY_MPI, "mpi", "MPI regions") -OMNITRACE_DEFINE_CATEGORY(category, ompt, OMNITRACE_CATEGORY_OMPT, "ompt", "OpenMP tools regions") -OMNITRACE_DEFINE_CATEGORY(category, process_sampling, OMNITRACE_CATEGORY_PROCESS_SAMPLING, "process_sampling", "Process-level data") -OMNITRACE_DEFINE_CATEGORY(category, comm_data, OMNITRACE_CATEGORY_COMM_DATA, "comm_data", "MPI/RCCL counters for tracking amount of data sent or received") -OMNITRACE_DEFINE_CATEGORY(category, causal, OMNITRACE_CATEGORY_CAUSAL, "causal", "Causal profiling data") -OMNITRACE_DEFINE_CATEGORY(category, cpu_freq, OMNITRACE_CATEGORY_CPU_FREQ, "cpu_frequency", "CPU frequency (collected in background thread)") -OMNITRACE_DEFINE_CATEGORY(category, process_page, OMNITRACE_CATEGORY_PROCESS_PAGE, "process_page_fault", "Memory page faults in process (collected in background thread)") -OMNITRACE_DEFINE_CATEGORY(category, process_virt, OMNITRACE_CATEGORY_PROCESS_VIRT, "process_virtual_memory", "Virtual memory usage in process in MB (collected in background thread)") -OMNITRACE_DEFINE_CATEGORY(category, process_peak, OMNITRACE_CATEGORY_PROCESS_PEAK, "process_memory_hwm", "Memory High-Water Mark i.e. peak memory usage (collected in background thread)") -OMNITRACE_DEFINE_CATEGORY(category, process_context_switch, OMNITRACE_CATEGORY_PROCESS_CONTEXT_SWITCH, "process_context_switch", "Context switches in process (collected in background thread)") -OMNITRACE_DEFINE_CATEGORY(category, process_page_fault, OMNITRACE_CATEGORY_PROCESS_PAGE_FAULT, "process_page_fault", "Memory page faults in process (collected in background thread)") -OMNITRACE_DEFINE_CATEGORY(category, process_user_mode_time, OMNITRACE_CATEGORY_PROCESS_USER_MODE_TIME, "process_user_cpu_time", "CPU time of functions executing in user-space in process in seconds (collected in background thread)") -OMNITRACE_DEFINE_CATEGORY(category, process_kernel_mode_time, OMNITRACE_CATEGORY_PROCESS_KERNEL_MODE_TIME, "process_kernel_cpu_time", "CPU time of functions executing in kernel-space in process in seconds (collected in background thread)") -OMNITRACE_DEFINE_CATEGORY(category, thread_wall_time, OMNITRACE_CATEGORY_THREAD_WALL_TIME, "thread_wall_time", "Wall-clock time on thread (derived from sampling)") -OMNITRACE_DEFINE_CATEGORY(category, thread_cpu_time, OMNITRACE_CATEGORY_THREAD_CPU_TIME, "thread_cpu_time", "CPU time on thread (derived from sampling)") -OMNITRACE_DEFINE_CATEGORY(category, thread_page_fault, OMNITRACE_CATEGORY_THREAD_PAGE_FAULT, "thread_page_fault", "Memory page faults on thread (derived from sampling)") -OMNITRACE_DEFINE_CATEGORY(category, thread_peak_memory, OMNITRACE_CATEGORY_THREAD_PEAK_MEMORY, "thread_peak_memory", "Peak memory usage on thread in MB (derived from sampling)") -OMNITRACE_DEFINE_CATEGORY(category, thread_context_switch, OMNITRACE_CATEGORY_THREAD_CONTEXT_SWITCH, "thread_context_switch", "Context switches on thread (derived from sampling)") -OMNITRACE_DEFINE_CATEGORY(category, thread_hardware_counter, OMNITRACE_CATEGORY_THREAD_HARDWARE_COUNTER, "thread_hardware_counter", "Hardware counter value on thread (derived from sampling)") -OMNITRACE_DEFINE_CATEGORY(category, kernel_hardware_counter, OMNITRACE_CATEGORY_KERNEL_HARDWARE_COUNTER, "kernel_hardware_counter", "Hardware counter value for kernel (deterministic)") -OMNITRACE_DEFINE_CATEGORY(category, numa, OMNITRACE_CATEGORY_NUMA, "numa", "Non-unified memory architecture") -OMNITRACE_DEFINE_CATEGORY(category, timer_sampling, OMNITRACE_CATEGORY_TIMER_SAMPLING, "timer_sampling", "Sampling based on a timer") -OMNITRACE_DEFINE_CATEGORY(category, overflow_sampling, OMNITRACE_CATEGORY_OVERFLOW_SAMPLING, "overflow_sampling", "Sampling based on a counter overflow") - -OMNITRACE_DECLARE_CATEGORY(category, sampling, OMNITRACE_CATEGORY_SAMPLING, "sampling", "Host-side call-stack sampling") +// these are defined by rocprofsys +ROCPROFSYS_DEFINE_CATEGORY(project, rocprofsys, ROCPROFSYS_CATEGORY_NONE, "rocprofsys", "ROCm Systems Profiler project") +ROCPROFSYS_DEFINE_CATEGORY(category, host, ROCPROFSYS_CATEGORY_HOST, "host", "Host-side function tracing") +ROCPROFSYS_DEFINE_CATEGORY(category, user, ROCPROFSYS_CATEGORY_USER, "user", "User-defined regions") +ROCPROFSYS_DEFINE_CATEGORY(category, python, ROCPROFSYS_CATEGORY_PYTHON, "python", "Python regions") +ROCPROFSYS_DEFINE_CATEGORY(category, device_hip, ROCPROFSYS_CATEGORY_DEVICE_HIP, "device_hip", "Device-side functions submitted via HIP API") +ROCPROFSYS_DEFINE_CATEGORY(category, device_hsa, ROCPROFSYS_CATEGORY_DEVICE_HSA, "device_hsa", "Device-side functions submitted via HSA API") +ROCPROFSYS_DEFINE_CATEGORY(category, rocm_hip, ROCPROFSYS_CATEGORY_ROCM_HIP, "rocm_hip", "Host-side HIP functions") +ROCPROFSYS_DEFINE_CATEGORY(category, rocm_hsa, ROCPROFSYS_CATEGORY_ROCM_HSA, "rocm_hsa", "Host-side HSA functions") +ROCPROFSYS_DEFINE_CATEGORY(category, rocm_roctx, ROCPROFSYS_CATEGORY_ROCM_ROCTX, "rocm_roctx", "ROCTx labels") +ROCPROFSYS_DEFINE_CATEGORY(category, rocm_smi, ROCPROFSYS_CATEGORY_ROCM_SMI, "rocm_smi", "rocm-smi data") +ROCPROFSYS_DEFINE_CATEGORY(category, rocm_smi_busy, ROCPROFSYS_CATEGORY_ROCM_SMI_BUSY, "device_busy", "Busy percentage of a GPU device") +ROCPROFSYS_DEFINE_CATEGORY(category, rocm_smi_temp, ROCPROFSYS_CATEGORY_ROCM_SMI_TEMP, "device_temp", "Temperature of a GPU device") +ROCPROFSYS_DEFINE_CATEGORY(category, rocm_smi_power, ROCPROFSYS_CATEGORY_ROCM_SMI_POWER, "device_power", "Power consumption of a GPU device") +ROCPROFSYS_DEFINE_CATEGORY(category, rocm_smi_memory_usage, ROCPROFSYS_CATEGORY_ROCM_SMI_MEMORY_USAGE, "device_memory_usage", "Memory usage of a GPU device") +ROCPROFSYS_DEFINE_CATEGORY(category, rocm_rccl, ROCPROFSYS_CATEGORY_ROCM_RCCL, "rccl", "ROCm Communication Collectives Library (RCCL) regions") +ROCPROFSYS_DEFINE_CATEGORY(category, roctracer, ROCPROFSYS_CATEGORY_ROCTRACER, "roctracer", "Kernel tracing provided by roctracer") +ROCPROFSYS_DEFINE_CATEGORY(category, rocprofiler, ROCPROFSYS_CATEGORY_ROCPROFILER, "rocprofiler", "HW counter data provided by rocprofiler") +ROCPROFSYS_DEFINE_CATEGORY(category, pthread, ROCPROFSYS_CATEGORY_PTHREAD, "pthread", "POSIX threading functions") +ROCPROFSYS_DEFINE_CATEGORY(category, kokkos, ROCPROFSYS_CATEGORY_KOKKOS, "kokkos", "KokkosTools regions") +ROCPROFSYS_DEFINE_CATEGORY(category, mpi, ROCPROFSYS_CATEGORY_MPI, "mpi", "MPI regions") +ROCPROFSYS_DEFINE_CATEGORY(category, ompt, ROCPROFSYS_CATEGORY_OMPT, "ompt", "OpenMP tools regions") +ROCPROFSYS_DEFINE_CATEGORY(category, process_sampling, ROCPROFSYS_CATEGORY_PROCESS_SAMPLING, "process_sampling", "Process-level data") +ROCPROFSYS_DEFINE_CATEGORY(category, comm_data, ROCPROFSYS_CATEGORY_COMM_DATA, "comm_data", "MPI/RCCL counters for tracking amount of data sent or received") +ROCPROFSYS_DEFINE_CATEGORY(category, causal, ROCPROFSYS_CATEGORY_CAUSAL, "causal", "Causal profiling data") +ROCPROFSYS_DEFINE_CATEGORY(category, cpu_freq, ROCPROFSYS_CATEGORY_CPU_FREQ, "cpu_frequency", "CPU frequency (collected in background thread)") +ROCPROFSYS_DEFINE_CATEGORY(category, process_page, ROCPROFSYS_CATEGORY_PROCESS_PAGE, "process_page_fault", "Memory page faults in process (collected in background thread)") +ROCPROFSYS_DEFINE_CATEGORY(category, process_virt, ROCPROFSYS_CATEGORY_PROCESS_VIRT, "process_virtual_memory", "Virtual memory usage in process in MB (collected in background thread)") +ROCPROFSYS_DEFINE_CATEGORY(category, process_peak, ROCPROFSYS_CATEGORY_PROCESS_PEAK, "process_memory_hwm", "Memory High-Water Mark i.e. peak memory usage (collected in background thread)") +ROCPROFSYS_DEFINE_CATEGORY(category, process_context_switch, ROCPROFSYS_CATEGORY_PROCESS_CONTEXT_SWITCH, "process_context_switch", "Context switches in process (collected in background thread)") +ROCPROFSYS_DEFINE_CATEGORY(category, process_page_fault, ROCPROFSYS_CATEGORY_PROCESS_PAGE_FAULT, "process_page_fault", "Memory page faults in process (collected in background thread)") +ROCPROFSYS_DEFINE_CATEGORY(category, process_user_mode_time, ROCPROFSYS_CATEGORY_PROCESS_USER_MODE_TIME, "process_user_cpu_time", "CPU time of functions executing in user-space in process in seconds (collected in background thread)") +ROCPROFSYS_DEFINE_CATEGORY(category, process_kernel_mode_time, ROCPROFSYS_CATEGORY_PROCESS_KERNEL_MODE_TIME, "process_kernel_cpu_time", "CPU time of functions executing in kernel-space in process in seconds (collected in background thread)") +ROCPROFSYS_DEFINE_CATEGORY(category, thread_wall_time, ROCPROFSYS_CATEGORY_THREAD_WALL_TIME, "thread_wall_time", "Wall-clock time on thread (derived from sampling)") +ROCPROFSYS_DEFINE_CATEGORY(category, thread_cpu_time, ROCPROFSYS_CATEGORY_THREAD_CPU_TIME, "thread_cpu_time", "CPU time on thread (derived from sampling)") +ROCPROFSYS_DEFINE_CATEGORY(category, thread_page_fault, ROCPROFSYS_CATEGORY_THREAD_PAGE_FAULT, "thread_page_fault", "Memory page faults on thread (derived from sampling)") +ROCPROFSYS_DEFINE_CATEGORY(category, thread_peak_memory, ROCPROFSYS_CATEGORY_THREAD_PEAK_MEMORY, "thread_peak_memory", "Peak memory usage on thread in MB (derived from sampling)") +ROCPROFSYS_DEFINE_CATEGORY(category, thread_context_switch, ROCPROFSYS_CATEGORY_THREAD_CONTEXT_SWITCH, "thread_context_switch", "Context switches on thread (derived from sampling)") +ROCPROFSYS_DEFINE_CATEGORY(category, thread_hardware_counter, ROCPROFSYS_CATEGORY_THREAD_HARDWARE_COUNTER, "thread_hardware_counter", "Hardware counter value on thread (derived from sampling)") +ROCPROFSYS_DEFINE_CATEGORY(category, kernel_hardware_counter, ROCPROFSYS_CATEGORY_KERNEL_HARDWARE_COUNTER, "kernel_hardware_counter", "Hardware counter value for kernel (deterministic)") +ROCPROFSYS_DEFINE_CATEGORY(category, numa, ROCPROFSYS_CATEGORY_NUMA, "numa", "Non-unified memory architecture") +ROCPROFSYS_DEFINE_CATEGORY(category, timer_sampling, ROCPROFSYS_CATEGORY_TIMER_SAMPLING, "timer_sampling", "Sampling based on a timer") +ROCPROFSYS_DEFINE_CATEGORY(category, overflow_sampling, ROCPROFSYS_CATEGORY_OVERFLOW_SAMPLING, "overflow_sampling", "Sampling based on a counter overflow") + +ROCPROFSYS_DECLARE_CATEGORY(category, sampling, ROCPROFSYS_CATEGORY_SAMPLING, "sampling", "Host-side call-stack sampling") // clang-format on namespace tim @@ -142,64 +142,64 @@ using name = perfetto_category; } } // namespace tim -#define OMNITRACE_PERFETTO_CATEGORY(TYPE) \ +#define ROCPROFSYS_PERFETTO_CATEGORY(TYPE) \ ::perfetto::Category(::tim::trait::perfetto_category<::tim::TYPE>::value) \ .SetDescription(::tim::trait::perfetto_category<::tim::TYPE>::description) -#define OMNITRACE_PERFETTO_CATEGORIES \ - OMNITRACE_PERFETTO_CATEGORY(category::host), \ - OMNITRACE_PERFETTO_CATEGORY(category::user), \ - OMNITRACE_PERFETTO_CATEGORY(category::python), \ - OMNITRACE_PERFETTO_CATEGORY(category::sampling), \ - OMNITRACE_PERFETTO_CATEGORY(category::device_hip), \ - OMNITRACE_PERFETTO_CATEGORY(category::device_hsa), \ - OMNITRACE_PERFETTO_CATEGORY(category::rocm_hip), \ - OMNITRACE_PERFETTO_CATEGORY(category::rocm_hsa), \ - OMNITRACE_PERFETTO_CATEGORY(category::rocm_roctx), \ - OMNITRACE_PERFETTO_CATEGORY(category::rocm_smi), \ - OMNITRACE_PERFETTO_CATEGORY(category::rocm_smi_busy), \ - OMNITRACE_PERFETTO_CATEGORY(category::rocm_smi_temp), \ - OMNITRACE_PERFETTO_CATEGORY(category::rocm_smi_power), \ - OMNITRACE_PERFETTO_CATEGORY(category::rocm_smi_memory_usage), \ - OMNITRACE_PERFETTO_CATEGORY(category::rocm_rccl), \ - OMNITRACE_PERFETTO_CATEGORY(category::roctracer), \ - OMNITRACE_PERFETTO_CATEGORY(category::rocprofiler), \ - OMNITRACE_PERFETTO_CATEGORY(category::pthread), \ - OMNITRACE_PERFETTO_CATEGORY(category::kokkos), \ - OMNITRACE_PERFETTO_CATEGORY(category::mpi), \ - OMNITRACE_PERFETTO_CATEGORY(category::ompt), \ - OMNITRACE_PERFETTO_CATEGORY(category::sampling), \ - OMNITRACE_PERFETTO_CATEGORY(category::process_sampling), \ - OMNITRACE_PERFETTO_CATEGORY(category::comm_data), \ - OMNITRACE_PERFETTO_CATEGORY(category::causal), \ - OMNITRACE_PERFETTO_CATEGORY(category::cpu_freq), \ - OMNITRACE_PERFETTO_CATEGORY(category::process_page), \ - OMNITRACE_PERFETTO_CATEGORY(category::process_virt), \ - OMNITRACE_PERFETTO_CATEGORY(category::process_peak), \ - OMNITRACE_PERFETTO_CATEGORY(category::process_context_switch), \ - OMNITRACE_PERFETTO_CATEGORY(category::process_page_fault), \ - OMNITRACE_PERFETTO_CATEGORY(category::process_user_mode_time), \ - OMNITRACE_PERFETTO_CATEGORY(category::process_kernel_mode_time), \ - OMNITRACE_PERFETTO_CATEGORY(category::thread_wall_time), \ - OMNITRACE_PERFETTO_CATEGORY(category::thread_cpu_time), \ - OMNITRACE_PERFETTO_CATEGORY(category::thread_page_fault), \ - OMNITRACE_PERFETTO_CATEGORY(category::thread_peak_memory), \ - OMNITRACE_PERFETTO_CATEGORY(category::thread_context_switch), \ - OMNITRACE_PERFETTO_CATEGORY(category::thread_hardware_counter), \ - OMNITRACE_PERFETTO_CATEGORY(category::kernel_hardware_counter), \ - OMNITRACE_PERFETTO_CATEGORY(category::numa), \ - OMNITRACE_PERFETTO_CATEGORY(category::timer_sampling), \ - OMNITRACE_PERFETTO_CATEGORY(category::overflow_sampling), \ +#define ROCPROFSYS_PERFETTO_CATEGORIES \ + ROCPROFSYS_PERFETTO_CATEGORY(category::host), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::user), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::python), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::sampling), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::device_hip), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::device_hsa), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_hip), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_hsa), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_roctx), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_smi), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_smi_busy), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_smi_temp), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_smi_power), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_smi_memory_usage), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::rocm_rccl), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::roctracer), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::rocprofiler), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::pthread), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::kokkos), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::mpi), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::ompt), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::sampling), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::process_sampling), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::comm_data), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::causal), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::cpu_freq), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::process_page), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::process_virt), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::process_peak), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::process_context_switch), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::process_page_fault), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::process_user_mode_time), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::process_kernel_mode_time), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::thread_wall_time), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::thread_cpu_time), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::thread_page_fault), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::thread_peak_memory), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::thread_context_switch), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::thread_hardware_counter), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::kernel_hardware_counter), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::numa), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::timer_sampling), \ + ROCPROFSYS_PERFETTO_CATEGORY(category::overflow_sampling), \ ::perfetto::Category("timemory").SetDescription("Events from the timemory API") #if defined(TIMEMORY_USE_PERFETTO) -# define TIMEMORY_PERFETTO_CATEGORIES OMNITRACE_PERFETTO_CATEGORIES +# define TIMEMORY_PERFETTO_CATEGORIES ROCPROFSYS_PERFETTO_CATEGORIES #endif #include #include -namespace omnitrace +namespace rocprofsys { inline namespace config { @@ -224,4 +224,4 @@ setup(); void shutdown(); } // namespace categories -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/common.hpp b/source/lib/core/common.hpp index 740991a6..5a0ad09a 100644 --- a/source/lib/core/common.hpp +++ b/source/lib/core/common.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -50,8 +50,8 @@ #include #include -#define OMNITRACE_DECLARE_COMPONENT(NAME) \ - namespace omnitrace \ +#define ROCPROFSYS_DECLARE_COMPONENT(NAME) \ + namespace rocprofsys \ { \ namespace component \ { \ @@ -63,7 +63,7 @@ namespace trait \ { \ template <> \ - struct is_component : true_type \ + struct is_component : true_type \ {}; \ } \ } \ @@ -71,12 +71,12 @@ { \ namespace component \ { \ - using ::omnitrace::component::NAME; \ + using ::rocprofsys::component::NAME; \ } \ } -#define OMNITRACE_COMPONENT_ALIAS(NAME, ...) \ - namespace omnitrace \ +#define ROCPROFSYS_COMPONENT_ALIAS(NAME, ...) \ + namespace rocprofsys \ { \ namespace component \ { \ @@ -87,22 +87,22 @@ { \ namespace component \ { \ - using ::omnitrace::component::NAME; \ + using ::rocprofsys::component::NAME; \ } \ } -#define OMNITRACE_DEFINE_CONCRETE_TRAIT(TRAIT, TYPE, VALUE) \ +#define ROCPROFSYS_DEFINE_CONCRETE_TRAIT(TRAIT, TYPE, VALUE) \ namespace tim \ { \ namespace trait \ { \ template <> \ - struct TRAIT<::omnitrace::TYPE> : VALUE \ + struct TRAIT<::rocprofsys::TYPE> : VALUE \ {}; \ } \ } -namespace omnitrace +namespace rocprofsys { namespace api = ::tim::api; // NOLINT namespace category = ::tim::category; // NOLINT @@ -126,9 +126,9 @@ struct construct_on_thread { int64_t index = threading::get_id(); }; -} // namespace omnitrace +} // namespace rocprofsys // same sort of functionality as python's " ".join([...]) #if !defined(JOIN) -# define JOIN(...) ::omnitrace::common::join(__VA_ARGS__) +# define JOIN(...) ::rocprofsys::common::join(__VA_ARGS__) #endif diff --git a/source/lib/core/components/CMakeLists.txt b/source/lib/core/components/CMakeLists.txt index 52774a7c..2580b9cd 100644 --- a/source/lib/core/components/CMakeLists.txt +++ b/source/lib/core/components/CMakeLists.txt @@ -3,4 +3,5 @@ set(component_sources) set(component_headers ${CMAKE_CURRENT_LIST_DIR}/fwd.hpp) -target_sources(omnitrace-core-library PRIVATE ${component_sources} ${component_headers}) +target_sources(rocprofiler-systems-core-library PRIVATE ${component_sources} + ${component_headers}) diff --git a/source/lib/core/components/fwd.hpp b/source/lib/core/components/fwd.hpp index aff7788b..b5726086 100644 --- a/source/lib/core/components/fwd.hpp +++ b/source/lib/core/components/fwd.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -39,15 +39,15 @@ #include -OMNITRACE_DECLARE_COMPONENT(roctracer) -OMNITRACE_DECLARE_COMPONENT(rocprofiler) -OMNITRACE_DECLARE_COMPONENT(rcclp_handle) -OMNITRACE_DECLARE_COMPONENT(comm_data) +ROCPROFSYS_DECLARE_COMPONENT(roctracer) +ROCPROFSYS_DECLARE_COMPONENT(rocprofiler) +ROCPROFSYS_DECLARE_COMPONENT(rcclp_handle) +ROCPROFSYS_DECLARE_COMPONENT(comm_data) -OMNITRACE_COMPONENT_ALIAS(comm_data_tracker_t, - ::tim::component::data_tracker) +ROCPROFSYS_COMPONENT_ALIAS(comm_data_tracker_t, + ::tim::component::data_tracker) -namespace omnitrace +namespace rocprofsys { namespace policy = ::tim::policy; // NOLINT namespace comp = ::tim::component; // NOLINT @@ -94,161 +94,162 @@ template struct functors; } // namespace component -} // namespace omnitrace +} // namespace rocprofsys -#if !defined(OMNITRACE_USE_ROCTRACER) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_available, component::roctracer, false_type) +#if !defined(ROCPROFSYS_USE_ROCTRACER) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::roctracer, false_type) #endif -#if !defined(OMNITRACE_USE_ROCPROFILER) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_available, component::rocprofiler, false_type) +#if !defined(ROCPROFSYS_USE_ROCPROFILER) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::rocprofiler, false_type) #endif -#if !defined(OMNITRACE_USE_RCCL) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_available, category::rocm_rccl, false_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_available, component::rcclp_handle, false_type) +#if !defined(ROCPROFSYS_USE_RCCL) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, category::rocm_rccl, false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::rcclp_handle, false_type) #endif -#if !defined(OMNITRACE_USE_RCCL) && !defined(OMNITRACE_USE_MPI) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_available, component::comm_data_tracker_t, false_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_available, component::comm_data, false_type) +#if !defined(ROCPROFSYS_USE_RCCL) && !defined(ROCPROFSYS_USE_MPI) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::comm_data_tracker_t, false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::comm_data, false_type) #endif #if !defined(TIMEMORY_USE_LIBUNWIND) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_available, category::sampling, false_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_available, component::backtrace, false_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_available, component::backtrace_metrics, false_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_available, component::backtrace_timestamp, false_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_available, component::sampling_wall_clock, false_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_available, component::sampling_cpu_clock, false_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_available, component::sampling_percent, false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, category::sampling, false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::backtrace, false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::backtrace_metrics, false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::backtrace_timestamp, false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::sampling_wall_clock, false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::sampling_cpu_clock, false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::sampling_percent, false_type) #endif -#if !defined(TIMEMORY_USE_LIBUNWIND) || !defined(OMNITRACE_USE_ROCM_SMI) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_available, component::sampling_gpu_busy, false_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_available, component::sampling_gpu_temp, false_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_available, component::sampling_gpu_power, false_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_available, component::sampling_gpu_memory, false_type) +#if !defined(TIMEMORY_USE_LIBUNWIND) || !defined(ROCPROFSYS_USE_ROCM_SMI) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::sampling_gpu_busy, false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::sampling_gpu_temp, false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::sampling_gpu_power, false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::sampling_gpu_memory, false_type) #endif -TIMEMORY_SET_COMPONENT_API(omnitrace::component::roctracer, project::omnitrace, +TIMEMORY_SET_COMPONENT_API(rocprofsys::component::roctracer, project::rocprofsys, tpls::rocm, device::gpu, os::supports_linux, category::external) -TIMEMORY_SET_COMPONENT_API(omnitrace::component::rocprofiler, project::omnitrace, +TIMEMORY_SET_COMPONENT_API(rocprofsys::component::rocprofiler, project::rocprofsys, tpls::rocm, device::gpu, os::supports_linux, category::external, category::hardware_counter) -TIMEMORY_SET_COMPONENT_API(omnitrace::component::sampling_wall_clock, project::omnitrace, +TIMEMORY_SET_COMPONENT_API(rocprofsys::component::sampling_wall_clock, + project::rocprofsys, category::timing, os::supports_unix, + category::sampling, category::interrupt_sampling) +TIMEMORY_SET_COMPONENT_API(rocprofsys::component::sampling_cpu_clock, project::rocprofsys, category::timing, os::supports_unix, category::sampling, category::interrupt_sampling) -TIMEMORY_SET_COMPONENT_API(omnitrace::component::sampling_cpu_clock, project::omnitrace, +TIMEMORY_SET_COMPONENT_API(rocprofsys::component::sampling_percent, project::rocprofsys, category::timing, os::supports_unix, category::sampling, category::interrupt_sampling) -TIMEMORY_SET_COMPONENT_API(omnitrace::component::sampling_percent, project::omnitrace, - category::timing, os::supports_unix, category::sampling, - category::interrupt_sampling) -TIMEMORY_SET_COMPONENT_API(omnitrace::component::sampling_gpu_busy, project::omnitrace, +TIMEMORY_SET_COMPONENT_API(rocprofsys::component::sampling_gpu_busy, project::rocprofsys, tpls::rocm, device::gpu, os::supports_linux, category::sampling, category::process_sampling) -TIMEMORY_SET_COMPONENT_API(omnitrace::component::sampling_gpu_memory, project::omnitrace, - tpls::rocm, device::gpu, os::supports_linux, category::memory, - category::sampling, category::process_sampling) -TIMEMORY_SET_COMPONENT_API(omnitrace::component::sampling_gpu_power, project::omnitrace, +TIMEMORY_SET_COMPONENT_API(rocprofsys::component::sampling_gpu_memory, + project::rocprofsys, tpls::rocm, device::gpu, + os::supports_linux, category::memory, category::sampling, + category::process_sampling) +TIMEMORY_SET_COMPONENT_API(rocprofsys::component::sampling_gpu_power, project::rocprofsys, tpls::rocm, device::gpu, os::supports_linux, category::power, category::sampling, category::process_sampling) -TIMEMORY_SET_COMPONENT_API(omnitrace::component::sampling_gpu_temp, project::omnitrace, +TIMEMORY_SET_COMPONENT_API(rocprofsys::component::sampling_gpu_temp, project::rocprofsys, tpls::rocm, device::gpu, os::supports_linux, category::temperature, category::sampling, category::process_sampling) -TIMEMORY_METADATA_SPECIALIZATION(omnitrace::component::roctracer, "roctracer", +TIMEMORY_METADATA_SPECIALIZATION(rocprofsys::component::roctracer, "roctracer", "High-precision ROCm API and kernel tracing", "") -TIMEMORY_METADATA_SPECIALIZATION(omnitrace::component::rocprofiler, "rocprofiler", +TIMEMORY_METADATA_SPECIALIZATION(rocprofsys::component::rocprofiler, "rocprofiler", "ROCm kernel hardware counters", "") -TIMEMORY_METADATA_SPECIALIZATION(omnitrace::component::sampling_wall_clock, +TIMEMORY_METADATA_SPECIALIZATION(rocprofsys::component::sampling_wall_clock, "sampling_wall_clock", "Wall-clock timing", "Derived from statistical sampling") -TIMEMORY_METADATA_SPECIALIZATION(omnitrace::component::sampling_cpu_clock, +TIMEMORY_METADATA_SPECIALIZATION(rocprofsys::component::sampling_cpu_clock, "sampling_cpu_clock", "CPU-clock timing", "Derived from statistical sampling") -TIMEMORY_METADATA_SPECIALIZATION(omnitrace::component::sampling_percent, +TIMEMORY_METADATA_SPECIALIZATION(rocprofsys::component::sampling_percent, "sampling_percent", "Fraction of wall-clock time spent in functions", "Derived from statistical sampling") -TIMEMORY_METADATA_SPECIALIZATION(omnitrace::component::sampling_gpu_busy, +TIMEMORY_METADATA_SPECIALIZATION(rocprofsys::component::sampling_gpu_busy, "sampling_gpu_busy", "GPU Utilization (% busy) via ROCm-SMI", "Derived from sampling") -TIMEMORY_METADATA_SPECIALIZATION(omnitrace::component::sampling_gpu_memory, +TIMEMORY_METADATA_SPECIALIZATION(rocprofsys::component::sampling_gpu_memory, "sampling_gpu_memory_usage", "GPU Memory Usage via ROCm-SMI", "Derived from sampling") -TIMEMORY_METADATA_SPECIALIZATION(omnitrace::component::sampling_gpu_power, +TIMEMORY_METADATA_SPECIALIZATION(rocprofsys::component::sampling_gpu_power, "sampling_gpu_power", "GPU Power Usage via ROCm-SMI", "Derived from sampling") -TIMEMORY_METADATA_SPECIALIZATION(omnitrace::component::sampling_gpu_temp, +TIMEMORY_METADATA_SPECIALIZATION(rocprofsys::component::sampling_gpu_temp, "sampling_gpu_temp", "GPU Temperature via ROCm-SMI", "Derived from sampling") // statistics type -TIMEMORY_STATISTICS_TYPE(omnitrace::component::sampling_wall_clock, double) -TIMEMORY_STATISTICS_TYPE(omnitrace::component::sampling_cpu_clock, double) -TIMEMORY_STATISTICS_TYPE(omnitrace::component::sampling_gpu_busy, double) -TIMEMORY_STATISTICS_TYPE(omnitrace::component::sampling_gpu_temp, double) -TIMEMORY_STATISTICS_TYPE(omnitrace::component::sampling_gpu_power, double) -TIMEMORY_STATISTICS_TYPE(omnitrace::component::sampling_gpu_memory, double) -TIMEMORY_STATISTICS_TYPE(omnitrace::component::comm_data_tracker_t, float) +TIMEMORY_STATISTICS_TYPE(rocprofsys::component::sampling_wall_clock, double) +TIMEMORY_STATISTICS_TYPE(rocprofsys::component::sampling_cpu_clock, double) +TIMEMORY_STATISTICS_TYPE(rocprofsys::component::sampling_gpu_busy, double) +TIMEMORY_STATISTICS_TYPE(rocprofsys::component::sampling_gpu_temp, double) +TIMEMORY_STATISTICS_TYPE(rocprofsys::component::sampling_gpu_power, double) +TIMEMORY_STATISTICS_TYPE(rocprofsys::component::sampling_gpu_memory, double) +TIMEMORY_STATISTICS_TYPE(rocprofsys::component::comm_data_tracker_t, float) // enable timing units -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_timing_category, component::sampling_wall_clock, - true_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_timing_category, component::sampling_cpu_clock, - true_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_timing_category, component::sampling_percent, - true_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(uses_timing_units, component::sampling_wall_clock, - true_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(uses_timing_units, component::sampling_cpu_clock, - true_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_timing_category, component::sampling_wall_clock, + true_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_timing_category, component::sampling_cpu_clock, + true_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_timing_category, component::sampling_percent, + true_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(uses_timing_units, component::sampling_wall_clock, + true_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(uses_timing_units, component::sampling_cpu_clock, + true_type) // enable percent units -OMNITRACE_DEFINE_CONCRETE_TRAIT(uses_percent_units, component::sampling_gpu_busy, - true_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(uses_percent_units, component::sampling_percent, - true_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(uses_percent_units, component::sampling_gpu_busy, + true_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(uses_percent_units, component::sampling_percent, + true_type) // enable memory units -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_memory_category, component::sampling_gpu_memory, - true_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(uses_memory_units, component::sampling_gpu_memory, - true_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_memory_category, component::sampling_gpu_memory, + true_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(uses_memory_units, component::sampling_gpu_memory, + true_type) // reporting categories (sum) -OMNITRACE_DEFINE_CONCRETE_TRAIT(report_sum, component::sampling_gpu_busy, false_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(report_sum, component::sampling_gpu_temp, false_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(report_sum, component::sampling_gpu_power, false_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(report_sum, component::sampling_gpu_memory, false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(report_sum, component::sampling_gpu_busy, false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(report_sum, component::sampling_gpu_temp, false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(report_sum, component::sampling_gpu_power, false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(report_sum, component::sampling_gpu_memory, false_type) // reporting categories (mean) -OMNITRACE_DEFINE_CONCRETE_TRAIT(report_mean, component::sampling_percent, false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(report_mean, component::sampling_percent, false_type) // reporting categories (stats) -OMNITRACE_DEFINE_CONCRETE_TRAIT(report_statistics, component::sampling_percent, - false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(report_statistics, component::sampling_percent, + false_type) // reporting categories (self) -OMNITRACE_DEFINE_CONCRETE_TRAIT(report_self, component::sampling_percent, false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(report_self, component::sampling_percent, false_type) -#define OMNITRACE_DECLARE_EXTERN_COMPONENT(NAME, HAS_DATA, ...) \ +#define ROCPROFSYS_DECLARE_EXTERN_COMPONENT(NAME, HAS_DATA, ...) \ TIMEMORY_DECLARE_EXTERN_TEMPLATE( \ - struct tim::component::base) \ - TIMEMORY_DECLARE_EXTERN_OPERATIONS(TIMEMORY_ESC(omnitrace::component::NAME), \ + TIMEMORY_DECLARE_EXTERN_OPERATIONS(TIMEMORY_ESC(rocprofsys::component::NAME), \ HAS_DATA) \ - TIMEMORY_DECLARE_EXTERN_STORAGE(TIMEMORY_ESC(omnitrace::component::NAME)) + TIMEMORY_DECLARE_EXTERN_STORAGE(TIMEMORY_ESC(rocprofsys::component::NAME)) -#define OMNITRACE_INSTANTIATE_EXTERN_COMPONENT(NAME, HAS_DATA, ...) \ +#define ROCPROFSYS_INSTANTIATE_EXTERN_COMPONENT(NAME, HAS_DATA, ...) \ TIMEMORY_INSTANTIATE_EXTERN_TEMPLATE( \ - struct tim::component::base) \ - TIMEMORY_INSTANTIATE_EXTERN_OPERATIONS(TIMEMORY_ESC(omnitrace::component::NAME), \ + TIMEMORY_INSTANTIATE_EXTERN_OPERATIONS(TIMEMORY_ESC(rocprofsys::component::NAME), \ HAS_DATA) \ - TIMEMORY_INSTANTIATE_EXTERN_STORAGE(TIMEMORY_ESC(omnitrace::component::NAME)) + TIMEMORY_INSTANTIATE_EXTERN_STORAGE(TIMEMORY_ESC(rocprofsys::component::NAME)) diff --git a/source/lib/core/concepts.hpp b/source/lib/core/concepts.hpp index 8b40046f..1164a99c 100644 --- a/source/lib/core/concepts.hpp +++ b/source/lib/core/concepts.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -31,16 +31,16 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace concepts = ::tim::concepts; // NOLINT -static constexpr size_t max_supported_threads = OMNITRACE_MAX_THREADS; +static constexpr size_t max_supported_threads = ROCPROFSYS_MAX_THREADS; template struct thread_deleter; -// unique ptr type for omnitrace +// unique ptr type for rocprof-sys template using unique_ptr_t = std::unique_ptr>; @@ -59,7 +59,7 @@ make_unique(Args&&... args) { return unique_ptr_t{ new Tp{ std::forward(args)... } }; } -} // namespace omnitrace +} // namespace rocprofsys namespace tim { @@ -70,7 +70,7 @@ struct is_unique_pointer : std::false_type {}; template -struct is_unique_pointer<::omnitrace::unique_ptr_t> : std::true_type +struct is_unique_pointer<::rocprofsys::unique_ptr_t> : std::true_type {}; template diff --git a/source/lib/core/config.cpp b/source/lib/core/config.cpp index d7bb5d95..c519dfd7 100644 --- a/source/lib/core/config.cpp +++ b/source/lib/core/config.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -70,7 +70,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { using settings = tim::settings; @@ -97,7 +97,7 @@ get_config() std::string get_setting_name(std::string _v) { - static const auto _prefix = tim::string_view_t{ "omnitrace_" }; + static const auto _prefix = tim::string_view_t{ "rocprofsys_" }; for(auto& itr : _v) itr = tolower(itr); auto _pos = _v.find(_prefix); @@ -110,53 +110,54 @@ Tp get_available_categories() { auto _v = Tp{}; - for(auto itr : { OMNITRACE_PERFETTO_CATEGORIES }) + for(auto itr : { ROCPROFSYS_PERFETTO_CATEGORIES }) tim::utility::emplace(_v, itr.name); return _v; } using utility::parse_numeric_range; -#define OMNITRACE_CONFIG_SETTING(TYPE, ENV_NAME, DESCRIPTION, INITIAL_VALUE, ...) \ +#define ROCPROFSYS_CONFIG_SETTING(TYPE, ENV_NAME, DESCRIPTION, INITIAL_VALUE, ...) \ [&]() { \ auto _ret = _config->insert( \ ENV_NAME, get_setting_name(ENV_NAME), DESCRIPTION, TYPE{ INITIAL_VALUE }, \ - std::set{ "custom", "omnitrace", "libomnitrace", \ + std::set{ "custom", "rocprofsys", "librocprof-sys", \ __VA_ARGS__ }); \ if(!_ret.second) \ { \ - OMNITRACE_PRINT("Warning! Duplicate setting: %s / %s\n", \ - get_setting_name(ENV_NAME).c_str(), ENV_NAME); \ + ROCPROFSYS_PRINT("Warning! Duplicate setting: %s / %s\n", \ + get_setting_name(ENV_NAME).c_str(), ENV_NAME); \ } \ return _config->find(ENV_NAME)->second; \ }() -// below does not include "libomnitrace" -#define OMNITRACE_CONFIG_EXT_SETTING(TYPE, ENV_NAME, DESCRIPTION, INITIAL_VALUE, ...) \ +// below does not include "librocprof-sys" +#define ROCPROFSYS_CONFIG_EXT_SETTING(TYPE, ENV_NAME, DESCRIPTION, INITIAL_VALUE, ...) \ [&]() { \ auto _ret = _config->insert( \ ENV_NAME, get_setting_name(ENV_NAME), DESCRIPTION, TYPE{ INITIAL_VALUE }, \ - std::set{ "custom", "omnitrace", __VA_ARGS__ }); \ + std::set{ "custom", "rocprofsys", __VA_ARGS__ }); \ if(!_ret.second) \ { \ - OMNITRACE_PRINT("Warning! Duplicate setting: %s / %s\n", \ - get_setting_name(ENV_NAME).c_str(), ENV_NAME); \ + ROCPROFSYS_PRINT("Warning! Duplicate setting: %s / %s\n", \ + get_setting_name(ENV_NAME).c_str(), ENV_NAME); \ } \ return _config->find(ENV_NAME)->second; \ }() // setting + command line option -#define OMNITRACE_CONFIG_CL_SETTING(TYPE, ENV_NAME, DESCRIPTION, INITIAL_VALUE, \ - CMD_LINE, ...) \ +#define ROCPROFSYS_CONFIG_CL_SETTING(TYPE, ENV_NAME, DESCRIPTION, INITIAL_VALUE, \ + CMD_LINE, ...) \ [&]() { \ 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", "rocprofsys", "librocprof-sys", \ + __VA_ARGS__ }, \ std::vector{ CMD_LINE }); \ if(!_ret.second) \ { \ - OMNITRACE_PRINT("Warning! Duplicate setting: %s / %s\n", \ - get_setting_name(ENV_NAME).c_str(), ENV_NAME); \ + ROCPROFSYS_PRINT("Warning! Duplicate setting: %s / %s\n", \ + get_setting_name(ENV_NAME).c_str(), ENV_NAME); \ } \ return _config->find(ENV_NAME)->second; \ }() @@ -172,7 +173,7 @@ auto cfg_fini_callbacks = std::vector>{}; void finalize() { - OMNITRACE_DEBUG("[omnitrace_finalize] Disabling signal handling...\n"); + ROCPROFSYS_DEBUG("[rocprofsys_finalize] Disabling signal handling...\n"); tim::signals::disable_signal_detection(); _settings_are_configured() = false; for(const auto& itr : cfg_fini_callbacks) @@ -197,187 +198,191 @@ configure_settings(bool _init) if(get_is_continuous_integration() && get_state() < State::Init) { timemory_print_demangled_backtrace<64>(); - OMNITRACE_THROW("config::configure_settings() called before " - "omnitrace_init_library. state = %s", - std::to_string(get_state()).c_str()); + ROCPROFSYS_THROW("config::configure_settings() called before " + "rocprofsys_init_library. state = %s", + std::to_string(get_state()).c_str()); } - tim::manager::add_metadata("OMNITRACE_VERSION", OMNITRACE_VERSION_STRING); - tim::manager::add_metadata("OMNITRACE_VERSION_MAJOR", OMNITRACE_VERSION_MAJOR); - tim::manager::add_metadata("OMNITRACE_VERSION_MINOR", OMNITRACE_VERSION_MINOR); - tim::manager::add_metadata("OMNITRACE_VERSION_PATCH", OMNITRACE_VERSION_PATCH); - tim::manager::add_metadata("OMNITRACE_GIT_DESCRIBE", OMNITRACE_GIT_DESCRIBE); - tim::manager::add_metadata("OMNITRACE_GIT_REVISION", OMNITRACE_GIT_REVISION); - - tim::manager::add_metadata("OMNITRACE_LIBRARY_ARCH", OMNITRACE_LIBRARY_ARCH); - tim::manager::add_metadata("OMNITRACE_SYSTEM_NAME", OMNITRACE_SYSTEM_NAME); - tim::manager::add_metadata("OMNITRACE_SYSTEM_PROCESSOR", OMNITRACE_SYSTEM_PROCESSOR); - tim::manager::add_metadata("OMNITRACE_SYSTEM_VERSION", OMNITRACE_SYSTEM_VERSION); - - tim::manager::add_metadata("OMNITRACE_COMPILER_ID", OMNITRACE_COMPILER_ID); - tim::manager::add_metadata("OMNITRACE_COMPILER_VERSION", OMNITRACE_COMPILER_VERSION); - -#if OMNITRACE_HIP_VERSION > 0 - tim::manager::add_metadata("OMNITRACE_HIP_VERSION", OMNITRACE_HIP_VERSION_STRING); - tim::manager::add_metadata("OMNITRACE_HIP_VERSION_MAJOR", - OMNITRACE_HIP_VERSION_MAJOR); - tim::manager::add_metadata("OMNITRACE_HIP_VERSION_MINOR", - OMNITRACE_HIP_VERSION_MINOR); - tim::manager::add_metadata("OMNITRACE_HIP_VERSION_PATCH", - OMNITRACE_HIP_VERSION_PATCH); + tim::manager::add_metadata("ROCPROFSYS_VERSION", ROCPROFSYS_VERSION_STRING); + tim::manager::add_metadata("ROCPROFSYS_VERSION_MAJOR", ROCPROFSYS_VERSION_MAJOR); + tim::manager::add_metadata("ROCPROFSYS_VERSION_MINOR", ROCPROFSYS_VERSION_MINOR); + tim::manager::add_metadata("ROCPROFSYS_VERSION_PATCH", ROCPROFSYS_VERSION_PATCH); + tim::manager::add_metadata("ROCPROFSYS_GIT_DESCRIBE", ROCPROFSYS_GIT_DESCRIBE); + tim::manager::add_metadata("ROCPROFSYS_GIT_REVISION", ROCPROFSYS_GIT_REVISION); + + tim::manager::add_metadata("ROCPROFSYS_LIBRARY_ARCH", ROCPROFSYS_LIBRARY_ARCH); + tim::manager::add_metadata("ROCPROFSYS_SYSTEM_NAME", ROCPROFSYS_SYSTEM_NAME); + tim::manager::add_metadata("ROCPROFSYS_SYSTEM_PROCESSOR", + ROCPROFSYS_SYSTEM_PROCESSOR); + tim::manager::add_metadata("ROCPROFSYS_SYSTEM_VERSION", ROCPROFSYS_SYSTEM_VERSION); + + tim::manager::add_metadata("ROCPROFSYS_COMPILER_ID", ROCPROFSYS_COMPILER_ID); + tim::manager::add_metadata("ROCPROFSYS_COMPILER_VERSION", + ROCPROFSYS_COMPILER_VERSION); + +#if ROCPROFSYS_HIP_VERSION > 0 + tim::manager::add_metadata("ROCPROFSYS_HIP_VERSION", ROCPROFSYS_HIP_VERSION_STRING); + tim::manager::add_metadata("ROCPROFSYS_HIP_VERSION_MAJOR", + ROCPROFSYS_HIP_VERSION_MAJOR); + tim::manager::add_metadata("ROCPROFSYS_HIP_VERSION_MINOR", + ROCPROFSYS_HIP_VERSION_MINOR); + tim::manager::add_metadata("ROCPROFSYS_HIP_VERSION_PATCH", + ROCPROFSYS_HIP_VERSION_PATCH); #endif auto _config = settings::shared_instance(); // if using timemory, default to perfetto being off - auto _default_perfetto_v = !tim::get_env("OMNITRACE_PROFILE", false, false); + auto _default_perfetto_v = !tim::get_env("ROCPROFSYS_PROFILE", false, false); auto _system_backend = - tim::get_env("OMNITRACE_PERFETTO_BACKEND_SYSTEM", false, false); + tim::get_env("ROCPROFSYS_PERFETTO_BACKEND_SYSTEM", false, false); - auto _omnitrace_debug = _config->get("OMNITRACE_DEBUG"); - if(_omnitrace_debug) tim::set_env("TIMEMORY_DEBUG_SETTINGS", "1", 0); + auto _rocprofsys_debug = _config->get("ROCPROFSYS_DEBUG"); + if(_rocprofsys_debug) tim::set_env("TIMEMORY_DEBUG_SETTINGS", "1", 0); - OMNITRACE_CONFIG_SETTING( - std::string, "OMNITRACE_MODE", - "Data collection mode. Used to set default values for OMNITRACE_USE_* options. " - "Typically set by omnitrace binary instrumenter.", + ROCPROFSYS_CONFIG_SETTING( + std::string, "ROCPROFSYS_MODE", + "Data collection mode. Used to set default values for ROCPROFSYS_USE_* options. " + "Typically set by rocprof-sys binary instrumenter.", std::string{ "trace" }, "backend", "advanced", "mode") ->set_choices({ "trace", "sampling", "causal", "coverage" }); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_CI", - "Enable some runtime validation checks (typically enabled " - "for continuous integration)", - false, "debugging", "advanced"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_CI", + "Enable some runtime validation checks (typically enabled " + "for continuous integration)", + false, "debugging", "advanced"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_MONOCHROME", "Disable colorized logging", - false, "debugging", "advanced"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_MONOCHROME", "Disable colorized logging", + false, "debugging", "advanced"); - OMNITRACE_CONFIG_EXT_SETTING(int, "OMNITRACE_DL_VERBOSE", - "Verbosity within the omnitrace-dl library", 0, - "debugging", "libomnitrace-dl", "advanced"); + ROCPROFSYS_CONFIG_EXT_SETTING(int, "ROCPROFSYS_DL_VERBOSE", + "Verbosity within the rocprof-sys-dl library", 0, + "debugging", "librocprof-sys-dl", "advanced"); - OMNITRACE_CONFIG_SETTING( - size_t, "OMNITRACE_NUM_THREADS_HINT", + ROCPROFSYS_CONFIG_SETTING( + size_t, "ROCPROFSYS_NUM_THREADS_HINT", "This is hint for how many threads are expected to be created in the " - "application. Setting this value allows omnitrace to preallocate resources " + "application. Setting this value allows rocprof-sys to preallocate resources " "during initialization and warn about any potential issues. For example, when " "call-stack sampling, each thread has a unique sampler instance which " "communicates with an allocator instance running in a background thread. Each " "allocator only handles N sampling instances (where N is the value of " - "OMNITRACE_SAMPLING_ALLOCATOR_SIZE). When this hint is set to >= the number of " - "threads that get sampled, omnitrace can start all the background threads during " + "ROCPROFSYS_SAMPLING_ALLOCATOR_SIZE). When this hint is set to >= the number of " + "threads that get sampled, rocprof-sys can start all the background threads " + "during " "initialization", - get_env("OMNITRACE_NUM_THREADS", 1), "threading", "performance", + get_env("ROCPROFSYS_NUM_THREADS", 1), "threading", "performance", "sampling", "parallelism", "advanced"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_TRACE", "Enable perfetto backend", - _default_perfetto_v, "backend", "perfetto"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_TRACE", "Enable perfetto backend", + _default_perfetto_v, "backend", "perfetto"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_USE_PERFETTO", - "[DEPRECATED] Renamed to OMNITRACE_TRACE", - _default_perfetto_v, "backend", "perfetto", "deprecated"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_USE_PERFETTO", + "[DEPRECATED] Renamed to ROCPROFSYS_TRACE", + _default_perfetto_v, "backend", "perfetto", "deprecated"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_PROFILE", "Enable timemory backend", - !_config->get("OMNITRACE_TRACE"), "backend", - "timemory"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_PROFILE", "Enable timemory backend", + !_config->get("ROCPROFSYS_TRACE"), "backend", + "timemory"); - OMNITRACE_CONFIG_SETTING( - bool, "OMNITRACE_USE_TIMEMORY", "[DEPRECATED] Renamed to OMNITRACE_PROFILE", - !_config->get("OMNITRACE_TRACE"), "backend", "timemory", "deprecated"); + ROCPROFSYS_CONFIG_SETTING( + bool, "ROCPROFSYS_USE_TIMEMORY", "[DEPRECATED] Renamed to ROCPROFSYS_PROFILE", + !_config->get("ROCPROFSYS_TRACE"), "backend", "timemory", "deprecated"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_USE_CAUSAL", - "Enable causal profiling analysis", false, "backend", - "causal", "analysis"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_USE_CAUSAL", + "Enable causal profiling analysis", false, "backend", + "causal", "analysis"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_USE_ROCTRACER", - "Enable ROCm API and kernel tracing", true, "backend", - "roctracer", "rocm"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_USE_ROCTRACER", + "Enable ROCm API and kernel tracing", true, "backend", + "roctracer", "rocm"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_USE_ROCPROFILER", - "Enable ROCm hardware counters", true, "backend", - "rocprofiler", "rocm"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_USE_ROCPROFILER", + "Enable ROCm hardware counters", true, "backend", + "rocprofiler", "rocm"); - OMNITRACE_CONFIG_SETTING( - bool, "OMNITRACE_USE_ROCM_SMI", + ROCPROFSYS_CONFIG_SETTING( + bool, "ROCPROFSYS_USE_ROCM_SMI", "Enable sampling GPU power, temp, utilization, and memory usage", true, "backend", "rocm_smi", "rocm", "process_sampling"); - OMNITRACE_CONFIG_SETTING( - bool, "OMNITRACE_USE_ROCTX", + ROCPROFSYS_CONFIG_SETTING( + bool, "ROCPROFSYS_USE_ROCTX", "Enable ROCtx API. Warning! Out-of-order ranges may corrupt perfetto flamegraph", false, "backend", "roctracer", "rocm", "roctx"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_USE_SAMPLING", - "Enable statistical sampling of call-stack", false, - "backend", "sampling"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_USE_SAMPLING", + "Enable statistical sampling of call-stack", false, + "backend", "sampling"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_USE_THREAD_SAMPLING", - "[DEPRECATED] Renamed to OMNITRACE_USE_PROCESS_SAMPLING", - true, "backend", "sampling", "process_sampling", - "deprecated", "advanced"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_USE_THREAD_SAMPLING", + "[DEPRECATED] Renamed to ROCPROFSYS_USE_PROCESS_SAMPLING", + true, "backend", "sampling", "process_sampling", + "deprecated", "advanced"); - OMNITRACE_CONFIG_SETTING( - bool, "OMNITRACE_USE_PROCESS_SAMPLING", + ROCPROFSYS_CONFIG_SETTING( + bool, "ROCPROFSYS_USE_PROCESS_SAMPLING", "Enable a background thread which samples process-level and system metrics " "such as the CPU/GPU freq, power, memory usage, etc.", true, "backend", "sampling", "process_sampling"); - OMNITRACE_CONFIG_SETTING( - bool, "OMNITRACE_USE_PID", + ROCPROFSYS_CONFIG_SETTING( + bool, "ROCPROFSYS_USE_PID", "Enable tagging filenames with process identifier (either MPI rank or pid)", true, "io", "filename"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_USE_KOKKOSP", - "Enable support for Kokkos Tools", false, "kokkos", - "backend"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_USE_KOKKOSP", + "Enable support for Kokkos Tools", false, "kokkos", + "backend"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_USE_MPIP", - "Enable support for MPI functions", true, "mpi", "backend", - "parallelism"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_USE_MPIP", + "Enable support for MPI functions", true, "mpi", "backend", + "parallelism"); - OMNITRACE_CONFIG_SETTING( - bool, "OMNITRACE_USE_RCCLP", + ROCPROFSYS_CONFIG_SETTING( + bool, "ROCPROFSYS_USE_RCCLP", "Enable support for ROCm Communication Collectives Library (RCCL) Performance", false, "rocm", "rccl", "backend"); - OMNITRACE_CONFIG_CL_SETTING( - bool, "OMNITRACE_KOKKOSP_KERNEL_LOGGER", "Enables kernel logging", false, - "--omnitrace-kokkos-kernel-logger", "kokkos", "debugging", "advanced"); + ROCPROFSYS_CONFIG_CL_SETTING( + bool, "ROCPROFSYS_KOKKOSP_KERNEL_LOGGER", "Enables kernel logging", false, + "--rocprofsys-kokkos-kernel-logger", "kokkos", "debugging", "advanced"); - OMNITRACE_CONFIG_SETTING(int64_t, "OMNITRACE_KOKKOSP_NAME_LENGTH_MAX", - "Set this to a value > 0 to help avoid unnamed Kokkos Tools " - "callbacks. Generally, unnamed callbacks are the demangled " - "name of the function, which is very long", - 0, "kokkos", "debugging", "advanced"); + ROCPROFSYS_CONFIG_SETTING( + int64_t, "ROCPROFSYS_KOKKOSP_NAME_LENGTH_MAX", + "Set this to a value > 0 to help avoid unnamed Kokkos Tools " + "callbacks. Generally, unnamed callbacks are the demangled " + "name of the function, which is very long", + 0, "kokkos", "debugging", "advanced"); - OMNITRACE_CONFIG_SETTING(std::string, "OMNITRACE_KOKKOSP_PREFIX", - "Set to [kokkos] to maintain old naming convention", "", - "kokkos", "debugging", "advanced"); + ROCPROFSYS_CONFIG_SETTING(std::string, "ROCPROFSYS_KOKKOSP_PREFIX", + "Set to [kokkos] to maintain old naming convention", "", + "kokkos", "debugging", "advanced"); - OMNITRACE_CONFIG_SETTING( - bool, "OMNITRACE_KOKKOSP_DEEP_COPY", + ROCPROFSYS_CONFIG_SETTING( + bool, "ROCPROFSYS_KOKKOSP_DEEP_COPY", "Enable tracking deep copies (warning: may corrupt flamegraph in perfetto)", false, "kokkos", "advanced"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_USE_OMPT", - "Enable support for OpenMP-Tools", false, "openmp", "ompt", - "backend"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_USE_OMPT", + "Enable support for OpenMP-Tools", false, "openmp", "ompt", + "backend"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_USE_CODE_COVERAGE", - "Enable support for code coverage", false, "coverage", - "backend", "advanced"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_USE_CODE_COVERAGE", + "Enable support for code coverage", false, "coverage", + "backend", "advanced"); - OMNITRACE_CONFIG_SETTING( - double, "OMNITRACE_TRACE_DELAY", + ROCPROFSYS_CONFIG_SETTING( + double, "ROCPROFSYS_TRACE_DELAY", "Time in seconds to wait before enabling trace/profile data collection. If " - "multiple delays + durations are needed, see OMNITRACE_TRACE_PERIODS.", + "multiple delays + durations are needed, see ROCPROFSYS_TRACE_PERIODS.", 0.0, "trace", "profile", "perfetto", "timemory"); - OMNITRACE_CONFIG_SETTING( - double, "OMNITRACE_TRACE_DURATION", + ROCPROFSYS_CONFIG_SETTING( + double, "ROCPROFSYS_TRACE_DURATION", "If > 0.0, time (in seconds) to collect trace/profile data. If multiple delays + " - "durations are needed, see OMNITRACE_TRACE_PERIODS.", + "durations are needed, see ROCPROFSYS_TRACE_PERIODS.", 0.0, "trace", "profile", "perfetto", "timemory"); auto _clock_choices = std::vector{}; @@ -387,176 +392,177 @@ configure_settings(bool _init) join("", "(", join('|', itr.name, itr.value, itr.raw_name), ")")); } - OMNITRACE_CONFIG_SETTING(std::string, "OMNITRACE_TRACE_PERIODS", - "Similar to specify trace delay and/or duration except in " - "the form :, ::, " - "and/or :::", - std::string{}, "trace", "profile", "perfetto", "timemory"); + ROCPROFSYS_CONFIG_SETTING(std::string, "ROCPROFSYS_TRACE_PERIODS", + "Similar to specify trace delay and/or duration except in " + "the form :, ::, " + "and/or :::", + std::string{}, "trace", "profile", "perfetto", "timemory"); - OMNITRACE_CONFIG_SETTING( - std::string, "OMNITRACE_TRACE_PERIOD_CLOCK_ID", - "Set the default clock ID for OMNITRACE_TRACE_DELAY, OMNITRACE_TRACE_DURATION, " - "and/or OMNITRACE_TRACE_PERIODS. E.g. \"realtime\" == the delay/duration is " + ROCPROFSYS_CONFIG_SETTING( + std::string, "ROCPROFSYS_TRACE_PERIOD_CLOCK_ID", + "Set the default clock ID for ROCPROFSYS_TRACE_DELAY, ROCPROFSYS_TRACE_DURATION, " + "and/or ROCPROFSYS_TRACE_PERIODS. E.g. \"realtime\" == the delay/duration is " "governed by the elapsed realtime, \"cputime\" == the delay/duration is governed " "by the elapsed CPU-time within the process, etc. Note: when using CPU-based " "timing, it is recommened to scale the value by the number of threads and be " - "aware that omnitrace may contribute to advancing the process CPU-time", + "aware that rocprof-sys may contribute to advancing the process CPU-time", "CLOCK_REALTIME", "trace", "profile", "perfetto", "timemory") ->set_choices(_clock_choices); - OMNITRACE_CONFIG_SETTING( - double, "OMNITRACE_SAMPLING_FREQ", + ROCPROFSYS_CONFIG_SETTING( + double, "ROCPROFSYS_SAMPLING_FREQ", "Number of software interrupts per second when OMNITTRACE_USE_SAMPLING=ON", 300.0, "sampling", "process_sampling"); - OMNITRACE_CONFIG_SETTING(double, "OMNITRACE_SAMPLING_CPUTIME_FREQ", - "Number of software interrupts per second of CPU-time. " - "Defaults to OMNITRACE_SAMPLING_FREQ when <= 0.0", - -1.0, "sampling", "advanced"); + ROCPROFSYS_CONFIG_SETTING(double, "ROCPROFSYS_SAMPLING_CPUTIME_FREQ", + "Number of software interrupts per second of CPU-time. " + "Defaults to ROCPROFSYS_SAMPLING_FREQ when <= 0.0", + -1.0, "sampling", "advanced"); - OMNITRACE_CONFIG_SETTING( - double, "OMNITRACE_SAMPLING_REALTIME_FREQ", + ROCPROFSYS_CONFIG_SETTING( + double, "ROCPROFSYS_SAMPLING_REALTIME_FREQ", "Number of software interrupts per second of real (wall) time. " - "Defaults to OMNITRACE_SAMPLING_FREQ when <= 0.0", + "Defaults to ROCPROFSYS_SAMPLING_FREQ when <= 0.0", -1.0, "sampling", "advanced"); - OMNITRACE_CONFIG_SETTING(double, "OMNITRACE_SAMPLING_OVERFLOW_FREQ", - "Number of events in between each sample. " - "Defaults to OMNITRACE_SAMPLING_FREQ when <= 0.0", - -1.0, "sampling", "advanced"); + ROCPROFSYS_CONFIG_SETTING(double, "ROCPROFSYS_SAMPLING_OVERFLOW_FREQ", + "Number of events in between each sample. " + "Defaults to ROCPROFSYS_SAMPLING_FREQ when <= 0.0", + -1.0, "sampling", "advanced"); - OMNITRACE_CONFIG_SETTING( - double, "OMNITRACE_SAMPLING_DELAY", + ROCPROFSYS_CONFIG_SETTING( + double, "ROCPROFSYS_SAMPLING_DELAY", "Time (in seconds) to wait before the first sampling signal is delivered, " "increasing this value can fix deadlocks during init", 0.5, "sampling", "process_sampling"); - OMNITRACE_CONFIG_SETTING(double, "OMNITRACE_SAMPLING_CPUTIME_DELAY", - "Time (in seconds) to wait before the first CPU-time " - "sampling signal is delivered. " - "Defaults to OMNITRACE_SAMPLING_DELAY when <= 0.0", - -1.0, "sampling", "advanced"); + ROCPROFSYS_CONFIG_SETTING(double, "ROCPROFSYS_SAMPLING_CPUTIME_DELAY", + "Time (in seconds) to wait before the first CPU-time " + "sampling signal is delivered. " + "Defaults to ROCPROFSYS_SAMPLING_DELAY when <= 0.0", + -1.0, "sampling", "advanced"); - OMNITRACE_CONFIG_SETTING( - double, "OMNITRACE_SAMPLING_REALTIME_DELAY", + ROCPROFSYS_CONFIG_SETTING( + double, "ROCPROFSYS_SAMPLING_REALTIME_DELAY", "Time (in seconds) to wait before the first real (wall) time sampling signal is " - "delivered. Defaults to OMNITRACE_SAMPLING_DELAY when <= 0.0", + "delivered. Defaults to ROCPROFSYS_SAMPLING_DELAY when <= 0.0", -1.0, "sampling", "advanced"); - OMNITRACE_CONFIG_SETTING(double, "OMNITRACE_SAMPLING_DURATION", - "If > 0.0, time (in seconds) to sample before stopping", 0.0, - "sampling", "process_sampling"); + ROCPROFSYS_CONFIG_SETTING(double, "ROCPROFSYS_SAMPLING_DURATION", + "If > 0.0, time (in seconds) to sample before stopping", + 0.0, "sampling", "process_sampling"); - OMNITRACE_CONFIG_SETTING( - double, "OMNITRACE_PROCESS_SAMPLING_FREQ", + ROCPROFSYS_CONFIG_SETTING( + double, "ROCPROFSYS_PROCESS_SAMPLING_FREQ", "Number of measurements per second when OMNITTRACE_USE_PROCESS_SAMPLING=ON. If " - "set to zero, uses OMNITRACE_SAMPLING_FREQ value", + "set to zero, uses ROCPROFSYS_SAMPLING_FREQ value", 0.0, "process_sampling"); - OMNITRACE_CONFIG_SETTING(double, "OMNITRACE_PROCESS_SAMPLING_DURATION", - "If > 0.0, time (in seconds) to sample before stopping. If " - "less than zero, uses OMNITRACE_SAMPLING_DURATION", - -1.0, "sampling", "process_sampling"); + ROCPROFSYS_CONFIG_SETTING(double, "ROCPROFSYS_PROCESS_SAMPLING_DURATION", + "If > 0.0, time (in seconds) to sample before stopping. If " + "less than zero, uses ROCPROFSYS_SAMPLING_DURATION", + -1.0, "sampling", "process_sampling"); - OMNITRACE_CONFIG_SETTING( - std::string, "OMNITRACE_SAMPLING_CPUS", + ROCPROFSYS_CONFIG_SETTING( + std::string, "ROCPROFSYS_SAMPLING_CPUS", "CPUs to collect frequency information for. Values should be separated by commas " "and can be explicit or ranges, e.g. 0,1,5-8. An empty value implies 'all' and " "'none' suppresses all CPU frequency sampling", std::string{}, "process_sampling"); - OMNITRACE_CONFIG_SETTING(std::string, "OMNITRACE_ROCM_SMI_DEVICES", - "[DEPRECATED] Renamed to OMNITRACE_SAMPLING_GPUS", - std::string{ "all" }, "rocm_smi", "rocm", "process_sampling", - "deprecated", "advanced"); + ROCPROFSYS_CONFIG_SETTING(std::string, "ROCPROFSYS_ROCM_SMI_DEVICES", + "[DEPRECATED] Renamed to ROCPROFSYS_SAMPLING_GPUS", + std::string{ "all" }, "rocm_smi", "rocm", + "process_sampling", "deprecated", "advanced"); - OMNITRACE_CONFIG_SETTING( - std::string, "OMNITRACE_SAMPLING_GPUS", - "Devices to query when OMNITRACE_USE_ROCM_SMI=ON. Values should be separated by " + ROCPROFSYS_CONFIG_SETTING( + std::string, "ROCPROFSYS_SAMPLING_GPUS", + "Devices to query when ROCPROFSYS_USE_ROCM_SMI=ON. Values should be separated by " "commas and can be explicit or ranges, e.g. 0,1,5-8. An empty value implies " "'all' and 'none' suppresses all GPU sampling", std::string{ "all" }, "rocm_smi", "rocm", "process_sampling"); - OMNITRACE_CONFIG_SETTING( - std::string, "OMNITRACE_SAMPLING_TIDS", + ROCPROFSYS_CONFIG_SETTING( + std::string, "ROCPROFSYS_SAMPLING_TIDS", "Limit call-stack sampling to specific thread IDs, starting at zero for the main " "thread. Be aware that some libraries, such as ROCm may create additional " - "threads which increment the TID count. However, no threads started by omnitrace " + "threads which increment the TID count. However, no threads started by " + "rocprof-sys " "will increment the TID count. Values should be separated by commas and can be " "explicit or ranges, e.g. 0,1,5-8. An empty value implies all TIDs.", std::string{}, "sampling", "advanced"); - OMNITRACE_CONFIG_SETTING( - std::string, "OMNITRACE_SAMPLING_CPUTIME_TIDS", - "Same as OMNITRACE_SAMPLING_TIDS but applies specifically to samplers whose " + ROCPROFSYS_CONFIG_SETTING( + std::string, "ROCPROFSYS_SAMPLING_CPUTIME_TIDS", + "Same as ROCPROFSYS_SAMPLING_TIDS but applies specifically to samplers whose " "timers are based on the CPU-time. This is useful when you want to restrict " "samples to particular threads.", std::string{}, "sampling", "advanced"); - OMNITRACE_CONFIG_SETTING( - std::string, "OMNITRACE_SAMPLING_REALTIME_TIDS", - "Same as OMNITRACE_SAMPLING_TIDS but applies specifically to samplers whose " + ROCPROFSYS_CONFIG_SETTING( + std::string, "ROCPROFSYS_SAMPLING_REALTIME_TIDS", + "Same as ROCPROFSYS_SAMPLING_TIDS but applies specifically to samplers whose " "timers are based on the real (wall) time. This is useful when you want to " "restrict samples to particular threads.", std::string{}, "sampling", "advanced"); - OMNITRACE_CONFIG_SETTING( - std::string, "OMNITRACE_SAMPLING_OVERFLOW_TIDS", - "Same as OMNITRACE_SAMPLING_TIDS but applies specifically to samplers whose " + ROCPROFSYS_CONFIG_SETTING( + std::string, "ROCPROFSYS_SAMPLING_OVERFLOW_TIDS", + "Same as ROCPROFSYS_SAMPLING_TIDS but applies specifically to samplers whose " "samples are based on the overflow of a particular event. This is useful when " "you want to restrict samples to particular threads.", std::string{}, "sampling", "advanced"); auto _backend = tim::get_env_choice( - "OMNITRACE_PERFETTO_BACKEND", - (_system_backend) ? "system" // if OMNITRACE_PERFETTO_BACKEND_SYSTEM is true, - // default to system. + "ROCPROFSYS_PERFETTO_BACKEND", + (_system_backend) ? "system" // if ROCPROFSYS_PERFETTO_BACKEND_SYSTEM is true, + // default to system. : "inprocess", // Otherwise, default to inprocess { "inprocess", "system", "all" }, false); - OMNITRACE_CONFIG_SETTING(std::string, "OMNITRACE_PERFETTO_BACKEND", - "Specify the perfetto backend to activate. Options are: " - "'inprocess', 'system', or 'all'", - _backend, "perfetto") + ROCPROFSYS_CONFIG_SETTING(std::string, "ROCPROFSYS_PERFETTO_BACKEND", + "Specify the perfetto backend to activate. Options are: " + "'inprocess', 'system', or 'all'", + _backend, "perfetto") ->set_choices({ "inprocess", "system", "all" }); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_TRACE_THREAD_LOCKS", - "Enable tracing calls to pthread_mutex_lock, " - "pthread_mutex_unlock, pthread_mutex_trylock", - false, "backend", "parallelism", "gotcha", "advanced"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_TRACE_THREAD_LOCKS", + "Enable tracing calls to pthread_mutex_lock, " + "pthread_mutex_unlock, pthread_mutex_trylock", + false, "backend", "parallelism", "gotcha", "advanced"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_TRACE_THREAD_RW_LOCKS", - "Enable tracing calls to pthread_rwlock_* functions. May " - "cause deadlocks with ROCm-enabled OpenMPI.", - false, "backend", "parallelism", "gotcha", "advanced"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_TRACE_THREAD_RW_LOCKS", + "Enable tracing calls to pthread_rwlock_* functions. May " + "cause deadlocks with ROCm-enabled OpenMPI.", + false, "backend", "parallelism", "gotcha", "advanced"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_TRACE_THREAD_SPIN_LOCKS", - "Enable tracing calls to pthread_spin_* functions. May " - "cause deadlocks with MPI distributions.", - false, "backend", "parallelism", "gotcha", "advanced"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_TRACE_THREAD_SPIN_LOCKS", + "Enable tracing calls to pthread_spin_* functions. May " + "cause deadlocks with MPI distributions.", + false, "backend", "parallelism", "gotcha", "advanced"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_TRACE_THREAD_BARRIERS", - "Enable tracing calls to pthread_barrier functions.", true, - "backend", "parallelism", "gotcha", "advanced"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_TRACE_THREAD_BARRIERS", + "Enable tracing calls to pthread_barrier functions.", true, + "backend", "parallelism", "gotcha", "advanced"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_TRACE_THREAD_JOIN", - "Enable tracing calls to pthread_join functions.", true, - "backend", "parallelism", "gotcha", "advanced"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_TRACE_THREAD_JOIN", + "Enable tracing calls to pthread_join functions.", true, + "backend", "parallelism", "gotcha", "advanced"); - OMNITRACE_CONFIG_SETTING( - bool, "OMNITRACE_SAMPLING_KEEP_INTERNAL", + ROCPROFSYS_CONFIG_SETTING( + bool, "ROCPROFSYS_SAMPLING_KEEP_INTERNAL", "Configure whether the statistical samples should include call-stack entries " - "from internal routines in omnitrace. E.g. when ON, the call-stack will show " - "functions like omnitrace_push_trace. If disabled, omnitrace will attempt to " + "from internal routines in rocprof-sys. E.g. when ON, the call-stack will show " + "functions like rocprofsys_push_trace. If disabled, rocprof-sys will attempt to " "filter out internal routines from the sampling call-stacks", true, "sampling", "data", "advanced"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_SAMPLING_INCLUDE_INLINES", - "Create entries for inlined functions when available", false, - "sampling", "data", "advanced"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_SAMPLING_INCLUDE_INLINES", + "Create entries for inlined functions when available", + false, "sampling", "data", "advanced"); - OMNITRACE_CONFIG_SETTING( - size_t, "OMNITRACE_SAMPLING_ALLOCATOR_SIZE", + ROCPROFSYS_CONFIG_SETTING( + size_t, "ROCPROFSYS_SAMPLING_ALLOCATOR_SIZE", "The number of sampled threads handled by an allocator running in a background " "thread. Each thread that is sampled communicates with an allocator running in a " "background thread which handles storing/caching the data when it's buffer is " @@ -567,135 +573,139 @@ configure_settings(bool _init) "thread started by the application.", 8, "sampling", "debugging", "advanced"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_SAMPLING_OVERFLOW", - "Enable sampling via an overflow of a HW counter. This " - "requires Linux perf (/proc/sys/kernel/perf_event_paranoid " - "created by OS) with a value of 2 or less in that file", - false, "sampling", "advanced"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_SAMPLING_OVERFLOW", + "Enable sampling via an overflow of a HW counter. This " + "requires Linux perf (/proc/sys/kernel/perf_event_paranoid " + "created by OS) with a value of 2 or less in that file", + false, "sampling", "advanced"); - OMNITRACE_CONFIG_SETTING( - bool, "OMNITRACE_SAMPLING_REALTIME", + ROCPROFSYS_CONFIG_SETTING( + bool, "ROCPROFSYS_SAMPLING_REALTIME", "Enable sampling frequency via a wall-clock timer. This may result in typically " "idle child threads consuming an unnecessary large amount of CPU time.", false, "sampling", "advanced"); - OMNITRACE_CONFIG_SETTING( - bool, "OMNITRACE_SAMPLING_CPUTIME", + ROCPROFSYS_CONFIG_SETTING( + bool, "ROCPROFSYS_SAMPLING_CPUTIME", "Enable sampling frequency via a timer that measures both CPU time used by the " "current process, and CPU time expended on behalf of the process by the system. " "This is recommended.", false, "sampling", "advanced"); - OMNITRACE_CONFIG_SETTING(int, "OMNITRACE_SAMPLING_CPUTIME_SIGNAL", - "Modify this value only if the target process is also using " - "the same signal (SIGPROF)", - SIGPROF, "sampling", "advanced"); - - OMNITRACE_CONFIG_SETTING(int, "OMNITRACE_SAMPLING_REALTIME_SIGNAL", - "Modify this value only if the target process is also using " - "the same signal (SIGRTMIN)", - SIGRTMIN, "sampling", "advanced"); - - OMNITRACE_CONFIG_SETTING(int, "OMNITRACE_SAMPLING_OVERFLOW_SIGNAL", - "Modify this value only if the target process is also using " - "the same signal (SIGRTMIN + 1)", - SIGRTMIN + 1, "sampling", "advanced"); - - OMNITRACE_CONFIG_SETTING(std::string, "OMNITRACE_SAMPLING_OVERFLOW_EVENT", - "Metric for overflow sampling", - std::string{ "perf::PERF_COUNT_HW_CACHE_REFERENCES" }, - "sampling", "hardware_counters") + ROCPROFSYS_CONFIG_SETTING( + int, "ROCPROFSYS_SAMPLING_CPUTIME_SIGNAL", + "Modify this value only if the target process is also using " + "the same signal (SIGPROF)", + SIGPROF, "sampling", "advanced"); + + ROCPROFSYS_CONFIG_SETTING( + int, "ROCPROFSYS_SAMPLING_REALTIME_SIGNAL", + "Modify this value only if the target process is also using " + "the same signal (SIGRTMIN)", + SIGRTMIN, "sampling", "advanced"); + + ROCPROFSYS_CONFIG_SETTING( + int, "ROCPROFSYS_SAMPLING_OVERFLOW_SIGNAL", + "Modify this value only if the target process is also using " + "the same signal (SIGRTMIN + 1)", + SIGRTMIN + 1, "sampling", "advanced"); + + ROCPROFSYS_CONFIG_SETTING(std::string, "ROCPROFSYS_SAMPLING_OVERFLOW_EVENT", + "Metric for overflow sampling", + std::string{ "perf::PERF_COUNT_HW_CACHE_REFERENCES" }, + "sampling", "hardware_counters") ->set_choices(perf::get_config_choices()); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_ROCTRACER_HIP_API", - "Enable HIP API tracing support", true, "roctracer", "rocm", - "advanced"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_ROCTRACER_HIP_API", + "Enable HIP API tracing support", true, "roctracer", "rocm", + "advanced"); - OMNITRACE_CONFIG_SETTING( - bool, "OMNITRACE_ROCTRACER_HIP_API_BACKTRACE", + ROCPROFSYS_CONFIG_SETTING( + bool, "ROCPROFSYS_ROCTRACER_HIP_API_BACKTRACE", "Enable annotating the perfetto debug annotation with backtraces", false, "roctracer", "rocm", "perfetto", "advanced"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_ROCTRACER_HIP_ACTIVITY", - "Enable HIP activity tracing support", true, "roctracer", - "rocm", "advanced"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_ROCTRACER_HIP_ACTIVITY", + "Enable HIP activity tracing support", true, "roctracer", + "rocm", "advanced"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_ROCTRACER_HSA_ACTIVITY", - "Enable HSA activity tracing support", false, "roctracer", - "rocm", "advanced"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_ROCTRACER_HSA_ACTIVITY", + "Enable HSA activity tracing support", false, "roctracer", + "rocm", "advanced"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_ROCTRACER_HSA_API", - "Enable HSA API tracing support", false, "roctracer", "rocm", - "advanced"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_ROCTRACER_HSA_API", + "Enable HSA API tracing support", false, "roctracer", + "rocm", "advanced"); - OMNITRACE_CONFIG_SETTING(std::string, "OMNITRACE_ROCTRACER_HSA_API_TYPES", - "HSA API type to collect", "", "roctracer", "rocm", - "advanced"); + ROCPROFSYS_CONFIG_SETTING(std::string, "ROCPROFSYS_ROCTRACER_HSA_API_TYPES", + "HSA API type to collect", "", "roctracer", "rocm", + "advanced"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_ROCTRACER_DISCARD_BARRIERS", - "Skip barrier marker events in traces", false, "roctracer", - "rocm", "advanced"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_ROCTRACER_DISCARD_BARRIERS", + "Skip barrier marker events in traces", false, "roctracer", + "rocm", "advanced"); - OMNITRACE_CONFIG_SETTING( - std::string, "OMNITRACE_ROCM_EVENTS", + ROCPROFSYS_CONFIG_SETTING( + std::string, "ROCPROFSYS_ROCM_EVENTS", "ROCm hardware counters. Use ':device=N' syntax to specify collection on device " "number N, e.g. ':device=0'. If no device specification is provided, the event " "is collected on every available device", "", "rocprofiler", "rocm", "hardware_counters"); - OMNITRACE_CONFIG_SETTING(std::string, "OMNITRACE_ROCM_SMI_METRICS", - "rocm-smi metrics to collect: busy, temp, power, mem_usage", - "busy,temp,power,mem_usage", "backend", "rocm_smi", "rocm", - "process_sampling", "advanced"); + ROCPROFSYS_CONFIG_SETTING(std::string, "ROCPROFSYS_ROCM_SMI_METRICS", + "rocm-smi metrics to collect: busy, temp, power, mem_usage", + "busy,temp,power,mem_usage", "backend", "rocm_smi", "rocm", + "process_sampling", "advanced"); - OMNITRACE_CONFIG_SETTING(size_t, "OMNITRACE_PERFETTO_SHMEM_SIZE_HINT_KB", - "Hint for shared-memory buffer size in perfetto (in KB)", - size_t{ 4096 }, "perfetto", "data", "advanced"); + ROCPROFSYS_CONFIG_SETTING(size_t, "ROCPROFSYS_PERFETTO_SHMEM_SIZE_HINT_KB", + "Hint for shared-memory buffer size in perfetto (in KB)", + size_t{ 4096 }, "perfetto", "data", "advanced"); - OMNITRACE_CONFIG_SETTING(size_t, "OMNITRACE_PERFETTO_BUFFER_SIZE_KB", - "Size of perfetto buffer (in KB)", size_t{ 1024000 }, - "perfetto", "data"); + ROCPROFSYS_CONFIG_SETTING(size_t, "ROCPROFSYS_PERFETTO_BUFFER_SIZE_KB", + "Size of perfetto buffer (in KB)", size_t{ 1024000 }, + "perfetto", "data"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_PERFETTO_COMBINE_TRACES", - "Combine Perfetto traces. If not explicitly set, it will " - "default to the value of OMNITRACE_COLLAPSE_PROCESSES", - false, "perfetto", "data", "advanced"); + ROCPROFSYS_CONFIG_SETTING(bool, "ROCPROFSYS_PERFETTO_COMBINE_TRACES", + "Combine Perfetto traces. If not explicitly set, it will " + "default to the value of ROCPROFSYS_COLLAPSE_PROCESSES", + false, "perfetto", "data", "advanced"); - OMNITRACE_CONFIG_SETTING( - bool, "OMNITRACE_PERFETTO_ROCTRACER_PER_STREAM", + ROCPROFSYS_CONFIG_SETTING( + bool, "ROCPROFSYS_PERFETTO_ROCTRACER_PER_STREAM", "Separate roctracer GPU side traces (copies, kernels) into separate " "tracks based on the stream they're enqueued into", true, "perfetto", "roctracer", "rocm", "advanced"); - OMNITRACE_CONFIG_SETTING( - std::string, "OMNITRACE_PERFETTO_FILL_POLICY", + ROCPROFSYS_CONFIG_SETTING( + std::string, "ROCPROFSYS_PERFETTO_FILL_POLICY", "Behavior when perfetto buffer is full. 'discard' will ignore new entries, " "'ring_buffer' will overwrite old entries", "discard", "perfetto", "data") ->set_choices({ "fill", "discard" }); - OMNITRACE_CONFIG_SETTING(std::string, "OMNITRACE_ENABLE_CATEGORIES", - "Enable collecting profiling and trace data for these " - "categories and disable all other categories", - "", "trace", "profile", "perfetto", "timemory", "data", - "category", "advanced") + ROCPROFSYS_CONFIG_SETTING(std::string, "ROCPROFSYS_ENABLE_CATEGORIES", + "Enable collecting profiling and trace data for these " + "categories and disable all other categories", + "", "trace", "profile", "perfetto", "timemory", "data", + "category", "advanced") ->set_choices(get_available_categories>()); - OMNITRACE_CONFIG_SETTING( - std::string, "OMNITRACE_DISABLE_CATEGORIES", + ROCPROFSYS_CONFIG_SETTING( + std::string, "ROCPROFSYS_DISABLE_CATEGORIES", "Disable collecting profiling and trace data for these categories", "", "trace", "profile", "perfetto", "timemory", "data", "category", "advanced") ->set_choices(get_available_categories>()); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_PERFETTO_ANNOTATIONS", - "Include debug annotations in perfetto trace. When enabled, " - "this feature will encode information such as the values of " - "the function arguments (when available). Disabling this " - "feature may dramatically reduce the size of the trace", - true, "perfetto", "data", "debugging", "advanced"); + ROCPROFSYS_CONFIG_SETTING( + bool, "ROCPROFSYS_PERFETTO_ANNOTATIONS", + "Include debug annotations in perfetto trace. When enabled, " + "this feature will encode information such as the values of " + "the function arguments (when available). Disabling this " + "feature may dramatically reduce the size of the trace", + true, "perfetto", "data", "debugging", "advanced"); - OMNITRACE_CONFIG_SETTING( - bool, "OMNITRACE_PERFETTO_COMPACT_ROCTRACER_ANNOTATIONS", + ROCPROFSYS_CONFIG_SETTING( + bool, "ROCPROFSYS_PERFETTO_COMPACT_ROCTRACER_ANNOTATIONS", "When PERFETTO_ANNOTATIONS, USE_ROCTRACER, and ROCTRACER_HIP_API are all " "enabled, enabling this option will result in the arg information for HIP API " "calls to all be within one annotation (e.g., args=\"stream=0x0, dst=0x1F, " @@ -706,60 +716,62 @@ configure_settings(bool _init) "trace with the same value", false, "perfetto", "data", "debugging", "roctracer", "rocm", "advanced"); - OMNITRACE_CONFIG_SETTING( - uint64_t, "OMNITRACE_THREAD_POOL_SIZE", + ROCPROFSYS_CONFIG_SETTING( + uint64_t, "ROCPROFSYS_THREAD_POOL_SIZE", "Max number of threads for processing background tasks", std::max(std::min(4, std::thread::hardware_concurrency() / 2), 1), "parallelism", "advanced"); - OMNITRACE_CONFIG_SETTING( - std::string, "OMNITRACE_TIMEMORY_COMPONENTS", - "List of components to collect via timemory (see `omnitrace-avail -C`)", + ROCPROFSYS_CONFIG_SETTING( + std::string, "ROCPROFSYS_TIMEMORY_COMPONENTS", + "List of components to collect via timemory (see `rocprof-sys-avail -C`)", "wall_clock", "timemory", "component"); - OMNITRACE_CONFIG_SETTING(std::string, "OMNITRACE_OUTPUT_FILE", - "[DEPRECATED] See OMNITRACE_PERFETTO_FILE", std::string{}, - "perfetto", "io", "filename", "deprecated", "advanced"); + ROCPROFSYS_CONFIG_SETTING(std::string, "ROCPROFSYS_OUTPUT_FILE", + "[DEPRECATED] See ROCPROFSYS_PERFETTO_FILE", std::string{}, + "perfetto", "io", "filename", "deprecated", "advanced"); - OMNITRACE_CONFIG_SETTING(std::string, "OMNITRACE_PERFETTO_FILE", "Perfetto filename", - std::string{ "perfetto-trace.proto" }, "perfetto", "io", - "filename", "advanced"); + ROCPROFSYS_CONFIG_SETTING(std::string, "ROCPROFSYS_PERFETTO_FILE", + "Perfetto filename", std::string{ "perfetto-trace.proto" }, + "perfetto", "io", "filename", "advanced"); - OMNITRACE_CONFIG_SETTING(bool, "OMNITRACE_USE_TEMPORARY_FILES", - "Write data to temporary files to minimize the memory usage " - "of omnitrace, e.g. call-stack samples will be periodically " - "written to a file and re-loaded during finalization", - true, "io", "data", "advanced"); + ROCPROFSYS_CONFIG_SETTING( + bool, "ROCPROFSYS_USE_TEMPORARY_FILES", + "Write data to temporary files to minimize the memory usage " + "of rocprof-sys, e.g. call-stack samples will be periodically " + "written to a file and re-loaded during finalization", + true, "io", "data", "advanced"); - OMNITRACE_CONFIG_SETTING( - std::string, "OMNITRACE_TMPDIR", "Base directory for temporary files", + ROCPROFSYS_CONFIG_SETTING( + std::string, "ROCPROFSYS_TMPDIR", "Base directory for temporary files", get_env("TMPDIR", "/tmp"), "io", "data", "advanced"); - OMNITRACE_CONFIG_SETTING( - std::string, "OMNITRACE_CAUSAL_BACKEND", + ROCPROFSYS_CONFIG_SETTING( + std::string, "ROCPROFSYS_CAUSAL_BACKEND", "Backend for call-stack sampling. See " - "https://rocm.github.io/omnitrace/causal_profiling.html#backends for more " - "info. If set to \"auto\", omnitrace will attempt to use the perf backend and " + "https://rocm.docs.amd.com/projects/rocprofiler-systems/en/latest/how-to/" + "performing-causal-profiling.html#backends for more " + "info. If set to \"auto\", rocprof-sys will attempt to use the perf backend and " "fallback on the timer backend if unavailable", std::string{ "auto" }, "causal", "analysis") ->set_choices({ "auto", "perf", "timer" }); - OMNITRACE_CONFIG_SETTING( - std::string, "OMNITRACE_CAUSAL_MODE", + ROCPROFSYS_CONFIG_SETTING( + std::string, "ROCPROFSYS_CAUSAL_MODE", "Perform causal experiments at the function-scope or line-scope. Ideally, use " "function first to locate function with highest impact and then switch to line " - "mode + OMNITRACE_CAUSAL_FUNCTION_SCOPE set to the function being targeted.", + "mode + ROCPROFSYS_CAUSAL_FUNCTION_SCOPE set to the function being targeted.", std::string{ "function" }, "causal", "analysis") ->set_choices({ "func", "line", "function" }); - OMNITRACE_CONFIG_SETTING( - double, "OMNITRACE_CAUSAL_DELAY", + ROCPROFSYS_CONFIG_SETTING( + double, "ROCPROFSYS_CAUSAL_DELAY", "Length of time to wait (in seconds) before starting the first causal experiment", 0.0, "causal", "analysis"); - OMNITRACE_CONFIG_SETTING( - double, "OMNITRACE_CAUSAL_DURATION", + ROCPROFSYS_CONFIG_SETTING( + double, "ROCPROFSYS_CAUSAL_DURATION", "Length of time to perform causal experimentation (in seconds) after the first " "experiment has started. After this amount of time has elapsed, no more causal " "experiments will be performed and the application will continue without any " @@ -767,74 +779,74 @@ configure_settings(bool _init) "completes", 0.0, "causal", "analysis"); - OMNITRACE_CONFIG_SETTING( - bool, "OMNITRACE_CAUSAL_END_TO_END", + ROCPROFSYS_CONFIG_SETTING( + bool, "ROCPROFSYS_CAUSAL_END_TO_END", "Perform causal experiment over the length of the entire application", false, "causal", "analysis", "advanced"); - OMNITRACE_CONFIG_SETTING(std::string, "OMNITRACE_CAUSAL_FILE", - "Name of causal output filename (w/o extension)", - std::string{ "experiments" }, "causal", "analysis", - "advanced", "io"); + ROCPROFSYS_CONFIG_SETTING(std::string, "ROCPROFSYS_CAUSAL_FILE", + "Name of causal output filename (w/o extension)", + std::string{ "experiments" }, "causal", "analysis", + "advanced", "io"); - OMNITRACE_CONFIG_SETTING( - bool, "OMNITRACE_CAUSAL_FILE_RESET", + ROCPROFSYS_CONFIG_SETTING( + bool, "ROCPROFSYS_CAUSAL_FILE_RESET", "Overwrite any existing causal output file instead of appending to it", false, "causal", "analysis", "advanced", "io"); - OMNITRACE_CONFIG_SETTING( - uint64_t, "OMNITRACE_CAUSAL_RANDOM_SEED", + ROCPROFSYS_CONFIG_SETTING( + uint64_t, "ROCPROFSYS_CAUSAL_RANDOM_SEED", "Seed for random number generator which selects speedups and experiments -- " "please note that the lines selected for experimentation are not reproducible " "but the speedup selection is. If set to zero, std::random_device{}() will be " "used.", 0, "causal", "analysis"); - OMNITRACE_CONFIG_SETTING(std::string, "OMNITRACE_CAUSAL_FIXED_SPEEDUP", - "List of virtual speedups between 0 and 100 (inclusive) to " - "sample from for causal profiling", - std::string{}, "causal", "analysis", "advanced"); + ROCPROFSYS_CONFIG_SETTING(std::string, "ROCPROFSYS_CAUSAL_FIXED_SPEEDUP", + "List of virtual speedups between 0 and 100 (inclusive) to " + "sample from for causal profiling", + std::string{}, "causal", "analysis", "advanced"); - OMNITRACE_CONFIG_SETTING( - std::string, "OMNITRACE_CAUSAL_BINARY_SCOPE", + ROCPROFSYS_CONFIG_SETTING( + std::string, "ROCPROFSYS_CAUSAL_BINARY_SCOPE", "Limits causal experiments to the binaries matching the provided list of regular " "expressions (separated by tab, semi-colon, and/or quotes (single or double))", std::string{ "%MAIN%" }, "causal", "analysis"); - OMNITRACE_CONFIG_SETTING( - std::string, "OMNITRACE_CAUSAL_SOURCE_SCOPE", + ROCPROFSYS_CONFIG_SETTING( + std::string, "ROCPROFSYS_CAUSAL_SOURCE_SCOPE", "Limits causal experiments to the source files or source file + lineno pair " "(i.e. or :) matching the provided list of regular " "expressions (separated by tab, semi-colon, and/or quotes (single or double))", std::string{}, "causal", "analysis"); - OMNITRACE_CONFIG_SETTING( - std::string, "OMNITRACE_CAUSAL_FUNCTION_SCOPE", + ROCPROFSYS_CONFIG_SETTING( + std::string, "ROCPROFSYS_CAUSAL_FUNCTION_SCOPE", "List of regex entries for causal profiling (separated by tab, " "semi-colon, and/or quotes (single or double))", std::string{}, "causal", "analysis"); - OMNITRACE_CONFIG_SETTING( - std::string, "OMNITRACE_CAUSAL_BINARY_EXCLUDE", + ROCPROFSYS_CONFIG_SETTING( + std::string, "ROCPROFSYS_CAUSAL_BINARY_EXCLUDE", "Excludes binaries matching the list of provided regexes from causal experiments " "(separated by tab, semi-colon, and/or quotes (single or double))", std::string{}, "causal", "analysis"); - OMNITRACE_CONFIG_SETTING( - std::string, "OMNITRACE_CAUSAL_SOURCE_EXCLUDE", + ROCPROFSYS_CONFIG_SETTING( + std::string, "ROCPROFSYS_CAUSAL_SOURCE_EXCLUDE", "Excludes source files or source file + lineno pair (i.e. or " ":) matching the list of provided regexes from causal experiments " "(separated by tab, semi-colon, and/or quotes (single or double))", std::string{}, "causal", "analysis"); - OMNITRACE_CONFIG_SETTING( - std::string, "OMNITRACE_CAUSAL_FUNCTION_EXCLUDE", + ROCPROFSYS_CONFIG_SETTING( + std::string, "ROCPROFSYS_CAUSAL_FUNCTION_EXCLUDE", "Excludes functions matching the list of provided regexes from causal " "experiments (separated by tab, semi-colon, and/or quotes (single or double))", std::string{}, "causal", "analysis"); - OMNITRACE_CONFIG_SETTING( - bool, "OMNITRACE_CAUSAL_FUNCTION_EXCLUDE_DEFAULTS", + ROCPROFSYS_CONFIG_SETTING( + bool, "ROCPROFSYS_CAUSAL_FUNCTION_EXCLUDE_DEFAULTS", "This controls adding a series of function exclude regexes to avoid " "experimenting on STL implementation functions, etc. which are, " "generally, not helpful. Details: excludes demangled function names " @@ -858,23 +870,23 @@ configure_settings(bool _init) _config->get_timing_units() = "sec"; _config->get_memory_units() = "MB"; - // settings native to timemory but critically and/or extensively used by omnitrace - auto _add_omnitrace_category = [&_config](auto itr) { + // settings native to timemory but critically and/or extensively used by rocprof-sys + auto _add_rocprofsys_category = [&_config](auto itr) { if(itr != _config->end()) { auto _categories = itr->second->get_categories(); - _categories.emplace("omnitrace"); - _categories.emplace("libomnitrace"); + _categories.emplace("rocprofsys"); + _categories.emplace("librocprof-sys"); itr->second->set_categories(_categories); } }; - _add_omnitrace_category(_config->find("OMNITRACE_CONFIG_FILE")); - _add_omnitrace_category(_config->find("OMNITRACE_DEBUG")); - _add_omnitrace_category(_config->find("OMNITRACE_VERBOSE")); - _add_omnitrace_category(_config->find("OMNITRACE_TIME_OUTPUT")); - _add_omnitrace_category(_config->find("OMNITRACE_OUTPUT_PREFIX")); - _add_omnitrace_category(_config->find("OMNITRACE_OUTPUT_PATH")); + _add_rocprofsys_category(_config->find("ROCPROFSYS_CONFIG_FILE")); + _add_rocprofsys_category(_config->find("ROCPROFSYS_DEBUG")); + _add_rocprofsys_category(_config->find("ROCPROFSYS_VERBOSE")); + _add_rocprofsys_category(_config->find("ROCPROFSYS_TIME_OUTPUT")); + _add_rocprofsys_category(_config->find("ROCPROFSYS_OUTPUT_PREFIX")); + _add_rocprofsys_category(_config->find("ROCPROFSYS_OUTPUT_PATH")); auto _add_advanced_category = [&_config](const std::string& _name) { auto itr = _config->find(_name); @@ -886,52 +898,52 @@ configure_settings(bool _init) } else { - if(_config->get("OMNITRACE_CI")) + if(_config->get("ROCPROFSYS_CI")) { - OMNITRACE_THROW("Error! Setting '%s' not found!", _name.c_str()); + ROCPROFSYS_THROW("Error! Setting '%s' not found!", _name.c_str()); } } }; - _add_advanced_category("OMNITRACE_CPU_AFFINITY"); - _add_advanced_category("OMNITRACE_COUT_OUTPUT"); - _add_advanced_category("OMNITRACE_FILE_OUTPUT"); - _add_advanced_category("OMNITRACE_JSON_OUTPUT"); - _add_advanced_category("OMNITRACE_TREE_OUTPUT"); - _add_advanced_category("OMNITRACE_TEXT_OUTPUT"); - _add_advanced_category("OMNITRACE_DIFF_OUTPUT"); - _add_advanced_category("OMNITRACE_DEBUG"); - _add_advanced_category("OMNITRACE_ENABLE_SIGNAL_HANDLER"); - _add_advanced_category("OMNITRACE_FLAT_PROFILE"); - _add_advanced_category("OMNITRACE_INPUT_EXTENSIONS"); - _add_advanced_category("OMNITRACE_INPUT_PATH"); - _add_advanced_category("OMNITRACE_INPUT_PREFIX"); - _add_advanced_category("OMNITRACE_MAX_DEPTH"); - _add_advanced_category("OMNITRACE_MAX_WIDTH"); - _add_advanced_category("OMNITRACE_MEMORY_PRECISION"); - _add_advanced_category("OMNITRACE_MEMORY_SCIENTIFIC"); - _add_advanced_category("OMNITRACE_MEMORY_UNITS"); - _add_advanced_category("OMNITRACE_MEMORY_WIDTH"); - _add_advanced_category("OMNITRACE_NETWORK_INTERFACE"); - _add_advanced_category("OMNITRACE_NODE_COUNT"); - _add_advanced_category("OMNITRACE_PAPI_FAIL_ON_ERROR"); - _add_advanced_category("OMNITRACE_PAPI_OVERFLOW"); - _add_advanced_category("OMNITRACE_PAPI_MULTIPLEXING"); - _add_advanced_category("OMNITRACE_PAPI_QUIET"); - _add_advanced_category("OMNITRACE_PAPI_THREADING"); - _add_advanced_category("OMNITRACE_PRECISION"); - _add_advanced_category("OMNITRACE_SCIENTIFIC"); - _add_advanced_category("OMNITRACE_STRICT_CONFIG"); - _add_advanced_category("OMNITRACE_TIMELINE_PROFILE"); - _add_advanced_category("OMNITRACE_SCIENTIFIC"); - _add_advanced_category("OMNITRACE_TIME_FORMAT"); - _add_advanced_category("OMNITRACE_TIMING_PRECISION"); - _add_advanced_category("OMNITRACE_TIMING_SCIENTIFIC"); - _add_advanced_category("OMNITRACE_TIMING_UNITS"); - _add_advanced_category("OMNITRACE_TIMING_WIDTH"); - _add_advanced_category("OMNITRACE_WIDTH"); - _add_advanced_category("OMNITRACE_COLLAPSE_THREADS"); - _add_advanced_category("OMNITRACE_COLLAPSE_PROCESSES"); + _add_advanced_category("ROCPROFSYS_CPU_AFFINITY"); + _add_advanced_category("ROCPROFSYS_COUT_OUTPUT"); + _add_advanced_category("ROCPROFSYS_FILE_OUTPUT"); + _add_advanced_category("ROCPROFSYS_JSON_OUTPUT"); + _add_advanced_category("ROCPROFSYS_TREE_OUTPUT"); + _add_advanced_category("ROCPROFSYS_TEXT_OUTPUT"); + _add_advanced_category("ROCPROFSYS_DIFF_OUTPUT"); + _add_advanced_category("ROCPROFSYS_DEBUG"); + _add_advanced_category("ROCPROFSYS_ENABLE_SIGNAL_HANDLER"); + _add_advanced_category("ROCPROFSYS_FLAT_PROFILE"); + _add_advanced_category("ROCPROFSYS_INPUT_EXTENSIONS"); + _add_advanced_category("ROCPROFSYS_INPUT_PATH"); + _add_advanced_category("ROCPROFSYS_INPUT_PREFIX"); + _add_advanced_category("ROCPROFSYS_MAX_DEPTH"); + _add_advanced_category("ROCPROFSYS_MAX_WIDTH"); + _add_advanced_category("ROCPROFSYS_MEMORY_PRECISION"); + _add_advanced_category("ROCPROFSYS_MEMORY_SCIENTIFIC"); + _add_advanced_category("ROCPROFSYS_MEMORY_UNITS"); + _add_advanced_category("ROCPROFSYS_MEMORY_WIDTH"); + _add_advanced_category("ROCPROFSYS_NETWORK_INTERFACE"); + _add_advanced_category("ROCPROFSYS_NODE_COUNT"); + _add_advanced_category("ROCPROFSYS_PAPI_FAIL_ON_ERROR"); + _add_advanced_category("ROCPROFSYS_PAPI_OVERFLOW"); + _add_advanced_category("ROCPROFSYS_PAPI_MULTIPLEXING"); + _add_advanced_category("ROCPROFSYS_PAPI_QUIET"); + _add_advanced_category("ROCPROFSYS_PAPI_THREADING"); + _add_advanced_category("ROCPROFSYS_PRECISION"); + _add_advanced_category("ROCPROFSYS_SCIENTIFIC"); + _add_advanced_category("ROCPROFSYS_STRICT_CONFIG"); + _add_advanced_category("ROCPROFSYS_TIMELINE_PROFILE"); + _add_advanced_category("ROCPROFSYS_SCIENTIFIC"); + _add_advanced_category("ROCPROFSYS_TIME_FORMAT"); + _add_advanced_category("ROCPROFSYS_TIMING_PRECISION"); + _add_advanced_category("ROCPROFSYS_TIMING_SCIENTIFIC"); + _add_advanced_category("ROCPROFSYS_TIMING_UNITS"); + _add_advanced_category("ROCPROFSYS_TIMING_WIDTH"); + _add_advanced_category("ROCPROFSYS_WIDTH"); + _add_advanced_category("ROCPROFSYS_COLLAPSE_THREADS"); + _add_advanced_category("ROCPROFSYS_COLLAPSE_PROCESSES"); #if defined(TIMEMORY_USE_PAPI) int _paranoid = 2; @@ -948,11 +960,12 @@ configure_settings(bool _init) if(_paranoid > 2 && !_has_cap_sys_admin) { - OMNITRACE_BASIC_VERBOSE(0, - "/proc/sys/kernel/perf_event_paranoid has a value of %i. " - "Disabling PAPI (requires a value <= 2)...\n", - _paranoid); - OMNITRACE_BASIC_VERBOSE( + ROCPROFSYS_BASIC_VERBOSE( + 0, + "/proc/sys/kernel/perf_event_paranoid has a value of %i. " + "Disabling PAPI (requires a value <= 2)...\n", + _paranoid); + ROCPROFSYS_BASIC_VERBOSE( 0, "In order to enable PAPI support, run 'echo N | sudo tee " "/proc/sys/kernel/perf_event_paranoid' where N is <= 2\n"); trait::runtime_enabled::set(false); @@ -966,8 +979,8 @@ configure_settings(bool _init) } else { - auto _papi_events = _config->find("OMNITRACE_PAPI_EVENTS"); - _add_omnitrace_category(_papi_events); + auto _papi_events = _config->find("ROCPROFSYS_PAPI_EVENTS"); + _add_rocprofsys_category(_papi_events); std::vector _papi_choices = {}; for(auto itr : tim::papi::available_events_info()) { @@ -976,13 +989,13 @@ configure_settings(bool _init) _papi_events->second->set_choices(_papi_choices); } #else - _config->find("OMNITRACE_PAPI_EVENTS")->second->set_hidden(true); + _config->find("ROCPROFSYS_PAPI_EVENTS")->second->set_hidden(true); _config->get_papi_quiet() = true; #endif // always initialize timemory because gotcha wrappers are always used auto _cmd = tim::read_command_line(process::get_id()); - auto _cmd_env = tim::get_env("OMNITRACE_COMMAND_LINE", ""); + auto _cmd_env = tim::get_env("ROCPROFSYS_COMMAND_LINE", ""); if(!_cmd_env.empty()) _cmd = tim::delimit(_cmd_env, " "); auto _exe = (_cmd.empty()) ? "exe" : _cmd.front(); get_exe_realpath() = filepath::realpath(_exe, nullptr, false); @@ -1004,13 +1017,13 @@ configure_settings(bool _init) bool _main_proc = (_proc.size() < 2 || *_proc.begin() == _pid); for(auto&& itr : - tim::delimit(_config->get("OMNITRACE_CONFIG_FILE"), ";:")) + tim::delimit(_config->get("ROCPROFSYS_CONFIG_FILE"), ";:")) { if(_config->get_suppress_config()) continue; - OMNITRACE_BASIC_VERBOSE(1, "Reading config file %s\n", itr.c_str()); + ROCPROFSYS_BASIC_VERBOSE(1, "Reading config file %s\n", itr.c_str()); if(_config->read(itr) && _main_proc && - ((_config->get("OMNITRACE_CI") && settings::verbose() >= 0) || + ((_config->get("ROCPROFSYS_CI") && settings::verbose() >= 0) || settings::verbose() >= 1 || settings::debug())) { auto fitr = settings::format(itr, _config->get_tag()); @@ -1024,57 +1037,57 @@ configure_settings(bool _init) } if(!_iss.str().empty()) { - OMNITRACE_BASIC_VERBOSE(1, "config file '%s':\n%s\n", fitr.c_str(), - _iss.str().c_str()); + ROCPROFSYS_BASIC_VERBOSE(1, "config file '%s':\n%s\n", fitr.c_str(), + _iss.str().c_str()); } } } settings::suppress_config() = true; - if(get_env("OMNITRACE_MONOCHROME", _config->get("OMNITRACE_MONOCHROME"))) + if(get_env("ROCPROFSYS_MONOCHROME", _config->get("ROCPROFSYS_MONOCHROME"))) tim::log::monochrome() = true; if(_init) { using argparser_t = tim::argparse::argument_parser; argparser_t _parser{ _exe }; - tim::timemory_init(_cmd, _parser, "omnitrace-"); + tim::timemory_init(_cmd, _parser, "rocprofsys-"); } -#if !defined(OMNITRACE_USE_MPI) && !defined(OMNITRACE_USE_MPI_HEADERS) - set_setting_value("OMNITRACE_USE_MPIP", false); +#if !defined(ROCPROFSYS_USE_MPI) && !defined(ROCPROFSYS_USE_MPI_HEADERS) + set_setting_value("ROCPROFSYS_USE_MPIP", false); #endif _config->get_global_components() = - _config->get("OMNITRACE_TIMEMORY_COMPONENTS"); + _config->get("ROCPROFSYS_TIMEMORY_COMPONENTS"); - auto _combine_perfetto_traces = _config->find("OMNITRACE_PERFETTO_COMBINE_TRACES"); + auto _combine_perfetto_traces = _config->find("ROCPROFSYS_PERFETTO_COMBINE_TRACES"); if(!_combine_perfetto_traces->second->get_environ_updated() && _combine_perfetto_traces->second->get_config_updated()) { _combine_perfetto_traces->second->set(_config->get("collapse_processes")); } - handle_deprecated_setting("OMNITRACE_ROCM_SMI_DEVICES", "OMNITRACE_SAMPLING_GPUS"); - handle_deprecated_setting("OMNITRACE_USE_THREAD_SAMPLING", - "OMNITRACE_USE_PROCESS_SAMPLING"); - handle_deprecated_setting("OMNITRACE_OUTPUT_FILE", "OMNITRACE_PERFETTO_FILE"); - handle_deprecated_setting("OMNITRACE_USE_PERFETTO", "OMNITRACE_TRACE"); - handle_deprecated_setting("OMNITRACE_USE_TIMEMORY", "OMNITRACE_PROFILE"); + handle_deprecated_setting("ROCPROFSYS_ROCM_SMI_DEVICES", "ROCPROFSYS_SAMPLING_GPUS"); + handle_deprecated_setting("ROCPROFSYS_USE_THREAD_SAMPLING", + "ROCPROFSYS_USE_PROCESS_SAMPLING"); + handle_deprecated_setting("ROCPROFSYS_OUTPUT_FILE", "ROCPROFSYS_PERFETTO_FILE"); + handle_deprecated_setting("ROCPROFSYS_USE_PERFETTO", "ROCPROFSYS_TRACE"); + handle_deprecated_setting("ROCPROFSYS_USE_TIMEMORY", "ROCPROFSYS_PROFILE"); scope::get_fields()[scope::flat::value] = _config->get_flat_profile(); scope::get_fields()[scope::timeline::value] = _config->get_timeline_profile(); settings::suppress_parsing() = true; - settings::use_output_suffix() = _config->get("OMNITRACE_USE_PID"); + settings::use_output_suffix() = _config->get("ROCPROFSYS_USE_PID"); if(settings::use_output_suffix()) settings::default_process_suffix() = process::get_id(); #if !defined(TIMEMORY_USE_MPI) && defined(TIMEMORY_USE_MPI_HEADERS) if(tim::dmp::is_initialized()) settings::default_process_suffix() = tim::dmp::rank(); #endif - auto _dl_verbose = _config->find("OMNITRACE_DL_VERBOSE"); + auto _dl_verbose = _config->find("ROCPROFSYS_DL_VERBOSE"); if(_dl_verbose->second->get_config_updated()) tim::set_env(std::string{ _dl_verbose->first }, _dl_verbose->second->as_string(), 0); @@ -1091,7 +1104,7 @@ configure_settings(bool _init) configure_signal_handler(_config); configure_disabled_settings(_config); - OMNITRACE_BASIC_VERBOSE(2, "configuration complete\n"); + ROCPROFSYS_BASIC_VERBOSE(2, "configuration complete\n"); _settings_are_configured() = true; } @@ -1102,14 +1115,14 @@ configure_mode_settings(const std::shared_ptr& _config) auto _set = [](const std::string& _name, bool _v) { if(!set_setting_value(_name, _v)) { - OMNITRACE_BASIC_VERBOSE( + ROCPROFSYS_BASIC_VERBOSE( 4, "[configure_mode_settings] No configuration setting named '%s'...\n", _name.data()); } else { bool _changed = get_setting_value(_name).value_or(!_v) != _v; - OMNITRACE_BASIC_VERBOSE( + ROCPROFSYS_BASIC_VERBOSE( 1 && _changed, "[configure_mode_settings] Overriding %s to %s in %s mode...\n", _name.c_str(), JOIN("", std::boolalpha, _v).c_str(), @@ -1117,54 +1130,54 @@ configure_mode_settings(const std::shared_ptr& _config) } }; - auto _use_causal = get_setting_value("OMNITRACE_USE_CAUSAL"); - if(_use_causal && *_use_causal) set_env("OMNITRACE_MODE", "causal", 1); + auto _use_causal = get_setting_value("ROCPROFSYS_USE_CAUSAL"); + if(_use_causal && *_use_causal) set_env("ROCPROFSYS_MODE", "causal", 1); if(get_mode() == Mode::Coverage) { - set_default_setting_value("OMNITRACE_USE_CODE_COVERAGE", true); - _set("OMNITRACE_TRACE", false); - _set("OMNITRACE_PROFILE", false); - _set("OMNITRACE_USE_CAUSAL", false); - _set("OMNITRACE_USE_ROCM_SMI", false); - _set("OMNITRACE_USE_ROCTRACER", false); - _set("OMNITRACE_USE_ROCPROFILER", false); - _set("OMNITRACE_USE_KOKKOSP", false); - _set("OMNITRACE_USE_RCCLP", false); - _set("OMNITRACE_USE_OMPT", false); - _set("OMNITRACE_USE_SAMPLING", false); - _set("OMNITRACE_USE_PROCESS_SAMPLING", false); + set_default_setting_value("ROCPROFSYS_USE_CODE_COVERAGE", true); + _set("ROCPROFSYS_TRACE", false); + _set("ROCPROFSYS_PROFILE", false); + _set("ROCPROFSYS_USE_CAUSAL", false); + _set("ROCPROFSYS_USE_ROCM_SMI", false); + _set("ROCPROFSYS_USE_ROCTRACER", false); + _set("ROCPROFSYS_USE_ROCPROFILER", false); + _set("ROCPROFSYS_USE_KOKKOSP", false); + _set("ROCPROFSYS_USE_RCCLP", false); + _set("ROCPROFSYS_USE_OMPT", false); + _set("ROCPROFSYS_USE_SAMPLING", false); + _set("ROCPROFSYS_USE_PROCESS_SAMPLING", false); } else if(get_mode() == Mode::Causal) { - _set("OMNITRACE_USE_CAUSAL", true); - _set("OMNITRACE_TRACE", false); - _set("OMNITRACE_PROFILE", false); - _set("OMNITRACE_USE_SAMPLING", false); - _set("OMNITRACE_USE_PROCESS_SAMPLING", false); + _set("ROCPROFSYS_USE_CAUSAL", true); + _set("ROCPROFSYS_TRACE", false); + _set("ROCPROFSYS_PROFILE", false); + _set("ROCPROFSYS_USE_SAMPLING", false); + _set("ROCPROFSYS_USE_PROCESS_SAMPLING", false); } else if(get_mode() == Mode::Sampling) { - set_default_setting_value("OMNITRACE_USE_SAMPLING", true); - set_default_setting_value("OMNITRACE_USE_PROCESS_SAMPLING", true); + set_default_setting_value("ROCPROFSYS_USE_SAMPLING", true); + set_default_setting_value("ROCPROFSYS_USE_PROCESS_SAMPLING", true); } if(gpu::device_count() == 0) { -#if OMNITRACE_HIP_VERSION > 0 - OMNITRACE_BASIC_VERBOSE(1, "No HIP devices were found: disabling roctracer, " - "rocprofiler, and rocm_smi...\n"); +#if ROCPROFSYS_HIP_VERSION > 0 + ROCPROFSYS_BASIC_VERBOSE(1, "No HIP devices were found: disabling roctracer, " + "rocprofiler, and rocm_smi...\n"); #endif - _set("OMNITRACE_USE_ROCPROFILER", false); - _set("OMNITRACE_USE_ROCTRACER", false); - _set("OMNITRACE_USE_ROCM_SMI", false); + _set("ROCPROFSYS_USE_ROCPROFILER", false); + _set("ROCPROFSYS_USE_ROCTRACER", false); + _set("ROCPROFSYS_USE_ROCM_SMI", false); } - if(_config->get("OMNITRACE_USE_KOKKOSP")) + if(_config->get("ROCPROFSYS_USE_KOKKOSP")) { auto _current_kokkosp_lib = tim::get_env("KOKKOS_PROFILE_LIBRARY"); - if(_current_kokkosp_lib.find("libomnitrace-dl.so") == std::string::npos && - _current_kokkosp_lib.find("libomnitrace.so") == std::string::npos) + if(_current_kokkosp_lib.find("librocprof-sys-dl.so") == std::string::npos && + _current_kokkosp_lib.find("librocprof-sys.so") == std::string::npos) { auto _force = 0; std::string _message = {}; @@ -1174,32 +1187,32 @@ configure_mode_settings(const std::shared_ptr& _config) _message = 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); + ROCPROFSYS_BASIC_VERBOSE_F(1, "Setting KOKKOS_PROFILE_LIBRARY=%s%s\n", + "librocprof-sys.so", _message.c_str()); + tim::set_env("KOKKOS_PROFILE_LIBRARY", "librocprof-sys.so", _force); } } // recycle all subsequent thread ids threading::recycle_ids() = tim::get_env( - "OMNITRACE_RECYCLE_TIDS", !_config->get("OMNITRACE_USE_SAMPLING")); + "ROCPROFSYS_RECYCLE_TIDS", !_config->get("ROCPROFSYS_USE_SAMPLING")); if(!_config->get_enabled()) { - _set("OMNITRACE_USE_TRACE", false); - _set("OMNITRACE_PROFILE", false); - _set("OMNITRACE_USE_CAUSAL", false); - _set("OMNITRACE_USE_ROCM_SMI", false); - _set("OMNITRACE_USE_ROCTRACER", false); - _set("OMNITRACE_USE_ROCPROFILER", false); - _set("OMNITRACE_USE_KOKKOSP", false); - _set("OMNITRACE_USE_RCCLP", false); - _set("OMNITRACE_USE_OMPT", false); - _set("OMNITRACE_USE_SAMPLING", false); - _set("OMNITRACE_USE_PROCESS_SAMPLING", false); - _set("OMNITRACE_USE_CODE_COVERAGE", false); - set_setting_value("OMNITRACE_TIMEMORY_COMPONENTS", std::string{}); - set_setting_value("OMNITRACE_PAPI_EVENTS", std::string{}); + _set("ROCPROFSYS_USE_TRACE", false); + _set("ROCPROFSYS_PROFILE", false); + _set("ROCPROFSYS_USE_CAUSAL", false); + _set("ROCPROFSYS_USE_ROCM_SMI", false); + _set("ROCPROFSYS_USE_ROCTRACER", false); + _set("ROCPROFSYS_USE_ROCPROFILER", false); + _set("ROCPROFSYS_USE_KOKKOSP", false); + _set("ROCPROFSYS_USE_RCCLP", false); + _set("ROCPROFSYS_USE_OMPT", false); + _set("ROCPROFSYS_USE_SAMPLING", false); + _set("ROCPROFSYS_USE_PROCESS_SAMPLING", false); + _set("ROCPROFSYS_USE_CODE_COVERAGE", false); + set_setting_value("ROCPROFSYS_TIMEMORY_COMPONENTS", std::string{}); + set_setting_value("ROCPROFSYS_PAPI_EVENTS", std::string{}); } } @@ -1216,28 +1229,28 @@ get_signal_handler() } void -omnitrace_exit_action(int nsig) +rocprofsys_exit_action(int nsig) { tim::signals::block_signals(get_sampling_signals(), tim::signals::sigmask_scope::process); - OMNITRACE_BASIC_PRINT("Finalizing after signal %i :: %s\n", nsig, - signal_settings::str(static_cast(nsig)).c_str()); + ROCPROFSYS_BASIC_PRINT("Finalizing after signal %i :: %s\n", nsig, + signal_settings::str(static_cast(nsig)).c_str()); auto _handler = get_signal_handler().load(); if(_handler) (*_handler)(); kill(process::get_id(), nsig); } void -omnitrace_trampoline_handler(int _v) +rocprofsys_trampoline_handler(int _v) { if(get_verbose_env() >= 1) { - ::omnitrace::debug::flush(); - ::omnitrace::debug::lock _debug_lk{}; - OMNITRACE_FPRINTF_STDERR_COLOR(warning); - fprintf(::omnitrace::debug::get_file(), - "signal %i ignored (OMNITRACE_IGNORE_DYNINST_TRAMPOLINE=ON)\n", _v); - ::omnitrace::debug::flush(); + ::rocprofsys::debug::flush(); + ::rocprofsys::debug::lock _debug_lk{}; + ROCPROFSYS_FPRINTF_STDERR_COLOR(warning); + fprintf(::rocprofsys::debug::get_file(), + "signal %i ignored (ROCPROFSYS_IGNORE_DYNINST_TRAMPOLINE=ON)\n", _v); + ::rocprofsys::debug::flush(); timemory_print_demangled_backtrace<64>(); } } @@ -1269,7 +1282,7 @@ void configure_signal_handler(const std::shared_ptr& _config) { auto _ignore_dyninst_trampoline = - tim::get_env("OMNITRACE_IGNORE_DYNINST_TRAMPOLINE", false); + tim::get_env("ROCPROFSYS_IGNORE_DYNINST_TRAMPOLINE", false); // this is how dyninst looks up the env variable static auto _dyninst_trampoline_signal = getenv("DYNINST_SIGNAL_TRAMPOLINE_SIGILL") ? SIGILL : SIGTRAP; @@ -1278,7 +1291,7 @@ configure_signal_handler(const std::shared_ptr& _config) { tim::signals::disable_signal_detection(); signal_settings::enable(sys_signal::Interrupt); - signal_settings::set_exit_action(omnitrace_exit_action); + signal_settings::set_exit_action(rocprofsys_exit_action); signal_settings::check_environment(); auto default_signals = signal_settings::get_default(); for(const auto& itr : default_signals) @@ -1294,7 +1307,7 @@ configure_signal_handler(const std::shared_ptr& _config) struct sigaction _action; sigemptyset(&_action.sa_mask); _action.sa_flags = {}; - _action.sa_handler = omnitrace_trampoline_handler; + _action.sa_handler = rocprofsys_trampoline_handler; sigaction(_dyninst_trampoline_signal, &_action, nullptr); } } @@ -1302,21 +1315,21 @@ configure_signal_handler(const std::shared_ptr& _config) bool get_use_sampling_overflow() { - static auto _v = get_config()->find("OMNITRACE_SAMPLING_OVERFLOW"); + static auto _v = get_config()->find("ROCPROFSYS_SAMPLING_OVERFLOW"); return static_cast&>(*_v->second).get(); } bool get_use_sampling_realtime() { - static auto _v = get_config()->find("OMNITRACE_SAMPLING_REALTIME"); + static auto _v = get_config()->find("ROCPROFSYS_SAMPLING_REALTIME"); return static_cast&>(*_v->second).get(); } bool get_use_sampling_cputime() { - static auto _v = get_config()->find("OMNITRACE_SAMPLING_CPUTIME"); + static auto _v = get_config()->find("ROCPROFSYS_SAMPLING_CPUTIME"); return static_cast&>(*_v->second).get(); } @@ -1333,9 +1346,9 @@ std::set get_sampling_signals(int64_t) if(get_use_sampling() && !get_use_sampling_cputime() && !get_use_sampling_realtime() && !get_use_sampling_overflow()) { - OMNITRACE_VERBOSE_F(1, "sampling enabled by cputime/realtime/overflow not " - "specified. defaulting to cputime...\n"); - set_setting_value("OMNITRACE_SAMPLING_CPUTIME", true); + ROCPROFSYS_VERBOSE_F(1, "sampling enabled by cputime/realtime/overflow not " + "specified. defaulting to cputime...\n"); + set_setting_value("ROCPROFSYS_SAMPLING_CPUTIME", true); } if(get_use_sampling_cputime()) _v.emplace(get_sampling_cputime_signal()); @@ -1356,58 +1369,58 @@ configure_disabled_settings(const std::shared_ptr& _config) auto _disabled = _config->disable_category(_category); _config->enable(_opt); for(auto&& itr : _disabled) - OMNITRACE_BASIC_VERBOSE(3, "[%s=OFF] disabled option :: '%s'\n", - _opt.c_str(), itr.c_str()); + ROCPROFSYS_BASIC_VERBOSE(3, "[%s=OFF] disabled option :: '%s'\n", + _opt.c_str(), itr.c_str()); return false; } auto _enabled = _config->enable_category(_category); for(auto&& itr : _enabled) - OMNITRACE_BASIC_VERBOSE(3, "[%s=ON] enabled option :: '%s'\n", - _opt.c_str(), itr.c_str()); + ROCPROFSYS_BASIC_VERBOSE(3, "[%s=ON] enabled option :: '%s'\n", + _opt.c_str(), itr.c_str()); return true; }; - _handle_use_option("OMNITRACE_USE_SAMPLING", "sampling"); - _handle_use_option("OMNITRACE_USE_PROCESS_SAMPLING", "process_sampling"); - _handle_use_option("OMNITRACE_USE_CAUSAL", "causal"); - _handle_use_option("OMNITRACE_USE_KOKKOSP", "kokkos"); - _handle_use_option("OMNITRACE_USE_TRACE", "perfetto"); - _handle_use_option("OMNITRACE_PROFILE", "timemory"); - _handle_use_option("OMNITRACE_USE_OMPT", "ompt"); - _handle_use_option("OMNITRACE_USE_RCCLP", "rcclp"); - _handle_use_option("OMNITRACE_USE_ROCM_SMI", "rocm_smi"); - _handle_use_option("OMNITRACE_USE_ROCTRACER", "roctracer"); - _handle_use_option("OMNITRACE_USE_ROCPROFILER", "rocprofiler"); - -#if !defined(OMNITRACE_USE_ROCTRACER) || OMNITRACE_USE_ROCTRACER == 0 - _config->find("OMNITRACE_USE_ROCTRACER")->second->set_hidden(true); + _handle_use_option("ROCPROFSYS_USE_SAMPLING", "sampling"); + _handle_use_option("ROCPROFSYS_USE_PROCESS_SAMPLING", "process_sampling"); + _handle_use_option("ROCPROFSYS_USE_CAUSAL", "causal"); + _handle_use_option("ROCPROFSYS_USE_KOKKOSP", "kokkos"); + _handle_use_option("ROCPROFSYS_USE_TRACE", "perfetto"); + _handle_use_option("ROCPROFSYS_PROFILE", "timemory"); + _handle_use_option("ROCPROFSYS_USE_OMPT", "ompt"); + _handle_use_option("ROCPROFSYS_USE_RCCLP", "rcclp"); + _handle_use_option("ROCPROFSYS_USE_ROCM_SMI", "rocm_smi"); + _handle_use_option("ROCPROFSYS_USE_ROCTRACER", "roctracer"); + _handle_use_option("ROCPROFSYS_USE_ROCPROFILER", "rocprofiler"); + +#if !defined(ROCPROFSYS_USE_ROCTRACER) || ROCPROFSYS_USE_ROCTRACER == 0 + _config->find("ROCPROFSYS_USE_ROCTRACER")->second->set_hidden(true); for(const auto& itr : _config->disable_category("roctracer")) _config->find(itr)->second->set_hidden(true); #endif -#if !defined(OMNITRACE_USE_ROCPROFILER) || OMNITRACE_USE_ROCPROFILER == 0 - _config->find("OMNITRACE_USE_ROCPROFILER")->second->set_hidden(true); +#if !defined(ROCPROFSYS_USE_ROCPROFILER) || ROCPROFSYS_USE_ROCPROFILER == 0 + _config->find("ROCPROFSYS_USE_ROCPROFILER")->second->set_hidden(true); for(const auto& itr : _config->disable_category("rocprofiler")) _config->find(itr)->second->set_hidden(true); #endif -#if !defined(OMNITRACE_USE_ROCM_SMI) || OMNITRACE_USE_ROCM_SMI == 0 - _config->find("OMNITRACE_USE_ROCM_SMI")->second->set_hidden(true); +#if !defined(ROCPROFSYS_USE_ROCM_SMI) || ROCPROFSYS_USE_ROCM_SMI == 0 + _config->find("ROCPROFSYS_USE_ROCM_SMI")->second->set_hidden(true); for(const auto& itr : _config->disable_category("rocm_smi")) _config->find(itr)->second->set_hidden(true); #endif -#if defined(OMNITRACE_USE_OMPT) || OMNITRACE_USE_OMPT == 0 - _config->find("OMNITRACE_USE_OMPT")->second->set_hidden(true); +#if defined(ROCPROFSYS_USE_OMPT) || ROCPROFSYS_USE_OMPT == 0 + _config->find("ROCPROFSYS_USE_OMPT")->second->set_hidden(true); for(const auto& itr : _config->disable_category("ompt")) _config->find(itr)->second->set_hidden(true); #endif #if !defined(TIMEMORY_USE_MPI) || TIMEMORY_USE_MPI == 0 - _config->disable("OMNITRACE_PERFETTO_COMBINE_TRACES"); - _config->disable("OMNITRACE_COLLAPSE_PROCESSES"); - _config->find("OMNITRACE_PERFETTO_COMBINE_TRACES")->second->set_hidden(true); - _config->find("OMNITRACE_COLLAPSE_PROCESSES")->second->set_hidden(true); + _config->disable("ROCPROFSYS_PERFETTO_COMBINE_TRACES"); + _config->disable("ROCPROFSYS_COLLAPSE_PROCESSES"); + _config->find("ROCPROFSYS_PERFETTO_COMBINE_TRACES")->second->set_hidden(true); + _config->find("ROCPROFSYS_COLLAPSE_PROCESSES")->second->set_hidden(true); #endif _config->disable_category("throttle"); @@ -1433,23 +1446,23 @@ configure_disabled_settings(const std::shared_ptr& _config) _config->disable("flamegraph_output"); _config->disable("separator_freq"); - // exclude some timemory settings which are not relevant to omnitrace - // exact matches, e.g. OMNITRACE_BANNER + // exclude some timemory settings which are not relevant to rocprof-sys + // exact matches, e.g. ROCPROFSYS_BANNER std::string _hidden_exact_re = - "^OMNITRACE_(BANNER|DESTRUCTOR_REPORT|COMPONENTS|(GLOBAL|MPIP|NCCLP|OMPT|" + "^ROCPROFSYS_(BANNER|DESTRUCTOR_REPORT|COMPONENTS|(GLOBAL|MPIP|NCCLP|OMPT|" "PROFILER|TRACE|KOKKOS)_COMPONENTS|PYTHON_EXE|PAPI_ATTACH|PLOT_OUTPUT|SEPARATOR_" "FREQ|STACK_CLEARING|TARGET_PID|THROTTLE_(COUNT|VALUE)|(AUTO|FLAMEGRAPH)_OUTPUT|" "(ENABLE|DISABLE)_ALL_SIGNALS|ALLOW_SIGNAL_HANDLER|CTEST_NOTES|INSTRUCTION_" "ROOFLINE|ADD_SECONDARY|MAX_THREAD_BOOKMARKS)$"; - // leading matches, e.g. OMNITRACE_MPI_[A-Z_]+ + // leading matches, e.g. ROCPROFSYS_MPI_[A-Z_]+ std::string _hidden_begin_re = - "^OMNITRACE_(ERT|DART|MPI|UPCXX|ROOFLINE|CUDA|NVTX|CUPTI)_[A-Z_]+$"; + "^ROCPROFSYS_(ERT|DART|MPI|UPCXX|ROOFLINE|CUDA|NVTX|CUPTI)_[A-Z_]+$"; auto _hidden_exact = std::set{}; #if !defined(TIMEMORY_USE_CRAYPAT) - _hidden_exact.emplace("OMNITRACE_CRAYPAT"); + _hidden_exact.emplace("ROCPROFSYS_CRAYPAT"); #endif for(const auto& itr : *_config) @@ -1474,8 +1487,8 @@ handle_deprecated_setting(const std::string& _old, const std::string& _new, int if(_old_setting == _config->end()) return; - OMNITRACE_CI_THROW(_new_setting == _config->end(), - "New configuration setting not found: '%s'", _new.c_str()); + ROCPROFSYS_CI_THROW(_new_setting == _config->end(), + "New configuration setting not found: '%s'", _new.c_str()); if(_old_setting->second->get_environ_updated() || _old_setting->second->get_config_updated()) @@ -1484,13 +1497,13 @@ handle_deprecated_setting(const std::string& _old, const std::string& _new, int std::array _v = {}; _v.fill('='); _v.back() = '\0'; - OMNITRACE_BASIC_VERBOSE(_verbose, "#%s#\n", _v.data()); + ROCPROFSYS_BASIC_VERBOSE(_verbose, "#%s#\n", _v.data()); }; _separator(); - OMNITRACE_BASIC_VERBOSE(_verbose, "#\n"); - OMNITRACE_BASIC_VERBOSE(_verbose, "# DEPRECATION NOTICE:\n"); - OMNITRACE_BASIC_VERBOSE(_verbose, "# %s is deprecated!\n", _old.c_str()); - OMNITRACE_BASIC_VERBOSE(_verbose, "# Use %s instead!\n", _new.c_str()); + ROCPROFSYS_BASIC_VERBOSE(_verbose, "#\n"); + ROCPROFSYS_BASIC_VERBOSE(_verbose, "# DEPRECATION NOTICE:\n"); + ROCPROFSYS_BASIC_VERBOSE(_verbose, "# %s is deprecated!\n", _old.c_str()); + ROCPROFSYS_BASIC_VERBOSE(_verbose, "# Use %s instead!\n", _new.c_str()); if(!_new_setting->second->get_environ_updated() && !_new_setting->second->get_config_updated()) @@ -1503,15 +1516,15 @@ handle_deprecated_setting(const std::string& _old, const std::string& _new, int { std::string _cause = (_old_setting->second->get_environ_updated()) ? "environ" : "config"; - OMNITRACE_BASIC_VERBOSE(_verbose, "#\n"); - OMNITRACE_BASIC_VERBOSE(_verbose, "# %s :: '%s' -> '%s'\n", _new.c_str(), - _before.c_str(), _after.c_str()); - OMNITRACE_BASIC_VERBOSE(_verbose, "# via %s (%s)\n", _old.c_str(), - _cause.c_str()); + ROCPROFSYS_BASIC_VERBOSE(_verbose, "#\n"); + ROCPROFSYS_BASIC_VERBOSE(_verbose, "# %s :: '%s' -> '%s'\n", _new.c_str(), + _before.c_str(), _after.c_str()); + ROCPROFSYS_BASIC_VERBOSE(_verbose, "# via %s (%s)\n", _old.c_str(), + _cause.c_str()); } } - OMNITRACE_BASIC_VERBOSE(_verbose, "#\n"); + ROCPROFSYS_BASIC_VERBOSE(_verbose, "#\n"); _separator(); } } @@ -1521,17 +1534,16 @@ print_banner(std::ostream& _os) { static const char* _banner = R"banner( - ______ .___ ___. .__ __. __ .___________..______ ___ ______ _______ - / __ \ | \/ | | \ | | | | | || _ \ / \ / || ____| - | | | | | \ / | | \| | | | `---| |----`| |_) | / ^ \ | ,----'| |__ - | | | | | |\/| | | . ` | | | | | | / / /_\ \ | | | __| - | `--' | | | | | | |\ | | | | | | |\ \----./ _____ \ | `----.| |____ - \______/ |__| |__| |__| \__| |__| |__| | _| `._____/__/ \__\ \______||_______| + ____ ___ ____ __ __ ______ ______ _____ _____ __ __ ____ ____ ____ ___ _____ ___ _ _____ ____ + | _ \ / _ \ / ___| \/ | / ___\ \ / / ___|_ _| ____| \/ / ___| | _ \| _ \ / _ \| ___|_ _| | | ____| _ \ + | |_) | | | | | | |\/| | \___ \\ V /\___ \ | | | _| | |\/| \___ \ | |_) | |_) | | | | |_ | || | | _| | |_) | + | _ <| |_| | |___| | | | ___) || | ___) || | | |___| | | |___) | | __/| _ <| |_| | _| | || |___| |___| _ < + |_| \_\\___/ \____|_| |_| |____/ |_| |____/ |_| |_____|_| |_|____/ |_| |_| \_\\___/|_| |___|_____|_____|_| \_\ )banner"; std::stringstream _version_info{}; - _version_info << "omnitrace v" << OMNITRACE_VERSION_STRING; + _version_info << "rocprof-sys v" << ROCPROFSYS_VERSION_STRING; namespace join = ::timemory::join; @@ -1551,11 +1563,11 @@ print_banner(std::ostream& _os) }; auto _properties = - _generate_properties({ { "rev", OMNITRACE_GIT_REVISION }, - { "tag", OMNITRACE_GIT_DESCRIBE }, - { "", OMNITRACE_LIBRARY_ARCH }, - { "compiler", OMNITRACE_COMPILER_STRING }, - { "rocm", OMNITRACE_HIP_VERSION_COMPAT_STRING } }); + _generate_properties({ { "rev", ROCPROFSYS_GIT_REVISION }, + { "tag", ROCPROFSYS_GIT_DESCRIBE }, + { "", ROCPROFSYS_LIBRARY_ARCH }, + { "compiler", ROCPROFSYS_COMPILER_STRING }, + { "rocm", ROCPROFSYS_HIP_VERSION_COMPAT_STRING } }); // () if(!_properties.empty()) @@ -1570,12 +1582,12 @@ print_settings( std::ostream& _ros, std::function&)>&& _filter) { - OMNITRACE_CONDITIONAL_BASIC_PRINT(true, "configuration:\n"); + ROCPROFSYS_CONDITIONAL_BASIC_PRINT(true, "configuration:\n"); std::stringstream _os{}; - bool _print_desc = get_debug() || tim::get_env("OMNITRACE_SETTINGS_DESC", false); - bool _md = tim::get_env("OMNITRACE_SETTINGS_DESC_MARKDOWN", false); + bool _print_desc = get_debug() || tim::get_env("ROCPROFSYS_SETTINGS_DESC", false); + bool _md = tim::get_env("ROCPROFSYS_SETTINGS_DESC_MARKDOWN", false); constexpr size_t nfields = 3; using str_array_t = std::array; @@ -1602,15 +1614,15 @@ print_settings( std::sort(_data.begin(), _data.end(), [](const auto& lhs, const auto& rhs) { auto _npos = std::string::npos; - // OMNITRACE_CONFIG_FILE always first - if(lhs.at(0) == "OMNITRACE_MODE") return true; - if(rhs.at(0) == "OMNITRACE_MODE") return false; - // OMNITRACE_CONFIG_FILE always second - if(lhs.at(0).find("OMNITRACE_CONFIG") != _npos) return true; - if(rhs.at(0).find("OMNITRACE_CONFIG") != _npos) return false; - // OMNITRACE_USE_* prioritized - auto _lhs_use = lhs.at(0).find("OMNITRACE_USE_"); - auto _rhs_use = rhs.at(0).find("OMNITRACE_USE_"); + // ROCPROFSYS_CONFIG_FILE always first + if(lhs.at(0) == "ROCPROFSYS_MODE") return true; + if(rhs.at(0) == "ROCPROFSYS_MODE") return false; + // ROCPROFSYS_CONFIG_FILE always second + if(lhs.at(0).find("ROCPROFSYS_CONFIG") != _npos) return true; + if(rhs.at(0).find("ROCPROFSYS_CONFIG") != _npos) return false; + // ROCPROFSYS_USE_* prioritized + auto _lhs_use = lhs.at(0).find("ROCPROFSYS_USE_"); + auto _rhs_use = rhs.at(0).find("ROCPROFSYS_USE_"); if(_lhs_use != _rhs_use && _lhs_use < _rhs_use) return true; if(_lhs_use != _rhs_use && _lhs_use > _rhs_use) return false; // alphabetical sort @@ -1677,22 +1689,22 @@ print_settings(bool _include_env) if(dmp::rank() > 0) return; // generic filter for filtering relevant options - auto _is_omnitrace_option = [](const auto& _v, const auto&) { - return (_v.find("OMNITRACE_") == 0); + auto _is_rocprofsys_option = [](const auto& _v, const auto&) { + return (_v.find("ROCPROFSYS_") == 0); }; if(_include_env) { std::cerr << tim::log::info; - tim::print_env(std::cerr, [_is_omnitrace_option](const std::string& _v) { - auto _is_omni_opt = _is_omnitrace_option(_v, std::set{}); + tim::print_env(std::cerr, [_is_rocprofsys_option](const std::string& _v) { + auto _is_omni_opt = _is_rocprofsys_option(_v, std::set{}); if(settings::verbose() >= 2 || settings::debug()) return _is_omni_opt; - return (_is_omni_opt && _v.find("OMNITRACE_SIGNAL_") != 0); + return (_is_omni_opt && _v.find("ROCPROFSYS_SIGNAL_") != 0); }); std::cerr << tim::log::flush; } - print_settings(std::cerr, _is_omnitrace_option); + print_settings(std::cerr, _is_rocprofsys_option); fprintf(stderr, "\n"); } @@ -1719,7 +1731,7 @@ get_exe_realpath() std::string get_config_file() { - static auto _v = get_config()->find("OMNITRACE_CONFIG_FILE"); + static auto _v = get_config()->find("ROCPROFSYS_CONFIG_FILE"); return static_cast&>(*_v->second).get(); } @@ -1729,7 +1741,7 @@ get_mode() if(!settings_are_configured()) { auto _mode = tim::get_env_choice( - "OMNITRACE_MODE", "trace", { "trace", "sampling", "causal", "coverage" }); + "ROCPROFSYS_MODE", "trace", { "trace", "sampling", "causal", "coverage" }); if(_mode == "sampling") return Mode::Sampling; else if(_mode == "causal") @@ -1743,7 +1755,7 @@ get_mode() { "causal", Mode::Causal }, { "sampling", Mode::Sampling }, { "coverage", Mode::Coverage } }; - static auto _v = get_config()->find("OMNITRACE_MODE"); + static auto _v = get_config()->find("ROCPROFSYS_MODE"); try { return _m.at(static_cast&>(*_v->second).get()); @@ -1754,8 +1766,8 @@ get_mode() for(const auto& itr : _v->second->get_choices()) _ss << ", " << itr; auto _msg = (_ss.str().length() > 2) ? _ss.str().substr(2) : std::string{}; - OMNITRACE_THROW("[%s] invalid mode %s. Choices: %s\n", __FUNCTION__, - _mode.c_str(), _msg.c_str()); + ROCPROFSYS_THROW("[%s] invalid mode %s. Choices: %s\n", __FUNCTION__, + _mode.c_str(), _msg.c_str()); } return Mode::Trace; } @@ -1779,34 +1791,34 @@ get_debug_env() { return (settings_are_configured()) ? get_debug() - : tim::get_env("OMNITRACE_DEBUG", false, false); + : tim::get_env("ROCPROFSYS_DEBUG", false, false); } bool get_is_continuous_integration() { if(!settings_are_configured()) - return tim::get_env("OMNITRACE_CI", false, false); - static auto _v = get_config()->find("OMNITRACE_CI"); + return tim::get_env("ROCPROFSYS_CI", false, false); + static auto _v = get_config()->find("ROCPROFSYS_CI"); return static_cast&>(*_v->second).get(); } bool get_debug_init() { - return tim::get_env("OMNITRACE_DEBUG_INIT", get_debug_env()); + return tim::get_env("ROCPROFSYS_DEBUG_INIT", get_debug_env()); } bool get_debug_finalize() { - return tim::get_env("OMNITRACE_DEBUG_FINALIZE", false); + return tim::get_env("ROCPROFSYS_DEBUG_FINALIZE", false); } bool get_debug() { - static auto _v = get_config()->find("OMNITRACE_DEBUG"); + static auto _v = get_config()->find("ROCPROFSYS_DEBUG"); return static_cast&>(*_v->second).get(); } @@ -1814,7 +1826,7 @@ bool get_debug_sampling() { static bool _v = - tim::get_env("OMNITRACE_DEBUG_SAMPLING", + tim::get_env("ROCPROFSYS_DEBUG_SAMPLING", (settings_are_configured() ? get_debug() : get_debug_env())); return _v; } @@ -1822,43 +1834,44 @@ get_debug_sampling() int get_verbose_env() { - return (settings_are_configured()) ? get_verbose() - : tim::get_env("OMNITRACE_VERBOSE", 0, false); + return (settings_are_configured()) + ? get_verbose() + : tim::get_env("ROCPROFSYS_VERBOSE", 0, false); } int get_verbose() { - static auto _v = get_config()->find("OMNITRACE_VERBOSE"); + static auto _v = get_config()->find("ROCPROFSYS_VERBOSE"); return static_cast&>(*_v->second).get(); } bool& get_use_perfetto() { - static auto _v = get_config()->find("OMNITRACE_TRACE"); + static auto _v = get_config()->find("ROCPROFSYS_TRACE"); return static_cast&>(*_v->second).get(); } bool& get_use_timemory() { - static auto _v = get_config()->find("OMNITRACE_PROFILE"); + static auto _v = get_config()->find("ROCPROFSYS_PROFILE"); return static_cast&>(*_v->second).get(); } bool& get_use_causal() { - static auto _v = get_config()->find("OMNITRACE_USE_CAUSAL"); + static auto _v = get_config()->find("ROCPROFSYS_USE_CAUSAL"); return static_cast&>(*_v->second).get(); } bool get_use_roctracer() { -#if defined(OMNITRACE_USE_ROCTRACER) && OMNITRACE_USE_ROCTRACER > 0 - static auto _v = get_config()->find("OMNITRACE_USE_ROCTRACER"); +#if defined(ROCPROFSYS_USE_ROCTRACER) && ROCPROFSYS_USE_ROCTRACER > 0 + static auto _v = get_config()->find("ROCPROFSYS_USE_ROCTRACER"); return static_cast&>(*_v->second).get(); #else return false; @@ -1868,8 +1881,8 @@ get_use_roctracer() bool get_perfetto_roctracer_per_stream() { -#if defined(OMNITRACE_USE_ROCTRACER) && OMNITRACE_USE_ROCTRACER > 0 - static auto _v = get_config()->find("OMNITRACE_PERFETTO_ROCTRACER_PER_STREAM"); +#if defined(ROCPROFSYS_USE_ROCTRACER) && ROCPROFSYS_USE_ROCTRACER > 0 + static auto _v = get_config()->find("ROCPROFSYS_PERFETTO_ROCTRACER_PER_STREAM"); return static_cast&>(*_v->second).get(); #else return false; @@ -1879,8 +1892,8 @@ get_perfetto_roctracer_per_stream() bool get_use_rocprofiler() { -#if defined(OMNITRACE_USE_ROCPROFILER) && OMNITRACE_USE_ROCPROFILER > 0 - static auto _v = get_config()->find("OMNITRACE_USE_ROCPROFILER"); +#if defined(ROCPROFSYS_USE_ROCPROFILER) && ROCPROFSYS_USE_ROCPROFILER > 0 + static auto _v = get_config()->find("ROCPROFSYS_USE_ROCPROFILER"); return static_cast&>(*_v->second).get(); #else return false; @@ -1890,8 +1903,8 @@ get_use_rocprofiler() bool get_use_rocm_smi() { -#if defined(OMNITRACE_USE_ROCM_SMI) && OMNITRACE_USE_ROCM_SMI > 0 - static auto _v = get_config()->find("OMNITRACE_USE_ROCM_SMI"); +#if defined(ROCPROFSYS_USE_ROCM_SMI) && ROCPROFSYS_USE_ROCM_SMI > 0 + static auto _v = get_config()->find("ROCPROFSYS_USE_ROCM_SMI"); return static_cast&>(*_v->second).get(); #else return false; @@ -1901,8 +1914,8 @@ get_use_rocm_smi() bool get_use_roctx() { -#if defined(OMNITRACE_USE_ROCTRACER) && OMNITRACE_USE_ROCTRACER > 0 - static auto _v = get_config()->find("OMNITRACE_USE_ROCTX"); +#if defined(ROCPROFSYS_USE_ROCTRACER) && ROCPROFSYS_USE_ROCTRACER > 0 + static auto _v = get_config()->find("ROCPROFSYS_USE_ROCTX"); return static_cast&>(*_v->second).get(); #else return false; @@ -1913,11 +1926,11 @@ bool& get_use_sampling() { #if defined(TIMEMORY_USE_LIBUNWIND) - static auto _v = get_config()->find("OMNITRACE_USE_SAMPLING"); + static auto _v = get_config()->find("ROCPROFSYS_USE_SAMPLING"); return static_cast&>(*_v->second).get(); #else - OMNITRACE_THROW( - "Error! sampling was enabled but omnitrace was not built with libunwind support"); + ROCPROFSYS_THROW("Error! sampling was enabled but rocprof-sys was not built with " + "libunwind support"); static bool _v = false; return _v; #endif @@ -1926,35 +1939,35 @@ get_use_sampling() bool& get_use_process_sampling() { - static auto _v = get_config()->find("OMNITRACE_USE_PROCESS_SAMPLING"); + static auto _v = get_config()->find("ROCPROFSYS_USE_PROCESS_SAMPLING"); return static_cast&>(*_v->second).get(); } bool& get_use_pid() { - static auto _v = get_config()->find("OMNITRACE_USE_PID"); + static auto _v = get_config()->find("ROCPROFSYS_USE_PID"); return static_cast&>(*_v->second).get(); } bool& get_use_mpip() { - static auto _v = get_config()->find("OMNITRACE_USE_MPIP"); + static auto _v = get_config()->find("ROCPROFSYS_USE_MPIP"); return static_cast&>(*_v->second).get(); } bool get_use_kokkosp() { - static auto _v = get_config()->find("OMNITRACE_USE_KOKKOSP"); + static auto _v = get_config()->find("ROCPROFSYS_USE_KOKKOSP"); return static_cast&>(*_v->second).get(); } bool get_use_kokkosp_kernel_logger() { - static auto _v = get_config()->find("OMNITRACE_KOKKOSP_KERNEL_LOGGER"); + static auto _v = get_config()->find("ROCPROFSYS_KOKKOSP_KERNEL_LOGGER"); return static_cast&>(*_v->second).get(); } @@ -1962,7 +1975,7 @@ bool get_use_ompt() { #if defined(TIMEMORY_USE_OMPT) - static auto _v = get_config()->find("OMNITRACE_USE_OMPT"); + static auto _v = get_config()->find("ROCPROFSYS_USE_OMPT"); return static_cast&>(*_v->second).get(); #else return false; @@ -1972,91 +1985,91 @@ get_use_ompt() bool get_use_code_coverage() { - static auto _v = get_config()->find("OMNITRACE_USE_CODE_COVERAGE"); + static auto _v = get_config()->find("ROCPROFSYS_USE_CODE_COVERAGE"); return static_cast&>(*_v->second).get(); } bool get_use_rcclp() { - static auto _v = get_config()->find("OMNITRACE_USE_RCCLP"); + static auto _v = get_config()->find("ROCPROFSYS_USE_RCCLP"); return static_cast&>(*_v->second).get(); } size_t get_num_threads_hint() { - static auto _v = get_config()->find("OMNITRACE_NUM_THREADS_HINT"); + static auto _v = get_config()->find("ROCPROFSYS_NUM_THREADS_HINT"); return static_cast&>(*_v->second).get(); } bool get_sampling_keep_internal() { - static auto _v = get_config()->find("OMNITRACE_SAMPLING_KEEP_INTERNAL"); + static auto _v = get_config()->find("ROCPROFSYS_SAMPLING_KEEP_INTERNAL"); return static_cast&>(*_v->second).get(); } int get_sampling_overflow_signal() { - static auto _v = get_config()->find("OMNITRACE_SAMPLING_OVERFLOW_SIGNAL"); + static auto _v = get_config()->find("ROCPROFSYS_SAMPLING_OVERFLOW_SIGNAL"); return static_cast&>(*_v->second).get(); } int get_sampling_realtime_signal() { - static auto _v = get_config()->find("OMNITRACE_SAMPLING_REALTIME_SIGNAL"); + static auto _v = get_config()->find("ROCPROFSYS_SAMPLING_REALTIME_SIGNAL"); return static_cast&>(*_v->second).get(); } int get_sampling_cputime_signal() { - static auto _v = get_config()->find("OMNITRACE_SAMPLING_CPUTIME_SIGNAL"); + static auto _v = get_config()->find("ROCPROFSYS_SAMPLING_CPUTIME_SIGNAL"); return static_cast&>(*_v->second).get(); } bool get_trace_hip_api() { - static auto _v = get_config()->find("OMNITRACE_ROCTRACER_HIP_API"); + static auto _v = get_config()->find("ROCPROFSYS_ROCTRACER_HIP_API"); return static_cast&>(*_v->second).get(); } bool get_trace_hip_activity() { - static auto _v = get_config()->find("OMNITRACE_ROCTRACER_HIP_ACTIVITY"); + static auto _v = get_config()->find("ROCPROFSYS_ROCTRACER_HIP_ACTIVITY"); return static_cast&>(*_v->second).get(); } bool get_trace_hsa_api() { - static auto _v = get_config()->find("OMNITRACE_ROCTRACER_HSA_API"); + static auto _v = get_config()->find("ROCPROFSYS_ROCTRACER_HSA_API"); return static_cast&>(*_v->second).get(); } bool get_trace_hsa_activity() { - static auto _v = get_config()->find("OMNITRACE_ROCTRACER_HSA_ACTIVITY"); + static auto _v = get_config()->find("ROCPROFSYS_ROCTRACER_HSA_ACTIVITY"); return static_cast&>(*_v->second).get(); } size_t get_perfetto_shmem_size_hint() { - static auto _v = get_config()->find("OMNITRACE_PERFETTO_SHMEM_SIZE_HINT_KB"); + static auto _v = get_config()->find("ROCPROFSYS_PERFETTO_SHMEM_SIZE_HINT_KB"); return static_cast&>(*_v->second).get(); } size_t get_perfetto_buffer_size() { - static auto _v = get_config()->find("OMNITRACE_PERFETTO_BUFFER_SIZE_KB"); + static auto _v = get_config()->find("ROCPROFSYS_PERFETTO_BUFFER_SIZE_KB"); return static_cast&>(*_v->second).get(); } @@ -2064,7 +2077,7 @@ bool get_perfetto_combined_traces() { #if defined(TIMEMORY_USE_MPI) && TIMEMORY_USE_MPI > 0 - static auto _v = get_config()->find("OMNITRACE_PERFETTO_COMBINE_TRACES"); + static auto _v = get_config()->find("ROCPROFSYS_PERFETTO_COMBINE_TRACES"); return static_cast&>(*_v->second).get(); #else return false; @@ -2074,7 +2087,7 @@ get_perfetto_combined_traces() std::string get_perfetto_fill_policy() { - static auto _v = get_config()->find("OMNITRACE_PERFETTO_FILL_POLICY"); + static auto _v = get_config()->find("ROCPROFSYS_PERFETTO_FILL_POLICY"); return static_cast&>(*_v->second).get(); } @@ -2098,8 +2111,8 @@ get_category_config() return _ret; }; - auto _enabled = _parse(get_config()->find("OMNITRACE_ENABLE_CATEGORIES")); - auto _disabled = _parse(get_config()->find("OMNITRACE_DISABLE_CATEGORIES")); + auto _enabled = _parse(get_config()->find("ROCPROFSYS_ENABLE_CATEGORIES")); + auto _disabled = _parse(get_config()->find("ROCPROFSYS_DISABLE_CATEGORIES")); if(_enabled.empty() && _disabled.empty()) { @@ -2121,14 +2134,15 @@ get_category_config() } else { - OMNITRACE_ABORT("Error! Conflicting options OMNITRACE_ENABLE_CATEGORIES and " - "OMNITRACE_DISABLE_CATEGORIES were both provided."); + ROCPROFSYS_ABORT( + "Error! Conflicting options ROCPROFSYS_ENABLE_CATEGORIES and " + "ROCPROFSYS_DISABLE_CATEGORIES were both provided."); } - OMNITRACE_CI_THROW(_enabled.size() + _disabled.size() != _avail.size(), - "Error! Internal error for categories: %zu (enabled) + %zu " - "(disabled) != %zu (total)\n", - _enabled.size(), _disabled.size(), _avail.size()); + ROCPROFSYS_CI_THROW(_enabled.size() + _disabled.size() != _avail.size(), + "Error! Internal error for categories: %zu (enabled) + %zu " + "(disabled) != %zu (total)\n", + _enabled.size(), _disabled.size(), _avail.size()); return std::make_pair(_enabled, _disabled); }(); @@ -2151,14 +2165,14 @@ get_disabled_categories() bool get_perfetto_annotations() { - static auto _v = get_config()->find("OMNITRACE_PERFETTO_ANNOTATIONS"); + static auto _v = get_config()->find("ROCPROFSYS_PERFETTO_ANNOTATIONS"); return static_cast&>(*_v->second).get(); } uint64_t get_thread_pool_size() { - static uint64_t _v = get_config()->get("OMNITRACE_THREAD_POOL_SIZE"); + static uint64_t _v = get_config()->get("ROCPROFSYS_THREAD_POOL_SIZE"); return _v; } @@ -2166,7 +2180,7 @@ std::string get_trace_hsa_api_types() { static std::string _v = - get_config()->get("OMNITRACE_ROCTRACER_HSA_API_TYPES"); + get_config()->get("ROCPROFSYS_ROCTRACER_HSA_API_TYPES"); return _v; } @@ -2174,14 +2188,14 @@ std::string& get_perfetto_backend() { // select inprocess, system, or both (i.e. all) - static auto _v = get_config()->find("OMNITRACE_PERFETTO_BACKEND"); + static auto _v = get_config()->find("ROCPROFSYS_PERFETTO_BACKEND"); return static_cast&>(*_v->second).get(); } std::string get_perfetto_output_filename() { - static auto _v = get_config()->find("OMNITRACE_PERFETTO_FILE"); + static auto _v = get_config()->find("ROCPROFSYS_PERFETTO_FILE"); auto _val = static_cast&>(*_v->second).get(); auto _pos_dir = _val.find_last_of('/'); auto _dir = std::string{}; @@ -2210,14 +2224,14 @@ get_perfetto_output_filename() double get_sampling_freq() { - static auto _v = get_config()->find("OMNITRACE_SAMPLING_FREQ"); + static auto _v = get_config()->find("ROCPROFSYS_SAMPLING_FREQ"); return static_cast&>(*_v->second).get(); } double get_sampling_cputime_freq() { - static auto _v = get_config()->find("OMNITRACE_SAMPLING_CPUTIME_FREQ"); + static auto _v = get_config()->find("ROCPROFSYS_SAMPLING_CPUTIME_FREQ"); auto& _val = static_cast&>(*_v->second).get(); if(_val <= 0.0) _val = get_sampling_freq(); return _val; @@ -2226,7 +2240,7 @@ get_sampling_cputime_freq() double get_sampling_realtime_freq() { - static auto _v = get_config()->find("OMNITRACE_SAMPLING_REALTIME_FREQ"); + static auto _v = get_config()->find("ROCPROFSYS_SAMPLING_REALTIME_FREQ"); auto& _val = static_cast&>(*_v->second).get(); if(_val <= 0.0) _val = get_sampling_freq(); return _val; @@ -2235,7 +2249,7 @@ get_sampling_realtime_freq() double get_sampling_overflow_freq() { - static auto _v = get_config()->find("OMNITRACE_SAMPLING_OVERFLOW_FREQ"); + static auto _v = get_config()->find("ROCPROFSYS_SAMPLING_OVERFLOW_FREQ"); auto& _val = static_cast&>(*_v->second).get(); if(_val <= 0.0) _val = get_sampling_freq(); return _val; @@ -2244,14 +2258,14 @@ get_sampling_overflow_freq() double get_sampling_delay() { - static auto _v = get_config()->find("OMNITRACE_SAMPLING_DELAY"); + static auto _v = get_config()->find("ROCPROFSYS_SAMPLING_DELAY"); return static_cast&>(*_v->second).get(); } double get_sampling_cputime_delay() { - static auto _v = get_config()->find("OMNITRACE_SAMPLING_CPUTIME_DELAY"); + static auto _v = get_config()->find("ROCPROFSYS_SAMPLING_CPUTIME_DELAY"); auto& _val = static_cast&>(*_v->second).get(); if(_val <= 0.0) _val = get_sampling_delay(); return _val; @@ -2260,7 +2274,7 @@ get_sampling_cputime_delay() double get_sampling_realtime_delay() { - static auto _v = get_config()->find("OMNITRACE_SAMPLING_REALTIME_DELAY"); + static auto _v = get_config()->find("ROCPROFSYS_SAMPLING_REALTIME_DELAY"); auto& _val = static_cast&>(*_v->second).get(); if(_val <= 0.0) _val = get_sampling_delay(); return _val; @@ -2269,21 +2283,21 @@ get_sampling_realtime_delay() double get_sampling_duration() { - static auto _v = get_config()->find("OMNITRACE_SAMPLING_DURATION"); + static auto _v = get_config()->find("ROCPROFSYS_SAMPLING_DURATION"); return static_cast&>(*_v->second).get(); } std::string get_sampling_cpus() { - auto _v = get_config()->find("OMNITRACE_SAMPLING_CPUS"); + auto _v = get_config()->find("ROCPROFSYS_SAMPLING_CPUS"); return static_cast&>(*_v->second).get(); } std::set get_sampling_tids() { - auto _v = get_config()->find("OMNITRACE_SAMPLING_TIDS"); + auto _v = get_config()->find("ROCPROFSYS_SAMPLING_TIDS"); return parse_numeric_range<>( static_cast&>(*_v->second).get(), "thread IDs", 1L); } @@ -2291,7 +2305,7 @@ get_sampling_tids() std::set get_sampling_cputime_tids() { - auto _v = get_config()->find("OMNITRACE_SAMPLING_CPUTIME_TIDS"); + auto _v = get_config()->find("ROCPROFSYS_SAMPLING_CPUTIME_TIDS"); return parse_numeric_range<>( static_cast&>(*_v->second).get(), "thread IDs", 1L); } @@ -2299,7 +2313,7 @@ get_sampling_cputime_tids() std::set get_sampling_realtime_tids() { - auto _v = get_config()->find("OMNITRACE_SAMPLING_REALTIME_TIDS"); + auto _v = get_config()->find("ROCPROFSYS_SAMPLING_REALTIME_TIDS"); return parse_numeric_range<>( static_cast&>(*_v->second).get(), "thread IDs", 1L); } @@ -2307,7 +2321,7 @@ get_sampling_realtime_tids() std::set get_sampling_overflow_tids() { - auto _v = get_config()->find("OMNITRACE_SAMPLING_OVERFLOW_TIDS"); + auto _v = get_config()->find("ROCPROFSYS_SAMPLING_OVERFLOW_TIDS"); return parse_numeric_range<>( static_cast&>(*_v->second).get(), "thread IDs", 1L); } @@ -2315,21 +2329,21 @@ get_sampling_overflow_tids() bool get_sampling_include_inlines() { - static auto _v = get_config()->find("OMNITRACE_SAMPLING_INCLUDE_INLINES"); + static auto _v = get_config()->find("ROCPROFSYS_SAMPLING_INCLUDE_INLINES"); return static_cast&>(*_v->second).get(); } size_t get_sampling_allocator_size() { - static auto _v = get_config()->find("OMNITRACE_SAMPLING_ALLOCATOR_SIZE"); + static auto _v = get_config()->find("ROCPROFSYS_SAMPLING_ALLOCATOR_SIZE"); return std::max(static_cast&>(*_v->second).get(), 1); } double get_process_sampling_freq() { - static auto _v = get_config()->find("OMNITRACE_PROCESS_SAMPLING_FREQ"); + static auto _v = get_config()->find("ROCPROFSYS_PROCESS_SAMPLING_FREQ"); auto _val = std::min(static_cast&>(*_v->second).get(), 1000.0); if(_val < 1.0e-9) return std::min(get_sampling_freq(), 100.0); @@ -2339,15 +2353,15 @@ get_process_sampling_freq() double get_process_sampling_duration() { - static auto _v = get_config()->find("OMNITRACE_PROCESS_SAMPLING_DURATION"); + static auto _v = get_config()->find("ROCPROFSYS_PROCESS_SAMPLING_DURATION"); return static_cast&>(*_v->second).get(); } std::string get_sampling_gpus() { -#if defined(OMNITRACE_USE_ROCM_SMI) && OMNITRACE_USE_ROCM_SMI > 0 - static auto _v = get_config()->find("OMNITRACE_SAMPLING_GPUS"); +#if defined(ROCPROFSYS_USE_ROCM_SMI) && ROCPROFSYS_USE_ROCM_SMI > 0 + static auto _v = get_config()->find("ROCPROFSYS_SAMPLING_GPUS"); return static_cast&>(*_v->second).get(); #else return std::string{}; @@ -2357,42 +2371,42 @@ get_sampling_gpus() bool get_trace_thread_locks() { - static auto _v = get_config()->find("OMNITRACE_TRACE_THREAD_LOCKS"); + static auto _v = get_config()->find("ROCPROFSYS_TRACE_THREAD_LOCKS"); return static_cast&>(*_v->second).get(); } std::string get_rocm_events() { - static auto _v = get_config()->find("OMNITRACE_ROCM_EVENTS"); + static auto _v = get_config()->find("ROCPROFSYS_ROCM_EVENTS"); return static_cast&>(*_v->second).get(); } bool get_trace_thread_rwlocks() { - static auto _v = get_config()->find("OMNITRACE_TRACE_THREAD_RW_LOCKS"); + static auto _v = get_config()->find("ROCPROFSYS_TRACE_THREAD_RW_LOCKS"); return static_cast&>(*_v->second).get(); } bool get_trace_thread_spin_locks() { - static auto _v = get_config()->find("OMNITRACE_TRACE_THREAD_SPIN_LOCKS"); + static auto _v = get_config()->find("ROCPROFSYS_TRACE_THREAD_SPIN_LOCKS"); return static_cast&>(*_v->second).get(); } bool get_trace_thread_barriers() { - static auto _v = get_config()->find("OMNITRACE_TRACE_THREAD_BARRIERS"); + static auto _v = get_config()->find("ROCPROFSYS_TRACE_THREAD_BARRIERS"); return static_cast&>(*_v->second).get(); } bool get_trace_thread_join() { - static auto _v = get_config()->find("OMNITRACE_TRACE_THREAD_JOIN"); + static auto _v = get_config()->find("ROCPROFSYS_TRACE_THREAD_JOIN"); return static_cast&>(*_v->second).get(); } @@ -2400,7 +2414,7 @@ bool get_debug_tid() { static auto _vlist = parse_numeric_range>( - tim::get_env("OMNITRACE_DEBUG_TIDS", ""), "debug tids", 1L); + tim::get_env("ROCPROFSYS_DEBUG_TIDS", ""), "debug tids", 1L); static thread_local bool _v = _vlist.empty() || _vlist.count(tim::threading::get_id()) > 0; return _v; @@ -2410,7 +2424,7 @@ bool get_debug_pid() { static auto _vlist = parse_numeric_range>( - tim::get_env("OMNITRACE_DEBUG_PIDS", ""), "debug pids", 1L); + tim::get_env("ROCPROFSYS_DEBUG_PIDS", ""), "debug pids", 1L); static bool _v = _vlist.empty() || _vlist.count(tim::process::get_id()) > 0 || _vlist.count(dmp::rank()) > 0; return _v; @@ -2419,14 +2433,14 @@ get_debug_pid() bool get_use_tmp_files() { - static auto _v = get_config()->find("OMNITRACE_USE_TEMPORARY_FILES"); + static auto _v = get_config()->find("ROCPROFSYS_USE_TEMPORARY_FILES"); return static_cast&>(*_v->second).get(); } std::string get_tmpdir() { - static auto _v = get_config()->find("OMNITRACE_TMPDIR"); + static auto _v = get_config()->find("ROCPROFSYS_TMPDIR"); return static_cast&>(*_v->second).get(); } @@ -2443,7 +2457,7 @@ tmp_file::~tmp_file() bool tmp_file::open(std::ios::openmode _mode) { - OMNITRACE_BASIC_VERBOSE(2, "Opening temporary file '%s'...\n", filename.c_str()); + ROCPROFSYS_BASIC_VERBOSE(2, "Opening temporary file '%s'...\n", filename.c_str()); if(!filepath::exists(filename)) { @@ -2460,7 +2474,7 @@ tmp_file::open(std::ios::openmode _mode) bool tmp_file::fopen(const char* _mode) { - OMNITRACE_BASIC_VERBOSE(2, "Opening temporary file '%s'...\n", filename.c_str()); + ROCPROFSYS_BASIC_VERBOSE(2, "Opening temporary file '%s'...\n", filename.c_str()); if(!filepath::exists(filename)) { @@ -2528,7 +2542,8 @@ tmp_file::remove() close(); if(filepath::exists(filename)) { - OMNITRACE_BASIC_VERBOSE(2, "Removing temporary file '%s'...\n", filename.c_str()); + ROCPROFSYS_BASIC_VERBOSE(2, "Removing temporary file '%s'...\n", + filename.c_str()); auto _ret = ::remove(filename.c_str()); return (_ret == 0); } @@ -2574,9 +2589,9 @@ get_tmp_file(std::string _basename, std::string _ext) if(_fname.empty() || _fname.front() != '/') { - OMNITRACE_THROW("Error! temporary file '%s' (based on '%s.%s') is either empty " - "or is not an absolute path", - _fname.c_str(), _basename.c_str(), _ext.c_str()); + ROCPROFSYS_THROW("Error! temporary file '%s' (based on '%s.%s') is either empty " + "or is not an absolute path", + _fname.c_str(), _basename.c_str(), _ext.c_str()); } auto itr = _existing_files.find(_fname); if(itr != _existing_files.end()) return itr->second; @@ -2595,18 +2610,18 @@ get_causal_backend() { "timer", CausalBackend::Timer }, }; - auto _v = get_config()->find("OMNITRACE_CAUSAL_BACKEND"); + auto _v = get_config()->find("ROCPROFSYS_CAUSAL_BACKEND"); try { return _m.at(static_cast&>(*_v->second).get()); } catch(std::runtime_error& _e) { auto _mode = static_cast&>(*_v->second).get(); - OMNITRACE_THROW("[%s] invalid causal backend %s. Choices: %s\n", __FUNCTION__, - _mode.c_str(), - timemory::join::join(timemory::join::array_config{ ", ", "", "" }, - _v->second->get_choices()) - .c_str()); + ROCPROFSYS_THROW( + "[%s] invalid causal backend %s. Choices: %s\n", __FUNCTION__, _mode.c_str(), + timemory::join::join(timemory::join::array_config{ ", ", "", "" }, + _v->second->get_choices()) + .c_str()); } return CausalBackend::Auto; } @@ -2616,8 +2631,8 @@ get_causal_mode() { if(!settings_are_configured()) { - auto _mode = tim::get_env_choice("OMNITRACE_CAUSAL_MODE", "function", - { "line", "function" }); + auto _mode = tim::get_env_choice("ROCPROFSYS_CAUSAL_MODE", + "function", { "line", "function" }); if(_mode == "line") return CausalMode::Line; return CausalMode::Function; } @@ -2627,14 +2642,14 @@ get_causal_mode() { "func", CausalMode::Function }, { "function", CausalMode::Function } }; - auto _v = get_config()->find("OMNITRACE_CAUSAL_MODE"); + auto _v = get_config()->find("ROCPROFSYS_CAUSAL_MODE"); try { return _m.at(static_cast&>(*_v->second).get()); } catch(std::runtime_error& _e) { auto _mode = static_cast&>(*_v->second).get(); - OMNITRACE_THROW( + ROCPROFSYS_THROW( "[%s] invalid causal mode %s. Choices: %s\n", __FUNCTION__, _mode.c_str(), timemory::join::join(timemory::join::array_config{ ", ", "", "" }, _v->second->get_choices()) @@ -2648,14 +2663,14 @@ get_causal_mode() bool get_causal_end_to_end() { - static auto _v = get_config()->find("OMNITRACE_CAUSAL_END_TO_END"); + static auto _v = get_config()->find("ROCPROFSYS_CAUSAL_END_TO_END"); return static_cast&>(*_v->second).get(); } std::vector get_causal_fixed_speedup() { - static auto _v = get_config()->find("OMNITRACE_CAUSAL_FIXED_SPEEDUP"); + static auto _v = get_config()->find("ROCPROFSYS_CAUSAL_FIXED_SPEEDUP"); return parse_numeric_range>( static_cast&>(*_v->second).get(), "causal fixed speedup", 5L); @@ -2664,7 +2679,7 @@ get_causal_fixed_speedup() std::string get_causal_output_filename() { - static auto _v = get_config()->find("OMNITRACE_CAUSAL_FILE"); + static auto _v = get_config()->find("ROCPROFSYS_CAUSAL_FILE"); auto _fname = static_cast&>(*_v->second).get(); for(auto&& itr : std::initializer_list{ ".txt", ".json", ".xml" }) { @@ -2707,7 +2722,7 @@ std::vector get_causal_binary_scope() { auto&& _config = get_config(); - static auto _v = _config->find("OMNITRACE_CAUSAL_BINARY_SCOPE"); + static auto _v = _config->find("ROCPROFSYS_CAUSAL_BINARY_SCOPE"); return format_causal_scopes( tim::delimit(static_cast&>(*_v->second).get(), "\t\"';"), @@ -2717,7 +2732,7 @@ get_causal_binary_scope() std::vector get_causal_source_scope() { - static auto _v = get_config()->find("OMNITRACE_CAUSAL_SOURCE_SCOPE"); + static auto _v = get_config()->find("ROCPROFSYS_CAUSAL_SOURCE_SCOPE"); return tim::delimit(static_cast&>(*_v->second).get(), "\t\"';"); } @@ -2725,7 +2740,7 @@ get_causal_source_scope() std::vector get_causal_function_scope() { - static auto _v = get_config()->find("OMNITRACE_CAUSAL_FUNCTION_SCOPE"); + static auto _v = get_config()->find("ROCPROFSYS_CAUSAL_FUNCTION_SCOPE"); return tim::delimit(static_cast&>(*_v->second).get(), "\t\"';"); } @@ -2734,7 +2749,7 @@ std::vector get_causal_binary_exclude() { auto&& _config = get_config(); - static auto _v = _config->find("OMNITRACE_CAUSAL_BINARY_EXCLUDE"); + static auto _v = _config->find("ROCPROFSYS_CAUSAL_BINARY_EXCLUDE"); return format_causal_scopes( tim::delimit(static_cast&>(*_v->second).get(), "\t\"';"), @@ -2744,7 +2759,7 @@ get_causal_binary_exclude() std::vector get_causal_source_exclude() { - static auto _v = get_config()->find("OMNITRACE_CAUSAL_SOURCE_EXCLUDE"); + static auto _v = get_config()->find("ROCPROFSYS_CAUSAL_SOURCE_EXCLUDE"); return tim::delimit(static_cast&>(*_v->second).get(), "\t\"';"); } @@ -2752,9 +2767,9 @@ get_causal_source_exclude() std::vector get_causal_function_exclude() { - static auto _v = get_config()->find("OMNITRACE_CAUSAL_FUNCTION_EXCLUDE"); + static auto _v = get_config()->find("ROCPROFSYS_CAUSAL_FUNCTION_EXCLUDE"); return tim::delimit(static_cast&>(*_v->second).get(), "\t\"';"); } } // namespace config -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/config.hpp b/source/lib/core/config.hpp index dac62fc3..2b9847bc 100644 --- a/source/lib/core/config.hpp +++ b/source/lib/core/config.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -35,7 +35,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { // // Initialization routines @@ -49,7 +49,7 @@ using signal_handler_t = void (*)(void); signal_handler_t set_signal_handler(signal_handler_t); bool -settings_are_configured() OMNITRACE_HOT; +settings_are_configured() ROCPROFSYS_HOT; void configure_settings(bool _init = true); @@ -156,10 +156,10 @@ bool& is_binary_rewrite(); bool -get_is_continuous_integration() OMNITRACE_HOT; +get_is_continuous_integration() ROCPROFSYS_HOT; bool -get_debug_env() OMNITRACE_HOT; +get_debug_env() ROCPROFSYS_HOT; bool get_debug_init(); @@ -168,49 +168,49 @@ bool get_debug_finalize(); bool -get_debug() OMNITRACE_HOT; +get_debug() ROCPROFSYS_HOT; bool -get_debug_sampling() OMNITRACE_HOT; +get_debug_sampling() ROCPROFSYS_HOT; bool -get_debug_tid() OMNITRACE_HOT; +get_debug_tid() ROCPROFSYS_HOT; bool -get_debug_pid() OMNITRACE_HOT; +get_debug_pid() ROCPROFSYS_HOT; int -get_verbose_env() OMNITRACE_HOT; +get_verbose_env() ROCPROFSYS_HOT; int -get_verbose() OMNITRACE_HOT; +get_verbose() ROCPROFSYS_HOT; bool& -get_use_perfetto() OMNITRACE_HOT; +get_use_perfetto() ROCPROFSYS_HOT; bool& -get_use_timemory() OMNITRACE_HOT; +get_use_timemory() ROCPROFSYS_HOT; bool& -get_use_causal() OMNITRACE_HOT; +get_use_causal() ROCPROFSYS_HOT; bool -get_use_roctracer() OMNITRACE_HOT; +get_use_roctracer() ROCPROFSYS_HOT; bool -get_use_rocprofiler() OMNITRACE_HOT; +get_use_rocprofiler() ROCPROFSYS_HOT; bool -get_use_rocm_smi() OMNITRACE_HOT; +get_use_rocm_smi() ROCPROFSYS_HOT; bool get_use_roctx(); bool& -get_use_sampling() OMNITRACE_HOT; +get_use_sampling() ROCPROFSYS_HOT; bool& -get_use_process_sampling() OMNITRACE_HOT; +get_use_process_sampling() ROCPROFSYS_HOT; bool& get_use_pid(); @@ -267,7 +267,7 @@ std::set get_disabled_categories(); bool -get_perfetto_annotations() OMNITRACE_HOT; +get_perfetto_annotations() ROCPROFSYS_HOT; uint64_t get_thread_pool_size(); @@ -278,12 +278,12 @@ 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(); bool -get_perfetto_roctracer_per_stream() OMNITRACE_HOT; +get_perfetto_roctracer_per_stream() ROCPROFSYS_HOT; double get_trace_delay(); @@ -424,4 +424,4 @@ get_causal_source_exclude(); std::vector get_causal_function_exclude(); } // namespace config -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/constraint.cpp b/source/lib/core/constraint.cpp index 8caed07c..858d3bec 100644 --- a/source/lib/core/constraint.cpp +++ b/source/lib/core/constraint.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -36,7 +36,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace constraint { @@ -47,7 +47,7 @@ namespace units = ::tim::units; using clock_type = std::chrono::high_resolution_clock; using duration_type = std::chrono::duration; -#define OMNITRACE_CLOCK_IDENTIFIER(VAL) \ +#define ROCPROFSYS_CLOCK_IDENTIFIER(VAL) \ clock_identifier { #VAL, VAL } auto @@ -63,13 +63,13 @@ clock_name(std::string _v) } auto accepted_clock_ids = - std::set{ OMNITRACE_CLOCK_IDENTIFIER(CLOCK_REALTIME), - OMNITRACE_CLOCK_IDENTIFIER(CLOCK_MONOTONIC), - OMNITRACE_CLOCK_IDENTIFIER(CLOCK_PROCESS_CPUTIME_ID), - OMNITRACE_CLOCK_IDENTIFIER(CLOCK_MONOTONIC_RAW), - OMNITRACE_CLOCK_IDENTIFIER(CLOCK_REALTIME_COARSE), - OMNITRACE_CLOCK_IDENTIFIER(CLOCK_MONOTONIC_COARSE), - OMNITRACE_CLOCK_IDENTIFIER(CLOCK_BOOTTIME) }; + std::set{ ROCPROFSYS_CLOCK_IDENTIFIER(CLOCK_REALTIME), + ROCPROFSYS_CLOCK_IDENTIFIER(CLOCK_MONOTONIC), + ROCPROFSYS_CLOCK_IDENTIFIER(CLOCK_PROCESS_CPUTIME_ID), + ROCPROFSYS_CLOCK_IDENTIFIER(CLOCK_MONOTONIC_RAW), + ROCPROFSYS_CLOCK_IDENTIFIER(CLOCK_REALTIME_COARSE), + ROCPROFSYS_CLOCK_IDENTIFIER(CLOCK_MONOTONIC_COARSE), + ROCPROFSYS_CLOCK_IDENTIFIER(CLOCK_BOOTTIME) }; template clock_identifier @@ -101,9 +101,9 @@ find_clock_identifier(const Tp& _v) } } - OMNITRACE_THROW("Unknown clock id %s: %s. Valid choices: %s\n", _descript, - timemory::join::join("", _v).c_str(), - timemory::join::join("", accepted_clock_ids).c_str()); + ROCPROFSYS_THROW("Unknown clock id %s: %s. Valid choices: %s\n", _descript, + timemory::join::join("", _v).c_str(), + timemory::join::join("", accepted_clock_ids).c_str()); } void @@ -232,10 +232,10 @@ spec::spec(const std::string& _clock_id, double _delay, double _dur, uint64_t _n {} spec::spec(const std::string& _line) -: spec{ config::get_setting_value("OMNITRACE_TRACE_PERIOD_CLOCK_ID") +: spec{ config::get_setting_value("ROCPROFSYS_TRACE_PERIOD_CLOCK_ID") .value_or("CLOCK_REALTIME"), - config::get_setting_value("OMNITRACE_TRACE_DELAY").value_or(0.0), - config::get_setting_value("OMNITRACE_TRACE_DURATION").value_or(0.0) } + config::get_setting_value("ROCPROFSYS_TRACE_DELAY").value_or(0.0), + config::get_setting_value("ROCPROFSYS_TRACE_DURATION").value_or(0.0) } { auto _delim = tim::delimit(_line, ":"); if(!_delim.empty()) delay = utility::convert(_delim.at(0)); @@ -266,11 +266,11 @@ spec::operator()(const stages& _stages) const return _ret; }; - OMNITRACE_VERBOSE(2, - "Executing constraint spec %lu of %lu :: delay: %6.3f, " - "duration: %6.3f, clock: %s\n", - i, _spec.repeat, _spec.delay, _spec.duration, - _spec.clock_id.as_string().c_str()); + ROCPROFSYS_VERBOSE(2, + "Executing constraint spec %lu of %lu :: delay: %6.3f, " + "duration: %6.3f, clock: %s\n", + i, _spec.repeat, _spec.delay, _spec.duration, + _spec.clock_id.as_string().c_str()); if(_stages.init(_spec) && _wait(_stages.wait, _spec.delay) && _stages.start(_spec) && _wait(_stages.collect, _spec.duration) && @@ -302,11 +302,11 @@ get_trace_specs() { auto _delay_v = - config::get_setting_value("OMNITRACE_TRACE_DELAY").value_or(0.0); + config::get_setting_value("ROCPROFSYS_TRACE_DELAY").value_or(0.0); auto _duration_v = - config::get_setting_value("OMNITRACE_TRACE_DURATION").value_or(0.0); + config::get_setting_value("ROCPROFSYS_TRACE_DURATION").value_or(0.0); auto _clock_v = find_clock_identifier( - config::get_setting_value("OMNITRACE_TRACE_PERIOD_CLOCK_ID") + config::get_setting_value("ROCPROFSYS_TRACE_PERIOD_CLOCK_ID") .value_or("CLOCK_REALTIME")); if(_delay_v > 0.0 || _duration_v > 0.0) @@ -317,7 +317,7 @@ get_trace_specs() { auto _periods_v = - config::get_setting_value("OMNITRACE_TRACE_PERIODS") + config::get_setting_value("ROCPROFSYS_TRACE_PERIODS") .value_or(""); if(!_periods_v.empty()) { @@ -349,4 +349,4 @@ get_trace_stages() return _v; } } // namespace constraint -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/constraint.hpp b/source/lib/core/constraint.hpp index f2b8808f..bd47c900 100644 --- a/source/lib/core/constraint.hpp +++ b/source/lib/core/constraint.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -39,7 +39,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace constraint { @@ -51,7 +51,7 @@ struct stages stages(); - OMNITRACE_DEFAULT_COPY_MOVE(stages) + ROCPROFSYS_DEFAULT_COPY_MOVE(stages) functor_t init = [](const spec&) { return true; }; functor_t wait = [](const spec&) { return true; }; @@ -69,7 +69,7 @@ struct clock_identifier clock_identifier(); clock_identifier(std::string_view, int); - OMNITRACE_DEFAULT_COPY_MOVE(clock_identifier) + ROCPROFSYS_DEFAULT_COPY_MOVE(clock_identifier) std::string as_string() const; @@ -91,7 +91,7 @@ struct spec spec(const std::string&, double, double, uint64_t = 0, uint64_t = 1); spec(const std::string&); - OMNITRACE_DEFAULT_COPY_MOVE(spec) + ROCPROFSYS_DEFAULT_COPY_MOVE(spec) void operator()(const stages&) const; @@ -111,4 +111,4 @@ get_trace_specs(); stages get_trace_stages(); } // namespace constraint -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/containers/CMakeLists.txt b/source/lib/core/containers/CMakeLists.txt index 57a361ea..4461bf20 100644 --- a/source/lib/core/containers/CMakeLists.txt +++ b/source/lib/core/containers/CMakeLists.txt @@ -8,4 +8,5 @@ set(containers_headers ${CMAKE_CURRENT_LIST_DIR}/stable_vector.hpp ${CMAKE_CURRENT_LIST_DIR}/static_vector.hpp) -target_sources(omnitrace-core-library PRIVATE ${containers_sources} ${containers_headers}) +target_sources(rocprofiler-systems-core-library PRIVATE ${containers_sources} + ${containers_headers}) diff --git a/source/lib/core/containers/aligned_static_vector.hpp b/source/lib/core/containers/aligned_static_vector.hpp index dd77c6c6..252c9cca 100644 --- a/source/lib/core/containers/aligned_static_vector.hpp +++ b/source/lib/core/containers/aligned_static_vector.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -32,21 +32,21 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace container { -#if !defined(OMNITRACE_CACHELINE_SIZE) +#if !defined(ROCPROFSYS_CACHELINE_SIZE) # ifdef __cpp_lib_hardware_interference_size -# define OMNITRACE_CACHELINE_SIZE std::hardware_destructive_interference_size +# define ROCPROFSYS_CACHELINE_SIZE std::hardware_destructive_interference_size # else // 64 bytes on x86-64 │ L1_CACHE_BYTES │ L1_CACHE_SHIFT │ __cacheline_aligned │ ... -# define OMNITRACE_CACHELINE_SIZE 64 +# define ROCPROFSYS_CACHELINE_SIZE 64 # endif #endif constexpr std::size_t cacheline_align_v = - std::max(OMNITRACE_CACHELINE_SIZE, OMNITRACE_CACHELINE_SIZE_MIN); + std::max(ROCPROFSYS_CACHELINE_SIZE, ROCPROFSYS_CACHELINE_SIZE_MIN); template @@ -228,7 +228,7 @@ aligned_static_vector& aligned_static_vector::operator=( std::initializer_list&& _v) { - if(OMNITRACE_UNLIKELY(_v.size() > N)) + if(ROCPROFSYS_UNLIKELY(_v.size() > N)) { throw exception( std::string{ "aligned_static_vector::operator=(initializer_list) size > " } + @@ -323,4 +323,4 @@ aligned_static_vector::emplace_back(Args&&... _v) } } // namespace container -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/containers/c_array.hpp b/source/lib/core/containers/c_array.hpp index 252d5df6..f854fcd8 100644 --- a/source/lib/core/containers/c_array.hpp +++ b/source/lib/core/containers/c_array.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -31,7 +31,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace container { @@ -62,7 +62,7 @@ struct c_array Tp& at(size_t i) { if(i < m_size) return m_base[i]; - throw ::omnitrace::exception( + throw ::rocprofsys::exception( std::string{ typeid(*this).name() } + std::to_string(i) + " exceeds size " + std::to_string(m_size)); } @@ -71,7 +71,7 @@ struct c_array const Tp& at(size_t i) const { if(i < m_size) return m_base[i]; - throw ::omnitrace::exception( + throw ::rocprofsys::exception( std::string{ typeid(*this).name() } + std::to_string(i) + " exceeds size " + std::to_string(m_size)); } @@ -137,4 +137,4 @@ wrap_c_array(Tp* base, size_t size) return c_array(base, size); } } // namespace container -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/containers/operators.hpp b/source/lib/core/containers/operators.hpp index 043497d0..a08ba9c6 100644 --- a/source/lib/core/containers/operators.hpp +++ b/source/lib/core/containers/operators.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -27,30 +27,30 @@ #include #include -#define OMNITRACE_IMPORT_TEMPLATE2(template_name) -#define OMNITRACE_IMPORT_TEMPLATE1(template_name) +#define ROCPROFSYS_IMPORT_TEMPLATE2(template_name) +#define ROCPROFSYS_IMPORT_TEMPLATE1(template_name) // Import a 2-type-argument operator template into boost (if necessary) and // provide a specialization of 'is_chained_base<>' for it. -#define OMNITRACE_OPERATOR_TEMPLATE2(template_name2) \ - OMNITRACE_IMPORT_TEMPLATE2(template_name2) \ +#define ROCPROFSYS_OPERATOR_TEMPLATE2(template_name2) \ + ROCPROFSYS_IMPORT_TEMPLATE2(template_name2) \ template \ - struct is_chained_base<::omnitrace::container::template_name2> \ + struct is_chained_base<::rocprofsys::container::template_name2> \ { \ - using value = ::omnitrace::container::true_t; \ + using value = ::rocprofsys::container::true_t; \ }; // Import a 1-type-argument operator template into boost (if necessary) and // provide a specialization of 'is_chained_base<>' for it. -#define OMNITRACE_OPERATOR_TEMPLATE1(template_name1) \ - OMNITRACE_IMPORT_TEMPLATE1(template_name1) \ +#define ROCPROFSYS_OPERATOR_TEMPLATE1(template_name1) \ + ROCPROFSYS_IMPORT_TEMPLATE1(template_name1) \ template \ - struct is_chained_base<::omnitrace::container::template_name1> \ + struct is_chained_base<::rocprofsys::container::template_name1> \ { \ - using value = ::omnitrace::container::true_t; \ + using value = ::rocprofsys::container::true_t; \ }; -#define OMNITRACE_OPERATOR_TEMPLATE(template_name) \ +#define ROCPROFSYS_OPERATOR_TEMPLATE(template_name) \ template , \ typename O = typename is_chained_base::value> \ struct template_name; \ @@ -74,13 +74,13 @@ template \ struct is_chained_base> \ { \ - using value = ::omnitrace::container::true_t; \ + using value = ::rocprofsys::container::true_t; \ }; \ \ - OMNITRACE_OPERATOR_TEMPLATE2(template_name##2) \ - OMNITRACE_OPERATOR_TEMPLATE1(template_name##1) + ROCPROFSYS_OPERATOR_TEMPLATE2(template_name##2) \ + ROCPROFSYS_OPERATOR_TEMPLATE1(template_name##1) -#define OMNITRACE_BINARY_OPERATOR_COMMUTATIVE(NAME, OP) \ +#define ROCPROFSYS_BINARY_OPERATOR_COMMUTATIVE(NAME, OP) \ template > \ struct NAME##2 \ : B{ friend T operator OP(T lhs, const U& rhs){ return lhs OP## = rhs; \ @@ -96,7 +96,7 @@ } \ ; -#define OMNITRACE_BINARY_OPERATOR_NON_COMMUTATIVE(NAME, OP) \ +#define ROCPROFSYS_BINARY_OPERATOR_NON_COMMUTATIVE(NAME, OP) \ template > \ struct NAME##2 \ : B{ friend T operator OP(T lhs, const U& rhs){ return lhs OP## = rhs; \ @@ -104,7 +104,7 @@ } \ ; -namespace omnitrace +namespace rocprofsys { namespace container { @@ -124,10 +124,10 @@ struct is_chained_base using value = true_t; }; -OMNITRACE_BINARY_OPERATOR_COMMUTATIVE(addable, +) -OMNITRACE_BINARY_OPERATOR_NON_COMMUTATIVE(subtractable, -) +ROCPROFSYS_BINARY_OPERATOR_COMMUTATIVE(addable, +) +ROCPROFSYS_BINARY_OPERATOR_NON_COMMUTATIVE(subtractable, -) -OMNITRACE_OPERATOR_TEMPLATE(addable) +ROCPROFSYS_OPERATOR_TEMPLATE(addable) template > struct incrementable : B @@ -237,4 +237,4 @@ struct random_access_iterator_helper friend D requires_difference_operator(const T& x, const T& y) { return x - y; } }; // random_access_iterator_helper } // namespace container -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/containers/stable_vector.hpp b/source/lib/core/containers/stable_vector.hpp index 6b9270b4..f52cf7eb 100644 --- a/source/lib/core/containers/stable_vector.hpp +++ b/source/lib/core/containers/stable_vector.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -34,11 +34,11 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace container { -template class stable_vector { @@ -299,7 +299,7 @@ template typename stable_vector::chunk_type& stable_vector::last_chunk() { - if(OMNITRACE_UNLIKELY(m_chunks.empty() || m_chunks.back()->size() == ChunkSizeV)) + if(ROCPROFSYS_UNLIKELY(m_chunks.empty() || m_chunks.back()->size() == ChunkSizeV)) { add_chunk(); } @@ -358,9 +358,9 @@ template typename stable_vector::reference stable_vector::at(size_type i) { - if(OMNITRACE_UNLIKELY(i >= size())) + if(ROCPROFSYS_UNLIKELY(i >= size())) { - throw ::omnitrace::exception( + throw ::rocprofsys::exception( "stable_vector::at(" + std::to_string(i) + "). size is " + std::to_string(size())); } @@ -387,4 +387,4 @@ resize(stable_vector& _v, size_t _n, Args&&... args) return _v.size(); } } // namespace container -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/containers/static_vector.hpp b/source/lib/core/containers/static_vector.hpp index 0773418a..70726fa0 100644 --- a/source/lib/core/containers/static_vector.hpp +++ b/source/lib/core/containers/static_vector.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -33,7 +33,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace container { @@ -147,7 +147,7 @@ template static_vector& static_vector::operator=(std::initializer_list&& _v) { - if(OMNITRACE_UNLIKELY(_v.size() > N)) + if(ROCPROFSYS_UNLIKELY(_v.size() > N)) { throw exception( std::string{ "static_vector::operator=(initializer_list) size > " } + @@ -227,4 +227,4 @@ static_vector::update_size(size_t _n) m_size = _n; } } // namespace container -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/debug.cpp b/source/lib/core/debug.cpp index 0595007e..807f49d6 100644 --- a/source/lib/core/debug.cpp +++ b/source/lib/core/debug.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -33,7 +33,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace debug { @@ -48,7 +48,7 @@ struct source_location_history const std::string& get_file_name() { - static auto _fname = tim::get_env("OMNITRACE_LOG_FILE", ""); + static auto _fname = tim::get_env("ROCPROFSYS_LOG_FILE", ""); return _fname; } @@ -127,7 +127,7 @@ close_file() fclose(_file); // Write the trace into a file. if(get_verbose() >= 0) - operation::file_output_message{}( + operation::file_output_message{}( get_file_name(), std::string{ "debug" }); } } @@ -164,4 +164,4 @@ template std::string as_hex(int64_t, size_t); template std::string as_hex(uint64_t, size_t); template std::string as_hex(void*, size_t); -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/debug.hpp b/source/lib/core/debug.hpp index 7f814163..c9c9c71a 100644 --- a/source/lib/core/debug.hpp +++ b/source/lib/core/debug.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -43,30 +43,30 @@ #include #include -namespace omnitrace +namespace rocprofsys { inline namespace config { bool -get_debug() OMNITRACE_HOT; +get_debug() ROCPROFSYS_HOT; int -get_verbose() OMNITRACE_HOT; +get_verbose() ROCPROFSYS_HOT; bool -get_debug_env() OMNITRACE_HOT; +get_debug_env() ROCPROFSYS_HOT; int -get_verbose_env() OMNITRACE_HOT; +get_verbose_env() ROCPROFSYS_HOT; bool -get_is_continuous_integration() OMNITRACE_HOT; +get_is_continuous_integration() ROCPROFSYS_HOT; bool -get_debug_tid() OMNITRACE_HOT; +get_debug_tid() ROCPROFSYS_HOT; bool -get_debug_pid() OMNITRACE_HOT; +get_debug_pid() ROCPROFSYS_HOT; } // namespace config namespace debug @@ -96,8 +96,8 @@ flush() fprintf(stdout, "%s", ::tim::log::color::end()); fflush(stdout); std::cout << ::tim::log::color::end() << std::flush; - fprintf(::omnitrace::debug::get_file(), "%s", ::tim::log::color::end()); - fflush(::omnitrace::debug::get_file()); + fprintf(::rocprofsys::debug::get_file(), "%s", ::tim::log::color::end()); + fflush(::rocprofsys::debug::get_file()); std::cerr << ::tim::log::color::end() << std::flush; } // @@ -152,58 +152,58 @@ extern template std::string as_hex(int64_t, size_t); extern template std::string as_hex(uint64_t, size_t); extern template std::string as_hex(void*, size_t); -} // namespace omnitrace +} // namespace rocprofsys -#if !defined(OMNITRACE_DEBUG_BUFFER_LEN) -# define OMNITRACE_DEBUG_BUFFER_LEN 1024 +#if !defined(ROCPROFSYS_DEBUG_BUFFER_LEN) +# define ROCPROFSYS_DEBUG_BUFFER_LEN 1024 #endif -#if !defined(OMNITRACE_DEBUG_PROCESS_IDENTIFIER) +#if !defined(ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER) # if defined(TIMEMORY_USE_MPI) -# define OMNITRACE_DEBUG_PROCESS_IDENTIFIER static_cast(::tim::dmp::rank()) +# define ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER static_cast(::tim::dmp::rank()) # elif defined(TIMEMORY_USE_MPI_HEADERS) -# define OMNITRACE_DEBUG_PROCESS_IDENTIFIER \ +# define ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER \ (::tim::dmp::is_initialized()) ? static_cast(::tim::dmp::rank()) \ : static_cast(::tim::process::get_id()) # else -# define OMNITRACE_DEBUG_PROCESS_IDENTIFIER \ +# define ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER \ static_cast(::tim::process::get_id()) # endif #endif -#if !defined(OMNITRACE_DEBUG_THREAD_IDENTIFIER) -# define OMNITRACE_DEBUG_THREAD_IDENTIFIER ::omnitrace::debug::get_tid() +#if !defined(ROCPROFSYS_DEBUG_THREAD_IDENTIFIER) +# define ROCPROFSYS_DEBUG_THREAD_IDENTIFIER ::rocprofsys::debug::get_tid() #endif -#if !defined(OMNITRACE_SOURCE_LOCATION) -# define OMNITRACE_SOURCE_LOCATION \ - ::omnitrace::debug::source_location { __PRETTY_FUNCTION__, __FILE__, __LINE__ } +#if !defined(ROCPROFSYS_SOURCE_LOCATION) +# define ROCPROFSYS_SOURCE_LOCATION \ + ::rocprofsys::debug::source_location { __PRETTY_FUNCTION__, __FILE__, __LINE__ } #endif -#if !defined(OMNITRACE_RECORD_SOURCE_LOCATION) -# define OMNITRACE_RECORD_SOURCE_LOCATION \ - ::omnitrace::debug::set_source_location(OMNITRACE_SOURCE_LOCATION) +#if !defined(ROCPROFSYS_RECORD_SOURCE_LOCATION) +# define ROCPROFSYS_RECORD_SOURCE_LOCATION \ + ::rocprofsys::debug::set_source_location(ROCPROFSYS_SOURCE_LOCATION) #endif #if defined(__clang__) || (__GNUC__ < 9) -# define OMNITRACE_FUNCTION \ +# define ROCPROFSYS_FUNCTION \ std::string{ __FUNCTION__ } \ .substr(0, std::string_view{ __FUNCTION__ }.find("_hidden")) \ .c_str() -# define OMNITRACE_PRETTY_FUNCTION \ +# define ROCPROFSYS_PRETTY_FUNCTION \ std::string{ __PRETTY_FUNCTION__ } \ .substr(0, std::string_view{ __PRETTY_FUNCTION__ }.find("_hidden")) \ .c_str() #else -# define OMNITRACE_FUNCTION \ - ::omnitrace::debug::get_chars( \ +# define ROCPROFSYS_FUNCTION \ + ::rocprofsys::debug::get_chars( \ std::string_view{ __FUNCTION__ }, \ std::make_index_sequence{}) \ .data() -# define OMNITRACE_PRETTY_FUNCTION \ - ::omnitrace::debug::get_chars( \ +# define ROCPROFSYS_PRETTY_FUNCTION \ + ::rocprofsys::debug::get_chars( \ std::string_view{ __PRETTY_FUNCTION__ }, \ std::make_index_sequence(void*, size_t); //--------------------------------------------------------------------------------------// -#define OMNITRACE_FPRINTF_STDERR_COLOR(COLOR) \ - fprintf(::omnitrace::debug::get_file(), "%s", ::tim::log::color::COLOR()) +#define ROCPROFSYS_FPRINTF_STDERR_COLOR(COLOR) \ + fprintf(::rocprofsys::debug::get_file(), "%s", ::tim::log::color::COLOR()) //--------------------------------------------------------------------------------------// -#define OMNITRACE_CONDITIONAL_PRINT_COLOR(COLOR, COND, ...) \ - if(OMNITRACE_UNLIKELY((COND) && ::omnitrace::config::get_debug_tid() && \ - ::omnitrace::config::get_debug_pid())) \ +#define ROCPROFSYS_CONDITIONAL_PRINT_COLOR(COLOR, COND, ...) \ + if(ROCPROFSYS_UNLIKELY((COND) && ::rocprofsys::config::get_debug_tid() && \ + ::rocprofsys::config::get_debug_pid())) \ { \ - ::omnitrace::debug::flush(); \ - ::omnitrace::debug::lock _debug_lk{}; \ - OMNITRACE_FPRINTF_STDERR_COLOR(COLOR); \ - fprintf(::omnitrace::debug::get_file(), "[omnitrace][%i][%li]%s", \ - OMNITRACE_DEBUG_PROCESS_IDENTIFIER, OMNITRACE_DEBUG_THREAD_IDENTIFIER, \ - ::omnitrace::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ - fprintf(::omnitrace::debug::get_file(), __VA_ARGS__); \ - ::omnitrace::debug::flush(); \ + ::rocprofsys::debug::flush(); \ + ::rocprofsys::debug::lock _debug_lk{}; \ + ROCPROFSYS_FPRINTF_STDERR_COLOR(COLOR); \ + fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i][%li]%s", \ + ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_DEBUG_THREAD_IDENTIFIER, \ + ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ + fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \ + ::rocprofsys::debug::flush(); \ } -#define OMNITRACE_CONDITIONAL_PRINT_COLOR_F(COLOR, COND, ...) \ - if(OMNITRACE_UNLIKELY((COND) && ::omnitrace::config::get_debug_tid() && \ - ::omnitrace::config::get_debug_pid())) \ +#define ROCPROFSYS_CONDITIONAL_PRINT_COLOR_F(COLOR, COND, ...) \ + if(ROCPROFSYS_UNLIKELY((COND) && ::rocprofsys::config::get_debug_tid() && \ + ::rocprofsys::config::get_debug_pid())) \ { \ - ::omnitrace::debug::flush(); \ - ::omnitrace::debug::lock _debug_lk{}; \ - OMNITRACE_FPRINTF_STDERR_COLOR(COLOR); \ - fprintf(::omnitrace::debug::get_file(), "[omnitrace][%i][%li][%s]%s", \ - OMNITRACE_DEBUG_PROCESS_IDENTIFIER, OMNITRACE_DEBUG_THREAD_IDENTIFIER, \ - OMNITRACE_FUNCTION, \ - ::omnitrace::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ - fprintf(::omnitrace::debug::get_file(), __VA_ARGS__); \ - ::omnitrace::debug::flush(); \ + ::rocprofsys::debug::flush(); \ + ::rocprofsys::debug::lock _debug_lk{}; \ + ROCPROFSYS_FPRINTF_STDERR_COLOR(COLOR); \ + fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i][%li][%s]%s", \ + ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_DEBUG_THREAD_IDENTIFIER, \ + ROCPROFSYS_FUNCTION, \ + ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ + fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \ + ::rocprofsys::debug::flush(); \ } -#define OMNITRACE_PRINT_COLOR(COLOR, ...) \ - OMNITRACE_CONDITIONAL_PRINT_COLOR(COLOR, true, __VA_ARGS__) +#define ROCPROFSYS_PRINT_COLOR(COLOR, ...) \ + ROCPROFSYS_CONDITIONAL_PRINT_COLOR(COLOR, true, __VA_ARGS__) -#define OMNITRACE_PRINT_COLOR_F(COLOR, ...) \ - OMNITRACE_CONDITIONAL_PRINT_COLOR_F(COLOR, true, __VA_ARGS__) +#define ROCPROFSYS_PRINT_COLOR_F(COLOR, ...) \ + ROCPROFSYS_CONDITIONAL_PRINT_COLOR_F(COLOR, true, __VA_ARGS__) //--------------------------------------------------------------------------------------// -#define OMNITRACE_CONDITIONAL_PRINT(COND, ...) \ - if(OMNITRACE_UNLIKELY((COND) && ::omnitrace::config::get_debug_tid() && \ - ::omnitrace::config::get_debug_pid())) \ +#define ROCPROFSYS_CONDITIONAL_PRINT(COND, ...) \ + if(ROCPROFSYS_UNLIKELY((COND) && ::rocprofsys::config::get_debug_tid() && \ + ::rocprofsys::config::get_debug_pid())) \ { \ - ::omnitrace::debug::flush(); \ - ::omnitrace::debug::lock _debug_lk{}; \ - OMNITRACE_FPRINTF_STDERR_COLOR(info); \ - fprintf(::omnitrace::debug::get_file(), "[omnitrace][%i][%li]%s", \ - OMNITRACE_DEBUG_PROCESS_IDENTIFIER, OMNITRACE_DEBUG_THREAD_IDENTIFIER, \ - ::omnitrace::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ - fprintf(::omnitrace::debug::get_file(), __VA_ARGS__); \ - ::omnitrace::debug::flush(); \ + ::rocprofsys::debug::flush(); \ + ::rocprofsys::debug::lock _debug_lk{}; \ + ROCPROFSYS_FPRINTF_STDERR_COLOR(info); \ + fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i][%li]%s", \ + ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_DEBUG_THREAD_IDENTIFIER, \ + ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ + fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \ + ::rocprofsys::debug::flush(); \ } -#define OMNITRACE_CONDITIONAL_BASIC_PRINT(COND, ...) \ - if(OMNITRACE_UNLIKELY((COND) && ::omnitrace::config::get_debug_tid() && \ - ::omnitrace::config::get_debug_pid())) \ +#define ROCPROFSYS_CONDITIONAL_BASIC_PRINT(COND, ...) \ + if(ROCPROFSYS_UNLIKELY((COND) && ::rocprofsys::config::get_debug_tid() && \ + ::rocprofsys::config::get_debug_pid())) \ { \ - ::omnitrace::debug::flush(); \ - ::omnitrace::debug::lock _debug_lk{}; \ - OMNITRACE_FPRINTF_STDERR_COLOR(info); \ - fprintf(::omnitrace::debug::get_file(), "[omnitrace][%i]%s", \ - OMNITRACE_DEBUG_PROCESS_IDENTIFIER, \ - ::omnitrace::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ - fprintf(::omnitrace::debug::get_file(), __VA_ARGS__); \ - ::omnitrace::debug::flush(); \ + ::rocprofsys::debug::flush(); \ + ::rocprofsys::debug::lock _debug_lk{}; \ + ROCPROFSYS_FPRINTF_STDERR_COLOR(info); \ + fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i]%s", \ + ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, \ + ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ + fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \ + ::rocprofsys::debug::flush(); \ } -#define OMNITRACE_CONDITIONAL_PRINT_F(COND, ...) \ - if(OMNITRACE_UNLIKELY((COND) && ::omnitrace::config::get_debug_tid() && \ - ::omnitrace::config::get_debug_pid())) \ +#define ROCPROFSYS_CONDITIONAL_PRINT_F(COND, ...) \ + if(ROCPROFSYS_UNLIKELY((COND) && ::rocprofsys::config::get_debug_tid() && \ + ::rocprofsys::config::get_debug_pid())) \ { \ - ::omnitrace::debug::flush(); \ - ::omnitrace::debug::lock _debug_lk{}; \ - OMNITRACE_FPRINTF_STDERR_COLOR(info); \ - fprintf(::omnitrace::debug::get_file(), "[omnitrace][%i][%li][%s]%s", \ - OMNITRACE_DEBUG_PROCESS_IDENTIFIER, OMNITRACE_DEBUG_THREAD_IDENTIFIER, \ - OMNITRACE_FUNCTION, \ - ::omnitrace::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ - fprintf(::omnitrace::debug::get_file(), __VA_ARGS__); \ - ::omnitrace::debug::flush(); \ + ::rocprofsys::debug::flush(); \ + ::rocprofsys::debug::lock _debug_lk{}; \ + ROCPROFSYS_FPRINTF_STDERR_COLOR(info); \ + fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i][%li][%s]%s", \ + ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_DEBUG_THREAD_IDENTIFIER, \ + ROCPROFSYS_FUNCTION, \ + ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ + fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \ + ::rocprofsys::debug::flush(); \ } -#define OMNITRACE_CONDITIONAL_BASIC_PRINT_F(COND, ...) \ - if(OMNITRACE_UNLIKELY((COND) && ::omnitrace::config::get_debug_tid() && \ - ::omnitrace::config::get_debug_pid())) \ +#define ROCPROFSYS_CONDITIONAL_BASIC_PRINT_F(COND, ...) \ + if(ROCPROFSYS_UNLIKELY((COND) && ::rocprofsys::config::get_debug_tid() && \ + ::rocprofsys::config::get_debug_pid())) \ { \ - ::omnitrace::debug::flush(); \ - ::omnitrace::debug::lock _debug_lk{}; \ - OMNITRACE_FPRINTF_STDERR_COLOR(info); \ - fprintf(::omnitrace::debug::get_file(), "[omnitrace][%i][%s]%s", \ - OMNITRACE_DEBUG_PROCESS_IDENTIFIER, OMNITRACE_FUNCTION, \ - ::omnitrace::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ - fprintf(::omnitrace::debug::get_file(), __VA_ARGS__); \ - ::omnitrace::debug::flush(); \ + ::rocprofsys::debug::flush(); \ + ::rocprofsys::debug::lock _debug_lk{}; \ + ROCPROFSYS_FPRINTF_STDERR_COLOR(info); \ + fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i][%s]%s", \ + ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_FUNCTION, \ + ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ + fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \ + ::rocprofsys::debug::flush(); \ } //--------------------------------------------------------------------------------------// -#define OMNITRACE_CONDITIONAL_WARN(COND, ...) \ - if(OMNITRACE_UNLIKELY((COND) && ::omnitrace::config::get_debug_tid() && \ - ::omnitrace::config::get_debug_pid())) \ +#define ROCPROFSYS_CONDITIONAL_WARN(COND, ...) \ + if(ROCPROFSYS_UNLIKELY((COND) && ::rocprofsys::config::get_debug_tid() && \ + ::rocprofsys::config::get_debug_pid())) \ { \ - ::omnitrace::debug::flush(); \ - ::omnitrace::debug::lock _debug_lk{}; \ - OMNITRACE_FPRINTF_STDERR_COLOR(warning); \ - fprintf(::omnitrace::debug::get_file(), "[omnitrace][%i][%li]%s", \ - OMNITRACE_DEBUG_PROCESS_IDENTIFIER, OMNITRACE_DEBUG_THREAD_IDENTIFIER, \ - ::omnitrace::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ - fprintf(::omnitrace::debug::get_file(), __VA_ARGS__); \ - ::omnitrace::debug::flush(); \ + ::rocprofsys::debug::flush(); \ + ::rocprofsys::debug::lock _debug_lk{}; \ + ROCPROFSYS_FPRINTF_STDERR_COLOR(warning); \ + fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i][%li]%s", \ + ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_DEBUG_THREAD_IDENTIFIER, \ + ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ + fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \ + ::rocprofsys::debug::flush(); \ } -#define OMNITRACE_CONDITIONAL_BASIC_WARN(COND, ...) \ - if(OMNITRACE_UNLIKELY((COND) && ::omnitrace::config::get_debug_tid() && \ - ::omnitrace::config::get_debug_pid())) \ +#define ROCPROFSYS_CONDITIONAL_BASIC_WARN(COND, ...) \ + if(ROCPROFSYS_UNLIKELY((COND) && ::rocprofsys::config::get_debug_tid() && \ + ::rocprofsys::config::get_debug_pid())) \ { \ - ::omnitrace::debug::flush(); \ - ::omnitrace::debug::lock _debug_lk{}; \ - OMNITRACE_FPRINTF_STDERR_COLOR(warning); \ - fprintf(::omnitrace::debug::get_file(), "[omnitrace][%i]%s", \ - OMNITRACE_DEBUG_PROCESS_IDENTIFIER, \ - ::omnitrace::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ - fprintf(::omnitrace::debug::get_file(), __VA_ARGS__); \ - ::omnitrace::debug::flush(); \ + ::rocprofsys::debug::flush(); \ + ::rocprofsys::debug::lock _debug_lk{}; \ + ROCPROFSYS_FPRINTF_STDERR_COLOR(warning); \ + fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i]%s", \ + ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, \ + ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ + fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \ + ::rocprofsys::debug::flush(); \ } -#define OMNITRACE_CONDITIONAL_WARN_F(COND, ...) \ - if(OMNITRACE_UNLIKELY((COND) && ::omnitrace::config::get_debug_tid() && \ - ::omnitrace::config::get_debug_pid())) \ +#define ROCPROFSYS_CONDITIONAL_WARN_F(COND, ...) \ + if(ROCPROFSYS_UNLIKELY((COND) && ::rocprofsys::config::get_debug_tid() && \ + ::rocprofsys::config::get_debug_pid())) \ { \ - ::omnitrace::debug::flush(); \ - ::omnitrace::debug::lock _debug_lk{}; \ - OMNITRACE_FPRINTF_STDERR_COLOR(warning); \ - fprintf(::omnitrace::debug::get_file(), "[omnitrace][%i][%li][%s]%s", \ - OMNITRACE_DEBUG_PROCESS_IDENTIFIER, OMNITRACE_DEBUG_THREAD_IDENTIFIER, \ - OMNITRACE_FUNCTION, \ - ::omnitrace::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ - fprintf(::omnitrace::debug::get_file(), __VA_ARGS__); \ - ::omnitrace::debug::flush(); \ + ::rocprofsys::debug::flush(); \ + ::rocprofsys::debug::lock _debug_lk{}; \ + ROCPROFSYS_FPRINTF_STDERR_COLOR(warning); \ + fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i][%li][%s]%s", \ + ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_DEBUG_THREAD_IDENTIFIER, \ + ROCPROFSYS_FUNCTION, \ + ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ + fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \ + ::rocprofsys::debug::flush(); \ } -#define OMNITRACE_CONDITIONAL_BASIC_WARN_F(COND, ...) \ - if(OMNITRACE_UNLIKELY((COND) && ::omnitrace::config::get_debug_tid() && \ - ::omnitrace::config::get_debug_pid())) \ +#define ROCPROFSYS_CONDITIONAL_BASIC_WARN_F(COND, ...) \ + if(ROCPROFSYS_UNLIKELY((COND) && ::rocprofsys::config::get_debug_tid() && \ + ::rocprofsys::config::get_debug_pid())) \ { \ - ::omnitrace::debug::flush(); \ - ::omnitrace::debug::lock _debug_lk{}; \ - OMNITRACE_FPRINTF_STDERR_COLOR(warning); \ - fprintf(::omnitrace::debug::get_file(), "[omnitrace][%i][%s]%s", \ - OMNITRACE_DEBUG_PROCESS_IDENTIFIER, OMNITRACE_FUNCTION, \ - ::omnitrace::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ - fprintf(::omnitrace::debug::get_file(), __VA_ARGS__); \ - ::omnitrace::debug::flush(); \ + ::rocprofsys::debug::flush(); \ + ::rocprofsys::debug::lock _debug_lk{}; \ + ROCPROFSYS_FPRINTF_STDERR_COLOR(warning); \ + fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i][%s]%s", \ + ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_FUNCTION, \ + ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ + fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \ + ::rocprofsys::debug::flush(); \ } //--------------------------------------------------------------------------------------// -#define OMNITRACE_CONDITIONAL_THROW_E(COND, TYPE, ...) \ - if(OMNITRACE_UNLIKELY((COND))) \ +#define ROCPROFSYS_CONDITIONAL_THROW_E(COND, TYPE, ...) \ + if(ROCPROFSYS_UNLIKELY((COND))) \ { \ - char _msg_buffer[OMNITRACE_DEBUG_BUFFER_LEN]; \ - snprintf(_msg_buffer, OMNITRACE_DEBUG_BUFFER_LEN, "[omnitrace][%i][%li][%s]%s", \ - OMNITRACE_DEBUG_PROCESS_IDENTIFIER, OMNITRACE_DEBUG_THREAD_IDENTIFIER, \ - OMNITRACE_FUNCTION, \ - ::omnitrace::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ + char _msg_buffer[ROCPROFSYS_DEBUG_BUFFER_LEN]; \ + snprintf(_msg_buffer, ROCPROFSYS_DEBUG_BUFFER_LEN, \ + "[rocprof-sys][%i][%li][%s]%s", ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, \ + ROCPROFSYS_DEBUG_THREAD_IDENTIFIER, ROCPROFSYS_FUNCTION, \ + ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ auto len = strlen(_msg_buffer); \ - snprintf(_msg_buffer + len, OMNITRACE_DEBUG_BUFFER_LEN - len, __VA_ARGS__); \ - throw ::omnitrace::exception( \ + snprintf(_msg_buffer + len, ROCPROFSYS_DEBUG_BUFFER_LEN - len, __VA_ARGS__); \ + throw ::rocprofsys::exception( \ ::tim::log::string(::tim::log::color::fatal(), _msg_buffer)); \ } -#define OMNITRACE_CONDITIONAL_BASIC_THROW_E(COND, TYPE, ...) \ - if(OMNITRACE_UNLIKELY((COND))) \ +#define ROCPROFSYS_CONDITIONAL_BASIC_THROW_E(COND, TYPE, ...) \ + if(ROCPROFSYS_UNLIKELY((COND))) \ { \ - char _msg_buffer[OMNITRACE_DEBUG_BUFFER_LEN]; \ - snprintf(_msg_buffer, OMNITRACE_DEBUG_BUFFER_LEN, "[omnitrace][%i][%s]%s", \ - OMNITRACE_DEBUG_PROCESS_IDENTIFIER, OMNITRACE_FUNCTION, \ - ::omnitrace::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ + char _msg_buffer[ROCPROFSYS_DEBUG_BUFFER_LEN]; \ + snprintf(_msg_buffer, ROCPROFSYS_DEBUG_BUFFER_LEN, "[rocprof-sys][%i][%s]%s", \ + ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_FUNCTION, \ + ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ auto len = strlen(_msg_buffer); \ - snprintf(_msg_buffer + len, OMNITRACE_DEBUG_BUFFER_LEN - len, __VA_ARGS__); \ - throw ::omnitrace::exception( \ + snprintf(_msg_buffer + len, ROCPROFSYS_DEBUG_BUFFER_LEN - len, __VA_ARGS__); \ + throw ::rocprofsys::exception( \ ::tim::log::string(::tim::log::color::fatal(), _msg_buffer)); \ } -#define OMNITRACE_CI_THROW_E(COND, TYPE, ...) \ - OMNITRACE_CONDITIONAL_THROW_E( \ - ::omnitrace::get_is_continuous_integration() && (COND), TYPE, __VA_ARGS__) +#define ROCPROFSYS_CI_THROW_E(COND, TYPE, ...) \ + ROCPROFSYS_CONDITIONAL_THROW_E( \ + ::rocprofsys::get_is_continuous_integration() && (COND), TYPE, __VA_ARGS__) -#define OMNITRACE_CI_BASIC_THROW_E(COND, TYPE, ...) \ - OMNITRACE_CONDITIONAL_BASIC_THROW_E( \ - ::omnitrace::get_is_continuous_integration() && (COND), TYPE, __VA_ARGS__) +#define ROCPROFSYS_CI_BASIC_THROW_E(COND, TYPE, ...) \ + ROCPROFSYS_CONDITIONAL_BASIC_THROW_E( \ + ::rocprofsys::get_is_continuous_integration() && (COND), TYPE, __VA_ARGS__) //--------------------------------------------------------------------------------------// -#define OMNITRACE_CONDITIONAL_THROW(COND, ...) \ - OMNITRACE_CONDITIONAL_THROW_E((COND), std::runtime_error, __VA_ARGS__) +#define ROCPROFSYS_CONDITIONAL_THROW(COND, ...) \ + ROCPROFSYS_CONDITIONAL_THROW_E((COND), std::runtime_error, __VA_ARGS__) -#define OMNITRACE_CONDITIONAL_BASIC_THROW(COND, ...) \ - OMNITRACE_CONDITIONAL_BASIC_THROW_E((COND), std::runtime_error, __VA_ARGS__) +#define ROCPROFSYS_CONDITIONAL_BASIC_THROW(COND, ...) \ + ROCPROFSYS_CONDITIONAL_BASIC_THROW_E((COND), std::runtime_error, __VA_ARGS__) -#define OMNITRACE_CI_THROW(COND, ...) \ - OMNITRACE_CI_THROW_E((COND), std::runtime_error, __VA_ARGS__) +#define ROCPROFSYS_CI_THROW(COND, ...) \ + ROCPROFSYS_CI_THROW_E((COND), std::runtime_error, __VA_ARGS__) -#define OMNITRACE_CI_BASIC_THROW(COND, ...) \ - OMNITRACE_CI_BASIC_THROW_E((COND), std::runtime_error, __VA_ARGS__) +#define ROCPROFSYS_CI_BASIC_THROW(COND, ...) \ + ROCPROFSYS_CI_BASIC_THROW_E((COND), std::runtime_error, __VA_ARGS__) //--------------------------------------------------------------------------------------// -#define OMNITRACE_CONDITIONAL_FAILURE(COND, METHOD, ...) \ - if(OMNITRACE_UNLIKELY((COND))) \ +#define ROCPROFSYS_CONDITIONAL_FAILURE(COND, METHOD, ...) \ + if(ROCPROFSYS_UNLIKELY((COND))) \ { \ - ::omnitrace::debug::flush(); \ - OMNITRACE_FPRINTF_STDERR_COLOR(fatal); \ - fprintf(::omnitrace::debug::get_file(), "[omnitrace][%i][%li]%s", \ - OMNITRACE_DEBUG_PROCESS_IDENTIFIER, OMNITRACE_DEBUG_THREAD_IDENTIFIER, \ - ::omnitrace::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ - fprintf(::omnitrace::debug::get_file(), __VA_ARGS__); \ - ::omnitrace::debug::flush(); \ - ::omnitrace::set_state(::omnitrace::State::Finalized); \ + ::rocprofsys::debug::flush(); \ + ROCPROFSYS_FPRINTF_STDERR_COLOR(fatal); \ + fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i][%li]%s", \ + ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_DEBUG_THREAD_IDENTIFIER, \ + ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ + fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \ + ::rocprofsys::debug::flush(); \ + ::rocprofsys::set_state(::rocprofsys::State::Finalized); \ timemory_print_demangled_backtrace<64>(); \ METHOD; \ } -#define OMNITRACE_CONDITIONAL_BASIC_FAILURE(COND, METHOD, ...) \ - if(OMNITRACE_UNLIKELY((COND))) \ +#define ROCPROFSYS_CONDITIONAL_BASIC_FAILURE(COND, METHOD, ...) \ + if(ROCPROFSYS_UNLIKELY((COND))) \ { \ - ::omnitrace::debug::flush(); \ - OMNITRACE_FPRINTF_STDERR_COLOR(fatal); \ - fprintf(::omnitrace::debug::get_file(), "[omnitrace][%i]%s", \ - OMNITRACE_DEBUG_PROCESS_IDENTIFIER, \ - ::omnitrace::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ - fprintf(::omnitrace::debug::get_file(), __VA_ARGS__); \ - ::omnitrace::debug::flush(); \ - ::omnitrace::set_state(::omnitrace::State::Finalized); \ + ::rocprofsys::debug::flush(); \ + ROCPROFSYS_FPRINTF_STDERR_COLOR(fatal); \ + fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i]%s", \ + ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, \ + ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ + fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \ + ::rocprofsys::debug::flush(); \ + ::rocprofsys::set_state(::rocprofsys::State::Finalized); \ timemory_print_demangled_backtrace<64>(); \ METHOD; \ } -#define OMNITRACE_CONDITIONAL_FAILURE_F(COND, METHOD, ...) \ - if(OMNITRACE_UNLIKELY((COND))) \ +#define ROCPROFSYS_CONDITIONAL_FAILURE_F(COND, METHOD, ...) \ + if(ROCPROFSYS_UNLIKELY((COND))) \ { \ - ::omnitrace::debug::flush(); \ - OMNITRACE_FPRINTF_STDERR_COLOR(fatal); \ - fprintf(::omnitrace::debug::get_file(), "[omnitrace][%i][%li][%s]%s", \ - OMNITRACE_DEBUG_PROCESS_IDENTIFIER, OMNITRACE_DEBUG_THREAD_IDENTIFIER, \ - OMNITRACE_FUNCTION, \ - ::omnitrace::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ - fprintf(::omnitrace::debug::get_file(), __VA_ARGS__); \ - ::omnitrace::debug::flush(); \ - ::omnitrace::set_state(::omnitrace::State::Finalized); \ + ::rocprofsys::debug::flush(); \ + ROCPROFSYS_FPRINTF_STDERR_COLOR(fatal); \ + fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i][%li][%s]%s", \ + ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_DEBUG_THREAD_IDENTIFIER, \ + ROCPROFSYS_FUNCTION, \ + ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ + fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \ + ::rocprofsys::debug::flush(); \ + ::rocprofsys::set_state(::rocprofsys::State::Finalized); \ timemory_print_demangled_backtrace<64>(); \ METHOD; \ } -#define OMNITRACE_CONDITIONAL_BASIC_FAILURE_F(COND, METHOD, ...) \ - if(OMNITRACE_UNLIKELY((COND))) \ +#define ROCPROFSYS_CONDITIONAL_BASIC_FAILURE_F(COND, METHOD, ...) \ + if(ROCPROFSYS_UNLIKELY((COND))) \ { \ - ::omnitrace::debug::flush(); \ - OMNITRACE_FPRINTF_STDERR_COLOR(fatal); \ - fprintf(::omnitrace::debug::get_file(), "[omnitrace][%i][%s]%s", \ - OMNITRACE_DEBUG_PROCESS_IDENTIFIER, OMNITRACE_FUNCTION, \ - ::omnitrace::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ - fprintf(::omnitrace::debug::get_file(), __VA_ARGS__); \ - ::omnitrace::debug::flush(); \ - ::omnitrace::set_state(::omnitrace::State::Finalized); \ + ::rocprofsys::debug::flush(); \ + ROCPROFSYS_FPRINTF_STDERR_COLOR(fatal); \ + fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i][%s]%s", \ + ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_FUNCTION, \ + ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \ + fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \ + ::rocprofsys::debug::flush(); \ + ::rocprofsys::set_state(::rocprofsys::State::Finalized); \ timemory_print_demangled_backtrace<64>(); \ METHOD; \ } -#define OMNITRACE_CI_FAILURE(COND, METHOD, ...) \ - OMNITRACE_CONDITIONAL_FAILURE( \ - ::omnitrace::get_is_continuous_integration() && (COND), METHOD, __VA_ARGS__) +#define ROCPROFSYS_CI_FAILURE(COND, METHOD, ...) \ + ROCPROFSYS_CONDITIONAL_FAILURE( \ + ::rocprofsys::get_is_continuous_integration() && (COND), METHOD, __VA_ARGS__) -#define OMNITRACE_CI_BASIC_FAILURE(COND, METHOD, ...) \ - OMNITRACE_CONDITIONAL_BASIC_FAILURE( \ - ::omnitrace::get_is_continuous_integration() && (COND), METHOD, __VA_ARGS__) +#define ROCPROFSYS_CI_BASIC_FAILURE(COND, METHOD, ...) \ + ROCPROFSYS_CONDITIONAL_BASIC_FAILURE( \ + ::rocprofsys::get_is_continuous_integration() && (COND), METHOD, __VA_ARGS__) //--------------------------------------------------------------------------------------// -#define OMNITRACE_CONDITIONAL_FAIL(COND, ...) \ - OMNITRACE_CONDITIONAL_FAILURE(COND, OMNITRACE_ESC(::std::exit(EXIT_FAILURE)), \ - __VA_ARGS__) +#define ROCPROFSYS_CONDITIONAL_FAIL(COND, ...) \ + ROCPROFSYS_CONDITIONAL_FAILURE(COND, ROCPROFSYS_ESC(::std::exit(EXIT_FAILURE)), \ + __VA_ARGS__) -#define OMNITRACE_CONDITIONAL_BASIC_FAIL(COND, ...) \ - OMNITRACE_CONDITIONAL_BASIC_FAILURE(COND, OMNITRACE_ESC(::std::exit(EXIT_FAILURE)), \ - __VA_ARGS__) +#define ROCPROFSYS_CONDITIONAL_BASIC_FAIL(COND, ...) \ + ROCPROFSYS_CONDITIONAL_BASIC_FAILURE( \ + COND, ROCPROFSYS_ESC(::std::exit(EXIT_FAILURE)), __VA_ARGS__) -#define OMNITRACE_CONDITIONAL_FAIL_F(COND, ...) \ - OMNITRACE_CONDITIONAL_FAILURE_F(COND, OMNITRACE_ESC(::std::exit(EXIT_FAILURE)), \ - __VA_ARGS__) +#define ROCPROFSYS_CONDITIONAL_FAIL_F(COND, ...) \ + ROCPROFSYS_CONDITIONAL_FAILURE_F(COND, ROCPROFSYS_ESC(::std::exit(EXIT_FAILURE)), \ + __VA_ARGS__) -#define OMNITRACE_CONDITIONAL_BASIC_FAIL_F(COND, ...) \ - OMNITRACE_CONDITIONAL_BASIC_FAILURE_F( \ - COND, OMNITRACE_ESC(::std::exit(EXIT_FAILURE)), __VA_ARGS__) +#define ROCPROFSYS_CONDITIONAL_BASIC_FAIL_F(COND, ...) \ + ROCPROFSYS_CONDITIONAL_BASIC_FAILURE_F( \ + COND, ROCPROFSYS_ESC(::std::exit(EXIT_FAILURE)), __VA_ARGS__) -#define OMNITRACE_CI_FAIL(COND, ...) \ - OMNITRACE_CI_FAILURE(COND, OMNITRACE_ESC(::std::exit(EXIT_FAILURE)), __VA_ARGS__) +#define ROCPROFSYS_CI_FAIL(COND, ...) \ + ROCPROFSYS_CI_FAILURE(COND, ROCPROFSYS_ESC(::std::exit(EXIT_FAILURE)), __VA_ARGS__) -#define OMNITRACE_CI_BASIC_FAIL(COND, ...) \ - OMNITRACE_CI_BASIC_FAILURE(COND, OMNITRACE_ESC(::std::exit(EXIT_FAILURE)), \ - __VA_ARGS__) +#define ROCPROFSYS_CI_BASIC_FAIL(COND, ...) \ + ROCPROFSYS_CI_BASIC_FAILURE(COND, ROCPROFSYS_ESC(::std::exit(EXIT_FAILURE)), \ + __VA_ARGS__) //--------------------------------------------------------------------------------------// -#define OMNITRACE_CONDITIONAL_ABORT(COND, ...) \ - OMNITRACE_CONDITIONAL_FAILURE(COND, OMNITRACE_ESC(::std::abort()), __VA_ARGS__) +#define ROCPROFSYS_CONDITIONAL_ABORT(COND, ...) \ + ROCPROFSYS_CONDITIONAL_FAILURE(COND, ROCPROFSYS_ESC(::std::abort()), __VA_ARGS__) -#define OMNITRACE_CONDITIONAL_BASIC_ABORT(COND, ...) \ - OMNITRACE_CONDITIONAL_BASIC_FAILURE(COND, OMNITRACE_ESC(::std::abort()), __VA_ARGS__) +#define ROCPROFSYS_CONDITIONAL_BASIC_ABORT(COND, ...) \ + ROCPROFSYS_CONDITIONAL_BASIC_FAILURE(COND, ROCPROFSYS_ESC(::std::abort()), \ + __VA_ARGS__) -#define OMNITRACE_CONDITIONAL_ABORT_F(COND, ...) \ - OMNITRACE_CONDITIONAL_FAILURE_F(COND, OMNITRACE_ESC(::std::abort()), __VA_ARGS__) +#define ROCPROFSYS_CONDITIONAL_ABORT_F(COND, ...) \ + ROCPROFSYS_CONDITIONAL_FAILURE_F(COND, ROCPROFSYS_ESC(::std::abort()), __VA_ARGS__) -#define OMNITRACE_CONDITIONAL_BASIC_ABORT_F(COND, ...) \ - OMNITRACE_CONDITIONAL_BASIC_FAILURE_F(COND, OMNITRACE_ESC(::std::abort()), \ - __VA_ARGS__) +#define ROCPROFSYS_CONDITIONAL_BASIC_ABORT_F(COND, ...) \ + ROCPROFSYS_CONDITIONAL_BASIC_FAILURE_F(COND, ROCPROFSYS_ESC(::std::abort()), \ + __VA_ARGS__) -#define OMNITRACE_CI_ABORT(COND, ...) \ - OMNITRACE_CI_FAILURE(COND, OMNITRACE_ESC(::std::abort()), __VA_ARGS__) +#define ROCPROFSYS_CI_ABORT(COND, ...) \ + ROCPROFSYS_CI_FAILURE(COND, ROCPROFSYS_ESC(::std::abort()), __VA_ARGS__) -#define OMNITRACE_CI_BASIC_ABORT(COND, ...) \ - OMNITRACE_CI_BASIC_FAILURE(COND, OMNITRACE_ESC(::std::abort()), __VA_ARGS__) +#define ROCPROFSYS_CI_BASIC_ABORT(COND, ...) \ + ROCPROFSYS_CI_BASIC_FAILURE(COND, ROCPROFSYS_ESC(::std::abort()), __VA_ARGS__) //--------------------------------------------------------------------------------------// // @@ -545,17 +546,17 @@ as_hex(void*, size_t); // //--------------------------------------------------------------------------------------// -#define OMNITRACE_DEBUG(...) \ - OMNITRACE_CONDITIONAL_PRINT(::omnitrace::get_debug(), __VA_ARGS__) +#define ROCPROFSYS_DEBUG(...) \ + ROCPROFSYS_CONDITIONAL_PRINT(::rocprofsys::get_debug(), __VA_ARGS__) -#define OMNITRACE_BASIC_DEBUG(...) \ - OMNITRACE_CONDITIONAL_BASIC_PRINT(::omnitrace::get_debug_env(), __VA_ARGS__) +#define ROCPROFSYS_BASIC_DEBUG(...) \ + ROCPROFSYS_CONDITIONAL_BASIC_PRINT(::rocprofsys::get_debug_env(), __VA_ARGS__) -#define OMNITRACE_DEBUG_F(...) \ - OMNITRACE_CONDITIONAL_PRINT_F(::omnitrace::get_debug(), __VA_ARGS__) +#define ROCPROFSYS_DEBUG_F(...) \ + ROCPROFSYS_CONDITIONAL_PRINT_F(::rocprofsys::get_debug(), __VA_ARGS__) -#define OMNITRACE_BASIC_DEBUG_F(...) \ - OMNITRACE_CONDITIONAL_BASIC_PRINT_F(::omnitrace::get_debug_env(), __VA_ARGS__) +#define ROCPROFSYS_BASIC_DEBUG_F(...) \ + ROCPROFSYS_CONDITIONAL_BASIC_PRINT_F(::rocprofsys::get_debug_env(), __VA_ARGS__) //--------------------------------------------------------------------------------------// // @@ -563,23 +564,25 @@ as_hex(void*, size_t); // //--------------------------------------------------------------------------------------// -#define OMNITRACE_VERBOSE(LEVEL, ...) \ - OMNITRACE_CONDITIONAL_PRINT( \ - ::omnitrace::get_debug() || (::omnitrace::get_verbose() >= LEVEL), __VA_ARGS__) +#define ROCPROFSYS_VERBOSE(LEVEL, ...) \ + ROCPROFSYS_CONDITIONAL_PRINT(::rocprofsys::get_debug() || \ + (::rocprofsys::get_verbose() >= LEVEL), \ + __VA_ARGS__) -#define OMNITRACE_BASIC_VERBOSE(LEVEL, ...) \ - OMNITRACE_CONDITIONAL_BASIC_PRINT(::omnitrace::get_debug_env() || \ - (::omnitrace::get_verbose_env() >= LEVEL), \ - __VA_ARGS__) +#define ROCPROFSYS_BASIC_VERBOSE(LEVEL, ...) \ + ROCPROFSYS_CONDITIONAL_BASIC_PRINT(::rocprofsys::get_debug_env() || \ + (::rocprofsys::get_verbose_env() >= LEVEL), \ + __VA_ARGS__) -#define OMNITRACE_VERBOSE_F(LEVEL, ...) \ - OMNITRACE_CONDITIONAL_PRINT_F( \ - ::omnitrace::get_debug() || (::omnitrace::get_verbose() >= LEVEL), __VA_ARGS__) +#define ROCPROFSYS_VERBOSE_F(LEVEL, ...) \ + ROCPROFSYS_CONDITIONAL_PRINT_F(::rocprofsys::get_debug() || \ + (::rocprofsys::get_verbose() >= LEVEL), \ + __VA_ARGS__) -#define OMNITRACE_BASIC_VERBOSE_F(LEVEL, ...) \ - OMNITRACE_CONDITIONAL_BASIC_PRINT_F(::omnitrace::get_debug_env() || \ - (::omnitrace::get_verbose_env() >= LEVEL), \ - __VA_ARGS__) +#define ROCPROFSYS_BASIC_VERBOSE_F(LEVEL, ...) \ + ROCPROFSYS_CONDITIONAL_BASIC_PRINT_F(::rocprofsys::get_debug_env() || \ + (::rocprofsys::get_verbose_env() >= LEVEL), \ + __VA_ARGS__) //--------------------------------------------------------------------------------------// // @@ -587,49 +590,51 @@ as_hex(void*, size_t); // //--------------------------------------------------------------------------------------// -#define OMNITRACE_WARNING(LEVEL, ...) \ - OMNITRACE_CONDITIONAL_WARN( \ - ::omnitrace::get_debug() || (::omnitrace::get_verbose() >= LEVEL), __VA_ARGS__) +#define ROCPROFSYS_WARNING(LEVEL, ...) \ + ROCPROFSYS_CONDITIONAL_WARN(::rocprofsys::get_debug() || \ + (::rocprofsys::get_verbose() >= LEVEL), \ + __VA_ARGS__) -#define OMNITRACE_BASIC_WARNING(LEVEL, ...) \ - OMNITRACE_CONDITIONAL_BASIC_WARN(::omnitrace::get_debug_env() || \ - (::omnitrace::get_verbose_env() >= LEVEL), \ - __VA_ARGS__) +#define ROCPROFSYS_BASIC_WARNING(LEVEL, ...) \ + ROCPROFSYS_CONDITIONAL_BASIC_WARN(::rocprofsys::get_debug_env() || \ + (::rocprofsys::get_verbose_env() >= LEVEL), \ + __VA_ARGS__) -#define OMNITRACE_WARNING_F(LEVEL, ...) \ - OMNITRACE_CONDITIONAL_WARN_F( \ - ::omnitrace::get_debug() || (::omnitrace::get_verbose() >= LEVEL), __VA_ARGS__) +#define ROCPROFSYS_WARNING_F(LEVEL, ...) \ + ROCPROFSYS_CONDITIONAL_WARN_F(::rocprofsys::get_debug() || \ + (::rocprofsys::get_verbose() >= LEVEL), \ + __VA_ARGS__) -#define OMNITRACE_BASIC_WARNING_F(LEVEL, ...) \ - OMNITRACE_CONDITIONAL_BASIC_WARN_F(::omnitrace::get_debug_env() || \ - (::omnitrace::get_verbose_env() >= LEVEL), \ - __VA_ARGS__) +#define ROCPROFSYS_BASIC_WARNING_F(LEVEL, ...) \ + ROCPROFSYS_CONDITIONAL_BASIC_WARN_F(::rocprofsys::get_debug_env() || \ + (::rocprofsys::get_verbose_env() >= LEVEL), \ + __VA_ARGS__) -#define OMNITRACE_WARNING_IF(COND, ...) OMNITRACE_CONDITIONAL_WARN((COND), __VA_ARGS__) +#define ROCPROFSYS_WARNING_IF(COND, ...) ROCPROFSYS_CONDITIONAL_WARN((COND), __VA_ARGS__) -#define OMNITRACE_WARNING_IF_F(COND, ...) \ - OMNITRACE_CONDITIONAL_WARN_F((COND), __VA_ARGS__) +#define ROCPROFSYS_WARNING_IF_F(COND, ...) \ + ROCPROFSYS_CONDITIONAL_WARN_F((COND), __VA_ARGS__) -#define OMNITRACE_WARNING_OR_CI_THROW(LEVEL, ...) \ +#define ROCPROFSYS_WARNING_OR_CI_THROW(LEVEL, ...) \ { \ - if(OMNITRACE_UNLIKELY(::omnitrace::get_is_continuous_integration())) \ + if(ROCPROFSYS_UNLIKELY(::rocprofsys::get_is_continuous_integration())) \ { \ - OMNITRACE_CI_THROW(true, __VA_ARGS__); \ + ROCPROFSYS_CI_THROW(true, __VA_ARGS__); \ } \ else \ { \ - OMNITRACE_CONDITIONAL_WARN(::omnitrace::get_debug() || \ - (::omnitrace::get_verbose() >= LEVEL), \ - __VA_ARGS__) \ + ROCPROFSYS_CONDITIONAL_WARN(::rocprofsys::get_debug() || \ + (::rocprofsys::get_verbose() >= LEVEL), \ + __VA_ARGS__) \ } \ } -#define OMNITRACE_REQUIRE(...) TIMEMORY_REQUIRE(__VA_ARGS__) -#define OMNITRACE_PREFER(COND) \ - ((OMNITRACE_LIKELY(COND)) \ +#define ROCPROFSYS_REQUIRE(...) TIMEMORY_REQUIRE(__VA_ARGS__) +#define ROCPROFSYS_PREFER(COND) \ + ((ROCPROFSYS_LIKELY(COND)) \ ? ::tim::log::base() \ - : ((::omnitrace::get_is_continuous_integration()) ? TIMEMORY_FATAL \ - : TIMEMORY_WARNING)) + : ((::rocprofsys::get_is_continuous_integration()) ? TIMEMORY_FATAL \ + : TIMEMORY_WARNING)) //--------------------------------------------------------------------------------------// // @@ -638,10 +643,10 @@ as_hex(void*, size_t); // //--------------------------------------------------------------------------------------// -#define OMNITRACE_BASIC_PRINT(...) OMNITRACE_CONDITIONAL_BASIC_PRINT(true, __VA_ARGS__) +#define ROCPROFSYS_BASIC_PRINT(...) ROCPROFSYS_CONDITIONAL_BASIC_PRINT(true, __VA_ARGS__) -#define OMNITRACE_BASIC_PRINT_F(...) \ - OMNITRACE_CONDITIONAL_BASIC_PRINT_F(true, __VA_ARGS__) +#define ROCPROFSYS_BASIC_PRINT_F(...) \ + ROCPROFSYS_CONDITIONAL_BASIC_PRINT_F(true, __VA_ARGS__) //--------------------------------------------------------------------------------------// // @@ -649,9 +654,9 @@ as_hex(void*, size_t); // //--------------------------------------------------------------------------------------// -#define OMNITRACE_PRINT(...) OMNITRACE_CONDITIONAL_PRINT(true, __VA_ARGS__) +#define ROCPROFSYS_PRINT(...) ROCPROFSYS_CONDITIONAL_PRINT(true, __VA_ARGS__) -#define OMNITRACE_PRINT_F(...) OMNITRACE_CONDITIONAL_PRINT_F(true, __VA_ARGS__) +#define ROCPROFSYS_PRINT_F(...) ROCPROFSYS_CONDITIONAL_PRINT_F(true, __VA_ARGS__) //--------------------------------------------------------------------------------------// // @@ -659,9 +664,9 @@ as_hex(void*, size_t); // //--------------------------------------------------------------------------------------// -#define OMNITRACE_THROW(...) OMNITRACE_CONDITIONAL_THROW(true, __VA_ARGS__) +#define ROCPROFSYS_THROW(...) ROCPROFSYS_CONDITIONAL_THROW(true, __VA_ARGS__) -#define OMNITRACE_BASIC_THROW(...) OMNITRACE_CONDITIONAL_BASIC_THROW(true, __VA_ARGS__) +#define ROCPROFSYS_BASIC_THROW(...) ROCPROFSYS_CONDITIONAL_BASIC_THROW(true, __VA_ARGS__) //--------------------------------------------------------------------------------------// // @@ -669,13 +674,14 @@ as_hex(void*, size_t); // //--------------------------------------------------------------------------------------// -#define OMNITRACE_FAIL(...) OMNITRACE_CONDITIONAL_FAIL(true, __VA_ARGS__) +#define ROCPROFSYS_FAIL(...) ROCPROFSYS_CONDITIONAL_FAIL(true, __VA_ARGS__) -#define OMNITRACE_FAIL_F(...) OMNITRACE_CONDITIONAL_FAIL_F(true, __VA_ARGS__) +#define ROCPROFSYS_FAIL_F(...) ROCPROFSYS_CONDITIONAL_FAIL_F(true, __VA_ARGS__) -#define OMNITRACE_BASIC_FAIL(...) OMNITRACE_CONDITIONAL_BASIC_FAIL(true, __VA_ARGS__) +#define ROCPROFSYS_BASIC_FAIL(...) ROCPROFSYS_CONDITIONAL_BASIC_FAIL(true, __VA_ARGS__) -#define OMNITRACE_BASIC_FAIL_F(...) OMNITRACE_CONDITIONAL_BASIC_FAIL_F(true, __VA_ARGS__) +#define ROCPROFSYS_BASIC_FAIL_F(...) \ + ROCPROFSYS_CONDITIONAL_BASIC_FAIL_F(true, __VA_ARGS__) //--------------------------------------------------------------------------------------// // @@ -683,14 +689,14 @@ as_hex(void*, size_t); // //--------------------------------------------------------------------------------------// -#define OMNITRACE_ABORT(...) OMNITRACE_CONDITIONAL_ABORT(true, __VA_ARGS__) +#define ROCPROFSYS_ABORT(...) ROCPROFSYS_CONDITIONAL_ABORT(true, __VA_ARGS__) -#define OMNITRACE_ABORT_F(...) OMNITRACE_CONDITIONAL_ABORT_F(true, __VA_ARGS__) +#define ROCPROFSYS_ABORT_F(...) ROCPROFSYS_CONDITIONAL_ABORT_F(true, __VA_ARGS__) -#define OMNITRACE_BASIC_ABORT(...) OMNITRACE_CONDITIONAL_BASIC_ABORT(true, __VA_ARGS__) +#define ROCPROFSYS_BASIC_ABORT(...) ROCPROFSYS_CONDITIONAL_BASIC_ABORT(true, __VA_ARGS__) -#define OMNITRACE_BASIC_ABORT_F(...) \ - OMNITRACE_CONDITIONAL_BASIC_ABORT_F(true, __VA_ARGS__) +#define ROCPROFSYS_BASIC_ABORT_F(...) \ + ROCPROFSYS_CONDITIONAL_BASIC_ABORT_F(true, __VA_ARGS__) #include diff --git a/source/lib/core/defines.hpp.in b/source/lib/core/defines.hpp.in index 1911e3e0..678600ab 100644 --- a/source/lib/core/defines.hpp.in +++ b/source/lib/core/defines.hpp.in @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -24,10 +24,10 @@ #include "common/defines.h" -#define OMNITRACE_METADATA(...) ::tim::manager::add_metadata(__VA_ARGS__) +#define ROCPROFSYS_METADATA(...) ::tim::manager::add_metadata(__VA_ARGS__) -#if !defined(OMNITRACE_DEFAULT_OBJECT) -# define OMNITRACE_DEFAULT_OBJECT(NAME) \ +#if !defined(ROCPROFSYS_DEFAULT_OBJECT) +# define ROCPROFSYS_DEFAULT_OBJECT(NAME) \ NAME() = default; \ NAME(const NAME&) = default; \ NAME(NAME&&) noexcept = default; \ @@ -35,8 +35,8 @@ NAME& operator=(NAME&&) noexcept = default; #endif -#if !defined(OMNITRACE_DEFAULT_COPY_MOVE) -# define OMNITRACE_DEFAULT_COPY_MOVE(NAME) \ +#if !defined(ROCPROFSYS_DEFAULT_COPY_MOVE) +# define ROCPROFSYS_DEFAULT_COPY_MOVE(NAME) \ NAME(const NAME&) = default; \ NAME(NAME&&) noexcept = default; \ NAME& operator=(const NAME&) = default; \ diff --git a/source/lib/core/dynamic_library.cpp b/source/lib/core/dynamic_library.cpp index 9959d0ef..37706268 100644 --- a/source/lib/core/dynamic_library.cpp +++ b/source/lib/core/dynamic_library.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -33,7 +33,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace procfs = ::tim::procfs; @@ -100,14 +100,15 @@ dynamic_library::dynamic_library(std::string _env, std::string _fname, int _flag } else if(_env_val.find('/') == 0) { - OMNITRACE_VERBOSE_F(1, - "Ignoring environment variable %s=\"%s\" because the " - "filepath does not exist. Using \"%s\" instead...\n", - envname.c_str(), _env_val.c_str(), filename.c_str()) + ROCPROFSYS_VERBOSE_F( + 1, + "Ignoring environment variable %s=\"%s\" because the " + "filepath does not exist. Using \"%s\" instead...\n", + envname.c_str(), _env_val.c_str(), filename.c_str()) } else if(_env_val.find('/') != 0 && filename.find('/') == 0) { - OMNITRACE_VERBOSE_F( + ROCPROFSYS_VERBOSE_F( 1, "Ignoring environment variable %s=\"%s\" because the " "filepath is relative. Using absolute path \"%s\" instead...\n", @@ -129,8 +130,8 @@ dynamic_library::open() handle = dlopen(filename.c_str(), flags); if(!handle) { - OMNITRACE_VERBOSE(2, "[dynamic_library] Error opening %s=\"%s\" :: %s.\n", - envname.c_str(), filename.c_str(), dlerror()); + ROCPROFSYS_VERBOSE(2, "[dynamic_library] Error opening %s=\"%s\" :: %s.\n", + envname.c_str(), filename.c_str(), dlerror()); } dlerror(); // Clear any existing error } @@ -149,4 +150,4 @@ dynamic_library::is_open() const { return (handle != nullptr); } -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/dynamic_library.hpp b/source/lib/core/dynamic_library.hpp index b8979aef..d280488b 100644 --- a/source/lib/core/dynamic_library.hpp +++ b/source/lib/core/dynamic_library.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -29,7 +29,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { std::string find_library_path(const std::string& _name, const std::vector& _env_vars, @@ -77,10 +77,10 @@ dynamic_library::invoke(std::string_view _name, RetT (*&_func)(Args...), Args... } else { - fprintf(stderr, "[omnitrace][pid=%i]> %s :: %s\n", getpid(), _name.data(), + fprintf(stderr, "[rocprof-sys][pid=%i]> %s :: %s\n", getpid(), _name.data(), dlerror()); } } return RetT{}; } -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/exception.cpp b/source/lib/core/exception.cpp index e95d43cb..213a2608 100644 --- a/source/lib/core/exception.cpp +++ b/source/lib/core/exception.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -37,7 +37,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace { @@ -125,4 +125,4 @@ template class exception; // template class exception; // template class exception; // template class exception; -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/exception.hpp b/source/lib/core/exception.hpp index fd098ef6..96435e4c 100644 --- a/source/lib/core/exception.hpp +++ b/source/lib/core/exception.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -28,7 +28,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { template class exception : public Tp @@ -50,4 +50,4 @@ class exception : public Tp private: char* m_what = nullptr; }; -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/gpu.cpp b/source/lib/core/gpu.cpp index d56dc7bb..1dfc7c46 100644 --- a/source/lib/core/gpu.cpp +++ b/source/lib/core/gpu.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -22,17 +22,17 @@ #include "common/defines.h" -#if !defined(OMNITRACE_USE_ROCM_SMI) -# define OMNITRACE_USE_ROCM_SMI 0 +#if !defined(ROCPROFSYS_USE_ROCM_SMI) +# define ROCPROFSYS_USE_ROCM_SMI 0 #endif -#if !defined(OMNITRACE_USE_HIP) -# define OMNITRACE_USE_HIP 0 +#if !defined(ROCPROFSYS_USE_HIP) +# define ROCPROFSYS_USE_HIP 0 #endif #include "core/hip_runtime.hpp" -#if OMNITRACE_USE_HIP > 0 +#if ROCPROFSYS_USE_HIP > 0 # if !defined(TIMEMORY_USE_HIP) # define TIMEMORY_USE_HIP 1 # endif @@ -44,19 +44,19 @@ #include -#if OMNITRACE_USE_ROCM_SMI > 0 +#if ROCPROFSYS_USE_ROCM_SMI > 0 # include #endif -#if OMNITRACE_USE_HIP > 0 +#if ROCPROFSYS_USE_HIP > 0 # include -# if !defined(OMNITRACE_HIP_RUNTIME_CALL) -# define OMNITRACE_HIP_RUNTIME_CALL(err) \ +# if !defined(ROCPROFSYS_HIP_RUNTIME_CALL) +# define ROCPROFSYS_HIP_RUNTIME_CALL(err) \ { \ if(err != ::tim::hip::success_v && (int) err != 0) \ { \ - OMNITRACE_THROW( \ + ROCPROFSYS_THROW( \ "[%s:%d] Warning! HIP API call failed with code %i :: %s\n", \ __FILE__, __LINE__, (int) err, hipGetErrorString(err)); \ } \ @@ -64,7 +64,7 @@ # endif #endif -namespace omnitrace +namespace rocprofsys { namespace gpu { @@ -72,9 +72,9 @@ namespace { namespace scope = ::tim::scope; -#if OMNITRACE_USE_ROCM_SMI > 0 -# define OMNITRACE_ROCM_SMI_CALL(ERROR_CODE) \ - ::omnitrace::gpu::check_rsmi_error(ERROR_CODE, __FILE__, __LINE__) +#if ROCPROFSYS_USE_ROCM_SMI > 0 +# define ROCPROFSYS_ROCM_SMI_CALL(ERROR_CODE) \ + ::rocprofsys::gpu::check_rsmi_error(ERROR_CODE, __FILE__, __LINE__) void check_rsmi_error(rsmi_status_t _code, const char* _file, int _line) @@ -83,11 +83,11 @@ check_rsmi_error(rsmi_status_t _code, const char* _file, int _line) const char* _msg = nullptr; auto _err = rsmi_status_string(_code, &_msg); if(_err != RSMI_STATUS_SUCCESS) - OMNITRACE_THROW("rsmi_status_string failed. No error message available. " - "Error code %i originated at %s:%i\n", - static_cast(_code), _file, _line); - OMNITRACE_THROW("[%s:%i] Error code %i :: %s", _file, _line, static_cast(_code), - _msg); + ROCPROFSYS_THROW("rsmi_status_string failed. No error message available. " + "Error code %i originated at %s:%i\n", + static_cast(_code), _file, _line); + ROCPROFSYS_THROW("[%s:%i] Error code %i :: %s", _file, _line, static_cast(_code), + _msg); } bool @@ -96,11 +96,11 @@ rsmi_init() auto _rsmi_init = []() { try { - OMNITRACE_ROCM_SMI_CALL(::rsmi_init(0)); + ROCPROFSYS_ROCM_SMI_CALL(::rsmi_init(0)); } catch(std::exception& _e) { - OMNITRACE_BASIC_VERBOSE(1, "Exception thrown initializing rocm-smi: %s\n", - _e.what()); + ROCPROFSYS_BASIC_VERBOSE(1, "Exception thrown initializing rocm-smi: %s\n", + _e.what()); return false; } return true; @@ -110,7 +110,7 @@ rsmi_init() } #endif -#if OMNITRACE_HIP_VERSION >= 60000 +#if ROCPROFSYS_HIP_VERSION >= 60000 template ::value, int> = 0> void @@ -164,7 +164,7 @@ device_prop_serialize(ArchiveT& archive, const char* name, hipDeviceArch_t arg) namespace cereal = tim::cereal; using cereal::make_nvp; -# define OMNITRACE_SERIALIZE_HIP_DEVICE_ARCH(NAME) \ +# define ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(NAME) \ { \ auto val = arg.NAME; \ archive(make_nvp(#NAME, val)); \ @@ -172,26 +172,26 @@ device_prop_serialize(ArchiveT& archive, const char* name, hipDeviceArch_t arg) archive.setNextName(name); archive.startNode(); - OMNITRACE_SERIALIZE_HIP_DEVICE_ARCH(hasGlobalInt32Atomics) - OMNITRACE_SERIALIZE_HIP_DEVICE_ARCH(hasGlobalFloatAtomicExch) - OMNITRACE_SERIALIZE_HIP_DEVICE_ARCH(hasSharedInt32Atomics) - OMNITRACE_SERIALIZE_HIP_DEVICE_ARCH(hasSharedFloatAtomicExch) - OMNITRACE_SERIALIZE_HIP_DEVICE_ARCH(hasFloatAtomicAdd) - OMNITRACE_SERIALIZE_HIP_DEVICE_ARCH(hasGlobalInt64Atomics) - OMNITRACE_SERIALIZE_HIP_DEVICE_ARCH(hasSharedInt64Atomics) - OMNITRACE_SERIALIZE_HIP_DEVICE_ARCH(hasDoubles) - OMNITRACE_SERIALIZE_HIP_DEVICE_ARCH(hasWarpVote) - OMNITRACE_SERIALIZE_HIP_DEVICE_ARCH(hasWarpBallot) - OMNITRACE_SERIALIZE_HIP_DEVICE_ARCH(hasWarpShuffle) - OMNITRACE_SERIALIZE_HIP_DEVICE_ARCH(hasFunnelShift) - OMNITRACE_SERIALIZE_HIP_DEVICE_ARCH(hasThreadFenceSystem) - OMNITRACE_SERIALIZE_HIP_DEVICE_ARCH(hasSyncThreadsExt) - OMNITRACE_SERIALIZE_HIP_DEVICE_ARCH(hasSurfaceFuncs) - OMNITRACE_SERIALIZE_HIP_DEVICE_ARCH(has3dGrid) - OMNITRACE_SERIALIZE_HIP_DEVICE_ARCH(hasDynamicParallelism) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasGlobalInt32Atomics) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasGlobalFloatAtomicExch) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasSharedInt32Atomics) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasSharedFloatAtomicExch) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasFloatAtomicAdd) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasGlobalInt64Atomics) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasSharedInt64Atomics) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasDoubles) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasWarpVote) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasWarpBallot) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasWarpShuffle) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasFunnelShift) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasThreadFenceSystem) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasSyncThreadsExt) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasSurfaceFuncs) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(has3dGrid) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH(hasDynamicParallelism) archive.finishNode(); -# undef OMNITRACE_SERIALIZE_HIP_DEVICE_ARCH +# undef ROCPROFSYS_SERIALIZE_HIP_DEVICE_ARCH } #endif } // namespace @@ -199,7 +199,7 @@ device_prop_serialize(ArchiveT& archive, const char* name, hipDeviceArch_t arg) int hip_device_count() { -#if OMNITRACE_USE_HIP > 0 +#if ROCPROFSYS_USE_HIP > 0 return ::tim::hip::device_count(); #else return 0; @@ -209,17 +209,17 @@ hip_device_count() int rsmi_device_count() { -#if OMNITRACE_USE_ROCM_SMI > 0 +#if ROCPROFSYS_USE_ROCM_SMI > 0 if(!rsmi_init()) return 0; static auto _num_devices = []() { uint32_t _v = 0; try { - OMNITRACE_ROCM_SMI_CALL(rsmi_num_monitor_devices(&_v)); + ROCPROFSYS_ROCM_SMI_CALL(rsmi_num_monitor_devices(&_v)); } catch(std::exception& _e) { - OMNITRACE_BASIC_VERBOSE( + ROCPROFSYS_BASIC_VERBOSE( 1, "Exception thrown getting the rocm-smi devices: %s\n", _e.what()); } return _v; @@ -234,10 +234,10 @@ rsmi_device_count() int device_count() { -#if OMNITRACE_USE_ROCM_SMI > 0 +#if ROCPROFSYS_USE_ROCM_SMI > 0 // store as static since calls after rsmi_shutdown will return zero return rsmi_device_count(); -#elif OMNITRACE_USE_HIP > 0 +#elif ROCPROFSYS_USE_HIP > 0 return ::tim::hip::device_count(); #else return 0; @@ -251,7 +251,7 @@ add_hip_device_metadata(ArchiveT& ar) namespace cereal = tim::cereal; using cereal::make_nvp; -#if OMNITRACE_USE_HIP > 0 +#if ROCPROFSYS_USE_HIP > 0 int _device_count = 0; int _current_device = 0; hipError_t _device_count_err = hipGetDeviceCount(&_device_count); @@ -263,7 +263,7 @@ add_hip_device_metadata(ArchiveT& ar) scope::destructor _dtor{ [_current_device, _current_device_err]() { if(_current_device_err == hipSuccess) { - OMNITRACE_HIP_RUNTIME_CALL(hipSetDevice(_current_device)); + ROCPROFSYS_HIP_RUNTIME_CALL(hipSetDevice(_current_device)); } } }; @@ -279,20 +279,20 @@ add_hip_device_metadata(ArchiveT& ar) auto _device_prop = hipDeviceProp_t{}; int _driver_version = 0; int _runtime_version = 0; - OMNITRACE_HIP_RUNTIME_CALL(hipSetDevice(dev)); - OMNITRACE_HIP_RUNTIME_CALL(hipGetDeviceProperties(&_device_prop, dev)); - OMNITRACE_HIP_RUNTIME_CALL(hipDriverGetVersion(&_driver_version)); - OMNITRACE_HIP_RUNTIME_CALL(hipRuntimeGetVersion(&_runtime_version)); + ROCPROFSYS_HIP_RUNTIME_CALL(hipSetDevice(dev)); + ROCPROFSYS_HIP_RUNTIME_CALL(hipGetDeviceProperties(&_device_prop, dev)); + ROCPROFSYS_HIP_RUNTIME_CALL(hipDriverGetVersion(&_driver_version)); + ROCPROFSYS_HIP_RUNTIME_CALL(hipRuntimeGetVersion(&_runtime_version)); ar.startNode(); -# if OMNITRACE_HIP_VERSION < 60000 +# if ROCPROFSYS_HIP_VERSION < 60000 using intvec_t = std::vector; -# define OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(NAME) \ +# define ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(NAME) \ ar(make_nvp(#NAME, _device_prop.NAME)); -# define OMNITRACE_SERIALIZE_HIP_DEVICE_PROP_ARRAY(NAME, ...) \ +# define ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP_ARRAY(NAME, ...) \ ar(make_nvp(NAME, __VA_ARGS__)); ar(make_nvp("name", std::string{ _device_prop.name })); @@ -301,162 +301,162 @@ add_hip_device_metadata(ArchiveT& ar) ar(make_nvp("capability.major_version", _device_prop.major)); ar(make_nvp("capability.minor_version", _device_prop.minor)); - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(totalGlobalMem) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(totalConstMem) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(clockRate) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(totalGlobalMem) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(totalConstMem) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(clockRate) -# if OMNITRACE_HIP_VERSION >= 50000 - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(memoryClockRate) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(memoryBusWidth) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(l2CacheSize) +# if ROCPROFSYS_HIP_VERSION >= 50000 + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(memoryClockRate) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(memoryBusWidth) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(l2CacheSize) # endif - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(sharedMemPerBlock) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(regsPerBlock) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(warpSize) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(multiProcessorCount) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxThreadsPerMultiProcessor) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxThreadsPerBlock) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP_ARRAY( + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(sharedMemPerBlock) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(regsPerBlock) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(warpSize) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(multiProcessorCount) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxThreadsPerMultiProcessor) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxThreadsPerBlock) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP_ARRAY( "maxThreadsDim", intvec_t{ _device_prop.maxThreadsDim[0], _device_prop.maxThreadsDim[1], _device_prop.maxThreadsDim[2] }) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP_ARRAY("maxGridSize", - intvec_t{ _device_prop.maxGridSize[0], - _device_prop.maxGridSize[1], - _device_prop.maxGridSize[2] }) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(memPitch) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(textureAlignment) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(kernelExecTimeoutEnabled) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(integrated) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(canMapHostMemory) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(ECCEnabled) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(cooperativeLaunch) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(cooperativeMultiDeviceLaunch) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(pciDomainID) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(pciBusID) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(pciDeviceID) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(computeMode) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(gcnArch) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(gcnArchName) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(isMultiGpuBoard) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(clockInstructionRate) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(pageableMemoryAccess) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(pageableMemoryAccessUsesHostPageTables) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(directManagedMemAccessFromHost) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(concurrentManagedAccess) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(concurrentKernels) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxSharedMemoryPerMultiProcessor) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(asicRevision) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP_ARRAY( + "maxGridSize", + intvec_t{ _device_prop.maxGridSize[0], _device_prop.maxGridSize[1], + _device_prop.maxGridSize[2] }) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(memPitch) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(textureAlignment) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(kernelExecTimeoutEnabled) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(integrated) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(canMapHostMemory) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(ECCEnabled) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(cooperativeLaunch) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(cooperativeMultiDeviceLaunch) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(pciDomainID) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(pciBusID) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(pciDeviceID) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(computeMode) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(gcnArch) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(gcnArchName) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(isMultiGpuBoard) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(clockInstructionRate) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(pageableMemoryAccess) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(pageableMemoryAccessUsesHostPageTables) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(directManagedMemAccessFromHost) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(concurrentManagedAccess) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(concurrentKernels) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxSharedMemoryPerMultiProcessor) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(asicRevision) # else -# define OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(NAME) \ +# define ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(NAME) \ device_prop_serialize(ar, #NAME, _device_prop.NAME); - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(name) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(uuid) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(luid) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(luidDeviceNodeMask) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(totalGlobalMem) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(sharedMemPerBlock) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(regsPerBlock) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(warpSize) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(memPitch) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxThreadsPerBlock) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxThreadsDim) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxGridSize) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(clockRate) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(totalConstMem) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(major) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(minor) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(textureAlignment) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(texturePitchAlignment) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(deviceOverlap) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(multiProcessorCount) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(kernelExecTimeoutEnabled) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(integrated) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(canMapHostMemory) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(computeMode) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxTexture1D) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxTexture1DMipmap) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxTexture1DLinear) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxTexture2D) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxTexture2DMipmap) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxTexture2DLinear) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxTexture2DGather) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxTexture3D) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxTexture3DAlt) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxTextureCubemap) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxTexture1DLayered) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxTexture2DLayered) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxTextureCubemapLayered) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxSurface1D) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxSurface2D) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxSurface3D) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxSurface1DLayered) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxSurface2DLayered) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxSurfaceCubemap) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxSurfaceCubemapLayered) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(surfaceAlignment) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(concurrentKernels) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(ECCEnabled) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(pciBusID) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(pciDeviceID) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(pciDomainID) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(tccDriver) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(asyncEngineCount) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(unifiedAddressing) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(memoryClockRate) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(memoryBusWidth) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(l2CacheSize) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(persistingL2CacheMaxSize) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxThreadsPerMultiProcessor) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(streamPrioritiesSupported) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(globalL1CacheSupported) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(localL1CacheSupported) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(sharedMemPerMultiprocessor) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(regsPerMultiprocessor) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(managedMemory) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(isMultiGpuBoard) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(multiGpuBoardGroupID) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(hostNativeAtomicSupported) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(singleToDoublePrecisionPerfRatio) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(pageableMemoryAccess) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(concurrentManagedAccess) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(computePreemptionSupported) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(canUseHostPointerForRegisteredMem) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(cooperativeLaunch) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(cooperativeMultiDeviceLaunch) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(sharedMemPerBlockOptin) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(pageableMemoryAccessUsesHostPageTables) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(directManagedMemAccessFromHost) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxBlocksPerMultiProcessor) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(accessPolicyMaxWindowSize) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(reservedSharedMemPerBlock) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(hostRegisterSupported) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(sparseHipArraySupported) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(hostRegisterReadOnlySupported) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(timelineSemaphoreInteropSupported) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(memoryPoolsSupported) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(gpuDirectRDMASupported) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(gpuDirectRDMAFlushWritesOptions) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(gpuDirectRDMAWritesOrdering) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(memoryPoolSupportedHandleTypes) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(deferredMappingHipArraySupported) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(ipcEventSupported) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(clusterLaunch) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(unifiedFunctionPointers) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(gcnArchName) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(maxSharedMemoryPerMultiProcessor) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(clockInstructionRate) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(arch) - // OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(hdpMemFlushCntl) - // OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(hdpRegFlushCntl) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(cooperativeMultiDeviceUnmatchedFunc) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(cooperativeMultiDeviceUnmatchedGridDim) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(cooperativeMultiDeviceUnmatchedBlockDim) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(cooperativeMultiDeviceUnmatchedSharedMem) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(isLargeBar) - OMNITRACE_SERIALIZE_HIP_DEVICE_PROP(asicRevision) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(name) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(uuid) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(luid) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(luidDeviceNodeMask) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(totalGlobalMem) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(sharedMemPerBlock) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(regsPerBlock) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(warpSize) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(memPitch) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxThreadsPerBlock) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxThreadsDim) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxGridSize) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(clockRate) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(totalConstMem) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(major) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(minor) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(textureAlignment) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(texturePitchAlignment) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(deviceOverlap) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(multiProcessorCount) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(kernelExecTimeoutEnabled) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(integrated) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(canMapHostMemory) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(computeMode) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTexture1D) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTexture1DMipmap) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTexture1DLinear) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTexture2D) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTexture2DMipmap) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTexture2DLinear) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTexture2DGather) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTexture3D) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTexture3DAlt) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTextureCubemap) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTexture1DLayered) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTexture2DLayered) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxTextureCubemapLayered) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxSurface1D) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxSurface2D) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxSurface3D) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxSurface1DLayered) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxSurface2DLayered) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxSurfaceCubemap) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxSurfaceCubemapLayered) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(surfaceAlignment) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(concurrentKernels) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(ECCEnabled) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(pciBusID) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(pciDeviceID) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(pciDomainID) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(tccDriver) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(asyncEngineCount) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(unifiedAddressing) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(memoryClockRate) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(memoryBusWidth) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(l2CacheSize) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(persistingL2CacheMaxSize) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxThreadsPerMultiProcessor) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(streamPrioritiesSupported) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(globalL1CacheSupported) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(localL1CacheSupported) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(sharedMemPerMultiprocessor) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(regsPerMultiprocessor) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(managedMemory) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(isMultiGpuBoard) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(multiGpuBoardGroupID) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(hostNativeAtomicSupported) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(singleToDoublePrecisionPerfRatio) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(pageableMemoryAccess) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(concurrentManagedAccess) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(computePreemptionSupported) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(canUseHostPointerForRegisteredMem) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(cooperativeLaunch) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(cooperativeMultiDeviceLaunch) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(sharedMemPerBlockOptin) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(pageableMemoryAccessUsesHostPageTables) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(directManagedMemAccessFromHost) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxBlocksPerMultiProcessor) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(accessPolicyMaxWindowSize) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(reservedSharedMemPerBlock) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(hostRegisterSupported) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(sparseHipArraySupported) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(hostRegisterReadOnlySupported) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(timelineSemaphoreInteropSupported) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(memoryPoolsSupported) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(gpuDirectRDMASupported) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(gpuDirectRDMAFlushWritesOptions) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(gpuDirectRDMAWritesOrdering) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(memoryPoolSupportedHandleTypes) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(deferredMappingHipArraySupported) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(ipcEventSupported) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(clusterLaunch) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(unifiedFunctionPointers) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(gcnArchName) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(maxSharedMemoryPerMultiProcessor) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(clockInstructionRate) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(arch) + // ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(hdpMemFlushCntl) + // ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(hdpRegFlushCntl) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(cooperativeMultiDeviceUnmatchedFunc) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(cooperativeMultiDeviceUnmatchedGridDim) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(cooperativeMultiDeviceUnmatchedBlockDim) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(cooperativeMultiDeviceUnmatchedSharedMem) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(isLargeBar) + ROCPROFSYS_SERIALIZE_HIP_DEVICE_PROP(asicRevision) # endif const auto _compute_mode_descr = std::array{ @@ -487,15 +487,15 @@ add_hip_device_metadata() { if(device_count() == 0) return; - OMNITRACE_METADATA([](auto& ar) { + ROCPROFSYS_METADATA([](auto& ar) { try { add_hip_device_metadata(ar); } catch(std::runtime_error& _e) { - OMNITRACE_VERBOSE(2, "%s\n", _e.what()); + ROCPROFSYS_VERBOSE(2, "%s\n", _e.what()); } }); } } // namespace gpu -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/gpu.hpp b/source/lib/core/gpu.hpp index 24e761c7..0989284b 100644 --- a/source/lib/core/gpu.hpp +++ b/source/lib/core/gpu.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -22,7 +22,7 @@ #pragma once -namespace omnitrace +namespace rocprofsys { namespace gpu { @@ -38,4 +38,4 @@ rsmi_device_count(); void add_hip_device_metadata(); } // namespace gpu -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/hip_runtime.hpp b/source/lib/core/hip_runtime.hpp index 492af153..9ec902dd 100644 --- a/source/lib/core/hip_runtime.hpp +++ b/source/lib/core/hip_runtime.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -24,7 +24,7 @@ #include "core/defines.hpp" -#if defined(OMNITRACE_USE_HIP) && OMNITRACE_USE_HIP > 0 +#if defined(ROCPROFSYS_USE_HIP) && ROCPROFSYS_USE_HIP > 0 # if defined(HIP_INCLUDE_HIP_HIP_RUNTIME_H) || \ defined(HIP_INCLUDE_HIP_HIP_RUNTIME_API_H) @@ -35,7 +35,7 @@ # define HIP_PROF_HIP_API_STRING 1 // following must be included before for ROCm 6.0+ -# if OMNITRACE_HIP_VERSION >= 60000 +# if ROCPROFSYS_HIP_VERSION >= 60000 # if defined(USE_PROF_API) # undef USE_PROF_API # endif diff --git a/source/lib/core/locking.hpp b/source/lib/core/locking.hpp index e3b00c94..bdc4af65 100644 --- a/source/lib/core/locking.hpp +++ b/source/lib/core/locking.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -27,11 +27,11 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace locking { using atomic_mutex = ::tim::locking::spin_mutex; using atomic_lock = ::tim::locking::spin_lock; } // namespace locking -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/mproc.cpp b/source/lib/core/mproc.cpp index 4fba4c0b..f4b61c4c 100644 --- a/source/lib/core/mproc.cpp +++ b/source/lib/core/mproc.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -32,7 +32,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace mproc { @@ -46,7 +46,7 @@ get_concurrent_processes(int _ppid) std::ifstream _ifs{ _inp }; if(!_ifs) { - OMNITRACE_VERBOSE_F(2, "Warning! File '%s' cannot be read\n", _inp.c_str()); + ROCPROFSYS_VERBOSE_F(2, "Warning! File '%s' cannot be read\n", _inp.c_str()); return _children; } @@ -191,4 +191,4 @@ diagnose_status(pid_t _pid, int _status, int _verbose) return _ec; } } // namespace mproc -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/mproc.hpp b/source/lib/core/mproc.hpp index b50c8034..fafb4eb1 100644 --- a/source/lib/core/mproc.hpp +++ b/source/lib/core/mproc.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -25,7 +25,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace mproc { @@ -42,4 +42,4 @@ wait_pid(pid_t _pid, int _opts = 0); int diagnose_status(pid_t _pid, int _status, int _verbose = 0); } // namespace mproc -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/perf.cpp b/source/lib/core/perf.cpp index e4579537..842b1c90 100644 --- a/source/lib/core/perf.cpp +++ b/source/lib/core/perf.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -25,7 +25,7 @@ #include -namespace omnitrace +namespace rocprofsys { namespace perf { @@ -101,7 +101,7 @@ get_hw_config(std::string_view _v) return hw_config::reference_cpu_cycles; else { - OMNITRACE_THROW("Unknown perf hardware config: %s", _v.data()); + ROCPROFSYS_THROW("Unknown perf hardware config: %s", _v.data()); } #undef HW_CONFIG_REGEX @@ -134,7 +134,7 @@ get_sw_config(std::string_view _v) return sw_config::emulation_faults; else { - OMNITRACE_THROW("Unknown perf hw cache config: %s", _v.data()); + ROCPROFSYS_THROW("Unknown perf hw cache config: %s", _v.data()); } #undef SW_CONFIG_REGEX @@ -165,7 +165,7 @@ get_hw_cache_config(std::string_view _v) else if(HW_CACHE_CONFIG_REGEX("NODE")) _value |= static_cast(hw_cache_config::node); else - OMNITRACE_THROW("Unknown perf software config: %s", _v.data()); + ROCPROFSYS_THROW("Unknown perf software config: %s", _v.data()); #undef HW_CACHE_CONFIG_REGEX #define HW_CACHE_OP_REGEX(KEY) \ @@ -226,7 +226,7 @@ config_overflow_sampling(struct perf_event_attr& _pe, std::string_view _event, case PERF_TYPE_MAX: default: { - OMNITRACE_THROW("unsupported perf type"); + ROCPROFSYS_THROW("unsupported perf type"); } }; @@ -241,4 +241,4 @@ config_overflow_sampling(struct perf_event_attr& _pe, std::string_view _event, } } } // namespace perf -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/perf.hpp b/source/lib/core/perf.hpp index a91b96f1..6f007b33 100644 --- a/source/lib/core/perf.hpp +++ b/source/lib/core/perf.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -42,7 +42,7 @@ enum HW_BREAKPOINT_X = 4 }; -namespace omnitrace +namespace rocprofsys { namespace perf { @@ -288,4 +288,4 @@ int get_hw_cache_config(std::string_view); void config_overflow_sampling(struct perf_event_attr&, std::string_view, double); } // namespace perf -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/perfetto.cpp b/source/lib/core/perfetto.cpp index a4725aea..ac2c2e50 100644 --- a/source/lib/core/perfetto.cpp +++ b/source/lib/core/perfetto.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -26,7 +26,7 @@ #include "perfetto_fwd.hpp" #include "utility.hpp" -namespace omnitrace +namespace rocprofsys { namespace perfetto { @@ -86,8 +86,8 @@ setup() for(const auto& itr : config::get_disabled_categories()) { - OMNITRACE_VERBOSE_F(1, "Disabling perfetto track event category: %s\n", - itr.c_str()); + ROCPROFSYS_VERBOSE_F(1, "Disabling perfetto track event category: %s\n", + itr.c_str()); track_event_cfg.add_disabled_categories(itr); } @@ -124,12 +124,12 @@ start() } else { - OMNITRACE_VERBOSE(2, "Resuming perfetto...\n"); + ROCPROFSYS_VERBOSE(2, "Resuming perfetto...\n"); _tmp_file->fopen("a+"); } } - OMNITRACE_VERBOSE(2, "Setup perfetto...\n"); + ROCPROFSYS_VERBOSE(2, "Setup perfetto...\n"); int _fd = (_tmp_file) ? _tmp_file->fd : -1; auto& cfg = get_config(); tracing_session->Setup(cfg, _fd); @@ -143,16 +143,17 @@ stop() auto& tracing_session = get_perfetto_session(); - OMNITRACE_CI_THROW(tracing_session == nullptr, "Null pointer to the tracing session"); + ROCPROFSYS_CI_THROW(tracing_session == nullptr, + "Null pointer to the tracing session"); if(tracing_session) { // Make sure the last event is closed - OMNITRACE_VERBOSE(2, "Flushing the perfetto trace data...\n"); + ROCPROFSYS_VERBOSE(2, "Flushing the perfetto trace data...\n"); ::perfetto::TrackEvent::Flush(); tracing_session->FlushBlocking(); - OMNITRACE_VERBOSE(2, "Stopping the perfetto trace session (blocking)...\n"); + ROCPROFSYS_VERBOSE(2, "Stopping the perfetto trace session (blocking)...\n"); tracing_session->StopBlocking(); } } @@ -177,7 +178,7 @@ post_process(tim::manager* _timemory_manager, bool& _perfetto_output_error) if(!_fdata) { - OMNITRACE_VERBOSE( + ROCPROFSYS_VERBOSE( -1, "Error! perfetto temp trace file '%s' could not be read", _tmp_file->filename.c_str()); return char_vec_t{ tracing_session->ReadTraceBlocking() }; @@ -191,7 +192,7 @@ post_process(tim::manager* _timemory_manager, bool& _perfetto_output_error) auto _fnum_read = fread(_data.data(), sizeof(char), _fnum_elem, _fdata); fclose(_fdata); - OMNITRACE_CI_THROW( + ROCPROFSYS_CI_THROW( _fnum_read != _fnum_elem, "Error! read %zu elements from perfetto trace file '%s'. Expected %zu\n", _fnum_read, _tmp_file->filename.c_str(), _fnum_elem); @@ -233,7 +234,7 @@ post_process(tim::manager* _timemory_manager, bool& _perfetto_output_error) auto _filename = config::get_perfetto_output_filename(); if(!trace_data.empty()) { - operation::file_output_message _fom{}; + operation::file_output_message _fom{}; // Write the trace into a file. if(config::get_verbose() >= 0) _fom(_filename, std::string{ "perfetto" }, @@ -259,7 +260,7 @@ post_process(tim::manager* _timemory_manager, bool& _perfetto_output_error) } else if(dmp::rank() == 0) { - OMNITRACE_VERBOSE( + ROCPROFSYS_VERBOSE( 0, "perfetto trace data is empty. File '%s' will not be written...\n", _filename.c_str()); } @@ -278,8 +279,8 @@ post_process(tim::manager* _timemory_manager, bool& _perfetto_output_error) std::unique_ptr<::perfetto::TracingSession>& get_perfetto_session(pid_t _pid) { - return ::omnitrace::perfetto::get_session(_pid); + return ::rocprofsys::perfetto::get_session(_pid); } -} // namespace omnitrace +} // namespace rocprofsys PERFETTO_TRACK_EVENT_STATIC_STORAGE(); diff --git a/source/lib/core/perfetto.hpp b/source/lib/core/perfetto.hpp index ac67b3e4..53c11eff 100644 --- a/source/lib/core/perfetto.hpp +++ b/source/lib/core/perfetto.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -29,7 +29,7 @@ # include #else # include -PERFETTO_DEFINE_CATEGORIES(OMNITRACE_PERFETTO_CATEGORIES); +PERFETTO_DEFINE_CATEGORIES(ROCPROFSYS_PERFETTO_CATEGORIES); #endif #include "debug.hpp" @@ -43,7 +43,7 @@ PERFETTO_DEFINE_CATEGORIES(OMNITRACE_PERFETTO_CATEGORIES); #include #include -namespace omnitrace +namespace rocprofsys { std::unique_ptr<::perfetto::TracingSession>& get_perfetto_session( pid_t = process::get_id()); @@ -143,15 +143,15 @@ perfetto_counter_track::emplace(size_t _idx, const std::string& _v, std::stringstream _css{}; for(auto&& eitr : _curr) _css << " " << std::hex << std::setw(12) << std::left << eitr; - OMNITRACE_THROW("perfetto_counter_track emplace method for '%s' (%p) " - "invalidated C-string '%s' (%p).\n%8s: %s\n%8s: %s\n", - _v.c_str(), (void*) _name->c_str(), - std::get<0>(itr).c_str(), - (void*) std::get<0>(itr).c_str(), "previous", - _pss.str().c_str(), "current", _css.str().c_str()); + ROCPROFSYS_THROW("perfetto_counter_track emplace method for '%s' (%p) " + "invalidated C-string '%s' (%p).\n%8s: %s\n%8s: %s\n", + _v.c_str(), (void*) _name->c_str(), + std::get<0>(itr).c_str(), + (void*) std::get<0>(itr).c_str(), "previous", + _pss.str().c_str(), "current", _css.str().c_str()); } } } return _index; } -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/perfetto_fwd.hpp b/source/lib/core/perfetto_fwd.hpp index dc2d0b95..6eb1c39d 100644 --- a/source/lib/core/perfetto_fwd.hpp +++ b/source/lib/core/perfetto_fwd.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -27,7 +27,7 @@ namespace tim class manager; } -namespace omnitrace +namespace rocprofsys { namespace perfetto { @@ -43,4 +43,4 @@ stop(); void post_process(tim::manager*, bool&); } // namespace perfetto -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/rccl.hpp b/source/lib/core/rccl.hpp index 0f97e3d3..68ef13e2 100644 --- a/source/lib/core/rccl.hpp +++ b/source/lib/core/rccl.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -25,9 +25,9 @@ #include "core/defines.hpp" #include "core/hip_runtime.hpp" -#if defined(OMNITRACE_USE_HIP) && OMNITRACE_USE_HIP > 0 && \ - defined(OMNITRACE_USE_RCCL) && OMNITRACE_USE_RCCL > 0 -# if OMNITRACE_HIP_VERSION == 0 || OMNITRACE_HIP_VERSION >= 50200 +#if defined(ROCPROFSYS_USE_HIP) && ROCPROFSYS_USE_HIP > 0 && \ + defined(ROCPROFSYS_USE_RCCL) && ROCPROFSYS_USE_RCCL > 0 +# if ROCPROFSYS_HIP_VERSION == 0 || ROCPROFSYS_HIP_VERSION >= 50200 # include # else # include diff --git a/source/lib/core/redirect.hpp b/source/lib/core/redirect.hpp index 65c59e8b..1d720df4 100644 --- a/source/lib/core/redirect.hpp +++ b/source/lib/core/redirect.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -31,15 +31,15 @@ #include #include -namespace omnitrace +namespace rocprofsys { inline namespace config { bool -get_debug() OMNITRACE_HOT; +get_debug() ROCPROFSYS_HOT; int -get_verbose() OMNITRACE_HOT; +get_verbose() ROCPROFSYS_HOT; } // namespace config struct redirect @@ -68,10 +68,11 @@ struct redirect if(_v != _expect) { if(get_verbose() > 0) - std::cerr << "[omnitrace::redirect] Expected:\n[omnitrace::redirect] " - << _expect - << "\n[omnitrace::redirect] Found:\n[omnitrace::redirect] " - << _v << "\n"; + std::cerr + << "[rocprofsys::redirect] Expected:\n[rocprofsys::redirect] " + << _expect + << "\n[rocprofsys::redirect] Found:\n[rocprofsys::redirect] " << _v + << "\n"; if(get_verbose() <= 0 || (&m_os != &std::cerr && &m_os != &std::cout)) m_os << m_buffer.str() << std::flush; } @@ -99,4 +100,4 @@ struct redirect std::stringstream m_buffer{}; std::streambuf* m_strm_buffer = nullptr; }; -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/state.cpp b/source/lib/core/state.cpp index efc4d6d6..7434b7de 100644 --- a/source/lib/core/state.cpp +++ b/source/lib/core/state.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -28,7 +28,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace { @@ -49,10 +49,10 @@ get_thread_state_value() auto& get_thread_state_history(int64_t _idx = utility::get_thread_index()) { - static auto _v = utility::get_filled_array( + static auto _v = utility::get_filled_array( []() { return utility::get_reserved_vector(32); }); - if(_idx >= OMNITRACE_MAX_THREADS) + if(_idx >= ROCPROFSYS_MAX_THREADS) { static thread_local auto _tl_v = utility::get_reserved_vector(32); return _tl_v; @@ -77,11 +77,11 @@ get_thread_state() State set_state(State _n) { - OMNITRACE_CONDITIONAL_PRINT_F(get_debug_init(), "Setting state :: %s -> %s\n", - std::to_string(get_state()).c_str(), - std::to_string(_n).c_str()); + ROCPROFSYS_CONDITIONAL_PRINT_F(get_debug_init(), "Setting state :: %s -> %s\n", + std::to_string(get_state()).c_str(), + std::to_string(_n).c_str()); // state should always be increased, not decreased - OMNITRACE_CI_BASIC_THROW( + ROCPROFSYS_CI_BASIC_THROW( _n < get_state(), "State is being assigned to a lesser value :: %s -> %s", std::to_string(get_state()).c_str(), std::to_string(_n).c_str()); auto _v = get_state(); @@ -118,57 +118,57 @@ pop_thread_state() } return get_thread_state(); } -} // namespace omnitrace +} // namespace rocprofsys namespace std { std::string -to_string(omnitrace::State _v) +to_string(rocprofsys::State _v) { switch(_v) { - case omnitrace::State::PreInit: return "PreInit"; - case omnitrace::State::Init: return "Init"; - case omnitrace::State::Active: return "Active"; - case omnitrace::State::Disabled: return "Disabled"; - case omnitrace::State::Finalized: return "Finalized"; + case rocprofsys::State::PreInit: return "PreInit"; + case rocprofsys::State::Init: return "Init"; + case rocprofsys::State::Active: return "Active"; + case rocprofsys::State::Disabled: return "Disabled"; + case rocprofsys::State::Finalized: return "Finalized"; } return {}; } std::string -to_string(omnitrace::ThreadState _v) +to_string(rocprofsys::ThreadState _v) { switch(_v) { - case omnitrace::ThreadState::Enabled: return "Enabled"; - case omnitrace::ThreadState::Internal: return "Internal"; - case omnitrace::ThreadState::Completed: return "Completed"; - case omnitrace::ThreadState::Disabled: return "Disabled"; + case rocprofsys::ThreadState::Enabled: return "Enabled"; + case rocprofsys::ThreadState::Internal: return "Internal"; + case rocprofsys::ThreadState::Completed: return "Completed"; + case rocprofsys::ThreadState::Disabled: return "Disabled"; } return {}; } std::string -to_string(omnitrace::Mode _v) +to_string(rocprofsys::Mode _v) { switch(_v) { - case omnitrace::Mode::Trace: return "Trace"; - case omnitrace::Mode::Sampling: return "Sampling"; - case omnitrace::Mode::Causal: return "Causal"; - case omnitrace::Mode::Coverage: return "Coverage"; + case rocprofsys::Mode::Trace: return "Trace"; + case rocprofsys::Mode::Sampling: return "Sampling"; + case rocprofsys::Mode::Causal: return "Causal"; + case rocprofsys::Mode::Coverage: return "Coverage"; } return {}; } std::string -to_string(omnitrace::CausalMode _v) +to_string(rocprofsys::CausalMode _v) { switch(_v) { - case omnitrace::CausalMode::Line: return "Line"; - case omnitrace::CausalMode::Function: return "Function"; + case rocprofsys::CausalMode::Line: return "Line"; + case rocprofsys::CausalMode::Function: return "Function"; } return {}; } diff --git a/source/lib/core/state.hpp b/source/lib/core/state.hpp index 326fe094..2ea55a46 100644 --- a/source/lib/core/state.hpp +++ b/source/lib/core/state.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -28,9 +28,9 @@ #include #include -namespace omnitrace +namespace rocprofsys { -// used for specifying the state of omnitrace +// used for specifying the state of rocprof-sys enum class State : unsigned short { PreInit = 0, @@ -40,7 +40,7 @@ enum class State : unsigned short Disabled, }; -// used for specifying the state of omnitrace +// used for specifying the state of rocprof-sys enum class ThreadState : unsigned short { Enabled = 0, @@ -74,48 +74,49 @@ enum class CausalMode : unsigned short // Runtime configuration data // State -get_state() OMNITRACE_HOT; +get_state() ROCPROFSYS_HOT; ThreadState -get_thread_state() OMNITRACE_HOT; +get_thread_state() ROCPROFSYS_HOT; /// returns old state -State set_state(State) OMNITRACE_COLD; // does not change often +State set_state(State) ROCPROFSYS_COLD; // does not change often /// returns old state -ThreadState set_thread_state(ThreadState) OMNITRACE_HOT; // changes often +ThreadState set_thread_state(ThreadState) ROCPROFSYS_HOT; // changes often /// return current state (state change may be ignored) -ThreadState push_thread_state(ThreadState) OMNITRACE_HOT; +ThreadState push_thread_state(ThreadState) ROCPROFSYS_HOT; /// return current state (state change may be ignored) ThreadState -pop_thread_state() OMNITRACE_HOT; +pop_thread_state() ROCPROFSYS_HOT; struct scoped_thread_state { - OMNITRACE_INLINE scoped_thread_state(ThreadState _v) { push_thread_state(_v); } - OMNITRACE_INLINE ~scoped_thread_state() { pop_thread_state(); } + ROCPROFSYS_INLINE scoped_thread_state(ThreadState _v) { push_thread_state(_v); } + ROCPROFSYS_INLINE ~scoped_thread_state() { pop_thread_state(); } }; -} // namespace omnitrace +} // namespace rocprofsys -#define OMNITRACE_SCOPED_THREAD_STATE(STATE) \ - ::omnitrace::scoped_thread_state OMNITRACE_VARIABLE(_scoped_thread_state_, __LINE__) \ +#define ROCPROFSYS_SCOPED_THREAD_STATE(STATE) \ + ::rocprofsys::scoped_thread_state ROCPROFSYS_VARIABLE(_scoped_thread_state_, \ + __LINE__) \ { \ - ::omnitrace::STATE \ + ::rocprofsys::STATE \ } namespace std { std::string -to_string(omnitrace::State _v); +to_string(rocprofsys::State _v); std::string -to_string(omnitrace::ThreadState _v); +to_string(rocprofsys::ThreadState _v); std::string -to_string(omnitrace::Mode _v); +to_string(rocprofsys::Mode _v); std::string -to_string(omnitrace::CausalMode _v); +to_string(rocprofsys::CausalMode _v); } // namespace std diff --git a/source/lib/core/timemory.cpp b/source/lib/core/timemory.cpp index 161ba6bd..3c633525 100644 --- a/source/lib/core/timemory.cpp +++ b/source/lib/core/timemory.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -22,6 +22,6 @@ #include "timemory.hpp" -using namespace omnitrace; +using namespace rocprofsys; TIMEMORY_INITIALIZE_STORAGE(comp::wall_clock, comp::user_global_bundle) diff --git a/source/lib/core/timemory.hpp b/source/lib/core/timemory.hpp index 0e3bdedd..01f5b1de 100644 --- a/source/lib/core/timemory.hpp +++ b/source/lib/core/timemory.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -43,7 +43,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace audit = ::tim::audit; // NOLINT namespace comp = ::tim::component; // NOLINT @@ -56,4 +56,4 @@ using settings = ::tim::settings; // NOLINT using ::tim::get_env; // NOLINT using ::tim::set_env; // NOLINT -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/utility.cpp b/source/lib/core/utility.cpp index 2a16c068..e89a6952 100644 --- a/source/lib/core/utility.cpp +++ b/source/lib/core/utility.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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,7 +23,7 @@ #include "utility.hpp" #include "debug.hpp" -namespace omnitrace +namespace rocprofsys { namespace utility { @@ -71,7 +71,7 @@ parse_numeric_range(std::string _input_string, const std::string& _label, Up _in { if(_v.find_first_not_of("0123456789-:") != std::string::npos) { - OMNITRACE_BASIC_VERBOSE_F( + ROCPROFSYS_BASIC_VERBOSE_F( 0, "Invalid %s specification. Only numerical values (e.g., 0), ranges " "(e.g., 0-7), and ranges with increments (e.g. 20-40:10) are permitted. " @@ -92,7 +92,7 @@ parse_numeric_range(std::string _input_string, const std::string& _label, Up _in if(_v.find('-') != std::string::npos) { auto _vv = tim::delimit(_v, "-"); - OMNITRACE_CONDITIONAL_THROW( + ROCPROFSYS_CONDITIONAL_THROW( _vv.size() != 2, "Invalid %s range specification: %s. Required format N-M, e.g. 0-4", _label.c_str(), _v.c_str()); @@ -120,4 +120,4 @@ template std::unordered_set parse_numeric_range>(std::string, const std::string&, long); } // namespace utility -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/core/utility.hpp b/source/lib/core/utility.hpp index cde303a0..ac0f71fe 100644 --- a/source/lib/core/utility.hpp +++ b/source/lib/core/utility.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -38,7 +38,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace utility { @@ -253,4 +253,4 @@ extern template std::unordered_set parse_numeric_range>(std::string, const std::string&, long); } // namespace utility -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace-dl/CMakeLists.txt b/source/lib/omnitrace-dl/CMakeLists.txt deleted file mode 100644 index f2f35f76..00000000 --- a/source/lib/omnitrace-dl/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -# ------------------------------------------------------------------------------# -# -# omnitrace dl library -# -# ------------------------------------------------------------------------------# - -set(CMAKE_BUILD_TYPE "Release") -set(CMAKE_SKIP_RPATH OFF) -set(CMAKE_BUILD_RPATH_USE_ORIGIN ON) -set(CMAKE_CXX_VISIBILITY_PRESET "internal") -set(CMAKE_POSITION_INDEPENDENT_CODE ON) - -find_package(Threads REQUIRED) - -add_library(omnitrace-dl-library SHARED) -add_library(omnitrace::omnitrace-dl-library ALIAS omnitrace-dl-library) - -target_sources( - omnitrace-dl-library - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/dl.cpp ${CMAKE_CURRENT_SOURCE_DIR}/main.c - ${CMAKE_CURRENT_SOURCE_DIR}/dl/dl.hpp) -target_include_directories( - omnitrace-dl-library - PUBLIC $ - $ - $ - $) -target_link_libraries( - omnitrace-dl-library - PUBLIC $ $ - $ - $) - -add_target_cxx_flag_if_avail(omnitrace-dl-library "-ftls-model=global-dynamic") -add_target_cxx_flag_if_avail(omnitrace-dl-library "-g3") - -set_target_properties( - omnitrace-dl-library - PROPERTIES OUTPUT_NAME omnitrace-dl - VERSION ${PROJECT_VERSION} - SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} - BUILD_RPATH "\$ORIGIN" - INSTALL_RPATH "\$ORIGIN") - -omnitrace_strip_target(omnitrace-dl-library) - -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/dl/dl.hpp - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/omnitrace/dl) - -install(TARGETS omnitrace-dl-library DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/source/lib/omnitrace-dl/dl.cpp b/source/lib/omnitrace-dl/dl.cpp deleted file mode 100644 index 0181df2d..00000000 --- a/source/lib/omnitrace-dl/dl.cpp +++ /dev/null @@ -1,1448 +0,0 @@ -// 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("libomnitrace-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("libomnitrace-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("libomnitrace-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", "libomnitrace-user.so"); - static auto _libdlib = get_env("OMNITRACE_DL_LIBRARY", "libomnitrace-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("libomnitrace-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("libomnitrace-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; - } -} diff --git a/source/lib/omnitrace-dl/dl/dl.hpp b/source/lib/omnitrace-dl/dl/dl.hpp deleted file mode 100644 index f04f0a50..00000000 --- a/source/lib/omnitrace-dl/dl/dl.hpp +++ /dev/null @@ -1,211 +0,0 @@ -// 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. - -#ifndef OMNITRACE_DL_HPP_ -#define OMNITRACE_DL_HPP_ - -#if defined(OMNITRACE_DL_SOURCE) && (OMNITRACE_DL_SOURCE > 0) -# include "common/defines.h" -#else -# if !defined(OMNITRACE_PUBLIC_API) -# define OMNITRACE_PUBLIC_API -# endif -#endif - -#include "omnitrace/user.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if !defined(OMNITRACE_USE_OMPT) -# define OMNITRACE_USE_OMPT 0 -#endif - -#if !defined(OMNITRACE_USE_ROCTRACER) -# define OMNITRACE_USE_ROCTRACER 0 -#endif - -#if !defined(OMNITRACE_USE_ROCPROFILER) -# define OMNITRACE_USE_ROCPROFILER 0 -#endif - -//--------------------------------------------------------------------------------------// -// -// omnitrace symbols -// -//--------------------------------------------------------------------------------------// - -extern "C" -{ - void omnitrace_init_library(void) OMNITRACE_PUBLIC_API; - void omnitrace_init_tooling(void) OMNITRACE_PUBLIC_API; - void omnitrace_init(const char*, bool, const char*) OMNITRACE_PUBLIC_API; - void omnitrace_finalize(void) OMNITRACE_PUBLIC_API; - void omnitrace_set_env(const char* env_name, - const char* env_val) OMNITRACE_PUBLIC_API; - void omnitrace_set_mpi(bool use, bool attached) OMNITRACE_PUBLIC_API; - void omnitrace_set_instrumented(int) OMNITRACE_PUBLIC_API; - void omnitrace_push_trace(const char* name) OMNITRACE_PUBLIC_API; - void omnitrace_pop_trace(const char* name) OMNITRACE_PUBLIC_API; - int omnitrace_push_region(const char*) OMNITRACE_PUBLIC_API; - int omnitrace_pop_region(const char*) OMNITRACE_PUBLIC_API; - int omnitrace_push_category_region(omnitrace_category_t, const char*, - omnitrace_annotation_t*, - size_t) OMNITRACE_PUBLIC_API; - int omnitrace_pop_category_region(omnitrace_category_t, const char*, - omnitrace_annotation_t*, - size_t) OMNITRACE_PUBLIC_API; - - void omnitrace_register_source(const char* file, const char* func, size_t line, - size_t address, - const char* source) OMNITRACE_PUBLIC_API; - void omnitrace_register_coverage(const char* file, const char* func, - size_t address) OMNITRACE_PUBLIC_API; - void omnitrace_progress(const char*) OMNITRACE_PUBLIC_API; - void omnitrace_annotated_progress(const char*, omnitrace_annotation_t*, - size_t) OMNITRACE_PUBLIC_API; - -#if defined(OMNITRACE_DL_SOURCE) && (OMNITRACE_DL_SOURCE > 0) - void omnitrace_preinit_library(void) OMNITRACE_HIDDEN_API; - int omnitrace_preload_library(void) OMNITRACE_HIDDEN_API; - - int omnitrace_user_start_trace_dl(void) OMNITRACE_HIDDEN_API; - int omnitrace_user_stop_trace_dl(void) OMNITRACE_HIDDEN_API; - - int omnitrace_user_start_thread_trace_dl(void) OMNITRACE_HIDDEN_API; - int omnitrace_user_stop_thread_trace_dl(void) OMNITRACE_HIDDEN_API; - - int omnitrace_user_push_region_dl(const char*) OMNITRACE_HIDDEN_API; - int omnitrace_user_pop_region_dl(const char*) OMNITRACE_HIDDEN_API; - - int omnitrace_user_push_annotated_region_dl(const char*, omnitrace_annotation_t*, - size_t) OMNITRACE_HIDDEN_API; - int omnitrace_user_pop_annotated_region_dl(const char*, omnitrace_annotation_t*, - size_t) OMNITRACE_HIDDEN_API; - - int omnitrace_user_progress_dl(const char* name) OMNITRACE_HIDDEN_API; - int omnitrace_user_annotated_progress_dl(const char*, omnitrace_annotation_t*, - size_t) OMNITRACE_HIDDEN_API; - // KokkosP - struct OMNITRACE_HIDDEN_API SpaceHandle - { - char name[64]; - }; - - struct OMNITRACE_HIDDEN_API Kokkos_Tools_ToolSettings - { - bool requires_global_fencing; - bool padding[255]; - }; - - void kokkosp_print_help(char*) OMNITRACE_PUBLIC_API; - void kokkosp_parse_args(int, char**) OMNITRACE_PUBLIC_API; - void kokkosp_declare_metadata(const char*, const char*) OMNITRACE_PUBLIC_API; - void kokkosp_request_tool_settings(const uint32_t, - Kokkos_Tools_ToolSettings*) OMNITRACE_PUBLIC_API; - void kokkosp_init_library(const int, const uint64_t, const uint32_t, - void*) OMNITRACE_PUBLIC_API; - void kokkosp_finalize_library() OMNITRACE_PUBLIC_API; - void kokkosp_begin_parallel_for(const char*, uint32_t, - uint64_t*) OMNITRACE_PUBLIC_API; - void kokkosp_end_parallel_for(uint64_t) OMNITRACE_PUBLIC_API; - void kokkosp_begin_parallel_reduce(const char*, uint32_t, - uint64_t*) OMNITRACE_PUBLIC_API; - void kokkosp_end_parallel_reduce(uint64_t) OMNITRACE_PUBLIC_API; - void kokkosp_begin_parallel_scan(const char*, uint32_t, - uint64_t*) OMNITRACE_PUBLIC_API; - void kokkosp_end_parallel_scan(uint64_t) OMNITRACE_PUBLIC_API; - void kokkosp_begin_fence(const char*, uint32_t, uint64_t*) OMNITRACE_PUBLIC_API; - void kokkosp_end_fence(uint64_t) OMNITRACE_PUBLIC_API; - void kokkosp_push_profile_region(const char*) OMNITRACE_PUBLIC_API; - void kokkosp_pop_profile_region() OMNITRACE_PUBLIC_API; - void kokkosp_create_profile_section(const char*, uint32_t*) OMNITRACE_PUBLIC_API; - void kokkosp_destroy_profile_section(uint32_t) OMNITRACE_PUBLIC_API; - void kokkosp_start_profile_section(uint32_t) OMNITRACE_PUBLIC_API; - void kokkosp_stop_profile_section(uint32_t) OMNITRACE_PUBLIC_API; - void kokkosp_allocate_data(const SpaceHandle, const char*, const void* const, - const uint64_t) OMNITRACE_PUBLIC_API; - void kokkosp_deallocate_data(const SpaceHandle, const char*, const void* const, - const uint64_t) OMNITRACE_PUBLIC_API; - void kokkosp_begin_deep_copy(SpaceHandle, const char*, const void*, SpaceHandle, - const char*, const void*, uint64_t) OMNITRACE_PUBLIC_API; - void kokkosp_end_deep_copy() OMNITRACE_PUBLIC_API; - void kokkosp_profile_event(const char*) OMNITRACE_PUBLIC_API; - void kokkosp_dual_view_sync(const char*, const void* const, - bool) OMNITRACE_PUBLIC_API; - void kokkosp_dual_view_modify(const char*, const void* const, - bool) OMNITRACE_PUBLIC_API; - - // OpenMP Tools (OMPT) -# if OMNITRACE_USE_OMPT > 0 - struct ompt_start_tool_result_t; - - ompt_start_tool_result_t* ompt_start_tool(unsigned int, - const char*) OMNITRACE_PUBLIC_API; -# endif - -# if OMNITRACE_USE_ROCTRACER > 0 - // HSA - struct HsaApiTable; - bool OnLoad(HsaApiTable* table, uint64_t runtime_version, uint64_t failed_tool_count, - const char* const* failed_tool_names) OMNITRACE_PUBLIC_API; - void OnUnload() OMNITRACE_PUBLIC_API; -# endif - -# if OMNITRACE_USE_ROCPROFILER > 0 - // ROCP - void OnLoadToolProp(void* settings) OMNITRACE_PUBLIC_API; - void OnUnloadTool() OMNITRACE_PUBLIC_API; -# endif -#endif -} - -namespace omnitrace -{ -namespace dl -{ -enum class InstrumentMode : int -{ - None = -1, - BinaryRewrite = 0, - ProcessCreate = 1, // runtime instrumentation at start of process - ProcessAttach = 2, // runtime instrumentation of running process - PythonProfile = 3, // python setprofile - Last, -}; -} -} // namespace omnitrace - -#endif // OMNITRACE_DL_HPP_ 1 diff --git a/source/lib/omnitrace-user/CMakeLists.txt b/source/lib/omnitrace-user/CMakeLists.txt deleted file mode 100644 index 112f756e..00000000 --- a/source/lib/omnitrace-user/CMakeLists.txt +++ /dev/null @@ -1,54 +0,0 @@ -# ------------------------------------------------------------------------------# -# -# omnitrace user library -# -# ------------------------------------------------------------------------------# - -set(CMAKE_BUILD_TYPE "Release") -set(CMAKE_SKIP_RPATH OFF) -set(BUILD_RPATH_USE_ORIGIN ON) -set(CMAKE_CXX_VISIBILITY_PRESET "hidden") -set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) - -add_library(omnitrace-user-library SHARED) -add_library(omnitrace::omnitrace-user-library ALIAS omnitrace-user-library) - -set(_user_headers - ${CMAKE_CURRENT_SOURCE_DIR}/omnitrace/user.h - ${CMAKE_CURRENT_SOURCE_DIR}/omnitrace/types.h - ${CMAKE_CURRENT_SOURCE_DIR}/omnitrace/causal.h - ${CMAKE_CURRENT_SOURCE_DIR}/omnitrace/categories.h) - -set(_user_sources ${CMAKE_CURRENT_SOURCE_DIR}/user.cpp) - -target_sources(omnitrace-user-library PRIVATE ${_user_sources} ${_user_headers}) -target_include_directories( - omnitrace-user-library PUBLIC $ - $) -target_link_libraries(omnitrace-user-library - PRIVATE $) - -set_target_properties( - omnitrace-user-library - PROPERTIES OUTPUT_NAME omnitrace-user - VERSION ${PROJECT_VERSION} - SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} - POSITION_INDEPENDENT_CODE ON - BUILD_RPATH "\$ORIGIN" - INSTALL_RPATH "\$ORIGIN") - -omnitrace_strip_target(omnitrace-user-library) - -foreach(_HEADER ${_user_headers}) - string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" - "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/" _DEST - "${_HEADER}") - configure_file(${_HEADER} ${_DEST} COPYONLY) -endforeach() - -install(FILES ${_user_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/omnitrace) - -install( - TARGETS omnitrace-user-library - EXPORT omnitrace-library-targets - DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/source/lib/omnitrace-user/omnitrace/categories.h b/source/lib/omnitrace-user/omnitrace/categories.h deleted file mode 100644 index dd435e50..00000000 --- a/source/lib/omnitrace-user/omnitrace/categories.h +++ /dev/null @@ -1,191 +0,0 @@ -// 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. - -#ifndef OMNITRACE_CATEGORIES_H_ -#define OMNITRACE_CATEGORIES_H_ - -#include -#include - -#if defined(__cplusplus) -extern "C" -{ -#endif - - /// @typedef omnitrace_category_t - /// @brief Identifier for categories - /// - typedef enum OMNITRACE_CATEGORIES - { - // Do not use first enum value - OMNITRACE_CATEGORY_NONE = 0, - // arrange these in the order most likely to - // be used since they have to be iterated over - OMNITRACE_CATEGORY_PYTHON, - OMNITRACE_CATEGORY_USER, - OMNITRACE_CATEGORY_HOST, - OMNITRACE_CATEGORY_DEVICE_HIP, - OMNITRACE_CATEGORY_DEVICE_HSA, - OMNITRACE_CATEGORY_ROCM_HIP, - OMNITRACE_CATEGORY_ROCM_HSA, - OMNITRACE_CATEGORY_ROCM_ROCTX, - OMNITRACE_CATEGORY_ROCM_SMI, - OMNITRACE_CATEGORY_ROCM_SMI_BUSY, - OMNITRACE_CATEGORY_ROCM_SMI_TEMP, - OMNITRACE_CATEGORY_ROCM_SMI_POWER, - OMNITRACE_CATEGORY_ROCM_SMI_MEMORY_USAGE, - OMNITRACE_CATEGORY_ROCM_RCCL, - OMNITRACE_CATEGORY_ROCTRACER, - OMNITRACE_CATEGORY_ROCPROFILER, - OMNITRACE_CATEGORY_SAMPLING, - OMNITRACE_CATEGORY_PTHREAD, - OMNITRACE_CATEGORY_KOKKOS, - OMNITRACE_CATEGORY_MPI, - OMNITRACE_CATEGORY_OMPT, - OMNITRACE_CATEGORY_PROCESS_SAMPLING, - OMNITRACE_CATEGORY_COMM_DATA, - OMNITRACE_CATEGORY_CAUSAL, - OMNITRACE_CATEGORY_CPU_FREQ, - OMNITRACE_CATEGORY_PROCESS_PAGE, - OMNITRACE_CATEGORY_PROCESS_VIRT, - OMNITRACE_CATEGORY_PROCESS_PEAK, - OMNITRACE_CATEGORY_PROCESS_CONTEXT_SWITCH, - OMNITRACE_CATEGORY_PROCESS_PAGE_FAULT, - OMNITRACE_CATEGORY_PROCESS_USER_MODE_TIME, - OMNITRACE_CATEGORY_PROCESS_KERNEL_MODE_TIME, - OMNITRACE_CATEGORY_THREAD_WALL_TIME, - OMNITRACE_CATEGORY_THREAD_CPU_TIME, - OMNITRACE_CATEGORY_THREAD_PAGE_FAULT, - OMNITRACE_CATEGORY_THREAD_PEAK_MEMORY, - OMNITRACE_CATEGORY_THREAD_CONTEXT_SWITCH, - OMNITRACE_CATEGORY_THREAD_HARDWARE_COUNTER, - OMNITRACE_CATEGORY_KERNEL_HARDWARE_COUNTER, - OMNITRACE_CATEGORY_NUMA, - OMNITRACE_CATEGORY_TIMER_SAMPLING, - OMNITRACE_CATEGORY_OVERFLOW_SAMPLING, - OMNITRACE_CATEGORY_LAST - // the value of below enum is used for iterating - // over the enum in C++ templates. It MUST - // be the last enumerated id - } omnitrace_category_t; - - /// @enum OMNITRACE_ANNOTATION_TYPE - /// @brief Identifier for the data type of the annotation. - /// if the data type is not a pointer, pass the address of - /// data. - /// @typedef OMNITRACE_ANNOTATION_TYPE omnitrace_annotation_type_t - typedef enum OMNITRACE_ANNOTATION_TYPE - { - // Do not use first enum value - OMNITRACE_VALUE_NONE = 0, - // arrange these in the order most likely to - // be used since they have to be iterated over - OMNITRACE_VALUE_CSTR = 1, - OMNITRACE_STRING = OMNITRACE_VALUE_CSTR, - OMNITRACE_VALUE_SIZE_T = 2, - OMNITRACE_SIZE_T = OMNITRACE_VALUE_SIZE_T, - OMNITRACE_VALUE_INT64 = 3, - OMNITRACE_INT64 = OMNITRACE_VALUE_INT64, - OMNITRACE_I64 = OMNITRACE_VALUE_INT64, - OMNITRACE_VALUE_UINT64 = 4, - OMNITRACE_UINT64 = OMNITRACE_VALUE_UINT64, - OMNITRACE_U64 = OMNITRACE_VALUE_UINT64, - OMNITRACE_VALUE_FLOAT64 = 5, - OMNITRACE_FLOAT64 = OMNITRACE_VALUE_FLOAT64, - OMNITRACE_FP64 = OMNITRACE_VALUE_FLOAT64, - OMNITRACE_VALUE_VOID_P = 6, - OMNITRACE_VOID_P = OMNITRACE_VALUE_VOID_P, - OMNITRACE_PTR = OMNITRACE_VALUE_VOID_P, - OMNITRACE_VALUE_INT32 = 7, - OMNITRACE_INT32 = OMNITRACE_VALUE_INT32, - OMNITRACE_I32 = OMNITRACE_VALUE_INT32, - OMNITRACE_VALUE_UINT32 = 8, - OMNITRACE_UINT32 = OMNITRACE_VALUE_UINT32, - OMNITRACE_U32 = OMNITRACE_VALUE_UINT32, - OMNITRACE_VALUE_FLOAT32 = 9, - OMNITRACE_FLOAT32 = OMNITRACE_VALUE_FLOAT32, - OMNITRACE_FP32 = OMNITRACE_VALUE_FLOAT32, - OMNITRACE_VALUE_INT16 = 10, - OMNITRACE_INT16 = OMNITRACE_VALUE_INT16, - OMNITRACE_I16 = OMNITRACE_VALUE_INT16, - OMNITRACE_VALUE_UINT16 = 11, - OMNITRACE_UINT16 = OMNITRACE_VALUE_UINT16, - OMNITRACE_U16 = OMNITRACE_VALUE_UINT16, - // the value of below enum is used for iterating - // over the enum in C++ templates. It MUST - // be the last enumerated id - OMNITRACE_VALUE_LAST - } omnitrace_annotation_type_t; - - /// @struct omnitrace_annotation - /// @brief A struct containing annotation data to be included in the perfetto trace. - /// - /// @code{.cpp} - /// #include - /// #include - /// - /// double - /// compute_residual(size_t n, double* data); - /// - /// double - /// compute(size_t n, double* data, size_t nitr, double tolerance) - /// { - /// omnitrace_annotation_t _annotations[] = { - /// { "iteration", OMNITRACE_VALUE_SIZE_T, nullptr }, - /// { "residual", OMNITRACE_VALUE_FLOAT64, nullptr }, - /// { "data", OMNITRACE_VALUE_PTR, data }, - /// { "size", OMNITRACE_VALUE_SIZE_T, &n }, - /// { "tolerance", OMNITRACE_VALUE_FLOAT64, &tolerance }, - /// nullptr - /// }; - /// - /// double residual = tolerance; - /// for(size_t i = 0; i < nitr; ++i) - /// { - /// omnitrace_user_push_annotated_region("compute", &_annotations); - /// - /// residual = compute_residual(n, data); - /// - /// _annotations[0].value = &i; - /// _annotations[1].value = &residual; - /// omnitrace_user_pop_annotated_region("compute", &_annotations); - /// } - /// - /// return residual; - /// } - /// @endcode - /// @typedef omnitrace_annotation omnitrace_annotation_t - typedef struct omnitrace_annotation - { - /// label for annotation - const char* name; - /// omnitrace_annotation_type_t - uintptr_t type; - /// data to annotate - void* value; - } omnitrace_annotation_t; - -#if defined(__cplusplus) -} -#endif - -#endif // OMNITRACE_TYPES_H_ diff --git a/source/lib/omnitrace-user/omnitrace/types.h b/source/lib/omnitrace-user/omnitrace/types.h deleted file mode 100644 index 1a8498fe..00000000 --- a/source/lib/omnitrace-user/omnitrace/types.h +++ /dev/null @@ -1,117 +0,0 @@ -// 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. - -#ifndef OMNITRACE_TYPES_H_ -#define OMNITRACE_TYPES_H_ - -#include -#include - -#if defined(__cplusplus) -extern "C" -{ -#endif - - struct omnitrace_annotation; - typedef int (*omnitrace_trace_func_t)(void); - typedef int (*omnitrace_region_func_t)(const char*); - typedef int (*omnitrace_annotated_region_func_t)(const char*, omnitrace_annotation*, - size_t); - - /// @struct omnitrace_user_callbacks - /// @brief Struct containing the callbacks for the user API - /// - /// @typedef omnitrace_user_callbacks omnitrace_user_callbacks_t - typedef struct omnitrace_user_callbacks - { - omnitrace_trace_func_t start_trace; - omnitrace_trace_func_t stop_trace; - omnitrace_trace_func_t start_thread_trace; - omnitrace_trace_func_t stop_thread_trace; - omnitrace_region_func_t push_region; - omnitrace_region_func_t pop_region; - omnitrace_region_func_t progress; - omnitrace_annotated_region_func_t push_annotated_region; - omnitrace_annotated_region_func_t pop_annotated_region; - omnitrace_annotated_region_func_t annotated_progress; - - /// @var start_trace - /// @brief callback for enabling tracing globally - /// @var stop_trace - /// @brief callback for disabling tracing globally - /// @var start_thread_trace - /// @brief callback for enabling tracing on current thread - /// @var stop_thread_trace - /// @brief callback for disabling tracing on current thread - /// @var push_region - /// @brief callback for starting a trace region - /// @var pop_region - /// @brief callback for ending a trace region - /// @var progress - /// @brief callback for marking an causal profiling event - /// @var push_annotated_region - /// @brief callback for starting a trace region + annotations - /// @var pop_annotated_region - /// @brief callback for ending a trace region + annotations - /// @var annotated_progress - /// @brief callback for marking an causal profiling event + annotations - } omnitrace_user_callbacks_t; - - /// @enum OMNITRACE_USER_CONFIGURE_MODE - /// @brief Identifier for errors - /// @typedef OMNITRACE_USER_CONFIGURE_MODE omnitrace_user_configure_mode_t - typedef enum OMNITRACE_USER_CONFIGURE_MODE - { - // clang-format off - OMNITRACE_USER_UNION_CONFIG = 0, ///< Replace the callbacks in the current config with the non-null callbacks in the provided config - OMNITRACE_USER_REPLACE_CONFIG, ///< Replace the entire config even if the provided config has null callbacks - OMNITRACE_USER_INTERSECT_CONFIG, ///< Produce a config which is the intersection of the current config and the provided config - OMNITRACE_USER_CONFIGURE_MODE_LAST - // clang-format on - } omnitrace_user_configure_mode_t; - - /// @enum OMNITRACE_USER_ERROR - /// @brief Identifier for errors - /// @typedef OMNITRACE_USER_ERROR omnitrace_user_error_t - /// - typedef enum OMNITRACE_USER_ERROR - { - OMNITRACE_USER_SUCCESS = 0, ///< No error - 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_LAST - } omnitrace_user_error_t; - -#if defined(__cplusplus) -} -#endif - -#ifndef OMNITRACE_USER_CALLBACKS_INIT -# define OMNITRACE_USER_CALLBACKS_INIT \ - { \ - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL \ - } -#endif - -#endif // OMNITRACE_TYPES_H_ diff --git a/source/lib/omnitrace-user/omnitrace/user.h b/source/lib/omnitrace-user/omnitrace/user.h deleted file mode 100644 index 64e7aa61..00000000 --- a/source/lib/omnitrace-user/omnitrace/user.h +++ /dev/null @@ -1,158 +0,0 @@ -// 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. - -#ifndef OMNITRACE_USER_H_ -#define OMNITRACE_USER_H_ - -#if defined(OMNITRACE_USER_SOURCE) && (OMNITRACE_USER_SOURCE > 0) -# if !defined(OMNITRACE_PUBLIC_API) -# define OMNITRACE_PUBLIC_API __attribute__((visibility("default"))) -# endif -#else -# if !defined(OMNITRACE_PUBLIC_API) -# define OMNITRACE_PUBLIC_API -# endif -#endif - -#include "omnitrace/categories.h" -#include "omnitrace/types.h" - -#if defined(__cplusplus) -extern "C" -{ -#endif - - /// @fn int omnitrace_user_start_trace(void) - /// @return omnitrace_user_error_t value - /// @brief Enable tracing on this thread and all subsequently created threads - extern int omnitrace_user_start_trace(void) OMNITRACE_PUBLIC_API; - - /// @fn int omnitrace_user_stop_trace(void) - /// @return omnitrace_user_error_t value - /// @brief Disable tracing on this thread and all subsequently created threads - extern int omnitrace_user_stop_trace(void) OMNITRACE_PUBLIC_API; - - /// @fn int omnitrace_user_start_thread_trace(void) - /// @return omnitrace_user_error_t value - /// @brief Enable tracing on this specific thread. Does not apply to subsequently - /// created threads - extern int omnitrace_user_start_thread_trace(void) OMNITRACE_PUBLIC_API; - - /// @fn int omnitrace_user_stop_thread_trace(void) - /// @return omnitrace_user_error_t value - /// @brief Disable tracing on this specific thread. Does not apply to subsequently - /// created threads - extern int omnitrace_user_stop_thread_trace(void) OMNITRACE_PUBLIC_API; - - /// @fn int omnitrace_user_push_region(const char* id) - /// @param id The string identifier for the region - /// @return omnitrace_user_error_t value - /// @brief Start a user defined region. - extern int omnitrace_user_push_region(const char*) OMNITRACE_PUBLIC_API; - - /// @fn int omnitrace_user_pop_region(const char* id) - /// @param id The string identifier for the region - /// @return omnitrace_user_error_t value - /// @brief End a user defined region. In general, user regions should be popped in - /// the inverse order that they were pushed, i.e. first-in, last-out (FILO). The - /// timemory backend was designed to accommodate asynchronous tasking, where FILO may - /// be violated, and will thus compenstate for out-of-order popping, however, the - /// perfetto backend will not; thus, out-of-order popping will result in different - /// results in timemory vs. perfetto. - extern int omnitrace_user_pop_region(const char*) OMNITRACE_PUBLIC_API; - - /// @typedef omnitrace_annotation omnitrace_annotation_t - /// - /// @fn int omnitrace_user_push_annotated_region(const char* id, - /// omnitrace_annotation_t* annotations, - /// size_t num_annotations) - /// @param id The string identifier for the region - /// @param annotations Array of @ref omnitrace_annotation instances - /// @param num_annotations Number of annotations - /// @return omnitrace_user_error_t value - /// @brief Start a user defined region and adds the annotations to the perfetto trace. - extern int omnitrace_user_push_annotated_region(const char*, omnitrace_annotation_t*, - size_t) OMNITRACE_PUBLIC_API; - - /// @fn int omnitrace_user_pop_annotated_region(const char* id, - /// omnitrace_annotation_t* annotations, - /// size_t num_annotations) - /// @param id The string identifier for the region - /// @param annotations Array of @ref omnitrace_annotation instances - /// @param num_annotations Number of annotations - /// @return omnitrace_user_error_t value - /// @brief Stop a user defined region and adds the annotations to the perfetto trace. - extern int omnitrace_user_pop_annotated_region(const char*, omnitrace_annotation_t*, - size_t) OMNITRACE_PUBLIC_API; - - /// mark causal progress - extern int omnitrace_user_progress(const char*) OMNITRACE_PUBLIC_API; - - /// mark causal progress with annotations - extern int omnitrace_user_annotated_progress(const char*, omnitrace_annotation_t*, - size_t) OMNITRACE_PUBLIC_API; - - /// @fn int omnitrace_user_configure(omnitrace_user_configure_mode_t mode, - /// omnitrace_user_callbacks_t inp, - /// omnitrace_user_callbacks_t* out) - /// @param[in] mode Specifies how the new callbacks are merged with the old - /// callbacks - /// @param[in] inp An @ref omnitrace_user_callbacks instance specifying - /// the callbacks which should be invoked by the user API. - /// @param[out] out Pointer to @ref omnitrace_user_callbacks which, - /// when non-NULL, will be assigned the former callbacks. - /// @return omnitrace_user_error_t value - /// @brief Configure the function pointers invoked by the omnitrace user API. - /// The initial callbacks are set via the omnitrace-dl library when it is loaded but - /// the user can user this feature to turn on/off the user API or customize how the - /// the user callbacks occur. For example, the user could maintain one set of - /// callbacks which discard any annotation data or redirect all unannotated user - /// regions to the annotated user regions with annotations about some global state. - /// Changing the callbacks is thread-safe but not thread-local. - extern int omnitrace_user_configure( - omnitrace_user_configure_mode_t mode, omnitrace_user_callbacks_t inp, - omnitrace_user_callbacks_t* out) OMNITRACE_PUBLIC_API; - - /// @fn int omnitrace_user_get_callbacks(int category, void** begin_func, void** - /// end_func) - /// @param[in] category An @ref OMNITRACE_USER_BINDINGS value - /// @param[out] begin_func The pointer to the function which corresponds to "starting" - /// the category, e.g. omnitrace_user_start_trace or omnitrace_user_push_region - /// @param[out] end_func The pointer to the function which corresponds to "ending" the - /// category, e.g. omnitrace_user_stop_trace or omnitrace_user_pop_region - /// @return omnitrace_user_error_t value - /// @brief Get the current function pointers for a given category. The initial values - /// are assigned by omnitrace-dl at start up. - extern int omnitrace_user_get_callbacks(omnitrace_user_callbacks_t*) - OMNITRACE_PUBLIC_API; - - /// @fn const char* omnitrace_user_error_string(int error_category) - /// @param error_category OMNITRACE_USER_ERROR value - /// @return String descripting the error code - /// @brief Return a descriptor for the provided error code - extern const char* omnitrace_user_error_string(int) OMNITRACE_PUBLIC_API; - -#if defined(__cplusplus) -} -#endif - -#endif // OMNITRACE_USER_H_ diff --git a/source/lib/omnitrace/CMakeLists.txt b/source/lib/omnitrace/CMakeLists.txt deleted file mode 100644 index 4928a85e..00000000 --- a/source/lib/omnitrace/CMakeLists.txt +++ /dev/null @@ -1,64 +0,0 @@ -# ------------------------------------------------------------------------------# -# -# omnitrace object library -# -# ------------------------------------------------------------------------------# - -add_library(omnitrace-object-library OBJECT) -add_library(omnitrace::omnitrace-object-library ALIAS omnitrace-object-library) - -target_sources( - omnitrace-object-library - PRIVATE ${CMAKE_CURRENT_LIST_DIR}/library.cpp ${CMAKE_CURRENT_LIST_DIR}/regions.cpp - ${CMAKE_CURRENT_LIST_DIR}/progress.cpp ${CMAKE_CURRENT_LIST_DIR}/api.cpp - ${CMAKE_CURRENT_LIST_DIR}/timeout.cpp ${CMAKE_CURRENT_LIST_DIR}/api.hpp) - -add_subdirectory(library) - -target_link_libraries(omnitrace-object-library - PRIVATE omnitrace::omnitrace-interface-library) - -# ------------------------------------------------------------------------------# -# -# omnitrace static library -# -# ------------------------------------------------------------------------------# - -add_library(omnitrace-static-library STATIC $) -add_library(omnitrace::libomnitrace-static ALIAS omnitrace-static-library) - -target_link_libraries( - omnitrace-static-library - PRIVATE omnitrace::omnitrace-interface-library omnitrace::omnitrace-core - omnitrace::omnitrace-binary) - -set_target_properties(omnitrace-static-library PROPERTIES OUTPUT_NAME omnitrace) - -# ------------------------------------------------------------------------------# -# -# omnitrace shared library -# -# ------------------------------------------------------------------------------# - -add_library(omnitrace-shared-library SHARED $) -add_library(omnitrace::libomnitrace-shared ALIAS omnitrace-shared-library) -add_library(omnitrace::omnitrace-library ALIAS omnitrace-shared-library) - -target_link_libraries( - omnitrace-shared-library - PRIVATE omnitrace::omnitrace-interface-library omnitrace::omnitrace-core - omnitrace::omnitrace-binary) - -set_target_properties( - omnitrace-shared-library - PROPERTIES OUTPUT_NAME omnitrace - VERSION ${PROJECT_VERSION} - SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} - INSTALL_RPATH "${OMNITRACE_LIB_INSTALL_RPATH}") - -omnitrace_strip_target(omnitrace-shared-library) - -install( - TARGETS omnitrace-shared-library - DESTINATION ${CMAKE_INSTALL_LIBDIR} - OPTIONAL) diff --git a/source/lib/omnitrace/api.cpp b/source/lib/omnitrace/api.cpp deleted file mode 100644 index 28000ee9..00000000 --- a/source/lib/omnitrace/api.cpp +++ /dev/null @@ -1,169 +0,0 @@ -// 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. - -#include "api.hpp" -#include "core/debug.hpp" - -#include -#include - -extern "C" void -omnitrace_push_trace(const char* _name) -{ - omnitrace_push_trace_hidden(_name); -} - -extern "C" void -omnitrace_pop_trace(const char* _name) -{ - omnitrace_pop_trace_hidden(_name); -} - -extern "C" int -omnitrace_push_region(const char* _name) -{ - try - { - omnitrace_push_region_hidden(_name); - } catch(std::exception& _e) - { - OMNITRACE_WARNING_F(1, "Exception caught: %s\n", _e.what()); - return -1; - } - return 0; -} - -extern "C" int -omnitrace_pop_region(const char* _name) -{ - try - { - omnitrace_pop_region_hidden(_name); - } catch(std::exception& _e) - { - OMNITRACE_WARNING_F(1, "Exception caught: %s\n", _e.what()); - return -1; - } - return 0; -} - -extern "C" int -omnitrace_push_category_region(omnitrace_category_t _category, const char* _name, - omnitrace_annotation_t* _annotations, - size_t _annotation_count) -{ - try - { - omnitrace_push_category_region_hidden(_category, _name, _annotations, - _annotation_count); - } catch(std::exception& _e) - { - OMNITRACE_WARNING_F(1, "Exception caught: %s\n", _e.what()); - return -1; - } - return 0; -} - -extern "C" int -omnitrace_pop_category_region(omnitrace_category_t _category, const char* _name, - omnitrace_annotation_t* _annotations, - size_t _annotation_count) -{ - try - { - omnitrace_pop_category_region_hidden(_category, _name, _annotations, - _annotation_count); - } catch(std::exception& _e) - { - OMNITRACE_WARNING_F(1, "Exception caught: %s\n", _e.what()); - return -1; - } - return 0; -} - -extern "C" void -omnitrace_progress(const char* _name) -{ - omnitrace_progress_hidden(_name); -} - -extern "C" void -omnitrace_annotated_progress(const char* _name, omnitrace_annotation_t* _annotations, - size_t _annotation_count) -{ - omnitrace_annotated_progress_hidden(_name, _annotations, _annotation_count); -} - -extern "C" void -omnitrace_init_library(void) -{ - omnitrace_init_library_hidden(); -} - -extern "C" void -omnitrace_init_tooling(void) -{ - omnitrace_init_tooling_hidden(); -} - -extern "C" void -omnitrace_init(const char* _mode, bool _rewrite, const char* _arg0) -{ - omnitrace_init_hidden(_mode, _rewrite, _arg0); -} - -extern "C" void -omnitrace_finalize(void) -{ - omnitrace_finalize_hidden(); -} - -extern "C" void -omnitrace_reset_preload(void) -{ - omnitrace_reset_preload_hidden(); -} - -extern "C" void -omnitrace_set_env(const char* env_name, const char* env_val) -{ - omnitrace_set_env_hidden(env_name, env_val); -} - -extern "C" void -omnitrace_set_mpi(bool use, bool attached) -{ - omnitrace_set_mpi_hidden(use, attached); -} - -extern "C" void -omnitrace_register_source(const char* file, const char* func, size_t line, size_t address, - const char* source) -{ - omnitrace_register_source_hidden(file, func, line, address, source); -} - -extern "C" void -omnitrace_register_coverage(const char* file, const char* func, size_t address) -{ - omnitrace_register_coverage_hidden(file, func, address); -} diff --git a/source/lib/omnitrace/api.hpp b/source/lib/omnitrace/api.hpp deleted file mode 100644 index 4cb8debf..00000000 --- a/source/lib/omnitrace/api.hpp +++ /dev/null @@ -1,121 +0,0 @@ -// 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. - -#pragma once - -#include "core/defines.hpp" -#include "omnitrace/categories.h" // in omnitrace-user - -#include - -#include - -// forward decl of the API -extern "C" -{ - /// handles configuration logic - void omnitrace_init_library(void) OMNITRACE_PUBLIC_API; - - /// handles configuration logic - void omnitrace_init_tooling(void) OMNITRACE_PUBLIC_API; - - /// starts gotcha wrappers - void omnitrace_init(const char*, bool, const char*) OMNITRACE_PUBLIC_API; - - /// shuts down all tooling and generates output - void omnitrace_finalize(void) OMNITRACE_PUBLIC_API; - - /// remove libomnitrace from LD_PRELOAD - void omnitrace_reset_preload(void) OMNITRACE_PUBLIC_API; - - /// sets an environment variable - void omnitrace_set_env(const char*, const char*) OMNITRACE_PUBLIC_API; - - /// sets whether MPI should be used - void omnitrace_set_mpi(bool, bool) OMNITRACE_PUBLIC_API; - - /// starts an instrumentation region - void omnitrace_push_trace(const char*) OMNITRACE_PUBLIC_API; - - /// stops an instrumentation region - void omnitrace_pop_trace(const char*) OMNITRACE_PUBLIC_API; - - /// starts an instrumentation region (user-defined) - int omnitrace_push_region(const char*) OMNITRACE_PUBLIC_API; - - /// stops an instrumentation region (user-defined) - int omnitrace_pop_region(const char*) OMNITRACE_PUBLIC_API; - - /// starts an instrumentation region in a user-defined category and (optionally) - /// adds annotations to the perfetto trace. - int omnitrace_push_category_region(omnitrace_category_t, const char*, - omnitrace_annotation_t*, - size_t) OMNITRACE_PUBLIC_API; - - /// stops an instrumentation region in a user-defined category and (optionally) - /// adds annotations to the perfetto trace. - int omnitrace_pop_category_region(omnitrace_category_t, const char*, - omnitrace_annotation_t*, - size_t) OMNITRACE_PUBLIC_API; - - /// stores source code information - void omnitrace_register_source(const char* file, const char* func, size_t line, - size_t address, - const char* source) OMNITRACE_PUBLIC_API; - - /// increments coverage values - void omnitrace_register_coverage(const char* file, const char* func, - size_t address) OMNITRACE_PUBLIC_API; - - /// mark causal progress - void omnitrace_progress(const char*) OMNITRACE_PUBLIC_API; - - /// mark causal progress with annotations - void omnitrace_annotated_progress(const char*, omnitrace_annotation_t*, - size_t) OMNITRACE_PUBLIC_API; - - // these are the real implementations for internal calling convention - void omnitrace_init_library_hidden(void) OMNITRACE_HIDDEN_API; - bool omnitrace_init_tooling_hidden(void) OMNITRACE_HIDDEN_API; - void omnitrace_init_hidden(const char*, bool, const char*) OMNITRACE_HIDDEN_API; - void omnitrace_finalize_hidden(void) OMNITRACE_HIDDEN_API; - void omnitrace_reset_preload_hidden(void) OMNITRACE_HIDDEN_API; - void omnitrace_set_env_hidden(const char*, const char*) OMNITRACE_HIDDEN_API; - void omnitrace_set_mpi_hidden(bool, bool) OMNITRACE_HIDDEN_API; - void omnitrace_push_trace_hidden(const char*) OMNITRACE_HIDDEN_API; - void omnitrace_pop_trace_hidden(const char*) OMNITRACE_HIDDEN_API; - void omnitrace_push_region_hidden(const char*) OMNITRACE_HIDDEN_API; - void omnitrace_pop_region_hidden(const char*) OMNITRACE_HIDDEN_API; - void omnitrace_push_category_region_hidden(omnitrace_category_t, const char*, - omnitrace_annotation_t*, - size_t) OMNITRACE_HIDDEN_API; - void omnitrace_pop_category_region_hidden(omnitrace_category_t, const char*, - omnitrace_annotation_t*, - size_t) OMNITRACE_HIDDEN_API; - void omnitrace_register_source_hidden(const char*, const char*, size_t, size_t, - const char*) OMNITRACE_HIDDEN_API; - void omnitrace_register_coverage_hidden(const char*, const char*, - size_t) OMNITRACE_HIDDEN_API; - void omnitrace_progress_hidden(const char*) OMNITRACE_HIDDEN_API; - void omnitrace_annotated_progress_hidden(const char*, omnitrace_annotation_t*, - size_t) OMNITRACE_HIDDEN_API; -} diff --git a/source/lib/omnitrace/library/coverage/CMakeLists.txt b/source/lib/omnitrace/library/coverage/CMakeLists.txt deleted file mode 100644 index bd8a386c..00000000 --- a/source/lib/omnitrace/library/coverage/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -# -set(coverage_sources) -set(coverage_headers ${CMAKE_CURRENT_LIST_DIR}/impl.hpp) - -target_sources(omnitrace-object-library PRIVATE ${coverage_sources} ${coverage_headers}) diff --git a/source/lib/omnitrace/library/rocm/CMakeLists.txt b/source/lib/omnitrace/library/rocm/CMakeLists.txt deleted file mode 100644 index 357ca938..00000000 --- a/source/lib/omnitrace/library/rocm/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -# -if(OMNITRACE_USE_ROCPROFILER OR OMNITRACE_USE_ROCTRACER) - target_sources( - omnitrace-object-library PRIVATE ${CMAKE_CURRENT_LIST_DIR}/hsa_rsrc_factory.hpp - ${CMAKE_CURRENT_LIST_DIR}/hsa_rsrc_factory.cpp) -endif() diff --git a/source/lib/omnitrace/library/tracing/CMakeLists.txt b/source/lib/omnitrace/library/tracing/CMakeLists.txt deleted file mode 100644 index b9c38d05..00000000 --- a/source/lib/omnitrace/library/tracing/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -# -set(tracing_sources ${CMAKE_CURRENT_LIST_DIR}/annotation.cpp) -set(tracing_headers ${CMAKE_CURRENT_LIST_DIR}/annotation.hpp) - -target_sources(omnitrace-object-library PRIVATE ${tracing_sources} ${tracing_headers}) diff --git a/source/lib/rocprof-sys-dl/CMakeLists.txt b/source/lib/rocprof-sys-dl/CMakeLists.txt new file mode 100644 index 00000000..5a36c711 --- /dev/null +++ b/source/lib/rocprof-sys-dl/CMakeLists.txt @@ -0,0 +1,52 @@ +# ------------------------------------------------------------------------------# +# +# rocprofiler-systems dl library +# +# ------------------------------------------------------------------------------# + +set(CMAKE_BUILD_TYPE "Release") +set(CMAKE_SKIP_RPATH OFF) +set(CMAKE_BUILD_RPATH_USE_ORIGIN ON) +set(CMAKE_CXX_VISIBILITY_PRESET "internal") +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +find_package(Threads REQUIRED) + +add_library(rocprofiler-systems-dl-library SHARED) +add_library(rocprofiler-systems::rocprofiler-systems-dl-library ALIAS + rocprofiler-systems-dl-library) + +target_sources( + rocprofiler-systems-dl-library + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/dl.cpp ${CMAKE_CURRENT_SOURCE_DIR}/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/dl/dl.hpp) +target_include_directories( + rocprofiler-systems-dl-library + PUBLIC $ + $ + $ + $) +target_link_libraries( + rocprofiler-systems-dl-library + PUBLIC $ + $ + $ + $) + +add_target_cxx_flag_if_avail(rocprofiler-systems-dl-library "-ftls-model=global-dynamic") +add_target_cxx_flag_if_avail(rocprofiler-systems-dl-library "-g3") + +set_target_properties( + rocprofiler-systems-dl-library + PROPERTIES OUTPUT_NAME ${BINARY_NAME_PREFIX}-dl + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} + BUILD_RPATH "\$ORIGIN" + INSTALL_RPATH "\$ORIGIN") + +rocprofiler_systems_strip_target(rocprofiler-systems-dl-library) + +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/dl/dl.hpp + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/dl) + +install(TARGETS rocprofiler-systems-dl-library DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/source/lib/rocprof-sys-dl/dl.cpp b/source/lib/rocprof-sys-dl/dl.cpp new file mode 100644 index 00000000..77d59f0e --- /dev/null +++ b/source/lib/rocprof-sys-dl/dl.cpp @@ -0,0 +1,1458 @@ +// MIT License +// +// Copyright (c) 2022-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 +// 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(ROCPROFSYS_DL_SOURCE) +# define ROCPROFSYS_DL_SOURCE 1 +#endif + +#define ROCPROFSYS_COMMON_LIBRARY_NAME "dl" + +#include + +#define ROCPROFSYS_COMMON_LIBRARY_LOG_START \ + fprintf(stderr, "%s", ::tim::log::color::info()); +#define ROCPROFSYS_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 "rocprofiler-systems/categories.h" +#include "rocprofiler-systems/types.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//--------------------------------------------------------------------------------------// + +#define ROCPROFSYS_DLSYM(VARNAME, HANDLE, FUNCNAME) \ + if(HANDLE) \ + { \ + *(void**) (&VARNAME) = dlsym(HANDLE, FUNCNAME); \ + if(VARNAME == nullptr && _rocprofsys_dl_verbose >= _warn_verbose) \ + { \ + ROCPROFSYS_COMMON_LIBRARY_LOG_START \ + fprintf(stderr, "[rocprof-sys][dl][pid=%i]> %s :: %s\n", getpid(), FUNCNAME, \ + dlerror()); \ + ROCPROFSYS_COMMON_LIBRARY_LOG_END \ + } \ + else if(_rocprofsys_dl_verbose > _info_verbose) \ + { \ + ROCPROFSYS_COMMON_LIBRARY_LOG_START \ + fprintf(stderr, "[rocprof-sys][dl][pid=%i]> %s :: success\n", getpid(), \ + FUNCNAME); \ + ROCPROFSYS_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 rocprofsys +{ +namespace dl +{ +namespace +{ +inline int +get_rocprofsys_env() +{ + auto&& _debug = get_env("ROCPROFSYS_DEBUG", false); + return get_env("ROCPROFSYS_VERBOSE", (_debug) ? 100 : 0); +} + +inline int +get_rocprofsys_dl_env() +{ + return get_env("ROCPROFSYS_DL_DEBUG", false) + ? 100 + : get_env("ROCPROFSYS_DL_VERBOSE", get_rocprofsys_env()); +} + +inline bool& +get_rocprofsys_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_rocprofsys_preload() +{ + static bool _v = []() { + auto&& _preload = get_env("ROCPROFSYS_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_rocprofsys_preload() +{ + auto&& _preload_libs = get_env("LD_PRELOAD", std::string{}); + if(_preload_libs.find("librocprof-sys-dl.so") != std::string::npos) + { + (void) get_rocprofsys_is_preloaded(); + (void) get_rocprofsys_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_rocprofsys_root_pid() +{ + auto _pid = getpid(); + setenv("ROCPROFSYS_ROOT_PROCESS", std::to_string(_pid).c_str(), 0); + return get_env("ROCPROFSYS_ROOT_PROCESS", _pid); +} + +void +rocprofsys_preinit() ROCPROFSYS_INTERNAL_API; + +void +rocprofsys_postinit(std::string exe = {}) ROCPROFSYS_INTERNAL_API; + +pid_t _rocprofsys_root_pid = get_rocprofsys_root_pid(); + +// environment priority: +// - ROCPROFSYS_DL_DEBUG +// - ROCPROFSYS_DL_VERBOSE +// - ROCPROFSYS_DEBUG +// - ROCPROFSYS_VERBOSE +int _rocprofsys_dl_verbose = get_rocprofsys_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 _rocprofsys_dl_dlopen_flags = RTLD_LAZY | RTLD_LOCAL; +const char* _rocprofsys_dl_dlopen_descr = "RTLD_LAZY | RTLD_LOCAL"; +#else +auto _rocprofsys_dl_dlopen_flags = RTLD_LAZY | RTLD_LOCAL; +const char* _rocprofsys_dl_dlopen_descr = "RTLD_LAZY | RTLD_LOCAL"; +#endif + +/// This class contains function pointers for rocprof-sys's instrumentation functions +struct ROCPROFSYS_INTERNAL_API indirect +{ + ROCPROFSYS_INLINE indirect(const std::string& _omnilib, const std::string& _userlib, + const std::string& _dllib) + : m_omnilib{ common::path::find_path(_omnilib, _rocprofsys_dl_verbose) } + , m_dllib{ common::path::find_path(_dllib, _rocprofsys_dl_verbose) } + , m_userlib{ common::path::find_path(_userlib, _rocprofsys_dl_verbose) } + { + if(_rocprofsys_dl_verbose >= 1) + { + ROCPROFSYS_COMMON_LIBRARY_LOG_START + fprintf(stderr, "[rocprof-sys][dl][pid=%i] %s resolved to '%s'\n", getpid(), + ::basename(_omnilib.c_str()), m_omnilib.c_str()); + fprintf(stderr, "[rocprof-sys][dl][pid=%i] %s resolved to '%s'\n", getpid(), + ::basename(_dllib.c_str()), m_dllib.c_str()); + fprintf(stderr, "[rocprof-sys][dl][pid=%i] %s resolved to '%s'\n", getpid(), + ::basename(_userlib.c_str()), m_userlib.c_str()); + ROCPROFSYS_COMMON_LIBRARY_LOG_END + } + + auto _search_paths = common::join(':', common::path::dirname(_omnilib), + common::path::dirname(_dllib)); + common::setup_environ(_rocprofsys_dl_verbose, _search_paths, _omnilib, _dllib); + + m_omnihandle = open(m_omnilib); + m_userhandle = open(m_userlib); + init(); + } + + ROCPROFSYS_INLINE ~indirect() { dlclose(m_omnihandle); } + + static ROCPROFSYS_INLINE void* open(const std::string& _lib) + { + auto* libhandle = dlopen(_lib.c_str(), _rocprofsys_dl_dlopen_flags); + + if(libhandle) + { + if(_rocprofsys_dl_verbose >= 2) + { + ROCPROFSYS_COMMON_LIBRARY_LOG_START + fprintf(stderr, + "[rocprof-sys][dl][pid=%i] dlopen(\"%s\", %s) :: success\n", + getpid(), _lib.c_str(), _rocprofsys_dl_dlopen_descr); + ROCPROFSYS_COMMON_LIBRARY_LOG_END + } + } + else + { + if(_rocprofsys_dl_verbose >= 0) + { + perror("dlopen"); + ROCPROFSYS_COMMON_LIBRARY_LOG_START + fprintf(stderr, "[rocprof-sys][dl][pid=%i] dlopen(\"%s\", %s) :: %s\n", + getpid(), _lib.c_str(), _rocprofsys_dl_dlopen_descr, dlerror()); + ROCPROFSYS_COMMON_LIBRARY_LOG_END + } + } + + dlerror(); // Clear any existing error + + return libhandle; + } + + ROCPROFSYS_INLINE void init() + { + if(!m_omnihandle) m_omnihandle = open(m_omnilib); + + int _warn_verbose = 0; + int _info_verbose = 2; + // Initialize all pointers + ROCPROFSYS_DLSYM(rocprofsys_init_library_f, m_omnihandle, + "rocprofsys_init_library"); + ROCPROFSYS_DLSYM(rocprofsys_init_tooling_f, m_omnihandle, + "rocprofsys_init_tooling"); + ROCPROFSYS_DLSYM(rocprofsys_init_f, m_omnihandle, "rocprofsys_init"); + ROCPROFSYS_DLSYM(rocprofsys_finalize_f, m_omnihandle, "rocprofsys_finalize"); + ROCPROFSYS_DLSYM(rocprofsys_set_env_f, m_omnihandle, "rocprofsys_set_env"); + ROCPROFSYS_DLSYM(rocprofsys_set_mpi_f, m_omnihandle, "rocprofsys_set_mpi"); + ROCPROFSYS_DLSYM(rocprofsys_push_trace_f, m_omnihandle, "rocprofsys_push_trace"); + ROCPROFSYS_DLSYM(rocprofsys_pop_trace_f, m_omnihandle, "rocprofsys_pop_trace"); + ROCPROFSYS_DLSYM(rocprofsys_push_region_f, m_omnihandle, + "rocprofsys_push_region"); + ROCPROFSYS_DLSYM(rocprofsys_pop_region_f, m_omnihandle, "rocprofsys_pop_region"); + ROCPROFSYS_DLSYM(rocprofsys_push_category_region_f, m_omnihandle, + "rocprofsys_push_category_region"); + ROCPROFSYS_DLSYM(rocprofsys_pop_category_region_f, m_omnihandle, + "rocprofsys_pop_category_region"); + ROCPROFSYS_DLSYM(rocprofsys_register_source_f, m_omnihandle, + "rocprofsys_register_source"); + ROCPROFSYS_DLSYM(rocprofsys_register_coverage_f, m_omnihandle, + "rocprofsys_register_coverage"); + ROCPROFSYS_DLSYM(rocprofsys_progress_f, m_omnihandle, "rocprofsys_progress"); + ROCPROFSYS_DLSYM(rocprofsys_annotated_progress_f, m_omnihandle, + "rocprofsys_annotated_progress"); + + ROCPROFSYS_DLSYM(kokkosp_print_help_f, m_omnihandle, "kokkosp_print_help"); + ROCPROFSYS_DLSYM(kokkosp_parse_args_f, m_omnihandle, "kokkosp_parse_args"); + ROCPROFSYS_DLSYM(kokkosp_declare_metadata_f, m_omnihandle, + "kokkosp_declare_metadata"); + ROCPROFSYS_DLSYM(kokkosp_request_tool_settings_f, m_omnihandle, + "kokkosp_request_tool_settings"); + ROCPROFSYS_DLSYM(kokkosp_init_library_f, m_omnihandle, "kokkosp_init_library"); + ROCPROFSYS_DLSYM(kokkosp_finalize_library_f, m_omnihandle, + "kokkosp_finalize_library"); + ROCPROFSYS_DLSYM(kokkosp_begin_parallel_for_f, m_omnihandle, + "kokkosp_begin_parallel_for"); + ROCPROFSYS_DLSYM(kokkosp_end_parallel_for_f, m_omnihandle, + "kokkosp_end_parallel_for"); + ROCPROFSYS_DLSYM(kokkosp_begin_parallel_reduce_f, m_omnihandle, + "kokkosp_begin_parallel_reduce"); + ROCPROFSYS_DLSYM(kokkosp_end_parallel_reduce_f, m_omnihandle, + "kokkosp_end_parallel_reduce"); + ROCPROFSYS_DLSYM(kokkosp_begin_parallel_scan_f, m_omnihandle, + "kokkosp_begin_parallel_scan"); + ROCPROFSYS_DLSYM(kokkosp_end_parallel_scan_f, m_omnihandle, + "kokkosp_end_parallel_scan"); + ROCPROFSYS_DLSYM(kokkosp_begin_fence_f, m_omnihandle, "kokkosp_begin_fence"); + ROCPROFSYS_DLSYM(kokkosp_end_fence_f, m_omnihandle, "kokkosp_end_fence"); + ROCPROFSYS_DLSYM(kokkosp_push_profile_region_f, m_omnihandle, + "kokkosp_push_profile_region"); + ROCPROFSYS_DLSYM(kokkosp_pop_profile_region_f, m_omnihandle, + "kokkosp_pop_profile_region"); + ROCPROFSYS_DLSYM(kokkosp_create_profile_section_f, m_omnihandle, + "kokkosp_create_profile_section"); + ROCPROFSYS_DLSYM(kokkosp_destroy_profile_section_f, m_omnihandle, + "kokkosp_destroy_profile_section"); + ROCPROFSYS_DLSYM(kokkosp_start_profile_section_f, m_omnihandle, + "kokkosp_start_profile_section"); + ROCPROFSYS_DLSYM(kokkosp_stop_profile_section_f, m_omnihandle, + "kokkosp_stop_profile_section"); + ROCPROFSYS_DLSYM(kokkosp_allocate_data_f, m_omnihandle, "kokkosp_allocate_data"); + ROCPROFSYS_DLSYM(kokkosp_deallocate_data_f, m_omnihandle, + "kokkosp_deallocate_data"); + ROCPROFSYS_DLSYM(kokkosp_begin_deep_copy_f, m_omnihandle, + "kokkosp_begin_deep_copy"); + ROCPROFSYS_DLSYM(kokkosp_end_deep_copy_f, m_omnihandle, "kokkosp_end_deep_copy"); + ROCPROFSYS_DLSYM(kokkosp_profile_event_f, m_omnihandle, "kokkosp_profile_event"); + ROCPROFSYS_DLSYM(kokkosp_dual_view_sync_f, m_omnihandle, + "kokkosp_dual_view_sync"); + ROCPROFSYS_DLSYM(kokkosp_dual_view_modify_f, m_omnihandle, + "kokkosp_dual_view_modify"); + +#if ROCPROFSYS_USE_ROCTRACER > 0 + ROCPROFSYS_DLSYM(hsa_on_load_f, m_omnihandle, "OnLoad"); + ROCPROFSYS_DLSYM(hsa_on_unload_f, m_omnihandle, "OnUnload"); +#endif + +#if ROCPROFSYS_USE_ROCPROFILER > 0 + ROCPROFSYS_DLSYM(rocp_on_load_tool_prop_f, m_omnihandle, "OnLoadToolProp"); + ROCPROFSYS_DLSYM(rocp_on_unload_tool_f, m_omnihandle, "OnUnloadTool"); +#endif + +#if ROCPROFSYS_USE_OMPT == 0 + _warn_verbose = 5; +#else + ROCPROFSYS_DLSYM(ompt_start_tool_f, m_omnihandle, "ompt_start_tool"); +#endif + + if(!m_userhandle) m_userhandle = open(m_userlib); + _warn_verbose = 0; + ROCPROFSYS_DLSYM(rocprofsys_user_configure_f, m_userhandle, + "rocprofsys_user_configure"); + + if(rocprofsys_user_configure_f) + { + rocprofsys_user_callbacks_t _cb = {}; + _cb.start_trace = &rocprofsys_user_start_trace_dl; + _cb.stop_trace = &rocprofsys_user_stop_trace_dl; + _cb.start_thread_trace = &rocprofsys_user_start_thread_trace_dl; + _cb.stop_thread_trace = &rocprofsys_user_stop_thread_trace_dl; + _cb.push_region = &rocprofsys_user_push_region_dl; + _cb.pop_region = &rocprofsys_user_pop_region_dl; + _cb.progress = &rocprofsys_user_progress_dl; + _cb.push_annotated_region = &rocprofsys_user_push_annotated_region_dl; + _cb.pop_annotated_region = &rocprofsys_user_pop_annotated_region_dl; + _cb.annotated_progress = &rocprofsys_user_annotated_progress_dl; + (*rocprofsys_user_configure_f)(ROCPROFSYS_USER_REPLACE_CONFIG, _cb, nullptr); + } + } + +public: + using user_cb_t = rocprofsys_user_callbacks_t; + + // librocprof-sys functions + void (*rocprofsys_init_library_f)(void) = nullptr; + void (*rocprofsys_init_tooling_f)(void) = nullptr; + void (*rocprofsys_init_f)(const char*, bool, const char*) = nullptr; + void (*rocprofsys_finalize_f)(void) = nullptr; + void (*rocprofsys_set_env_f)(const char*, const char*) = nullptr; + void (*rocprofsys_set_mpi_f)(bool, bool) = nullptr; + void (*rocprofsys_register_source_f)(const char*, const char*, size_t, size_t, + const char*) = nullptr; + void (*rocprofsys_register_coverage_f)(const char*, const char*, size_t) = nullptr; + void (*rocprofsys_push_trace_f)(const char*) = nullptr; + void (*rocprofsys_pop_trace_f)(const char*) = nullptr; + int (*rocprofsys_push_region_f)(const char*) = nullptr; + int (*rocprofsys_pop_region_f)(const char*) = nullptr; + int (*rocprofsys_push_category_region_f)(rocprofsys_category_t, const char*, + rocprofsys_annotation_t*, size_t) = nullptr; + int (*rocprofsys_pop_category_region_f)(rocprofsys_category_t, const char*, + rocprofsys_annotation_t*, size_t) = nullptr; + void (*rocprofsys_progress_f)(const char*) = nullptr; + void (*rocprofsys_annotated_progress_f)(const char*, rocprofsys_annotation_t*, + size_t) = nullptr; + + // librocprof-sys-user functions + int (*rocprofsys_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 ROCPROFSYS_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 ROCPROFSYS_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(ROCPROFSYS_USE_OMPT) && ROCPROFSYS_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() ROCPROFSYS_INTERNAL_API; + +indirect& +get_indirect() +{ + rocprofsys_preinit_library(); + + static auto _libomni = get_env("ROCPROFSYS_LIBRARY", "librocprof-sys.so"); + static auto _libuser = get_env("ROCPROFSYS_USER_LIBRARY", "librocprof-sys-user.so"); + static auto _libdlib = get_env("ROCPROFSYS_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("ROCPROFSYS_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("ROCPROFSYS_INSTRUMENT_MODE", InstrumentMode::None); + return _v; +} + +// ensure finalization is called +bool _rocprofsys_dl_fini = (std::atexit([]() { + if(get_active()) rocprofsys_finalize(); + }), + true); +} // namespace +} // namespace dl +} // namespace rocprofsys + +//--------------------------------------------------------------------------------------// + +#define ROCPROFSYS_DL_INVOKE(...) \ + ::rocprofsys::common::invoke(__FUNCTION__, ::rocprofsys::dl::_rocprofsys_dl_verbose, \ + (::rocprofsys::dl::get_thread_status() = false), \ + __VA_ARGS__) + +#define ROCPROFSYS_DL_IGNORE(...) \ + ::rocprofsys::common::ignore(__FUNCTION__, ::rocprofsys::dl::_rocprofsys_dl_verbose, \ + __VA_ARGS__) + +#define ROCPROFSYS_DL_INVOKE_STATUS(STATUS, ...) \ + ::rocprofsys::common::invoke(__FUNCTION__, ::rocprofsys::dl::_rocprofsys_dl_verbose, \ + STATUS, __VA_ARGS__) + +#define ROCPROFSYS_DL_LOG(LEVEL, ...) \ + if(::rocprofsys::dl::_rocprofsys_dl_verbose >= LEVEL) \ + { \ + fflush(stderr); \ + ROCPROFSYS_COMMON_LIBRARY_LOG_START \ + fprintf(stderr, "[rocprof-sys][" ROCPROFSYS_COMMON_LIBRARY_NAME "][%i] ", \ + getpid()); \ + fprintf(stderr, __VA_ARGS__); \ + ROCPROFSYS_COMMON_LIBRARY_LOG_END \ + fflush(stderr); \ + } + +using rocprofsys::dl::get_indirect; +namespace dl = rocprofsys::dl; + +extern "C" +{ + void rocprofsys_preinit_library(void) + { + if(rocprofsys::common::get_env("ROCPROFSYS_MONOCHROME", tim::log::monochrome())) + tim::log::monochrome() = true; + } + + int rocprofsys_preload_library(void) + { + return (::rocprofsys::dl::get_rocprofsys_preload()) ? 1 : 0; + } + + void rocprofsys_init_library(void) + { + ROCPROFSYS_DL_INVOKE(get_indirect().rocprofsys_init_library_f); + } + + void rocprofsys_init_tooling(void) + { + ROCPROFSYS_DL_INVOKE(get_indirect().rocprofsys_init_tooling_f); + } + + void rocprofsys_init(const char* a, bool b, const char* c) + { + if(dl::get_inited() && dl::get_finied()) + { + ROCPROFSYS_DL_LOG( + 2, "%s(%s) ignored :: already initialized and finalized\n", __FUNCTION__, + ::rocprofsys::join(::rocprofsys::QuoteStrings{}, ", ", a, b, c).c_str()); + return; + } + else if(dl::get_inited() && dl::get_active()) + { + ROCPROFSYS_DL_LOG( + 2, "%s(%s) ignored :: already initialized and active\n", __FUNCTION__, + ::rocprofsys::join(::rocprofsys::QuoteStrings{}, ", ", a, b, c).c_str()); + return; + } + + if(dl::get_instrumented() < dl::InstrumentMode::PythonProfile) + dl::rocprofsys_preinit(); + + bool _invoked = false; + ROCPROFSYS_DL_INVOKE_STATUS(_invoked, get_indirect().rocprofsys_init_f, a, b, c); + if(_invoked) + { + dl::get_active() = true; + dl::get_inited() = true; + dl::_rocprofsys_dl_verbose = dl::get_rocprofsys_dl_env(); + if(dl::get_instrumented() < dl::InstrumentMode::PythonProfile) + dl::rocprofsys_postinit((c) ? std::string{ c } : std::string{}); + } + } + + void rocprofsys_finalize(void) + { + if(dl::get_inited() && dl::get_finied()) + { + ROCPROFSYS_DL_LOG(2, "%s() ignored :: already initialized and finalized\n", + __FUNCTION__); + return; + } + else if(dl::get_finied() && !dl::get_active()) + { + ROCPROFSYS_DL_LOG(2, "%s() ignored :: already finalized but not active\n", + __FUNCTION__); + return; + } + + bool _invoked = false; + ROCPROFSYS_DL_INVOKE_STATUS(_invoked, get_indirect().rocprofsys_finalize_f); + if(_invoked) + { + dl::get_active() = false; + dl::get_finied() = true; + } + } + + void rocprofsys_push_trace(const char* name) + { + if(!dl::get_active()) return; + if(dl::get_thread_enabled()) + { + ROCPROFSYS_DL_INVOKE(get_indirect().rocprofsys_push_trace_f, name); + } + else + { + ++dl::get_thread_count(); + } + } + + void rocprofsys_pop_trace(const char* name) + { + if(!dl::get_active()) return; + if(dl::get_thread_enabled()) + { + ROCPROFSYS_DL_INVOKE(get_indirect().rocprofsys_pop_trace_f, name); + } + else + { + if(dl::get_thread_count()-- == 0) rocprofsys_user_start_thread_trace_dl(); + } + } + + int rocprofsys_push_region(const char* name) + { + if(!dl::get_active()) return 0; + if(dl::get_thread_enabled()) + { + return ROCPROFSYS_DL_INVOKE(get_indirect().rocprofsys_push_region_f, name); + } + else + { + ++dl::get_thread_count(); + } + return 0; + } + + int rocprofsys_pop_region(const char* name) + { + if(!dl::get_active()) return 0; + if(dl::get_thread_enabled()) + { + return ROCPROFSYS_DL_INVOKE(get_indirect().rocprofsys_pop_region_f, name); + } + else + { + if(dl::get_thread_count()-- == 0) rocprofsys_user_start_thread_trace_dl(); + } + return 0; + } + + int rocprofsys_push_category_region(rocprofsys_category_t _category, const char* name, + rocprofsys_annotation_t* _annotations, + size_t _annotation_count) + { + if(!dl::get_active()) return 0; + if(dl::get_thread_enabled()) + { + return ROCPROFSYS_DL_INVOKE(get_indirect().rocprofsys_push_category_region_f, + _category, name, _annotations, _annotation_count); + } + else + { + ++dl::get_thread_count(); + } + return 0; + } + + int rocprofsys_pop_category_region(rocprofsys_category_t _category, const char* name, + rocprofsys_annotation_t* _annotations, + size_t _annotation_count) + { + if(!dl::get_active()) return 0; + if(dl::get_thread_enabled()) + { + return ROCPROFSYS_DL_INVOKE(get_indirect().rocprofsys_pop_category_region_f, + _category, name, _annotations, _annotation_count); + } + else + { + ++dl::get_thread_count(); + } + return 0; + } + + void rocprofsys_set_env(const char* a, const char* b) + { + if(dl::get_inited() && dl::get_active()) + { + ROCPROFSYS_DL_IGNORE(2, "already initialized and active", a, b); + return; + } + ROCPROFSYS_DL_LOG(2, "%s(%s, %s)\n", __FUNCTION__, a, b); + setenv(a, b, 0); + // ROCPROFSYS_DL_INVOKE(get_indirect().rocprofsys_set_env_f, a, b); + } + + void rocprofsys_set_mpi(bool a, bool b) + { + if(dl::get_inited() && dl::get_active()) + { + ROCPROFSYS_DL_IGNORE(2, "already initialized and active", a, b); + return; + } + ROCPROFSYS_DL_INVOKE(get_indirect().rocprofsys_set_mpi_f, a, b); + } + + void rocprofsys_register_source(const char* file, const char* func, size_t line, + size_t address, const char* source) + { + ROCPROFSYS_DL_LOG(3, "%s(\"%s\", \"%s\", %zu, %zu, \"%s\")\n", __FUNCTION__, file, + func, line, address, source); + ROCPROFSYS_DL_INVOKE(get_indirect().rocprofsys_register_source_f, file, func, + line, address, source); + } + + void rocprofsys_register_coverage(const char* file, const char* func, size_t address) + { + ROCPROFSYS_DL_INVOKE(get_indirect().rocprofsys_register_coverage_f, file, func, + address); + } + + int rocprofsys_user_start_trace_dl(void) + { + dl::get_enabled().store(true); + return rocprofsys_user_start_thread_trace_dl(); + } + + int rocprofsys_user_stop_trace_dl(void) + { + dl::get_enabled().store(false); + return rocprofsys_user_stop_thread_trace_dl(); + } + + int rocprofsys_user_start_thread_trace_dl(void) + { + dl::get_thread_enabled() = true; + return 0; + } + + int rocprofsys_user_stop_thread_trace_dl(void) + { + dl::get_thread_enabled() = false; + return 0; + } + + int rocprofsys_user_push_region_dl(const char* name) + { + if(!dl::get_active()) return 0; + return ROCPROFSYS_DL_INVOKE(get_indirect().rocprofsys_push_region_f, name); + } + + int rocprofsys_user_pop_region_dl(const char* name) + { + if(!dl::get_active()) return 0; + return ROCPROFSYS_DL_INVOKE(get_indirect().rocprofsys_pop_region_f, name); + } + + int rocprofsys_user_progress_dl(const char* name) + { + ROCPROFSYS_DL_INVOKE(get_indirect().rocprofsys_progress_f, name); + return 0; + } + + int rocprofsys_user_push_annotated_region_dl(const char* name, + rocprofsys_annotation_t* _annotations, + size_t _annotation_count) + { + if(!dl::get_active()) return 0; + return ROCPROFSYS_DL_INVOKE(get_indirect().rocprofsys_push_category_region_f, + ROCPROFSYS_CATEGORY_USER, name, _annotations, + _annotation_count); + } + + int rocprofsys_user_pop_annotated_region_dl(const char* name, + rocprofsys_annotation_t* _annotations, + size_t _annotation_count) + { + if(!dl::get_active()) return 0; + return ROCPROFSYS_DL_INVOKE(get_indirect().rocprofsys_pop_category_region_f, + ROCPROFSYS_CATEGORY_USER, name, _annotations, + _annotation_count); + } + + int rocprofsys_user_annotated_progress_dl(const char* name, + rocprofsys_annotation_t* _annotations, + size_t _annotation_count) + { + ROCPROFSYS_DL_INVOKE(get_indirect().rocprofsys_annotated_progress_f, name, + _annotations, _annotation_count); + return 0; + } + + void rocprofsys_progress(const char* _name) + { + return ROCPROFSYS_DL_INVOKE(get_indirect().rocprofsys_progress_f, _name); + } + + void rocprofsys_annotated_progress(const char* _name, + rocprofsys_annotation_t* _annotations, + size_t _annotation_count) + { + return ROCPROFSYS_DL_INVOKE(get_indirect().rocprofsys_annotated_progress_f, _name, + _annotations, _annotation_count); + } + + void rocprofsys_set_instrumented(int _mode) + { + ROCPROFSYS_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) + { + ROCPROFSYS_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 ROCPROFSYS_DL_INVOKE(get_indirect().kokkosp_print_help_f, argv0); + } + + void kokkosp_parse_args(int argc, char** argv) + { + return ROCPROFSYS_DL_INVOKE(get_indirect().kokkosp_parse_args_f, argc, argv); + } + + void kokkosp_declare_metadata(const char* key, const char* value) + { + return ROCPROFSYS_DL_INVOKE(get_indirect().kokkosp_declare_metadata_f, key, + value); + } + + void kokkosp_request_tool_settings(const uint32_t version, + Kokkos_Tools_ToolSettings* settings) + { + return ROCPROFSYS_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 ROCPROFSYS_DL_INVOKE(get_indirect().kokkosp_init_library_f, loadSeq, + interfaceVer, devInfoCount, deviceInfo); + } + + void kokkosp_finalize_library() + { + return ROCPROFSYS_DL_INVOKE(get_indirect().kokkosp_finalize_library_f); + } + + void kokkosp_begin_parallel_for(const char* name, uint32_t devid, uint64_t* kernid) + { + return ROCPROFSYS_DL_INVOKE(get_indirect().kokkosp_begin_parallel_for_f, name, + devid, kernid); + } + + void kokkosp_end_parallel_for(uint64_t kernid) + { + return ROCPROFSYS_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 ROCPROFSYS_DL_INVOKE(get_indirect().kokkosp_begin_parallel_reduce_f, name, + devid, kernid); + } + + void kokkosp_end_parallel_reduce(uint64_t kernid) + { + return ROCPROFSYS_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 ROCPROFSYS_DL_INVOKE(get_indirect().kokkosp_begin_parallel_scan_f, name, + devid, kernid); + } + + void kokkosp_end_parallel_scan(uint64_t kernid) + { + return ROCPROFSYS_DL_INVOKE(get_indirect().kokkosp_end_parallel_scan_f, kernid); + } + + void kokkosp_begin_fence(const char* name, uint32_t devid, uint64_t* kernid) + { + return ROCPROFSYS_DL_INVOKE(get_indirect().kokkosp_begin_fence_f, name, devid, + kernid); + } + + void kokkosp_end_fence(uint64_t kernid) + { + return ROCPROFSYS_DL_INVOKE(get_indirect().kokkosp_end_fence_f, kernid); + } + + void kokkosp_push_profile_region(const char* name) + { + return ROCPROFSYS_DL_INVOKE(get_indirect().kokkosp_push_profile_region_f, name); + } + + void kokkosp_pop_profile_region() + { + return ROCPROFSYS_DL_INVOKE(get_indirect().kokkosp_pop_profile_region_f); + } + + void kokkosp_create_profile_section(const char* name, uint32_t* secid) + { + return ROCPROFSYS_DL_INVOKE(get_indirect().kokkosp_create_profile_section_f, name, + secid); + } + + void kokkosp_destroy_profile_section(uint32_t secid) + { + return ROCPROFSYS_DL_INVOKE(get_indirect().kokkosp_destroy_profile_section_f, + secid); + } + + void kokkosp_start_profile_section(uint32_t secid) + { + return ROCPROFSYS_DL_INVOKE(get_indirect().kokkosp_start_profile_section_f, + secid); + } + + void kokkosp_stop_profile_section(uint32_t secid) + { + return ROCPROFSYS_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 ROCPROFSYS_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 ROCPROFSYS_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 ROCPROFSYS_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 ROCPROFSYS_DL_INVOKE(get_indirect().kokkosp_end_deep_copy_f); + } + + void kokkosp_profile_event(const char* name) + { + return ROCPROFSYS_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 ROCPROFSYS_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 ROCPROFSYS_DL_INVOKE(get_indirect().kokkosp_dual_view_modify_f, label, + data, is_device); + } + + //----------------------------------------------------------------------------------// + // + // HSA + // + //----------------------------------------------------------------------------------// + +#if ROCPROFSYS_USE_ROCTRACER > 0 + bool OnLoad(HsaApiTable* table, uint64_t runtime_version, uint64_t failed_tool_count, + const char* const* failed_tool_names) + { + return ROCPROFSYS_DL_INVOKE(get_indirect().hsa_on_load_f, table, runtime_version, + failed_tool_count, failed_tool_names); + } + + void OnUnload() { return ROCPROFSYS_DL_INVOKE(get_indirect().hsa_on_unload_f); } +#endif + + //----------------------------------------------------------------------------------// + // + // ROCP + // + //----------------------------------------------------------------------------------// + +#if ROCPROFSYS_USE_ROCPROFILER > 0 + void OnLoadToolProp(void* settings) + { + ROCPROFSYS_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 ROCPROFSYS_DL_INVOKE(get_indirect().rocp_on_load_tool_prop_f, settings); + } + + void OnUnloadTool() + { + return ROCPROFSYS_DL_INVOKE(get_indirect().rocp_on_unload_tool_f); + } +#endif + + //----------------------------------------------------------------------------------// + // + // OMPT + // + //----------------------------------------------------------------------------------// +#if ROCPROFSYS_USE_OMPT > 0 + ompt_start_tool_result_t* ompt_start_tool(unsigned int omp_version, + const char* runtime_version) + { + return ROCPROFSYS_DL_INVOKE(get_indirect().ompt_start_tool_f, omp_version, + runtime_version); + } +#endif +} + +namespace rocprofsys +{ +namespace dl +{ +namespace +{ +bool +rocprofsys_preload() ROCPROFSYS_INTERNAL_API; + +std::vector +get_link_map(const char*, + std::vector&& = { (RTLD_LAZY | RTLD_NOLOAD) }) ROCPROFSYS_INTERNAL_API; + +const char* +get_default_mode() ROCPROFSYS_INTERNAL_API; + +void +verify_instrumented_preloaded() ROCPROFSYS_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("ROCPROFSYS_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 +rocprofsys_preinit() +{ + switch(get_instrumented()) + { + case InstrumentMode::None: + case InstrumentMode::BinaryRewrite: + case InstrumentMode::ProcessCreate: + case InstrumentMode::ProcessAttach: + { + auto _use_mpip = get_env("ROCPROFSYS_USE_MPIP", false); + auto _use_mpi = get_env("ROCPROFSYS_USE_MPI", _use_mpip); + auto _causal = get_env("ROCPROFSYS_USE_CAUSAL", false); + auto _mode = get_env("ROCPROFSYS_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 + // ROCPROFSYS_USE_PID. + rocprofsys_set_mpi(_use_mpi, dl::get_instrumented() == + dl::InstrumentMode::ProcessAttach); + } + break; + } + case InstrumentMode::PythonProfile: + case InstrumentMode::Last: break; + } +} + +void +rocprofsys_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")); + + rocprofsys_init_tooling(); + if(_exe.empty()) + rocprofsys_push_trace("main"); + else + rocprofsys_push_trace(basename(_exe.c_str())); + break; + } + case InstrumentMode::PythonProfile: + { + rocprofsys_init_tooling(); + break; + } + case InstrumentMode::Last: break; + } +} + +bool +rocprofsys_preload() +{ + auto _preload = get_rocprofsys_is_preloaded() && get_rocprofsys_preload() && + get_env("ROCPROFSYS_ENABLED", true); + + auto _link_map = get_link_map(nullptr); + auto _instr_mode = + get_env("ROCPROFSYS_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) + { + rocprofsys_set_instrumented(static_cast(_instr_mode)); + break; + } + } + + verify_instrumented_preloaded(); + + static bool _once = false; + if(_once) return _preload; + _once = true; + + if(_preload) + { + reset_rocprofsys_preload(); + rocprofsys_preinit_library(); + } + + return _preload; +} + +void +verify_instrumented_preloaded() +{ + // if preloaded then we are fine + if(get_rocprofsys_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, 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 '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.: + + + mpirun -n 2 + + should be: + + rocprof-sys-run -- + mpirun -n 2 rocprof-sys-run -- + + 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 ROCPROFSYS_SAMPLING_DELAY=5.0 -- sleep + $ echo "ROCPROFSYS_SAMPLING_FREQ = 500" > rocprof-sys.cfg + $ export ROCPROFSYS_CONFIG_FILE=rocprof-sys.cfg + $ 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 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 ROCm Systems Profiler and happy optimizing! + )notice"; + + // emit notice + std::cerr << _notice << std::endl; + + std::quick_exit(EXIT_FAILURE); +} + +bool _handle_preload = rocprofsys_preload(); +main_func_t main_real = nullptr; +} // namespace +} // namespace dl +} // namespace rocprofsys + +extern "C" +{ + int rocprofsys_main(int argc, char** argv, char** envp) ROCPROFSYS_INTERNAL_API; + void rocprofsys_set_main(main_func_t) ROCPROFSYS_INTERNAL_API; + + void rocprofsys_set_main(main_func_t _main_real) + { + ::rocprofsys::dl::main_real = _main_real; + } + + int rocprofsys_main(int argc, char** argv, char** envp) + { + ROCPROFSYS_DL_LOG(0, "%s\n", __FUNCTION__); + using ::rocprofsys::common::get_env; + using ::rocprofsys::dl::get_default_mode; + + // prevent re-entry + static int _reentry = 0; + if(_reentry > 0) return -1; + _reentry = 1; + + if(!::rocprofsys::dl::main_real) + throw std::runtime_error("[rocprof-sys][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("ROCPROFSYS") != 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); + ROCPROFSYS_DL_LOG(1, "%s(%s, %s)\n", "rocprofsys_set_env", + _var.c_str(), _val.c_str()); + setenv(_var.c_str(), _val.c_str(), 0); + } + } + } + + auto _mode = get_env("ROCPROFSYS_MODE", get_default_mode()); + rocprofsys_init(_mode.c_str(), + dl::get_instrumented() == dl::InstrumentMode::BinaryRewrite, + argv[0]); + + int ret = (*::rocprofsys::dl::main_real)(argc, argv, envp); + + rocprofsys_pop_trace(basename(argv[0])); + rocprofsys_finalize(); + + return ret; + } +} diff --git a/source/lib/rocprof-sys-dl/dl/dl.hpp b/source/lib/rocprof-sys-dl/dl/dl.hpp new file mode 100644 index 00000000..1a34612b --- /dev/null +++ b/source/lib/rocprof-sys-dl/dl/dl.hpp @@ -0,0 +1,212 @@ +// MIT License +// +// Copyright (c) 2022-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 +// 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. + +#ifndef ROCPROFSYS_DL_HPP_ +#define ROCPROFSYS_DL_HPP_ + +#if defined(ROCPROFSYS_DL_SOURCE) && (ROCPROFSYS_DL_SOURCE > 0) +# include "common/defines.h" +#else +# if !defined(ROCPROFSYS_PUBLIC_API) +# define ROCPROFSYS_PUBLIC_API +# endif +#endif + +#include "rocprofiler-systems/user.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if !defined(ROCPROFSYS_USE_OMPT) +# define ROCPROFSYS_USE_OMPT 0 +#endif + +#if !defined(ROCPROFSYS_USE_ROCTRACER) +# define ROCPROFSYS_USE_ROCTRACER 0 +#endif + +#if !defined(ROCPROFSYS_USE_ROCPROFILER) +# define ROCPROFSYS_USE_ROCPROFILER 0 +#endif + +//--------------------------------------------------------------------------------------// +// +// rocprof-sys symbols +// +//--------------------------------------------------------------------------------------// + +extern "C" +{ + void rocprofsys_init_library(void) ROCPROFSYS_PUBLIC_API; + void rocprofsys_init_tooling(void) ROCPROFSYS_PUBLIC_API; + void rocprofsys_init(const char*, bool, const char*) ROCPROFSYS_PUBLIC_API; + void rocprofsys_finalize(void) ROCPROFSYS_PUBLIC_API; + void rocprofsys_set_env(const char* env_name, + const char* env_val) ROCPROFSYS_PUBLIC_API; + void rocprofsys_set_mpi(bool use, bool attached) ROCPROFSYS_PUBLIC_API; + void rocprofsys_set_instrumented(int) ROCPROFSYS_PUBLIC_API; + void rocprofsys_push_trace(const char* name) ROCPROFSYS_PUBLIC_API; + void rocprofsys_pop_trace(const char* name) ROCPROFSYS_PUBLIC_API; + int rocprofsys_push_region(const char*) ROCPROFSYS_PUBLIC_API; + int rocprofsys_pop_region(const char*) ROCPROFSYS_PUBLIC_API; + int rocprofsys_push_category_region(rocprofsys_category_t, const char*, + rocprofsys_annotation_t*, + size_t) ROCPROFSYS_PUBLIC_API; + int rocprofsys_pop_category_region(rocprofsys_category_t, const char*, + rocprofsys_annotation_t*, + size_t) ROCPROFSYS_PUBLIC_API; + + void rocprofsys_register_source(const char* file, const char* func, size_t line, + size_t address, + const char* source) ROCPROFSYS_PUBLIC_API; + void rocprofsys_register_coverage(const char* file, const char* func, + size_t address) ROCPROFSYS_PUBLIC_API; + void rocprofsys_progress(const char*) ROCPROFSYS_PUBLIC_API; + void rocprofsys_annotated_progress(const char*, rocprofsys_annotation_t*, + size_t) ROCPROFSYS_PUBLIC_API; + +#if defined(ROCPROFSYS_DL_SOURCE) && (ROCPROFSYS_DL_SOURCE > 0) + void rocprofsys_preinit_library(void) ROCPROFSYS_HIDDEN_API; + int rocprofsys_preload_library(void) ROCPROFSYS_HIDDEN_API; + + int rocprofsys_user_start_trace_dl(void) ROCPROFSYS_HIDDEN_API; + int rocprofsys_user_stop_trace_dl(void) ROCPROFSYS_HIDDEN_API; + + int rocprofsys_user_start_thread_trace_dl(void) ROCPROFSYS_HIDDEN_API; + int rocprofsys_user_stop_thread_trace_dl(void) ROCPROFSYS_HIDDEN_API; + + int rocprofsys_user_push_region_dl(const char*) ROCPROFSYS_HIDDEN_API; + int rocprofsys_user_pop_region_dl(const char*) ROCPROFSYS_HIDDEN_API; + + int rocprofsys_user_push_annotated_region_dl(const char*, rocprofsys_annotation_t*, + size_t) ROCPROFSYS_HIDDEN_API; + int rocprofsys_user_pop_annotated_region_dl(const char*, rocprofsys_annotation_t*, + size_t) ROCPROFSYS_HIDDEN_API; + + int rocprofsys_user_progress_dl(const char* name) ROCPROFSYS_HIDDEN_API; + int rocprofsys_user_annotated_progress_dl(const char*, rocprofsys_annotation_t*, + size_t) ROCPROFSYS_HIDDEN_API; + // KokkosP + struct ROCPROFSYS_HIDDEN_API SpaceHandle + { + char name[64]; + }; + + struct ROCPROFSYS_HIDDEN_API Kokkos_Tools_ToolSettings + { + bool requires_global_fencing; + bool padding[255]; + }; + + void kokkosp_print_help(char*) ROCPROFSYS_PUBLIC_API; + void kokkosp_parse_args(int, char**) ROCPROFSYS_PUBLIC_API; + void kokkosp_declare_metadata(const char*, const char*) ROCPROFSYS_PUBLIC_API; + void kokkosp_request_tool_settings(const uint32_t, + Kokkos_Tools_ToolSettings*) ROCPROFSYS_PUBLIC_API; + void kokkosp_init_library(const int, const uint64_t, const uint32_t, + void*) ROCPROFSYS_PUBLIC_API; + void kokkosp_finalize_library() ROCPROFSYS_PUBLIC_API; + void kokkosp_begin_parallel_for(const char*, uint32_t, + uint64_t*) ROCPROFSYS_PUBLIC_API; + void kokkosp_end_parallel_for(uint64_t) ROCPROFSYS_PUBLIC_API; + void kokkosp_begin_parallel_reduce(const char*, uint32_t, + uint64_t*) ROCPROFSYS_PUBLIC_API; + void kokkosp_end_parallel_reduce(uint64_t) ROCPROFSYS_PUBLIC_API; + void kokkosp_begin_parallel_scan(const char*, uint32_t, + uint64_t*) ROCPROFSYS_PUBLIC_API; + void kokkosp_end_parallel_scan(uint64_t) ROCPROFSYS_PUBLIC_API; + void kokkosp_begin_fence(const char*, uint32_t, uint64_t*) ROCPROFSYS_PUBLIC_API; + void kokkosp_end_fence(uint64_t) ROCPROFSYS_PUBLIC_API; + void kokkosp_push_profile_region(const char*) ROCPROFSYS_PUBLIC_API; + void kokkosp_pop_profile_region() ROCPROFSYS_PUBLIC_API; + void kokkosp_create_profile_section(const char*, uint32_t*) ROCPROFSYS_PUBLIC_API; + void kokkosp_destroy_profile_section(uint32_t) ROCPROFSYS_PUBLIC_API; + void kokkosp_start_profile_section(uint32_t) ROCPROFSYS_PUBLIC_API; + void kokkosp_stop_profile_section(uint32_t) ROCPROFSYS_PUBLIC_API; + void kokkosp_allocate_data(const SpaceHandle, const char*, const void* const, + const uint64_t) ROCPROFSYS_PUBLIC_API; + void kokkosp_deallocate_data(const SpaceHandle, const char*, const void* const, + const uint64_t) ROCPROFSYS_PUBLIC_API; + void kokkosp_begin_deep_copy(SpaceHandle, const char*, const void*, SpaceHandle, + const char*, const void*, + uint64_t) ROCPROFSYS_PUBLIC_API; + void kokkosp_end_deep_copy() ROCPROFSYS_PUBLIC_API; + void kokkosp_profile_event(const char*) ROCPROFSYS_PUBLIC_API; + void kokkosp_dual_view_sync(const char*, const void* const, + bool) ROCPROFSYS_PUBLIC_API; + void kokkosp_dual_view_modify(const char*, const void* const, + bool) ROCPROFSYS_PUBLIC_API; + + // OpenMP Tools (OMPT) +# if ROCPROFSYS_USE_OMPT > 0 + struct ompt_start_tool_result_t; + + ompt_start_tool_result_t* ompt_start_tool(unsigned int, + const char*) ROCPROFSYS_PUBLIC_API; +# endif + +# if ROCPROFSYS_USE_ROCTRACER > 0 + // HSA + struct HsaApiTable; + bool OnLoad(HsaApiTable* table, uint64_t runtime_version, uint64_t failed_tool_count, + const char* const* failed_tool_names) ROCPROFSYS_PUBLIC_API; + void OnUnload() ROCPROFSYS_PUBLIC_API; +# endif + +# if ROCPROFSYS_USE_ROCPROFILER > 0 + // ROCP + void OnLoadToolProp(void* settings) ROCPROFSYS_PUBLIC_API; + void OnUnloadTool() ROCPROFSYS_PUBLIC_API; +# endif +#endif +} + +namespace rocprofsys +{ +namespace dl +{ +enum class InstrumentMode : int +{ + None = -1, + BinaryRewrite = 0, + ProcessCreate = 1, // runtime instrumentation at start of process + ProcessAttach = 2, // runtime instrumentation of running process + PythonProfile = 3, // python setprofile + Last, +}; +} +} // namespace rocprofsys + +#endif // ROCPROFSYS_DL_HPP_ 1 diff --git a/source/lib/omnitrace-dl/main.c b/source/lib/rocprof-sys-dl/main.c similarity index 62% rename from source/lib/omnitrace-dl/main.c rename to source/lib/rocprof-sys-dl/main.c index c83325c6..7391a4e7 100644 --- a/source/lib/omnitrace-dl/main.c +++ b/source/lib/rocprof-sys-dl/main.c @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -22,9 +22,9 @@ #define _GNU_SOURCE -#define OMNITRACE_PUBLIC_API __attribute__((visibility("default"))); -#define OMNITRACE_HIDDEN_API __attribute__((visibility("hidden"))); -#define OMNITRACE_INTERNAL_API __attribute__((visibility("internal"))); +#define ROCPROFSYS_PUBLIC_API __attribute__((visibility("default"))); +#define ROCPROFSYS_HIDDEN_API __attribute__((visibility("hidden"))); +#define ROCPROFSYS_INTERNAL_API __attribute__((visibility("internal"))); #include #include @@ -45,49 +45,49 @@ typedef int (*start_main_t)(int (*)(int, char**, char**), int, char**, // local function declarations // int -omnitrace_libc_start_main(int (*)(int, char**, char**), int, char**, - int (*)(int, char**, char**), void (*)(void), void (*)(void), - void*) OMNITRACE_INTERNAL_API; +rocprofsys_libc_start_main(int (*)(int, char**, char**), int, char**, + int (*)(int, char**, char**), void (*)(void), void (*)(void), + void*) ROCPROFSYS_INTERNAL_API; int __libc_start_main(int (*)(int, char**, char**), int, char**, int (*)(int, char**, char**), - void (*)(void), void (*)(void), void*) OMNITRACE_PUBLIC_API; + void (*)(void), void (*)(void), void*) ROCPROFSYS_PUBLIC_API; // // external function declarations // extern int -omnitrace_preload_library(void); +rocprofsys_preload_library(void); extern void -omnitrace_finalize(void); +rocprofsys_finalize(void); extern void -omnitrace_push_trace(const char* name); +rocprofsys_push_trace(const char* name); extern void -omnitrace_pop_trace(const char* name); +rocprofsys_pop_trace(const char* name); extern void -omnitrace_init_tooling(void); +rocprofsys_init_tooling(void); extern void -omnitrace_init(const char*, bool, const char*); +rocprofsys_init(const char*, bool, const char*); extern char* basename(const char*); -extern void omnitrace_set_main(main_func_t) OMNITRACE_INTERNAL_API; +extern void rocprofsys_set_main(main_func_t) ROCPROFSYS_INTERNAL_API; extern int -omnitrace_main(int argc, char** argv, char** envp) OMNITRACE_INTERNAL_API; +rocprofsys_main(int argc, char** argv, char** envp) ROCPROFSYS_INTERNAL_API; int -omnitrace_libc_start_main(int (*_main)(int, char**, char**), int _argc, char** _argv, - int (*_init)(int, char**, char**), void (*_fini)(void), - void (*_rtld_fini)(void), void* _stack_end) +rocprofsys_libc_start_main(int (*_main)(int, char**, char**), int _argc, char** _argv, + int (*_init)(int, char**, char**), void (*_fini)(void), + void (*_rtld_fini)(void), void* _stack_end) { - int _preload = omnitrace_preload_library(); + int _preload = rocprofsys_preload_library(); // prevent re-entry static int _reentry = 0; @@ -98,13 +98,13 @@ omnitrace_libc_start_main(int (*_main)(int, char**, char**), int _argc, char** _ void* _this_func = __builtin_return_address(0); // Save the real main function address - omnitrace_set_main(_main); + rocprofsys_set_main(_main); // Find the real __libc_start_main() start_main_t user_main = dlsym(RTLD_NEXT, "__libc_start_main"); // disable future LD_PRELOADs - setenv("OMNITRACE_PRELOAD", "0", 1); + setenv("ROCPROFSYS_PRELOAD", "0", 1); if(user_main && user_main != _this_func) { @@ -115,14 +115,14 @@ omnitrace_libc_start_main(int (*_main)(int, char**, char**), int _argc, char** _ } else { - // call omnitrace main function wrapper - return user_main(omnitrace_main, _argc, _argv, _init, _fini, _rtld_fini, + // call rocprof-sys main function wrapper + return user_main(rocprofsys_main, _argc, _argv, _init, _fini, _rtld_fini, _stack_end); } } else { - fputs("Error! omnitrace could not find __libc_start_main!", stderr); + fputs("Error! rocprof-sys could not find __libc_start_main!", stderr); return -1; } } @@ -132,6 +132,6 @@ __libc_start_main(int (*_main)(int, char**, char**), int _argc, char** _argv, int (*_init)(int, char**, char**), void (*_fini)(void), void (*_rtld_fini)(void), void* _stack_end) { - return omnitrace_libc_start_main(_main, _argc, _argv, _init, _fini, _rtld_fini, - _stack_end); + return rocprofsys_libc_start_main(_main, _argc, _argv, _init, _fini, _rtld_fini, + _stack_end); } diff --git a/source/lib/omnitrace-rt/CMakeLists.txt b/source/lib/rocprof-sys-rt/CMakeLists.txt similarity index 80% rename from source/lib/omnitrace-rt/CMakeLists.txt rename to source/lib/rocprof-sys-rt/CMakeLists.txt index c189d4d2..c00308ce 100644 --- a/source/lib/omnitrace-rt/CMakeLists.txt +++ b/source/lib/rocprof-sys-rt/CMakeLists.txt @@ -91,45 +91,48 @@ if(UNIX) endif() endif() -add_library(omnitrace-rt-library SHARED) -add_library(omnitrace::omnitrace-rt-library ALIAS omnitrace-rt-library) +add_library(rocprofiler-systems-rt-library SHARED) +add_library(rocprofiler-systems::rocprofiler-systems-rt-library ALIAS + rocprofiler-systems-rt-library) -target_sources(omnitrace-rt-library PRIVATE ${SRC_LIST}) +target_sources(rocprofiler-systems-rt-library PRIVATE ${SRC_LIST}) target_include_directories( - omnitrace-rt-library PRIVATE $ - $) -target_compile_definitions(omnitrace-rt-library PRIVATE ${UNIFIED_DEFINES}) + rocprofiler-systems-rt-library + PRIVATE $ + $) +target_compile_definitions(rocprofiler-systems-rt-library PRIVATE ${UNIFIED_DEFINES}) target_link_libraries( - omnitrace-rt-library + rocprofiler-systems-rt-library PUBLIC $ - PRIVATE omnitrace::omnitrace-threading) + PRIVATE rocprofiler-systems::rocprofiler-systems-threading) -add_target_cxx_flag_if_avail(omnitrace-rt-library "-g3") +add_target_cxx_flag_if_avail(rocprofiler-systems-rt-library "-g3") set_target_properties( - omnitrace-rt-library - PROPERTIES OUTPUT_NAME omnitrace-rt + rocprofiler-systems-rt-library + PROPERTIES OUTPUT_NAME ${BINARY_NAME_PREFIX}-rt VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} BUILD_RPATH "\$ORIGIN" INSTALL_RPATH "\$ORIGIN") -omnitrace_strip_target(omnitrace-rt-library) +rocprofiler_systems_strip_target(rocprofiler-systems-rt-library) -install(TARGETS omnitrace-rt-library DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(TARGETS rocprofiler-systems-rt-library DESTINATION ${CMAKE_INSTALL_LIBDIR}) if(NOT EXISTS ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}) file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}) endif() add_custom_target( - omnitrace-rt-library-dyninstAPI_RT-symlink ALL - ${CMAKE_COMMAND} -E create_symlink ../$ + rocprofiler-systems-rt-library-dyninstAPI_RT-symlink ALL + ${CMAKE_COMMAND} -E create_symlink + ../$ ${CMAKE_SHARED_LIBRARY_PREFIX}dyninstAPI_RT${CMAKE_SHARED_LIBRARY_SUFFIX} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME} - DEPENDS omnitrace-rt-library + DEPENDS rocprofiler-systems-rt-library COMMENT - "Creating ${CMAKE_SHARED_LIBRARY_PREFIX}dyninstAPI_RT${CMAKE_SHARED_LIBRARY_SUFFIX} to omnitrace-rt..." + "Creating ${CMAKE_SHARED_LIBRARY_PREFIX}dyninstAPI_RT${CMAKE_SHARED_LIBRARY_SUFFIX} to rocprof-sys-rt..." ) install( diff --git a/source/lib/omnitrace-rt/cmake/dynsysname b/source/lib/rocprof-sys-rt/cmake/dynsysname similarity index 100% rename from source/lib/omnitrace-rt/cmake/dynsysname rename to source/lib/rocprof-sys-rt/cmake/dynsysname diff --git a/source/lib/omnitrace-rt/cmake/platform.cmake b/source/lib/rocprof-sys-rt/cmake/platform.cmake similarity index 96% rename from source/lib/omnitrace-rt/cmake/platform.cmake rename to source/lib/rocprof-sys-rt/cmake/platform.cmake index ae737009..4d282b0c 100644 --- a/source/lib/omnitrace-rt/cmake/platform.cmake +++ b/source/lib/rocprof-sys-rt/cmake/platform.cmake @@ -29,14 +29,14 @@ if(INVALID_PLATFORM) OUTPUT_VARIABLE DYNSYSNAME_OUT OUTPUT_STRIP_TRAILING_WHITESPACE) string(REPLACE "\n" "" PLATFORM ${DYNSYSNAME_OUT}) - omnitrace_message(STATUS - "-- Attempting to automatically identify platform: ${PLATFORM}") + rocprofiler_systems_message( + STATUS "-- Attempting to automatically identify platform: ${PLATFORM}") endif() list(FIND VALID_PLATFORMS ${PLATFORM} PLATFORM_FOUND) if(PLATFORM_FOUND EQUAL -1) - omnitrace_message( + rocprofiler_systems_message( FATAL_ERROR "Error: unknown platform ${PLATFORM}; please set the PLATFORM environment variable to one of the following options: ${VALID_PLATFORMS}" ) diff --git a/source/lib/omnitrace-rt/cmake/sysname b/source/lib/rocprof-sys-rt/cmake/sysname similarity index 100% rename from source/lib/omnitrace-rt/cmake/sysname rename to source/lib/rocprof-sys-rt/cmake/sysname diff --git a/source/lib/omnitrace-rt/h/Types.h b/source/lib/rocprof-sys-rt/h/Types.h similarity index 100% rename from source/lib/omnitrace-rt/h/Types.h rename to source/lib/rocprof-sys-rt/h/Types.h diff --git a/source/lib/omnitrace-rt/h/compiler_annotations.h b/source/lib/rocprof-sys-rt/h/compiler_annotations.h similarity index 100% rename from source/lib/omnitrace-rt/h/compiler_annotations.h rename to source/lib/rocprof-sys-rt/h/compiler_annotations.h diff --git a/source/lib/omnitrace-rt/h/dyninstAPI_RT.h b/source/lib/rocprof-sys-rt/h/dyninstAPI_RT.h similarity index 100% rename from source/lib/omnitrace-rt/h/dyninstAPI_RT.h rename to source/lib/rocprof-sys-rt/h/dyninstAPI_RT.h diff --git a/source/lib/omnitrace-rt/h/dyninstRTExport.h b/source/lib/rocprof-sys-rt/h/dyninstRTExport.h similarity index 100% rename from source/lib/omnitrace-rt/h/dyninstRTExport.h rename to source/lib/rocprof-sys-rt/h/dyninstRTExport.h diff --git a/source/lib/omnitrace-rt/h/dyntypes.h b/source/lib/rocprof-sys-rt/h/dyntypes.h similarity index 100% rename from source/lib/omnitrace-rt/h/dyntypes.h rename to source/lib/rocprof-sys-rt/h/dyntypes.h diff --git a/source/lib/omnitrace-rt/h/util.h b/source/lib/rocprof-sys-rt/h/util.h similarity index 100% rename from source/lib/omnitrace-rt/h/util.h rename to source/lib/rocprof-sys-rt/h/util.h diff --git a/source/lib/omnitrace-rt/src/DYNINSTAPI_RT_EXPORTS b/source/lib/rocprof-sys-rt/src/DYNINSTAPI_RT_EXPORTS similarity index 100% rename from source/lib/omnitrace-rt/src/DYNINSTAPI_RT_EXPORTS rename to source/lib/rocprof-sys-rt/src/DYNINSTAPI_RT_EXPORTS diff --git a/source/lib/omnitrace-rt/src/RTcommon.c b/source/lib/rocprof-sys-rt/src/RTcommon.c similarity index 100% rename from source/lib/omnitrace-rt/src/RTcommon.c rename to source/lib/rocprof-sys-rt/src/RTcommon.c diff --git a/source/lib/omnitrace-rt/src/RTcommon.h b/source/lib/rocprof-sys-rt/src/RTcommon.h similarity index 100% rename from source/lib/omnitrace-rt/src/RTcommon.h rename to source/lib/rocprof-sys-rt/src/RTcommon.h diff --git a/source/lib/omnitrace-rt/src/RTfreebsd.c b/source/lib/rocprof-sys-rt/src/RTfreebsd.c similarity index 100% rename from source/lib/omnitrace-rt/src/RTfreebsd.c rename to source/lib/rocprof-sys-rt/src/RTfreebsd.c diff --git a/source/lib/omnitrace-rt/src/RTheap-freebsd.c b/source/lib/rocprof-sys-rt/src/RTheap-freebsd.c similarity index 100% rename from source/lib/omnitrace-rt/src/RTheap-freebsd.c rename to source/lib/rocprof-sys-rt/src/RTheap-freebsd.c diff --git a/source/lib/omnitrace-rt/src/RTheap-linux.c b/source/lib/rocprof-sys-rt/src/RTheap-linux.c similarity index 100% rename from source/lib/omnitrace-rt/src/RTheap-linux.c rename to source/lib/rocprof-sys-rt/src/RTheap-linux.c diff --git a/source/lib/omnitrace-rt/src/RTheap-win.c b/source/lib/rocprof-sys-rt/src/RTheap-win.c similarity index 100% rename from source/lib/omnitrace-rt/src/RTheap-win.c rename to source/lib/rocprof-sys-rt/src/RTheap-win.c diff --git a/source/lib/omnitrace-rt/src/RTheap.c b/source/lib/rocprof-sys-rt/src/RTheap.c similarity index 100% rename from source/lib/omnitrace-rt/src/RTheap.c rename to source/lib/rocprof-sys-rt/src/RTheap.c diff --git a/source/lib/omnitrace-rt/src/RTheap.h b/source/lib/rocprof-sys-rt/src/RTheap.h similarity index 100% rename from source/lib/omnitrace-rt/src/RTheap.h rename to source/lib/rocprof-sys-rt/src/RTheap.h diff --git a/source/lib/omnitrace-rt/src/RTlinux.c b/source/lib/rocprof-sys-rt/src/RTlinux.c similarity index 100% rename from source/lib/omnitrace-rt/src/RTlinux.c rename to source/lib/rocprof-sys-rt/src/RTlinux.c diff --git a/source/lib/omnitrace-rt/src/RTmemEmulator.c b/source/lib/rocprof-sys-rt/src/RTmemEmulator.c similarity index 100% rename from source/lib/omnitrace-rt/src/RTmemEmulator.c rename to source/lib/rocprof-sys-rt/src/RTmemEmulator.c diff --git a/source/lib/omnitrace-rt/src/RTposix.c b/source/lib/rocprof-sys-rt/src/RTposix.c similarity index 100% rename from source/lib/omnitrace-rt/src/RTposix.c rename to source/lib/rocprof-sys-rt/src/RTposix.c diff --git a/source/lib/omnitrace-rt/src/RTsigill-x86.S b/source/lib/rocprof-sys-rt/src/RTsigill-x86.S similarity index 100% rename from source/lib/omnitrace-rt/src/RTsigill-x86.S rename to source/lib/rocprof-sys-rt/src/RTsigill-x86.S diff --git a/source/lib/omnitrace-rt/src/RTsignal-x86.S b/source/lib/rocprof-sys-rt/src/RTsignal-x86.S similarity index 100% rename from source/lib/omnitrace-rt/src/RTsignal-x86.S rename to source/lib/rocprof-sys-rt/src/RTsignal-x86.S diff --git a/source/lib/omnitrace-rt/src/RTsignal-x86_64.S b/source/lib/rocprof-sys-rt/src/RTsignal-x86_64.S similarity index 100% rename from source/lib/omnitrace-rt/src/RTsignal-x86_64.S rename to source/lib/rocprof-sys-rt/src/RTsignal-x86_64.S diff --git a/source/lib/omnitrace-rt/src/RTsignal.c b/source/lib/rocprof-sys-rt/src/RTsignal.c similarity index 100% rename from source/lib/omnitrace-rt/src/RTsignal.c rename to source/lib/rocprof-sys-rt/src/RTsignal.c diff --git a/source/lib/omnitrace-rt/src/RTspace-smallmem.s b/source/lib/rocprof-sys-rt/src/RTspace-smallmem.s similarity index 100% rename from source/lib/omnitrace-rt/src/RTspace-smallmem.s rename to source/lib/rocprof-sys-rt/src/RTspace-smallmem.s diff --git a/source/lib/omnitrace-rt/src/RTspace.S b/source/lib/rocprof-sys-rt/src/RTspace.S similarity index 100% rename from source/lib/omnitrace-rt/src/RTspace.S rename to source/lib/rocprof-sys-rt/src/RTspace.S diff --git a/source/lib/omnitrace-rt/src/RTstatic_ctors_dtors-aarch64.c b/source/lib/rocprof-sys-rt/src/RTstatic_ctors_dtors-aarch64.c similarity index 100% rename from source/lib/omnitrace-rt/src/RTstatic_ctors_dtors-aarch64.c rename to source/lib/rocprof-sys-rt/src/RTstatic_ctors_dtors-aarch64.c diff --git a/source/lib/omnitrace-rt/src/RTstatic_ctors_dtors-ppc32.c b/source/lib/rocprof-sys-rt/src/RTstatic_ctors_dtors-ppc32.c similarity index 100% rename from source/lib/omnitrace-rt/src/RTstatic_ctors_dtors-ppc32.c rename to source/lib/rocprof-sys-rt/src/RTstatic_ctors_dtors-ppc32.c diff --git a/source/lib/omnitrace-rt/src/RTstatic_ctors_dtors-ppc64.c b/source/lib/rocprof-sys-rt/src/RTstatic_ctors_dtors-ppc64.c similarity index 100% rename from source/lib/omnitrace-rt/src/RTstatic_ctors_dtors-ppc64.c rename to source/lib/rocprof-sys-rt/src/RTstatic_ctors_dtors-ppc64.c diff --git a/source/lib/omnitrace-rt/src/RTstatic_ctors_dtors-x86.c b/source/lib/rocprof-sys-rt/src/RTstatic_ctors_dtors-x86.c similarity index 100% rename from source/lib/omnitrace-rt/src/RTstatic_ctors_dtors-x86.c rename to source/lib/rocprof-sys-rt/src/RTstatic_ctors_dtors-x86.c diff --git a/source/lib/omnitrace-rt/src/RTstatic_ctors_dtors_begin.c b/source/lib/rocprof-sys-rt/src/RTstatic_ctors_dtors_begin.c similarity index 100% rename from source/lib/omnitrace-rt/src/RTstatic_ctors_dtors_begin.c rename to source/lib/rocprof-sys-rt/src/RTstatic_ctors_dtors_begin.c diff --git a/source/lib/omnitrace-rt/src/RTstatic_ctors_dtors_end.c b/source/lib/rocprof-sys-rt/src/RTstatic_ctors_dtors_end.c similarity index 100% rename from source/lib/omnitrace-rt/src/RTstatic_ctors_dtors_end.c rename to source/lib/rocprof-sys-rt/src/RTstatic_ctors_dtors_end.c diff --git a/source/lib/omnitrace-rt/src/RTthread-aarch64.c b/source/lib/rocprof-sys-rt/src/RTthread-aarch64.c similarity index 100% rename from source/lib/omnitrace-rt/src/RTthread-aarch64.c rename to source/lib/rocprof-sys-rt/src/RTthread-aarch64.c diff --git a/source/lib/omnitrace-rt/src/RTthread-power-asm.s b/source/lib/rocprof-sys-rt/src/RTthread-power-asm.s similarity index 100% rename from source/lib/omnitrace-rt/src/RTthread-power-asm.s rename to source/lib/rocprof-sys-rt/src/RTthread-power-asm.s diff --git a/source/lib/omnitrace-rt/src/RTthread-powerpc-asm.S b/source/lib/rocprof-sys-rt/src/RTthread-powerpc-asm.S similarity index 100% rename from source/lib/omnitrace-rt/src/RTthread-powerpc-asm.S rename to source/lib/rocprof-sys-rt/src/RTthread-powerpc-asm.S diff --git a/source/lib/omnitrace-rt/src/RTthread-powerpc.c b/source/lib/rocprof-sys-rt/src/RTthread-powerpc.c similarity index 100% rename from source/lib/omnitrace-rt/src/RTthread-powerpc.c rename to source/lib/rocprof-sys-rt/src/RTthread-powerpc.c diff --git a/source/lib/omnitrace-rt/src/RTthread-x86-64.c b/source/lib/rocprof-sys-rt/src/RTthread-x86-64.c similarity index 100% rename from source/lib/omnitrace-rt/src/RTthread-x86-64.c rename to source/lib/rocprof-sys-rt/src/RTthread-x86-64.c diff --git a/source/lib/omnitrace-rt/src/RTthread-x86.c b/source/lib/rocprof-sys-rt/src/RTthread-x86.c similarity index 100% rename from source/lib/omnitrace-rt/src/RTthread-x86.c rename to source/lib/rocprof-sys-rt/src/RTthread-x86.c diff --git a/source/lib/omnitrace-rt/src/RTthread.c b/source/lib/rocprof-sys-rt/src/RTthread.c similarity index 100% rename from source/lib/omnitrace-rt/src/RTthread.c rename to source/lib/rocprof-sys-rt/src/RTthread.c diff --git a/source/lib/omnitrace-rt/src/RTthread.h b/source/lib/rocprof-sys-rt/src/RTthread.h similarity index 100% rename from source/lib/omnitrace-rt/src/RTthread.h rename to source/lib/rocprof-sys-rt/src/RTthread.h diff --git a/source/lib/omnitrace-rt/src/RTtlsgetaddr-x86.S b/source/lib/rocprof-sys-rt/src/RTtlsgetaddr-x86.S similarity index 100% rename from source/lib/omnitrace-rt/src/RTtlsgetaddr-x86.S rename to source/lib/rocprof-sys-rt/src/RTtlsgetaddr-x86.S diff --git a/source/lib/omnitrace-rt/src/RTtlsgetaddr-x86_64.S b/source/lib/rocprof-sys-rt/src/RTtlsgetaddr-x86_64.S similarity index 100% rename from source/lib/omnitrace-rt/src/RTtlsgetaddr-x86_64.S rename to source/lib/rocprof-sys-rt/src/RTtlsgetaddr-x86_64.S diff --git a/source/lib/omnitrace-rt/src/RTwinnt.c b/source/lib/rocprof-sys-rt/src/RTwinnt.c similarity index 100% rename from source/lib/omnitrace-rt/src/RTwinnt.c rename to source/lib/rocprof-sys-rt/src/RTwinnt.c diff --git a/source/lib/omnitrace-rt/src/libSpace.s b/source/lib/rocprof-sys-rt/src/libSpace.s similarity index 100% rename from source/lib/omnitrace-rt/src/libSpace.s rename to source/lib/rocprof-sys-rt/src/libSpace.s diff --git a/source/lib/omnitrace-rt/src/libSpace64.s b/source/lib/rocprof-sys-rt/src/libSpace64.s similarity index 100% rename from source/lib/omnitrace-rt/src/libSpace64.s rename to source/lib/rocprof-sys-rt/src/libSpace64.s diff --git a/source/lib/rocprof-sys-user/CMakeLists.txt b/source/lib/rocprof-sys-user/CMakeLists.txt new file mode 100644 index 00000000..f3cfbd5d --- /dev/null +++ b/source/lib/rocprof-sys-user/CMakeLists.txt @@ -0,0 +1,60 @@ +# ------------------------------------------------------------------------------# +# +# rocprofiler-systems user library +# +# ------------------------------------------------------------------------------# + +set(CMAKE_BUILD_TYPE "Release") +set(CMAKE_SKIP_RPATH OFF) +set(BUILD_RPATH_USE_ORIGIN ON) +set(CMAKE_CXX_VISIBILITY_PRESET "hidden") +set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) + +add_library(rocprofiler-systems-user-library SHARED) +add_library(rocprofiler-systems::rocprofiler-systems-user-library ALIAS + rocprofiler-systems-user-library) + +set(_user_headers + ${CMAKE_CURRENT_SOURCE_DIR}/rocprofiler-systems/user.h + ${CMAKE_CURRENT_SOURCE_DIR}/rocprofiler-systems/types.h + ${CMAKE_CURRENT_SOURCE_DIR}/rocprofiler-systems/causal.h + ${CMAKE_CURRENT_SOURCE_DIR}/rocprofiler-systems/categories.h) + +set(_user_sources ${CMAKE_CURRENT_SOURCE_DIR}/user.cpp) + +target_sources(rocprofiler-systems-user-library PRIVATE ${_user_sources} ${_user_headers}) +target_include_directories( + rocprofiler-systems-user-library + PUBLIC $ + $) +target_link_libraries( + rocprofiler-systems-user-library + PRIVATE + $) + +set_target_properties( + rocprofiler-systems-user-library + PROPERTIES OUTPUT_NAME ${BINARY_NAME_PREFIX}-user + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} + POSITION_INDEPENDENT_CODE ON + BUILD_RPATH "\$ORIGIN" + INSTALL_RPATH "\$ORIGIN") + +rocprofiler_systems_strip_target(rocprofiler-systems-user-library) + +foreach(_HEADER ${_user_headers}) + string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/rocprofiler-systems/" + "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/" _DEST ${_HEADER}) + string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" + "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/" _DEST "${_DEST}") + + configure_file(${_HEADER} ${_DEST} COPYONLY) +endforeach() + +install(FILES ${_user_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) + +install( + TARGETS rocprofiler-systems-user-library + EXPORT rocprofiler-systems-library-targets + DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/source/lib/rocprof-sys-user/rocprofiler-systems/categories.h b/source/lib/rocprof-sys-user/rocprofiler-systems/categories.h new file mode 100644 index 00000000..d559799b --- /dev/null +++ b/source/lib/rocprof-sys-user/rocprofiler-systems/categories.h @@ -0,0 +1,191 @@ +// MIT License +// +// Copyright (c) 2022-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 +// 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. + +#ifndef ROCPROFSYS_CATEGORIES_H_ +#define ROCPROFSYS_CATEGORIES_H_ + +#include +#include + +#if defined(__cplusplus) +extern "C" +{ +#endif + + /// @typedef rocprofsys_category_t + /// @brief Identifier for categories + /// + typedef enum ROCPROFSYS_CATEGORIES + { + // Do not use first enum value + ROCPROFSYS_CATEGORY_NONE = 0, + // arrange these in the order most likely to + // be used since they have to be iterated over + ROCPROFSYS_CATEGORY_PYTHON, + ROCPROFSYS_CATEGORY_USER, + ROCPROFSYS_CATEGORY_HOST, + ROCPROFSYS_CATEGORY_DEVICE_HIP, + ROCPROFSYS_CATEGORY_DEVICE_HSA, + ROCPROFSYS_CATEGORY_ROCM_HIP, + ROCPROFSYS_CATEGORY_ROCM_HSA, + ROCPROFSYS_CATEGORY_ROCM_ROCTX, + ROCPROFSYS_CATEGORY_ROCM_SMI, + ROCPROFSYS_CATEGORY_ROCM_SMI_BUSY, + ROCPROFSYS_CATEGORY_ROCM_SMI_TEMP, + ROCPROFSYS_CATEGORY_ROCM_SMI_POWER, + ROCPROFSYS_CATEGORY_ROCM_SMI_MEMORY_USAGE, + ROCPROFSYS_CATEGORY_ROCM_RCCL, + ROCPROFSYS_CATEGORY_ROCTRACER, + ROCPROFSYS_CATEGORY_ROCPROFILER, + ROCPROFSYS_CATEGORY_SAMPLING, + ROCPROFSYS_CATEGORY_PTHREAD, + ROCPROFSYS_CATEGORY_KOKKOS, + ROCPROFSYS_CATEGORY_MPI, + ROCPROFSYS_CATEGORY_OMPT, + ROCPROFSYS_CATEGORY_PROCESS_SAMPLING, + ROCPROFSYS_CATEGORY_COMM_DATA, + ROCPROFSYS_CATEGORY_CAUSAL, + ROCPROFSYS_CATEGORY_CPU_FREQ, + ROCPROFSYS_CATEGORY_PROCESS_PAGE, + ROCPROFSYS_CATEGORY_PROCESS_VIRT, + ROCPROFSYS_CATEGORY_PROCESS_PEAK, + ROCPROFSYS_CATEGORY_PROCESS_CONTEXT_SWITCH, + ROCPROFSYS_CATEGORY_PROCESS_PAGE_FAULT, + ROCPROFSYS_CATEGORY_PROCESS_USER_MODE_TIME, + ROCPROFSYS_CATEGORY_PROCESS_KERNEL_MODE_TIME, + ROCPROFSYS_CATEGORY_THREAD_WALL_TIME, + ROCPROFSYS_CATEGORY_THREAD_CPU_TIME, + ROCPROFSYS_CATEGORY_THREAD_PAGE_FAULT, + ROCPROFSYS_CATEGORY_THREAD_PEAK_MEMORY, + ROCPROFSYS_CATEGORY_THREAD_CONTEXT_SWITCH, + ROCPROFSYS_CATEGORY_THREAD_HARDWARE_COUNTER, + ROCPROFSYS_CATEGORY_KERNEL_HARDWARE_COUNTER, + ROCPROFSYS_CATEGORY_NUMA, + ROCPROFSYS_CATEGORY_TIMER_SAMPLING, + ROCPROFSYS_CATEGORY_OVERFLOW_SAMPLING, + ROCPROFSYS_CATEGORY_LAST + // the value of below enum is used for iterating + // over the enum in C++ templates. It MUST + // be the last enumerated id + } rocprofsys_category_t; + + /// @enum ROCPROFSYS_ANNOTATION_TYPE + /// @brief Identifier for the data type of the annotation. + /// if the data type is not a pointer, pass the address of + /// data. + /// @typedef ROCPROFSYS_ANNOTATION_TYPE rocprofsys_annotation_type_t + typedef enum ROCPROFSYS_ANNOTATION_TYPE + { + // Do not use first enum value + ROCPROFSYS_VALUE_NONE = 0, + // arrange these in the order most likely to + // be used since they have to be iterated over + ROCPROFSYS_VALUE_CSTR = 1, + ROCPROFSYS_STRING = ROCPROFSYS_VALUE_CSTR, + ROCPROFSYS_VALUE_SIZE_T = 2, + ROCPROFSYS_SIZE_T = ROCPROFSYS_VALUE_SIZE_T, + ROCPROFSYS_VALUE_INT64 = 3, + ROCPROFSYS_INT64 = ROCPROFSYS_VALUE_INT64, + ROCPROFSYS_I64 = ROCPROFSYS_VALUE_INT64, + ROCPROFSYS_VALUE_UINT64 = 4, + ROCPROFSYS_UINT64 = ROCPROFSYS_VALUE_UINT64, + ROCPROFSYS_U64 = ROCPROFSYS_VALUE_UINT64, + ROCPROFSYS_VALUE_FLOAT64 = 5, + ROCPROFSYS_FLOAT64 = ROCPROFSYS_VALUE_FLOAT64, + ROCPROFSYS_FP64 = ROCPROFSYS_VALUE_FLOAT64, + ROCPROFSYS_VALUE_VOID_P = 6, + ROCPROFSYS_VOID_P = ROCPROFSYS_VALUE_VOID_P, + ROCPROFSYS_PTR = ROCPROFSYS_VALUE_VOID_P, + ROCPROFSYS_VALUE_INT32 = 7, + ROCPROFSYS_INT32 = ROCPROFSYS_VALUE_INT32, + ROCPROFSYS_I32 = ROCPROFSYS_VALUE_INT32, + ROCPROFSYS_VALUE_UINT32 = 8, + ROCPROFSYS_UINT32 = ROCPROFSYS_VALUE_UINT32, + ROCPROFSYS_U32 = ROCPROFSYS_VALUE_UINT32, + ROCPROFSYS_VALUE_FLOAT32 = 9, + ROCPROFSYS_FLOAT32 = ROCPROFSYS_VALUE_FLOAT32, + ROCPROFSYS_FP32 = ROCPROFSYS_VALUE_FLOAT32, + ROCPROFSYS_VALUE_INT16 = 10, + ROCPROFSYS_INT16 = ROCPROFSYS_VALUE_INT16, + ROCPROFSYS_I16 = ROCPROFSYS_VALUE_INT16, + ROCPROFSYS_VALUE_UINT16 = 11, + ROCPROFSYS_UINT16 = ROCPROFSYS_VALUE_UINT16, + ROCPROFSYS_U16 = ROCPROFSYS_VALUE_UINT16, + // the value of below enum is used for iterating + // over the enum in C++ templates. It MUST + // be the last enumerated id + ROCPROFSYS_VALUE_LAST + } rocprofsys_annotation_type_t; + + /// @struct rocprofsys_annotation + /// @brief A struct containing annotation data to be included in the perfetto trace. + /// + /// @code{.cpp} + /// #include + /// #include + /// + /// double + /// compute_residual(size_t n, double* data); + /// + /// double + /// compute(size_t n, double* data, size_t nitr, double tolerance) + /// { + /// rocprofsys_annotation_t _annotations[] = { + /// { "iteration", ROCPROFSYS_VALUE_SIZE_T, nullptr }, + /// { "residual", ROCPROFSYS_VALUE_FLOAT64, nullptr }, + /// { "data", ROCPROFSYS_VALUE_PTR, data }, + /// { "size", ROCPROFSYS_VALUE_SIZE_T, &n }, + /// { "tolerance", ROCPROFSYS_VALUE_FLOAT64, &tolerance }, + /// nullptr + /// }; + /// + /// double residual = tolerance; + /// for(size_t i = 0; i < nitr; ++i) + /// { + /// rocprofsys_user_push_annotated_region("compute", &_annotations); + /// + /// residual = compute_residual(n, data); + /// + /// _annotations[0].value = &i; + /// _annotations[1].value = &residual; + /// rocprofsys_user_pop_annotated_region("compute", &_annotations); + /// } + /// + /// return residual; + /// } + /// @endcode + /// @typedef rocprofsys_annotation rocprofsys_annotation_t + typedef struct rocprofsys_annotation + { + /// label for annotation + const char* name; + /// rocprofsys_annotation_type_t + uintptr_t type; + /// data to annotate + void* value; + } rocprofsys_annotation_t; + +#if defined(__cplusplus) +} +#endif + +#endif // ROCPROFSYS_TYPES_H_ diff --git a/source/lib/omnitrace-user/omnitrace/causal.h b/source/lib/rocprof-sys-user/rocprofiler-systems/causal.h similarity index 52% rename from source/lib/omnitrace-user/omnitrace/causal.h rename to source/lib/rocprof-sys-user/rocprofiler-systems/causal.h index b5b1b514..e8a70667 100644 --- a/source/lib/omnitrace-user/omnitrace/causal.h +++ b/source/lib/rocprof-sys-user/rocprofiler-systems/causal.h @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -22,65 +22,66 @@ /** @file causal.h */ -#ifndef OMNITRACE_CAUSAL_H_ -#define OMNITRACE_CAUSAL_H_ +#ifndef ROCPROFSYS_CAUSAL_H_ +#define ROCPROFSYS_CAUSAL_H_ /** - * @defgroup OMNITRACE_CASUAL_GROUP OmniTrace Causal Profiling Defines + * @defgroup ROCPROFSYS_CASUAL_GROUP ROCm Systems Profiler Causal Profiling Defines * * @{ */ -#if !defined(OMNITRACE_CAUSAL_ENABLED) +#if !defined(ROCPROFSYS_CAUSAL_ENABLED) /** Preprocessor switch to enable/disable instrumentation for causal profiling */ -# define OMNITRACE_CAUSAL_ENABLED 1 +# define ROCPROFSYS_CAUSAL_ENABLED 1 #endif -#if OMNITRACE_CAUSAL_ENABLED > 0 -# include +#if ROCPROFSYS_CAUSAL_ENABLED > 0 +# include -# if !defined(OMNITRACE_CAUSAL_LABEL) -/** @cond OMNITRACE_HIDDEN_DEFINES */ -# define OMNITRACE_CAUSAL_STR2(x) # x -# define OMNITRACE_CAUSAL_STR(x) OMNITRACE_CAUSAL_STR2(x) +# if !defined(ROCPROFSYS_CAUSAL_LABEL) +/** @cond ROCPROFSYS_HIDDEN_DEFINES */ +# define ROCPROFSYS_CAUSAL_STR2(x) # x +# define ROCPROFSYS_CAUSAL_STR(x) ROCPROFSYS_CAUSAL_STR2(x) /** @endcond */ /** Default label for a causal progress point */ -# define OMNITRACE_CAUSAL_LABEL __FILE__ ":" OMNITRACE_CAUSAL_STR(__LINE__) +# define ROCPROFSYS_CAUSAL_LABEL __FILE__ ":" ROCPROFSYS_CAUSAL_STR(__LINE__) # endif -# if !defined(OMNITRACE_CAUSAL_PROGRESS) +# if !defined(ROCPROFSYS_CAUSAL_PROGRESS) /** Adds a throughput progress point with label `:` */ -# define OMNITRACE_CAUSAL_PROGRESS omnitrace_user_progress(OMNITRACE_CAUSAL_LABEL); +# define ROCPROFSYS_CAUSAL_PROGRESS \ + rocprofsys_user_progress(ROCPROFSYS_CAUSAL_LABEL); # endif -# if !defined(OMNITRACE_CAUSAL_PROGRESS_NAMED) +# if !defined(ROCPROFSYS_CAUSAL_PROGRESS_NAMED) /** Adds a throughput progress point with user defined label. Each instance should use a * unique label. */ -# define OMNITRACE_CAUSAL_PROGRESS_NAMED(LABEL) omnitrace_user_progress(LABEL); +# define ROCPROFSYS_CAUSAL_PROGRESS_NAMED(LABEL) rocprofsys_user_progress(LABEL); # endif -# if !defined(OMNITRACE_CAUSAL_BEGIN) +# if !defined(ROCPROFSYS_CAUSAL_BEGIN) /** Starts a latency progress point (region of interest) with user defined label. Each * instance should use a unique label. */ -# define OMNITRACE_CAUSAL_BEGIN(LABEL) omnitrace_user_push_region(LABEL); +# define ROCPROFSYS_CAUSAL_BEGIN(LABEL) rocprofsys_user_push_region(LABEL); # endif -# if !defined(OMNITRACE_CAUSAL_END) +# if !defined(ROCPROFSYS_CAUSAL_END) /** End the latency progress point (region of interest) for the matching user defined * label. */ -# define OMNITRACE_CAUSAL_END(LABEL) omnitrace_user_pop_region(LABEL); +# define ROCPROFSYS_CAUSAL_END(LABEL) rocprofsys_user_pop_region(LABEL); # endif #else -# if !defined(OMNITRACE_CAUSAL_PROGRESS) -# define OMNITRACE_CAUSAL_PROGRESS +# if !defined(ROCPROFSYS_CAUSAL_PROGRESS) +# define ROCPROFSYS_CAUSAL_PROGRESS # endif -# if !defined(OMNITRACE_CAUSAL_PROGRESS_NAMED) -# define OMNITRACE_CAUSAL_PROGRESS_NAMED(LABEL) +# if !defined(ROCPROFSYS_CAUSAL_PROGRESS_NAMED) +# define ROCPROFSYS_CAUSAL_PROGRESS_NAMED(LABEL) # endif -# if !defined(OMNITRACE_CAUSAL_BEGIN) -# define OMNITRACE_CAUSAL_BEGIN(LABEL) +# if !defined(ROCPROFSYS_CAUSAL_BEGIN) +# define ROCPROFSYS_CAUSAL_BEGIN(LABEL) # endif -# if !defined(OMNITRACE_CAUSAL_END) -# define OMNITRACE_CAUSAL_END(LABEL) +# if !defined(ROCPROFSYS_CAUSAL_END) +# define ROCPROFSYS_CAUSAL_END(LABEL) # endif #endif /** @} */ -#endif // OMNITRACE_CAUSAL_H_ +#endif // ROCPROFSYS_CAUSAL_H_ diff --git a/source/lib/rocprof-sys-user/rocprofiler-systems/types.h b/source/lib/rocprof-sys-user/rocprofiler-systems/types.h new file mode 100644 index 00000000..ff621574 --- /dev/null +++ b/source/lib/rocprof-sys-user/rocprofiler-systems/types.h @@ -0,0 +1,118 @@ +// MIT License +// +// Copyright (c) 2022-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 +// 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. + +#ifndef ROCPROFSYS_TYPES_H_ +#define ROCPROFSYS_TYPES_H_ + +#include +#include + +#if defined(__cplusplus) +extern "C" +{ +#endif + + struct rocprofsys_annotation; + typedef int (*rocprofsys_trace_func_t)(void); + typedef int (*rocprofsys_region_func_t)(const char*); + typedef int (*rocprofsys_annotated_region_func_t)(const char*, rocprofsys_annotation*, + size_t); + + /// @struct rocprofsys_user_callbacks + /// @brief Struct containing the callbacks for the user API + /// + /// @typedef rocprofsys_user_callbacks rocprofsys_user_callbacks_t + typedef struct rocprofsys_user_callbacks + { + rocprofsys_trace_func_t start_trace; + rocprofsys_trace_func_t stop_trace; + rocprofsys_trace_func_t start_thread_trace; + rocprofsys_trace_func_t stop_thread_trace; + rocprofsys_region_func_t push_region; + rocprofsys_region_func_t pop_region; + rocprofsys_region_func_t progress; + rocprofsys_annotated_region_func_t push_annotated_region; + rocprofsys_annotated_region_func_t pop_annotated_region; + rocprofsys_annotated_region_func_t annotated_progress; + + /// @var start_trace + /// @brief callback for enabling tracing globally + /// @var stop_trace + /// @brief callback for disabling tracing globally + /// @var start_thread_trace + /// @brief callback for enabling tracing on current thread + /// @var stop_thread_trace + /// @brief callback for disabling tracing on current thread + /// @var push_region + /// @brief callback for starting a trace region + /// @var pop_region + /// @brief callback for ending a trace region + /// @var progress + /// @brief callback for marking an causal profiling event + /// @var push_annotated_region + /// @brief callback for starting a trace region + annotations + /// @var pop_annotated_region + /// @brief callback for ending a trace region + annotations + /// @var annotated_progress + /// @brief callback for marking an causal profiling event + annotations + } rocprofsys_user_callbacks_t; + + /// @enum ROCPROFSYS_USER_CONFIGURE_MODE + /// @brief Identifier for errors + /// @typedef ROCPROFSYS_USER_CONFIGURE_MODE rocprofsys_user_configure_mode_t + typedef enum ROCPROFSYS_USER_CONFIGURE_MODE + { + // clang-format off + ROCPROFSYS_USER_UNION_CONFIG = 0, ///< Replace the callbacks in the current config with the non-null callbacks in the provided config + ROCPROFSYS_USER_REPLACE_CONFIG, ///< Replace the entire config even if the provided config has null callbacks + ROCPROFSYS_USER_INTERSECT_CONFIG, ///< Produce a config which is the intersection of the current config and the provided config + ROCPROFSYS_USER_CONFIGURE_MODE_LAST + // clang-format on + } rocprofsys_user_configure_mode_t; + + /// @enum ROCPROFSYS_USER_ERROR + /// @brief Identifier for errors + /// @typedef ROCPROFSYS_USER_ERROR rocprofsys_user_error_t + /// + typedef enum ROCPROFSYS_USER_ERROR + { + ROCPROFSYS_USER_SUCCESS = 0, ///< No error + ROCPROFSYS_USER_ERROR_NO_BINDING, ///< Function pointer was not assigned + ROCPROFSYS_USER_ERROR_BAD_VALUE, ///< Provided value was invalid + ROCPROFSYS_USER_ERROR_INVALID_CATEGORY, ///< Invalid user binding category + ROCPROFSYS_USER_ERROR_INTERNAL, ///< Internal error occurred within + ///< librocprof-sys + ROCPROFSYS_USER_ERROR_LAST + } rocprofsys_user_error_t; + +#if defined(__cplusplus) +} +#endif + +#ifndef ROCPROFSYS_USER_CALLBACKS_INIT +# define ROCPROFSYS_USER_CALLBACKS_INIT \ + { \ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL \ + } +#endif + +#endif // ROCPROFSYS_TYPES_H_ diff --git a/source/lib/rocprof-sys-user/rocprofiler-systems/user.h b/source/lib/rocprof-sys-user/rocprofiler-systems/user.h new file mode 100644 index 00000000..53099d9b --- /dev/null +++ b/source/lib/rocprof-sys-user/rocprofiler-systems/user.h @@ -0,0 +1,159 @@ +// MIT License +// +// Copyright (c) 2022-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 +// 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. + +#ifndef ROCPROFSYS_USER_H_ +#define ROCPROFSYS_USER_H_ + +#if defined(ROCPROFSYS_USER_SOURCE) && (ROCPROFSYS_USER_SOURCE > 0) +# if !defined(ROCPROFSYS_PUBLIC_API) +# define ROCPROFSYS_PUBLIC_API __attribute__((visibility("default"))) +# endif +#else +# if !defined(ROCPROFSYS_PUBLIC_API) +# define ROCPROFSYS_PUBLIC_API +# endif +#endif + +#include "rocprofiler-systems/categories.h" +#include "rocprofiler-systems/types.h" + +#if defined(__cplusplus) +extern "C" +{ +#endif + + /// @fn int rocprofsys_user_start_trace(void) + /// @return rocprofsys_user_error_t value + /// @brief Enable tracing on this thread and all subsequently created threads + extern int rocprofsys_user_start_trace(void) ROCPROFSYS_PUBLIC_API; + + /// @fn int rocprofsys_user_stop_trace(void) + /// @return rocprofsys_user_error_t value + /// @brief Disable tracing on this thread and all subsequently created threads + extern int rocprofsys_user_stop_trace(void) ROCPROFSYS_PUBLIC_API; + + /// @fn int rocprofsys_user_start_thread_trace(void) + /// @return rocprofsys_user_error_t value + /// @brief Enable tracing on this specific thread. Does not apply to subsequently + /// created threads + extern int rocprofsys_user_start_thread_trace(void) ROCPROFSYS_PUBLIC_API; + + /// @fn int rocprofsys_user_stop_thread_trace(void) + /// @return rocprofsys_user_error_t value + /// @brief Disable tracing on this specific thread. Does not apply to subsequently + /// created threads + extern int rocprofsys_user_stop_thread_trace(void) ROCPROFSYS_PUBLIC_API; + + /// @fn int rocprofsys_user_push_region(const char* id) + /// @param id The string identifier for the region + /// @return rocprofsys_user_error_t value + /// @brief Start a user defined region. + extern int rocprofsys_user_push_region(const char*) ROCPROFSYS_PUBLIC_API; + + /// @fn int rocprofsys_user_pop_region(const char* id) + /// @param id The string identifier for the region + /// @return rocprofsys_user_error_t value + /// @brief End a user defined region. In general, user regions should be popped in + /// the inverse order that they were pushed, i.e. first-in, last-out (FILO). The + /// timemory backend was designed to accommodate asynchronous tasking, where FILO may + /// be violated, and will thus compenstate for out-of-order popping, however, the + /// perfetto backend will not; thus, out-of-order popping will result in different + /// results in timemory vs. perfetto. + extern int rocprofsys_user_pop_region(const char*) ROCPROFSYS_PUBLIC_API; + + /// @typedef rocprofsys_annotation rocprofsys_annotation_t + /// + /// @fn int rocprofsys_user_push_annotated_region(const char* id, + /// rocprofsys_annotation_t* annotations, + /// size_t num_annotations) + /// @param id The string identifier for the region + /// @param annotations Array of @ref rocprofsys_annotation instances + /// @param num_annotations Number of annotations + /// @return rocprofsys_user_error_t value + /// @brief Start a user defined region and adds the annotations to the perfetto trace. + extern int rocprofsys_user_push_annotated_region(const char*, + rocprofsys_annotation_t*, + size_t) ROCPROFSYS_PUBLIC_API; + + /// @fn int rocprofsys_user_pop_annotated_region(const char* id, + /// rocprofsys_annotation_t* annotations, + /// size_t num_annotations) + /// @param id The string identifier for the region + /// @param annotations Array of @ref rocprofsys_annotation instances + /// @param num_annotations Number of annotations + /// @return rocprofsys_user_error_t value + /// @brief Stop a user defined region and adds the annotations to the perfetto trace. + extern int rocprofsys_user_pop_annotated_region(const char*, rocprofsys_annotation_t*, + size_t) ROCPROFSYS_PUBLIC_API; + + /// mark causal progress + extern int rocprofsys_user_progress(const char*) ROCPROFSYS_PUBLIC_API; + + /// mark causal progress with annotations + extern int rocprofsys_user_annotated_progress(const char*, rocprofsys_annotation_t*, + size_t) ROCPROFSYS_PUBLIC_API; + + /// @fn int rocprofsys_user_configure(rocprofsys_user_configure_mode_t mode, + /// rocprofsys_user_callbacks_t inp, + /// rocprofsys_user_callbacks_t* out) + /// @param[in] mode Specifies how the new callbacks are merged with the old + /// callbacks + /// @param[in] inp An @ref rocprofsys_user_callbacks instance specifying + /// the callbacks which should be invoked by the user API. + /// @param[out] out Pointer to @ref rocprofsys_user_callbacks which, + /// when non-NULL, will be assigned the former callbacks. + /// @return rocprofsys_user_error_t value + /// @brief Configure the function pointers invoked by the rocprof-sys user API. + /// The initial callbacks are set via the rocprof-sys-dl library when it is loaded but + /// the user can user this feature to turn on/off the user API or customize how the + /// the user callbacks occur. For example, the user could maintain one set of + /// callbacks which discard any annotation data or redirect all unannotated user + /// regions to the annotated user regions with annotations about some global state. + /// Changing the callbacks is thread-safe but not thread-local. + extern int rocprofsys_user_configure( + rocprofsys_user_configure_mode_t mode, rocprofsys_user_callbacks_t inp, + rocprofsys_user_callbacks_t* out) ROCPROFSYS_PUBLIC_API; + + /// @fn int rocprofsys_user_get_callbacks(int category, void** begin_func, void** + /// end_func) + /// @param[in] category An @ref ROCPROFSYS_USER_BINDINGS value + /// @param[out] begin_func The pointer to the function which corresponds to "starting" + /// the category, e.g. rocprofsys_user_start_trace or rocprofsys_user_push_region + /// @param[out] end_func The pointer to the function which corresponds to "ending" the + /// category, e.g. rocprofsys_user_stop_trace or rocprofsys_user_pop_region + /// @return rocprofsys_user_error_t value + /// @brief Get the current function pointers for a given category. The initial values + /// are assigned by rocprof-sys-dl at start up. + extern int rocprofsys_user_get_callbacks(rocprofsys_user_callbacks_t*) + ROCPROFSYS_PUBLIC_API; + + /// @fn const char* rocprofsys_user_error_string(int error_category) + /// @param error_category ROCPROFSYS_USER_ERROR value + /// @return String descripting the error code + /// @brief Return a descriptor for the provided error code + extern const char* rocprofsys_user_error_string(int) ROCPROFSYS_PUBLIC_API; + +#if defined(__cplusplus) +} +#endif + +#endif // ROCPROFSYS_USER_H_ diff --git a/source/lib/omnitrace-user/user.cpp b/source/lib/rocprof-sys-user/user.cpp similarity index 63% rename from source/lib/omnitrace-user/user.cpp rename to source/lib/rocprof-sys-user/user.cpp index 72fa03fe..4c045be0 100644 --- a/source/lib/omnitrace-user/user.cpp +++ b/source/lib/rocprof-sys-user/user.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -20,105 +20,105 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#if !defined(OMNITRACE_USER_SOURCE) -# define OMNITRACE_USER_SOURCE 1 +#if !defined(ROCPROFSYS_USER_SOURCE) +# define ROCPROFSYS_USER_SOURCE 1 #endif -#include "omnitrace/user.h" -#include "omnitrace/categories.h" -#include "omnitrace/types.h" +#include "rocprofiler-systems/user.h" +#include "rocprofiler-systems/categories.h" +#include "rocprofiler-systems/types.h" #include #include #include #include -using annotation_t = omnitrace_annotation_t; +using annotation_t = rocprofsys_annotation_t; namespace { -using trace_func_t = omnitrace_trace_func_t; -using region_func_t = omnitrace_region_func_t; -using annotated_region_func_t = omnitrace_annotated_region_func_t; -using user_callbacks_t = omnitrace_user_callbacks_t; +using trace_func_t = rocprofsys_trace_func_t; +using region_func_t = rocprofsys_region_func_t; +using annotated_region_func_t = rocprofsys_annotated_region_func_t; +using user_callbacks_t = rocprofsys_user_callbacks_t; -user_callbacks_t _callbacks = OMNITRACE_USER_CALLBACKS_INIT; +user_callbacks_t _callbacks = ROCPROFSYS_USER_CALLBACKS_INIT; template inline auto invoke(int (*_func)(Args...), Args... args) { - if(!_func) return OMNITRACE_USER_ERROR_NO_BINDING; - if((*_func)(args...) != 0) return OMNITRACE_USER_ERROR_INTERNAL; - return OMNITRACE_USER_SUCCESS; + if(!_func) return ROCPROFSYS_USER_ERROR_NO_BINDING; + if((*_func)(args...) != 0) return ROCPROFSYS_USER_ERROR_INTERNAL; + return ROCPROFSYS_USER_SUCCESS; } } // namespace extern "C" { - int omnitrace_user_start_trace(void) { return invoke(_callbacks.start_trace); } + int rocprofsys_user_start_trace(void) { return invoke(_callbacks.start_trace); } - int omnitrace_user_stop_trace(void) { return invoke(_callbacks.stop_trace); } + int rocprofsys_user_stop_trace(void) { return invoke(_callbacks.stop_trace); } - int omnitrace_user_start_thread_trace(void) + int rocprofsys_user_start_thread_trace(void) { return invoke(_callbacks.start_thread_trace); } - int omnitrace_user_stop_thread_trace(void) + int rocprofsys_user_stop_thread_trace(void) { return invoke(_callbacks.stop_thread_trace); } - int omnitrace_user_push_region(const char* id) + int rocprofsys_user_push_region(const char* id) { return invoke(_callbacks.push_region, id); } - int omnitrace_user_pop_region(const char* id) + int rocprofsys_user_pop_region(const char* id) { return invoke(_callbacks.pop_region, id); } - int omnitrace_user_progress(const char* id) + int rocprofsys_user_progress(const char* id) { return invoke(_callbacks.progress, id); } - int omnitrace_user_push_annotated_region(const char* id, annotation_t* _annotations, - size_t _annotation_count) + int rocprofsys_user_push_annotated_region(const char* id, annotation_t* _annotations, + size_t _annotation_count) { return invoke(_callbacks.push_annotated_region, id, _annotations, _annotation_count); } - int omnitrace_user_pop_annotated_region(const char* id, annotation_t* _annotations, - size_t _annotation_count) + int rocprofsys_user_pop_annotated_region(const char* id, annotation_t* _annotations, + size_t _annotation_count) { return invoke(_callbacks.pop_annotated_region, id, _annotations, _annotation_count); } - int omnitrace_user_annotated_progress(const char* id, annotation_t* _annotations, - size_t _annotation_count) + int rocprofsys_user_annotated_progress(const char* id, annotation_t* _annotations, + size_t _annotation_count) { return invoke(_callbacks.annotated_progress, id, _annotations, _annotation_count); } - int omnitrace_user_configure(omnitrace_user_configure_mode_t mode, - omnitrace_user_callbacks_t inp, - omnitrace_user_callbacks_t* out) + int rocprofsys_user_configure(rocprofsys_user_configure_mode_t mode, + rocprofsys_user_callbacks_t inp, + rocprofsys_user_callbacks_t* out) { auto _former = _callbacks; switch(mode) { - case OMNITRACE_USER_REPLACE_CONFIG: + case ROCPROFSYS_USER_REPLACE_CONFIG: { _callbacks = inp; break; } - case OMNITRACE_USER_UNION_CONFIG: + case ROCPROFSYS_USER_UNION_CONFIG: { auto _update = [](auto& _lhs, auto _rhs) { if(_rhs) _lhs = _rhs; @@ -140,7 +140,7 @@ extern "C" _callbacks = _v; break; } - case OMNITRACE_USER_INTERSECT_CONFIG: + case ROCPROFSYS_USER_INTERSECT_CONFIG: { auto _update = [](auto& _lhs, auto _rhs) { if(_lhs != _rhs) _lhs = nullptr; @@ -165,26 +165,26 @@ extern "C" default: { if(out) *out = _former; - return OMNITRACE_USER_ERROR_INVALID_CATEGORY; + return ROCPROFSYS_USER_ERROR_INVALID_CATEGORY; } } if(out) *out = _former; - return OMNITRACE_USER_SUCCESS; + return ROCPROFSYS_USER_SUCCESS; } - const char* omnitrace_user_error_string(int error_category) + const char* rocprofsys_user_error_string(int error_category) { switch(error_category) { - case OMNITRACE_USER_SUCCESS: return "Success"; - case OMNITRACE_USER_ERROR_NO_BINDING: return "Function pointer not assigned"; - case OMNITRACE_USER_ERROR_BAD_VALUE: return "Invalid value was provided"; - case OMNITRACE_USER_ERROR_INVALID_CATEGORY: + case ROCPROFSYS_USER_SUCCESS: return "Success"; + case ROCPROFSYS_USER_ERROR_NO_BINDING: return "Function pointer not assigned"; + case ROCPROFSYS_USER_ERROR_BAD_VALUE: return "Invalid value was provided"; + case ROCPROFSYS_USER_ERROR_INVALID_CATEGORY: return "Invalid user binding category"; - case OMNITRACE_USER_ERROR_INTERNAL: - return "An unknown error occurred within omnitrace library"; + case ROCPROFSYS_USER_ERROR_INTERNAL: + return "An unknown error occurred within rocprof-sys library"; default: break; } return "No error"; diff --git a/source/lib/rocprof-sys/CMakeLists.txt b/source/lib/rocprof-sys/CMakeLists.txt new file mode 100644 index 00000000..3be9472e --- /dev/null +++ b/source/lib/rocprof-sys/CMakeLists.txt @@ -0,0 +1,73 @@ +# ------------------------------------------------------------------------------# +# +# rocprofiler-systems object library +# +# ------------------------------------------------------------------------------# + +add_library(rocprofiler-systems-object-library OBJECT) +add_library(rocprofiler-systems::rocprofiler-systems-object-library ALIAS + rocprofiler-systems-object-library) + +target_sources( + rocprofiler-systems-object-library + PRIVATE ${CMAKE_CURRENT_LIST_DIR}/library.cpp ${CMAKE_CURRENT_LIST_DIR}/regions.cpp + ${CMAKE_CURRENT_LIST_DIR}/progress.cpp ${CMAKE_CURRENT_LIST_DIR}/api.cpp + ${CMAKE_CURRENT_LIST_DIR}/timeout.cpp ${CMAKE_CURRENT_LIST_DIR}/api.hpp) + +add_subdirectory(library) + +target_link_libraries(rocprofiler-systems-object-library + PRIVATE rocprofiler-systems::rocprofiler-systems-interface-library) + +# ------------------------------------------------------------------------------# +# +# rocprofiler-systems static library +# +# ------------------------------------------------------------------------------# + +add_library(rocprofiler-systems-static-library STATIC + $) +add_library(rocprofiler-systems::librocprofiler-systems-static ALIAS + rocprofiler-systems-static-library) + +target_link_libraries( + rocprofiler-systems-static-library + PRIVATE rocprofiler-systems::rocprofiler-systems-interface-library + rocprofiler-systems::rocprofiler-systems-core + rocprofiler-systems::rocprofiler-systems-binary) + +set_target_properties(rocprofiler-systems-static-library PROPERTIES OUTPUT_NAME + ${BINARY_NAME_PREFIX}) + +# ------------------------------------------------------------------------------# +# +# rocprofiler-systems shared library +# +# ------------------------------------------------------------------------------# + +add_library(rocprofiler-systems-shared-library SHARED + $) +add_library(rocprofiler-systems::librocprofiler-systems-shared ALIAS + rocprofiler-systems-shared-library) +add_library(rocprofiler-systems::rocprofiler-systems-library ALIAS + rocprofiler-systems-shared-library) + +target_link_libraries( + rocprofiler-systems-shared-library + PRIVATE rocprofiler-systems::rocprofiler-systems-interface-library + rocprofiler-systems::rocprofiler-systems-core + rocprofiler-systems::rocprofiler-systems-binary) + +set_target_properties( + rocprofiler-systems-shared-library + PROPERTIES OUTPUT_NAME ${BINARY_NAME_PREFIX} + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} + INSTALL_RPATH "${ROCPROFSYS_LIB_INSTALL_RPATH}") + +rocprofiler_systems_strip_target(rocprofiler-systems-shared-library) + +install( + TARGETS rocprofiler-systems-shared-library + DESTINATION ${CMAKE_INSTALL_LIBDIR} + OPTIONAL) diff --git a/source/lib/rocprof-sys/api.cpp b/source/lib/rocprof-sys/api.cpp new file mode 100644 index 00000000..50dc48d6 --- /dev/null +++ b/source/lib/rocprof-sys/api.cpp @@ -0,0 +1,169 @@ +// MIT License +// +// Copyright (c) 2022-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 +// 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. + +#include "api.hpp" +#include "core/debug.hpp" + +#include +#include + +extern "C" void +rocprofsys_push_trace(const char* _name) +{ + rocprofsys_push_trace_hidden(_name); +} + +extern "C" void +rocprofsys_pop_trace(const char* _name) +{ + rocprofsys_pop_trace_hidden(_name); +} + +extern "C" int +rocprofsys_push_region(const char* _name) +{ + try + { + rocprofsys_push_region_hidden(_name); + } catch(std::exception& _e) + { + ROCPROFSYS_WARNING_F(1, "Exception caught: %s\n", _e.what()); + return -1; + } + return 0; +} + +extern "C" int +rocprofsys_pop_region(const char* _name) +{ + try + { + rocprofsys_pop_region_hidden(_name); + } catch(std::exception& _e) + { + ROCPROFSYS_WARNING_F(1, "Exception caught: %s\n", _e.what()); + return -1; + } + return 0; +} + +extern "C" int +rocprofsys_push_category_region(rocprofsys_category_t _category, const char* _name, + rocprofsys_annotation_t* _annotations, + size_t _annotation_count) +{ + try + { + rocprofsys_push_category_region_hidden(_category, _name, _annotations, + _annotation_count); + } catch(std::exception& _e) + { + ROCPROFSYS_WARNING_F(1, "Exception caught: %s\n", _e.what()); + return -1; + } + return 0; +} + +extern "C" int +rocprofsys_pop_category_region(rocprofsys_category_t _category, const char* _name, + rocprofsys_annotation_t* _annotations, + size_t _annotation_count) +{ + try + { + rocprofsys_pop_category_region_hidden(_category, _name, _annotations, + _annotation_count); + } catch(std::exception& _e) + { + ROCPROFSYS_WARNING_F(1, "Exception caught: %s\n", _e.what()); + return -1; + } + return 0; +} + +extern "C" void +rocprofsys_progress(const char* _name) +{ + rocprofsys_progress_hidden(_name); +} + +extern "C" void +rocprofsys_annotated_progress(const char* _name, rocprofsys_annotation_t* _annotations, + size_t _annotation_count) +{ + rocprofsys_annotated_progress_hidden(_name, _annotations, _annotation_count); +} + +extern "C" void +rocprofsys_init_library(void) +{ + rocprofsys_init_library_hidden(); +} + +extern "C" void +rocprofsys_init_tooling(void) +{ + rocprofsys_init_tooling_hidden(); +} + +extern "C" void +rocprofsys_init(const char* _mode, bool _rewrite, const char* _arg0) +{ + rocprofsys_init_hidden(_mode, _rewrite, _arg0); +} + +extern "C" void +rocprofsys_finalize(void) +{ + rocprofsys_finalize_hidden(); +} + +extern "C" void +rocprofsys_reset_preload(void) +{ + rocprofsys_reset_preload_hidden(); +} + +extern "C" void +rocprofsys_set_env(const char* env_name, const char* env_val) +{ + rocprofsys_set_env_hidden(env_name, env_val); +} + +extern "C" void +rocprofsys_set_mpi(bool use, bool attached) +{ + rocprofsys_set_mpi_hidden(use, attached); +} + +extern "C" void +rocprofsys_register_source(const char* file, const char* func, size_t line, + size_t address, const char* source) +{ + rocprofsys_register_source_hidden(file, func, line, address, source); +} + +extern "C" void +rocprofsys_register_coverage(const char* file, const char* func, size_t address) +{ + rocprofsys_register_coverage_hidden(file, func, address); +} diff --git a/source/lib/rocprof-sys/api.hpp b/source/lib/rocprof-sys/api.hpp new file mode 100644 index 00000000..d1ed1be5 --- /dev/null +++ b/source/lib/rocprof-sys/api.hpp @@ -0,0 +1,121 @@ +// MIT License +// +// Copyright (c) 2022-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 +// 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. + +#pragma once + +#include "core/defines.hpp" +#include "rocprofiler-systems/categories.h" // in rocprof-sys-user + +#include + +#include + +// forward decl of the API +extern "C" +{ + /// handles configuration logic + void rocprofsys_init_library(void) ROCPROFSYS_PUBLIC_API; + + /// handles configuration logic + void rocprofsys_init_tooling(void) ROCPROFSYS_PUBLIC_API; + + /// starts gotcha wrappers + void rocprofsys_init(const char*, bool, const char*) ROCPROFSYS_PUBLIC_API; + + /// shuts down all tooling and generates output + void rocprofsys_finalize(void) ROCPROFSYS_PUBLIC_API; + + /// remove librocprof-sys from LD_PRELOAD + void rocprofsys_reset_preload(void) ROCPROFSYS_PUBLIC_API; + + /// sets an environment variable + void rocprofsys_set_env(const char*, const char*) ROCPROFSYS_PUBLIC_API; + + /// sets whether MPI should be used + void rocprofsys_set_mpi(bool, bool) ROCPROFSYS_PUBLIC_API; + + /// starts an instrumentation region + void rocprofsys_push_trace(const char*) ROCPROFSYS_PUBLIC_API; + + /// stops an instrumentation region + void rocprofsys_pop_trace(const char*) ROCPROFSYS_PUBLIC_API; + + /// starts an instrumentation region (user-defined) + int rocprofsys_push_region(const char*) ROCPROFSYS_PUBLIC_API; + + /// stops an instrumentation region (user-defined) + int rocprofsys_pop_region(const char*) ROCPROFSYS_PUBLIC_API; + + /// starts an instrumentation region in a user-defined category and (optionally) + /// adds annotations to the perfetto trace. + int rocprofsys_push_category_region(rocprofsys_category_t, const char*, + rocprofsys_annotation_t*, + size_t) ROCPROFSYS_PUBLIC_API; + + /// stops an instrumentation region in a user-defined category and (optionally) + /// adds annotations to the perfetto trace. + int rocprofsys_pop_category_region(rocprofsys_category_t, const char*, + rocprofsys_annotation_t*, + size_t) ROCPROFSYS_PUBLIC_API; + + /// stores source code information + void rocprofsys_register_source(const char* file, const char* func, size_t line, + size_t address, + const char* source) ROCPROFSYS_PUBLIC_API; + + /// increments coverage values + void rocprofsys_register_coverage(const char* file, const char* func, + size_t address) ROCPROFSYS_PUBLIC_API; + + /// mark causal progress + void rocprofsys_progress(const char*) ROCPROFSYS_PUBLIC_API; + + /// mark causal progress with annotations + void rocprofsys_annotated_progress(const char*, rocprofsys_annotation_t*, + size_t) ROCPROFSYS_PUBLIC_API; + + // these are the real implementations for internal calling convention + void rocprofsys_init_library_hidden(void) ROCPROFSYS_HIDDEN_API; + bool rocprofsys_init_tooling_hidden(void) ROCPROFSYS_HIDDEN_API; + void rocprofsys_init_hidden(const char*, bool, const char*) ROCPROFSYS_HIDDEN_API; + void rocprofsys_finalize_hidden(void) ROCPROFSYS_HIDDEN_API; + void rocprofsys_reset_preload_hidden(void) ROCPROFSYS_HIDDEN_API; + void rocprofsys_set_env_hidden(const char*, const char*) ROCPROFSYS_HIDDEN_API; + void rocprofsys_set_mpi_hidden(bool, bool) ROCPROFSYS_HIDDEN_API; + void rocprofsys_push_trace_hidden(const char*) ROCPROFSYS_HIDDEN_API; + void rocprofsys_pop_trace_hidden(const char*) ROCPROFSYS_HIDDEN_API; + void rocprofsys_push_region_hidden(const char*) ROCPROFSYS_HIDDEN_API; + void rocprofsys_pop_region_hidden(const char*) ROCPROFSYS_HIDDEN_API; + void rocprofsys_push_category_region_hidden(rocprofsys_category_t, const char*, + rocprofsys_annotation_t*, + size_t) ROCPROFSYS_HIDDEN_API; + void rocprofsys_pop_category_region_hidden(rocprofsys_category_t, const char*, + rocprofsys_annotation_t*, + size_t) ROCPROFSYS_HIDDEN_API; + void rocprofsys_register_source_hidden(const char*, const char*, size_t, size_t, + const char*) ROCPROFSYS_HIDDEN_API; + void rocprofsys_register_coverage_hidden(const char*, const char*, + size_t) ROCPROFSYS_HIDDEN_API; + void rocprofsys_progress_hidden(const char*) ROCPROFSYS_HIDDEN_API; + void rocprofsys_annotated_progress_hidden(const char*, rocprofsys_annotation_t*, + size_t) ROCPROFSYS_HIDDEN_API; +} diff --git a/source/lib/omnitrace/library.cpp b/source/lib/rocprof-sys/library.cpp similarity index 69% rename from source/lib/omnitrace/library.cpp rename to source/lib/rocprof-sys/library.cpp index 1086989c..e5d10171 100644 --- a/source/lib/omnitrace/library.cpp +++ b/source/lib/rocprof-sys/library.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -58,7 +58,7 @@ #include "library/thread_data.hpp" #include "library/thread_info.hpp" #include "library/tracing.hpp" -#include "omnitrace/categories.h" // in omnitrace-user +#include "rocprofiler-systems/categories.h" // in rocprof-sys-user #include #include @@ -87,18 +87,18 @@ #include #include -using namespace omnitrace; +using namespace rocprofsys; //======================================================================================// -namespace omnitrace +namespace rocprofsys { namespace timeout { void -setup() OMNITRACE_INTERNAL_API; +setup() ROCPROFSYS_INTERNAL_API; } -} // namespace omnitrace +} // namespace rocprofsys namespace { @@ -117,12 +117,12 @@ ensure_initialization(bool _offset, int64_t _glob_n, int64_t _offset_n) if(_tid > 0 && _tid < _peak_num_threads) { const auto& _info = thread_info::get(); - OMNITRACE_BASIC_VERBOSE_F(3, - "thread info: %s, offset: %s, global counter: %li, " - "offset counter: %li, max threads: %li\n", - std::to_string(static_cast(_info)).c_str(), - std::to_string(_offset).c_str(), _glob_n, _offset_n, - _peak_num_threads); + ROCPROFSYS_BASIC_VERBOSE_F(3, + "thread info: %s, offset: %s, global counter: %li, " + "offset counter: %li, max threads: %li\n", + std::to_string(static_cast(_info)).c_str(), + std::to_string(_offset).c_str(), _glob_n, _offset_n, + _peak_num_threads); } return _offset; @@ -131,7 +131,7 @@ ensure_initialization(bool _offset, int64_t _glob_n, int64_t _offset_n) void finalization_handler() { - if(get_state() == State::Active) omnitrace_finalize(); + if(get_state() == State::Active) rocprofsys_finalize(); } auto @@ -147,7 +147,7 @@ ensure_finalization(bool _static_init = false) throw exception("failure adding threading callback"); } - OMNITRACE_CI_BASIC_THROW( + ROCPROFSYS_CI_BASIC_THROW( config::set_signal_handler(nullptr) != &finalization_handler, "Assignment of signal handler failed. signal handler is %s, expected %s\n", as_hex(reinterpret_cast(config::set_signal_handler(nullptr))).c_str(), @@ -157,15 +157,15 @@ ensure_finalization(bool _static_init = false) const auto& _tid = _info->index_data; if(_tid) { - OMNITRACE_CI_THROW(_tid->sequent_value != threading::get_id(), - "Error! internal tid != %li :: %li", threading::get_id(), - _tid->sequent_value); - OMNITRACE_CI_THROW(_tid->system_value != threading::get_sys_tid(), - "Error! system tid != %li :: %li", threading::get_sys_tid(), - _tid->system_value); + ROCPROFSYS_CI_THROW(_tid->sequent_value != threading::get_id(), + "Error! internal tid != %li :: %li", threading::get_id(), + _tid->sequent_value); + ROCPROFSYS_CI_THROW(_tid->system_value != threading::get_sys_tid(), + "Error! system tid != %li :: %li", threading::get_sys_tid(), + _tid->system_value); } - if(common::get_env("OMNITRACE_MONOCHROME", false)) tim::log::monochrome() = true; + if(common::get_env("ROCPROFSYS_MONOCHROME", false)) tim::log::monochrome() = true; timeout::setup(); @@ -176,16 +176,16 @@ ensure_finalization(bool _static_init = false) { tim::get_shared_ptr_pair_callback() = new tim::shared_ptr_pair_callback_t{ [](int64_t _n) { - if(_n == 0) omnitrace_finalize_hidden(); + if(_n == 0) rocprofsys_finalize_hidden(); } }; } if(_static_init) { - OMNITRACE_BASIC_DEBUG_F("\n"); + ROCPROFSYS_BASIC_DEBUG_F("\n"); auto _verbose = get_verbose_env() + ((get_debug_env() || get_debug_init()) ? 16 : 0); - auto _search_paths = JOIN(':', tim::get_env("OMNITRACE_PATH", ""), + auto _search_paths = JOIN(':', tim::get_env("ROCPROFSYS_PATH", ""), tim::get_env("PWD"), ".", tim::get_env("LD_LIBRARY_PATH", ""), tim::get_env("LIBRARY_PATH", ""), @@ -194,12 +194,12 @@ ensure_finalization(bool _static_init = false) } else { - OMNITRACE_DEBUG_F("\n"); + ROCPROFSYS_DEBUG_F("\n"); } if(_timemory_manager) _timemory_manager->set_write_metadata(-1); - return scope::destructor{ []() { omnitrace_finalize_hidden(); } }; + return scope::destructor{ []() { rocprofsys_finalize_hidden(); } }; } template @@ -207,7 +207,7 @@ struct fini_bundle { using data_type = std::tuple; - OMNITRACE_DEFAULT_OBJECT(fini_bundle) + ROCPROFSYS_DEFAULT_OBJECT(fini_bundle) fini_bundle(std::string_view _label) : m_label{ _label } @@ -261,7 +261,7 @@ struct set_env_s // NOLINT } // namespace extern "C" void -omnitrace_set_env_hidden(const char* env_name, const char* env_val) +rocprofsys_set_env_hidden(const char* env_name, const char* env_val) { tim::auto_lock_t _lk{ tim::type_mutex() }; @@ -269,16 +269,17 @@ omnitrace_set_env_hidden(const char* env_name, const char* env_val) bool _success = _set_envs.emplace(env_name).second; // just search env to avoid initializing the settings - OMNITRACE_CONDITIONAL_PRINT_F(get_debug_init() || get_verbose_env() > 2, - "Setting env: %s=%s\n", env_name, env_val); + ROCPROFSYS_CONDITIONAL_PRINT_F(get_debug_init() || get_verbose_env() > 2, + "Setting env: %s=%s\n", env_name, env_val); tim::set_env(env_name, env_val, 0); if(_success && get_state() >= State::Init) { - OMNITRACE_WARNING_F( + ROCPROFSYS_WARNING_F( 0, - "omnitrace_set_env(\"%s\", \"%s\") called after omnitrace was initialized. " + "rocprofsys_set_env(\"%s\", \"%s\") called after rocprof-sys was " + "initialized. " "state = %s. This environment variable will have no effect\n", env_name, env_val, std::to_string(get_state()).c_str()); } @@ -296,7 +297,7 @@ bool _set_mpi_called = false; std::function _preinit_callback = []() { get_preinit_bundle()->start(); }; void -omnitrace_preinit_hidden() +rocprofsys_preinit_hidden() { // run once and discard _preinit_callback(); @@ -305,7 +306,7 @@ omnitrace_preinit_hidden() } // namespace extern "C" void -omnitrace_set_mpi_hidden(bool use, bool attached) +rocprofsys_set_mpi_hidden(bool use, bool attached) { static bool _once = false; static auto _args = std::make_pair(use, attached); @@ -316,16 +317,16 @@ omnitrace_set_mpi_hidden(bool use, bool attached) _once = true; // just search env to avoid initializing the settings - OMNITRACE_CONDITIONAL_PRINT_F(get_debug_init() || get_verbose_env() > 2, - "use: %s, attached: %s\n", (use) ? "y" : "n", - (attached) ? "y" : "n"); + ROCPROFSYS_CONDITIONAL_PRINT_F(get_debug_init() || get_verbose_env() > 2, + "use: %s, attached: %s\n", (use) ? "y" : "n", + (attached) ? "y" : "n"); _set_mpi_called = true; config::is_attached() = attached; if(use && !attached && get_state() == State::PreInit) { - tim::set_env("OMNITRACE_USE_PID", "ON", 1); + tim::set_env("ROCPROFSYS_USE_PID", "ON", 1); } else if(!use) { @@ -334,22 +335,22 @@ omnitrace_set_mpi_hidden(bool use, bool attached) if(get_state() >= State::Init) { - OMNITRACE_WARNING_F( + ROCPROFSYS_WARNING_F( 0, - "omnitrace_set_mpi(use=%s, attached=%s) called after omnitrace was " + "rocprofsys_set_mpi(use=%s, attached=%s) called after rocprof-sys was " "initialized. state = %s. MPI support may not be properly initialized. Use " - "OMNITRACE_USE_MPIP=ON and OMNITRACE_USE_PID=ON to ensure full support\n", + "ROCPROFSYS_USE_MPIP=ON and ROCPROFSYS_USE_PID=ON to ensure full support\n", std::to_string(use).c_str(), std::to_string(attached).c_str(), std::to_string(get_state()).c_str()); } - omnitrace_preinit_hidden(); + rocprofsys_preinit_hidden(); } //======================================================================================// extern "C" void -omnitrace_init_library_hidden() +rocprofsys_init_library_hidden() { auto _tid = threading::get_id(); (void) _tid; @@ -357,22 +358,22 @@ omnitrace_init_library_hidden() static bool _once = false; auto _debug_init = get_debug_init(); - OMNITRACE_CONDITIONAL_BASIC_PRINT_F(_debug_init, "State is %s...\n", - std::to_string(get_state()).c_str()); + ROCPROFSYS_CONDITIONAL_BASIC_PRINT_F(_debug_init, "State is %s...\n", + std::to_string(get_state()).c_str()); - OMNITRACE_CI_THROW(get_state() != State::PreInit, "State is not PreInit :: %s", - std::to_string(get_state()).c_str()); + ROCPROFSYS_CI_THROW(get_state() != State::PreInit, "State is not PreInit :: %s", + std::to_string(get_state()).c_str()); if(get_state() != State::PreInit || get_state() == State::Init || _once) return; _once = true; - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); - OMNITRACE_CONDITIONAL_BASIC_PRINT_F(_debug_init, "State is %s. Setting to %s...\n", - std::to_string(get_state()).c_str(), - std::to_string(State::Init).c_str()); + ROCPROFSYS_CONDITIONAL_BASIC_PRINT_F(_debug_init, "State is %s. Setting to %s...\n", + std::to_string(get_state()).c_str(), + std::to_string(State::Init).c_str()); - OMNITRACE_CONDITIONAL_BASIC_PRINT_F( + ROCPROFSYS_CONDITIONAL_BASIC_PRINT_F( _debug_init, "Calling backtrace once so that the one-time call of malloc in " "glibc's backtrace() occurs...\n"); { @@ -383,84 +384,84 @@ omnitrace_init_library_hidden() set_state(State::Init); - OMNITRACE_CI_THROW(get_state() != State::Init, - "set_state(State::Init) failed. state is %s", - std::to_string(get_state()).c_str()); + ROCPROFSYS_CI_THROW(get_state() != State::Init, + "set_state(State::Init) failed. state is %s", + std::to_string(get_state()).c_str()); - OMNITRACE_CONDITIONAL_BASIC_PRINT_F(_debug_init, "Configuring settings...\n"); + ROCPROFSYS_CONDITIONAL_BASIC_PRINT_F(_debug_init, "Configuring settings...\n"); // configure the settings configure_settings(); auto _debug_value = get_debug(); - if(_debug_init) config::set_setting_value("OMNITRACE_DEBUG", true); + if(_debug_init) config::set_setting_value("ROCPROFSYS_DEBUG", true); scope::destructor _debug_dtor{ [_debug_value, _debug_init]() { - if(_debug_init) config::set_setting_value("OMNITRACE_DEBUG", _debug_value); + if(_debug_init) config::set_setting_value("ROCPROFSYS_DEBUG", _debug_value); } }; tim::trait::runtime_enabled::set(get_use_roctracer()); tim::trait::runtime_enabled::set(get_use_roctracer() && get_use_timemory()); - OMNITRACE_CONDITIONAL_BASIC_PRINT_F(_debug_init, "\n"); + ROCPROFSYS_CONDITIONAL_BASIC_PRINT_F(_debug_init, "\n"); } //======================================================================================// extern "C" bool -omnitrace_init_tooling_hidden() +rocprofsys_init_tooling_hidden() { - if(get_env("OMNITRACE_MONOCHROME", false, false)) tim::log::monochrome() = true; + if(get_env("ROCPROFSYS_MONOCHROME", false, false)) tim::log::monochrome() = true; - if(!tim::get_env("OMNITRACE_INIT_TOOLING", true)) + if(!tim::get_env("ROCPROFSYS_INIT_TOOLING", true)) { - omnitrace_init_library_hidden(); + rocprofsys_init_library_hidden(); return false; } static bool _once = false; static auto _debug_init = get_debug_init(); - OMNITRACE_CONDITIONAL_BASIC_PRINT_F(_debug_init, "State is %s...\n", - std::to_string(get_state()).c_str()); + ROCPROFSYS_CONDITIONAL_BASIC_PRINT_F(_debug_init, "State is %s...\n", + std::to_string(get_state()).c_str()); if(get_state() != State::PreInit || get_state() == State::Init || _once) return false; _once = true; - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); - OMNITRACE_CONDITIONAL_THROW( + ROCPROFSYS_CONDITIONAL_THROW( get_state() == State::Init, - "%s called after omnitrace_init_library() was explicitly called", - OMNITRACE_FUNCTION); + "%s called after rocprofsys_init_library() was explicitly called", + ROCPROFSYS_FUNCTION); - OMNITRACE_CONDITIONAL_BASIC_PRINT_F(get_verbose_env() >= 0, - "Instrumentation mode: %s\n", - std::to_string(config::get_mode()).c_str()); + ROCPROFSYS_CONDITIONAL_BASIC_PRINT_F(get_verbose_env() >= 0, + "Instrumentation mode: %s\n", + std::to_string(config::get_mode()).c_str()); - OMNITRACE_CONDITIONAL_BASIC_PRINT_F(_debug_init, "Printing banner...\n"); + ROCPROFSYS_CONDITIONAL_BASIC_PRINT_F(_debug_init, "Printing banner...\n"); if(get_verbose_env() >= 0) print_banner(); - OMNITRACE_CONDITIONAL_BASIC_PRINT_F(_debug_init, - "Calling omnitrace_init_library()...\n"); + ROCPROFSYS_CONDITIONAL_BASIC_PRINT_F(_debug_init, + "Calling rocprofsys_init_library()...\n"); - omnitrace_init_library_hidden(); + rocprofsys_init_library_hidden(); - OMNITRACE_DEBUG_F("\n"); + ROCPROFSYS_DEBUG_F("\n"); auto _dtor = scope::destructor{ []() { // if set to finalized, don't continue if(get_state() > State::Active) return; if(get_use_process_sampling()) { - OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false); + ROCPROFSYS_SCOPED_SAMPLING_ON_CHILD_THREADS(false); process_sampler::setup(); } if(get_use_causal()) { { - OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false); + ROCPROFSYS_SCOPED_SAMPLING_ON_CHILD_THREADS(false); causal::sampling::setup(); } push_enable_sampling_on_child_threads(get_use_causal()); @@ -469,22 +470,22 @@ omnitrace_init_tooling_hidden() else if(get_use_sampling()) { { - OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false); + ROCPROFSYS_SCOPED_SAMPLING_ON_CHILD_THREADS(false); sampling::setup(); } push_enable_sampling_on_child_threads(get_use_sampling()); sampling::unblock_signals(); } get_main_bundle()->start(); - OMNITRACE_DEBUG_F("State: %s -> State::Active\n", - std::to_string(get_state()).c_str()); + ROCPROFSYS_DEBUG_F("State: %s -> State::Active\n", + std::to_string(get_state()).c_str()); set_state(State::Active); // set to active as very last operation } }; - OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false); + ROCPROFSYS_SCOPED_SAMPLING_ON_CHILD_THREADS(false); // ideally these have already been started - omnitrace_preinit_hidden(); + rocprofsys_preinit_hidden(); // start these gotchas once settings have been initialized if(get_init_bundle()) get_init_bundle()->start(); @@ -494,8 +495,8 @@ omnitrace_init_tooling_hidden() // perfetto initialization if(get_use_perfetto()) { - OMNITRACE_VERBOSE_F(1, "Setting up Perfetto...\n"); - omnitrace::perfetto::setup(); + ROCPROFSYS_VERBOSE_F(1, "Setting up Perfetto...\n"); + rocprofsys::perfetto::setup(); } tasking::setup(); @@ -527,26 +528,26 @@ omnitrace_init_tooling_hidden() } else { - tim::trait::runtime_enabled::set(false); + tim::trait::runtime_enabled::set(false); } } if(get_use_ompt()) { - OMNITRACE_VERBOSE_F(1, "Setting up OMPT...\n"); + ROCPROFSYS_VERBOSE_F(1, "Setting up OMPT...\n"); ompt::setup(); } if(get_use_rcclp()) { - OMNITRACE_VERBOSE_F(1, "Setting up RCCLP...\n"); + ROCPROFSYS_VERBOSE_F(1, "Setting up RCCLP...\n"); rcclp::setup(); } if(get_use_perfetto()) { - OMNITRACE_VERBOSE_F(1, "Starting Perfetto...\n"); - omnitrace::perfetto::start(); + ROCPROFSYS_VERBOSE_F(1, "Starting Perfetto...\n"); + rocprofsys::perfetto::start(); } categories::setup(); @@ -562,7 +563,7 @@ omnitrace_init_tooling_hidden() //======================================================================================// extern "C" void -omnitrace_init_hidden(const char* _mode, bool _is_binary_rewrite, const char* _argv0_c) +rocprofsys_init_hidden(const char* _mode, bool _is_binary_rewrite, const char* _argv0_c) { static int _total_count = 0; static auto _args = std::make_pair(std::string_view{ _mode }, _is_binary_rewrite); @@ -576,13 +577,13 @@ omnitrace_init_hidden(const char* _mode, bool _is_binary_rewrite, const char* _a std::tie(_args.first, _args.second) == std::tie(_mode_sv, _is_binary_rewrite)) return; - OMNITRACE_CONDITIONAL_THROW( + ROCPROFSYS_CONDITIONAL_THROW( _count > 0 && std::tie(_args.first, _args.second) != std::tie(_mode_sv, _is_binary_rewrite), - "\nomnitrace_init(...) called multiple times with different arguments for mode " + "\nrocprofsys_init(...) called multiple times with different arguments for mode " "and/or is_binary_rewrite:" - "\n Invocation #1: omnitrace_init(mode=%-8s, is_binary_rewrite=%-5s, ...)" - "\n Invocation #%i: omnitrace_init(mode=%-8s, is_binary_rewrite=%-5s, ...)", + "\n Invocation #1: rocprofsys_init(mode=%-8s, is_binary_rewrite=%-5s, ...)" + "\n Invocation #%i: rocprofsys_init(mode=%-8s, is_binary_rewrite=%-5s, ...)", _args.first.data(), std::to_string(_args.second).c_str(), _count + 1, _mode, std::to_string(_is_binary_rewrite).c_str()); @@ -595,64 +596,64 @@ omnitrace_init_hidden(const char* _mode, bool _is_binary_rewrite, const char* _a { if(std::string_view{ _mode } != "trace" && std::string_view{ _mode } != "Trace") { - OMNITRACE_WARNING_F( + ROCPROFSYS_WARNING_F( 0, - "omnitrace_init(mode=%s, is_binary_rewrite=%s, argv0=%s) " - "called after omnitrace was initialized. state = %s. Mode-based settings " - "(via -M passed to omnitrace exe) may not be properly " - "configured.\n", + "rocprofsys_init(mode=%s, is_binary_rewrite=%s, argv0=%s) " + "called after rocprof-sys was initialized. state = %s. Mode-based " + "settings (via -M passed to rocprof-sys exe) may not be " + "properly configured.\n", _mode, std::to_string(_is_binary_rewrite).c_str(), _argv0.c_str(), std::to_string(get_state()).c_str()); } } tracing::get_finalization_functions().emplace_back([_argv0_c]() { - OMNITRACE_CI_THROW(get_state() != State::Active, - "Finalizer function for popping main invoked in non-active " - "state :: state = %s\n", - std::to_string(get_state()).c_str()); + ROCPROFSYS_CI_THROW(get_state() != State::Active, + "Finalizer function for popping main invoked in non-active " + "state :: state = %s\n", + std::to_string(get_state()).c_str()); if(get_state() == State::Active) { auto _name = (_argv0_c) ? std::string{ _argv0_c } : config::get_exe_name(); // if main hasn't been popped yet, pop it - OMNITRACE_BASIC_VERBOSE(2, "Running omnitrace_pop_trace(%s)...\n", - _name.c_str()); - omnitrace_pop_trace_hidden(_name.c_str()); + ROCPROFSYS_BASIC_VERBOSE(2, "Running rocprofsys_pop_trace(%s)...\n", + _name.c_str()); + rocprofsys_pop_trace_hidden(_name.c_str()); } }); std::atexit([]() { // if active (not already finalized) then we should finalize - if(get_state() == State::Active) omnitrace_finalize_hidden(); + if(get_state() == State::Active) rocprofsys_finalize_hidden(); }); - OMNITRACE_CONDITIONAL_BASIC_PRINT_F( + ROCPROFSYS_CONDITIONAL_BASIC_PRINT_F( get_debug_env() || get_verbose_env() > 2, "mode: %s | is binary rewrite: %s | command: %s\n", _mode, (_is_binary_rewrite) ? "y" : "n", _argv0.c_str()); - tim::set_env("OMNITRACE_MODE", _mode, 0); + tim::set_env("ROCPROFSYS_MODE", _mode, 0); config::is_binary_rewrite() = _is_binary_rewrite; if(_set_mpi_called) { - omnitrace_preinit_hidden(); + rocprofsys_preinit_hidden(); } } //======================================================================================// extern "C" void -omnitrace_reset_preload_hidden(void) +rocprofsys_reset_preload_hidden(void) { - tim::set_env("OMNITRACE_PRELOAD", "0", 1); + tim::set_env("ROCPROFSYS_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) @@ -665,7 +666,7 @@ omnitrace_reset_preload_hidden(void) //======================================================================================// extern "C" void -omnitrace_finalize_hidden(void) +rocprofsys_finalize_hidden(void) { // disable thread id recycling during finalization threading::recycle_ids() = false; @@ -679,8 +680,8 @@ omnitrace_finalize_hidden(void) // return if not active if(get_state() != State::Active) { - OMNITRACE_BASIC_DEBUG_F("State = %s. Finalization skipped\n", - std::to_string(get_state()).c_str()); + ROCPROFSYS_BASIC_DEBUG_F("State = %s. Finalization skipped\n", + std::to_string(get_state()).c_str()); return; } else if(_is_child) @@ -691,7 +692,7 @@ omnitrace_finalize_hidden(void) } if(get_verbose() >= 0 || get_debug()) fprintf(stderr, "\n"); - OMNITRACE_VERBOSE_F(0, "finalizing...\n"); + ROCPROFSYS_VERBOSE_F(0, "finalizing...\n"); sampling::block_samples(); @@ -700,14 +701,14 @@ omnitrace_finalize_hidden(void) tim::signals::block_signals(get_sampling_signals(), tim::signals::sigmask_scope::process); - omnitrace_reset_preload_hidden(); + rocprofsys_reset_preload_hidden(); // some functions called during finalization may alter the push/pop count so we need // to save them here auto _push_count = tracing::push_count().load(); auto _pop_count = tracing::pop_count().load(); - // e.g. omnitrace_pop_trace("main"); + // e.g. rocprofsys_pop_trace("main"); if(_push_count > _pop_count) { for(auto& itr : tracing::get_finalization_functions()) @@ -719,7 +720,7 @@ omnitrace_finalize_hidden(void) if(get_use_roctracer()) { - OMNITRACE_VERBOSE_F(1, "Flushing roctracer...\n"); + ROCPROFSYS_VERBOSE_F(1, "Flushing roctracer...\n"); // ensure that roctracer is flushed before setting the state to finalized comp::roctracer::flush(); } @@ -735,9 +736,9 @@ omnitrace_finalize_hidden(void) auto _debug_init = get_debug_finalize(); auto _debug_value = get_debug(); - if(_debug_init) config::set_setting_value("OMNITRACE_DEBUG", true); + if(_debug_init) config::set_setting_value("ROCPROFSYS_DEBUG", true); scope::destructor _debug_dtor{ [_debug_value, _debug_init]() { - if(_debug_init) config::set_setting_value("OMNITRACE_DEBUG", _debug_value); + if(_debug_init) config::set_setting_value("ROCPROFSYS_DEBUG", _debug_value); } }; auto& _thread_bundle = thread_data::instance(); @@ -747,25 +748,25 @@ omnitrace_finalize_hidden(void) { if(dmp::rank() == 0) { - OMNITRACE_PRINT_F("\n"); + ROCPROFSYS_PRINT_F("\n"); config::print_settings( - tim::get_env("OMNITRACE_PRINT_ENV", get_debug())); + tim::get_env("ROCPROFSYS_PRINT_ENV", get_debug())); } } - OMNITRACE_VERBOSE_F(1, "omnitrace_push_trace :: called %zux\n", _push_count); - OMNITRACE_VERBOSE_F(1, "omnitrace_pop_trace :: called %zux\n", _pop_count); + ROCPROFSYS_VERBOSE_F(1, "rocprofsys_push_trace :: called %zux\n", _push_count); + ROCPROFSYS_VERBOSE_F(1, "rocprofsys_pop_trace :: called %zux\n", _pop_count); tim::signals::enable_signal_detection({ tim::signals::sys_signal::Interrupt }, [](int) {}); - OMNITRACE_DEBUG_F("Copying over all timemory hash information to main thread...\n"); + ROCPROFSYS_DEBUG_F("Copying over all timemory hash information to main thread...\n"); tracing::copy_timemory_hash_ids(); // stop the main bundle which has stats for run if(get_main_bundle()) { - OMNITRACE_DEBUG_F("Stopping main bundle...\n"); + ROCPROFSYS_DEBUG_F("Stopping main bundle...\n"); get_main_bundle()->stop(); } @@ -774,17 +775,17 @@ omnitrace_finalize_hidden(void) if(get_use_rcclp()) { - OMNITRACE_VERBOSE_F(1, "Shutting down RCCLP...\n"); + ROCPROFSYS_VERBOSE_F(1, "Shutting down RCCLP...\n"); rcclp::shutdown(); } if(get_use_ompt()) { - OMNITRACE_VERBOSE_F(1, "Shutting down OMPT...\n"); + ROCPROFSYS_VERBOSE_F(1, "Shutting down OMPT...\n"); ompt::shutdown(); } - OMNITRACE_DEBUG_F("Stopping and destroying instrumentation bundles...\n"); + ROCPROFSYS_DEBUG_F("Stopping and destroying instrumentation bundles...\n"); for(size_t i = 0; i < thread_info::get_peak_num_threads(); ++i) { if(!instrumentation_bundles::get()) continue; @@ -798,10 +799,11 @@ omnitrace_finalize_hidden(void) ++_pop_count; _lvl = 4; } - OMNITRACE_VERBOSE_F(_lvl, - "Warning! instrumentation bundle on thread %zu (TID=%li) " - "with label '%s' was not stopped.\n", - i, itr->back()->tid(), itr->back()->key().c_str()); + ROCPROFSYS_VERBOSE_F( + _lvl, + "Warning! instrumentation bundle on thread %zu (TID=%li) " + "with label '%s' was not stopped.\n", + i, itr->back()->tid(), itr->back()->key().c_str()); itr->back()->stop(); itr->back()->pop(); @@ -812,7 +814,7 @@ omnitrace_finalize_hidden(void) // stop the main gotcha which shuts down the pthread gotchas if(get_init_bundle()) { - OMNITRACE_DEBUG_F("Stopping main gotcha...\n"); + ROCPROFSYS_DEBUG_F("Stopping main gotcha...\n"); get_init_bundle()->stop(); pthread_gotcha::shutdown(); @@ -822,57 +824,57 @@ omnitrace_finalize_hidden(void) // stop the gotcha bundle if(get_preinit_bundle()) { - OMNITRACE_VERBOSE_F(1, "Shutting down miscellaneous gotchas...\n"); + ROCPROFSYS_VERBOSE_F(1, "Shutting down miscellaneous gotchas...\n"); get_preinit_bundle()->stop(); component::mpi_gotcha::shutdown(); } if(get_use_process_sampling()) { - OMNITRACE_VERBOSE_F(1, "Shutting down background sampler...\n"); + ROCPROFSYS_VERBOSE_F(1, "Shutting down background sampler...\n"); process_sampler::shutdown(); } if(get_use_roctracer()) { - OMNITRACE_VERBOSE_F(1, "Shutting down roctracer...\n"); + ROCPROFSYS_VERBOSE_F(1, "Shutting down roctracer...\n"); // ensure that threads running roctracer callbacks shutdown comp::roctracer::shutdown(); // join extra thread(s) used by roctracer - OMNITRACE_VERBOSE_F(2, "Waiting on roctracer tasks...\n"); + ROCPROFSYS_VERBOSE_F(2, "Waiting on roctracer tasks...\n"); tasking::join(); } if(get_use_rocprofiler()) { - OMNITRACE_VERBOSE_F(1, "Shutting down rocprofiler...\n"); + ROCPROFSYS_VERBOSE_F(1, "Shutting down rocprofiler...\n"); rocprofiler::post_process(); rocprofiler::rocm_cleanup(); } if(get_use_causal()) { - OMNITRACE_VERBOSE_F(1, "Shutting down causal sampling...\n"); + ROCPROFSYS_VERBOSE_F(1, "Shutting down causal sampling...\n"); causal::sampling::shutdown(); } if(get_use_sampling()) { - OMNITRACE_VERBOSE_F(1, "Shutting down sampling...\n"); + ROCPROFSYS_VERBOSE_F(1, "Shutting down sampling...\n"); sampling::shutdown(); } - OMNITRACE_VERBOSE_F(3, "Reporting the process- and thread-level metrics...\n"); + ROCPROFSYS_VERBOSE_F(3, "Reporting the process- and thread-level metrics...\n"); // report the high-level metrics for the process if(get_main_bundle()) { - OMNITRACE_VERBOSE_F(0, "\n"); + ROCPROFSYS_VERBOSE_F(0, "\n"); std::string _msg = JOIN("", *get_main_bundle()); auto _pos = _msg.find(">>> "); if(_pos != std::string::npos) _msg = _msg.substr(_pos + 5); - OMNITRACE_VERBOSE_F(0, "%s\n", _msg.c_str()); - OMNITRACE_DEBUG_F("Resetting main bundle...\n"); + ROCPROFSYS_VERBOSE_F(0, "%s\n", _msg.c_str()); + ROCPROFSYS_DEBUG_F("Resetting main bundle...\n"); get_main_bundle()->reset(); } @@ -891,39 +893,39 @@ omnitrace_finalize_hidden(void) std::string _msg = JOIN("", *itr); auto _pos = _msg.find(">>> "); if(_pos != std::string::npos) _msg = _msg.substr(_pos + 5); - OMNITRACE_VERBOSE_F(_thr_verbose, "%s\n", _msg.c_str()); + ROCPROFSYS_VERBOSE_F(_thr_verbose, "%s\n", _msg.c_str()); } } } - OMNITRACE_VERBOSE_F(0, "\n"); + ROCPROFSYS_VERBOSE_F(0, "\n"); // ensure that all the MT instances are flushed if(get_use_sampling()) { - OMNITRACE_VERBOSE_F(1, "Post-processing the sampling backtraces...\n"); + ROCPROFSYS_VERBOSE_F(1, "Post-processing the sampling backtraces...\n"); sampling::post_process(); } if(get_use_causal()) { - OMNITRACE_VERBOSE_F(1, "Finishing the causal experiments...\n"); + ROCPROFSYS_VERBOSE_F(1, "Finishing the causal experiments...\n"); causal::finish_experimenting(); } if(get_use_process_sampling()) { - OMNITRACE_VERBOSE_F(1, "Post-processing the system-level samples...\n"); + ROCPROFSYS_VERBOSE_F(1, "Post-processing the system-level samples...\n"); process_sampler::post_process(); } // shutdown tasking before timemory is finalized, especially the roctracer thread-pool - OMNITRACE_VERBOSE_F(1, "Shutting down thread-pools...\n"); + ROCPROFSYS_VERBOSE_F(1, "Shutting down thread-pools...\n"); tasking::shutdown(); if(get_use_code_coverage()) { - OMNITRACE_VERBOSE_F(1, "Post-processing the code coverage...\n"); + ROCPROFSYS_VERBOSE_F(1, "Post-processing the code coverage...\n"); coverage::post_process(); } @@ -932,9 +934,9 @@ omnitrace_finalize_hidden(void) bool _perfetto_output_error = false; if(get_use_perfetto()) { - OMNITRACE_VERBOSE_F(0, "Finalizing perfetto...\n"); - omnitrace::perfetto::post_process(_timemory_manager.get(), - _perfetto_output_error); + ROCPROFSYS_VERBOSE_F(0, "Finalizing perfetto...\n"); + rocprofsys::perfetto::post_process(_timemory_manager.get(), + _perfetto_output_error); } if(_timemory_manager && _timemory_manager != nullptr) @@ -952,14 +954,14 @@ omnitrace_finalize_hidden(void) tim::cereal::make_nvp("memory_maps", _maps)); }); - OMNITRACE_VERBOSE_F(1, "Finalizing timemory...\n"); + ROCPROFSYS_VERBOSE_F(1, "Finalizing timemory...\n"); tim::timemory_finalize(_timemory_manager.get()); auto _cfg = settings::compose_filename_config{}; _cfg.use_suffix = config::get_use_pid(); _cfg.suffix = settings::default_process_suffix(); _timemory_manager->write_metadata(settings::get_global_output_prefix(), - "omnitrace", _cfg); + "rocprofsys", _cfg); } categories::shutdown(); @@ -968,15 +970,15 @@ omnitrace_finalize_hidden(void) if(_perfetto_output_error) { - OMNITRACE_THROW("Error opening perfetto output file: %s", - get_perfetto_output_filename().c_str()); + ROCPROFSYS_THROW("Error opening perfetto output file: %s", + get_perfetto_output_filename().c_str()); } - OMNITRACE_CI_THROW( + ROCPROFSYS_CI_THROW( _push_count > _pop_count, "%s", TIMEMORY_JOIN(" ", - "omnitrace_push_trace was called more times than " - "omnitrace_pop_trace. The inverse is fine but the current state " + "rocprofsys_push_trace was called more times than " + "rocprofsys_pop_trace. The inverse is fine but the current state " "means not every measurement was ended :: pushed:", _push_count, "vs. popped:", _pop_count) .c_str()); @@ -984,7 +986,7 @@ omnitrace_finalize_hidden(void) debug::close_file(); config::finalize(); - OMNITRACE_VERBOSE_F(0, "Finalized: %s\n", _finalization.as_string().c_str()); + ROCPROFSYS_VERBOSE_F(0, "Finalized: %s\n", _finalization.as_string().c_str()); tim::signals::enable_signal_detection( { tim::signals::sys_signal::SegFault, tim::signals::sys_signal::Stop }, @@ -997,7 +999,7 @@ namespace { // if static objects are destroyed randomly (relatively uncommon behavior) // this might call finalization before perfetto ends the tracing session -// but static variable in omnitrace_init_tooling_hidden is more likely +// but static variable in rocprofsys_init_tooling_hidden is more likely auto _ensure_finalization = ensure_finalization(true); auto _manager = tim::manager::instance(); auto _settings = tim::settings::shared_instance(); diff --git a/source/lib/omnitrace/library/CMakeLists.txt b/source/lib/rocprof-sys/library/CMakeLists.txt similarity index 71% rename from source/lib/omnitrace/library/CMakeLists.txt rename to source/lib/rocprof-sys/library/CMakeLists.txt index 60f6b4f6..776b06b5 100644 --- a/source/lib/omnitrace/library/CMakeLists.txt +++ b/source/lib/rocprof-sys/library/CMakeLists.txt @@ -32,29 +32,33 @@ set(library_headers ${CMAKE_CURRENT_LIST_DIR}/thread_info.hpp ${CMAKE_CURRENT_LIST_DIR}/tracing.hpp) -target_sources(omnitrace-object-library PRIVATE ${library_sources} ${library_headers}) +target_sources(rocprofiler-systems-object-library PRIVATE ${library_sources} + ${library_headers}) -if(OMNITRACE_USE_ROCTRACER OR OMNITRACE_USE_ROCPROFILER) - target_sources(omnitrace-object-library PRIVATE ${CMAKE_CURRENT_LIST_DIR}/rocm.cpp) +if(ROCPROFSYS_USE_ROCTRACER OR ROCPROFSYS_USE_ROCPROFILER) + target_sources(rocprofiler-systems-object-library + PRIVATE ${CMAKE_CURRENT_LIST_DIR}/rocm.cpp) endif() -if(OMNITRACE_USE_ROCTRACER) - target_sources(omnitrace-object-library +if(ROCPROFSYS_USE_ROCTRACER) + target_sources(rocprofiler-systems-object-library PRIVATE ${CMAKE_CURRENT_LIST_DIR}/roctracer.cpp) endif() -if(OMNITRACE_USE_RCCL) - target_sources(omnitrace-object-library PRIVATE ${CMAKE_CURRENT_LIST_DIR}/rcclp.cpp) +if(ROCPROFSYS_USE_RCCL) + target_sources(rocprofiler-systems-object-library + PRIVATE ${CMAKE_CURRENT_LIST_DIR}/rcclp.cpp) endif() -if(OMNITRACE_USE_ROCPROFILER) +if(ROCPROFSYS_USE_ROCPROFILER) target_sources( - omnitrace-object-library PRIVATE ${CMAKE_CURRENT_LIST_DIR}/rocprofiler.cpp - ${CMAKE_CURRENT_LIST_DIR}/rocprofiler.hpp) + rocprofiler-systems-object-library + PRIVATE ${CMAKE_CURRENT_LIST_DIR}/rocprofiler.cpp + ${CMAKE_CURRENT_LIST_DIR}/rocprofiler.hpp) endif() -if(OMNITRACE_USE_ROCM_SMI) - target_sources(omnitrace-object-library +if(ROCPROFSYS_USE_ROCM_SMI) + target_sources(rocprofiler-systems-object-library PRIVATE ${CMAKE_CURRENT_LIST_DIR}/rocm_smi.cpp) endif() @@ -73,5 +77,5 @@ set(ndebug_sources ${CMAKE_CURRENT_LIST_DIR}/ompt.cpp) set_source_files_properties( - ${ndebug_sources} DIRECTORY ${PROJECT_SOURCE_DIR}/source/lib/omnitrace + ${ndebug_sources} DIRECTORY ${PROJECT_SOURCE_DIR}/source/lib/rocprof-sys PROPERTIES COMPILE_DEFINITIONS NDEBUG COMPILE_OPTIONS "-g0;-O3") diff --git a/source/lib/omnitrace/library/causal/CMakeLists.txt b/source/lib/rocprof-sys/library/causal/CMakeLists.txt similarity index 78% rename from source/lib/omnitrace/library/causal/CMakeLists.txt rename to source/lib/rocprof-sys/library/causal/CMakeLists.txt index d00fe85f..1ff3a01a 100644 --- a/source/lib/omnitrace/library/causal/CMakeLists.txt +++ b/source/lib/rocprof-sys/library/causal/CMakeLists.txt @@ -9,6 +9,7 @@ set(causal_headers ${CMAKE_CURRENT_LIST_DIR}/experiment.hpp ${CMAKE_CURRENT_LIST_DIR}/sample_data.hpp ${CMAKE_CURRENT_LIST_DIR}/sampling.hpp ${CMAKE_CURRENT_LIST_DIR}/selected_entry.hpp) -target_sources(omnitrace-object-library PRIVATE ${causal_sources} ${causal_headers}) +target_sources(rocprofiler-systems-object-library PRIVATE ${causal_sources} + ${causal_headers}) add_subdirectory(components) diff --git a/source/lib/omnitrace/library/causal/components/CMakeLists.txt b/source/lib/rocprof-sys/library/causal/components/CMakeLists.txt similarity index 77% rename from source/lib/omnitrace/library/causal/components/CMakeLists.txt rename to source/lib/rocprof-sys/library/causal/components/CMakeLists.txt index ef71d103..a362ecfb 100644 --- a/source/lib/omnitrace/library/causal/components/CMakeLists.txt +++ b/source/lib/rocprof-sys/library/causal/components/CMakeLists.txt @@ -13,4 +13,5 @@ set(component_headers ${CMAKE_CURRENT_LIST_DIR}/progress_point.hpp ${CMAKE_CURRENT_LIST_DIR}/unblocking_gotcha.hpp) -target_sources(omnitrace-object-library PRIVATE ${component_sources} ${component_headers}) +target_sources(rocprofiler-systems-object-library PRIVATE ${component_sources} + ${component_headers}) diff --git a/source/lib/omnitrace/library/causal/components/backtrace.cpp b/source/lib/rocprof-sys/library/causal/components/backtrace.cpp similarity index 92% rename from source/lib/omnitrace/library/causal/components/backtrace.cpp rename to source/lib/rocprof-sys/library/causal/components/backtrace.cpp index 476d2b99..c402b02d 100644 --- a/source/lib/omnitrace/library/causal/components/backtrace.cpp +++ b/source/lib/rocprof-sys/library/causal/components/backtrace.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -49,7 +49,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace causal { @@ -95,7 +95,7 @@ backtrace::global_init() void overflow::sample(int _sig) { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); static thread_local const auto& _tinfo = thread_info::get(); auto _tid = _tinfo->index_data->sequent_value; @@ -143,8 +143,8 @@ overflow::sample(int _sig) void backtrace::sample(int _sig) { - constexpr size_t depth = ::omnitrace::causal::unwind_depth; - constexpr int64_t ignore_depth = ::omnitrace::causal::unwind_offset; + constexpr size_t depth = ::rocprofsys::causal::unwind_depth; + constexpr int64_t ignore_depth = ::rocprofsys::causal::unwind_offset; constexpr size_t select_init = std::numeric_limits::max(); constexpr size_t select_ival = 5; // interval at which realtime signal contributes @@ -157,14 +157,14 @@ backtrace::sample(int _sig) static thread_local size_t _select_zeros = 0; if((_protect_flag & 1) == 1 || - OMNITRACE_UNLIKELY(!trait::runtime_enabled::get())) + ROCPROFSYS_UNLIKELY(!trait::runtime_enabled::get())) { return; } ++_protect_flag; // on RedHat, the unw_step within get_unw_signal_frame_stack_raw involves a mutex lock - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); m_index = causal::experiment::get_index(); m_stack = get_unw_signal_frame_stack_raw(); @@ -218,7 +218,7 @@ backtrace::sample(int _sig) } else { - OMNITRACE_THROW("unhandled signal %i\n", _sig); + ROCPROFSYS_THROW("unhandled signal %i\n", _sig); } ++_protect_flag; @@ -236,10 +236,10 @@ backtrace::get_period(uint64_t _units) } } // namespace component } // namespace causal -} // namespace omnitrace +} // namespace rocprofsys #define INSTANTIATE_BT_CAUSAL_PERIOD(TYPE) \ - template TYPE omnitrace::causal::component::backtrace::get_period(uint64_t); + template TYPE rocprofsys::causal::component::backtrace::get_period(uint64_t); INSTANTIATE_BT_CAUSAL_PERIOD(float) INSTANTIATE_BT_CAUSAL_PERIOD(double) diff --git a/source/lib/omnitrace/library/causal/components/backtrace.hpp b/source/lib/rocprof-sys/library/causal/components/backtrace.hpp similarity index 96% rename from source/lib/omnitrace/library/causal/components/backtrace.hpp rename to source/lib/rocprof-sys/library/causal/components/backtrace.hpp index 7af3f310..3ece6126 100644 --- a/source/lib/omnitrace/library/causal/components/backtrace.hpp +++ b/source/lib/rocprof-sys/library/causal/components/backtrace.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -40,7 +40,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace causal { @@ -101,4 +101,4 @@ struct backtrace : comp::empty_base }; } // namespace component } // namespace causal -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/causal/components/blocking_gotcha.cpp b/source/lib/rocprof-sys/library/causal/components/blocking_gotcha.cpp similarity index 94% rename from source/lib/omnitrace/library/causal/components/blocking_gotcha.cpp rename to source/lib/rocprof-sys/library/causal/components/blocking_gotcha.cpp index 5c7f7e50..43cb79cf 100644 --- a/source/lib/omnitrace/library/causal/components/blocking_gotcha.cpp +++ b/source/lib/rocprof-sys/library/causal/components/blocking_gotcha.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -60,7 +60,7 @@ #pragma weak sigtimedwait #pragma weak sigsuspend -namespace omnitrace +namespace rocprofsys { namespace causal { @@ -153,7 +153,7 @@ blocking_gotcha::operator()(gotcha_index, Ret (*_func)(Args...), auto _ret = (*_func)(_args...); causal::sampling::unblock_backtrace_samples(); - if(get_thread_state() < ::omnitrace::ThreadState::Internal) + if(get_thread_state() < ::rocprofsys::ThreadState::Internal) { if constexpr(Idx >= always_post_block_min_idx && Idx <= always_post_block_max_idx) { @@ -177,7 +177,7 @@ int blocking_gotcha::operator()(gotcha_index, int (*)(const sigset_t*, int*), const sigset_t* _set_v, int* _sig) const noexcept { - auto _active = get_thread_state() < ::omnitrace::ThreadState::Internal; + auto _active = get_thread_state() < ::rocprofsys::ThreadState::Internal; sigset_t _set = *_set_v; causal_gotcha::remove_signals(&_set); @@ -209,7 +209,7 @@ blocking_gotcha::operator()(gotcha_index, int (*_func)(const sigset_t*, siginfo_t*), const sigset_t* _set_v, siginfo_t* _info_v) const noexcept { - auto _active = get_thread_state() < ::omnitrace::ThreadState::Internal; + auto _active = get_thread_state() < ::rocprofsys::ThreadState::Internal; sigset_t _set = *_set_v; causal_gotcha::remove_signals(&_set); @@ -237,7 +237,7 @@ blocking_gotcha::operator()(gotcha_index, const sigset_t* _set_v, siginfo_t* _info_v, const struct timespec* _wait_v) const noexcept { - auto _active = get_thread_state() < ::omnitrace::ThreadState::Internal; + auto _active = get_thread_state() < ::rocprofsys::ThreadState::Internal; sigset_t _set = *_set_v; causal_gotcha::remove_signals(&_set); @@ -273,6 +273,6 @@ blocking_gotcha::operator()(gotcha_index, int (*)(const sigset_t } } // namespace component } // namespace causal -} // namespace omnitrace +} // namespace rocprofsys -TIMEMORY_INVOKE_PREINIT(omnitrace::causal::component::blocking_gotcha) +TIMEMORY_INVOKE_PREINIT(rocprofsys::causal::component::blocking_gotcha) diff --git a/source/lib/omnitrace/library/causal/components/blocking_gotcha.hpp b/source/lib/rocprof-sys/library/causal/components/blocking_gotcha.hpp similarity index 85% rename from source/lib/omnitrace/library/causal/components/blocking_gotcha.hpp rename to source/lib/rocprof-sys/library/causal/components/blocking_gotcha.hpp index 5d2ede3f..5cdf3756 100644 --- a/source/lib/omnitrace/library/causal/components/blocking_gotcha.hpp +++ b/source/lib/rocprof-sys/library/causal/components/blocking_gotcha.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -34,7 +34,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace causal { @@ -60,7 +60,7 @@ struct blocking_gotcha : comp::base indexes_max = gotcha_capacity - 1, }; - OMNITRACE_DEFAULT_OBJECT(blocking_gotcha) + ROCPROFSYS_DEFAULT_OBJECT(blocking_gotcha) // string id for component static std::string label(); @@ -93,11 +93,11 @@ using blocking_gotcha_t = comp::gotcha, blocking_gotcha>; } // namespace component } // namespace causal -} // namespace omnitrace - -OMNITRACE_DEFINE_CONCRETE_TRAIT(prevent_reentry, causal::component::blocking_gotcha_t, - false_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(static_data, causal::component::blocking_gotcha_t, - false_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(fast_gotcha, causal::component::blocking_gotcha_t, - true_type) +} // namespace rocprofsys + +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(prevent_reentry, causal::component::blocking_gotcha_t, + false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(static_data, causal::component::blocking_gotcha_t, + false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(fast_gotcha, causal::component::blocking_gotcha_t, + true_type) diff --git a/source/lib/omnitrace/library/causal/components/causal_gotcha.cpp b/source/lib/rocprof-sys/library/causal/components/causal_gotcha.cpp similarity index 95% rename from source/lib/omnitrace/library/causal/components/causal_gotcha.cpp rename to source/lib/rocprof-sys/library/causal/components/causal_gotcha.cpp index 911ee124..36cc82f8 100644 --- a/source/lib/omnitrace/library/causal/components/causal_gotcha.cpp +++ b/source/lib/rocprof-sys/library/causal/components/causal_gotcha.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -33,7 +33,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace causal { @@ -113,4 +113,4 @@ causal_gotcha::remove_signals(sigset_t* _set) } } // namespace component } // namespace causal -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/causal/components/causal_gotcha.hpp b/source/lib/rocprof-sys/library/causal/components/causal_gotcha.hpp similarity index 90% rename from source/lib/omnitrace/library/causal/components/causal_gotcha.hpp rename to source/lib/rocprof-sys/library/causal/components/causal_gotcha.hpp index fb4e8d19..485694a3 100644 --- a/source/lib/omnitrace/library/causal/components/causal_gotcha.hpp +++ b/source/lib/rocprof-sys/library/causal/components/causal_gotcha.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -29,7 +29,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace causal { @@ -37,7 +37,7 @@ namespace component { struct causal_gotcha : tim::component::base { - OMNITRACE_DEFAULT_OBJECT(causal_gotcha) + ROCPROFSYS_DEFAULT_OBJECT(causal_gotcha) // string id for component static std::string label() { return "causal_gotcha"; } @@ -53,4 +53,4 @@ struct causal_gotcha : tim::component::base }; } // namespace component } // namespace causal -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/causal/components/progress_point.cpp b/source/lib/rocprof-sys/library/causal/components/progress_point.cpp similarity index 97% rename from source/lib/omnitrace/library/causal/components/progress_point.cpp rename to source/lib/rocprof-sys/library/causal/components/progress_point.cpp index 88440e69..97043a92 100644 --- a/source/lib/omnitrace/library/causal/components/progress_point.cpp +++ b/source/lib/rocprof-sys/library/causal/components/progress_point.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -32,7 +32,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace causal { @@ -201,13 +201,13 @@ progress_point::print(std::ostream& os) const } } // namespace component } // namespace causal -} // namespace omnitrace +} // namespace rocprofsys namespace tim { namespace operation { -namespace causal = omnitrace::causal; +namespace causal = rocprofsys::causal; void push_node::operator()(type& _obj, scope::config, diff --git a/source/lib/omnitrace/library/causal/components/progress_point.hpp b/source/lib/rocprof-sys/library/causal/components/progress_point.hpp similarity index 81% rename from source/lib/omnitrace/library/causal/components/progress_point.hpp rename to source/lib/rocprof-sys/library/causal/components/progress_point.hpp index aa74c1ff..22a9d056 100644 --- a/source/lib/omnitrace/library/causal/components/progress_point.hpp +++ b/source/lib/rocprof-sys/library/causal/components/progress_point.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -36,7 +36,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace causal { @@ -52,7 +52,7 @@ struct progress_point : comp::base static std::string label(); static std::string description(); - OMNITRACE_DEFAULT_OBJECT(progress_point) + ROCPROFSYS_DEFAULT_OBJECT(progress_point) void start(); void stop(); @@ -110,27 +110,27 @@ struct progress_point : comp::base }; } // namespace component } // namespace causal -} // namespace omnitrace +} // namespace rocprofsys -OMNITRACE_DEFINE_CONCRETE_TRAIT(uses_storage, causal::component::progress_point, - false_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(flat_storage, causal::component::progress_point, - true_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(uses_timing_units, causal::component::progress_point, - true_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_timing_category, causal::component::progress_point, - true_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(uses_storage, causal::component::progress_point, + false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(flat_storage, causal::component::progress_point, + true_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(uses_timing_units, causal::component::progress_point, + true_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_timing_category, causal::component::progress_point, + true_type) namespace tim { namespace operation { template <> -struct push_node +struct push_node { - using type = omnitrace::causal::component::progress_point; + using type = rocprofsys::causal::component::progress_point; - OMNITRACE_DEFAULT_OBJECT(push_node) + ROCPROFSYS_DEFAULT_OBJECT(push_node) push_node(type& _obj, scope::config _scope, hash_value_t _hash, int64_t _tid = threading::get_id()) @@ -143,11 +143,11 @@ struct push_node }; template <> -struct pop_node +struct pop_node { - using type = omnitrace::causal::component::progress_point; + using type = rocprofsys::causal::component::progress_point; - OMNITRACE_DEFAULT_OBJECT(pop_node) + ROCPROFSYS_DEFAULT_OBJECT(pop_node) pop_node(type& _obj, int64_t _tid = threading::get_id()) { (*this)(_obj, _tid); } diff --git a/source/lib/omnitrace/library/causal/components/unblocking_gotcha.cpp b/source/lib/rocprof-sys/library/causal/components/unblocking_gotcha.cpp similarity index 92% rename from source/lib/omnitrace/library/causal/components/unblocking_gotcha.cpp rename to source/lib/rocprof-sys/library/causal/components/unblocking_gotcha.cpp index 99c9db37..acc2d292 100644 --- a/source/lib/omnitrace/library/causal/components/unblocking_gotcha.cpp +++ b/source/lib/rocprof-sys/library/causal/components/unblocking_gotcha.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -48,7 +48,7 @@ #pragma weak pthread_barrier_wait #pragma weak kill -namespace omnitrace +namespace rocprofsys { namespace causal { @@ -102,7 +102,7 @@ std::enable_if_t<(Idx < unblocking_gotcha::indexes::kill_idx), Ret> unblocking_gotcha::operator()(gotcha_index, Ret (*_func)(Args...), Args... _args) const noexcept { - auto _active = get_thread_state() < ::omnitrace::ThreadState::Internal; + auto _active = get_thread_state() < ::rocprofsys::ThreadState::Internal; if(_active) { @@ -128,7 +128,7 @@ int unblocking_gotcha::operator()(gotcha_index, int (*_func)(pid_t, int), pid_t _pid, int _sig) const noexcept { - auto _active = get_thread_state() < ::omnitrace::ThreadState::Internal; + auto _active = get_thread_state() < ::rocprofsys::ThreadState::Internal; if(_active && _pid == process::get_id()) causal::delay::process(); @@ -140,6 +140,6 @@ unblocking_gotcha::operator()(gotcha_index, int (*_func)(pid_t, int), } } // namespace component } // namespace causal -} // namespace omnitrace +} // namespace rocprofsys -TIMEMORY_INVOKE_PREINIT(omnitrace::causal::component::unblocking_gotcha) +TIMEMORY_INVOKE_PREINIT(rocprofsys::causal::component::unblocking_gotcha) diff --git a/source/lib/omnitrace/library/causal/components/unblocking_gotcha.hpp b/source/lib/rocprof-sys/library/causal/components/unblocking_gotcha.hpp similarity index 81% rename from source/lib/omnitrace/library/causal/components/unblocking_gotcha.hpp rename to source/lib/rocprof-sys/library/causal/components/unblocking_gotcha.hpp index 547573f6..e21f5caf 100644 --- a/source/lib/omnitrace/library/causal/components/unblocking_gotcha.hpp +++ b/source/lib/rocprof-sys/library/causal/components/unblocking_gotcha.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -33,7 +33,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace causal { @@ -53,7 +53,7 @@ struct unblocking_gotcha : comp::base template using gotcha_index = std::integral_constant; - OMNITRACE_DEFAULT_OBJECT(unblocking_gotcha) + ROCPROFSYS_DEFAULT_OBJECT(unblocking_gotcha) // string id for component static std::string label(); @@ -77,11 +77,11 @@ using unblocking_gotcha_t = comp::gotcha, unblocking_gotcha>; } // namespace component } // namespace causal -} // namespace omnitrace +} // namespace rocprofsys -OMNITRACE_DEFINE_CONCRETE_TRAIT(prevent_reentry, causal::component::unblocking_gotcha_t, - false_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(static_data, causal::component::unblocking_gotcha_t, - false_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(fast_gotcha, causal::component::unblocking_gotcha_t, - true_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(prevent_reentry, causal::component::unblocking_gotcha_t, + false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(static_data, causal::component::unblocking_gotcha_t, + false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(fast_gotcha, causal::component::unblocking_gotcha_t, + true_type) diff --git a/source/lib/omnitrace/library/causal/data.cpp b/source/lib/rocprof-sys/library/causal/data.cpp similarity index 89% rename from source/lib/omnitrace/library/causal/data.cpp rename to source/lib/rocprof-sys/library/causal/data.cpp index b614add6..652e03ea 100644 --- a/source/lib/omnitrace/library/causal/data.cpp +++ b/source/lib/rocprof-sys/library/causal/data.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -67,7 +67,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace causal { @@ -77,7 +77,7 @@ using random_engine_t = std::mt19937_64; using progress_bundles_t = component_bundle_cache; auto speedup_seeds = std::vector{}; -auto speedup_divisions = get_env("OMNITRACE_CAUSAL_SPEEDUP_DIVISIONS", 5); +auto speedup_divisions = get_env("ROCPROFSYS_CAUSAL_SPEEDUP_DIVISIONS", 5); auto speedup_dist = []() { size_t _n = std::max(1, 100 / speedup_divisions); std::vector _v(_n, uint16_t{ 0 }); @@ -87,8 +87,8 @@ auto speedup_dist = []() { size_t _nzero = std::ceil(_v.size() / 4.0); _v.resize(_v.size() + _nzero, 0); std::sort(_v.begin(), _v.end()); - OMNITRACE_CI_THROW(_v.back() > 100, "Error! last value is too large: %i\n", - (int) _v.back()); + ROCPROFSYS_CI_THROW(_v.back() > 100, "Error! last value is too large: %i\n", + (int) _v.back()); return _v; }(); @@ -106,8 +106,9 @@ auto& get_engine() { static auto _seed = []() -> hash_value_t { - auto _seed_v = config::get_setting_value("OMNITRACE_CAUSAL_RANDOM_SEED") - .value_or(0); + auto _seed_v = + config::get_setting_value("ROCPROFSYS_CAUSAL_RANDOM_SEED") + .value_or(0); if(_seed_v == 0) _seed_v = std::random_device{}(); return _seed_v; }(); @@ -132,11 +133,11 @@ get_filters(const std::set& _scopes = { { auto _filters = std::vector{}; - // exclude internal libraries used by omnitrace + // exclude internal libraries used by rocprof-sys if(_scopes.count(sf::BINARY_FILTER) > 0) - _filters.emplace_back( - sf{ sf::FILTER_EXCLUDE, sf::BINARY_FILTER, - "lib(omnitrace[-\\.]|dyninst|tbbmalloc|gotcha\\.|unwind\\.so\\.99)" }); + _filters.emplace_back(sf{ sf::FILTER_EXCLUDE, sf::BINARY_FILTER, + "lib(rocprof-sys[-\\.]|dyninst|" + "tbbmalloc|gotcha\\.|unwind\\.so\\.99)" }); // in function mode, it generally doesn't help to experiment on main function since // telling the user to "make the main function" faster is literally useless since it @@ -147,7 +148,7 @@ get_filters(const std::set& _scopes = { "( main\\(|^main$|^main\\.cold$)" }); bool _use_default_excludes = - config::get_setting_value("OMNITRACE_CAUSAL_FUNCTION_EXCLUDE_DEFAULTS") + config::get_setting_value("ROCPROFSYS_CAUSAL_FUNCTION_EXCLUDE_DEFAULTS") .value_or(true); if(_use_default_excludes && _scopes.count(sf::FUNCTION_FILTER) > 0) @@ -190,14 +191,14 @@ get_filters(const std::set& _scopes = { if(_former_include != _current_include) { if(!_binary_include.empty()) - OMNITRACE_VERBOSE(0, "[causal] binary scope : %s\n", - _binary_include.c_str()); + ROCPROFSYS_VERBOSE(0, "[causal] binary scope : %s\n", + _binary_include.c_str()); if(!_source_include.empty()) - OMNITRACE_VERBOSE(0, "[causal] source scope : %s\n", - _source_include.c_str()); + ROCPROFSYS_VERBOSE(0, "[causal] source scope : %s\n", + _source_include.c_str()); if(!_function_include.empty()) - OMNITRACE_VERBOSE(0, "[causal] function scope : %s\n", - _function_include.c_str()); + ROCPROFSYS_VERBOSE(0, "[causal] function scope : %s\n", + _function_include.c_str()); _former_include = _current_include; } @@ -228,14 +229,14 @@ get_filters(const std::set& _scopes = { if(_former_exclude != _current_exclude) { if(!_binary_exclude.empty()) - OMNITRACE_VERBOSE(0, "[causal] binary exclude : %s\n", - _binary_exclude.c_str()); + ROCPROFSYS_VERBOSE(0, "[causal] binary exclude : %s\n", + _binary_exclude.c_str()); if(!_source_exclude.empty()) - OMNITRACE_VERBOSE(0, "[causal] source exclude : %s\n", - _source_exclude.c_str()); + ROCPROFSYS_VERBOSE(0, "[causal] source exclude : %s\n", + _source_exclude.c_str()); if(!_function_exclude.empty()) - OMNITRACE_VERBOSE(0, "[causal] function exclude : %s\n", - _function_exclude.c_str()); + ROCPROFSYS_VERBOSE(0, "[causal] function exclude : %s\n", + _function_exclude.c_str()); _former_exclude = _current_exclude; } @@ -260,7 +261,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()); @@ -340,7 +341,7 @@ compute_eligible_lines_impl() } } - OMNITRACE_VERBOSE( + ROCPROFSYS_VERBOSE( 0, "[causal] eligible address ranges: %zu, coarse address range: %zu [%s]\n", _eligible_ar.size(), _eligible_ar.range_size(), _eligible_ar.get_coarse_range().as_string().c_str()); @@ -353,7 +354,7 @@ compute_eligible_lines_impl() save_line_info(_cfg, config::get_verbose()); } - OMNITRACE_CONDITIONAL_THROW( + ROCPROFSYS_CONDITIONAL_THROW( _eligible_ar.empty(), "Error! binary analysis (after filters) resulted in zero eligible instruction " "pointer addresses for causal experimentation"); @@ -468,8 +469,8 @@ perform_experiment_impl(std::shared_ptr> _started) // NOLINT const auto& _thr_info = thread_info::init(true); set_thread_state(ThreadState::Disabled); - OMNITRACE_CONDITIONAL_THROW(!_thr_info->is_offset, - "Error! causal profiling thread should be offset"); + ROCPROFSYS_CONDITIONAL_THROW(!_thr_info->is_offset, + "Error! causal profiling thread should be offset"); if(!perform_experiment_impl_completed) perform_experiment_impl_completed = std::make_unique>(); @@ -496,15 +497,15 @@ perform_experiment_impl(std::shared_ptr> _started) // NOLINT std::this_thread::sleep_for(std::chrono::milliseconds{ 10 }); double _delay_sec = - config::get_setting_value("OMNITRACE_CAUSAL_DELAY").value_or(0.0); + config::get_setting_value("ROCPROFSYS_CAUSAL_DELAY").value_or(0.0); double _duration_sec = - config::get_setting_value("OMNITRACE_CAUSAL_DURATION").value_or(0.0); + config::get_setting_value("ROCPROFSYS_CAUSAL_DURATION").value_or(0.0); auto _duration_nsec = duration_nsec_t{ _duration_sec * units::sec }; if(_delay_sec > 0.0) { - OMNITRACE_VERBOSE(1, "[causal] delaying experimentation for %.2f seconds...\n", - _delay_sec); + ROCPROFSYS_VERBOSE(1, "[causal] delaying experimentation for %.2f seconds...\n", + _delay_sec); uint64_t _delay_nsec = _delay_sec * units::sec; std::this_thread::yield(); std::this_thread::sleep_for(std::chrono::nanoseconds{ _delay_nsec }); @@ -518,7 +519,7 @@ perform_experiment_impl(std::shared_ptr> _started) // NOLINT auto _elapsed = clock_type::now() - _start_time; if(_elapsed >= _duration_nsec) { - OMNITRACE_VERBOSE( + ROCPROFSYS_VERBOSE( 1, "[causal] stopping experimentation after %.2f seconds " "(elapsed: %.2f seconds)...\n", @@ -543,7 +544,7 @@ perform_experiment_impl(std::shared_ptr> _started) // NOLINT { if(_impl_no > 0) return; - OMNITRACE_VERBOSE( + ROCPROFSYS_VERBOSE( 0, "[causal] experiment failed to start. Number of PC candidates: %zu\n", eligible_pc_candidates.load()); @@ -620,7 +621,7 @@ perform_experiment_impl(std::shared_ptr> _started) // NOLINT } } - OMNITRACE_PRINT_COLOR(fatal, "causal experiment never started\n"); + ROCPROFSYS_PRINT_COLOR(fatal, "causal experiment never started\n"); std::cerr << std::flush; auto _cerr = tim::log::warning_stream(std::cerr); @@ -634,32 +635,32 @@ 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"; + get_env("ROCPROFSYS_LAUNCHER", "", false) == + "rocprof-sys-causal"; if(!(get_causal_end_to_end() && _omni_causal_launcher)) { - OMNITRACE_CONDITIONAL_THROW(_impl_no == 0, - "causal experiment never started"); + ROCPROFSYS_CONDITIONAL_THROW(_impl_no == 0, + "causal experiment never started"); } return; } else { - OMNITRACE_VERBOSE( + ROCPROFSYS_VERBOSE( 1, "[causal] experiment failed to start. Number of PC candidates: %zu\n", eligible_pc_candidates.load()); } } - OMNITRACE_VERBOSE(3, - "[causal] experiment started. Number of PC candidates: %zu\n", - eligible_pc_candidates.load()); + ROCPROFSYS_VERBOSE(3, + "[causal] experiment started. Number of PC candidates: %zu\n", + eligible_pc_candidates.load()); reset_sample_selection(); @@ -724,7 +725,7 @@ save_line_info(const settings::compose_filename_config& _cfg, int _verbose) } else { - throw ::omnitrace::exception("Error opening " + ofname); + throw ::rocprofsys::exception("Error opening " + ofname); } }; @@ -784,14 +785,14 @@ reset_sample_selection() selected_entry sample_selection(size_t _nitr, size_t _wait_ns) { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); auto _select_address = [&](auto& _address_vec) { // this isn't necessary bc of check before calling this lambda but // kept because of size() - 1 in distribution range - if(OMNITRACE_UNLIKELY(_address_vec.empty())) + if(ROCPROFSYS_UNLIKELY(_address_vec.empty())) { - OMNITRACE_WARNING(0, "no addresses for sample selection...\n"); + ROCPROFSYS_WARNING(0, "no addresses for sample selection...\n"); return selected_entry{}; } @@ -821,8 +822,8 @@ sample_selection(size_t _nitr, size_t _wait_ns) if(linfo.empty()) continue; // debugging for continuous integration - if(OMNITRACE_UNLIKELY(config::get_is_continuous_integration() || - config::get_debug())) + if(ROCPROFSYS_UNLIKELY(config::get_is_continuous_integration() || + config::get_debug())) { auto _location = (_dl_info.location) @@ -831,9 +832,9 @@ sample_selection(size_t _nitr, size_t _wait_ns) : std::string{}; for(const auto& itr : linfo) { - if(OMNITRACE_UNLIKELY(config::get_debug())) + if(ROCPROFSYS_UNLIKELY(config::get_debug())) { - OMNITRACE_WARNING( + ROCPROFSYS_WARNING( 0, "[%s][%s][%s][%s] %s [%s:%i][%s][%zu]\n", as_hex(_lookup_addr).c_str(), as_hex(_addr).c_str(), as_hex(_sym_addr).c_str(), @@ -864,9 +865,9 @@ sample_selection(size_t _nitr, size_t _wait_ns) auto _addresses = std::deque{}; for(auto& aitr : latest_eligible_pc) { - if(OMNITRACE_UNLIKELY(!aitr)) + if(ROCPROFSYS_UNLIKELY(!aitr)) { - OMNITRACE_WARNING(0, "invalid atomic pc...\n"); + ROCPROFSYS_WARNING(0, "invalid atomic pc...\n"); continue; } @@ -937,7 +938,7 @@ get_line_info(uintptr_t _addr, bool _include_discarded) for(const auto& itr : ditr.get_debug_line_info(_filters)) { if(!_ipaddr.contains(itr.ipaddr())) - OMNITRACE_THROW( + ROCPROFSYS_THROW( "Error! debug line info ipaddr (%s) is not contained in " "symbol ipaddr (%s)", as_hex(itr.ipaddr()).c_str(), as_hex(_ipaddr).c_str()); @@ -973,7 +974,7 @@ push_progress_point(std::string_view _name) auto _hash = tim::add_hash_id(_name); auto& _data = get_progress_bundles(); - if(OMNITRACE_LIKELY(_data != nullptr)) + if(ROCPROFSYS_LIKELY(_data != nullptr)) { auto* _bundle = _data->construct(_hash); _bundle->push(); @@ -987,7 +988,7 @@ pop_progress_point(std::string_view _name) if(config::get_causal_end_to_end()) return; auto& _data = get_progress_bundles(); - if(OMNITRACE_UNLIKELY(!_data || _data->empty())) return; + if(ROCPROFSYS_UNLIKELY(!_data || _data->empty())) return; if(_name.empty()) { auto* itr = _data->back(); @@ -1021,7 +1022,7 @@ mark_progress_point(std::string_view _name, bool _force) auto _hash = tim::add_hash_id(_name); auto& _data = get_progress_bundles(); - if(OMNITRACE_LIKELY(_data != nullptr)) + if(ROCPROFSYS_LIKELY(_data != nullptr)) { auto* _bundle = _data->construct(_hash); _bundle->push(); @@ -1051,7 +1052,7 @@ sample_virtual_speedup() void start_experimenting() { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); auto _user_speedup_dist = config::get_causal_fixed_speedup(); if(!_user_speedup_dist.empty()) @@ -1059,10 +1060,10 @@ start_experimenting() speedup_dist.clear(); for(auto itr : _user_speedup_dist) { - OMNITRACE_CONDITIONAL_ABORT_F(itr > 100, - "Virtual speedups must be in range [0, 100]. " - "Invalid virtual speedup: %lu\n", - itr); + ROCPROFSYS_CONDITIONAL_ABORT_F(itr > 100, + "Virtual speedups must be in range [0, 100]. " + "Invalid virtual speedup: %lu\n", + itr); speedup_dist.emplace_back(static_cast(itr)); } } @@ -1072,7 +1073,7 @@ start_experimenting() if(get_state() < State::Finalized) { - OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false); + ROCPROFSYS_SCOPED_SAMPLING_ON_CHILD_THREADS(false); auto _promise = std::make_shared>(); std::thread{ perform_experiment_impl, _promise }.detach(); _promise->get_future().wait_for(std::chrono::seconds{ 2 }); @@ -1092,4 +1093,4 @@ finish_experimenting() experiment::save_experiments(); } } // namespace causal -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/causal/data.hpp b/source/lib/rocprof-sys/library/causal/data.hpp similarity index 94% rename from source/lib/omnitrace/library/causal/data.hpp rename to source/lib/rocprof-sys/library/causal/data.hpp index 3648fcdd..48422dce 100644 --- a/source/lib/omnitrace/library/causal/data.hpp +++ b/source/lib/rocprof-sys/library/causal/data.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -40,7 +40,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace causal { @@ -77,4 +77,4 @@ start_experimenting(); void finish_experimenting(); } // namespace causal -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/causal/delay.cpp b/source/lib/rocprof-sys/library/causal/delay.cpp similarity index 89% rename from source/lib/omnitrace/library/causal/delay.cpp rename to source/lib/rocprof-sys/library/causal/delay.cpp index 0568a9bb..8e401d8d 100644 --- a/source/lib/omnitrace/library/causal/delay.cpp +++ b/source/lib/rocprof-sys/library/causal/delay.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -40,7 +40,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace causal { @@ -72,16 +72,16 @@ compute_sleep_for_overhead() int64_t _end = tracing::now(); if(i < _nwarm) continue; auto _diff = (_end - _beg); - OMNITRACE_CONDITIONAL_THROW( + ROCPROFSYS_CONDITIONAL_THROW( _diff < _val, "Error! sleep_for(%zu) [nanoseconds] >= %zu", _val, _diff); _stats += (_diff - _val); } - OMNITRACE_BASIC_VERBOSE(2, - "[causal] overhead of std::this_thread::sleep_for(...) " - "invocation = %6.3f usec +/- %e\n", - _stats.get_mean() / units::usec, - _stats.get_stddev() / units::usec); + ROCPROFSYS_BASIC_VERBOSE(2, + "[causal] overhead of std::this_thread::sleep_for(...) " + "invocation = %6.3f usec +/- %e\n", + _stats.get_mean() / units::usec, + _stats.get_stddev() / units::usec); tim::manager::instance()->add_metadata([_stats](auto& ar) { ar(tim::cereal::make_nvp("causal thread sleep overhead [nsec]", _stats)); @@ -113,12 +113,12 @@ delay::process() } else if(get_global() > get_local()) { - ::omnitrace::causal::sampling::pause(); + ::rocprofsys::causal::sampling::pause(); auto _beg = tracing::now(); std::this_thread::sleep_for( std::chrono::nanoseconds{ get_global() - get_local() }); get_local() += (tracing::now() - _beg); - ::omnitrace::causal::sampling::resume(); + ::rocprofsys::causal::sampling::resume(); } } else @@ -188,4 +188,4 @@ delay::compute_total_delay(uint64_t _baseline) return get_global().load() - _baseline; } } // namespace causal -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/causal/delay.hpp b/source/lib/rocprof-sys/library/causal/delay.hpp similarity index 92% rename from source/lib/omnitrace/library/causal/delay.hpp rename to source/lib/rocprof-sys/library/causal/delay.hpp index 6f57d633..ffc865e5 100644 --- a/source/lib/omnitrace/library/causal/delay.hpp +++ b/source/lib/rocprof-sys/library/causal/delay.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -34,7 +34,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace causal { @@ -42,7 +42,7 @@ struct delay : comp::empty_base { using value_type = void; - OMNITRACE_DEFAULT_OBJECT(delay) + ROCPROFSYS_DEFAULT_OBJECT(delay) static void setup(); static void process(); @@ -58,4 +58,4 @@ struct delay : comp::empty_base static uint64_t compute_total_delay(uint64_t); }; } // namespace causal -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/causal/experiment.cpp b/source/lib/rocprof-sys/library/causal/experiment.cpp similarity index 92% rename from source/lib/omnitrace/library/causal/experiment.cpp rename to source/lib/rocprof-sys/library/causal/experiment.cpp index 0ab6c388..4f877a7f 100644 --- a/source/lib/omnitrace/library/causal/experiment.cpp +++ b/source/lib/rocprof-sys/library/causal/experiment.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -54,13 +54,13 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace causal { namespace { -using backtrace_causal = omnitrace::causal::component::backtrace; +using backtrace_causal = rocprofsys::causal::component::backtrace; namespace cereal = ::tim::cereal; auto current_experiment_value = experiment{}; @@ -70,7 +70,7 @@ auto experiment_history = std::vector{}; int64_t global_scaling = 1; int64_t global_scaling_increments = 0; bool use_exp_speedup_scaling = - get_env("OMNITRACE_CAUSAL_SCALE_EXPERIMENT_TIME_BY_SPEEDUP", false); + get_env("ROCPROFSYS_CAUSAL_SCALE_EXPERIMENT_TIME_BY_SPEEDUP", false); } // namespace experiment::sample::sample(const base_type& _b, uint64_t _c) @@ -251,8 +251,8 @@ experiment::start() init_progress = component::progress_point::get_progress_points(); start_time = tracing::now(); - OMNITRACE_VERBOSE(0, "Starting causal experiment #%-3u: %s\n", index, - as_string().c_str()); + ROCPROFSYS_VERBOSE(0, "Starting causal experiment #%-3u: %s\n", index, + as_string().c_str()); if(get_state() < State::Finalized) { @@ -320,32 +320,33 @@ experiment::stop() if(_lowv <= 3 && (_mean < 5 || _medi < 5)) { - OMNITRACE_VERBOSE(2, - "[progress points] increasing experiment time :: low: %6.3f, " - "high: %6.3f, mean: %6.3f, median: %zi\n", - _lowv, _high, _mean, _medi); + ROCPROFSYS_VERBOSE(2, + "[progress points] increasing experiment time :: low: %6.3f, " + "high: %6.3f, mean: %6.3f, median: %zi\n", + _lowv, _high, _mean, _medi); global_scaling *= 2; ++global_scaling_increments; // keep track of how many successive increments have // been performed } else if(_mean > 10 && _lowv >= 8 && global_scaling > 1) { - OMNITRACE_VERBOSE(2, - "[progress points] decreasing experiment time :: low: %6.3f, " - "high: %6.3f, mean: %6.3f, median: %zi\n", - _lowv, _high, _mean, _medi); + ROCPROFSYS_VERBOSE(2, + "[progress points] decreasing experiment time :: low: %6.3f, " + "high: %6.3f, mean: %6.3f, median: %zi\n", + _lowv, _high, _mean, _medi); global_scaling /= 2; global_scaling_increments = 0; } - if(OMNITRACE_UNLIKELY(global_scaling_increments >= 5)) + if(ROCPROFSYS_UNLIKELY(global_scaling_increments >= 5)) { - OMNITRACE_WARNING( + ROCPROFSYS_WARNING( 0, "Warning! causal experimentation hasn't seen at least 5 progress points " "in the last %li experiments. Progress points are necessary for measuring " "the effect of the virtual speed-up. Please visit " - "https://rocm.github.io/omnitrace/ for documentation on progress " + "https://rocm.docs.amd.com/projects/rocprofiler-systems/en/latest/ for " + "documentation on progress " "points and how to add them\n", global_scaling_increments); } @@ -521,8 +522,8 @@ experiment::save_experiments(std::string _fname_base, const filename_config_t& _ } } - OMNITRACE_VERBOSE_F(1, "Processing line info for %zu sampled addresses...\n", - _total_samples.size()); + ROCPROFSYS_VERBOSE_F(1, "Processing line info for %zu sampled addresses...\n", + _total_samples.size()); for(const auto& itr : _total_samples) { @@ -537,7 +538,7 @@ experiment::save_experiments(std::string _fname_base, const filename_config_t& _ } bool _causal_output_reset = - config::get_setting_value("OMNITRACE_CAUSAL_FILE_RESET").value_or(false); + config::get_setting_value("ROCPROFSYS_CAUSAL_FILE_RESET").value_or(false); { auto _saved_experiments = (_causal_output_reset) @@ -549,7 +550,7 @@ experiment::save_experiments(std::string _fname_base, const filename_config_t& _ auto ar = tim::policy::output_archive::get(oss); - ar->setNextName("omnitrace"); + ar->setNextName("rocprofsys"); ar->startNode(); ar->setNextName("causal"); ar->startNode(); @@ -569,8 +570,8 @@ experiment::save_experiments(std::string _fname_base, const filename_config_t& _ } else { - OMNITRACE_THROW("Error opening causal experiments output file: %s", - _fname.c_str()); + ROCPROFSYS_THROW("Error opening causal experiments output file: %s", + _fname.c_str()); } } @@ -612,7 +613,7 @@ experiment::save_experiments(std::string _fname_base, const filename_config_t& _ ? _line_info.func : join(":", _line_info.file, _line_info.line); - OMNITRACE_CONDITIONAL_THROW( + ROCPROFSYS_CONDITIONAL_THROW( _name.empty(), "Error! causal experiment selection has no name: address=%s, file=%s, " "line=%u, func=%s", @@ -665,8 +666,8 @@ experiment::save_experiments(std::string _fname_base, const filename_config_t& _ } else { - OMNITRACE_THROW("Error opening causal experiments output file: %s", - _fname.c_str()); + ROCPROFSYS_THROW("Error opening causal experiments output file: %s", + _fname.c_str()); } } @@ -691,7 +692,7 @@ experiment::load_experiments(std::string _fname, const filename_config_t& _cfg, { auto ar = tim::policy::input_archive::get(ifs); - ar->setNextName("omnitrace"); + ar->setNextName("rocprofsys"); ar->startNode(); ar->setNextName("causal"); ar->startNode(); @@ -703,12 +704,12 @@ experiment::load_experiments(std::string _fname, const filename_config_t& _cfg, { if(_throw_on_error) { - OMNITRACE_THROW("Error opening causal experiments input file: %s", - _fname.c_str()); + ROCPROFSYS_THROW("Error opening causal experiments input file: %s", + _fname.c_str()); } } return _data; } } // namespace causal -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/causal/experiment.hpp b/source/lib/rocprof-sys/library/causal/experiment.hpp similarity index 97% rename from source/lib/omnitrace/library/causal/experiment.hpp rename to source/lib/rocprof-sys/library/causal/experiment.hpp index 7663acd5..d1174eeb 100644 --- a/source/lib/omnitrace/library/causal/experiment.hpp +++ b/source/lib/rocprof-sys/library/causal/experiment.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -43,7 +43,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace causal { @@ -92,7 +92,7 @@ struct experiment static std::string description(); static const std::atomic& get_current_experiment(); - OMNITRACE_DEFAULT_OBJECT(experiment) + ROCPROFSYS_DEFAULT_OBJECT(experiment) bool start(); bool wait() const; // returns false if interrupted @@ -145,4 +145,4 @@ struct experiment progress_points_t fini_progress = {}; /// progress points at end }; } // namespace causal -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/causal/fwd.hpp b/source/lib/rocprof-sys/library/causal/fwd.hpp similarity index 90% rename from source/lib/omnitrace/library/causal/fwd.hpp rename to source/lib/rocprof-sys/library/causal/fwd.hpp index 31db91a9..e5c680b5 100644 --- a/source/lib/omnitrace/library/causal/fwd.hpp +++ b/source/lib/rocprof-sys/library/causal/fwd.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -36,13 +36,13 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace unwind = ::tim::unwind; namespace causal { -static constexpr size_t unwind_depth = OMNITRACE_MAX_UNWIND_DEPTH; +static constexpr size_t unwind_depth = ROCPROFSYS_MAX_UNWIND_DEPTH; static constexpr size_t unwind_offset = 0; using unwind_stack_t = unwind::stack; using unwind_addr_t = container::static_vector; @@ -50,4 +50,4 @@ using hash_value_t = tim::hash_value_t; struct selected_entry; } // namespace causal -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/causal/sample_data.cpp b/source/lib/rocprof-sys/library/causal/sample_data.cpp similarity index 94% rename from source/lib/omnitrace/library/causal/sample_data.cpp rename to source/lib/rocprof-sys/library/causal/sample_data.cpp index 4cde1233..0e64c10d 100644 --- a/source/lib/omnitrace/library/causal/sample_data.cpp +++ b/source/lib/rocprof-sys/library/causal/sample_data.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -27,7 +27,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace causal { @@ -81,4 +81,4 @@ add_samples(uint32_t _index, const std::map& _v) add_sample(_index, itr.first, itr.second); } } // namespace causal -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/causal/sample_data.hpp b/source/lib/rocprof-sys/library/causal/sample_data.hpp similarity index 94% rename from source/lib/omnitrace/library/causal/sample_data.hpp rename to source/lib/rocprof-sys/library/causal/sample_data.hpp index a6898e8a..d4302f57 100644 --- a/source/lib/omnitrace/library/causal/sample_data.hpp +++ b/source/lib/rocprof-sys/library/causal/sample_data.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -28,7 +28,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace causal { @@ -64,4 +64,4 @@ void add_sample(uint32_t, uintptr_t, uint64_t = 1); void add_samples(uint32_t, const std::map&); } // namespace causal -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/causal/sampling.cpp b/source/lib/rocprof-sys/library/causal/sampling.cpp similarity index 89% rename from source/lib/omnitrace/library/causal/sampling.cpp rename to source/lib/rocprof-sys/library/causal/sampling.cpp index ba2864af..7bdfc60b 100644 --- a/source/lib/omnitrace/library/causal/sampling.cpp +++ b/source/lib/rocprof-sys/library/causal/sampling.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -58,7 +58,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace causal { @@ -75,18 +75,18 @@ using backtrace_enabled = trait::runtime_enabled; using overflow_enabled = trait::runtime_enabled; } // namespace sampling } // namespace causal -} // namespace omnitrace +} // namespace rocprofsys -OMNITRACE_DEFINE_CONCRETE_TRAIT(prevent_reentry, causal::sampling::causal_sampler_t, - std::true_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(prevent_reentry, causal::sampling::causal_sampler_t, + std::true_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(provide_backtrace, causal::sampling::causal_sampler_t, - std::false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(provide_backtrace, causal::sampling::causal_sampler_t, + std::false_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(buffer_size, causal::sampling::causal_sampler_t, - TIMEMORY_ESC(std::integral_constant)) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(buffer_size, causal::sampling::causal_sampler_t, + TIMEMORY_ESC(std::integral_constant)) -namespace omnitrace +namespace rocprofsys { namespace causal { @@ -219,11 +219,11 @@ configure(bool _setup, int64_t _tid) auto& _running = get_causal_sampler_running(_tid); auto& _signal_types = get_causal_sampler_signals(_tid); - OMNITRACE_CONDITIONAL_THROW(get_use_sampling(), - "Internal error! configuring causal profiling not " - "permitted when sampling is enabled"); + ROCPROFSYS_CONDITIONAL_THROW(get_use_sampling(), + "Internal error! configuring causal profiling not " + "permitted when sampling is enabled"); - OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false); + ROCPROFSYS_SCOPED_SAMPLING_ON_CHILD_THREADS(false); if(_setup && _signal_types.empty()) _signal_types = get_sampling_signals(_tid); @@ -258,7 +258,7 @@ configure(bool _setup, int64_t _tid) assert(_tid == threading::get_id()); auto _causal_alloc = get_causal_sampler_allocator(true); - _causal = std::make_unique(_causal_alloc, "omnitrace", _tid, + _causal = std::make_unique(_causal_alloc, "rocprofsys", _tid, _verbose); auto _activate_perf_backend = [&_causal, &_causal_perf, &_info, &_tid]() { @@ -287,7 +287,7 @@ configure(bool _setup, int64_t _tid) return perf::get_instance(_idx)->stop(); }, _tid, threading::get_sys_tid() }); - if(_tid == 0) OMNITRACE_VERBOSE(1, "causal profiling backend: perf\n"); + if(_tid == 0) ROCPROFSYS_VERBOSE(1, "causal profiling backend: perf\n"); } return _open_error; @@ -301,7 +301,7 @@ configure(bool _setup, int64_t _tid) _causal->configure(timer{ get_sampling_realtime_signal(), CLOCK_REALTIME, SIGEV_THREAD_ID, 1000.0, 1.0e-6, _tid, threading::get_sys_tid() }); - if(_tid == 0) OMNITRACE_VERBOSE(1, "causal profiling backend: timer\n"); + if(_tid == 0) ROCPROFSYS_VERBOSE(1, "causal profiling backend: timer\n"); return true; }; @@ -314,13 +314,13 @@ configure(bool _setup, int64_t _tid) if(get_causal_backend() == CausalBackend::Perf) { auto _perf_error = _activate_perf_backend(); - OMNITRACE_REQUIRE(!_perf_error) + ROCPROFSYS_REQUIRE(!_perf_error) << "perf backend for causal profiling failed to activate: " << *_perf_error << "\n"; } else if(get_causal_backend() == CausalBackend::Timer) { - OMNITRACE_REQUIRE(_activate_timer_backend()) + ROCPROFSYS_REQUIRE(_activate_timer_backend()) << "timer backend for causal profiling failed to activate\n"; } else if(get_causal_backend() == CausalBackend::Auto) @@ -328,19 +328,19 @@ configure(bool _setup, int64_t _tid) auto _perf_error = _activate_perf_backend(); if(!_perf_error) { - config::set_setting_value("OMNITRACE_CAUSAL_BACKEND", + config::set_setting_value("ROCPROFSYS_CAUSAL_BACKEND", std::string{ "perf" }); } else { - OMNITRACE_WARNING_F( + ROCPROFSYS_WARNING_F( 0, "perf backend for causal profiling failed to activate: %s\n", _perf_error->c_str()); - OMNITRACE_REQUIRE(_activate_timer_backend()) + ROCPROFSYS_REQUIRE(_activate_timer_backend()) << "timer backend for causal profiling failed to activate\n"; - config::set_setting_value("OMNITRACE_CAUSAL_BACKEND", + config::set_setting_value("ROCPROFSYS_CAUSAL_BACKEND", std::string{ "timer" }); } } @@ -354,7 +354,7 @@ configure(bool _setup, int64_t _tid) } else if(!_setup && _causal && _running) { - OMNITRACE_DEBUG("Destroying causal sampler for thread %lu...\n", _tid); + ROCPROFSYS_DEBUG("Destroying causal sampler for thread %lu...\n", _tid); _running = false; if(_tid == threading::get_id() && !_signal_types.empty()) @@ -367,7 +367,7 @@ configure(bool _setup, int64_t _tid) // this propagates to all threads _causal->ignore(_signal_types); - for(int64_t i = 1; i < OMNITRACE_MAX_THREADS; ++i) + for(int64_t i = 1; i < ROCPROFSYS_MAX_THREADS; ++i) { if(get_causal_sampler(i)) { @@ -390,7 +390,7 @@ configure(bool _setup, int64_t _tid) _causal_perf.reset(); } - OMNITRACE_DEBUG("Causal sampler destroyed for thread %lu\n", _tid); + ROCPROFSYS_DEBUG("Causal sampler destroyed for thread %lu\n", _tid); } return _signal_types; @@ -489,7 +489,7 @@ void pause(ScopeT) bool _paused_v = *_process_paused; if(!_paused_v) { - for(auto i = 0; i < OMNITRACE_MAX_THREADS; ++i) + for(auto i = 0; i < ROCPROFSYS_MAX_THREADS; ++i) { auto& _causal_perf = perf::get_instance(i); if(_causal_perf) _causal_perf->stop(); @@ -528,7 +528,7 @@ void resume(ScopeT) bool _paused_v = *_process_paused; if(_paused_v) { - for(auto i = 0; i < OMNITRACE_MAX_THREADS; ++i) + for(auto i = 0; i < ROCPROFSYS_MAX_THREADS; ++i) { auto& _causal_perf = perf::get_instance(i); if(_causal_perf) _causal_perf->start(); @@ -551,7 +551,7 @@ block_signals(std::set _signals) if(_signals.empty()) _signals = get_signal_types(threading::get_id()); if(_signals.empty()) return; - ::omnitrace::sampling::block_signals(_signals); + ::rocprofsys::sampling::block_signals(_signals); } void @@ -560,16 +560,16 @@ unblock_signals(std::set _signals) if(_signals.empty()) _signals = get_signal_types(threading::get_id()); if(_signals.empty()) return; - ::omnitrace::sampling::unblock_signals(_signals); + ::rocprofsys::sampling::unblock_signals(_signals); } void post_process() { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); - OMNITRACE_VERBOSE(2 || get_debug_sampling(), - "Stopping causal sampling components...\n"); + ROCPROFSYS_VERBOSE(2 || get_debug_sampling(), + "Stopping causal sampling components...\n"); block_samples(); @@ -644,4 +644,4 @@ post_process_causal(int64_t, const std::vector& _data) } // namespace } // namespace sampling } // namespace causal -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/causal/sampling.hpp b/source/lib/rocprof-sys/library/causal/sampling.hpp similarity index 93% rename from source/lib/omnitrace/library/causal/sampling.hpp rename to source/lib/rocprof-sys/library/causal/sampling.hpp index c02a6c05..08298b53 100644 --- a/source/lib/omnitrace/library/causal/sampling.hpp +++ b/source/lib/rocprof-sys/library/causal/sampling.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -30,7 +30,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace causal { @@ -71,4 +71,4 @@ void post_process(); } // namespace sampling } // namespace causal -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/causal/selected_entry.cpp b/source/lib/rocprof-sys/library/causal/selected_entry.cpp similarity index 93% rename from source/lib/omnitrace/library/causal/selected_entry.cpp rename to source/lib/rocprof-sys/library/causal/selected_entry.cpp index 0fd68c11..ca9f2536 100644 --- a/source/lib/omnitrace/library/causal/selected_entry.cpp +++ b/source/lib/rocprof-sys/library/causal/selected_entry.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -24,7 +24,7 @@ #include "core/common.hpp" #include "core/timemory.hpp" -namespace omnitrace +namespace rocprofsys { namespace causal { @@ -49,4 +49,4 @@ template void selected_entry::serialize( cereal::PrettyJSONOutputArchive&, const unsigned int); } // namespace causal -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/causal/selected_entry.hpp b/source/lib/rocprof-sys/library/causal/selected_entry.hpp similarity index 92% rename from source/lib/omnitrace/library/causal/selected_entry.hpp rename to source/lib/rocprof-sys/library/causal/selected_entry.hpp index bc45ffbc..7a5d7040 100644 --- a/source/lib/omnitrace/library/causal/selected_entry.hpp +++ b/source/lib/rocprof-sys/library/causal/selected_entry.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -41,13 +41,13 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace causal { struct selected_entry { - OMNITRACE_DEFAULT_OBJECT(selected_entry) + ROCPROFSYS_DEFAULT_OBJECT(selected_entry) uintptr_t address = 0x0; uintptr_t symbol_address = 0x0; @@ -67,4 +67,4 @@ selected_entry::contains(uintptr_t _v) const symbol.ipaddr().contains(_v)); } } // namespace causal -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/components/CMakeLists.txt b/source/lib/rocprof-sys/library/components/CMakeLists.txt similarity index 78% rename from source/lib/omnitrace/library/components/CMakeLists.txt rename to source/lib/rocprof-sys/library/components/CMakeLists.txt index efc8915e..16f841a8 100644 --- a/source/lib/omnitrace/library/components/CMakeLists.txt +++ b/source/lib/rocprof-sys/library/components/CMakeLists.txt @@ -34,18 +34,20 @@ set(component_headers ${CMAKE_CURRENT_LIST_DIR}/pthread_create_gotcha.hpp ${CMAKE_CURRENT_LIST_DIR}/pthread_mutex_gotcha.hpp) -target_sources(omnitrace-object-library PRIVATE ${component_sources} ${component_headers}) +target_sources(rocprofiler-systems-object-library PRIVATE ${component_sources} + ${component_headers}) -if(OMNITRACE_USE_ROCPROFILER) - target_sources(omnitrace-object-library +if(ROCPROFSYS_USE_ROCPROFILER) + target_sources(rocprofiler-systems-object-library PRIVATE ${CMAKE_CURRENT_LIST_DIR}/rocprofiler.cpp) endif() -if(OMNITRACE_USE_ROCTRACER) - target_sources(omnitrace-object-library +if(ROCPROFSYS_USE_ROCTRACER) + target_sources(rocprofiler-systems-object-library PRIVATE ${CMAKE_CURRENT_LIST_DIR}/roctracer.cpp) endif() -if(OMNITRACE_USE_RCCL) - target_sources(omnitrace-object-library PRIVATE ${CMAKE_CURRENT_LIST_DIR}/rcclp.cpp) +if(ROCPROFSYS_USE_RCCL) + target_sources(rocprofiler-systems-object-library + PRIVATE ${CMAKE_CURRENT_LIST_DIR}/rcclp.cpp) endif() diff --git a/source/lib/omnitrace/library/components/backtrace.cpp b/source/lib/rocprof-sys/library/components/backtrace.cpp similarity index 92% rename from source/lib/omnitrace/library/components/backtrace.cpp rename to source/lib/rocprof-sys/library/components/backtrace.cpp index 172f18a0..e4cc4686 100644 --- a/source/lib/omnitrace/library/components/backtrace.cpp +++ b/source/lib/rocprof-sys/library/components/backtrace.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -70,7 +70,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace component { @@ -119,12 +119,12 @@ backtrace::filter_and_patch(const std::vector& _data) bool _keep_internal = get_sampling_keep_internal(); const auto _npos = std::string::npos; if(_keep_internal) return 1; - if(_lbl.find("omnitrace_main") != _npos) return 0; - if(_lbl.find("omnitrace::") != _npos) return 0; + if(_lbl.find("rocprofsys_main") != _npos) return 0; + if(_lbl.find("rocprofsys::") != _npos) return 0; if(_lbl.find("tim::openmp::") != _npos) return -1; if(_lbl.find("tim::") != _npos) return 0; if(_lbl.find("DYNINST_") != _npos) return 0; - if(_lbl.find("omnitrace_") != _npos) return -1; + if(_lbl.find("rocprofsys_") != _npos) return -1; if(_lbl.find("rocprofiler_") != _npos) return -1; if(_lbl.find("roctracer_") != _npos) return -1; if(_lbl.find("perfetto::") != _npos) return -1; @@ -134,7 +134,7 @@ backtrace::filter_and_patch(const std::vector& _data) }; static bool _keep_suffix = tim::get_env( - "OMNITRACE_SAMPLING_KEEP_DYNINST_SUFFIX", get_debug_sampling()); + "ROCPROFSYS_SAMPLING_KEEP_DYNINST_SUFFIX", get_debug_sampling()); // in the dyninst binary rewrite runtime, instrumented functions are appended with // "_dyninst", i.e. "main" will show up as "main_dyninst" in the backtrace. @@ -189,7 +189,7 @@ backtrace::sample(int signo) if(signo == get_sampling_overflow_signal()) return; // on RedHat, the unw_step within get_unw_stack involves a mutex lock - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); using namespace tim::backtrace; constexpr bool with_signal_frame = false; @@ -204,6 +204,6 @@ backtrace::sample(int signo) m_data = get_unw_stack(); } } // namespace component -} // namespace omnitrace +} // namespace rocprofsys -TIMEMORY_INITIALIZE_STORAGE(omnitrace::component::backtrace) +TIMEMORY_INITIALIZE_STORAGE(rocprofsys::component::backtrace) diff --git a/source/lib/omnitrace/library/components/backtrace.hpp b/source/lib/rocprof-sys/library/components/backtrace.hpp similarity index 93% rename from source/lib/omnitrace/library/components/backtrace.hpp rename to source/lib/rocprof-sys/library/components/backtrace.hpp index 33a13169..8479774f 100644 --- a/source/lib/omnitrace/library/components/backtrace.hpp +++ b/source/lib/rocprof-sys/library/components/backtrace.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -41,13 +41,13 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace component { struct backtrace : comp::empty_base { - static constexpr size_t stack_depth = OMNITRACE_MAX_UNWIND_DEPTH; + static constexpr size_t stack_depth = ROCPROFSYS_MAX_UNWIND_DEPTH; using data_t = tim::unwind::stack; using cache_type = typename data_t::cache_type; @@ -83,4 +83,4 @@ struct backtrace : comp::empty_base data_t m_data = {}; }; } // namespace component -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/components/backtrace_metrics.cpp b/source/lib/rocprof-sys/library/components/backtrace_metrics.cpp similarity index 92% rename from source/lib/omnitrace/library/components/backtrace_metrics.cpp rename to source/lib/rocprof-sys/library/components/backtrace_metrics.cpp index f3706ac1..8d26acac 100644 --- a/source/lib/omnitrace/library/components/backtrace_metrics.cpp +++ b/source/lib/rocprof-sys/library/components/backtrace_metrics.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -73,10 +73,10 @@ namespace tracing { -using namespace ::omnitrace::tracing; +using namespace ::rocprofsys::tracing; } -namespace omnitrace +namespace rocprofsys { namespace component { @@ -210,7 +210,7 @@ backtrace_metrics::configure(bool _setup, int64_t _tid) if constexpr(tim::trait::is_available::value) { perfetto_counter_track::init(); - OMNITRACE_DEBUG("HW COUNTER: starting...\n"); + ROCPROFSYS_DEBUG("HW COUNTER: starting...\n"); if(get_papi_vector(_tid)) { get_papi_vector(_tid)->start(); @@ -220,7 +220,7 @@ backtrace_metrics::configure(bool _setup, int64_t _tid) } else if(!_setup && _is_running) { - OMNITRACE_DEBUG("Destroying sampler for thread %lu...\n", _tid); + ROCPROFSYS_DEBUG("Destroying sampler for thread %lu...\n", _tid); *_running = false; if constexpr(tim::trait::is_available::value) @@ -228,10 +228,10 @@ backtrace_metrics::configure(bool _setup, int64_t _tid) if(_tid == threading::get_id()) { if(get_papi_vector(_tid)) get_papi_vector(_tid)->stop(); - OMNITRACE_DEBUG("HW COUNTER: stopped...\n"); + ROCPROFSYS_DEBUG("HW COUNTER: stopped...\n"); } } - OMNITRACE_DEBUG("Sampler destroyed for thread %lu\n", _tid); + ROCPROFSYS_DEBUG("Sampler destroyed for thread %lu\n", _tid); } } @@ -265,7 +265,7 @@ backtrace_metrics::init_perfetto(int64_t _tid, valid_array_t _valid) { std::string _desc = tim::papi::get_event_info(itr).short_descr; if(_desc.empty()) _desc = itr; - OMNITRACE_CI_THROW(_desc.empty(), "Empty description for %s\n", itr.c_str()); + ROCPROFSYS_CI_THROW(_desc.empty(), "Empty description for %s\n", itr.c_str()); perfetto_counter_track::emplace( _tid, JOIN(' ', "Thread", _desc, _tid_name, "(S)")); } @@ -278,7 +278,7 @@ backtrace_metrics::fini_perfetto(int64_t _tid, valid_array_t _valid) auto _hw_cnt_labels = *get_papi_labels(_tid); const auto& _thread_info = thread_info::get(_tid, SequentTID); - OMNITRACE_CI_THROW(!_thread_info, "Error! missing thread info for tid=%li\n", _tid); + ROCPROFSYS_CI_THROW(!_thread_info, "Error! missing thread info for tid=%li\n", _tid); if(!_thread_info) return; uint64_t _ts = _thread_info->get_stop(); @@ -407,18 +407,18 @@ backtrace_metrics::post_process_perfetto(int64_t _tid, uint64_t _ts) const } } } // namespace component -} // namespace omnitrace +} // namespace rocprofsys -OMNITRACE_INSTANTIATE_EXTERN_COMPONENT( - TIMEMORY_ESC(data_tracker), true, +ROCPROFSYS_INSTANTIATE_EXTERN_COMPONENT( + TIMEMORY_ESC(data_tracker), true, double) -OMNITRACE_INSTANTIATE_EXTERN_COMPONENT( - TIMEMORY_ESC(data_tracker), true, +ROCPROFSYS_INSTANTIATE_EXTERN_COMPONENT( + TIMEMORY_ESC(data_tracker), true, double) -OMNITRACE_INSTANTIATE_EXTERN_COMPONENT( - TIMEMORY_ESC(data_tracker), true, +ROCPROFSYS_INSTANTIATE_EXTERN_COMPONENT( + TIMEMORY_ESC(data_tracker), true, double) -TIMEMORY_INITIALIZE_STORAGE(omnitrace::component::backtrace_metrics) +TIMEMORY_INITIALIZE_STORAGE(rocprofsys::component::backtrace_metrics) diff --git a/source/lib/omnitrace/library/components/backtrace_metrics.hpp b/source/lib/rocprof-sys/library/components/backtrace_metrics.hpp similarity index 89% rename from source/lib/omnitrace/library/components/backtrace_metrics.hpp rename to source/lib/rocprof-sys/library/components/backtrace_metrics.hpp index 512007a4..928da0c0 100644 --- a/source/lib/omnitrace/library/components/backtrace_metrics.hpp +++ b/source/lib/rocprof-sys/library/components/backtrace_metrics.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -44,7 +44,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { template using type_list = ::tim::type_list; @@ -162,23 +162,23 @@ bool backtrace_metrics::operator()(Tp) const return (*this)(type_list{}); } } // namespace component -} // namespace omnitrace +} // namespace rocprofsys -#if !defined(OMNITRACE_EXTERN_COMPONENTS) || \ - (defined(OMNITRACE_EXTERN_COMPONENTS) && OMNITRACE_EXTERN_COMPONENTS > 0) +#if !defined(ROCPROFSYS_EXTERN_COMPONENTS) || \ + (defined(ROCPROFSYS_EXTERN_COMPONENTS) && ROCPROFSYS_EXTERN_COMPONENTS > 0) # include -OMNITRACE_DECLARE_EXTERN_COMPONENT( - TIMEMORY_ESC(data_tracker), true, +ROCPROFSYS_DECLARE_EXTERN_COMPONENT( + TIMEMORY_ESC(data_tracker), true, double) -OMNITRACE_DECLARE_EXTERN_COMPONENT( - TIMEMORY_ESC(data_tracker), true, +ROCPROFSYS_DECLARE_EXTERN_COMPONENT( + TIMEMORY_ESC(data_tracker), true, double) -OMNITRACE_DECLARE_EXTERN_COMPONENT( - TIMEMORY_ESC(data_tracker), true, +ROCPROFSYS_DECLARE_EXTERN_COMPONENT( + TIMEMORY_ESC(data_tracker), true, double) #endif diff --git a/source/lib/omnitrace/library/components/backtrace_timestamp.cpp b/source/lib/rocprof-sys/library/components/backtrace_timestamp.cpp similarity index 89% rename from source/lib/omnitrace/library/components/backtrace_timestamp.cpp rename to source/lib/rocprof-sys/library/components/backtrace_timestamp.cpp index 691298be..ca6ac229 100644 --- a/source/lib/omnitrace/library/components/backtrace_timestamp.cpp +++ b/source/lib/rocprof-sys/library/components/backtrace_timestamp.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -25,7 +25,7 @@ #include -namespace omnitrace +namespace rocprofsys { namespace component { @@ -49,6 +49,6 @@ backtrace_timestamp::sample(int) m_real = tim::get_clock_real_now(); } } // namespace component -} // namespace omnitrace +} // namespace rocprofsys -TIMEMORY_INITIALIZE_STORAGE(omnitrace::component::backtrace_timestamp) +TIMEMORY_INITIALIZE_STORAGE(rocprofsys::component::backtrace_timestamp) diff --git a/source/lib/omnitrace/library/components/backtrace_timestamp.hpp b/source/lib/rocprof-sys/library/components/backtrace_timestamp.hpp similarity index 95% rename from source/lib/omnitrace/library/components/backtrace_timestamp.hpp rename to source/lib/rocprof-sys/library/components/backtrace_timestamp.hpp index 69fa2af5..08d839d0 100644 --- a/source/lib/omnitrace/library/components/backtrace_timestamp.hpp +++ b/source/lib/rocprof-sys/library/components/backtrace_timestamp.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -34,7 +34,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace component { @@ -69,4 +69,4 @@ struct backtrace_timestamp : comp::empty_base uint64_t m_real = 0; }; } // namespace component -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/components/callchain.cpp b/source/lib/rocprof-sys/library/components/callchain.cpp similarity index 96% rename from source/lib/omnitrace/library/components/callchain.cpp rename to source/lib/rocprof-sys/library/components/callchain.cpp index 33bbf227..af6d6f6b 100644 --- a/source/lib/omnitrace/library/components/callchain.cpp +++ b/source/lib/rocprof-sys/library/components/callchain.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -74,7 +74,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace component { @@ -178,7 +178,7 @@ callchain::sample(int signo) if(signo != get_sampling_overflow_signal()) return; // on RedHat, the unw_step within get_unw_stack involves a mutex lock - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); static thread_local const auto& _tinfo = thread_info::get(); auto _tid = _tinfo->index_data->sequent_value; @@ -214,6 +214,6 @@ callchain::sample(int signo) _perf_event->start(); } } // namespace component -} // namespace omnitrace +} // namespace rocprofsys -TIMEMORY_INITIALIZE_STORAGE(omnitrace::component::callchain) +TIMEMORY_INITIALIZE_STORAGE(rocprofsys::component::callchain) diff --git a/source/lib/omnitrace/library/components/callchain.hpp b/source/lib/rocprof-sys/library/components/callchain.hpp similarity index 94% rename from source/lib/omnitrace/library/components/callchain.hpp rename to source/lib/rocprof-sys/library/components/callchain.hpp index 681e61f3..f3cec838 100644 --- a/source/lib/omnitrace/library/components/callchain.hpp +++ b/source/lib/rocprof-sys/library/components/callchain.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -42,13 +42,13 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace component { struct callchain : comp::empty_base { - static constexpr size_t stack_depth = OMNITRACE_MAX_UNWIND_DEPTH; + static constexpr size_t stack_depth = ROCPROFSYS_MAX_UNWIND_DEPTH; struct record { @@ -92,4 +92,4 @@ struct callchain : comp::empty_base data_t m_data = {}; }; } // namespace component -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/components/category_region.hpp b/source/lib/rocprof-sys/library/components/category_region.hpp similarity index 90% rename from source/lib/omnitrace/library/components/category_region.hpp rename to source/lib/rocprof-sys/library/components/category_region.hpp index b0348f84..ddb57104 100644 --- a/source/lib/omnitrace/library/components/category_region.hpp +++ b/source/lib/rocprof-sys/library/components/category_region.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -54,7 +54,7 @@ struct timemory : concepts::quirk_type } // namespace quirk } // namespace tim -namespace omnitrace +namespace rocprofsys { namespace component { @@ -83,7 +83,7 @@ get_thread_status() return get_thread_state(); } -// timemory component which calls omnitrace functions +// timemory component which calls rocprof-sys functions // (used in gotcha wrappers) template struct category_region : comp::base, void> @@ -92,7 +92,10 @@ struct category_region : comp::base, void> static constexpr auto category_name = trait::name::value; - static std::string label() { return JOIN('_', "omnitrace", category_name, "region"); } + static std::string label() + { + return JOIN('_', "rocprofsys", category_name, "region"); + } template static void start(std::string_view name, Args&&...); @@ -133,12 +136,12 @@ category_region::start(std::string_view name, Args&&... args) if(name.empty()) return; - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); // the expectation here is that if the state is not active then the call - // to omnitrace_init_tooling_hidden will activate all the appropriate + // to rocprofsys_init_tooling_hidden will activate all the appropriate // tooling one time and as it exits set it to active and return true. - if(get_state() != State::Active && !omnitrace_init_tooling_hidden()) return; + if(get_state() != State::Active && !rocprofsys_init_tooling_hidden()) return; if(get_thread_status() == ThreadState::Disabled) return; @@ -151,9 +154,9 @@ category_region::start(std::string_view name, Args&&... args) constexpr bool _ct_use_causal = (sizeof...(OptsT) == 0 || is_one_of>::value); - OMNITRACE_CONDITIONAL_PRINT( + ROCPROFSYS_CONDITIONAL_PRINT( tracing::debug_push, - "[%s][PID=%i][state=%s][thread_state=%s] omnitrace_push_region(%s)\n", + "[%s][PID=%i][state=%s][thread_state=%s] rocprofsys_push_region(%s)\n", category_name, process::get_id(), std::to_string(get_state()).c_str(), std::to_string(get_thread_state()).c_str(), name.data()); @@ -200,7 +203,7 @@ category_region::stop(std::string_view name, Args&&... args) if(get_thread_state() == ThreadState::Disabled) return; - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); constexpr bool _ct_use_timemory = (sizeof...(OptsT) == 0 || is_one_of>::value); @@ -211,9 +214,9 @@ category_region::stop(std::string_view name, Args&&... args) constexpr bool _ct_use_causal = (sizeof...(OptsT) == 0 || is_one_of>::value); - OMNITRACE_CONDITIONAL_PRINT( + ROCPROFSYS_CONDITIONAL_PRINT( tracing::debug_pop, - "[%s][PID=%i][state=%s][thread_state=%s] omnitrace_pop_region(%s)\n", + "[%s][PID=%i][state=%s][thread_state=%s] rocprofsys_pop_region(%s)\n", category_name, process::get_id(), std::to_string(get_state()).c_str(), std::to_string(get_thread_state()).c_str(), name.data()); @@ -257,8 +260,8 @@ category_region::stop(std::string_view name, Args&&... args) else { static auto _debug = get_debug_env(); - OMNITRACE_CONDITIONAL_BASIC_PRINT( - _debug, "[%s] omnitrace_pop_region(%s) ignored :: state = %s\n", + ROCPROFSYS_CONDITIONAL_BASIC_PRINT( + _debug, "[%s] rocprofsys_pop_region(%s) ignored :: state = %s\n", category_name, name.data(), std::to_string(get_state()).c_str()); } } @@ -277,20 +280,20 @@ category_region::mark(std::string_view name, Args&&...) if(tracing::category_mark_disabled()) return; // the expectation here is that if the state is not active then the call - // to omnitrace_init_tooling_hidden will activate all the appropriate + // to rocprofsys_init_tooling_hidden will activate all the appropriate // tooling one time and as it exits set it to active and return true. - if(get_state() != State::Active && !omnitrace_init_tooling_hidden()) return; + if(get_state() != State::Active && !rocprofsys_init_tooling_hidden()) return; // unconditionally return if thread is disabled or finalized if(get_thread_state() >= ThreadState::Completed) return; - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); if(get_use_causal()) { - OMNITRACE_CONDITIONAL_PRINT( + ROCPROFSYS_CONDITIONAL_PRINT( tracing::debug_mark, - "[%s][PID=%i][state=%s][thread_state=%s] omnitrace_progress(%s)\n", + "[%s][PID=%i][state=%s][thread_state=%s] rocprofsys_progress(%s)\n", category_name, process::get_id(), std::to_string(get_state()).c_str(), std::to_string(get_thread_state()).c_str(), name.data()); @@ -308,7 +311,7 @@ category_region::audit(const gotcha_data_t& _data, audit::incoming, if(config::get_perfetto_annotations()) { int64_t _n = 0; - OMNITRACE_FOLD_EXPRESSION(tracing::add_perfetto_annotation( + ROCPROFSYS_FOLD_EXPRESSION(tracing::add_perfetto_annotation( ctx, tim::try_demangle>(), _args, _n++)); } }); @@ -336,7 +339,7 @@ category_region::audit(std::string_view _name, audit::incoming, if(config::get_perfetto_annotations()) { int64_t _n = 0; - OMNITRACE_FOLD_EXPRESSION(tracing::add_perfetto_annotation( + ROCPROFSYS_FOLD_EXPRESSION(tracing::add_perfetto_annotation( ctx, tim::try_demangle>(), _args, _n++)); } }); @@ -414,4 +417,4 @@ struct local_category_region : comp::base, void std::string_view m_prefix = {}; }; } // namespace component -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/components/comm_data.cpp b/source/lib/rocprof-sys/library/components/comm_data.cpp similarity index 89% rename from source/lib/omnitrace/library/components/comm_data.cpp rename to source/lib/rocprof-sys/library/components/comm_data.cpp index e1cd9741..62f7a95e 100644 --- a/source/lib/omnitrace/library/components/comm_data.cpp +++ b/source/lib/rocprof-sys/library/components/comm_data.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -31,7 +31,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace component { @@ -41,10 +41,10 @@ template void write_perfetto_counter_track(uint64_t _val) { - using counter_track = omnitrace::perfetto_counter_track; + using counter_track = rocprofsys::perfetto_counter_track; - if(omnitrace::get_use_perfetto() && - omnitrace::get_state() == omnitrace::State::Active) + if(rocprofsys::get_use_perfetto() && + rocprofsys::get_state() == rocprofsys::State::Active) { auto _emplace = [](const size_t _idx) { if(!counter_track::exists(_idx)) @@ -65,7 +65,7 @@ write_perfetto_counter_track(uint64_t _val) uint64_t _now = 0; { std::unique_lock _lk{ _mutex }; - _now = omnitrace::tracing::now(); + _now = rocprofsys::tracing::now(); _val = (value += _val); } @@ -105,7 +105,7 @@ comm_data::configure() comm_data_tracker_t::set_format_flags(_fmt_flags); } -#if defined(OMNITRACE_USE_MPI) +#if defined(ROCPROFSYS_USE_MPI) // MPI_Send void comm_data::audit(const gotcha_data& _data, audit::incoming, const void*, int count, @@ -116,7 +116,7 @@ comm_data::audit(const gotcha_data& _data, audit::incoming, const void*, int cou write_perfetto_counter_track(count * _size); - if(!omnitrace::get_use_timemory()) return; + if(!rocprofsys::get_use_timemory()) return; auto _name = std::string_view{ _data.tool_id }; tracker_t _a{ _name }; add(_a, count * _size); @@ -135,7 +135,7 @@ comm_data::audit(const gotcha_data& _data, audit::incoming, void*, int count, write_perfetto_counter_track(count * _size); - if(!omnitrace::get_use_timemory()) return; + if(!rocprofsys::get_use_timemory()) return; auto _name = std::string_view{ _data.tool_id }; tracker_t _a{ _name }; add(_a, count * _size); @@ -154,7 +154,7 @@ comm_data::audit(const gotcha_data& _data, audit::incoming, const void*, int cou write_perfetto_counter_track(count * _size); - if(!omnitrace::get_use_timemory()) return; + if(!rocprofsys::get_use_timemory()) return; auto _name = std::string_view{ _data.tool_id }; tracker_t _a{ _name }; add(_a, count * _size); @@ -173,7 +173,7 @@ comm_data::audit(const gotcha_data& _data, audit::incoming, void*, int count, write_perfetto_counter_track(count * _size); - if(!omnitrace::get_use_timemory()) return; + if(!rocprofsys::get_use_timemory()) return; auto _name = std::string_view{ _data.tool_id }; tracker_t _a{ _name }; add(_a, count * _size); @@ -192,7 +192,7 @@ comm_data::audit(const gotcha_data& _data, audit::incoming, void*, int count, write_perfetto_counter_track(count * _size); - if(!omnitrace::get_use_timemory()) return; + if(!rocprofsys::get_use_timemory()) return; auto _name = std::string_view{ _data.tool_id }; tracker_t _t{ _name }; add(_t, count * _size); @@ -210,7 +210,7 @@ comm_data::audit(const gotcha_data& _data, audit::incoming, const void*, void*, write_perfetto_counter_track(count * _size); write_perfetto_counter_track(count * _size); - if(!omnitrace::get_use_timemory()) return; + if(!rocprofsys::get_use_timemory()) return; add(_data, count * _size); } @@ -227,7 +227,7 @@ comm_data::audit(const gotcha_data& _data, audit::incoming, const void*, int sen write_perfetto_counter_track(sendcount * _send_size); write_perfetto_counter_track(recvcount * _recv_size); - if(!omnitrace::get_use_timemory()) return; + if(!rocprofsys::get_use_timemory()) return; auto _name = std::string_view{ _data.tool_id }; tracker_t _t{ _name }; add(_t, sendcount * _send_size + recvcount * _recv_size); @@ -265,7 +265,7 @@ comm_data::audit(const gotcha_data& _data, audit::incoming, const void*, int sen write_perfetto_counter_track(sendcount * _send_size); write_perfetto_counter_track(recvcount * _recv_size); - if(!omnitrace::get_use_timemory()) return; + if(!rocprofsys::get_use_timemory()) return; auto _name = std::string_view{ _data.tool_id }; tracker_t _t{ _name }; add(_t, sendcount * _send_size + recvcount * _recv_size); @@ -288,7 +288,7 @@ comm_data::audit(const gotcha_data& _data, audit::incoming, const void*, int sen write_perfetto_counter_track(sendcount * _send_size); write_perfetto_counter_track(recvcount * _recv_size); - if(!omnitrace::get_use_timemory()) return; + if(!rocprofsys::get_use_timemory()) return; auto _name = std::string_view{ _data.tool_id }; tracker_t _t{ _name }; add(_t, sendcount * _send_size + recvcount * _recv_size); @@ -297,7 +297,7 @@ comm_data::audit(const gotcha_data& _data, audit::incoming, const void*, int sen } #endif -#if defined(OMNITRACE_USE_RCCL) +#if defined(ROCPROFSYS_USE_RCCL) // ncclReduce void comm_data::audit(const gotcha_data& _data, audit::incoming, const void*, const void*, @@ -309,7 +309,7 @@ comm_data::audit(const gotcha_data& _data, audit::incoming, const void*, const v write_perfetto_counter_track(count * _size); - if(!omnitrace::get_use_timemory()) return; + if(!rocprofsys::get_use_timemory()) return; auto _name = std::string_view{ _data.tool_id }; tracker_t _t{ _name }; add(_t, count * _size); @@ -340,12 +340,12 @@ comm_data::audit(const gotcha_data& _data, audit::incoming, const void*, size_t } else { - OMNITRACE_CI_THROW(true, "RCCL function not handled: %s", _data.tool_id.c_str()); + ROCPROFSYS_CI_THROW(true, "RCCL function not handled: %s", _data.tool_id.c_str()); } write_perfetto_counter_track(count * _size); - if(!omnitrace::get_use_timemory()) return; + if(!rocprofsys::get_use_timemory()) return; auto _name = std::string_view{ _data.tool_id }; std::string _label = "root"; if(_name.find("Send") != std::string::npos) _label = "peer"; @@ -365,7 +365,7 @@ comm_data::audit(const gotcha_data& _data, audit::incoming, const void*, const v write_perfetto_counter_track(count * _size); - if(!omnitrace::get_use_timemory()) return; + if(!rocprofsys::get_use_timemory()) return; auto _name = std::string_view{ _data.tool_id }; tracker_t _t{ _name }; add(_t, count * _size); @@ -395,10 +395,10 @@ comm_data::audit(const gotcha_data& _data, audit::incoming, const void*, const v } else { - OMNITRACE_CI_THROW(true, "RCCL function not handled: %s", _data.tool_id.c_str()); + ROCPROFSYS_CI_THROW(true, "RCCL function not handled: %s", _data.tool_id.c_str()); } - if(!omnitrace::get_use_timemory()) return; + if(!rocprofsys::get_use_timemory()) return; add(_data, count * _size); } @@ -412,14 +412,14 @@ comm_data::audit(const gotcha_data& _data, audit::incoming, const void*, const v write_perfetto_counter_track(count * _size); - if(!omnitrace::get_use_timemory()) return; + if(!rocprofsys::get_use_timemory()) return; add(_data, count * _size); } #endif } // namespace component -} // namespace omnitrace +} // namespace rocprofsys -OMNITRACE_INSTANTIATE_EXTERN_COMPONENT( - TIMEMORY_ESC(data_tracker), true, float) +ROCPROFSYS_INSTANTIATE_EXTERN_COMPONENT( + TIMEMORY_ESC(data_tracker), true, float) -OMNITRACE_INSTANTIATE_EXTERN_COMPONENT(comm_data, false, void) +ROCPROFSYS_INSTANTIATE_EXTERN_COMPONENT(comm_data, false, void) diff --git a/source/lib/omnitrace/library/components/comm_data.hpp b/source/lib/rocprof-sys/library/components/comm_data.hpp similarity index 91% rename from source/lib/omnitrace/library/components/comm_data.hpp rename to source/lib/rocprof-sys/library/components/comm_data.hpp index 0c297bb5..03735862 100644 --- a/source/lib/omnitrace/library/components/comm_data.hpp +++ b/source/lib/rocprof-sys/library/components/comm_data.hpp @@ -38,7 +38,7 @@ #include -#if defined(OMNITRACE_USE_MPI) +#if defined(ROCPROFSYS_USE_MPI) # include #endif @@ -49,10 +49,10 @@ #include #include -OMNITRACE_COMPONENT_ALIAS(comm_data_tracker_t, - ::tim::component::data_tracker) +ROCPROFSYS_COMPONENT_ALIAS(comm_data_tracker_t, + ::tim::component::data_tracker) -namespace omnitrace +namespace rocprofsys { namespace component { @@ -90,7 +90,7 @@ struct comm_data : base static constexpr auto label = "RCCL Comm Send"; }; - OMNITRACE_DEFAULT_OBJECT(comm_data) + ROCPROFSYS_DEFAULT_OBJECT(comm_data) static void preinit(); static void configure(); @@ -98,7 +98,7 @@ struct comm_data : base static void start() {} static void stop() {} -#if defined(OMNITRACE_USE_MPI) +#if defined(ROCPROFSYS_USE_MPI) static int mpi_type_size(MPI_Datatype _datatype) { int _size = 0; @@ -148,7 +148,7 @@ struct comm_data : base MPI_Datatype recvtype, MPI_Comm); #endif -#if defined(OMNITRACE_USE_RCCL) +#if defined(ROCPROFSYS_USE_RCCL) static auto rccl_type_size(ncclDataType_t datatype) { switch(datatype) @@ -200,7 +200,7 @@ struct comm_data : base private: static auto& add(tracker_t& _t, data_type value) { - if(omnitrace::get_state() != omnitrace::State::Active) + if(rocprofsys::get_state() != rocprofsys::State::Active) { _t.invoke(true); return _t; @@ -228,17 +228,17 @@ struct comm_data : base } }; } // namespace component -} // namespace omnitrace +} // namespace rocprofsys -#if !defined(OMNITRACE_EXTERN_COMPONENTS) || \ - (defined(OMNITRACE_EXTERN_COMPONENTS) && OMNITRACE_EXTERN_COMPONENTS > 0) +#if !defined(ROCPROFSYS_EXTERN_COMPONENTS) || \ + (defined(ROCPROFSYS_EXTERN_COMPONENTS) && ROCPROFSYS_EXTERN_COMPONENTS > 0) # include # include # include -OMNITRACE_DECLARE_EXTERN_COMPONENT( - TIMEMORY_ESC(data_tracker), true, float) +ROCPROFSYS_DECLARE_EXTERN_COMPONENT( + TIMEMORY_ESC(data_tracker), true, float) -OMNITRACE_DECLARE_EXTERN_COMPONENT(comm_data, false, void) +ROCPROFSYS_DECLARE_EXTERN_COMPONENT(comm_data, false, void) #endif diff --git a/source/lib/omnitrace/library/components/cpu_freq.cpp b/source/lib/rocprof-sys/library/components/cpu_freq.cpp similarity index 89% rename from source/lib/omnitrace/library/components/cpu_freq.cpp rename to source/lib/rocprof-sys/library/components/cpu_freq.cpp index 4444eadc..8117d9ad 100644 --- a/source/lib/omnitrace/library/components/cpu_freq.cpp +++ b/source/lib/rocprof-sys/library/components/cpu_freq.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -38,7 +38,7 @@ namespace cpuinfo = tim::procfs::cpuinfo; -namespace omnitrace +namespace rocprofsys { namespace component { @@ -98,7 +98,7 @@ cpu_freq::configure() { if(_v.find_first_not_of("0123456789-") != std::string::npos) { - OMNITRACE_VERBOSE_F( + ROCPROFSYS_VERBOSE_F( 0, "Invalid CPU specification. Only numerical values (e.g., 0) or " "ranges (e.g., 0-7) are permitted. Ignoring %s...", @@ -108,7 +108,7 @@ cpu_freq::configure() if(_v.find('-') != std::string::npos) { auto _vv = tim::delimit(_v, "-"); - OMNITRACE_CONDITIONAL_THROW( + ROCPROFSYS_CONDITIONAL_THROW( _vv.size() != 2, "Invalid CPU range specification: %s. Required format N-M, e.g. 0-4", _v.c_str()); @@ -137,20 +137,21 @@ cpu_freq::configure() _enabled_freqs.emplace(itr); else { - OMNITRACE_VERBOSE( + ROCPROFSYS_VERBOSE( 0, "[cpu_freq::config] Warning! Removing invalid cpu %zu...\n", itr); } } if(!cpuinfo::freq{}) { - OMNITRACE_VERBOSE(0, "[cpu_freq::config] Warning! CPU frequencies are disabled " - ":: unable to open /proc/cpuinfo"); + ROCPROFSYS_VERBOSE(0, "[cpu_freq::config] Warning! CPU frequencies are disabled " + ":: unable to open /proc/cpuinfo"); _enabled_freqs.clear(); } - OMNITRACE_CI_FAIL(!cpuinfo::freq{}, "[cpu_freq::config] CPU frequencies are disabled " - ":: unable to open /proc/cpuinfo"); + ROCPROFSYS_CI_FAIL(!cpuinfo::freq{}, + "[cpu_freq::config] CPU frequencies are disabled " + ":: unable to open /proc/cpuinfo"); get_enabled_cpus() = _enabled_freqs; } @@ -216,6 +217,6 @@ cpu_freq::get(int64_t _unit) const return _v; } } // namespace component -} // namespace omnitrace +} // namespace rocprofsys -TIMEMORY_INITIALIZE_STORAGE(omnitrace::component::cpu_freq) +TIMEMORY_INITIALIZE_STORAGE(rocprofsys::component::cpu_freq) diff --git a/source/lib/omnitrace/library/components/cpu_freq.hpp b/source/lib/rocprof-sys/library/components/cpu_freq.hpp similarity index 95% rename from source/lib/omnitrace/library/components/cpu_freq.hpp rename to source/lib/rocprof-sys/library/components/cpu_freq.hpp index 66904bf8..310156ec 100644 --- a/source/lib/omnitrace/library/components/cpu_freq.hpp +++ b/source/lib/rocprof-sys/library/components/cpu_freq.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -29,7 +29,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace component { @@ -44,7 +44,7 @@ struct cpu_freq using storage_type = tim::storage; using cpu_id_set_t = std::set; - OMNITRACE_DEFAULT_OBJECT(cpu_freq) + ROCPROFSYS_DEFAULT_OBJECT(cpu_freq) // string id for component static std::string label(); @@ -108,4 +108,4 @@ struct cpu_freq using tim::component::base_data::value; }; } // namespace component -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/components/ensure_storage.hpp b/source/lib/rocprof-sys/library/components/ensure_storage.hpp similarity index 89% rename from source/lib/omnitrace/library/components/ensure_storage.hpp rename to source/lib/rocprof-sys/library/components/ensure_storage.hpp index 383f3a45..603bfaad 100644 --- a/source/lib/omnitrace/library/components/ensure_storage.hpp +++ b/source/lib/rocprof-sys/library/components/ensure_storage.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -30,7 +30,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace component { @@ -39,9 +39,9 @@ namespace template struct ensure_storage { - OMNITRACE_DEFAULT_OBJECT(ensure_storage) + ROCPROFSYS_DEFAULT_OBJECT(ensure_storage) - void operator()() const { OMNITRACE_FOLD_EXPRESSION((*this)(tim::type_list{})); } + void operator()() const { ROCPROFSYS_FOLD_EXPRESSION((*this)(tim::type_list{})); } private: template ::value, int> = 0> @@ -66,4 +66,4 @@ struct ensure_storage }; } // namespace } // namespace component -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/components/exit_gotcha.cpp b/source/lib/rocprof-sys/library/components/exit_gotcha.cpp similarity index 72% rename from source/lib/omnitrace/library/components/exit_gotcha.cpp rename to source/lib/rocprof-sys/library/components/exit_gotcha.cpp index 540da5d4..68318a35 100644 --- a/source/lib/omnitrace/library/components/exit_gotcha.cpp +++ b/source/lib/rocprof-sys/library/components/exit_gotcha.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -35,7 +35,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace component { @@ -64,35 +64,35 @@ invoke_exit_gotcha(const exit_gotcha::gotcha_data& _data, FuncT _func, Args... _ { if(config::settings_are_configured()) { - OMNITRACE_VERBOSE(0, "finalizing %s before calling %s(%s)...\n", - get_exe_name().c_str(), _data.tool_id.c_str(), - JOIN(", ", _args...).c_str()); + ROCPROFSYS_VERBOSE(0, "finalizing %s before calling %s(%s)...\n", + get_exe_name().c_str(), _data.tool_id.c_str(), + JOIN(", ", _args...).c_str()); } else { - OMNITRACE_BASIC_VERBOSE(0, "finalizing %s before calling %s(%s)...\n", - get_exe_name().c_str(), _data.tool_id.c_str(), - JOIN(", ", _args...).c_str()); + ROCPROFSYS_BASIC_VERBOSE(0, "finalizing %s before calling %s(%s)...\n", + get_exe_name().c_str(), _data.tool_id.c_str(), + JOIN(", ", _args...).c_str()); } - omnitrace_finalize(); + rocprofsys_finalize(); } if(config::settings_are_configured()) { - OMNITRACE_VERBOSE(0, "calling %s(%s) in %s...\n", _data.tool_id.c_str(), - JOIN(", ", _args...).c_str(), get_exe_name().c_str()); + ROCPROFSYS_VERBOSE(0, "calling %s(%s) in %s...\n", _data.tool_id.c_str(), + JOIN(", ", _args...).c_str(), get_exe_name().c_str()); } else { - OMNITRACE_BASIC_VERBOSE(0, "calling %s(%s) in %s...\n", _data.tool_id.c_str(), - JOIN(", ", _args...).c_str(), get_exe_name().c_str()); + ROCPROFSYS_BASIC_VERBOSE(0, "calling %s(%s) in %s...\n", _data.tool_id.c_str(), + JOIN(", ", _args...).c_str(), get_exe_name().c_str()); } if(_exit_info.is_known && _exit_info.exit_code != 0) { - OMNITRACE_BASIC_VERBOSE(0, "%s exiting with non-zero exit code: %i...\n", - get_exe_name().c_str(), _exit_info.exit_code); + ROCPROFSYS_BASIC_VERBOSE(0, "%s exiting with non-zero exit code: %i...\n", + get_exe_name().c_str(), _exit_info.exit_code); } (*_func)(_args...); @@ -122,4 +122,4 @@ exit_gotcha::get_exit_info() return _exit_info; } } // namespace component -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/components/exit_gotcha.hpp b/source/lib/rocprof-sys/library/components/exit_gotcha.hpp similarity index 93% rename from source/lib/omnitrace/library/components/exit_gotcha.hpp rename to source/lib/rocprof-sys/library/components/exit_gotcha.hpp index b5a63bad..c97190b6 100644 --- a/source/lib/omnitrace/library/components/exit_gotcha.hpp +++ b/source/lib/rocprof-sys/library/components/exit_gotcha.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -32,7 +32,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace component { @@ -44,7 +44,7 @@ struct exit_gotcha : tim::component::base using exit_func_t = void (*)(int); using abort_func_t = void (*)(); - OMNITRACE_DEFAULT_OBJECT(exit_gotcha) + ROCPROFSYS_DEFAULT_OBJECT(exit_gotcha) // string id for component static std::string label() { return "exit_gotcha"; } @@ -73,4 +73,4 @@ struct exit_gotcha : tim::component::base using exit_gotcha_t = tim::component::gotcha, component::exit_gotcha>; -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/components/fork_gotcha.cpp b/source/lib/rocprof-sys/library/components/fork_gotcha.cpp similarity index 76% rename from source/lib/omnitrace/library/components/fork_gotcha.cpp rename to source/lib/rocprof-sys/library/components/fork_gotcha.cpp index cba7b5b3..50e9d7fc 100644 --- a/source/lib/omnitrace/library/components/fork_gotcha.cpp +++ b/source/lib/rocprof-sys/library/components/fork_gotcha.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -41,7 +41,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace component { @@ -66,25 +66,25 @@ prefork_setup() { if(prefork_lock) return; - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); - OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_SAMPLING_ON_CHILD_THREADS(false); if(get_state() < State::Active && !config::settings_are_configured()) - omnitrace_init_library_hidden(); - - tim::set_env("OMNITRACE_PRELOAD", "0", 1); - tim::set_env("OMNITRACE_ROOT_PROCESS", process::get_id(), 0); - omnitrace_reset_preload_hidden(); - OMNITRACE_BASIC_VERBOSE(0, "fork() called on PID %i (rank: %i), TID %li\n", - process::get_id(), dmp::rank(), threading::get_id()); - OMNITRACE_BASIC_DEBUG( + rocprofsys_init_library_hidden(); + + tim::set_env("ROCPROFSYS_PRELOAD", "0", 1); + tim::set_env("ROCPROFSYS_ROOT_PROCESS", process::get_id(), 0); + rocprofsys_reset_preload_hidden(); + ROCPROFSYS_BASIC_VERBOSE(0, "fork() called on PID %i (rank: %i), TID %li\n", + process::get_id(), dmp::rank(), threading::get_id()); + ROCPROFSYS_BASIC_DEBUG( "Warning! Calling fork() within an OpenMPI application using libfabric " "may result is segmentation fault\n"); TIMEMORY_CONDITIONAL_DEMANGLED_BACKTRACE(get_debug_env(), 16); if(config::get_use_sampling()) sampling::block_samples(); - omnitrace::categories::disable_categories(config::get_enabled_categories()); + rocprofsys::categories::disable_categories(config::get_enabled_categories()); // prevent re-entry until post-fork routines have been called prefork_lock = true; @@ -97,7 +97,7 @@ postfork_parent() { if(postfork_parent_lock) return; - omnitrace::categories::enable_categories(config::get_enabled_categories()); + rocprofsys::categories::enable_categories(config::get_enabled_categories()); if(config::get_use_sampling()) sampling::unblock_samples(); @@ -111,18 +111,18 @@ postfork_child() { if(postfork_child_lock) return; - OMNITRACE_REQUIRE(is_child_process()) + ROCPROFSYS_REQUIRE(is_child_process()) << "Error! child process " << process::get_id() << " believes it is the root process " << get_root_process_id() << "\n"; settings::enabled() = false; settings::verbose() = -127; settings::debug() = false; - omnitrace::sampling::shutdown(); - omnitrace::categories::shutdown(); - set_thread_state(::omnitrace::ThreadState::Disabled); + rocprofsys::sampling::shutdown(); + rocprofsys::categories::shutdown(); + set_thread_state(::rocprofsys::ThreadState::Disabled); - omnitrace::get_perfetto_session(process::get_parent_id()).release(); + rocprofsys::get_perfetto_session(process::get_parent_id()).release(); // register these exit handlers to avoid cleaning up resources on_exit(&child_exit, nullptr); @@ -155,8 +155,8 @@ fork_gotcha::operator()(const gotcha_data_t&, pid_t (*_real_fork)()) const if(_pid != 0) { - OMNITRACE_BASIC_VERBOSE(0, "fork() called on PID %i created PID %i\n", getpid(), - _pid); + ROCPROFSYS_BASIC_VERBOSE(0, "fork() called on PID %i created PID %i\n", getpid(), + _pid); postfork_parent(); } @@ -167,12 +167,12 @@ fork_gotcha::operator()(const gotcha_data_t&, pid_t (*_real_fork)()) const if(!settings::use_output_suffix()) { - OMNITRACE_BASIC_VERBOSE( + ROCPROFSYS_BASIC_VERBOSE( 0, "Application which make calls to fork() should enable using an process " - "identifier output suffix (i.e. set OMNITRACE_USE_PID=ON)\n"); + "identifier output suffix (i.e. set ROCPROFSYS_USE_PID=ON)\n"); } return _pid; } } // namespace component -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/components/fork_gotcha.hpp b/source/lib/rocprof-sys/library/components/fork_gotcha.hpp similarity index 89% rename from source/lib/omnitrace/library/components/fork_gotcha.hpp rename to source/lib/rocprof-sys/library/components/fork_gotcha.hpp index a58b7313..0a35d3a0 100644 --- a/source/lib/omnitrace/library/components/fork_gotcha.hpp +++ b/source/lib/rocprof-sys/library/components/fork_gotcha.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -26,7 +26,7 @@ #include "core/defines.hpp" #include "core/timemory.hpp" -namespace omnitrace +namespace rocprofsys { namespace component { @@ -37,7 +37,7 @@ struct fork_gotcha : comp::base using gotcha_data_t = comp::gotcha_data; - OMNITRACE_DEFAULT_OBJECT(fork_gotcha) + ROCPROFSYS_DEFAULT_OBJECT(fork_gotcha) // string id for component static std::string label() { return "fork_gotcha"; } @@ -48,7 +48,7 @@ struct fork_gotcha : comp::base // this will get called right before fork pid_t operator()(const gotcha_data_t&, pid_t (*)()) const; - // silence SFINAE disabled for omnitrace::fork_gotcha warnings + // silence SFINAE disabled for rocprofsys::fork_gotcha warnings static inline void start() {} static inline void stop() {} }; @@ -56,4 +56,4 @@ struct fork_gotcha : comp::base using fork_gotcha_t = comp::gotcha, component::fork_gotcha>; -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/components/mpi_gotcha.cpp b/source/lib/rocprof-sys/library/components/mpi_gotcha.cpp similarity index 79% rename from source/lib/omnitrace/library/components/mpi_gotcha.cpp rename to source/lib/rocprof-sys/library/components/mpi_gotcha.cpp index 5e552e91..4034843c 100644 --- a/source/lib/omnitrace/library/components/mpi_gotcha.cpp +++ b/source/lib/rocprof-sys/library/components/mpi_gotcha.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -40,7 +40,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace component { @@ -75,8 +75,8 @@ struct comm_rank_data friend bool operator>(const comm_rank_data& _lhs, const comm_rank_data& _rhs) { - OMNITRACE_CI_THROW(!_lhs.updated() && !_rhs.updated(), - "Error! comparing rank data that is not updated"); + ROCPROFSYS_CI_THROW(!_lhs.updated() && !_rhs.updated(), + "Error! comparing rank data that is not updated"); if(_lhs.updated() && !_rhs.updated()) return true; if(!_lhs.updated() && _rhs.updated()) return false; @@ -104,28 +104,28 @@ using tim::type_mutex; #if defined(TIMEMORY_USE_MPI) int -omnitrace_mpi_copy(MPI_Comm, int, void*, void*, void*, int*) +rocprofsys_mpi_copy(MPI_Comm, int, void*, void*, void*, int*) { return MPI_SUCCESS; } int -omnitrace_mpi_fini(MPI_Comm, int, void*, void*) +rocprofsys_mpi_fini(MPI_Comm, int, void*, void*) { - OMNITRACE_DEBUG("MPI Comm attribute finalize\n"); + ROCPROFSYS_DEBUG("MPI Comm attribute finalize\n"); auto _blocked = get_sampling_signals(); if(!_blocked.empty()) tim::signals::block_signals(_blocked, tim::signals::sigmask_scope::process); if(mpip_index != std::numeric_limits::max()) - comp::deactivate_mpip(mpip_index); - if(is_root_process()) omnitrace_finalize_hidden(); + comp::deactivate_mpip(mpip_index); + if(is_root_process()) rocprofsys_finalize_hidden(); return MPI_SUCCESS; } #endif -// this ensures omnitrace_finalize is called before MPI_Finalize +// this ensures rocprofsys_finalize is called before MPI_Finalize void -omnitrace_mpi_set_attr() +rocprofsys_mpi_set_attr() { #if defined(TIMEMORY_USE_MPI) auto _blocked = get_sampling_signals(); @@ -133,7 +133,7 @@ omnitrace_mpi_set_attr() tim::signals::block_signals(_blocked, tim::signals::sigmask_scope::process); int _comm_key = -1; - if(PMPI_Comm_create_keyval(&omnitrace_mpi_copy, &omnitrace_mpi_fini, &_comm_key, + if(PMPI_Comm_create_keyval(&rocprofsys_mpi_copy, &rocprofsys_mpi_fini, &_comm_key, nullptr) == MPI_SUCCESS) PMPI_Comm_set_attr(MPI_COMM_SELF, _comm_key, nullptr); @@ -168,7 +168,7 @@ mpi_gotcha::configure() reject_bindings.emplace("MPI_Init"); reject_bindings.emplace("MPI_Init_thread"); reject_bindings.emplace("MPI_Finalize"); -#if defined(OMNITRACE_USE_MPI_HEADERS) && OMNITRACE_USE_MPI_HEADERS > 0 +#if defined(ROCPROFSYS_USE_MPI_HEADERS) && ROCPROFSYS_USE_MPI_HEADERS > 0 mpi_gotcha_t::template configure<3, int, comm_t, int*>("MPI_Comm_rank"); mpi_gotcha_t::template configure<4, int, comm_t, int*>("MPI_Comm_size"); reject_bindings.emplace("MPI_Comm_rank"); @@ -211,9 +211,9 @@ mpi_gotcha::update() tim::mpi::set_size(_size); tim::settings::default_process_suffix() = _rank; - OMNITRACE_BASIC_VERBOSE(0, "[pid=%i] MPI rank: %i (%i), MPI size: %i (%i)\n", - process::get_id(), tim::mpi::rank(), _rank, - tim::mpi::size(), _size); + ROCPROFSYS_BASIC_VERBOSE(0, "[pid=%i] MPI rank: %i (%i), MPI size: %i (%i)\n", + process::get_id(), tim::mpi::rank(), _rank, + tim::mpi::size(), _size); last_comm_record = _rank_data; config::get_use_pid() = true; return true; @@ -224,7 +224,7 @@ mpi_gotcha::update() void mpi_gotcha::disable_comm_intercept() { -#if defined(OMNITRACE_USE_MPI_HEADERS) && OMNITRACE_USE_MPI_HEADERS > 0 +#if defined(ROCPROFSYS_USE_MPI_HEADERS) && ROCPROFSYS_USE_MPI_HEADERS > 0 mpi_gotcha_t::revert<3>(); mpi_gotcha_t::revert<4>(); #endif @@ -233,9 +233,9 @@ mpi_gotcha::disable_comm_intercept() void mpi_gotcha::audit(const gotcha_data_t& _data, audit::incoming, int*, char***) { - OMNITRACE_BASIC_DEBUG_F("%s(int*, char***)\n", _data.tool_id.c_str()); + ROCPROFSYS_BASIC_DEBUG_F("%s(int*, char***)\n", _data.tool_id.c_str()); - omnitrace_push_trace_hidden(_data.tool_id.c_str()); + rocprofsys_push_trace_hidden(_data.tool_id.c_str()); #if !defined(TIMEMORY_USE_MPI) && defined(TIMEMORY_USE_MPI_HEADERS) tim::mpi::is_initialized_callback() = []() { return true; }; tim::mpi::is_finalized() = false; @@ -245,9 +245,9 @@ mpi_gotcha::audit(const gotcha_data_t& _data, audit::incoming, int*, char***) void mpi_gotcha::audit(const gotcha_data_t& _data, audit::incoming, int*, char***, int, int*) { - OMNITRACE_BASIC_DEBUG_F("%s(int*, char***, int, int*)\n", _data.tool_id.c_str()); + ROCPROFSYS_BASIC_DEBUG_F("%s(int*, char***, int, int*)\n", _data.tool_id.c_str()); - omnitrace_push_trace_hidden(_data.tool_id.c_str()); + rocprofsys_push_trace_hidden(_data.tool_id.c_str()); #if !defined(TIMEMORY_USE_MPI) && defined(TIMEMORY_USE_MPI_HEADERS) tim::mpi::is_initialized_callback() = []() { return true; }; tim::mpi::is_finalized() = false; @@ -257,30 +257,30 @@ mpi_gotcha::audit(const gotcha_data_t& _data, audit::incoming, int*, char***, in void mpi_gotcha::audit(const gotcha_data_t& _data, audit::incoming) { - OMNITRACE_BASIC_DEBUG_F("%s()\n", _data.tool_id.c_str()); + ROCPROFSYS_BASIC_DEBUG_F("%s()\n", _data.tool_id.c_str()); auto _blocked = get_sampling_signals(); if(!_blocked.empty()) tim::signals::block_signals(_blocked, tim::signals::sigmask_scope::process); if(mpip_index != std::numeric_limits::max()) - comp::deactivate_mpip(mpip_index); + comp::deactivate_mpip(mpip_index); #if !defined(TIMEMORY_USE_MPI) && defined(TIMEMORY_USE_MPI_HEADERS) tim::mpi::is_initialized_callback() = []() { return false; }; tim::mpi::is_finalized() = true; #else - if(is_root_process() && omnitrace::get_state() < omnitrace::State::Finalized) - omnitrace_finalize_hidden(); + if(is_root_process() && rocprofsys::get_state() < rocprofsys::State::Finalized) + rocprofsys_finalize_hidden(); #endif } void mpi_gotcha::audit(const gotcha_data_t& _data, audit::incoming, comm_t _comm, int* _val) { - OMNITRACE_BASIC_DEBUG_F("%s()\n", _data.tool_id.c_str()); + ROCPROFSYS_BASIC_DEBUG_F("%s()\n", _data.tool_id.c_str()); - omnitrace_push_trace_hidden(_data.tool_id.c_str()); + rocprofsys_push_trace_hidden(_data.tool_id.c_str()); if(_data.tool_id == "MPI_Comm_rank") { m_comm_val = (uintptr_t) _comm; // NOLINT @@ -293,35 +293,35 @@ mpi_gotcha::audit(const gotcha_data_t& _data, audit::incoming, comm_t _comm, int } else { - OMNITRACE_BASIC_PRINT_F("%s(, %p) :: unexpected function wrapper\n", - _data.tool_id.c_str(), static_cast(_val)); + ROCPROFSYS_BASIC_PRINT_F("%s(, %p) :: unexpected function wrapper\n", + _data.tool_id.c_str(), static_cast(_val)); } } void mpi_gotcha::audit(const gotcha_data_t& _data, audit::outgoing, int _retval) { - OMNITRACE_BASIC_DEBUG_F("%s() returned %i\n", _data.tool_id.c_str(), (int) _retval); + ROCPROFSYS_BASIC_DEBUG_F("%s() returned %i\n", _data.tool_id.c_str(), (int) _retval); if(!settings::use_output_suffix()) settings::use_output_suffix() = true; if(_retval == tim::mpi::success_v && _data.tool_id.find("MPI_Init") == 0) { - omnitrace_mpi_set_attr(); - // omnitrace will set this environement variable to true in binary rewrite mode + rocprofsys_mpi_set_attr(); + // rocprof-sys will set this environement variable to true in binary rewrite mode // when it detects MPI. Hides this env variable from the user to avoid this // being activated unwaringly during runtime instrumentation because that // will result in double instrumenting the MPI functions (unless the MPI functions // were excluded via a regex expression) if(get_use_mpip()) { - OMNITRACE_BASIC_VERBOSE_F(2, "Activating MPI wrappers...\n"); + ROCPROFSYS_BASIC_VERBOSE_F(2, "Activating MPI wrappers...\n"); - // use env vars OMNITRACE_MPIP_PERMIT_LIST and OMNITRACE_MPIP_REJECT_LIST + // use env vars ROCPROFSYS_MPIP_PERMIT_LIST and ROCPROFSYS_MPIP_REJECT_LIST // to control the gotcha bindings at runtime - comp::configure_mpip(permit_bindings, - reject_bindings); - mpip_index = comp::activate_mpip(); + comp::configure_mpip(permit_bindings, + reject_bindings); + mpip_index = comp::activate_mpip(); } auto_lock_t _lk{ type_mutex() }; @@ -363,7 +363,7 @@ mpi_gotcha::audit(const gotcha_data_t& _data, audit::outgoing, int _retval) } else { - OMNITRACE_BASIC_VERBOSE( + ROCPROFSYS_BASIC_VERBOSE( 0, "%s() returned %i :: unexpected function wrapper\n", _data.tool_id.c_str(), (int) _retval); } @@ -372,14 +372,14 @@ mpi_gotcha::audit(const gotcha_data_t& _data, audit::outgoing, int _retval) { static thread_local int _num_updates = 0; static int _disable_after = - tim::get_env("OMNITRACE_MPI_MAX_COMM_UPDATES", 4); + tim::get_env("ROCPROFSYS_MPI_MAX_COMM_UPDATES", 4); if(_num_updates++ < _disable_after) update(); } } } - omnitrace_pop_trace_hidden(_data.tool_id.c_str()); + rocprofsys_pop_trace_hidden(_data.tool_id.c_str()); } } // namespace component -} // namespace omnitrace +} // namespace rocprofsys -TIMEMORY_INITIALIZE_STORAGE(omnitrace::component::mpi_gotcha) +TIMEMORY_INITIALIZE_STORAGE(rocprofsys::component::mpi_gotcha) diff --git a/source/lib/omnitrace/library/components/mpi_gotcha.hpp b/source/lib/rocprof-sys/library/components/mpi_gotcha.hpp similarity index 93% rename from source/lib/omnitrace/library/components/mpi_gotcha.hpp rename to source/lib/rocprof-sys/library/components/mpi_gotcha.hpp index 20ff490e..cbb1af4c 100644 --- a/source/lib/omnitrace/library/components/mpi_gotcha.hpp +++ b/source/lib/rocprof-sys/library/components/mpi_gotcha.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -28,7 +28,7 @@ #include -namespace omnitrace +namespace rocprofsys { namespace component { @@ -38,7 +38,7 @@ struct mpi_gotcha : comp::base using comm_t = tim::mpi::comm_t; using gotcha_data_t = comp::gotcha_data; - OMNITRACE_DEFAULT_OBJECT(mpi_gotcha) + ROCPROFSYS_DEFAULT_OBJECT(mpi_gotcha) // string id for component static std::string label() { return "mpi_gotcha"; } @@ -81,5 +81,5 @@ struct mpi_gotcha : comp::base } // namespace component using mpi_gotcha_t = - comp::gotcha<5, tim::component_tuple, project::omnitrace>; -} // namespace omnitrace + comp::gotcha<5, tim::component_tuple, project::rocprofsys>; +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/components/numa_gotcha.cpp b/source/lib/rocprof-sys/library/components/numa_gotcha.cpp similarity index 97% rename from source/lib/omnitrace/library/components/numa_gotcha.cpp rename to source/lib/rocprof-sys/library/components/numa_gotcha.cpp index e006bbe2..d6954f5e 100644 --- a/source/lib/omnitrace/library/components/numa_gotcha.cpp +++ b/source/lib/rocprof-sys/library/components/numa_gotcha.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -45,7 +45,7 @@ // status, // int flags); -namespace omnitrace +namespace rocprofsys { namespace component { @@ -204,6 +204,6 @@ numa_gotcha::audit(const gotcha_data& _data, audit::outgoing, void* ret) ret); } } // namespace component -} // namespace omnitrace +} // namespace rocprofsys -TIMEMORY_STORAGE_INITIALIZER(omnitrace::component::numa_gotcha) +TIMEMORY_STORAGE_INITIALIZER(rocprofsys::component::numa_gotcha) diff --git a/source/lib/omnitrace/library/components/numa_gotcha.hpp b/source/lib/rocprof-sys/library/components/numa_gotcha.hpp similarity index 95% rename from source/lib/omnitrace/library/components/numa_gotcha.hpp rename to source/lib/rocprof-sys/library/components/numa_gotcha.hpp index 78b65648..01838f8c 100644 --- a/source/lib/omnitrace/library/components/numa_gotcha.hpp +++ b/source/lib/rocprof-sys/library/components/numa_gotcha.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -32,7 +32,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace component { @@ -44,7 +44,7 @@ struct numa_gotcha : tim::component::base using exit_func_t = void (*)(int); using abort_func_t = void (*)(); - OMNITRACE_DEFAULT_OBJECT(numa_gotcha) + ROCPROFSYS_DEFAULT_OBJECT(numa_gotcha) // string id for component static std::string label() { return "numa_gotcha"; } @@ -78,4 +78,4 @@ struct numa_gotcha : tim::component::base using numa_bundle_t = tim::component_bundle; using numa_gotcha_t = tim::component::gotcha; -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/components/pthread_create_gotcha.cpp b/source/lib/rocprof-sys/library/components/pthread_create_gotcha.cpp similarity index 89% rename from source/lib/omnitrace/library/components/pthread_create_gotcha.cpp rename to source/lib/rocprof-sys/library/components/pthread_create_gotcha.cpp index e34c8306..39a370f4 100644 --- a/source/lib/omnitrace/library/components/pthread_create_gotcha.cpp +++ b/source/lib/rocprof-sys/library/components/pthread_create_gotcha.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -49,7 +49,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace sampling { @@ -83,8 +83,8 @@ start_bundle(bundle_t& _bundle, int64_t _tid, Args&&... _args) { if(!get_use_timemory() && !get_use_perfetto()) return; trait::runtime_enabled::set(get_use_roctracer()); - OMNITRACE_BASIC_VERBOSE_F(3, "starting bundle '%s' in thread %li...\n", - _bundle.key().c_str(), _tid); + ROCPROFSYS_BASIC_VERBOSE_F(3, "starting bundle '%s' in thread %li...\n", + _bundle.key().c_str(), _tid); if constexpr(sizeof...(Args) > 0) { const char* _name = nullptr; @@ -117,8 +117,8 @@ stop_bundle(bundle_t& _bundle, int64_t _tid, Args&&... _args) _this_manager->is_finalized()) return; - OMNITRACE_BASIC_VERBOSE_F(3, "stopping bundle '%s' in thread %li...\n", - _bundle.key().c_str(), _tid); + ROCPROFSYS_BASIC_VERBOSE_F(3, "stopping bundle '%s' in thread %li...\n", + _bundle.key().c_str(), _tid); if(get_use_timemory()) { auto _wc = *_bundle.get(); @@ -201,7 +201,7 @@ pthread_create_gotcha::wrapper::operator()() const if(_tid >= 0) { - auto _active = (get_state() == ::omnitrace::State::Active && + auto _active = (get_state() == ::rocprofsys::State::Active && bundles != nullptr && bundles_mutex != nullptr); if(!_active) return; thread_info::set_stop(comp::wall_clock::record()); @@ -211,14 +211,14 @@ pthread_create_gotcha::wrapper::operator()() const _thr_bundle->stop(); if(_bundle) stop_bundle(*_bundle, _tid); pthread_create_gotcha::shutdown(_tid); - OMNITRACE_BASIC_VERBOSE( + ROCPROFSYS_BASIC_VERBOSE( 1, "[PID=%i][rank=%i] Thread %s (parent: %s) exited\n", process::get_id(), dmp::rank(), _info->index_data->as_string().c_str(), _parent_info->index_data->as_string().c_str()); } }; - auto _active = (get_state() == ::omnitrace::State::Active && bundles != nullptr && + auto _active = (get_state() == ::rocprofsys::State::Active && bundles != nullptr && bundles_mutex != nullptr); if(m_config.offset) @@ -230,17 +230,17 @@ pthread_create_gotcha::wrapper::operator()() const if(_active && !_coverage && !m_config.offset) { _tid = _info->index_data->sequent_value; - OMNITRACE_BASIC_VERBOSE(1, "[PID=%i][rank=%i] Thread %s (parent: %s) created\n", - process::get_id(), dmp::rank(), - _info->index_data->as_string().c_str(), - _parent_info->index_data->as_string().c_str()); + ROCPROFSYS_BASIC_VERBOSE(1, "[PID=%i][rank=%i] Thread %s (parent: %s) created\n", + process::get_id(), dmp::rank(), + _info->index_data->as_string().c_str(), + _parent_info->index_data->as_string().c_str()); threading::set_thread_name(TIMEMORY_JOIN(" ", "Thread", _tid).c_str()); auto _manager = tim::manager::instance(); if(_manager) _manager->initialize(); if(!thread_bundle_data_t::get()->at(_tid)) { thread_data::construct( - TIMEMORY_JOIN('/', "omnitrace/process", process::get_id(), "thread", + TIMEMORY_JOIN('/', "rocprofsys/process", process::get_id(), "thread", _tid), quirk::config{}); thread_bundle_data_t::get()->at(_tid)->start(); @@ -260,23 +260,23 @@ pthread_create_gotcha::wrapper::operator()() const causal::delay::get_local(_tid) = causal::delay::get_local(_parent_info->index_data->sequent_value); _is_sampling = true; - OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false); + ROCPROFSYS_SCOPED_SAMPLING_ON_CHILD_THREADS(false); _signals = causal::sampling::setup(); causal::sampling::unblock_signals(); } else if(m_config.enable_sampling) { _is_sampling = true; - OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false); + ROCPROFSYS_SCOPED_SAMPLING_ON_CHILD_THREADS(false); _signals = sampling::setup(); sampling::unblock_signals(); } } else if(m_config.offset) { - OMNITRACE_BASIC_VERBOSE( + ROCPROFSYS_BASIC_VERBOSE( 2, - "[PID=%i][rank=%i] Thread %s (parent: %s) created [started by omnitrace]\n", + "[PID=%i][rank=%i] Thread %s (parent: %s) created [started by rocprof-sys]\n", process::get_id(), dmp::rank(), _info->index_data->as_string().c_str(), _parent_info->index_data->as_string().c_str()); } @@ -292,7 +292,7 @@ pthread_create_gotcha::wrapper::operator()() const // execute the original function _ret = m_routine(m_arg); - if(get_state() < ::omnitrace::State::Finalized) + if(get_state() < ::rocprofsys::State::Finalized) { pop_thread_state(); @@ -322,7 +322,7 @@ pthread_create_gotcha::wrapper::wrap(void* _arg) } static thread_local auto _remover = scope::destructor{ []() { - if(get_state() >= omnitrace::State::Finalized) return; + if(get_state() >= rocprofsys::State::Finalized) return; // remove the handle even if original function aborts auto _lk = locking::atomic_lock{ native_handles_mutex }; native_handles.erase(pthread_self()); @@ -429,7 +429,7 @@ pthread_create_gotcha::shutdown() std::this_thread::sleep_for(std::chrono::milliseconds{ 50 }); } - OMNITRACE_CI_BASIC_FAIL( + ROCPROFSYS_CI_BASIC_FAIL( shutdown_signals_delivered != _expected_shutdown_signals_delivered, "Number of signals delivered (%zu) != expected number of signals delievered " "(%zu)", @@ -458,13 +458,13 @@ pthread_create_gotcha::shutdown() if(config::settings_are_configured()) { - OMNITRACE_VERBOSE(2 && _ndangling > 0, - "[pthread_create_gotcha] cleaned up %lu dangling bundles\n", - _ndangling); + ROCPROFSYS_VERBOSE(2 && _ndangling > 0, + "[pthread_create_gotcha] cleaned up %lu dangling bundles\n", + _ndangling); } else { - OMNITRACE_BASIC_VERBOSE( + ROCPROFSYS_BASIC_VERBOSE( 2 && _ndangling > 0, "[pthread_create_gotcha] cleaned up %lu dangling bundles\n", _ndangling); } @@ -515,10 +515,10 @@ pthread_create_gotcha::operator()(pthread_t* thread, const pthread_attr_t* attr, auto _enabled = (_thr_state == ThreadState::Enabled); auto _bundle = std::optional{}; auto _sample_child = sampling_enabled_on_child_threads(); - auto _active = (_glob_state == ::omnitrace::State::Active && !_disabled); - const auto& _info = thread_info::init(!_active || !_sample_child || _disabled); + auto _active = (_glob_state == ::rocprofsys::State::Active && !_disabled); + const auto& _info = thread_info::init(!_active || !_sample_child || _disabled); - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); auto _coverage = (_mode == Mode::Coverage); auto _use_sampling = config::get_use_sampling(); @@ -534,7 +534,7 @@ pthread_create_gotcha::operator()(pthread_t* thread, const pthread_attr_t* attr, get_env(TIMEMORY_SETTINGS_PREFIX "DEBUG_THREADING_GET_ID", false); auto _verbose = (debug_threading_get_id) ? 0 : 3; - OMNITRACE_VERBOSE( + ROCPROFSYS_VERBOSE( _verbose, "Creating new thread :: global_state=%s, thread_state=%s, mode=%s, active=%s, " "coverage=%s, use_causal=%s, use_sampling=%s, sample_children=%s, tid=%li, " @@ -557,15 +557,15 @@ pthread_create_gotcha::operator()(pthread_t* thread, const pthread_attr_t* attr, if(_active && !_disabled && !_info->is_offset) { - OMNITRACE_BASIC_VERBOSE(2, "[PID=%i][rank=%i] Starting new thread on %s...\n", - process::get_id(), dmp::rank(), - _info->index_data->as_string().c_str()); + ROCPROFSYS_BASIC_VERBOSE(2, "[PID=%i][rank=%i] Starting new thread on %s...\n", + process::get_id(), dmp::rank(), + _info->index_data->as_string().c_str()); } // ensure that cpu cid stack exists on the parent thread if active if(_active && !_coverage) { - OMNITRACE_DEBUG("blocking signals...\n"); + ROCPROFSYS_DEBUG("blocking signals...\n"); get_cpu_cid_stack(); } @@ -580,7 +580,7 @@ pthread_create_gotcha::operator()(pthread_t* thread, const pthread_attr_t* attr, // block the signals in entire process if(_enable_sampling && !_blocked.empty()) { - OMNITRACE_DEBUG("blocking signals...\n"); + ROCPROFSYS_DEBUG("blocking signals...\n"); tim::signals::block_signals(_blocked, tim::signals::sigmask_scope::process); } @@ -600,7 +600,7 @@ pthread_create_gotcha::operator()(pthread_t* thread, const pthread_attr_t* attr, // wait for thread to set promise if(_promise) { - OMNITRACE_DEBUG("waiting for child to signal it is setup...\n"); + ROCPROFSYS_DEBUG("waiting for child to signal it is setup...\n"); _promise->get_future().wait_for(std::chrono::milliseconds{ 500 }); } @@ -610,14 +610,14 @@ pthread_create_gotcha::operator()(pthread_t* thread, const pthread_attr_t* attr, // unblock the signals in the entire process if(_enable_sampling && !_blocked.empty()) { - OMNITRACE_DEBUG("unblocking signals...\n"); + ROCPROFSYS_DEBUG("unblocking signals...\n"); tim::signals::unblock_signals(_blocked, tim::signals::sigmask_scope::process); } - OMNITRACE_DEBUG("returning success...\n"); + ROCPROFSYS_DEBUG("returning success...\n"); return _ret; } } // namespace component -} // namespace omnitrace +} // namespace rocprofsys TIMEMORY_INITIALIZE_STORAGE(component::roctracer_data) diff --git a/source/lib/omnitrace/library/components/pthread_create_gotcha.hpp b/source/lib/rocprof-sys/library/components/pthread_create_gotcha.hpp similarity index 93% rename from source/lib/omnitrace/library/components/pthread_create_gotcha.hpp rename to source/lib/rocprof-sys/library/components/pthread_create_gotcha.hpp index 4cda99cb..9a162a12 100644 --- a/source/lib/omnitrace/library/components/pthread_create_gotcha.hpp +++ b/source/lib/rocprof-sys/library/components/pthread_create_gotcha.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -30,7 +30,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { struct pthread_gotcha; @@ -67,7 +67,7 @@ struct pthread_create_gotcha : tim::component::base wrapper_config m_config = {}; }; - OMNITRACE_DEFAULT_OBJECT(pthread_create_gotcha) + ROCPROFSYS_DEFAULT_OBJECT(pthread_create_gotcha) // string id for component static std::string label() { return "pthread_create_gotcha"; } @@ -84,7 +84,7 @@ struct pthread_create_gotcha : tim::component::base void set_data(wrappee_t); private: - friend struct ::omnitrace::pthread_gotcha; + friend struct ::rocprofsys::pthread_gotcha; static std::set get_native_handles(); @@ -95,4 +95,4 @@ using pthread_create_gotcha_t = tim::component::gotcha, pthread_create_gotcha>; } // namespace component -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/components/pthread_gotcha.cpp b/source/lib/rocprof-sys/library/components/pthread_gotcha.cpp similarity index 81% rename from source/lib/omnitrace/library/components/pthread_gotcha.cpp rename to source/lib/rocprof-sys/library/components/pthread_gotcha.cpp index aef2fd57..6cbcee33 100644 --- a/source/lib/omnitrace/library/components/pthread_gotcha.cpp +++ b/source/lib/rocprof-sys/library/components/pthread_gotcha.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -43,11 +43,11 @@ namespace tim namespace operation { template <> -struct stop +struct stop { - using type = omnitrace::component::pthread_create_gotcha_t; + using type = rocprofsys::component::pthread_create_gotcha_t; - OMNITRACE_DEFAULT_OBJECT(stop) + ROCPROFSYS_DEFAULT_OBJECT(stop) template explicit stop(type&, Args&&...) @@ -60,7 +60,7 @@ struct stop } // namespace operation } // namespace tim -namespace omnitrace +namespace rocprofsys { namespace { @@ -85,8 +85,8 @@ pthread_gotcha::configure() { if(!is_configured) { - ::omnitrace::component::pthread_create_gotcha::configure(); - ::omnitrace::component::pthread_mutex_gotcha::configure(); + ::rocprofsys::component::pthread_create_gotcha::configure(); + ::rocprofsys::component::pthread_mutex_gotcha::configure(); is_configured = true; } } @@ -96,8 +96,8 @@ pthread_gotcha::shutdown() { if(is_configured) { - ::omnitrace::component::pthread_mutex_gotcha::shutdown(); - ::omnitrace::component::pthread_create_gotcha::shutdown(); + ::rocprofsys::component::pthread_mutex_gotcha::shutdown(); + ::rocprofsys::component::pthread_create_gotcha::shutdown(); is_configured = false; } } @@ -118,6 +118,6 @@ pthread_gotcha::stop() std::set pthread_gotcha::get_native_handles() { - return ::omnitrace::component::pthread_create_gotcha::get_native_handles(); + return ::rocprofsys::component::pthread_create_gotcha::get_native_handles(); } -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/components/pthread_gotcha.hpp b/source/lib/rocprof-sys/library/components/pthread_gotcha.hpp similarity index 90% rename from source/lib/omnitrace/library/components/pthread_gotcha.hpp rename to source/lib/rocprof-sys/library/components/pthread_gotcha.hpp index 306a3d2a..7026a4dc 100644 --- a/source/lib/omnitrace/library/components/pthread_gotcha.hpp +++ b/source/lib/rocprof-sys/library/components/pthread_gotcha.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -30,13 +30,13 @@ #include #include -namespace omnitrace +namespace rocprofsys { struct pthread_gotcha : tim::component::base { using native_handle_t = std::thread::native_handle_type; - OMNITRACE_DEFAULT_OBJECT(pthread_gotcha) + ROCPROFSYS_DEFAULT_OBJECT(pthread_gotcha) // string id for component static std::string label() { return "pthread_gotcha"; } @@ -50,4 +50,4 @@ struct pthread_gotcha : tim::component::base static std::set get_native_handles(); }; -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/components/pthread_mutex_gotcha.cpp b/source/lib/rocprof-sys/library/components/pthread_mutex_gotcha.cpp similarity index 90% rename from source/lib/omnitrace/library/components/pthread_mutex_gotcha.cpp rename to source/lib/rocprof-sys/library/components/pthread_mutex_gotcha.cpp index ed9650a4..4cf19823 100644 --- a/source/lib/omnitrace/library/components/pthread_mutex_gotcha.cpp +++ b/source/lib/rocprof-sys/library/components/pthread_mutex_gotcha.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -36,7 +36,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace component { @@ -76,12 +76,12 @@ pthread_mutex_gotcha::get_hashes() else { if(_skip.count(i) > 0) continue; - OMNITRACE_VERBOSE( + ROCPROFSYS_VERBOSE( 1, "WARNING!!! pthread_mutex_gotcha tool id at index %zu was empty!\n", i); } - OMNITRACE_CI_FAIL( + ROCPROFSYS_CI_FAIL( _id.empty() || _init.at(i) == 0, "pthread_mutex_gotcha tool id at index %zu has no hash value\n", i); } @@ -183,7 +183,7 @@ pthread_mutex_gotcha::operator()(uintptr_t&&, int (*_callee)(Args...), { if(m_data) { - OMNITRACE_PRINT("Warning! nullptr to %s\n", m_data->tool_id.c_str()); + ROCPROFSYS_PRINT("Warning! nullptr to %s\n", m_data->tool_id.c_str()); } return EINVAL; } @@ -210,7 +210,7 @@ int pthread_mutex_gotcha::operator()(int (*_callee)(pthread_mutex_t*), pthread_mutex_t* _mutex) const { - if(get_state() != ::omnitrace::State::Active || m_protect) return (*_callee)(_mutex); + if(get_state() != ::rocprofsys::State::Active || m_protect) return (*_callee)(_mutex); return (*this)(reinterpret_cast(_mutex), _callee, _mutex); } @@ -218,7 +218,7 @@ int pthread_mutex_gotcha::operator()(int (*_callee)(pthread_spinlock_t*), pthread_spinlock_t* _lock) const { - if(get_state() != ::omnitrace::State::Active || m_protect) return (*_callee)(_lock); + if(get_state() != ::rocprofsys::State::Active || m_protect) return (*_callee)(_lock); return (*this)(reinterpret_cast(_lock), _callee, _lock); } @@ -226,7 +226,7 @@ int pthread_mutex_gotcha::operator()(int (*_callee)(pthread_rwlock_t*), pthread_rwlock_t* _lock) const { - if(get_state() != ::omnitrace::State::Active || m_protect) return (*_callee)(_lock); + if(get_state() != ::rocprofsys::State::Active || m_protect) return (*_callee)(_lock); return (*this)(reinterpret_cast(_lock), _callee, _lock); } @@ -234,7 +234,7 @@ int pthread_mutex_gotcha::operator()(int (*_callee)(pthread_barrier_t*), pthread_barrier_t* _barrier) const { - if(get_state() != ::omnitrace::State::Active || m_protect) + if(get_state() != ::rocprofsys::State::Active || m_protect) return (*_callee)(_barrier); return (*this)(reinterpret_cast(_barrier), _callee, _barrier); } @@ -243,7 +243,7 @@ int pthread_mutex_gotcha::operator()(int (*_callee)(pthread_t, void**), pthread_t _thr, void** _tinfo) const { - if(get_state() != ::omnitrace::State::Active || m_protect) + if(get_state() != ::rocprofsys::State::Active || m_protect) return (*_callee)(_thr, _tinfo); return (*this)(static_cast(threading::get_id()), _callee, _thr, _tinfo); } @@ -252,11 +252,11 @@ bool pthread_mutex_gotcha::is_disabled() { static thread_local const auto& _info = thread_info::get(); - return (!_info || _info->is_offset || get_state() != ::omnitrace::State::Active || + return (!_info || _info->is_offset || get_state() != ::rocprofsys::State::Active || get_thread_state() != ThreadState::Enabled); } } // namespace component -} // namespace omnitrace +} // namespace rocprofsys namespace tim { @@ -268,9 +268,9 @@ static_data::operator()( std::integral_constant, const component::gotcha_data& _data) const { using thread_data_t = - omnitrace::thread_data>; + rocprofsys::thread_data>; static thread_local auto& _v = - thread_data_t::instance(omnitrace::construct_on_thread{}, _data); + thread_data_t::instance(rocprofsys::construct_on_thread{}, _data); return *_v; } } // namespace policy diff --git a/source/lib/omnitrace/library/components/pthread_mutex_gotcha.hpp b/source/lib/rocprof-sys/library/components/pthread_mutex_gotcha.hpp similarity index 84% rename from source/lib/omnitrace/library/components/pthread_mutex_gotcha.hpp rename to source/lib/rocprof-sys/library/components/pthread_mutex_gotcha.hpp index 36ef1ae8..309f1eaf 100644 --- a/source/lib/omnitrace/library/components/pthread_mutex_gotcha.hpp +++ b/source/lib/rocprof-sys/library/components/pthread_mutex_gotcha.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -33,7 +33,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace component { @@ -44,7 +44,7 @@ struct pthread_mutex_gotcha : comp::base using hash_array_t = std::array; using gotcha_data_t = comp::gotcha_data; - OMNITRACE_DEFAULT_OBJECT(pthread_mutex_gotcha) + ROCPROFSYS_DEFAULT_OBJECT(pthread_mutex_gotcha) explicit pthread_mutex_gotcha(const gotcha_data_t&); @@ -75,17 +75,19 @@ struct pthread_mutex_gotcha : comp::base using pthread_mutex_gotcha_t = comp::gotcha, pthread_mutex_gotcha>; } // namespace component -} // namespace omnitrace +} // namespace rocprofsys -OMNITRACE_DEFINE_CONCRETE_TRAIT(fast_gotcha, component::pthread_mutex_gotcha_t, true_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(static_data, component::pthread_mutex_gotcha_t, true_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(fast_gotcha, component::pthread_mutex_gotcha_t, + true_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(static_data, component::pthread_mutex_gotcha_t, + true_type) namespace tim { namespace policy { -using pthread_mutex_gotcha = ::omnitrace::component::pthread_mutex_gotcha; -using pthread_mutex_gotcha_t = ::omnitrace::component::pthread_mutex_gotcha_t; +using pthread_mutex_gotcha = ::rocprofsys::component::pthread_mutex_gotcha; +using pthread_mutex_gotcha_t = ::rocprofsys::component::pthread_mutex_gotcha_t; template <> struct static_data : std::true_type diff --git a/source/lib/omnitrace/library/components/rcclp.cpp b/source/lib/rocprof-sys/library/components/rcclp.cpp similarity index 95% rename from source/lib/omnitrace/library/components/rcclp.cpp rename to source/lib/rocprof-sys/library/components/rcclp.cpp index fb4a611e..9fea7c20 100644 --- a/source/lib/omnitrace/library/components/rcclp.cpp +++ b/source/lib/rocprof-sys/library/components/rcclp.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -33,7 +33,7 @@ operator<<(std::ostream& _os, const ncclUniqueId& _v) return _os; } -namespace omnitrace +namespace rocprofsys { namespace component { @@ -123,7 +123,7 @@ configure_rcclp(const std::set& permit, const std::set auto _reject = reject; // check environment auto reject_list = - tim::get_env("OMNITRACE_RCCLP_REJECT_LIST", ""); + tim::get_env("ROCPROFSYS_RCCLP_REJECT_LIST", ""); // add environment setting for(const auto& itr : tim::delimit(reject_list)) _reject.insert(itr); @@ -135,7 +135,7 @@ configure_rcclp(const std::set& permit, const std::set auto _permit = permit; // check environment auto permit_list = - tim::get_env("OMNITRACE_RCCLP_PERMIT_LIST", ""); + tim::get_env("ROCPROFSYS_RCCLP_PERMIT_LIST", ""); // add environment setting for(const auto& itr : tim::delimit(permit_list)) _permit.insert(itr); @@ -192,4 +192,4 @@ rcclp_handle::get_tool_count() return get_persistent_data().m_count; } } // namespace component -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/components/rcclp.hpp b/source/lib/rocprof-sys/library/components/rcclp.hpp similarity index 82% rename from source/lib/omnitrace/library/components/rcclp.hpp rename to source/lib/rocprof-sys/library/components/rcclp.hpp index f0d6b029..957dec1c 100644 --- a/source/lib/omnitrace/library/components/rcclp.hpp +++ b/source/lib/rocprof-sys/library/components/rcclp.hpp @@ -40,24 +40,24 @@ #include #include -#if !defined(OMNITRACE_NUM_RCCLP_WRAPPERS) -# define OMNITRACE_NUM_RCCLP_WRAPPERS 25 +#if !defined(ROCPROFSYS_NUM_RCCLP_WRAPPERS) +# define ROCPROFSYS_NUM_RCCLP_WRAPPERS 25 #endif -OMNITRACE_COMPONENT_ALIAS( +ROCPROFSYS_COMPONENT_ALIAS( rccl_toolset_t, ::tim::component_bundle, + rocprofsys::component::category_region, comm_data>) -OMNITRACE_COMPONENT_ALIAS(rcclp_gotcha_t, - ::tim::component::gotcha) +ROCPROFSYS_COMPONENT_ALIAS(rcclp_gotcha_t, + ::tim::component::gotcha) -#if !defined(OMNITRACE_USE_RCCL) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_available, component::rcclp_gotcha_t, false_type) +#if !defined(ROCPROFSYS_USE_RCCL) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::rcclp_gotcha_t, false_type) #endif -namespace omnitrace +namespace rocprofsys { namespace component { @@ -73,7 +73,7 @@ configure_rcclp(const std::set& permit = {}, struct rcclp_handle : base { - static constexpr size_t rcclp_wrapper_count = OMNITRACE_NUM_RCCLP_WRAPPERS; + static constexpr size_t rcclp_wrapper_count = ROCPROFSYS_NUM_RCCLP_WRAPPERS; using value_type = void; using this_type = rcclp_handle; @@ -103,4 +103,4 @@ struct rcclp_handle : base static std::atomic& get_tool_count(); }; } // namespace component -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/components/rocprofiler.cpp b/source/lib/rocprof-sys/library/components/rocprofiler.cpp similarity index 88% rename from source/lib/omnitrace/library/components/rocprofiler.cpp rename to source/lib/rocprof-sys/library/components/rocprofiler.cpp index fce20e4c..0253436a 100644 --- a/source/lib/omnitrace/library/components/rocprofiler.cpp +++ b/source/lib/rocprof-sys/library/components/rocprofiler.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -43,7 +43,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace component { @@ -115,7 +115,7 @@ rocm_event::as_string() const _ss << std::fixed; for(size_t i = 0; i < feature_names.size(); ++i) { - auto _name = omnitrace::rocprofiler::get_data_labels().at(device_id).at( + auto _name = rocprofsys::rocprofiler::get_data_labels().at(device_id).at( feature_names.at(i)); _ss << ", " << _name << " = "; auto _as_string = [&_ss](auto&& itr) { _ss << std::setw(4) << itr; }; @@ -146,7 +146,7 @@ rocprofiler::stop() bool rocprofiler::is_setup() { - return omnitrace::rocprofiler::is_setup(); + return rocprofsys::rocprofiler::is_setup(); } void @@ -168,15 +168,15 @@ rocprofiler::remove_shutdown(const std::string&) void rocprofiler::setup() { - OMNITRACE_VERBOSE_F(1, "rocprofiler is setup\n"); + ROCPROFSYS_VERBOSE_F(1, "rocprofiler is setup\n"); } void rocprofiler::shutdown() { - omnitrace::rocprofiler::post_process(); - omnitrace::rocprofiler::rocm_cleanup(); - OMNITRACE_VERBOSE_F(1, "rocprofiler is shutdown\n"); + rocprofsys::rocprofiler::post_process(); + rocprofsys::rocprofiler::rocm_cleanup(); + ROCPROFSYS_VERBOSE_F(1, "rocprofiler is shutdown\n"); } scope::transient_destructor @@ -186,8 +186,8 @@ rocprofiler::protect_flush_activity() []() { ++rocprofiler_activity_count(); }); } } // namespace component -} // namespace omnitrace +} // namespace rocprofsys -OMNITRACE_INSTANTIATE_EXTERN_COMPONENT(rocprofiler, false, void) -OMNITRACE_INSTANTIATE_EXTERN_COMPONENT(rocprofiler_data, true, - tim::component::rocprofiler_value) +ROCPROFSYS_INSTANTIATE_EXTERN_COMPONENT(rocprofiler, false, void) +ROCPROFSYS_INSTANTIATE_EXTERN_COMPONENT(rocprofiler_data, true, + tim::component::rocprofiler_value) diff --git a/source/lib/omnitrace/library/components/rocprofiler.hpp b/source/lib/rocprof-sys/library/components/rocprofiler.hpp similarity index 81% rename from source/lib/omnitrace/library/components/rocprofiler.hpp rename to source/lib/rocprof-sys/library/components/rocprofiler.hpp index 27f7df8c..27326e9d 100644 --- a/source/lib/omnitrace/library/components/rocprofiler.hpp +++ b/source/lib/rocprof-sys/library/components/rocprofiler.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -47,7 +47,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace component { @@ -57,7 +57,7 @@ using rocm_feature_value = std::variant; struct rocm_counter { - std::array counters; + std::array counters; }; struct rocm_event @@ -95,7 +95,7 @@ struct rocm_event using rocm_data_t = std::vector; using rocm_data_tracker = data_tracker; -omnitrace::unique_ptr_t& +rocprofsys::unique_ptr_t& rocm_data(int64_t _tid = threading::get_id()); using rocprofiler_value = typename rocm_event::value_type; @@ -109,7 +109,7 @@ struct rocprofiler using base_type = base; using tracker_type = policy::instance_tracker; - OMNITRACE_DEFAULT_OBJECT(rocprofiler) + ROCPROFSYS_DEFAULT_OBJECT(rocprofiler) static void preinit(); static void global_init() { setup(); } @@ -127,11 +127,11 @@ struct rocprofiler void stop(); // this function protects rocprofiler_flush_activty from being called - // when omnitrace exits during a callback + // when rocprof-sys exits during a callback [[nodiscard]] static scope::transient_destructor protect_flush_activity(); }; -#if !defined(OMNITRACE_USE_ROCPROFILER) +#if !defined(ROCPROFSYS_USE_ROCPROFILER) inline void rocprofiler::setup() {} @@ -147,16 +147,16 @@ rocprofiler::is_setup() } #endif } // namespace component -} // namespace omnitrace +} // namespace rocprofsys namespace tim { namespace component { -using ::omnitrace::component::rocm_data_tracker; -using ::omnitrace::component::rocm_feature_value; -using ::omnitrace::component::rocprofiler_data; -using ::omnitrace::component::rocprofiler_value; +using ::rocprofsys::component::rocm_data_tracker; +using ::rocprofsys::component::rocm_feature_value; +using ::rocprofsys::component::rocprofiler_data; +using ::rocprofsys::component::rocprofiler_value; } // namespace component } // namespace tim @@ -173,7 +173,7 @@ struct set_storage using storage_array_t = std::array*, max_threads>; friend struct get_storage; - OMNITRACE_DEFAULT_OBJECT(set_storage) + ROCPROFSYS_DEFAULT_OBJECT(set_storage) auto operator()(storage*, size_t) const {} auto operator()(type&, size_t) const {} @@ -192,7 +192,7 @@ struct get_storage { using type = component::rocm_data_tracker; - OMNITRACE_DEFAULT_OBJECT(get_storage) + ROCPROFSYS_DEFAULT_OBJECT(get_storage) auto operator()(const type&) const { @@ -215,27 +215,27 @@ struct get_storage } // namespace operation } // namespace tim -#if !defined(OMNITRACE_USE_ROCPROFILER) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_available, component::rocprofiler_data, false_type) +#if !defined(ROCPROFSYS_USE_ROCPROFILER) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::rocprofiler_data, false_type) #endif TIMEMORY_SET_COMPONENT_API(component::rocprofiler_data, project::timemory, category::timing, os::supports_unix) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_timing_category, component::rocprofiler_data, - false_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(uses_timing_units, component::rocprofiler_data, - false_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(report_units, component::rocprofiler_data, false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_timing_category, component::rocprofiler_data, + false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(uses_timing_units, component::rocprofiler_data, + false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(report_units, component::rocprofiler_data, false_type) TIMEMORY_STATISTICS_TYPE(component::rocprofiler_data, component::rocprofiler_value) TIMEMORY_STATISTICS_TYPE(component::rocm_data_tracker, component::rocm_feature_value) -OMNITRACE_DEFINE_CONCRETE_TRAIT(report_units, component::rocm_data_tracker, false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(report_units, component::rocm_data_tracker, false_type) -#if !defined(OMNITRACE_EXTERN_COMPONENTS) || \ - (defined(OMNITRACE_EXTERN_COMPONENTS) && OMNITRACE_EXTERN_COMPONENTS > 0) +#if !defined(ROCPROFSYS_EXTERN_COMPONENTS) || \ + (defined(ROCPROFSYS_EXTERN_COMPONENTS) && ROCPROFSYS_EXTERN_COMPONENTS > 0) # include -OMNITRACE_DECLARE_EXTERN_COMPONENT(rocprofiler, false, void) -OMNITRACE_DECLARE_EXTERN_COMPONENT(rocprofiler_data, true, double) +ROCPROFSYS_DECLARE_EXTERN_COMPONENT(rocprofiler, false, void) +ROCPROFSYS_DECLARE_EXTERN_COMPONENT(rocprofiler_data, true, double) #endif diff --git a/source/lib/omnitrace/library/components/roctracer.cpp b/source/lib/rocprof-sys/library/components/roctracer.cpp similarity index 74% rename from source/lib/omnitrace/library/components/roctracer.cpp rename to source/lib/rocprof-sys/library/components/roctracer.cpp index a419e46d..29ba1838 100644 --- a/source/lib/omnitrace/library/components/roctracer.cpp +++ b/source/lib/rocprof-sys/library/components/roctracer.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -40,14 +40,14 @@ #include #include -#if OMNITRACE_HIP_VERSION < 50300 +#if ROCPROFSYS_HIP_VERSION < 50300 # include #endif #define AMD_INTERNAL_BUILD 1 #include -namespace omnitrace +namespace rocprofsys { namespace component { @@ -135,24 +135,24 @@ roctracer::setup(void* table, bool on_load_trace) if(roctracer_is_setup()) return; roctracer_is_setup() = true; - OMNITRACE_VERBOSE_F(1, "setting up roctracer...\n"); - OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false); + ROCPROFSYS_VERBOSE_F(1, "setting up roctracer...\n"); + ROCPROFSYS_SCOPED_SAMPLING_ON_CHILD_THREADS(false); - dynamic_library _amdhip64{ "OMNITRACE_ROCTRACER_LIBAMDHIP64", + dynamic_library _amdhip64{ "ROCPROFSYS_ROCTRACER_LIBAMDHIP64", find_library_path("libamdhip64.so", - { "OMNITRACE_ROCM_PATH", "ROCM_PATH" }, - { OMNITRACE_DEFAULT_ROCM_PATH }) }; + { "ROCPROFSYS_ROCM_PATH", "ROCM_PATH" }, + { ROCPROFSYS_DEFAULT_ROCM_PATH }) }; -#if OMNITRACE_HIP_VERSION_MAJOR == 4 && OMNITRACE_HIP_VERSION_MINOR < 4 +#if ROCPROFSYS_HIP_VERSION_MAJOR == 4 && ROCPROFSYS_HIP_VERSION_MINOR < 4 dynamic_library _kfdwrapper{ - "OMNITRACE_ROCTRACER_LIBKFDWRAPPER", - find_library_path("libkfdwrapper64.so", { "OMNITRACE_ROCM_PATH", "ROCM_PATH" }, - { OMNITRACE_DEFAULT_ROCM_PATH }, + "ROCPROFSYS_ROCTRACER_LIBKFDWRAPPER", + find_library_path("libkfdwrapper64.so", { "ROCPROFSYS_ROCM_PATH", "ROCM_PATH" }, + { ROCPROFSYS_DEFAULT_ROCM_PATH }, { "roctracer/lib", "roctracer/lib64", "lib", "lib64" }) }; #endif - OMNITRACE_ROCTRACER_CALL(roctracer_set_properties(ACTIVITY_DOMAIN_HIP_API, nullptr)); + ROCPROFSYS_ROCTRACER_CALL(roctracer_set_properties(ACTIVITY_DOMAIN_HIP_API, nullptr)); // Allocating tracing pool roctracer_properties_t properties{}; @@ -160,9 +160,9 @@ roctracer::setup(void* table, bool on_load_trace) // properties.mode = 0x1000; properties.buffer_size = 0x100; properties.buffer_callback_fun = hip_activity_callback; - OMNITRACE_ROCTRACER_CALL(roctracer_open_pool(&properties)); + ROCPROFSYS_ROCTRACER_CALL(roctracer_open_pool(&properties)); -#if OMNITRACE_HIP_VERSION_MAJOR == 4 && OMNITRACE_HIP_VERSION_MINOR >= 4 +#if ROCPROFSYS_HIP_VERSION_MAJOR == 4 && ROCPROFSYS_HIP_VERSION_MINOR >= 4 // HIP 4.5.0 has an invalid warning redirect _rd{ std::cerr, "roctracer_enable_callback(), get_op_end(), invalid domain " "ID(4) in: roctracer_enable_callback(hip_api_callback, " @@ -172,26 +172,26 @@ roctracer::setup(void* table, bool on_load_trace) if(get_trace_hip_api()) { - OMNITRACE_ROCTRACER_CALL(roctracer_enable_domain_callback( + ROCPROFSYS_ROCTRACER_CALL(roctracer_enable_domain_callback( ACTIVITY_DOMAIN_HIP_API, hip_api_callback, nullptr)); } if(get_use_roctx()) { - OMNITRACE_ROCTRACER_CALL(roctracer_enable_domain_callback( + ROCPROFSYS_ROCTRACER_CALL(roctracer_enable_domain_callback( ACTIVITY_DOMAIN_ROCTX, roctx_api_callback, nullptr)); } if(get_trace_hip_activity()) { // Enable HIP activity tracing - OMNITRACE_ROCTRACER_CALL( + ROCPROFSYS_ROCTRACER_CALL( roctracer_enable_domain_activity(ACTIVITY_DOMAIN_HIP_OPS)); } if(table != nullptr) { - OMNITRACE_VERBOSE(1 || on_load_trace, "[OnLoad] setting up HSA...\n"); + ROCPROFSYS_VERBOSE(1 || on_load_trace, "[OnLoad] setting up HSA...\n"); bool trace_hsa_api = get_trace_hsa_api(); @@ -211,20 +211,20 @@ roctracer::setup(void* table, bool on_load_trace) { uint32_t cid = HSA_API_ID_NUMBER; const char* api = itr.c_str(); - OMNITRACE_ROCTRACER_CALL(roctracer_op_code( + ROCPROFSYS_ROCTRACER_CALL(roctracer_op_code( static_cast(ACTIVITY_DOMAIN_HSA_API), api, &cid, nullptr)); - OMNITRACE_ROCTRACER_CALL(roctracer_enable_op_callback( + ROCPROFSYS_ROCTRACER_CALL(roctracer_enable_op_callback( static_cast(ACTIVITY_DOMAIN_HSA_API), cid, hsa_api_callback, nullptr)); - OMNITRACE_VERBOSE(1 || on_load_trace, " HSA-trace(%s)", api); + ROCPROFSYS_VERBOSE(1 || on_load_trace, " HSA-trace(%s)", api); } } else { - OMNITRACE_VERBOSE(1 || on_load_trace, " HSA-trace()\n"); - OMNITRACE_ROCTRACER_CALL(roctracer_enable_domain_callback( + ROCPROFSYS_VERBOSE(1 || on_load_trace, " HSA-trace()\n"); + ROCPROFSYS_ROCTRACER_CALL(roctracer_enable_domain_callback( static_cast(ACTIVITY_DOMAIN_HSA_API), hsa_api_callback, nullptr)); } @@ -234,7 +234,7 @@ roctracer::setup(void* table, bool on_load_trace) // Enable HSA GPU activity if(trace_hsa_activity) { -#if OMNITRACE_HIP_VERSION < 50300 +#if ROCPROFSYS_HIP_VERSION < 50300 using namespace roctracer; // initialize HSA tracing const char* output_prefix = nullptr; @@ -242,7 +242,7 @@ roctracer::setup(void* table, bool on_load_trace) table, reinterpret_cast(hsa_activity_callback), nullptr, output_prefix }; -#elif OMNITRACE_HIP_VERSION < 50301 +#elif ROCPROFSYS_HIP_VERSION < 50301 hsa_ops_properties_t ops_properties; ops_properties.table = table; ops_properties.reserved1[0] = reinterpret_cast(&hsa_activity_callback); @@ -256,8 +256,8 @@ roctracer::setup(void* table, bool on_load_trace) roctracer_set_properties( static_cast(ACTIVITY_DOMAIN_HSA_OPS), &ops_properties); - OMNITRACE_VERBOSE(1 || on_load_trace, " HSA-activity-trace()\n"); - OMNITRACE_ROCTRACER_CALL(roctracer_enable_op_activity( + ROCPROFSYS_VERBOSE(1 || on_load_trace, " HSA-activity-trace()\n"); + ROCPROFSYS_ROCTRACER_CALL(roctracer_enable_op_activity( static_cast(ACTIVITY_DOMAIN_HSA_OPS), HSA_OP_ID_COPY)); } } @@ -270,7 +270,7 @@ roctracer::setup(void* table, bool on_load_trace) for(size_t i = 0; i < thread_info::get_peak_num_threads(); ++i) hip_exec_activity_callbacks(i); - OMNITRACE_VERBOSE_F(1, "roctracer is setup\n"); + ROCPROFSYS_VERBOSE_F(1, "roctracer is setup\n"); } void @@ -287,27 +287,27 @@ roctracer::flush() if(roctracer_activity_count() == 0) { - OMNITRACE_VERBOSE_F(2, "executing roctracer_flush_activity()...\n"); - OMNITRACE_ROCTRACER_CALL(roctracer_flush_activity()); + ROCPROFSYS_VERBOSE_F(2, "executing roctracer_flush_activity()...\n"); + ROCPROFSYS_ROCTRACER_CALL(roctracer_flush_activity()); // wait to make sure flush completes std::this_thread::sleep_for(std::chrono::milliseconds{ 100 }); wait_for_activity_flush_completion(); } else { - OMNITRACE_CI_FAIL(true, - "roctracer_activity_count() != 0 (== %li). " - "roctracer::shutdown() most likely called during abort", - roctracer_activity_count().load()); + ROCPROFSYS_CI_FAIL(true, + "roctracer_activity_count() != 0 (== %li). " + "roctracer::shutdown() most likely called during abort", + roctracer_activity_count().load()); } - OMNITRACE_VERBOSE_F(2, "executing hip_exec_activity_callbacks(0..%zu)\n", - thread_info::get_peak_num_threads()); + ROCPROFSYS_VERBOSE_F(2, "executing hip_exec_activity_callbacks(0..%zu)\n", + thread_info::get_peak_num_threads()); // make sure all async operations are executed for(size_t i = 0; i < thread_info::get_peak_num_threads(); ++i) hip_exec_activity_callbacks(i); - OMNITRACE_VERBOSE_F(2, "roctracer flush completed\n"); + ROCPROFSYS_VERBOSE_F(2, "roctracer flush completed\n"); } void @@ -318,16 +318,16 @@ roctracer::shutdown() roctracer_is_setup() = false; - OMNITRACE_VERBOSE_F(1, "shutting down roctracer...\n"); + ROCPROFSYS_VERBOSE_F(1, "shutting down roctracer...\n"); // callback for hsa - OMNITRACE_VERBOSE_F(2, "executing %zu roctracer_shutdown_routines...\n", - roctracer_shutdown_routines().size()); + ROCPROFSYS_VERBOSE_F(2, "executing %zu roctracer_shutdown_routines...\n", + roctracer_shutdown_routines().size()); for(auto& itr : roctracer_shutdown_routines()) itr.second(); -#if OMNITRACE_HIP_VERSION_MAJOR == 4 && OMNITRACE_HIP_VERSION_MINOR >= 4 - OMNITRACE_DEBUG_F("redirecting roctracer warnings\n"); +#if ROCPROFSYS_HIP_VERSION_MAJOR == 4 && ROCPROFSYS_HIP_VERSION_MINOR >= 4 + ROCPROFSYS_DEBUG_F("redirecting roctracer warnings\n"); // HIP 4.5.0 has an invalid warning redirect _rd{ std::cerr, "roctracer_disable_callback(), get_op_end(), invalid domain ID(4) " @@ -338,49 +338,49 @@ roctracer::shutdown() if(get_trace_hip_api()) { - OMNITRACE_VERBOSE_F( + ROCPROFSYS_VERBOSE_F( 2, "executing roctracer_disable_domain_callback(ACTIVITY_DOMAIN_HIP_API)...\n"); - OMNITRACE_ROCTRACER_CALL( + ROCPROFSYS_ROCTRACER_CALL( roctracer_disable_domain_callback(ACTIVITY_DOMAIN_HIP_API)); } if(get_use_roctx()) { - OMNITRACE_VERBOSE_F( + ROCPROFSYS_VERBOSE_F( 2, "executing roctracer_disable_domain_activity(ACTIVITY_DOMAIN_ROCTX)...\n"); - OMNITRACE_ROCTRACER_CALL( + ROCPROFSYS_ROCTRACER_CALL( roctracer_disable_domain_callback(ACTIVITY_DOMAIN_ROCTX)); } if(get_trace_hip_activity()) { - OMNITRACE_VERBOSE_F( + ROCPROFSYS_VERBOSE_F( 2, "executing roctracer_disable_domain_activity(ACTIVITY_DOMAIN_HIP_OPS)...\n"); - OMNITRACE_ROCTRACER_CALL( + ROCPROFSYS_ROCTRACER_CALL( roctracer_disable_domain_activity(ACTIVITY_DOMAIN_HIP_OPS)); } if(get_trace_hsa_api()) { - OMNITRACE_VERBOSE_F( + ROCPROFSYS_VERBOSE_F( 2, "executing roctracer_disable_domain_activity(ACTIVITY_DOMAIN_HSA_API)...\n"); - OMNITRACE_ROCTRACER_CALL( + ROCPROFSYS_ROCTRACER_CALL( roctracer_disable_domain_callback(ACTIVITY_DOMAIN_HSA_API)); } if(get_trace_hsa_api()) { - OMNITRACE_VERBOSE_F( + ROCPROFSYS_VERBOSE_F( 2, "executing roctracer_disable_op_activity(ACTIVITY_DOMAIN_HSA_OPS, " "HSA_OP_ID_COPY)...\n"); - OMNITRACE_ROCTRACER_CALL( + ROCPROFSYS_ROCTRACER_CALL( roctracer_disable_op_activity(ACTIVITY_DOMAIN_HSA_OPS, HSA_OP_ID_COPY)); } - OMNITRACE_VERBOSE_F(1, "roctracer is shutdown\n"); + ROCPROFSYS_VERBOSE_F(1, "roctracer is shutdown\n"); } scope::transient_destructor @@ -390,7 +390,7 @@ roctracer::protect_flush_activity() []() { ++roctracer_activity_count(); }); } } // namespace component -} // namespace omnitrace +} // namespace rocprofsys -OMNITRACE_INSTANTIATE_EXTERN_COMPONENT(roctracer, false, void) -OMNITRACE_INSTANTIATE_EXTERN_COMPONENT(roctracer_data, true, double) +ROCPROFSYS_INSTANTIATE_EXTERN_COMPONENT(roctracer, false, void) +ROCPROFSYS_INSTANTIATE_EXTERN_COMPONENT(roctracer_data, true, double) diff --git a/source/lib/omnitrace/library/components/roctracer.hpp b/source/lib/rocprof-sys/library/components/roctracer.hpp similarity index 72% rename from source/lib/omnitrace/library/components/roctracer.hpp rename to source/lib/rocprof-sys/library/components/roctracer.hpp index 5423f0d0..93c9f605 100644 --- a/source/lib/omnitrace/library/components/roctracer.hpp +++ b/source/lib/rocprof-sys/library/components/roctracer.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -36,10 +36,10 @@ #include #include -OMNITRACE_COMPONENT_ALIAS(roctracer_data, - ::tim::component::data_tracker) +ROCPROFSYS_COMPONENT_ALIAS(roctracer_data, + ::tim::component::data_tracker) -namespace omnitrace +namespace rocprofsys { namespace component { @@ -51,7 +51,7 @@ struct roctracer using base_type = base; using tracker_type = policy::instance_tracker; - OMNITRACE_DEFAULT_OBJECT(roctracer) + ROCPROFSYS_DEFAULT_OBJECT(roctracer) static void preinit(); static void global_finalize() { shutdown(); } @@ -69,11 +69,11 @@ struct roctracer void stop(); // this function protects roctracer_flush_activty from being called - // when omnitrace exits during a callback + // when rocprof-sys exits during a callback [[nodiscard]] static scope::transient_destructor protect_flush_activity(); }; -#if !defined(OMNITRACE_USE_ROCTRACER) +#if !defined(ROCPROFSYS_USE_ROCTRACER) inline void roctracer::setup(void*, bool) {} @@ -93,25 +93,25 @@ roctracer::is_setup() } #endif } // namespace component -} // namespace omnitrace +} // namespace rocprofsys -#if !defined(OMNITRACE_USE_ROCTRACER) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_available, component::roctracer_data, false_type) +#if !defined(ROCPROFSYS_USE_ROCTRACER) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_available, component::roctracer_data, false_type) #endif -TIMEMORY_SET_COMPONENT_API(omnitrace::component::roctracer_data, project::timemory, +TIMEMORY_SET_COMPONENT_API(rocprofsys::component::roctracer_data, project::timemory, category::timing, os::supports_unix) -OMNITRACE_DEFINE_CONCRETE_TRAIT(is_timing_category, component::roctracer_data, true_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(uses_timing_units, component::roctracer_data, true_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(is_timing_category, component::roctracer_data, true_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(uses_timing_units, component::roctracer_data, true_type) -#if defined(OMNITRACE_USE_ROCTRACER) && OMNITRACE_USE_ROCTRACER > 0 -# if !defined(OMNITRACE_EXTERN_COMPONENTS) || \ - (defined(OMNITRACE_EXTERN_COMPONENTS) && OMNITRACE_EXTERN_COMPONENTS > 0) +#if defined(ROCPROFSYS_USE_ROCTRACER) && ROCPROFSYS_USE_ROCTRACER > 0 +# if !defined(ROCPROFSYS_EXTERN_COMPONENTS) || \ + (defined(ROCPROFSYS_EXTERN_COMPONENTS) && ROCPROFSYS_EXTERN_COMPONENTS > 0) # include -OMNITRACE_DECLARE_EXTERN_COMPONENT(roctracer, false, void) -OMNITRACE_DECLARE_EXTERN_COMPONENT(roctracer_data, true, double) +ROCPROFSYS_DECLARE_EXTERN_COMPONENT(roctracer, false, void) +ROCPROFSYS_DECLARE_EXTERN_COMPONENT(roctracer_data, true, double) # endif #endif diff --git a/source/lib/omnitrace/library/coverage.cpp b/source/lib/rocprof-sys/library/coverage.cpp similarity index 81% rename from source/lib/omnitrace/library/coverage.cpp rename to source/lib/rocprof-sys/library/coverage.cpp index c8ec4311..12749f97 100644 --- a/source/lib/omnitrace/library/coverage.cpp +++ b/source/lib/rocprof-sys/library/coverage.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -39,10 +39,10 @@ #include #include -#define OMNITRACE_SERIALIZE(MEMBER_VARIABLE) \ +#define ROCPROFSYS_SERIALIZE(MEMBER_VARIABLE) \ ar(::tim::cereal::make_nvp(#MEMBER_VARIABLE, MEMBER_VARIABLE)) -namespace omnitrace +namespace rocprofsys { namespace coverage { @@ -61,7 +61,7 @@ using coverage_data_map = uomap_t>>; // using coverage_thread_data = - omnitrace::thread_data; + rocprofsys::thread_data; // auto& get_code_coverage() @@ -108,7 +108,7 @@ post_process() if(_coverage.size == 0) { - OMNITRACE_VERBOSE_F( + ROCPROFSYS_VERBOSE_F( 0, "Warning! Code coverage enabled but no code coverage data is available!\n"); return; @@ -150,11 +150,11 @@ post_process() } else { - OMNITRACE_VERBOSE_F(0, - "Warning! No matching coverage data for " - "%s :: %s (0x%x)\n", - func.first.data(), file.first.data(), - (unsigned int) addr.first); + ROCPROFSYS_VERBOSE_F(0, + "Warning! No matching coverage data for " + "%s :: %s (0x%x)\n", + func.first.data(), file.first.data(), + (unsigned int) addr.first); } } } @@ -208,11 +208,11 @@ post_process() std::swap(_coverage_data, _tmp); } - OMNITRACE_VERBOSE(0, "code coverage :: %6.2f%s\n", _coverage() * 100.0, "%"); - OMNITRACE_VERBOSE(0, "module coverage :: %6.2f%s\n", - _coverage(code_coverage::MODULE) * 100.0, "%"); - OMNITRACE_VERBOSE(0, "function coverage :: %6.2f%s\n", - _coverage(code_coverage::FUNCTION) * 100.0, "%"); + ROCPROFSYS_VERBOSE(0, "code coverage :: %6.2f%s\n", _coverage() * 100.0, "%"); + ROCPROFSYS_VERBOSE(0, "module coverage :: %6.2f%s\n", + _coverage(code_coverage::MODULE) * 100.0, "%"); + ROCPROFSYS_VERBOSE(0, "function coverage :: %6.2f%s\n", + _coverage(code_coverage::FUNCTION) * 100.0, "%"); if(get_verbose() >= 0) fprintf(stderr, "\n"); @@ -221,12 +221,13 @@ post_process() auto _get_setting = [](const std::string& _v) { auto&& _b = config::get_setting_value(_v); - OMNITRACE_CI_THROW(!_b, "Error! No configuration setting named '%s'", _v.c_str()); + ROCPROFSYS_CI_THROW(!_b, "Error! No configuration setting named '%s'", + _v.c_str()); return _b.value_or(true); }; - auto _text_output = _get_setting("OMNITRACE_TEXT_OUTPUT"); - auto _json_output = _get_setting("OMNITRACE_JSON_OUTPUT"); + auto _text_output = _get_setting("ROCPROFSYS_TEXT_OUTPUT"); + auto _json_output = _get_setting("ROCPROFSYS_JSON_OUTPUT"); if(_text_output) { @@ -254,7 +255,7 @@ post_process() } else { - OMNITRACE_THROW("Error opening coverage output file: %s", _fname.c_str()); + ROCPROFSYS_THROW("Error opening coverage output file: %s", _fname.c_str()); } } @@ -266,7 +267,7 @@ post_process() auto ar = tim::policy::output_archive::get(oss); - ar->setNextName("omnitrace"); + ar->setNextName("rocprofsys"); ar->startNode(); ar->setNextName("coverage"); ar->startNode(); @@ -286,29 +287,29 @@ post_process() } else { - OMNITRACE_THROW("Error opening coverage output file: %s", _fname.c_str()); + ROCPROFSYS_THROW("Error opening coverage output file: %s", _fname.c_str()); } } if(get_verbose() >= 0) fprintf(stderr, "\n"); } } // namespace coverage -} // namespace omnitrace +} // namespace rocprofsys //--------------------------------------------------------------------------------------// -namespace coverage = omnitrace::coverage; +namespace coverage = rocprofsys::coverage; extern "C" void -omnitrace_register_source_hidden(const char* file, const char* func, size_t line, - size_t address, const char* source) +rocprofsys_register_source_hidden(const char* file, const char* func, size_t line, + size_t address, const char* source) { if(coverage::get_post_processed()) return; using coverage_data = coverage::coverage_data; - OMNITRACE_BASIC_VERBOSE_F(4, "[0x%x] :: %-20s :: %20s:%zu :: %s\n", - (unsigned int) address, func, file, line, source); + ROCPROFSYS_BASIC_VERBOSE_F(4, "[0x%x] :: %-20s :: %20s:%zu :: %s\n", + (unsigned int) address, func, file, line, source); coverage::get_coverage_data().emplace_back( coverage_data{ size_t{ 0 }, address, line, file, func, @@ -329,17 +330,17 @@ omnitrace_register_source_hidden(const char* file, const char* func, size_t line //--------------------------------------------------------------------------------------// extern "C" void -omnitrace_register_coverage_hidden(const char* file, const char* func, size_t address) +rocprofsys_register_coverage_hidden(const char* file, const char* func, size_t address) { if(coverage::get_post_processed()) return; - if(omnitrace::get_state() < omnitrace::State::Active && - !omnitrace_init_tooling_hidden()) + if(rocprofsys::get_state() < rocprofsys::State::Active && + !rocprofsys_init_tooling_hidden()) return; - else if(omnitrace::get_state() >= omnitrace::State::Finalized) + else if(rocprofsys::get_state() >= rocprofsys::State::Finalized) return; - OMNITRACE_BASIC_VERBOSE_F(3, "[0x%x] %-20s :: %20s\n", (unsigned int) address, func, - file); + ROCPROFSYS_BASIC_VERBOSE_F(3, "[0x%x] %-20s :: %20s\n", (unsigned int) address, func, + file); (*coverage::get_coverage_count())[file][func][address] += 1; } diff --git a/source/lib/omnitrace/library/coverage.hpp b/source/lib/rocprof-sys/library/coverage.hpp similarity index 86% rename from source/lib/omnitrace/library/coverage.hpp rename to source/lib/rocprof-sys/library/coverage.hpp index 9dcfc31e..0175f600 100644 --- a/source/lib/omnitrace/library/coverage.hpp +++ b/source/lib/rocprof-sys/library/coverage.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -30,16 +30,16 @@ #include #include -#if !defined(OMNITRACE_SERIALIZE) -# define OMNITRACE_SERIALIZE(MEMBER_VARIABLE) \ +#if !defined(ROCPROFSYS_SERIALIZE) +# define ROCPROFSYS_SERIALIZE(MEMBER_VARIABLE) \ ar(::tim::cereal::make_nvp(#MEMBER_VARIABLE, MEMBER_VARIABLE)) #endif -namespace omnitrace +namespace rocprofsys { namespace coverage { -#if !defined(OMNITRACE_PYBIND11_SOURCE) || OMNITRACE_PYBIND11_SOURCE == 0 +#if !defined(ROCPROFSYS_PYBIND11_SOURCE) || ROCPROFSYS_PYBIND11_SOURCE == 0 void post_process(); #endif @@ -97,10 +97,10 @@ template void code_coverage::serialize(ArchiveT& ar, const unsigned version) { - OMNITRACE_SERIALIZE(count); - OMNITRACE_SERIALIZE(size); - OMNITRACE_SERIALIZE(covered); - OMNITRACE_SERIALIZE(possible); + ROCPROFSYS_SERIALIZE(count); + ROCPROFSYS_SERIALIZE(size); + ROCPROFSYS_SERIALIZE(covered); + ROCPROFSYS_SERIALIZE(possible); if constexpr(tim::concepts::is_output_archive::value) { ar.setNextName("coverage"); @@ -118,9 +118,9 @@ template void code_coverage::data::serialize(ArchiveT& ar, const unsigned version) { - OMNITRACE_SERIALIZE(addresses); - OMNITRACE_SERIALIZE(modules); - OMNITRACE_SERIALIZE(functions); + ROCPROFSYS_SERIALIZE(addresses); + ROCPROFSYS_SERIALIZE(modules); + ROCPROFSYS_SERIALIZE(functions); (void) version; } @@ -160,14 +160,14 @@ template void coverage_data::serialize(ArchiveT& ar, const unsigned version) { - OMNITRACE_SERIALIZE(count); - OMNITRACE_SERIALIZE(line); - OMNITRACE_SERIALIZE(address); - OMNITRACE_SERIALIZE(module); - OMNITRACE_SERIALIZE(function); - OMNITRACE_SERIALIZE(source); + ROCPROFSYS_SERIALIZE(count); + ROCPROFSYS_SERIALIZE(line); + ROCPROFSYS_SERIALIZE(address); + ROCPROFSYS_SERIALIZE(module); + ROCPROFSYS_SERIALIZE(function); + ROCPROFSYS_SERIALIZE(source); (void) version; } // } // namespace coverage -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/rocprof-sys/library/coverage/CMakeLists.txt b/source/lib/rocprof-sys/library/coverage/CMakeLists.txt new file mode 100644 index 00000000..bfd775fb --- /dev/null +++ b/source/lib/rocprof-sys/library/coverage/CMakeLists.txt @@ -0,0 +1,6 @@ +# +set(coverage_sources) +set(coverage_headers ${CMAKE_CURRENT_LIST_DIR}/impl.hpp) + +target_sources(rocprofiler-systems-object-library PRIVATE ${coverage_sources} + ${coverage_headers}) diff --git a/source/lib/omnitrace/library/coverage/impl.hpp b/source/lib/rocprof-sys/library/coverage/impl.hpp similarity index 97% rename from source/lib/omnitrace/library/coverage/impl.hpp rename to source/lib/rocprof-sys/library/coverage/impl.hpp index 24ac324e..e66ea29f 100644 --- a/source/lib/omnitrace/library/coverage/impl.hpp +++ b/source/lib/rocprof-sys/library/coverage/impl.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -36,7 +36,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace coverage { @@ -191,4 +191,4 @@ coverage_data::operator>=(const coverage_data& rhs) const } // } // namespace coverage -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/cpu_freq.cpp b/source/lib/rocprof-sys/library/cpu_freq.cpp similarity index 94% rename from source/lib/omnitrace/library/cpu_freq.cpp rename to source/lib/rocprof-sys/library/cpu_freq.cpp index bf13049e..770e6038 100644 --- a/source/lib/omnitrace/library/cpu_freq.cpp +++ b/source/lib/rocprof-sys/library/cpu_freq.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -46,7 +46,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace cpu_freq { @@ -66,9 +66,9 @@ void init_perfetto_counter_tracks(type_list) } } // namespace } // namespace cpu_freq -} // namespace omnitrace +} // namespace rocprofsys -namespace omnitrace +namespace rocprofsys { namespace cpu_freq { @@ -159,14 +159,14 @@ write_perfetto_counter_track(index&& _idx, Args... _args) void post_process() { - OMNITRACE_VERBOSE(1, - "Post-processing %zu cpu frequency and memory usage entries...\n", - data.size()); + ROCPROFSYS_VERBOSE(1, + "Post-processing %zu cpu frequency and memory usage entries...\n", + data.size()); auto _process_frequencies = [](size_t _idx, size_t _offset) { using freq_track = perfetto_counter_track; const auto& _thread_info = thread_info::get(0, InternalTID); - OMNITRACE_CI_THROW(!_thread_info, "Missing thread info for thread 0"); + ROCPROFSYS_CI_THROW(!_thread_info, "Missing thread info for thread 0"); if(!_thread_info) return; if(!freq_track::exists(_idx)) @@ -200,7 +200,7 @@ post_process() { "MB", "MB", "MB", "", "", "sec", "sec" }); const auto& _thread_info = thread_info::get(0, InternalTID); - OMNITRACE_CI_THROW(!_thread_info, "Missing thread info for thread 0"); + ROCPROFSYS_CI_THROW(!_thread_info, "Missing thread info for thread 0"); if(!_thread_info) return; for(auto& itr : data) @@ -251,4 +251,4 @@ post_process() enabled_cpu_freqs.clear(); } } // namespace cpu_freq -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/cpu_freq.hpp b/source/lib/rocprof-sys/library/cpu_freq.hpp similarity index 90% rename from source/lib/omnitrace/library/cpu_freq.hpp rename to source/lib/rocprof-sys/library/cpu_freq.hpp index 616861f0..4f52e3ce 100644 --- a/source/lib/omnitrace/library/cpu_freq.hpp +++ b/source/lib/rocprof-sys/library/cpu_freq.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -22,7 +22,7 @@ #pragma once -namespace omnitrace +namespace rocprofsys { namespace cpu_freq { @@ -41,4 +41,4 @@ shutdown(); void post_process(); } // namespace cpu_freq -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/kokkosp.cpp b/source/lib/rocprof-sys/library/kokkosp.cpp similarity index 79% rename from source/lib/omnitrace/library/kokkosp.cpp rename to source/lib/rocprof-sys/library/kokkosp.cpp index df19b599..44d20be2 100644 --- a/source/lib/omnitrace/library/kokkosp.cpp +++ b/source/lib/rocprof-sys/library/kokkosp.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -20,7 +20,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#define TIMEMORY_KOKKOSP_POSTFIX OMNITRACE_PUBLIC_API +#define TIMEMORY_KOKKOSP_POSTFIX ROCPROFSYS_PUBLIC_API #include "api.hpp" #include "core/components/fwd.hpp" @@ -45,7 +45,7 @@ namespace kokkosp = ::tim::kokkosp; namespace category = ::tim::category; -namespace comp = ::omnitrace::component; +namespace comp = ::rocprofsys::component; using kokkosp_region = comp::local_category_region; @@ -75,7 +75,7 @@ inline void setup_kernel_logger() { if((tim::settings::debug() && tim::settings::verbose() >= 3) || - omnitrace::config::get_use_kokkosp_kernel_logger()) + rocprofsys::config::get_use_kokkosp_kernel_logger()) { kokkosp::logger_t::get_initializer() = [](kokkosp::logger_t& _obj) { _obj.initialize(); @@ -132,7 +132,7 @@ bool violates_name_rules(Arg&& _arg, Args&&... _args) { // for causal profiling we only consider callbacks which are explicitly named - if(omnitrace::config::get_use_causal() && + if(rocprofsys::config::get_use_causal() && (std::string_view{ _arg }.find("Kokkos::") == 0 || std::string_view{ _arg }.find("Space::") != std::string_view::npos)) return true; @@ -161,23 +161,23 @@ extern "C" }; void kokkosp_request_tool_settings(const uint32_t, - Kokkos_Tools_ToolSettings*) OMNITRACE_PUBLIC_API; + Kokkos_Tools_ToolSettings*) ROCPROFSYS_PUBLIC_API; void kokkosp_dual_view_sync(const char*, const void* const, - bool) OMNITRACE_PUBLIC_API; + bool) ROCPROFSYS_PUBLIC_API; void kokkosp_dual_view_modify(const char*, const void* const, - bool) OMNITRACE_PUBLIC_API; + bool) ROCPROFSYS_PUBLIC_API; void kokkosp_print_help(char*) {} void kokkosp_parse_args(int argc, char** argv) { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); - if(!omnitrace::config::settings_are_configured() && - omnitrace::get_state() < omnitrace::State::Active) + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); + if(!rocprofsys::config::settings_are_configured() && + rocprofsys::get_state() < rocprofsys::State::Active) { _standalone_initialized = true; - OMNITRACE_BASIC_VERBOSE_F(0, "Parsing arguments...\n"); + ROCPROFSYS_BASIC_VERBOSE_F(0, "Parsing arguments...\n"); std::string _command_line = {}; for(int i = 0; i < argc; ++i) { @@ -185,13 +185,13 @@ extern "C" _command_line.append(" ").append(argv[i]); } if(_command_line.length() > 1) _command_line = _command_line.substr(1); - tim::set_env("OMNITRACE_COMMAND_LINE", _command_line, 0); + tim::set_env("ROCPROFSYS_COMMAND_LINE", _command_line, 0); } } void kokkosp_declare_metadata(const char* key, const char* value) { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); tim::manager::add_metadata(key, value); } @@ -204,19 +204,21 @@ extern "C" void kokkosp_init_library(const int loadSeq, const uint64_t interfaceVer, const uint32_t devInfoCount, void* deviceInfo) { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); tim::consume_parameters(devInfoCount, deviceInfo); - OMNITRACE_BASIC_VERBOSE_F( - 0, "Initializing omnitrace kokkos connector (sequence %d, version: %llu)... ", + ROCPROFSYS_BASIC_VERBOSE_F( + 0, + "Initializing rocprof-sys kokkos connector (sequence %d, version: %llu)... ", loadSeq, (unsigned long long) interfaceVer); - if(_standalone_initialized || (!omnitrace::config::settings_are_configured() && - omnitrace::get_state() < omnitrace::State::Active)) + if(_standalone_initialized || + (!rocprofsys::config::settings_are_configured() && + rocprofsys::get_state() < rocprofsys::State::Active)) { 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{}; @@ -224,77 +226,77 @@ extern "C" { auto&& _path = itr.pathname; if(!_path.empty() && _path.at(0) != '[' && - omnitrace::filepath::exists(_path)) + rocprofsys::filepath::exists(_path)) _libs.emplace(_path); } for(const auto& itr : _libs) { - if(itr.find("libomnitrace-dl.so") != std::string::npos) + if(itr.find("librocprof-sys-dl.so") != std::string::npos) { std::stringstream _libs_str{}; for(const auto& litr : _libs) _libs_str << " " << litr << "\n"; - OMNITRACE_ABORT( - "%s was invoked with libomnitrace.so as the " + ROCPROFSYS_ABORT( + "%s was invoked with librocprof-sys.so as the " "KOKKOS_PROFILE_LIBRARY.\n" - "However, libomnitrace-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()); } } } - OMNITRACE_BASIC_VERBOSE_F(0, "Initializing omnitrace (standalone)... "); - auto _mode = tim::get_env("OMNITRACE_MODE", "trace"); + ROCPROFSYS_BASIC_VERBOSE_F(0, "Initializing rocprof-sys (standalone)... "); + auto _mode = tim::get_env("ROCPROFSYS_MODE", "trace"); auto _arg0 = (_initialize_arguments.empty()) ? std::string{ "unknown" } : _initialize_arguments.at(0); _standalone_initialized = true; - omnitrace_set_mpi_hidden(false, false); - omnitrace_init_hidden(_mode.c_str(), false, _arg0.c_str()); - omnitrace_push_trace_hidden("kokkos_main"); + rocprofsys_set_mpi_hidden(false, false); + rocprofsys_init_hidden(_mode.c_str(), false, _arg0.c_str()); + rocprofsys_push_trace_hidden("kokkos_main"); } setup_kernel_logger(); tim::trait::runtime_enabled::set( - omnitrace::config::get_use_timemory()); + rocprofsys::config::get_use_timemory()); - if(omnitrace::get_verbose() >= 0) + if(rocprofsys::get_verbose() >= 0) { fprintf(stderr, "%sDone\n%s", tim::log::color::info(), tim::log::color::end()); } - _name_len_limit = omnitrace::config::get_setting_value( - "OMNITRACE_KOKKOSP_NAME_LENGTH_MAX") + _name_len_limit = rocprofsys::config::get_setting_value( + "ROCPROFSYS_KOKKOSP_NAME_LENGTH_MAX") .value_or(_name_len_limit); - _kp_prefix = - omnitrace::config::get_setting_value("OMNITRACE_KOKKOSP_PREFIX") - .value_or(_kp_prefix); + _kp_prefix = rocprofsys::config::get_setting_value( + "ROCPROFSYS_KOKKOSP_PREFIX") + .value_or(_kp_prefix); _kp_deep_copy = - omnitrace::config::get_setting_value("OMNITRACE_KOKKOSP_DEEP_COPY") + rocprofsys::config::get_setting_value("ROCPROFSYS_KOKKOSP_DEEP_COPY") .value_or(_kp_deep_copy); } void kokkosp_finalize_library() { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); if(_standalone_initialized) { - omnitrace_pop_trace_hidden("kokkos_main"); - OMNITRACE_VERBOSE_F( - 0, "Finalizing kokkos omnitrace connector (standalone)...\n"); - omnitrace_finalize_hidden(); + rocprofsys_pop_trace_hidden("kokkos_main"); + ROCPROFSYS_VERBOSE_F( + 0, "Finalizing kokkos rocprof-sys connector (standalone)...\n"); + rocprofsys_finalize_hidden(); } else { - OMNITRACE_VERBOSE_F(0, "Finalizing kokkos omnitrace connector... "); + ROCPROFSYS_VERBOSE_F(0, "Finalizing kokkos rocprof-sys connector... "); kokkosp::cleanup(); - if(omnitrace::get_verbose() >= 0) fprintf(stderr, "Done\n"); + if(rocprofsys::get_verbose() >= 0) fprintf(stderr, "Done\n"); } } @@ -304,7 +306,7 @@ extern "C" { if(violates_name_rules(name)) return set_invalid_id(kernid); - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); auto pname = (devid > std::numeric_limits::max()) // junk device number ? JOIN(" ", _kp_prefix, name, "[for]") : JOIN(" ", _kp_prefix, name, JOIN("", "[for][dev", devid, ']')); @@ -318,7 +320,7 @@ extern "C" { if(is_invalid_id(kernid)) return; - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); kokkosp::logger_t{}.mark(-1, __FUNCTION__, kernid); kokkosp::stop_profiler(kernid); kokkosp::destroy_profiler(kernid); @@ -330,7 +332,7 @@ extern "C" { if(violates_name_rules(name)) return set_invalid_id(kernid); - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); auto pname = (devid > std::numeric_limits::max()) // junk device number ? JOIN(" ", _kp_prefix, name, "[reduce]") @@ -345,7 +347,7 @@ extern "C" { if(is_invalid_id(kernid)) return; - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); kokkosp::logger_t{}.mark(-1, __FUNCTION__, kernid); kokkosp::stop_profiler(kernid); kokkosp::destroy_profiler(kernid); @@ -357,7 +359,7 @@ extern "C" { if(violates_name_rules(name)) return set_invalid_id(kernid); - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); auto pname = (devid > std::numeric_limits::max()) // junk device number ? JOIN(" ", _kp_prefix, name, "[scan]") @@ -372,7 +374,7 @@ extern "C" { if(is_invalid_id(kernid)) return; - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); kokkosp::logger_t{}.mark(-1, __FUNCTION__, kernid); kokkosp::stop_profiler(kernid); kokkosp::destroy_profiler(kernid); @@ -384,7 +386,7 @@ extern "C" { if(violates_name_rules(name)) return set_invalid_id(kernid); - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); auto pname = (devid > std::numeric_limits::max()) // junk device number ? JOIN(" ", _kp_prefix, name, "[fence]") @@ -399,7 +401,7 @@ extern "C" { if(is_invalid_id(kernid)) return; - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); kokkosp::logger_t{}.mark(-1, __FUNCTION__, kernid); kokkosp::stop_profiler(kernid); kokkosp::destroy_profiler(kernid); @@ -409,7 +411,7 @@ extern "C" void kokkosp_push_profile_region(const char* name) { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); kokkosp::logger_t{}.mark(1, __FUNCTION__, name); kokkosp::get_profiler_stack() .emplace_back(kokkosp::profiler_t(name)) @@ -418,7 +420,7 @@ extern "C" void kokkosp_pop_profile_region() { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); kokkosp::logger_t{}.mark(-1, __FUNCTION__); if(kokkosp::get_profiler_stack().empty()) return; kokkosp::get_profiler_stack().back().stop(); @@ -429,7 +431,7 @@ extern "C" void kokkosp_create_profile_section(const char* name, uint32_t* secid) { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); *secid = kokkosp::get_unique_id(); auto pname = std::string{ name }; kokkosp::create_profiler(name, *secid); @@ -437,7 +439,7 @@ extern "C" void kokkosp_destroy_profile_section(uint32_t secid) { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); kokkosp::destroy_profiler(secid); } @@ -445,14 +447,14 @@ extern "C" void kokkosp_start_profile_section(uint32_t secid) { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); kokkosp::logger_t{}.mark(1, __FUNCTION__, secid); kokkosp::start_profiler(secid); } void kokkosp_stop_profile_section(uint32_t secid) { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); kokkosp::logger_t{}.mark(-1, __FUNCTION__, secid); kokkosp::stop_profiler(secid); } @@ -463,9 +465,9 @@ extern "C" const void* const ptr, const uint64_t size) { if(violates_name_rules(label)) return; - if(omnitrace::config::get_use_causal()) return; + if(rocprofsys::config::get_use_causal()) return; - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); kokkosp::logger_t{}.mark(0, __FUNCTION__, space.name, label, JOIN("", '[', ptr, ']'), size); auto pname = @@ -478,9 +480,9 @@ extern "C" const void* const ptr, const uint64_t size) { if(violates_name_rules(label)) return; - if(omnitrace::config::get_use_causal()) return; + if(rocprofsys::config::get_use_causal()) return; - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); kokkosp::logger_t{}.mark(0, __FUNCTION__, space.name, label, JOIN("", '[', ptr, ']'), size); auto pname = @@ -495,10 +497,10 @@ extern "C" const void* dst_ptr, SpaceHandle src_handle, const char* src_name, const void* src_ptr, uint64_t size) { - if(!_kp_deep_copy || omnitrace::config::get_use_causal()) return; + if(!_kp_deep_copy || rocprofsys::config::get_use_causal()) return; if(violates_name_rules(dst_name, src_name)) return; - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); kokkosp::logger_t{}.mark(1, __FUNCTION__, dst_handle.name, dst_name, JOIN("", '[', dst_ptr, ']'), src_handle.name, src_name, JOIN("", '[', src_ptr, ']'), size); @@ -517,9 +519,9 @@ extern "C" void kokkosp_end_deep_copy() { - if(!_kp_deep_copy || omnitrace::config::get_use_causal()) return; + if(!_kp_deep_copy || rocprofsys::config::get_use_causal()) return; - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); kokkosp::logger_t{}.mark(-1, __FUNCTION__); auto& _data = kokkosp::get_profiler_stack(); if(_data.empty()) return; @@ -533,7 +535,7 @@ extern "C" void kokkosp_profile_event(const char* name) { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); auto _name = tim::get_hash_identifier_fast(tim::add_hash_id(name)); kokkosp::profiler_t{ _name }.mark(); } @@ -544,15 +546,15 @@ extern "C" { if(violates_name_rules(label)) return; - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); - if(omnitrace::config::get_use_perfetto()) + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); + if(rocprofsys::config::get_use_perfetto()) { auto _name = tim::get_hash_identifier_fast( tim::add_hash_id(JOIN(" ", _kp_prefix, label, "[dual_view_sync]"))); TRACE_EVENT_INSTANT("user", ::perfetto::StaticString{ _name.data() }, "target", (is_device) ? "device" : "host"); } - else if(omnitrace::config::get_use_causal()) + else if(rocprofsys::config::get_use_causal()) { auto _name = tim::get_hash_identifier_fast(tim::add_hash_id(JOIN( "", label, " [dual_view_sync][", (is_device) ? "device" : "host", "]"))); @@ -564,15 +566,15 @@ extern "C" { if(violates_name_rules(label)) return; - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); - if(omnitrace::config::get_use_perfetto()) + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); + if(rocprofsys::config::get_use_perfetto()) { auto _name = tim::get_hash_identifier_fast( tim::add_hash_id(JOIN(" ", _kp_prefix, label, "[dual_view_modify]"))); TRACE_EVENT_INSTANT("user", ::perfetto::StaticString{ _name.data() }, "target", (is_device) ? "device" : "host"); } - else if(omnitrace::config::get_use_causal()) + else if(rocprofsys::config::get_use_causal()) { auto _name = tim::get_hash_identifier_fast( tim::add_hash_id(JOIN(" ", _kp_prefix, label, "[dual_view_modify][", diff --git a/source/lib/omnitrace/library/ompt.cpp b/source/lib/rocprof-sys/library/ompt.cpp similarity index 79% rename from source/lib/omnitrace/library/ompt.cpp rename to source/lib/rocprof-sys/library/ompt.cpp index 843c5bf8..6cb66c38 100644 --- a/source/lib/omnitrace/library/ompt.cpp +++ b/source/lib/rocprof-sys/library/ompt.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -28,7 +28,7 @@ #include -#if defined(OMNITRACE_USE_OMPT) && OMNITRACE_USE_OMPT > 0 +#if defined(ROCPROFSYS_USE_OMPT) && ROCPROFSYS_USE_OMPT > 0 # include "core/components/fwd.hpp" # include "library/components/category_region.hpp" @@ -49,10 +49,10 @@ using ompt_bundle_t = tim::component_tuple; extern "C" { ompt_start_tool_result_t* ompt_start_tool(unsigned int, - const char*) OMNITRACE_PUBLIC_API; + const char*) ROCPROFSYS_PUBLIC_API; } -namespace omnitrace +namespace rocprofsys { namespace ompt { @@ -74,7 +74,7 @@ setup() comp::user_ompt_bundle::reset(); tim::auto_lock_t lk{ tim::type_mutex() }; comp::user_ompt_bundle::configure>(); - f_bundle = std::make_unique("omnitrace/ompt", + f_bundle = std::make_unique("rocprofsys/ompt", quirk::config{}); } @@ -86,7 +86,7 @@ shutdown() _protect = true; if(f_bundle) { - if(tim::manager::instance()) tim::manager::instance()->cleanup("omnitrace-ompt"); + if(tim::manager::instance()) tim::manager::instance()->cleanup("rocprofsys-ompt"); f_bundle->stop(); ompt_context_t::cleanup(); trait::runtime_enabled::set(false); @@ -113,17 +113,17 @@ int tool_initialize(ompt_function_lookup_t lookup, int initial_device_num, ompt_data_t* tool_data) { - if(!omnitrace::settings_are_configured()) + if(!rocprofsys::settings_are_configured()) { - OMNITRACE_BASIC_WARNING( + ROCPROFSYS_BASIC_WARNING( 0, - "[%s] invoked before omnitrace was initialized. In instrumentation mode, " + "[%s] invoked before rocprof-sys was initialized. In instrumentation mode, " "settings exported to the environment have not been propagated yet...\n", __FUNCTION__); - omnitrace::configure_settings(); + rocprofsys::configure_settings(); } - use_tool() = omnitrace::config::get_use_ompt(); + use_tool() = rocprofsys::config::get_use_ompt(); if(use_tool()) { TIMEMORY_PRINTF(stderr, "OpenMP-tools configuring for initial device %i\n\n", @@ -141,24 +141,24 @@ tool_finalize(ompt_data_t*) } } // namespace } // namespace ompt -} // namespace omnitrace +} // namespace rocprofsys extern "C" ompt_start_tool_result_t* ompt_start_tool(unsigned int omp_version, const char* runtime_version) { - OMNITRACE_BASIC_VERBOSE_F(0, "OpenMP version: %u, runtime version: %s\n", omp_version, - runtime_version); - OMNITRACE_METADATA("OMP_VERSION", omp_version); - OMNITRACE_METADATA("OMP_RUNTIME_VERSION", runtime_version); + ROCPROFSYS_BASIC_VERBOSE_F(0, "OpenMP version: %u, runtime version: %s\n", + omp_version, runtime_version); + ROCPROFSYS_METADATA("OMP_VERSION", omp_version); + ROCPROFSYS_METADATA("OMP_RUNTIME_VERSION", runtime_version); - static auto* data = new ompt_start_tool_result_t{ &omnitrace::ompt::tool_initialize, - &omnitrace::ompt::tool_finalize, + static auto* data = new ompt_start_tool_result_t{ &rocprofsys::ompt::tool_initialize, + &rocprofsys::ompt::tool_finalize, { 0 } }; return data; } #else -namespace omnitrace +namespace rocprofsys { namespace ompt { @@ -170,6 +170,6 @@ void shutdown() {} } // namespace ompt -} // namespace omnitrace +} // namespace rocprofsys #endif diff --git a/source/lib/omnitrace/library/ompt.hpp b/source/lib/rocprof-sys/library/ompt.hpp similarity index 90% rename from source/lib/omnitrace/library/ompt.hpp rename to source/lib/rocprof-sys/library/ompt.hpp index 32b8c525..f74c6884 100644 --- a/source/lib/omnitrace/library/ompt.hpp +++ b/source/lib/rocprof-sys/library/ompt.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -22,7 +22,7 @@ #pragma once -namespace omnitrace +namespace rocprofsys { namespace ompt { @@ -32,4 +32,4 @@ setup(); void shutdown(); } // namespace ompt -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/perf.cpp b/source/lib/rocprof-sys/library/perf.cpp similarity index 84% rename from source/lib/omnitrace/library/perf.cpp rename to source/lib/rocprof-sys/library/perf.cpp index 476515b6..6b49a62c 100644 --- a/source/lib/omnitrace/library/perf.cpp +++ b/source/lib/rocprof-sys/library/perf.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -49,8 +49,8 @@ #include #include -#if !defined(OMNITRACE_RETURN_ERROR_MSG) -# define OMNITRACE_RETURN_ERROR_MSG(COND, ...) \ +#if !defined(ROCPROFSYS_RETURN_ERROR_MSG) +# define ROCPROFSYS_RETURN_ERROR_MSG(COND, ...) \ if((COND)) \ { \ auto _msg_ss = std::stringstream{}; \ @@ -59,15 +59,15 @@ } #endif -#if !defined(OMNITRACE_FATAL) -# define OMNITRACE_FATAL TIMEMORY_FATAL +#if !defined(ROCPROFSYS_FATAL) +# define ROCPROFSYS_FATAL TIMEMORY_FATAL #endif -#if !defined(OMNITRACE_ASSERT) -# define OMNITRACE_ASSERT(COND) (COND) ? ::tim::log::base() : TIMEMORY_FATAL +#if !defined(ROCPROFSYS_ASSERT) +# define ROCPROFSYS_ASSERT(COND) (COND) ? ::tim::log::base() : TIMEMORY_FATAL #endif -namespace omnitrace +namespace rocprofsys { namespace perf { @@ -98,7 +98,7 @@ perf_event::perf_event(perf_event&& rhs) noexcept if(m_fd != -1 && m_fd != rhs.m_fd) { ::close(m_fd); - OMNITRACE_VERBOSE(1, "Closed perf event fd %li\n", m_fd); + ROCPROFSYS_VERBOSE(1, "Closed perf event fd %li\n", m_fd); } if(m_mapping != nullptr && m_mapping != rhs.m_mapping) munmap(m_mapping, sizes.mmap); @@ -123,7 +123,7 @@ perf_event::~perf_event() { close(); } perf_event& perf_event::operator=(perf_event&& rhs) noexcept { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); if(&rhs == this) return *this; // Release resources if the current perf_event is initialized and not equal to this @@ -150,7 +150,7 @@ perf_event::operator=(perf_event&& rhs) noexcept std::optional perf_event::open(struct perf_event_attr& _pe, pid_t _pid, int _cpu) { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); m_sample_type = _pe.sample_type; m_read_format = _pe.read_format; m_batch_size = _pe.wakeup_events; @@ -167,20 +167,20 @@ perf_event::open(struct perf_event_attr& _pe, pid_t _pid, int _cpu) auto file = std::ifstream{ path.c_str() }; - OMNITRACE_RETURN_ERROR_MSG(!file, - "Failed to open " << path << ": " << strerror(errno)); + ROCPROFSYS_RETURN_ERROR_MSG(!file, + "Failed to open " << path << ": " << strerror(errno)); int value = 4; file >> value; - OMNITRACE_RETURN_ERROR_MSG(file.bad(), "Failed to read from " << path << ": " - << strerror(errno)); + ROCPROFSYS_RETURN_ERROR_MSG(file.bad(), "Failed to read from " + << path << ": " << strerror(errno)); - OMNITRACE_RETURN_ERROR_MSG( + ROCPROFSYS_RETURN_ERROR_MSG( true, "Failed to open perf event. Consider tweaking " << path << " to 2 or less " << "(current value is " << value << "), " - << "or run omnitrace as a privileged user (with CAP_SYS_ADMIN)."); + << "or run rocprof-sys as a privileged user (with CAP_SYS_ADMIN)."); } // If sampling, map the perf event file @@ -189,7 +189,7 @@ perf_event::open(struct perf_event_attr& _pe, pid_t _pid, int _cpu) void* ring_buffer = mmap(nullptr, sizes.mmap, PROT_READ | PROT_WRITE, MAP_SHARED, m_fd, 0); - OMNITRACE_RETURN_ERROR_MSG( + ROCPROFSYS_RETURN_ERROR_MSG( ring_buffer == MAP_FAILED, "Mapping perf_event ring buffer failed. Make sure the current user has " "permission to invoke the perf tool, and that the program being profiled " @@ -204,7 +204,7 @@ perf_event::open(struct perf_event_attr& _pe, pid_t _pid, int _cpu) std::optional perf_event::open(double _freq, uint32_t _batch_size, pid_t _pid, int _cpu) { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); uint64_t _period = (1.0 / _freq) * units::sec; struct perf_event_attr _pe; @@ -247,7 +247,7 @@ uint64_t perf_event::get_count() const { uint64_t count; - OMNITRACE_REQUIRE(read(m_fd, &count, sizeof(uint64_t)) == sizeof(uint64_t)) + ROCPROFSYS_REQUIRE(read(m_fd, &count, sizeof(uint64_t)) == sizeof(uint64_t)) << "Failed to read event count from perf_event file"; return count; } @@ -258,8 +258,8 @@ perf_event::start() const { if(m_fd != -1) { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); - OMNITRACE_REQUIRE(ioctl(m_fd, PERF_EVENT_IOC_ENABLE, 0) != -1) + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_REQUIRE(ioctl(m_fd, PERF_EVENT_IOC_ENABLE, 0) != -1) << "Failed to start perf event: " << strerror(errno); } return (m_fd != -1); @@ -271,8 +271,8 @@ perf_event::stop() const { if(m_fd != -1) { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); - OMNITRACE_REQUIRE(ioctl(m_fd, PERF_EVENT_IOC_DISABLE, 0) != -1) + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_REQUIRE(ioctl(m_fd, PERF_EVENT_IOC_DISABLE, 0) != -1) << "Failed to stop perf event: " << strerror(errno) << " (" << m_fd << ")"; } return (m_fd != -1); @@ -287,7 +287,7 @@ perf_event::is_open() const void perf_event::close() { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); stop(); if(m_fd != -1) @@ -306,24 +306,24 @@ perf_event::close() void perf_event::set_ready_signal(int sig) const { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); // Set the perf_event file to async - OMNITRACE_REQUIRE(fcntl(m_fd, F_SETFL, fcntl(m_fd, F_GETFL, 0) | O_ASYNC) != -1) + ROCPROFSYS_REQUIRE(fcntl(m_fd, F_SETFL, fcntl(m_fd, F_GETFL, 0) | O_ASYNC) != -1) << "failed to set perf_event file to async mode"; // Set the notification signal for the perf file - OMNITRACE_REQUIRE(fcntl(m_fd, F_SETSIG, sig) != -1) + ROCPROFSYS_REQUIRE(fcntl(m_fd, F_SETSIG, sig) != -1) << "failed to set perf_event file signal"; // Set the current thread as the owner of the file (to target signal delivery) - OMNITRACE_REQUIRE(fcntl(m_fd, F_SETOWN, gettid()) != -1) + ROCPROFSYS_REQUIRE(fcntl(m_fd, F_SETOWN, gettid()) != -1) << "failed to set the owner of the perf_event file"; } void perf_event::iterator::next() { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); struct perf_event_header _hdr; @@ -375,7 +375,7 @@ perf_event::iterator::operator!=(const iterator& other) const perf_event::record perf_event::iterator::get() { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); // Copy out the record header perf_event::copy_from_ring_buffer(m_mapping, m_index, _buf, @@ -422,7 +422,7 @@ void perf_event::copy_from_ring_buffer(struct perf_event_mmap_page* _mapping, ptrdiff_t _index, void* _dest, size_t _nbytes) { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); uintptr_t _base = reinterpret_cast(_mapping) + sizes.page; size_t _beg_idx = _index % sizes.data; @@ -448,8 +448,8 @@ perf_event::copy_from_ring_buffer(struct perf_event_mmap_page* _mapping, ptrdiff uint64_t perf_event::record::get_ip() const { - OMNITRACE_ASSERT(is_sample() && m_source != nullptr && - m_source->is_sampling(sample::ip)) + ROCPROFSYS_ASSERT(is_sample() && m_source != nullptr && + m_source->is_sampling(sample::ip)) << "Record does not have an ip field (" << is_sample() << "|" << m_source << ")"; return *locate_field(); } @@ -457,8 +457,8 @@ perf_event::record::get_ip() const uint64_t perf_event::record::get_pid() const { - OMNITRACE_ASSERT(is_sample() && m_source != nullptr && - m_source->is_sampling(sample::pid_tid)) + ROCPROFSYS_ASSERT(is_sample() && m_source != nullptr && + m_source->is_sampling(sample::pid_tid)) << "Record does not have a `pid` field (" << is_sample() << "|" << m_source << ")"; return locate_field()[0]; @@ -467,8 +467,8 @@ perf_event::record::get_pid() const uint64_t perf_event::record::get_tid() const { - OMNITRACE_ASSERT(is_sample() && m_source != nullptr && - m_source->is_sampling(sample::pid_tid)) + ROCPROFSYS_ASSERT(is_sample() && m_source != nullptr && + m_source->is_sampling(sample::pid_tid)) << "Record does not have a `tid` field (" << is_sample() << "|" << m_source << ")"; return locate_field()[1]; @@ -477,8 +477,8 @@ perf_event::record::get_tid() const uint64_t perf_event::record::get_time() const { - OMNITRACE_ASSERT(is_sample() && m_source != nullptr && - m_source->is_sampling(sample::time)) + ROCPROFSYS_ASSERT(is_sample() && m_source != nullptr && + m_source->is_sampling(sample::time)) << "Record does not have a 'time' field (" << is_sample() << "|" << m_source << ")"; return *locate_field(); @@ -487,8 +487,8 @@ perf_event::record::get_time() const uint64_t perf_event::record::get_period() const { - OMNITRACE_ASSERT(is_sample() && m_source != nullptr && - m_source->is_sampling(sample::period)) + ROCPROFSYS_ASSERT(is_sample() && m_source != nullptr && + m_source->is_sampling(sample::period)) << "Record does not have a 'period' field (" << is_sample() << "|" << m_source << ")"; return *locate_field(); @@ -497,8 +497,8 @@ perf_event::record::get_period() const uint32_t perf_event::record::get_cpu() const { - OMNITRACE_ASSERT(is_sample() && m_source != nullptr && - m_source->is_sampling(sample::cpu)) + ROCPROFSYS_ASSERT(is_sample() && m_source != nullptr && + m_source->is_sampling(sample::cpu)) << "Record does not have a 'cpu' field (" << is_sample() << "|" << m_source << ")"; return *locate_field(); @@ -507,8 +507,8 @@ perf_event::record::get_cpu() const container::c_array perf_event::record::get_callchain() const { - OMNITRACE_ASSERT(is_sample() && m_source != nullptr && - m_source->is_sampling(sample::callchain)) + ROCPROFSYS_ASSERT(is_sample() && m_source != nullptr && + m_source->is_sampling(sample::callchain)) << "Record does not have a callchain field (" << is_sample() << "|" << m_source << ")"; @@ -523,7 +523,7 @@ template Tp perf_event::record::locate_field() const { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); uintptr_t p = reinterpret_cast(m_header) + sizeof(struct perf_event_header); @@ -617,22 +617,22 @@ perf_event::record::locate_field() const // branch_stack if constexpr(SampleT == sample::branch_stack) return reinterpret_cast(p); if(m_source != nullptr && m_source->is_sampling(sample::branch_stack)) - OMNITRACE_FATAL << "Branch stack sampling is not supported"; + ROCPROFSYS_FATAL << "Branch stack sampling is not supported"; // regs if constexpr(SampleT == sample::regs) return reinterpret_cast(p); if(m_source != nullptr && m_source->is_sampling(sample::regs)) - OMNITRACE_FATAL << "Register sampling is not supported"; + ROCPROFSYS_FATAL << "Register sampling is not supported"; // stack if constexpr(SampleT == sample::stack) return reinterpret_cast(p); if(m_source != nullptr && m_source->is_sampling(sample::stack)) - OMNITRACE_FATAL << "Stack sampling is not supported"; + ROCPROFSYS_FATAL << "Stack sampling is not supported"; // end if constexpr(SampleT == sample::last) return reinterpret_cast(p); - OMNITRACE_FATAL << "Unsupported sample field requested!"; + ROCPROFSYS_FATAL << "Unsupported sample field requested!"; if constexpr(std::is_pointer::value) return nullptr; @@ -657,10 +657,10 @@ get_instance(int64_t _tid) auto& _data = get_instances(); if(static_cast(_tid) >= _data->size()) { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); _data->resize(_tid + 1); } return _data->at(_tid); } } // namespace perf -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/perf.hpp b/source/lib/rocprof-sys/library/perf.hpp similarity index 98% rename from source/lib/omnitrace/library/perf.hpp rename to source/lib/rocprof-sys/library/perf.hpp index 132ff4ce..ed5136eb 100644 --- a/source/lib/omnitrace/library/perf.hpp +++ b/source/lib/rocprof-sys/library/perf.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -38,7 +38,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace perf { @@ -209,4 +209,4 @@ struct perf_event std::unique_ptr& get_instance(int64_t _tid); } // namespace perf -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/process_sampler.cpp b/source/lib/rocprof-sys/library/process_sampler.cpp similarity index 91% rename from source/lib/omnitrace/library/process_sampler.cpp rename to source/lib/rocprof-sys/library/process_sampler.cpp index 29bd4efc..1ee23018 100644 --- a/source/lib/omnitrace/library/process_sampler.cpp +++ b/source/lib/rocprof-sys/library/process_sampler.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -30,7 +30,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace process_sampler { @@ -75,7 +75,7 @@ sampler::poll(std::atomic* _state, nsec_t _interval, promise_t* _ready) threading::offset_this_id(true); threading::set_thread_name("omni.sampler"); - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); // notify thread started if(_ready) _ready->set_value(); @@ -83,7 +83,7 @@ sampler::poll(std::atomic* _state, nsec_t _interval, promise_t* _ready) for(auto& itr : instances) itr->config(); - OMNITRACE_VERBOSE( + ROCPROFSYS_VERBOSE( 1, "Background process sampling polling at an interval of %f seconds...\n", std::chrono::duration_cast>(_interval).count()); @@ -113,15 +113,15 @@ sampler::poll(std::atomic* _state, nsec_t _interval, promise_t* _ready) if(_has_duration && _now >= _end && get_state() < State::Finalized) { - OMNITRACE_VERBOSE( + ROCPROFSYS_VERBOSE( 1, "Background process sampling duration of %f seconds has elapsed. " "Shutting down process sampling...\n", _duration); } - OMNITRACE_CONDITIONAL_BASIC_PRINT(get_debug(), - "Thread sampler polling completed...\n"); + ROCPROFSYS_CONDITIONAL_BASIC_PRINT(get_debug(), + "Thread sampler polling completed...\n"); if(polling_finished) polling_finished->set_value(); } @@ -131,11 +131,11 @@ sampler::setup() { if(!get_use_process_sampling()) { - OMNITRACE_DEBUG("Background sampler is disabled...\n"); + ROCPROFSYS_DEBUG("Background sampler is disabled...\n"); return; } - OMNITRACE_VERBOSE(1, "Setting up background sampler...\n"); + ROCPROFSYS_VERBOSE(1, "Setting up background sampler...\n"); // shutdown if already running shutdown(); @@ -167,7 +167,7 @@ sampler::setup() polling_finished = std::make_unique(); - OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false); + ROCPROFSYS_SCOPED_SAMPLING_ON_CHILD_THREADS(false); set_state(State::PreInit); get_thread() = std::make_unique(&poll, &get_sampler_state(), @@ -201,7 +201,7 @@ sampler::shutdown() } // during CI, throw an error if polling_finished is not valid - OMNITRACE_CI_THROW(!polling_finished, "polling_finished is not valid\n"); + ROCPROFSYS_CI_THROW(!polling_finished, "polling_finished is not valid\n"); if(polling_finished) { // wait for the thread to finish @@ -238,4 +238,4 @@ sampler::set_state(state_t _state) get_sampler_state().store(_state); } } // namespace process_sampler -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/process_sampler.hpp b/source/lib/rocprof-sys/library/process_sampler.hpp similarity index 95% rename from source/lib/omnitrace/library/process_sampler.hpp rename to source/lib/rocprof-sys/library/process_sampler.hpp index 6b73f887..47ff7378 100644 --- a/source/lib/omnitrace/library/process_sampler.hpp +++ b/source/lib/rocprof-sys/library/process_sampler.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -37,7 +37,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace process_sampler { @@ -100,4 +100,4 @@ post_process() } // } // namespace process_sampler -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/ptl.cpp b/source/lib/rocprof-sys/library/ptl.cpp similarity index 85% rename from source/lib/omnitrace/library/ptl.cpp rename to source/lib/rocprof-sys/library/ptl.cpp index 5b963813..45b13d72 100644 --- a/source/lib/omnitrace/library/ptl.cpp +++ b/source/lib/rocprof-sys/library/ptl.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -36,7 +36,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace tasking { @@ -53,14 +53,14 @@ auto _thread_pool_cfg = []() { const int64_t _max_threads = std::thread::hardware_concurrency() / 2; const int64_t _min_threads = 1; - _nthreads = get_env("OMNITRACE_THREAD_POOL_SIZE", -1, false); + _nthreads = get_env("ROCPROFSYS_THREAD_POOL_SIZE", -1, false); if(_nthreads == -1) { _nthreads = 4; if(_nthreads > _max_threads) _nthreads = _max_threads; if(_nthreads < _min_threads) _nthreads = _min_threads; - tim::set_env("OMNITRACE_THREAD_POOL_SIZE", _nthreads, 0); + tim::set_env("ROCPROFSYS_THREAD_POOL_SIZE", _nthreads, 0); } } @@ -132,8 +132,8 @@ get_thread_pool_state() void setup() { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); - OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_SAMPLING_ON_CHILD_THREADS(false); (void) get_thread_pool(); } @@ -142,18 +142,18 @@ join() { if(roctracer::get_thread_pool_state() == State::Active) { - OMNITRACE_DEBUG_F("waiting for all roctracer tasks to complete...\n"); + ROCPROFSYS_DEBUG_F("waiting for all roctracer tasks to complete...\n"); for(size_t i = 0; i < thread_info::get_peak_num_threads(); ++i) roctracer::get_task_group(i).join(); } else { - OMNITRACE_DEBUG_F("roctracer thread-pool is not active...\n"); + ROCPROFSYS_DEBUG_F("roctracer thread-pool is not active...\n"); } if(general::get_thread_pool_state() == State::Active) { - OMNITRACE_DEBUG_F("waiting for all general tasks to complete...\n"); + ROCPROFSYS_DEBUG_F("waiting for all general tasks to complete...\n"); for(size_t i = 0; i < thread_info::get_peak_num_threads(); ++i) general::get_task_group(i).join(); } @@ -164,7 +164,7 @@ shutdown() { if(roctracer::get_thread_pool_state() == State::Active) { - OMNITRACE_DEBUG_F("Waiting on completion of roctracer tasks...\n"); + ROCPROFSYS_DEBUG_F("Waiting on completion of roctracer tasks...\n"); for(size_t i = 0; i < thread_info::get_peak_num_threads(); ++i) { roctracer::get_task_group(i).join(); @@ -175,12 +175,12 @@ shutdown() } else { - OMNITRACE_DEBUG_F("roctracer thread-pool is not active...\n"); + ROCPROFSYS_DEBUG_F("roctracer thread-pool is not active...\n"); } if(general::get_thread_pool_state() == State::Active) { - OMNITRACE_DEBUG_F("Waiting on completion of general tasks...\n"); + ROCPROFSYS_DEBUG_F("Waiting on completion of general tasks...\n"); for(size_t i = 0; i < thread_info::get_peak_num_threads(); ++i) { general::get_task_group(i).join(); @@ -192,13 +192,13 @@ shutdown() if(get_thread_pool_state() == State::Active) { - OMNITRACE_DEBUG_F("Destroying the omnitrace thread pool...\n"); + ROCPROFSYS_DEBUG_F("Destroying the rocprof-sys thread pool...\n"); get_thread_pool().destroy_threadpool(); get_thread_pool_state() = State::Finalized; } else { - OMNITRACE_DEBUG_F("thread-pool is not active...\n"); + ROCPROFSYS_DEBUG_F("thread-pool is not active...\n"); } } @@ -231,4 +231,4 @@ roctracer::get_task_group(int64_t _tid) return *_v; } } // namespace tasking -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/ptl.hpp b/source/lib/rocprof-sys/library/ptl.hpp similarity index 94% rename from source/lib/omnitrace/library/ptl.hpp rename to source/lib/rocprof-sys/library/ptl.hpp index 4980673d..1afa7310 100644 --- a/source/lib/omnitrace/library/ptl.hpp +++ b/source/lib/rocprof-sys/library/ptl.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -29,7 +29,7 @@ #include -namespace omnitrace +namespace rocprofsys { namespace tasking { @@ -68,4 +68,4 @@ PTL::TaskGroup& get_task_group(int64_t _tid = utility::get_thread_index()); } // namespace roctracer } // namespace tasking -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/rcclp.cpp b/source/lib/rocprof-sys/library/rcclp.cpp similarity index 91% rename from source/lib/omnitrace/library/rcclp.cpp rename to source/lib/rocprof-sys/library/rcclp.cpp index a362d985..541f0575 100644 --- a/source/lib/omnitrace/library/rcclp.cpp +++ b/source/lib/rocprof-sys/library/rcclp.cpp @@ -43,7 +43,7 @@ namespace uint64_t global_id = std::numeric_limits::max(); } -namespace omnitrace +namespace rocprofsys { namespace rcclp { @@ -58,10 +58,10 @@ setup() // make sure the symbols are loaded to be wrapped dynamic_library _librccl{ - "OMNITRACE_RCCL_LIBRARY", "librccl.so", RTLD_NOW | RTLD_GLOBAL, true, true, true + "ROCPROFSYS_RCCL_LIBRARY", "librccl.so", RTLD_NOW | RTLD_GLOBAL, true, true, true }; - auto _use_data = tim::get_env("OMNITRACE_RCCLP_COMM_DATA", get_use_timemory()); + auto _use_data = tim::get_env("ROCPROFSYS_RCCLP_COMM_DATA", get_use_timemory()); if(!get_use_timemory()) { trait::runtime_enabled::set(false); @@ -84,4 +84,4 @@ shutdown() component::deactivate_rcclp(global_id); } } // namespace rcclp -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/rcclp.hpp b/source/lib/rocprof-sys/library/rcclp.hpp similarity index 89% rename from source/lib/omnitrace/library/rcclp.hpp rename to source/lib/rocprof-sys/library/rcclp.hpp index 75a5faaa..05343367 100644 --- a/source/lib/omnitrace/library/rcclp.hpp +++ b/source/lib/rocprof-sys/library/rcclp.hpp @@ -26,7 +26,7 @@ #include "core/defines.hpp" -namespace omnitrace +namespace rocprofsys { namespace rcclp { @@ -39,8 +39,8 @@ setup(); void shutdown(); -#if !defined(OMNITRACE_USE_RCCL) || \ - (defined(OMNITRACE_USE_RCCL) && OMNITRACE_USE_RCCL == 0) +#if !defined(ROCPROFSYS_USE_RCCL) || \ + (defined(ROCPROFSYS_USE_RCCL) && ROCPROFSYS_USE_RCCL == 0) inline void configure() {} @@ -54,4 +54,4 @@ shutdown() {} #endif } // namespace rcclp -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/rocm.cpp b/source/lib/rocprof-sys/library/rocm.cpp similarity index 61% rename from source/lib/omnitrace/library/rocm.cpp rename to source/lib/rocprof-sys/library/rocm.cpp index d57705a9..bd850570 100644 --- a/source/lib/omnitrace/library/rocm.cpp +++ b/source/lib/rocprof-sys/library/rocm.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -46,13 +46,13 @@ #include #include -#if defined(OMNITRACE_USE_ROCPROFILER) && OMNITRACE_USE_ROCPROFILER > 0 +#if defined(ROCPROFSYS_USE_ROCPROFILER) && ROCPROFSYS_USE_ROCPROFILER > 0 # include #endif -using namespace omnitrace; +using namespace rocprofsys; -namespace omnitrace +namespace rocprofsys { namespace rocm { @@ -60,9 +60,9 @@ std::mutex rocm_mutex = {}; bool is_loaded = false; bool on_load_trace = (get_env("ROCP_ONLOAD_TRACE", 0) > 0); } // namespace rocm -} // namespace omnitrace +} // namespace rocprofsys -#if defined(OMNITRACE_USE_ROCPROFILER) && OMNITRACE_USE_ROCPROFILER > 0 +#if defined(ROCPROFSYS_USE_ROCPROFILER) && ROCPROFSYS_USE_ROCPROFILER > 0 std::ostream& operator<<(std::ostream& _os, const rocprofiler_settings_t& _v) { @@ -84,18 +84,18 @@ operator<<(std::ostream& _os, const rocprofiler_settings_t& _v) // HSA-runtime tool on-load method extern "C" { -#if defined(OMNITRACE_USE_ROCPROFILER) && OMNITRACE_USE_ROCPROFILER > 0 +#if defined(ROCPROFSYS_USE_ROCPROFILER) && ROCPROFSYS_USE_ROCPROFILER > 0 void OnUnloadTool() { - OMNITRACE_BASIC_VERBOSE_F(2 || rocm::on_load_trace, "Unloading...\n"); + ROCPROFSYS_BASIC_VERBOSE_F(2 || rocm::on_load_trace, "Unloading...\n"); rocm::lock_t _lk{ rocm::rocm_mutex, std::defer_lock }; if(!_lk.owns_lock()) _lk.lock(); if(!rocm::is_loaded) { - OMNITRACE_BASIC_VERBOSE_F(1 || rocm::on_load_trace, - "rocprofiler is not loaded\n"); + ROCPROFSYS_BASIC_VERBOSE_F(1 || rocm::on_load_trace, + "rocprofiler is not loaded\n"); return; } rocm::is_loaded = false; @@ -104,7 +104,7 @@ extern "C" // stop_top_level_timer_if_necessary(); // Final resources cleanup - omnitrace::rocprofiler::rocm_cleanup(); + rocprofsys::rocprofiler::rocm_cleanup(); } void OnLoadToolProp(rocprofiler_settings_t* settings) @@ -113,15 +113,15 @@ extern "C" if(!config::get_use_rocprofiler() || config::get_rocm_events().empty()) return; - OMNITRACE_BASIC_VERBOSE_F(2 || rocm::on_load_trace, "Loading...\n"); + ROCPROFSYS_BASIC_VERBOSE_F(2 || rocm::on_load_trace, "Loading...\n"); rocm::lock_t _lk{ rocm::rocm_mutex, std::defer_lock }; if(!_lk.owns_lock()) _lk.lock(); if(rocm::is_loaded) { - OMNITRACE_BASIC_VERBOSE_F(1 || rocm::on_load_trace, - "rocprofiler is already loaded\n"); + ROCPROFSYS_BASIC_VERBOSE_F(1 || rocm::on_load_trace, + "rocprofiler is already loaded\n"); return; } rocm::is_loaded = true; @@ -141,11 +141,11 @@ extern "C" // settings->trace_size = 0; // settings->timeout = 0; - OMNITRACE_BASIC_VERBOSE_F(1 || rocm::on_load_trace, "rocprofiler settings: %s\n", - JOIN("", *settings).c_str()); + ROCPROFSYS_BASIC_VERBOSE_F(1 || rocm::on_load_trace, "rocprofiler settings: %s\n", + JOIN("", *settings).c_str()); // Initialize profiling - omnitrace::rocprofiler::rocm_initialize(); + rocprofsys::rocprofiler::rocm_initialize(); HsaRsrcFactory::Instance().PrintGpuAgents("ROCm"); } #endif @@ -160,38 +160,38 @@ extern "C" if(_once) return true; _once = true; - OMNITRACE_BASIC_VERBOSE_F(2 || rocm::on_load_trace, "Loading...\n"); - OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false); + ROCPROFSYS_BASIC_VERBOSE_F(2 || rocm::on_load_trace, "Loading...\n"); + ROCPROFSYS_SCOPED_SAMPLING_ON_CHILD_THREADS(false); - if(!tim::get_env("OMNITRACE_INIT_TOOLING", true)) return true; + if(!tim::get_env("ROCPROFSYS_INIT_TOOLING", true)) return true; if(!tim::settings::enabled()) return true; roctracer_is_init() = true; - OMNITRACE_BASIC_VERBOSE_F(1 || rocm::on_load_trace, "Loading ROCm tooling...\n"); + ROCPROFSYS_BASIC_VERBOSE_F(1 || rocm::on_load_trace, "Loading ROCm tooling...\n"); if(!config::settings_are_configured() && get_state() < State::Active) - omnitrace_init_tooling_hidden(); + rocprofsys_init_tooling_hidden(); - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); -#if OMNITRACE_HIP_VERSION < 50300 - OMNITRACE_VERBOSE_F(1 || rocm::on_load_trace, - "Computing the roctracer clock skew...\n"); - (void) omnitrace::get_clock_skew(); +#if ROCPROFSYS_HIP_VERSION < 50300 + ROCPROFSYS_VERBOSE_F(1 || rocm::on_load_trace, + "Computing the roctracer clock skew...\n"); + (void) rocprofsys::get_clock_skew(); #endif if(get_use_process_sampling() && get_use_rocm_smi()) { - OMNITRACE_VERBOSE_F(1 || rocm::on_load_trace, - "Setting rocm_smi state to active...\n"); + ROCPROFSYS_VERBOSE_F(1 || rocm::on_load_trace, + "Setting rocm_smi state to active...\n"); rocm_smi::set_state(State::Active); } comp::roctracer::setup(static_cast(table), rocm::on_load_trace); -#if defined(OMNITRACE_USE_ROCPROFILER) && OMNITRACE_USE_ROCPROFILER > 0 +#if defined(ROCPROFSYS_USE_ROCPROFILER) && ROCPROFSYS_USE_ROCPROFILER > 0 bool _force_rocprofiler_init = - tim::get_env("OMNITRACE_FORCE_ROCPROFILER_INIT", false, false); + tim::get_env("ROCPROFSYS_FORCE_ROCPROFILER_INIT", false, false); #else bool _force_rocprofiler_init = false; #endif @@ -201,32 +201,32 @@ extern "C" (config::settings_are_configured() && config::get_rocm_events().empty()); if(_force_rocprofiler_init || (get_use_rocprofiler() && !_is_empty)) { -#if OMNITRACE_HIP_VERSION < 50500 - auto _rocprof = - dynamic_library{ "OMNITRACE_ROCPROFILER_LIBRARY", - find_library_path("librocprofiler64.so", - { "OMNITRACE_ROCM_PATH", "ROCM_PATH" }, - { OMNITRACE_DEFAULT_ROCM_PATH }, - { "lib", "lib64", "rocprofiler/lib", - "rocprofiler/lib64" }), - (RTLD_LAZY | RTLD_GLOBAL), false }; - - OMNITRACE_VERBOSE_F(1 || rocm::on_load_trace, - "Loading rocprofiler library (%s=%s)...\n", - _rocprof.envname.c_str(), _rocprof.filename.c_str()); +#if ROCPROFSYS_HIP_VERSION < 50500 + auto _rocprof = dynamic_library{ + "ROCPROFSYS_ROCPROFILER_LIBRARY", + find_library_path( + "librocprofiler64.so", { "ROCPROFSYS_ROCM_PATH", "ROCM_PATH" }, + { ROCPROFSYS_DEFAULT_ROCM_PATH }, + { "lib", "lib64", "rocprofiler/lib", "rocprofiler/lib64" }), + (RTLD_LAZY | RTLD_GLOBAL), false + }; + + ROCPROFSYS_VERBOSE_F(1 || rocm::on_load_trace, + "Loading rocprofiler library (%s=%s)...\n", + _rocprof.envname.c_str(), _rocprof.filename.c_str()); _rocprof.open(); on_load_t _rocprof_load = nullptr; _success = _rocprof.invoke("OnLoad", _rocprof_load, table, runtime_version, failed_tool_count, failed_tool_names); - OMNITRACE_CONDITIONAL_PRINT_F(!_success, - "Warning! Invoking rocprofiler's OnLoad " - "failed! OMNITRACE_ROCPROFILER_LIBRARY=%s\n", - _rocprof.filename.c_str()); - OMNITRACE_CI_THROW(!_success, - "Warning! Invoking rocprofiler's OnLoad " - "failed! OMNITRACE_ROCPROFILER_LIBRARY=%s\n", - _rocprof.filename.c_str()); + ROCPROFSYS_CONDITIONAL_PRINT_F(!_success, + "Warning! Invoking rocprofiler's OnLoad " + "failed! ROCPROFSYS_ROCPROFILER_LIBRARY=%s\n", + _rocprof.filename.c_str()); + ROCPROFSYS_CI_THROW(!_success, + "Warning! Invoking rocprofiler's OnLoad " + "failed! ROCPROFSYS_ROCPROFILER_LIBRARY=%s\n", + _rocprof.filename.c_str()); #endif } else @@ -238,16 +238,16 @@ extern "C" gpu::add_hip_device_metadata(); - OMNITRACE_BASIC_VERBOSE_F(2 || rocm::on_load_trace, "Loading... %s\n", - (_success) ? "Done" : "Failed"); + ROCPROFSYS_BASIC_VERBOSE_F(2 || rocm::on_load_trace, "Loading... %s\n", + (_success) ? "Done" : "Failed"); return _success; } // HSA-runtime on-unload method void OnUnload() { - OMNITRACE_BASIC_VERBOSE_F(2 || rocm::on_load_trace, "Unloading...\n"); - omnitrace_finalize_hidden(); - OMNITRACE_BASIC_VERBOSE_F(2 || rocm::on_load_trace, "Unloading... Done\n"); + ROCPROFSYS_BASIC_VERBOSE_F(2 || rocm::on_load_trace, "Unloading...\n"); + rocprofsys_finalize_hidden(); + ROCPROFSYS_BASIC_VERBOSE_F(2 || rocm::on_load_trace, "Unloading... Done\n"); } } diff --git a/source/lib/omnitrace/library/rocm.hpp b/source/lib/rocprof-sys/library/rocm.hpp similarity index 75% rename from source/lib/omnitrace/library/rocm.hpp rename to source/lib/rocprof-sys/library/rocm.hpp index 2eeb3190..b5b1808f 100644 --- a/source/lib/omnitrace/library/rocm.hpp +++ b/source/lib/rocprof-sys/library/rocm.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -24,14 +24,14 @@ #include "core/defines.hpp" -#if defined(OMNITRACE_USE_ROCPROFILER) && OMNITRACE_USE_ROCPROFILER > 0 +#if defined(ROCPROFSYS_USE_ROCPROFILER) && ROCPROFSYS_USE_ROCPROFILER > 0 # include #endif #include #include -namespace omnitrace +namespace rocprofsys { namespace rocm { @@ -40,7 +40,7 @@ using lock_t = std::unique_lock; extern std::mutex rocm_mutex; extern bool is_loaded; } // namespace rocm -} // namespace omnitrace +} // namespace rocprofsys extern "C" { @@ -48,11 +48,11 @@ extern "C" using on_load_t = bool (*)(HsaApiTable*, uint64_t, uint64_t, const char* const*); bool OnLoad(HsaApiTable* table, uint64_t runtime_version, uint64_t failed_tool_count, - const char* const* failed_tool_names) OMNITRACE_PUBLIC_API; - void OnUnload() OMNITRACE_PUBLIC_API; + const char* const* failed_tool_names) ROCPROFSYS_PUBLIC_API; + void OnUnload() ROCPROFSYS_PUBLIC_API; -#if defined(OMNITRACE_USE_ROCPROFILER) && OMNITRACE_USE_ROCPROFILER > 0 - void OnLoadToolProp(rocprofiler_settings_t* settings) OMNITRACE_PUBLIC_API; - void OnUnloadTool() OMNITRACE_PUBLIC_API; +#if defined(ROCPROFSYS_USE_ROCPROFILER) && ROCPROFSYS_USE_ROCPROFILER > 0 + void OnLoadToolProp(rocprofiler_settings_t* settings) ROCPROFSYS_PUBLIC_API; + void OnUnloadTool() ROCPROFSYS_PUBLIC_API; #endif } diff --git a/source/lib/rocprof-sys/library/rocm/CMakeLists.txt b/source/lib/rocprof-sys/library/rocm/CMakeLists.txt new file mode 100644 index 00000000..0136d5d1 --- /dev/null +++ b/source/lib/rocprof-sys/library/rocm/CMakeLists.txt @@ -0,0 +1,7 @@ +# +if(ROCPROFSYS_USE_ROCPROFILER OR ROCPROFSYS_USE_ROCTRACER) + target_sources( + rocprofiler-systems-object-library + PRIVATE ${CMAKE_CURRENT_LIST_DIR}/hsa_rsrc_factory.hpp + ${CMAKE_CURRENT_LIST_DIR}/hsa_rsrc_factory.cpp) +endif() diff --git a/source/lib/omnitrace/library/rocm/hsa_rsrc_factory.cpp b/source/lib/rocprof-sys/library/rocm/hsa_rsrc_factory.cpp similarity index 99% rename from source/lib/omnitrace/library/rocm/hsa_rsrc_factory.cpp rename to source/lib/rocprof-sys/library/rocm/hsa_rsrc_factory.cpp index e4f8578f..ecb010cd 100644 --- a/source/lib/omnitrace/library/rocm/hsa_rsrc_factory.cpp +++ b/source/lib/rocprof-sys/library/rocm/hsa_rsrc_factory.cpp @@ -1,5 +1,5 @@ /****************************************************************************** -Copyright (c) 2018 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2018-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 @@ -828,7 +828,7 @@ HsaRsrcFactory::PrintGpuAgents(const std::string&) if(itr) _agents.emplace_back(*itr); } - OMNITRACE_METADATA([_agents](auto& ar) { + ROCPROFSYS_METADATA([_agents](auto& ar) { namespace cereal = ::tim::cereal; ar.setNextName("rocm_agents"); diff --git a/source/lib/omnitrace/library/rocm/hsa_rsrc_factory.hpp b/source/lib/rocprof-sys/library/rocm/hsa_rsrc_factory.hpp similarity index 98% rename from source/lib/omnitrace/library/rocm/hsa_rsrc_factory.hpp rename to source/lib/rocprof-sys/library/rocm/hsa_rsrc_factory.hpp index 2d68b5ec..9e255ce9 100644 --- a/source/lib/omnitrace/library/rocm/hsa_rsrc_factory.hpp +++ b/source/lib/rocprof-sys/library/rocm/hsa_rsrc_factory.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -60,7 +60,7 @@ char _buffer[HSA_MESSAGE_LENGTH]; \ snprintf(_buffer, HSA_MESSAGE_LENGTH - 1, "%s: %s", msg, \ emsg ? emsg : ""); \ - throw ::omnitrace::exception(_buffer); \ + throw ::rocprofsys::exception(_buffer); \ } \ } while(0) @@ -74,7 +74,7 @@ char _buffer[HSA_MESSAGE_LENGTH]; \ snprintf(_buffer, HSA_MESSAGE_LENGTH - 1, "%s: %s", msg, \ emsg ? emsg : ""); \ - throw ::omnitrace::exception(_buffer); \ + throw ::rocprofsys::exception(_buffer); \ } \ } while(0) diff --git a/source/lib/omnitrace/library/rocm_smi.cpp b/source/lib/rocprof-sys/library/rocm_smi.cpp similarity index 78% rename from source/lib/omnitrace/library/rocm_smi.cpp rename to source/lib/rocprof-sys/library/rocm_smi.cpp index b65a7731..73373a03 100644 --- a/source/lib/omnitrace/library/rocm_smi.cpp +++ b/source/lib/rocprof-sys/library/rocm_smi.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2018-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 @@ -59,10 +59,10 @@ #include #include -#define OMNITRACE_ROCM_SMI_CALL(...) \ - ::omnitrace::rocm_smi::check_error(__FILE__, __LINE__, __VA_ARGS__) +#define ROCPROFSYS_ROCM_SMI_CALL(...) \ + ::rocprofsys::rocm_smi::check_error(__FILE__, __LINE__, __VA_ARGS__) -namespace omnitrace +namespace rocprofsys { namespace rocm_smi { @@ -99,11 +99,11 @@ check_error(const char* _file, int _line, rsmi_status_t _code, bool* _option = n const char* _msg = nullptr; auto _err = rsmi_status_string(_code, &_msg); if(_err != RSMI_STATUS_SUCCESS) - OMNITRACE_THROW("rsmi_status_string failed. No error message available. " - "Error code %i originated at %s:%i\n", - static_cast(_code), _file, _line); - OMNITRACE_THROW("[%s:%i] Error code %i :: %s", _file, _line, static_cast(_code), - _msg); + ROCPROFSYS_THROW("rsmi_status_string failed. No error message available. " + "Error code %i originated at %s:%i\n", + static_cast(_code), _file, _line); + ROCPROFSYS_THROW("[%s:%i] Error code %i :: %s", _file, _line, static_cast(_code), + _msg); } std::atomic& @@ -135,31 +135,31 @@ data::sample(uint32_t _dev_id) m_dev_id = _dev_id; m_ts = _ts; -#define OMNITRACE_RSMI_GET(OPTION, FUNCTION, ...) \ +#define ROCPROFSYS_RSMI_GET(OPTION, FUNCTION, ...) \ if(OPTION) \ { \ try \ { \ - OMNITRACE_ROCM_SMI_CALL(FUNCTION(__VA_ARGS__), &OPTION); \ + ROCPROFSYS_ROCM_SMI_CALL(FUNCTION(__VA_ARGS__), &OPTION); \ } catch(std::runtime_error & _e) \ { \ - OMNITRACE_VERBOSE_F( \ + ROCPROFSYS_VERBOSE_F( \ 0, "[%s] Exception: %s. Disabling future samples from rocm-smi...\n", \ #FUNCTION, _e.what()); \ get_state().store(State::Disabled); \ } \ } - OMNITRACE_RSMI_GET(get_settings(m_dev_id).busy, rsmi_dev_busy_percent_get, _dev_id, - &m_busy_perc); - OMNITRACE_RSMI_GET(get_settings(m_dev_id).temp, rsmi_dev_temp_metric_get, _dev_id, - RSMI_TEMP_TYPE_EDGE, RSMI_TEMP_CURRENT, &m_temp); - OMNITRACE_RSMI_GET(get_settings(m_dev_id).power, rsmi_dev_power_ave_get, _dev_id, 0, - &m_power); - OMNITRACE_RSMI_GET(get_settings(m_dev_id).mem_usage, rsmi_dev_memory_usage_get, - _dev_id, RSMI_MEM_TYPE_VRAM, &m_mem_usage); + ROCPROFSYS_RSMI_GET(get_settings(m_dev_id).busy, rsmi_dev_busy_percent_get, _dev_id, + &m_busy_perc); + ROCPROFSYS_RSMI_GET(get_settings(m_dev_id).temp, rsmi_dev_temp_metric_get, _dev_id, + RSMI_TEMP_TYPE_EDGE, RSMI_TEMP_CURRENT, &m_temp); + ROCPROFSYS_RSMI_GET(get_settings(m_dev_id).power, rsmi_dev_power_ave_get, _dev_id, 0, + &m_power); + ROCPROFSYS_RSMI_GET(get_settings(m_dev_id).mem_usage, rsmi_dev_memory_usage_get, + _dev_id, RSMI_MEM_TYPE_VRAM, &m_mem_usage); -#undef OMNITRACE_RSMI_GET +#undef ROCPROFSYS_RSMI_GET } void @@ -201,11 +201,11 @@ sample() for(auto itr : data::device_list) { if(rocm_smi::get_state() != State::Active) continue; - OMNITRACE_DEBUG_F("Polling rocm-smi for device %u...\n", itr); + ROCPROFSYS_DEBUG_F("Polling rocm-smi for device %u...\n", itr); auto& _data = *_bundle_data.at(itr); if(!_data) continue; _data->emplace_back(data{ itr }); - OMNITRACE_DEBUG_F(" %s\n", TIMEMORY_JOIN("", _data->back()).c_str()); + ROCPROFSYS_DEBUG_F(" %s\n", TIMEMORY_JOIN("", _data->back()).c_str()); } } @@ -233,7 +233,7 @@ data::setup() bool data::shutdown() { - OMNITRACE_DEBUG("Shutting down rocm-smi...\n"); + ROCPROFSYS_DEBUG("Shutting down rocm-smi...\n"); rocm_smi::set_state(State::Finalized); return true; } @@ -263,10 +263,10 @@ data::post_process(uint32_t _dev_id) auto _rocm_smi = (_rocm_smi_v) ? *_rocm_smi_v : std::deque{}; const auto& _thread_info = thread_info::get(0, InternalTID); - OMNITRACE_VERBOSE(1, "Post-processing %zu rocm-smi samples from device %u\n", - _rocm_smi.size(), _dev_id); + ROCPROFSYS_VERBOSE(1, "Post-processing %zu rocm-smi samples from device %u\n", + _rocm_smi.size(), _dev_id); - OMNITRACE_CI_THROW(!_thread_info, "Missing thread info for thread 0"); + ROCPROFSYS_CI_THROW(!_thread_info, "Missing thread info for thread 0"); if(!_thread_info) return; auto _settings = get_settings(_dev_id); @@ -336,7 +336,7 @@ setup() if(is_initialized() || !get_use_rocm_smi()) return; - OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false); + ROCPROFSYS_SCOPED_SAMPLING_ON_CHILD_THREADS(false); // assign the data value to determined by rocm-smi data::device_count = device_count(); @@ -368,18 +368,18 @@ setup() { if(itr.find_first_not_of("0123456789-") != std::string::npos) { - OMNITRACE_THROW("Invalid GPU specification: '%s'. Only numerical values " - "(e.g., 0) or ranges (e.g., 0-7) are permitted.", - itr.c_str()); + ROCPROFSYS_THROW("Invalid GPU specification: '%s'. Only numerical values " + "(e.g., 0) or ranges (e.g., 0-7) are permitted.", + itr.c_str()); } if(itr.find('-') != std::string::npos) { auto _v = tim::delimit(itr, "-"); - OMNITRACE_CONDITIONAL_THROW(_v.size() != 2, - "Invalid GPU range specification: '%s'. " - "Required format N-M, e.g. 0-4", - itr.c_str()); + ROCPROFSYS_CONDITIONAL_THROW(_v.size() != 2, + "Invalid GPU range specification: '%s'. " + "Required format N-M, e.g. 0-4", + itr.c_str()); for(auto i = std::stoul(_v.at(0)); i < std::stoul(_v.at(1)); ++i) _emplace(i); } @@ -392,14 +392,14 @@ setup() data::device_list = _devices; - auto _metrics = get_setting_value("OMNITRACE_ROCM_SMI_METRICS"); + auto _metrics = get_setting_value("ROCPROFSYS_ROCM_SMI_METRICS"); try { for(auto itr : _devices) { uint16_t dev_id = 0; - OMNITRACE_ROCM_SMI_CALL(rsmi_dev_id_get(itr, &dev_id)); + ROCPROFSYS_ROCM_SMI_CALL(rsmi_dev_id_get(itr, &dev_id)); // dev_id holds the device ID of device i, upon a successful call if(_metrics && !_metrics->empty()) @@ -417,11 +417,11 @@ setup() { auto iitr = supported.find(metric); if(iitr == supported.end()) - OMNITRACE_FAIL_F("unsupported rocm-smi metric: %s\n", - metric.c_str()); + ROCPROFSYS_FAIL_F("unsupported rocm-smi metric: %s\n", + metric.c_str()); - OMNITRACE_VERBOSE_F(1, "Enabling rocm-smi metric '%s'\n", - metric.c_str()); + ROCPROFSYS_VERBOSE_F(1, "Enabling rocm-smi metric '%s'\n", + metric.c_str()); iitr->second = true; } } @@ -432,8 +432,8 @@ setup() data::setup(); } catch(std::runtime_error& _e) { - OMNITRACE_VERBOSE(0, "Exception thrown when initializing rocm-smi: %s\n", - _e.what()); + ROCPROFSYS_VERBOSE(0, "Exception thrown when initializing rocm-smi: %s\n", + _e.what()); data::device_list = {}; } } @@ -449,12 +449,12 @@ shutdown() { if(data::shutdown()) { - OMNITRACE_ROCM_SMI_CALL(rsmi_shut_down()); + ROCPROFSYS_ROCM_SMI_CALL(rsmi_shut_down()); } } catch(std::runtime_error& _e) { - OMNITRACE_VERBOSE(0, "Exception thrown when shutting down rocm-smi: %s\n", - _e.what()); + ROCPROFSYS_VERBOSE(0, "Exception thrown when shutting down rocm-smi: %s\n", + _e.what()); } is_initialized() = false; @@ -473,20 +473,20 @@ device_count() return gpu::rsmi_device_count(); } } // namespace rocm_smi -} // namespace omnitrace +} // namespace rocprofsys -OMNITRACE_INSTANTIATE_EXTERN_COMPONENT( - TIMEMORY_ESC(data_tracker), true, +ROCPROFSYS_INSTANTIATE_EXTERN_COMPONENT( + TIMEMORY_ESC(data_tracker), true, double) -OMNITRACE_INSTANTIATE_EXTERN_COMPONENT( - TIMEMORY_ESC(data_tracker), true, +ROCPROFSYS_INSTANTIATE_EXTERN_COMPONENT( + TIMEMORY_ESC(data_tracker), true, double) -OMNITRACE_INSTANTIATE_EXTERN_COMPONENT( - TIMEMORY_ESC(data_tracker), true, +ROCPROFSYS_INSTANTIATE_EXTERN_COMPONENT( + TIMEMORY_ESC(data_tracker), true, double) -OMNITRACE_INSTANTIATE_EXTERN_COMPONENT( - TIMEMORY_ESC(data_tracker), true, +ROCPROFSYS_INSTANTIATE_EXTERN_COMPONENT( + TIMEMORY_ESC(data_tracker), true, double) diff --git a/source/lib/omnitrace/library/rocm_smi.hpp b/source/lib/rocprof-sys/library/rocm_smi.hpp similarity index 76% rename from source/lib/omnitrace/library/rocm_smi.hpp rename to source/lib/rocprof-sys/library/rocm_smi.hpp index f6e45027..09d67e75 100644 --- a/source/lib/omnitrace/library/rocm_smi.hpp +++ b/source/lib/rocprof-sys/library/rocm_smi.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2018-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 @@ -45,7 +45,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace rocm_smi { @@ -90,7 +90,7 @@ struct data using mem_usage_t = uint64_t; using temp_t = int64_t; - OMNITRACE_DEFAULT_OBJECT(data) + ROCPROFSYS_DEFAULT_OBJECT(data) explicit data(uint32_t _dev_id); @@ -113,11 +113,11 @@ struct data } private: - friend void omnitrace::rocm_smi::setup(); - friend void omnitrace::rocm_smi::config(); - friend void omnitrace::rocm_smi::sample(); - friend void omnitrace::rocm_smi::shutdown(); - friend void omnitrace::rocm_smi::post_process(); + friend void rocprofsys::rocm_smi::setup(); + friend void rocprofsys::rocm_smi::config(); + friend void rocprofsys::rocm_smi::sample(); + friend void rocprofsys::rocm_smi::shutdown(); + friend void rocprofsys::rocm_smi::post_process(); static size_t device_count; static std::set device_list; @@ -128,7 +128,7 @@ struct data static bool shutdown(); }; -#if !defined(OMNITRACE_USE_ROCM_SMI) +#if !defined(ROCPROFSYS_USE_ROCM_SMI) inline void setup() {} @@ -152,30 +152,30 @@ post_process() inline void set_state(State) {} #endif } // namespace rocm_smi -} // namespace omnitrace +} // namespace rocprofsys -#if defined(OMNITRACE_USE_ROCM_SMI) && OMNITRACE_USE_ROCM_SMI > 0 -# if !defined(OMNITRACE_EXTERN_COMPONENTS) || \ - (defined(OMNITRACE_EXTERN_COMPONENTS) && OMNITRACE_EXTERN_COMPONENTS > 0) +#if defined(ROCPROFSYS_USE_ROCM_SMI) && ROCPROFSYS_USE_ROCM_SMI > 0 +# if !defined(ROCPROFSYS_EXTERN_COMPONENTS) || \ + (defined(ROCPROFSYS_EXTERN_COMPONENTS) && ROCPROFSYS_EXTERN_COMPONENTS > 0) # include # include # include -OMNITRACE_DECLARE_EXTERN_COMPONENT( - TIMEMORY_ESC(data_tracker), true, +ROCPROFSYS_DECLARE_EXTERN_COMPONENT( + TIMEMORY_ESC(data_tracker), true, double) -OMNITRACE_DECLARE_EXTERN_COMPONENT( - TIMEMORY_ESC(data_tracker), true, +ROCPROFSYS_DECLARE_EXTERN_COMPONENT( + TIMEMORY_ESC(data_tracker), true, double) -OMNITRACE_DECLARE_EXTERN_COMPONENT( - TIMEMORY_ESC(data_tracker), true, +ROCPROFSYS_DECLARE_EXTERN_COMPONENT( + TIMEMORY_ESC(data_tracker), true, double) -OMNITRACE_DECLARE_EXTERN_COMPONENT( - TIMEMORY_ESC(data_tracker), true, +ROCPROFSYS_DECLARE_EXTERN_COMPONENT( + TIMEMORY_ESC(data_tracker), true, double) # endif diff --git a/source/lib/omnitrace/library/rocprofiler.cpp b/source/lib/rocprof-sys/library/rocprofiler.cpp similarity index 94% rename from source/lib/omnitrace/library/rocprofiler.cpp rename to source/lib/rocprof-sys/library/rocprofiler.cpp index e80bbd56..5e155b87 100644 --- a/source/lib/omnitrace/library/rocprofiler.cpp +++ b/source/lib/rocprof-sys/library/rocprofiler.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -50,7 +50,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace rocprofiler { @@ -71,8 +71,8 @@ get_event_names() void fatal(const std::string& msg) { - OMNITRACE_PRINT_F("\n"); - OMNITRACE_PRINT_F("%s\n", msg.c_str()); + ROCPROFSYS_PRINT_F("\n"); + ROCPROFSYS_PRINT_F("%s\n", msg.c_str()); abort(); } @@ -94,7 +94,7 @@ rocm_check_status(hsa_status_t _status, const std::set& _nonfatal if(_nonfatal.count(_status) == 0) fatal(JOIN(" :: ", "ERROR", rocm_error_string(_status))); - OMNITRACE_PRINT_F("Warning! %s\n", rocm_error_string(_status)); + ROCPROFSYS_PRINT_F("Warning! %s\n", rocm_error_string(_status)); return false; } return true; @@ -240,8 +240,8 @@ metrics_input(unsigned _device, rocprofiler_feature_t** ret) auto _this_device = JOIN("", ":device=", _device); for(auto itr : _events) { - OMNITRACE_VERBOSE_F(3, "Processing feature '%s' for device %u...\n", itr.c_str(), - _device); + ROCPROFSYS_VERBOSE_F(3, "Processing feature '%s' for device %u...\n", itr.c_str(), + _device); auto _pos = itr.find(":device="); if(_pos != std::string::npos) { @@ -262,8 +262,8 @@ metrics_input(unsigned _device, rocprofiler_feature_t** ret) // PMC events for(unsigned i = 0; i < feature_count; ++i) { - OMNITRACE_VERBOSE_F(3, "Adding feature '%s' for device %u...\n", - _features.at(i).c_str(), _device); + ROCPROFSYS_VERBOSE_F(3, "Adding feature '%s' for device %u...\n", + _features.at(i).c_str(), _device); features[i].kind = ROCPROFILER_FEATURE_KIND_METRIC; features[i].name = strdup(_features.at(i).c_str()); features[i].parameters = nullptr; @@ -353,7 +353,7 @@ rocm_metrics() (void) HsaRsrcFactory::Instance(); } catch(std::runtime_error& _e) { - OMNITRACE_VERBOSE_F(0, "%s\n", _e.what()); + ROCPROFSYS_VERBOSE_F(0, "%s\n", _e.what()); return _data; } @@ -372,8 +372,8 @@ rocm_metrics() info_data_callback, reinterpret_cast(&_data)), { HSA_STATUS_ERROR_NOT_INITIALIZED })) { - OMNITRACE_WARNING_F(-1, "rocprofiler_iterate_info failed for gpu agent %u\n", - i); + ROCPROFSYS_WARNING_F(-1, "rocprofiler_iterate_info failed for gpu agent %u\n", + i); } } @@ -384,15 +384,15 @@ rocm_metrics() info_data_callback, reinterpret_cast(&_data)), { HSA_STATUS_ERROR_NOT_INITIALIZED })) { - OMNITRACE_WARNING_F(-1, "rocprofiler_iterate_info failed for %i gpu agents\n", - gpu_count); + ROCPROFSYS_WARNING_F( + -1, "rocprofiler_iterate_info failed for %i gpu agents\n", gpu_count); } } auto _settings = tim::settings::shared_instance(); if(_settings) { - auto ritr = _settings->find("OMNITRACE_ROCM_EVENTS"); + auto ritr = _settings->find("ROCPROFSYS_ROCM_EVENTS"); if(ritr != _settings->end()) { auto _rocm_events = ritr->second; @@ -468,7 +468,7 @@ rocm_initialize() rocprofiler_queue_callbacks_t callbacks_ptrs{}; callbacks_ptrs.dispatch = rocm_dispatch_callback; int err = rocprofiler_set_queue_callbacks(callbacks_ptrs, callbacks_arg); - OMNITRACE_VERBOSE_F(3, "err=%d, rocprofiler_set_queue_callbacks\n", err); + ROCPROFSYS_VERBOSE_F(3, "err=%d, rocprofiler_set_queue_callbacks\n", err); is_setup() = true; } @@ -504,7 +504,7 @@ post_process_perfetto() auto _device_fields = std::map>{}; auto _device_range = std::map>{}; - for(size_t i = 0; i < OMNITRACE_MAX_THREADS; ++i) + for(size_t i = 0; i < ROCPROFSYS_MAX_THREADS; ++i) { auto& _v = component::rocm_data(i); if(_v) @@ -624,7 +624,7 @@ post_process_timemory() auto _device_fields = std::map>{}; auto _device_range = std::map>{}; - for(size_t i = 0; i < OMNITRACE_MAX_THREADS; ++i) + for(size_t i = 0; i < ROCPROFSYS_MAX_THREADS; ++i) { auto& _v = component::rocm_data(i); if(_v) @@ -672,7 +672,7 @@ post_process_timemory() rocm_event* parent = nullptr; mutable std::vector children = {}; - OMNITRACE_DEFAULT_OBJECT(local_event) + ROCPROFSYS_DEFAULT_OBJECT(local_event) explicit local_event(rocm_event* _v) : parent{ _v } @@ -752,8 +752,8 @@ post_process_timemory() for(auto& ditr : _device_data) { - OMNITRACE_VERBOSE_F(1, "Post-processing %zu entries for device %u...\n", - ditr.second.size(), ditr.first); + ROCPROFSYS_VERBOSE_F(1, "Post-processing %zu entries for device %u...\n", + ditr.second.size(), ditr.first); auto _storage = std::vector{}; for(auto& itr : ditr.second) { @@ -795,8 +795,8 @@ post_process_timemory() } } - OMNITRACE_VERBOSE_F(3, "Average # of iterations before match: %.1f\n", - _avg / ditr.second.size() * 100.0); + ROCPROFSYS_VERBOSE_F(3, "Average # of iterations before match: %.1f\n", + _avg / ditr.second.size() * 100.0); for(auto& sitr : _storage) { @@ -808,7 +808,7 @@ post_process_timemory() itr.write(); } - tim::trait::runtime_enabled::set(false); + tim::trait::runtime_enabled::set(false); } } // namespace @@ -831,4 +831,4 @@ post_process() } } } // namespace rocprofiler -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/rocprofiler.hpp b/source/lib/rocprof-sys/library/rocprofiler.hpp similarity index 91% rename from source/lib/omnitrace/library/rocprofiler.hpp rename to source/lib/rocprof-sys/library/rocprofiler.hpp index 26eb9b58..a87784c8 100644 --- a/source/lib/omnitrace/library/rocprofiler.hpp +++ b/source/lib/rocprof-sys/library/rocprofiler.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -46,7 +46,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace rocprofiler { @@ -68,7 +68,7 @@ post_process(); std::vector rocm_metrics(); -#if !defined(OMNITRACE_USE_ROCPROFILER) || OMNITRACE_USE_ROCPROFILER == 0 +#if !defined(ROCPROFSYS_USE_ROCPROFILER) || ROCPROFSYS_USE_ROCPROFILER == 0 inline void post_process() {} @@ -85,4 +85,4 @@ rocm_metrics() #endif } // namespace rocprofiler -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/roctracer.cpp b/source/lib/rocprof-sys/library/roctracer.cpp similarity index 92% rename from source/lib/omnitrace/library/roctracer.cpp rename to source/lib/rocprof-sys/library/roctracer.cpp index 224f5972..daf6bb8a 100644 --- a/source/lib/omnitrace/library/roctracer.cpp +++ b/source/lib/rocprof-sys/library/roctracer.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -48,22 +48,22 @@ #include #include -#if OMNITRACE_HIP_VERSION < 50300 +#if ROCPROFSYS_HIP_VERSION < 50300 # include #endif #define AMD_INTERNAL_BUILD 1 #include -#if __has_include() || (defined(OMNITRACE_USE_HIP) && OMNITRACE_USE_HIP > 0) +#if __has_include() || (defined(ROCPROFSYS_USE_HIP) && ROCPROFSYS_USE_HIP > 0) # include -# define OMNITRACE_HIP_API_ARGS 1 +# define ROCPROFSYS_HIP_API_ARGS 1 #else -# define OMNITRACE_HIP_API_ARGS 0 +# define ROCPROFSYS_HIP_API_ARGS 0 #endif TIMEMORY_DEFINE_API(roctracer) -namespace omnitrace +namespace rocprofsys { namespace { @@ -78,7 +78,7 @@ roctracer_type_mutex() std::string hip_api_string(hip_api_id_t id, const hip_api_data_t* data) { -#if OMNITRACE_HIP_API_ARGS > 0 +#if ROCPROFSYS_HIP_API_ARGS > 0 std::string _v = hipApiString(id, data); if(_v.empty()) return _v; auto _pbeg = _v.find('('); @@ -160,7 +160,7 @@ get_hip_activity_mutex(int64_t _tid = threading::get_id()) int64_t get_clock_skew() { - static auto _use = tim::get_env("OMNITRACE_USE_ROCTRACER_CLOCK_SKEW", true); + static auto _use = tim::get_env("ROCPROFSYS_USE_ROCTRACER_CLOCK_SKEW", true); if(!_use) return 0; static auto _v = []() { namespace cpu = tim::cpu; @@ -176,7 +176,7 @@ get_clock_skew() static auto _gpu_now = []() { cpu::fence(); uint64_t _ts = 0; - OMNITRACE_ROCTRACER_CALL(roctracer_get_timestamp(&_ts)); + ROCPROFSYS_ROCTRACER_CALL(roctracer_get_timestamp(&_ts)); return _ts; }; @@ -207,10 +207,10 @@ get_clock_skew() _cpu_ave += _cpu_ts / _n; _gpu_ave += _gpu_ts / _n; } - OMNITRACE_BASIC_VERBOSE(2, "CPU timestamp: %li\n", _cpu_ave); - OMNITRACE_BASIC_VERBOSE(2, "HIP timestamp: %li\n", _gpu_ave); - OMNITRACE_BASIC_VERBOSE(1, "CPU/HIP timestamp skew: %li (used: %s)\n", _diff, - _use ? "yes" : "no"); + ROCPROFSYS_BASIC_VERBOSE(2, "CPU timestamp: %li\n", _cpu_ave); + ROCPROFSYS_BASIC_VERBOSE(2, "HIP timestamp: %li\n", _gpu_ave); + ROCPROFSYS_BASIC_VERBOSE(1, "CPU/HIP timestamp skew: %li (used: %s)\n", _diff, + _use ? "yes" : "no"); _diff /= _n; return _diff; }(); @@ -224,11 +224,11 @@ hsa_api_callback(uint32_t domain, uint32_t cid, const void* callback_data, void* if(get_state() != State::Active || !trait::runtime_enabled::get()) return; - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); (void) arg; const hsa_api_data_t* data = reinterpret_cast(callback_data); - OMNITRACE_CONDITIONAL_PRINT_F( + ROCPROFSYS_CONDITIONAL_PRINT_F( get_debug() && get_verbose() >= 2, "<%-30s id(%u)\tcorrelation_id(%lu) %s>\n", roctracer_op_string(domain, cid, 0), cid, data->correlation_id, (data->phase == ACTIVITY_API_PHASE_ENTER) ? "on-enter" : "on-exit"); @@ -344,7 +344,7 @@ hsa_activity_callback(uint32_t op, const void* vrecord, void* arg) if(get_state() != State::Active || !trait::runtime_enabled::get()) return; - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); auto&& _protect = comp::roctracer::protect_flush_activity(); (void) _protect; @@ -362,8 +362,8 @@ hsa_activity_callback(uint32_t op, const void* vrecord, void* arg) default: break; } - OMNITRACE_CI_FAIL(_name == nullptr, "Error! HSA operation type not handled: %u\n", - op); + ROCPROFSYS_CI_FAIL(_name == nullptr, "Error! HSA operation type not handled: %u\n", + op); if(!_name) return; @@ -414,7 +414,7 @@ hip_exec_activity_callbacks(int64_t _tid) // guard against initialization of structure when trying to exec if(static_cast(_tid) >= get_hip_activity_callbacks_size()) return; - // OMNITRACE_ROCTRACER_CALL(roctracer_flush_activity()); + // ROCPROFSYS_ROCTRACER_CALL(roctracer_flush_activity()); locking::atomic_lock _lk{ get_hip_activity_mutex(_tid) }; auto& _async_ops = get_hip_activity_callbacks(_tid); if(!_async_ops) return; @@ -437,7 +437,7 @@ roctx_api_callback(uint32_t domain, uint32_t cid, const void* callback_data, if(get_state() != State::Active || !trait::runtime_enabled::get()) return; - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); if(domain != ACTIVITY_DOMAIN_ROCTX) return; @@ -467,8 +467,8 @@ roctx_api_callback(uint32_t domain, uint32_t cid, const void* callback_data, } else { - OMNITRACE_THROW("Error! roctxRangePop stack is empty! Expected " - "roctxRangePush/roctxRangePop on same thread\n"); + ROCPROFSYS_THROW("Error! roctxRangePop stack is empty! Expected " + "roctxRangePush/roctxRangePop on same thread\n"); } break; } @@ -491,13 +491,13 @@ roctx_api_callback(uint32_t domain, uint32_t cid, const void* callback_data, locking::atomic_lock _lk{ _range_lock, std::defer_lock }; if(!_lk.owns_lock()) _lk.lock(); auto itr = _range_map.find(roctx_range_id_t{ _data->args.id }); - OMNITRACE_CI_THROW(itr == _range_map.end(), - "Error! could not find range with id %lu\n", - _data->args.id); + ROCPROFSYS_CI_THROW(itr == _range_map.end(), + "Error! could not find range with id %lu\n", + _data->args.id); if(itr == _range_map.end()) { - OMNITRACE_VERBOSE(0, "Warning! could not find range with id %lu\n", - _data->args.id); + ROCPROFSYS_VERBOSE(0, "Warning! could not find range with id %lu\n", + _data->args.id); return; } else @@ -533,7 +533,7 @@ hip_api_callback(uint32_t domain, uint32_t cid, const void* callback_data, void* if(get_state() != State::Active || !trait::runtime_enabled::get()) return; - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); assert(domain == ACTIVITY_DOMAIN_HIP_API); const char* op_name = roctracer_op_string(domain, cid, 0); @@ -546,8 +546,8 @@ hip_api_callback(uint32_t domain, uint32_t cid, const void* callback_data, void* case HIP_API_ID___hipPushCallConfiguration: case HIP_API_ID___hipPopCallConfiguration: case HIP_API_ID_hipDeviceEnablePeerAccess: -#if OMNITRACE_HIP_VERSION_MAJOR > 4 || \ - (OMNITRACE_HIP_VERSION_MAJOR == 4 && OMNITRACE_HIP_VERSION_MINOR >= 3) +#if ROCPROFSYS_HIP_VERSION_MAJOR > 4 || \ + (ROCPROFSYS_HIP_VERSION_MAJOR == 4 && ROCPROFSYS_HIP_VERSION_MINOR >= 3) case HIP_API_ID_hipImportExternalMemory: case HIP_API_ID_hipDestroyExternalMemory: #endif @@ -556,7 +556,7 @@ hip_api_callback(uint32_t domain, uint32_t cid, const void* callback_data, void* } const hip_api_data_t* data = reinterpret_cast(callback_data); - OMNITRACE_CONDITIONAL_PRINT_F( + ROCPROFSYS_CONDITIONAL_PRINT_F( get_debug() && get_verbose() >= 2, "<%-30s id(%u)\tcorrelation_id(%lu) %s>\n", op_name, cid, data->correlation_id, (data->phase == ACTIVITY_API_PHASE_ENTER) ? "on-enter" : "on-exit"); @@ -639,11 +639,11 @@ hip_api_callback(uint32_t domain, uint32_t cid, const void* callback_data, void* { static auto _compact_annotations = config::get_setting_value( - "OMNITRACE_PERFETTO_COMPACT_ROCTRACER_ANNOTATIONS") + "ROCPROFSYS_PERFETTO_COMPACT_ROCTRACER_ANNOTATIONS") .value_or(false); static auto _enable_backtraces = - config::get_setting_value("OMNITRACE_ROCTRACER_HIP_API_BACKTRACE") + config::get_setting_value("ROCPROFSYS_ROCTRACER_HIP_API_BACKTRACE") .value_or(false); constexpr size_t bt_stack_depth = 16; @@ -806,7 +806,7 @@ hip_activity_callback(const char* begin, const char* end, void* arg) if(get_state() != State::Active || !trait::runtime_enabled::get()) return; - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); auto&& _protect = comp::roctracer::protect_flush_activity(); (void) _protect; @@ -815,14 +815,14 @@ hip_activity_callback(const char* begin, const char* end, void* arg) static auto _kernel_names = std::unordered_map{}; static auto _indexes = std::unordered_map{}; static auto _skip_barrier_packets = - config::get_setting_value("OMNITRACE_ROCTRACER_DISCARD_BARRIERS") + config::get_setting_value("ROCPROFSYS_ROCTRACER_DISCARD_BARRIERS") .value_or(false); const roctracer_record_t* record = reinterpret_cast(begin); const roctracer_record_t* end_record = reinterpret_cast(end); auto&& _advance_record = [&record]() { - OMNITRACE_ROCTRACER_CALL(roctracer_next_record(record, &record)); + ROCPROFSYS_ROCTRACER_CALL(roctracer_next_record(record, &record)); }; while(record < end_record) @@ -830,7 +830,7 @@ hip_activity_callback(const char* begin, const char* end, void* arg) // make sure every iteration advances regardless of where return point happens scope::destructor _next_dtor{ _advance_record }; - // OMNITRACE_CI will enable these asserts and should fail if something relevant + // ROCPROFSYS_CI will enable these asserts and should fail if something relevant // changes assert(HIP_OP_ID_DISPATCH == 0); assert(HIP_OP_ID_COPY == 1); @@ -884,9 +884,9 @@ hip_activity_callback(const char* begin, const char* end, void* arg) auto _verbose = []() { return get_verbose() >= 0 || get_debug(); }; static size_t _n = 0; static size_t _nmax = - get_env("OMNITRACE_ROCTRACER_DISCARD_INVALID", 0); + get_env("ROCPROFSYS_ROCTRACER_DISCARD_INVALID", 0); if(_nmax == 0) std::swap(_end_ns, _beg_ns); - OMNITRACE_WARNING_IF_F( + ROCPROFSYS_WARNING_IF_F( _n < _nmax && _verbose(), "%4zu :: Discarding kernel roctracer activity record which ended before " "it started :: %-20s :: %-20s :: cid=%lu, time_ns=(%12lu:%12lu) " @@ -894,11 +894,11 @@ hip_activity_callback(const char* begin, const char* end, void* arg) _n, op_name, _name, record->correlation_id, _beg_ns, _end_ns, (static_cast(_end_ns) - static_cast(_beg_ns)), _devid, _queid, record->process_id, _tid, _op_id_names.at(record->op)); - OMNITRACE_WARNING_IF_F( + ROCPROFSYS_WARNING_IF_F( _nmax > 0 && _n == _nmax && _verbose(), "Suppressing future messages about discarding kernel roctracer activity " "record which ended before it started. Set " - "OMNITRACE_ROCTRACER_DISCARD_INVALID=N to increase/decrease the number " + "ROCPROFSYS_ROCTRACER_DISCARD_INVALID=N to increase/decrease the number " "of messages. If N is set to 0, data will be included after swapping the " "begin and end values\n"); if(_end_ns < _beg_ns) @@ -975,7 +975,7 @@ hip_activity_callback(const char* begin, const char* end, void* arg) bool& roctracer_is_init() { - static bool _v = tim::get_env("OMNITRACE_ROCTRACER_IS_INIT", false); + static bool _v = tim::get_env("ROCPROFSYS_ROCTRACER_IS_INIT", false); return _v; } @@ -1001,4 +1001,4 @@ roctracer_shutdown_routines() static auto _v = roctracer_functions_t{}; return _v; } -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/roctracer.hpp b/source/lib/rocprof-sys/library/roctracer.hpp similarity index 89% rename from source/lib/omnitrace/library/roctracer.hpp rename to source/lib/rocprof-sys/library/roctracer.hpp index 5b773389..e0f0a4a1 100644 --- a/source/lib/omnitrace/library/roctracer.hpp +++ b/source/lib/rocprof-sys/library/roctracer.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -33,17 +33,17 @@ #include // Macro to check ROC-tracer calls status -#define OMNITRACE_ROCTRACER_CALL(call) \ +#define ROCPROFSYS_ROCTRACER_CALL(call) \ { \ - OMNITRACE_DEBUG_F(#call); \ + ROCPROFSYS_DEBUG_F(#call); \ int err = call; \ if(err != 0) \ { \ - OMNITRACE_PRINT_F("%s in: %s\n", roctracer_error_string(), #call); \ + ROCPROFSYS_PRINT_F("%s in: %s\n", roctracer_error_string(), #call); \ } \ } -namespace omnitrace +namespace rocprofsys { using roctracer_hip_bundle_t = tim::component_bundle; @@ -86,4 +86,4 @@ roctracer_setup_routines(); roctracer_functions_t& roctracer_shutdown_routines(); -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/runtime.cpp b/source/lib/rocprof-sys/library/runtime.cpp similarity index 87% rename from source/lib/omnitrace/library/runtime.cpp rename to source/lib/rocprof-sys/library/runtime.cpp index 66cb12eb..db082710 100644 --- a/source/lib/omnitrace/library/runtime.cpp +++ b/source/lib/rocprof-sys/library/runtime.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -52,19 +52,20 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace { -auto root_process_id = get_env("OMNITRACE_ROOT_PROCESS", process::get_id(), false); +auto root_process_id = + get_env("ROCPROFSYS_ROOT_PROCESS", process::get_id(), false); auto& get_sampling_on_child_threads_history(int64_t _idx = utility::get_thread_index()) { - static auto _v = utility::get_filled_array( + static auto _v = utility::get_filled_array( []() { return utility::get_reserved_vector(32); }); - if(_idx >= OMNITRACE_MAX_THREADS) + if(_idx >= ROCPROFSYS_MAX_THREADS) { static thread_local auto _tl_v = utility::get_reserved_vector(32); return _tl_v; @@ -102,10 +103,10 @@ get_cpu_cid() unique_ptr_t>& get_cpu_cid_stack(int64_t _tid, int64_t _parent) { - struct omnitrace_cpu_cid_stack + struct rocprofsys_cpu_cid_stack {}; - using init_data_t = thread_data; - using thread_data_t = thread_data, omnitrace_cpu_cid_stack>; + using init_data_t = thread_data; + using thread_data_t = thread_data, rocprofsys_cpu_cid_stack>; auto& _v_tid = thread_data_t::instance(construct_on_thread{ _tid }); auto& _b_tid = init_data_t::instance(construct_on_thread{ _tid }, false); @@ -127,9 +128,9 @@ get_cpu_cid_stack(int64_t _tid, int64_t _parent) unique_ptr_t& get_cpu_cid_parents(int64_t _tid) { - struct omnitrace_cpu_cid_stack + struct rocprofsys_cpu_cid_stack {}; - using thread_data_t = thread_data; + using thread_data_t = thread_data; return thread_data_t::instance(construct_on_thread{ _tid }, cpu_cid_parent_map_t{}); } @@ -138,7 +139,7 @@ create_cpu_cid_entry(int64_t _tid) { using tim::auto_lock_t; - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); // unique lock for _tid auto& _mtx = get_cpu_cid_stack_lock(_tid); @@ -178,7 +179,7 @@ get_cpu_cid_stack_lock(int64_t _tid) { struct cpu_cid_stack_s {}; - return tim::type_mutex( + return tim::type_mutex( _tid); } @@ -191,7 +192,7 @@ setup_gotchas() if(_initialized) return; _initialized = true; - OMNITRACE_BASIC_DEBUG( + ROCPROFSYS_BASIC_DEBUG( "Configuring gotcha wrapper around fork, MPI_Init, and MPI_Init_thread\n"); component::mpi_gotcha::configure(); @@ -207,7 +208,7 @@ get_main_bundle() auto _self = RUSAGE_SELF; std::swap(_self, tim::get_rusage_type()); auto _tmp = std::make_unique( - JOIN('/', "omnitrace/process", process::get_id()), + JOIN('/', "rocprofsys/process", process::get_id()), quirk::config{}); std::swap(_self, tim::get_rusage_type()); return _tmp; @@ -219,7 +220,7 @@ std::unique_ptr& get_init_bundle() { static auto _v = std::make_unique( - JOIN('/', "omnitrace/process", process::get_id())); + JOIN('/', "rocprofsys/process", process::get_id())); return _v; } @@ -228,7 +229,7 @@ get_preinit_bundle() { static auto _v = (setup_gotchas(), std::make_unique( - JOIN('/', "omnitrace/process", process::get_id()), + JOIN('/', "rocprofsys/process", process::get_id()), quirk::config{})); return _v; } @@ -286,4 +287,4 @@ is_child_process() { return (root_process_id != process::get_id()); } -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/runtime.hpp b/source/lib/rocprof-sys/library/runtime.hpp similarity index 91% rename from source/lib/omnitrace/library/runtime.hpp rename to source/lib/rocprof-sys/library/runtime.hpp index ec3bf9c3..7d64c326 100644 --- a/source/lib/omnitrace/library/runtime.hpp +++ b/source/lib/rocprof-sys/library/runtime.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -45,7 +45,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { // started during preinit phase using preinit_bundle_t = @@ -55,7 +55,7 @@ using preinit_bundle_t = using init_bundle_t = tim::lightweight_tuple; -// bundle of components around omnitrace_init and omnitrace_finalize +// bundle of components around rocprofsys_init and rocprofsys_finalize using main_bundle_t = tim::lightweight_tuple; @@ -130,11 +130,11 @@ is_root_process(); bool is_child_process(); -} // namespace omnitrace +} // namespace rocprofsys -#define OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(VALUE) \ - ::omnitrace::scoped_child_sampling OMNITRACE_VARIABLE(_scoped_child_sampling_, \ - __LINE__) \ +#define ROCPROFSYS_SCOPED_SAMPLING_ON_CHILD_THREADS(VALUE) \ + ::rocprofsys::scoped_child_sampling ROCPROFSYS_VARIABLE(_scoped_child_sampling_, \ + __LINE__) \ { \ VALUE \ } diff --git a/source/lib/omnitrace/library/sampling.cpp b/source/lib/rocprof-sys/library/sampling.cpp similarity index 88% rename from source/lib/omnitrace/library/sampling.cpp rename to source/lib/rocprof-sys/library/sampling.cpp index 3c991aa3..6615fcd1 100644 --- a/source/lib/omnitrace/library/sampling.cpp +++ b/source/lib/rocprof-sys/library/sampling.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -99,7 +99,7 @@ plus(Tp&& _lhs, const Up& _rhs) } } // namespace math } // namespace tim -namespace omnitrace +namespace rocprofsys { namespace sampling { @@ -132,16 +132,16 @@ using component::sampling_gpu_temp; using component::sampling_percent; using component::sampling_wall_clock; } // namespace sampling -} // namespace omnitrace +} // namespace rocprofsys -OMNITRACE_DEFINE_CONCRETE_TRAIT(prevent_reentry, sampling::sampler_t, std::true_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(prevent_reentry, sampling::sampler_t, std::true_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(provide_backtrace, sampling::sampler_t, std::false_type) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(provide_backtrace, sampling::sampler_t, std::false_type) -OMNITRACE_DEFINE_CONCRETE_TRAIT(buffer_size, sampling::sampler_t, - TIMEMORY_ESC(std::integral_constant)) +ROCPROFSYS_DEFINE_CONCRETE_TRAIT(buffer_size, sampling::sampler_t, + TIMEMORY_ESC(std::integral_constant)) -namespace omnitrace +namespace rocprofsys { namespace sampling { @@ -164,8 +164,8 @@ configure_sampler_allocator(std::shared_ptr& _v) { if(_v) return; - OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false); - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_SAMPLING_ON_CHILD_THREADS(false); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); _v = std::make_shared(); _v->reserve(config::get_sampling_allocator_size()); @@ -196,7 +196,7 @@ get_sampler_allocator() auto& _allocators = get_sampler_allocators(); - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); auto_lock_t _lk{ type_mutex() }; @@ -356,7 +356,7 @@ start_duration_thread() if(_premature && !_finalized) { // protect against spurious wakeups - OMNITRACE_VERBOSE( + ROCPROFSYS_VERBOSE( 2, "%sSpurious wakeup of sampling duration thread...\n", tim::log::color::warning()); _wait = true; @@ -368,19 +368,19 @@ start_duration_thread() else { get_duration_disabled().store(true); - OMNITRACE_VERBOSE(1, - "Sampling duration of %f seconds has elapsed. " - "Shutting down sampling...\n", - config::get_sampling_duration()); + ROCPROFSYS_VERBOSE(1, + "Sampling duration of %f seconds has elapsed. " + "Shutting down sampling...\n", + config::get_sampling_duration()); configure(false, 0); } } }; - OMNITRACE_VERBOSE(1, "Sampling will be disabled after %f seconds...\n", - config::get_sampling_duration()); + ROCPROFSYS_VERBOSE(1, "Sampling will be disabled after %f seconds...\n", + config::get_sampling_duration()); - OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false); + ROCPROFSYS_SCOPED_SAMPLING_ON_CHILD_THREADS(false); get_duration_thread() = std::make_unique(_func); _protect = false; } @@ -394,9 +394,9 @@ get_offload_file() if(get_use_tmp_files()) { auto _success = _tmp_v->open(); - OMNITRACE_CI_FAIL(!_success, - "Error opening sampling offload temporary file '%s'\n", - _tmp_v->filename.c_str()); + ROCPROFSYS_CI_FAIL(!_success, + "Error opening sampling offload temporary file '%s'\n", + _tmp_v->filename.c_str()); } return _tmp_v; }(); @@ -419,26 +419,26 @@ auto offload_seq_data = std::unordered_map>{}; void offload_buffer(int64_t _seq, sampler_buffer_t&& _buf) { - OMNITRACE_REQUIRE(get_use_tmp_files()) + ROCPROFSYS_REQUIRE(get_use_tmp_files()) << "Error! sampling allocator tries to offload buffer of samples but " - "omnitrace was configured to not use temporary files\n"; + "rocprof-sys was configured to not use temporary files\n"; // use homemade atomic_mutex/atomic_lock since contention will be low // and using pthread_lock might trigger our wrappers auto _lk = locking::atomic_lock{ get_offload_mutex() }; auto& _file = get_offload_file(); - OMNITRACE_REQUIRE(_file) + ROCPROFSYS_REQUIRE(_file) << "Error! sampling allocator tried to offload buffer of samples for thread " << _seq << " but the offload file does not exist\n"; - OMNITRACE_VERBOSE_F(2, "Offloading %zu samples for thread %li to %s...\n", - _buf.count(), _seq, _file->filename.c_str()); + ROCPROFSYS_VERBOSE_F(2, "Offloading %zu samples for thread %li to %s...\n", + _buf.count(), _seq, _file->filename.c_str()); auto& _fs = _file->stream; - OMNITRACE_REQUIRE(_fs.good()) << "Error! temporary file for offloading buffer is in " - "an invalid state during offload for thread " - << _seq << "\n"; + ROCPROFSYS_REQUIRE(_fs.good()) << "Error! temporary file for offloading buffer is in " + "an invalid state during offload for thread " + << _seq << "\n"; offload_seq_data[_seq].emplace(_fs.tellg()); _fs.write(reinterpret_cast(&_seq), sizeof(_seq)); @@ -454,7 +454,7 @@ load_offload_buffer(int64_t _thread_idx) auto _data = std::vector{}; if(!get_use_tmp_files()) { - OMNITRACE_WARNING_F( + ROCPROFSYS_WARNING_F( 2, "[sampling] returning no data because using temporary files is disabled"); return _data; } @@ -465,7 +465,7 @@ load_offload_buffer(int64_t _thread_idx) auto& _file = get_offload_file(); if(!_file) { - OMNITRACE_WARNING_F( + ROCPROFSYS_WARNING_F( 0, "[sampling] returning no data because the offload file no longer exists"); return _data; } @@ -476,7 +476,7 @@ load_offload_buffer(int64_t _thread_idx) if(!_file->open(std::ios::binary | std::ios::in)) { - OMNITRACE_WARNING_F(0, "[sampling] %s failed to open", _file->filename.c_str()); + ROCPROFSYS_WARNING_F(0, "[sampling] %s failed to open", _file->filename.c_str()); return _data; } @@ -496,7 +496,7 @@ load_offload_buffer(int64_t _thread_idx) if(_seq != _thread_idx) { - OMNITRACE_WARNING_F( + ROCPROFSYS_WARNING_F( 0, "[sampling] file position %zu returned %zi instead of (expected) %zi\n", static_cast(itr), _seq, _thread_idx); @@ -506,8 +506,8 @@ load_offload_buffer(int64_t _thread_idx) _data.emplace_back(std::move(_buffer)); } - OMNITRACE_VERBOSE_F(2, "[sampling] Loaded %zu samples for thread %li...\n", _count, - _thread_idx); + ROCPROFSYS_VERBOSE_F(2, "[sampling] Loaded %zu samples for thread %li...\n", _count, + _thread_idx); _file->close(); @@ -524,12 +524,12 @@ configure(bool _setup, int64_t _tid) bool _is_running = (!_running) ? false : *_running; auto& _signal_types = sampling::get_signal_types(_tid); - OMNITRACE_CONDITIONAL_THROW(get_use_causal(), - "Internal error! configuring sampling not permitted when " - "causal profiling is enabled"); + ROCPROFSYS_CONDITIONAL_THROW( + get_use_causal(), "Internal error! configuring sampling not permitted when " + "causal profiling is enabled"); - OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false); - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_SAMPLING_ON_CHILD_THREADS(false); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); auto&& _cputime_tids = get_sampling_cputime_tids(); auto&& _realtime_tids = get_sampling_realtime_tids(); @@ -540,7 +540,7 @@ configure(bool _setup, int64_t _tid) { if(_tids.count(_tid) == 0) { - OMNITRACE_VERBOSE(3, "Disabling SIG%i from thread %li\n", _signum, _tid); + ROCPROFSYS_VERBOSE(3, "Disabling SIG%i from thread %li\n", _signum, _tid); _signal_types->erase(_signum); } } @@ -575,12 +575,12 @@ configure(bool _setup, int64_t _tid) auto _verbose = std::min(get_verbose() - 2, 2); if(get_debug_sampling()) _verbose = 2; - OMNITRACE_DEBUG("Requesting allocator for sampler on thread %lu...\n", _tid); + ROCPROFSYS_DEBUG("Requesting allocator for sampler on thread %lu...\n", _tid); auto _alloc = get_sampler_allocator(); - OMNITRACE_DEBUG("Configuring sampler for thread %lu...\n", _tid); + ROCPROFSYS_DEBUG("Configuring sampler for thread %lu...\n", _tid); sampling::sampler_instances::construct(construct_on_thread{ _tid }, _alloc, - "omnitrace", _tid, _verbose); + "rocprofsys", _tid, _verbose); _sampler->set_flags(SA_RESTART); _sampler->set_verbose(_verbose); @@ -613,7 +613,7 @@ configure(bool _setup, int64_t _tid) auto _freq = get_sampling_overflow_freq(); auto _overflow_event = - get_setting_value("OMNITRACE_SAMPLING_OVERFLOW_EVENT") + get_setting_value("ROCPROFSYS_SAMPLING_OVERFLOW_EVENT") .value_or("perf::PERF_COUNT_HW_CACHE_REFERENCES"); perf::config_overflow_sampling(_pe, _overflow_event, _freq); @@ -637,7 +637,7 @@ configure(bool _setup, int64_t _tid) auto _perf_open_error = _perf_sampler->open(_pe, _info->index_data->system_value); - OMNITRACE_REQUIRE(!_perf_open_error) + ROCPROFSYS_REQUIRE(!_perf_open_error) << "perf backend for overflow failed to activate: " << *_perf_open_error; _perf_sampler->set_ready_signal(get_sampling_overflow_signal()); @@ -669,7 +669,7 @@ configure(bool _setup, int64_t _tid) static_assert(tim::trait::buffer_size::value > 0, "Error! Zero buffer size"); - OMNITRACE_CONDITIONAL_THROW( + ROCPROFSYS_CONDITIONAL_THROW( _sampler->get_buffer_size() != tim::trait::buffer_size::value, "dynamic sampler has a buffer size different from static trait: %zu instead " @@ -677,7 +677,7 @@ configure(bool _setup, int64_t _tid) _sampler->get_buffer_size(), tim::trait::buffer_size::value); - OMNITRACE_CONDITIONAL_THROW( + ROCPROFSYS_CONDITIONAL_THROW( _sampler->get_buffer_size() <= 0, "dynamic sampler requires a positive buffer size: %zu", _sampler->get_buffer_size()); @@ -688,12 +688,12 @@ configure(bool _setup, int64_t _tid) { auto _freq = get_sampling_overflow_freq(); auto _overflow_event = - get_setting_value("OMNITRACE_SAMPLING_OVERFLOW_EVENT") + get_setting_value("ROCPROFSYS_SAMPLING_OVERFLOW_EVENT") .value_or("perf::PERF_COUNT_HW_CACHE_REFERENCES"); - OMNITRACE_VERBOSE(2, - "[SIG%i] Sampler for thread %lu will be triggered " - "every %.1f %s events...\n", - itr, _tid, _freq, _overflow_event.c_str()); + ROCPROFSYS_VERBOSE(2, + "[SIG%i] Sampler for thread %lu will be triggered " + "every %.1f %s events...\n", + itr, _tid, _freq, _overflow_event.c_str()); } else { @@ -703,7 +703,7 @@ configure(bool _setup, int64_t _tid) dynamic_cast(_sampler->get_trigger(itr)); if(_timer) { - OMNITRACE_VERBOSE( + ROCPROFSYS_VERBOSE( 2, "[SIG%i] Sampler for thread %lu will be triggered %.1fx per " "second of %s-time (every %.3e milliseconds)...\n", @@ -720,7 +720,7 @@ configure(bool _setup, int64_t _tid) } else if(!_setup && _sampler && _is_running) { - OMNITRACE_DEBUG("Stopping sampler for thread %lu...\n", _tid); + ROCPROFSYS_DEBUG("Stopping sampler for thread %lu...\n", _tid); *_running = false; if(_tid == threading::get_id() && !_signal_types->empty()) @@ -744,13 +744,13 @@ configure(bool _setup, int64_t _tid) if(_tid == 0) { - for(int64_t i = 1; i < OMNITRACE_MAX_THREADS; ++i) + for(int64_t i = 1; i < ROCPROFSYS_MAX_THREADS; ++i) { if(sampling::get_sampler(i)) sampling::get_sampler(i)->stop(); if(perf::get_instance(i)) perf::get_instance(i)->stop(); } - for(int64_t i = 1; i < OMNITRACE_MAX_THREADS; ++i) + for(int64_t i = 1; i < ROCPROFSYS_MAX_THREADS; ++i) { if(sampling::get_sampler(i)) { @@ -769,7 +769,7 @@ configure(bool _setup, int64_t _tid) if(trait::runtime_enabled::get()) backtrace_metrics::configure(_setup, _tid); - OMNITRACE_DEBUG("Sampler destroyed for thread %lu\n", _tid); + ROCPROFSYS_DEBUG("Sampler destroyed for thread %lu\n", _tid); } return (_signal_types) ? *_signal_types : std::set{}; @@ -814,7 +814,7 @@ unique_ptr_t>& get_signal_types(int64_t _tid) { return signal_type_instances::instance(construct_on_thread{ _tid }, - omnitrace::get_sampling_signals(_tid)); + rocprofsys::get_sampling_signals(_tid)); } std::set @@ -857,12 +857,12 @@ block_signals(std::set _signals) if(_signals.empty()) _signals = *get_signal_types(threading::get_id()); if(_signals.empty()) { - OMNITRACE_VERBOSE(2, "No signals to block...\n"); + ROCPROFSYS_VERBOSE(2, "No signals to block...\n"); return; } - OMNITRACE_DEBUG("Blocking signals [%s] on thread #%lu...\n", - get_signal_names(_signals).c_str(), threading::get_id()); + ROCPROFSYS_DEBUG("Blocking signals [%s] on thread #%lu...\n", + get_signal_names(_signals).c_str(), threading::get_id()); sigset_t _v = get_signal_set(_signals); thread_sigmask(SIG_BLOCK, &_v, nullptr); @@ -874,12 +874,12 @@ unblock_signals(std::set _signals) if(_signals.empty()) _signals = *get_signal_types(threading::get_id()); if(_signals.empty()) { - OMNITRACE_VERBOSE(2, "No signals to unblock...\n"); + ROCPROFSYS_VERBOSE(2, "No signals to unblock...\n"); return; } - OMNITRACE_DEBUG("Unblocking signals [%s] on thread #%lu...\n", - get_signal_names(_signals).c_str(), threading::get_id()); + ROCPROFSYS_DEBUG("Unblocking signals [%s] on thread #%lu...\n", + get_signal_names(_signals).c_str(), threading::get_id()); sigset_t _v = get_signal_set(_signals); thread_sigmask(SIG_UNBLOCK, &_v, nullptr); @@ -888,16 +888,16 @@ unblock_signals(std::set _signals) void post_process() { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); size_t _total_data = 0; size_t _total_threads = 0; auto _external_samples = std::atomic{ 0 }; auto _internal_samples = std::atomic{ 0 }; - OMNITRACE_VERBOSE(2 || get_debug_sampling(), "Stopping sampling components...\n"); + ROCPROFSYS_VERBOSE(2 || get_debug_sampling(), "Stopping sampling components...\n"); - omnitrace::component::backtrace::stop(); + rocprofsys::component::backtrace::stop(); configure(false, 0); for(auto& itr : get_sampler_allocators()) @@ -910,7 +910,7 @@ post_process() if(!_sampler) { // this should be relatively common - OMNITRACE_CONDITIONAL_PRINT( + ROCPROFSYS_CONDITIONAL_PRINT( get_debug() && get_verbose() >= 2, "Post-processing sampling entries for thread %lu skipped (no sampler)\n", i); @@ -922,16 +922,16 @@ post_process() if(!_init) { // this is not common - OMNITRACE_PRINT("Post-processing sampling entries for thread %lu skipped " - "(not initialized)\n", - i); + ROCPROFSYS_PRINT("Post-processing sampling entries for thread %lu skipped " + "(not initialized)\n", + i); continue; } const auto& _thread_info = thread_info::get(i, SequentTID); - OMNITRACE_VERBOSE(3 || get_debug_sampling(), - "Getting sampler data for thread %lu...\n", i); + ROCPROFSYS_VERBOSE(3 || get_debug_sampling(), + "Getting sampler data for thread %lu...\n", i); auto _raw_data = _sampler->get_data(); auto _loaded_data = load_offload_buffer(i); @@ -946,11 +946,11 @@ post_process() litr.destroy(); } - OMNITRACE_VERBOSE(2 || get_debug_sampling(), - "Sampler data for thread %lu has %zu initial entries...\n", i, - _raw_data.size()); + ROCPROFSYS_VERBOSE(2 || get_debug_sampling(), + "Sampler data for thread %lu has %zu initial entries...\n", i, + _raw_data.size()); - OMNITRACE_CI_THROW( + ROCPROFSYS_CI_THROW( _sampler->get_sample_count() != _raw_data.size(), "Error! sampler recorded %zu samples but %zu samples were returned\n", _sampler->get_sample_count(), _raw_data.size()); @@ -975,9 +975,9 @@ post_process() if(!_data.empty()) { - OMNITRACE_VERBOSE(2 || get_debug_sampling(), - "Sampler data for thread %lu has %zu valid entries...\n", i, - _data.size()); + ROCPROFSYS_VERBOSE(2 || get_debug_sampling(), + "Sampler data for thread %lu has %zu valid entries...\n", + i, _data.size()); auto _timer_data = post_process_timer_data(i, _init, _data); auto _overflow_data = post_process_overflow_data(i, _init, _data); @@ -987,15 +987,16 @@ post_process() } else { - OMNITRACE_VERBOSE(2 || get_debug_sampling(), - "Sampler data for thread %lu has zero valid entries out of " - "%zu... (skipped)\n", - i, _raw_data.size()); + ROCPROFSYS_VERBOSE( + 2 || get_debug_sampling(), + "Sampler data for thread %lu has zero valid entries out of " + "%zu... (skipped)\n", + i, _raw_data.size()); } } - OMNITRACE_VERBOSE(3 || get_debug_sampling(), - "Destroying samplers and allocators...\n"); + ROCPROFSYS_VERBOSE(3 || get_debug_sampling(), + "Destroying samplers and allocators...\n"); get_offload_file().reset(); // remove the temporary file @@ -1013,11 +1014,11 @@ post_process() get_offload_file().reset(); } - OMNITRACE_VERBOSE(1 || get_debug_sampling(), - "Collected %zu samples from %zu threads... %zu samples out of %zu " - "were taken while within instrumented routines\n", - _total_data, _total_threads, _internal_samples.load(), - (_internal_samples + _external_samples)); + ROCPROFSYS_VERBOSE(1 || get_debug_sampling(), + "Collected %zu samples from %zu threads... %zu samples out of %zu " + "were taken while within instrumented routines\n", + _total_data, _total_threads, _internal_samples.load(), + (_internal_samples + _external_samples)); } namespace @@ -1123,24 +1124,24 @@ post_process_perfetto(int64_t _tid, const std::vector& _tim if(trait::runtime_enabled::get()) { - OMNITRACE_VERBOSE(3 || get_debug_sampling(), - "[%li] Post-processing metrics for perfetto...\n", _tid); + ROCPROFSYS_VERBOSE(3 || get_debug_sampling(), + "[%li] Post-processing metrics for perfetto...\n", _tid); backtrace_metrics::init_perfetto(_tid, _valid_metrics); for(const auto& itr : _timer_data) itr.m_metrics.post_process_perfetto(_tid, 0.5 * (itr.m_beg + itr.m_end)); backtrace_metrics::fini_perfetto(_tid, _valid_metrics); } - OMNITRACE_VERBOSE(3 || get_debug_sampling(), - "[%li] Post-processing backtraces for perfetto...\n", _tid); + ROCPROFSYS_VERBOSE(3 || get_debug_sampling(), + "[%li] Post-processing backtraces for perfetto...\n", _tid); const auto& _thread_info = thread_info::get(_tid, SequentTID); - OMNITRACE_CI_THROW(!_thread_info, "No valid thread info for tid=%li\n", _tid); + ROCPROFSYS_CI_THROW(!_thread_info, "No valid thread info for tid=%li\n", _tid); if(!_thread_info) return; auto _overflow_event = - get_setting_value("OMNITRACE_SAMPLING_OVERFLOW_EVENT").value_or(""); + get_setting_value("ROCPROFSYS_SAMPLING_OVERFLOW_EVENT").value_or(""); if(!_overflow_event.empty() && !_overflow_data.empty()) { @@ -1154,7 +1155,7 @@ post_process_perfetto(int64_t _tid, const std::vector& _tim _overflow_event.substr(_overflow_pos + _overflow_prefix.length()); const auto* _main_name = - static_strings.emplace(join(" ", _overflow_event, "samples [omnitrace]")) + static_strings.emplace(join(" ", _overflow_event, "samples [rocprof-sys]")) .first->c_str(); auto _track = tracing::get_perfetto_track( @@ -1239,7 +1240,7 @@ post_process_perfetto(int64_t _tid, const std::vector& _tim _thread_info->index_data->sequent_value, _thread_info->index_data->system_value); - tracing::push_perfetto_track(category::timer_sampling{}, "samples [omnitrace]", + tracing::push_perfetto_track(category::timer_sampling{}, "samples [rocprof-sys]", _track, _beg_ns, [&](::perfetto::EventContext ctx) { if(config::get_perfetto_annotations()) { @@ -1355,7 +1356,7 @@ post_process_perfetto(int64_t _tid, const std::vector& _tim } } - tracing::pop_perfetto_track(category::timer_sampling{}, "samples [omnitrace]", + tracing::pop_perfetto_track(category::timer_sampling{}, "samples [rocprof-sys]", _track, _end_ns, [&](::perfetto::EventContext ctx) { if(config::get_perfetto_annotations()) { @@ -1370,8 +1371,8 @@ void post_process_timemory(int64_t _tid, const std::vector& _timer_data, const std::vector& _overflow_data) { - OMNITRACE_VERBOSE(3 || get_debug_sampling(), - "[%li] Post-processing data for timemory...\n", _tid); + ROCPROFSYS_VERBOSE(3 || get_debug_sampling(), + "[%li] Post-processing data for timemory...\n", _tid); // compute the total number of entries int64_t _sum = 0; @@ -1575,6 +1576,6 @@ struct sampling_initialization }; } // namespace } // namespace sampling -} // namespace omnitrace +} // namespace rocprofsys -TIMEMORY_INVOKE_PREINIT(omnitrace::sampling::sampling_initialization) +TIMEMORY_INVOKE_PREINIT(rocprofsys::sampling::sampling_initialization) diff --git a/source/lib/omnitrace/library/sampling.hpp b/source/lib/rocprof-sys/library/sampling.hpp similarity index 93% rename from source/lib/omnitrace/library/sampling.hpp rename to source/lib/rocprof-sys/library/sampling.hpp index 62234f73..ae4999ee 100644 --- a/source/lib/omnitrace/library/sampling.hpp +++ b/source/lib/rocprof-sys/library/sampling.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -40,7 +40,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace sampling { @@ -66,4 +66,4 @@ void unblock_signals(std::set = {}); void post_process(); } // namespace sampling -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/thread_data.hpp b/source/lib/rocprof-sys/library/thread_data.hpp similarity index 98% rename from source/lib/omnitrace/library/thread_data.hpp rename to source/lib/rocprof-sys/library/thread_data.hpp index 98e8de4a..dfaf33b9 100644 --- a/source/lib/omnitrace/library/thread_data.hpp +++ b/source/lib/rocprof-sys/library/thread_data.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -44,11 +44,11 @@ #include #include -namespace omnitrace +namespace rocprofsys { // bundle of components used in instrumentation using instrumentation_bundle_t = - tim::component_bundle; // allocator for instrumentation_bundle_t @@ -583,7 +583,7 @@ template struct component_bundle_cache_impl { using this_type = component_bundle_cache_impl; - using bundle_type = tim::component_bundle; + using bundle_type = tim::component_bundle; using allocator_type = tim::data::ring_buffer_allocator; using array_type = std::vector; @@ -671,7 +671,7 @@ struct component_bundle_cache_impl }; template -struct component_bundle_cache_impl> +struct component_bundle_cache_impl> : component_bundle_cache_impl { using base_type = component_bundle_cache_impl; @@ -684,4 +684,4 @@ using component_bundle_cache = thread_data>; using instrumentation_bundles = component_bundle_cache; extern template struct component_bundle_cache_impl; -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/thread_deleter.cpp b/source/lib/rocprof-sys/library/thread_deleter.cpp similarity index 90% rename from source/lib/omnitrace/library/thread_deleter.cpp rename to source/lib/rocprof-sys/library/thread_deleter.cpp index e785809e..bdfa36c1 100644 --- a/source/lib/omnitrace/library/thread_deleter.cpp +++ b/source/lib/rocprof-sys/library/thread_deleter.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -29,7 +29,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { template struct component_bundle_cache_impl; @@ -46,7 +46,7 @@ thread_deleter::operator()() const component::pthread_create_gotcha::shutdown(_tid); set_thread_state(ThreadState::Completed); - if(get_state() < State::Finalized && _tid == 0) omnitrace_finalize_hidden(); + if(get_state() < State::Finalized && _tid == 0) rocprofsys_finalize_hidden(); } else { @@ -55,4 +55,4 @@ thread_deleter::operator()() const } template struct thread_deleter; -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/thread_deleter.hpp b/source/lib/rocprof-sys/library/thread_deleter.hpp similarity index 92% rename from source/lib/omnitrace/library/thread_deleter.hpp rename to source/lib/rocprof-sys/library/thread_deleter.hpp index 845349c9..a6156456 100644 --- a/source/lib/omnitrace/library/thread_deleter.hpp +++ b/source/lib/rocprof-sys/library/thread_deleter.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -25,7 +25,7 @@ #include "core/concepts.hpp" #include "core/defines.hpp" -namespace omnitrace +namespace rocprofsys { template <> struct thread_deleter @@ -49,4 +49,4 @@ struct thread_deleter (void) ptr; } }; -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/thread_info.cpp b/source/lib/rocprof-sys/library/thread_info.cpp similarity index 84% rename from source/lib/omnitrace/library/thread_info.cpp rename to source/lib/rocprof-sys/library/thread_info.cpp index 01ebf95f..eb52bda6 100644 --- a/source/lib/omnitrace/library/thread_info.cpp +++ b/source/lib/rocprof-sys/library/thread_info.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -37,14 +37,14 @@ #include -namespace omnitrace +namespace rocprofsys { namespace { auto& get_info_data() { - using thread_data_t = thread_data, project::omnitrace>; + using thread_data_t = thread_data, project::rocprofsys>; static auto& _v = thread_data_t::instance(construct_on_init{}); return _v; } @@ -53,7 +53,7 @@ auto& get_index_data() { using thread_data_t = - thread_data, project::omnitrace>; + thread_data, project::rocprofsys>; static auto& _v = thread_data_t::instance(construct_on_init{}); return _v; } @@ -79,29 +79,30 @@ init_index_data(int64_t _tid, bool _offset = false) threading::offset_this_id(_offset); itr = thread_index_data{}; - OMNITRACE_CONDITIONAL_THROW(itr->internal_value != _tid, - "Error! thread_info::init_index_data was called for " - "thread %zi on thread %zi\n", - _tid, itr->internal_value); + ROCPROFSYS_CONDITIONAL_THROW(itr->internal_value != _tid, + "Error! thread_info::init_index_data was called for " + "thread %zi on thread %zi\n", + _tid, itr->internal_value); int _verb = 2; // if thread created using finalization, bump up the minimum verbosity level if(get_state() >= State::Finalized && _offset) _verb += 2; if(!config::settings_are_configured()) { - OMNITRACE_BASIC_VERBOSE_F(_verb, - "Thread %li on PID %i (rank: %i) assigned " - "omnitrace TID %li (internal: %li)\n", - itr->system_value, process::get_id(), dmp::rank(), - itr->sequent_value, itr->internal_value); + ROCPROFSYS_BASIC_VERBOSE_F(_verb, + "Thread %li on PID %i (rank: %i) assigned " + "rocprof-sys TID %li (internal: %li)\n", + itr->system_value, process::get_id(), dmp::rank(), + itr->sequent_value, itr->internal_value); } else { - OMNITRACE_VERBOSE_F(_verb, - "Thread %li on PID %i (rank: %i) assigned omnitrace TID " - "%li (internal: %li)\n", - itr->system_value, process::get_id(), dmp::rank(), - itr->sequent_value, itr->internal_value); + ROCPROFSYS_VERBOSE_F( + _verb, + "Thread %li on PID %i (rank: %i) assigned rocprof-sys TID " + "%li (internal: %li)\n", + itr->system_value, process::get_id(), dmp::rank(), itr->sequent_value, + itr->internal_value); } } return itr; @@ -129,7 +130,7 @@ grow_data(int64_t _tid) if(_tid >= peak_num_threads) { - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); auto_lock_t _lk{ type_mutex() }; // check again after locking @@ -234,7 +235,7 @@ thread_info::get(native_handle_t&& _tid) } } - OMNITRACE_CI_THROW(unknown_thread, "Unknown thread has been assigned a value"); + ROCPROFSYS_CI_THROW(unknown_thread, "Unknown thread has been assigned a value"); return unknown_thread; } @@ -250,7 +251,7 @@ thread_info::get(std::thread::id _tid) } } - OMNITRACE_CI_THROW(unknown_thread, "Unknown thread has been assigned a value"); + ROCPROFSYS_CI_THROW(unknown_thread, "Unknown thread has been assigned a value"); return unknown_thread; } @@ -285,16 +286,16 @@ thread_info::get(int64_t _tid, ThreadIdType _type) } else if(_type == ThreadIdType::PthreadID) { - OMNITRACE_THROW("omnitrace does not support thread_info::get(int64_t, " - "ThreadIdType) with ThreadIdType::PthreadID\n"); + ROCPROFSYS_THROW("rocprof-sys does not support thread_info::get(int64_t, " + "ThreadIdType) with ThreadIdType::PthreadID\n"); } else if(_type == ThreadIdType::StlThreadID) { - OMNITRACE_THROW("omnitrace does not support thread_info::get(int64_t, " - "ThreadIdType) with ThreadIdType::StlThreadID\n"); + ROCPROFSYS_THROW("rocprof-sys does not support thread_info::get(int64_t, " + "ThreadIdType) with ThreadIdType::StlThreadID\n"); } - OMNITRACE_CI_THROW(unknown_thread, "Unknown thread has been assigned a value"); + ROCPROFSYS_CI_THROW(unknown_thread, "Unknown thread has been assigned a value"); return unknown_thread; } @@ -386,4 +387,4 @@ thread_info::as_string() const _ss << ", lifetime=(" << lifetime.first << ":" << lifetime.second << ")"; return _ss.str(); } -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/thread_info.hpp b/source/lib/rocprof-sys/library/thread_info.hpp similarity index 89% rename from source/lib/omnitrace/library/thread_info.hpp rename to source/lib/rocprof-sys/library/thread_info.hpp index 250d0a89..6ae1d2d9 100644 --- a/source/lib/omnitrace/library/thread_info.hpp +++ b/source/lib/rocprof-sys/library/thread_info.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -34,10 +34,10 @@ #include #include -namespace omnitrace +namespace rocprofsys { // InternalTID: zero-based, process-local thread-ID from atomic increment -// from user-created threads and omnitrace-created threads. +// from user-created threads and rocprof-sys-created threads. // This value may vary based on threads created by different // backends, e.g., roctracer will create threads // @@ -46,11 +46,11 @@ namespace omnitrace // // SequentTID: zero-based, process-local thread-ID based on the sequence of // user-created threads which are created in-between the -// initialization and finalization of omnitrace. -// In theory, omnitrace will never increment this value -// because of a thread explicitly by omnitrace or +// initialization and finalization of rocprof-sys. +// In theory, rocprof-sys will never increment this value +// because of a thread explicitly by rocprof-sys or // by other of the dependent libraries. Most commonly -// used for indexing into omnitrace's thread-local data. +// used for indexing into rocprof-sys's thread-local data. // // NativeHandle: value of static_cast(pthread_self()) // @@ -131,12 +131,12 @@ struct thread_info private: thread_info() = default; }; -} // namespace omnitrace +} // namespace rocprofsys namespace std { inline std::string -to_string(const omnitrace::thread_info& _info) +to_string(const rocprofsys::thread_info& _info) { return _info.as_string(); } diff --git a/source/lib/omnitrace/library/tpls/mpi/mpi.h b/source/lib/rocprof-sys/library/tpls/mpi/mpi.h similarity index 100% rename from source/lib/omnitrace/library/tpls/mpi/mpi.h rename to source/lib/rocprof-sys/library/tpls/mpi/mpi.h diff --git a/source/lib/omnitrace/library/tpls/mpi/mpi_portable_platform.h b/source/lib/rocprof-sys/library/tpls/mpi/mpi_portable_platform.h similarity index 100% rename from source/lib/omnitrace/library/tpls/mpi/mpi_portable_platform.h rename to source/lib/rocprof-sys/library/tpls/mpi/mpi_portable_platform.h diff --git a/source/lib/omnitrace/library/tpls/rccl/rccl/rccl.h b/source/lib/rocprof-sys/library/tpls/rccl/rccl/rccl.h similarity index 100% rename from source/lib/omnitrace/library/tpls/rccl/rccl/rccl.h rename to source/lib/rocprof-sys/library/tpls/rccl/rccl/rccl.h diff --git a/source/lib/omnitrace/library/tracing.cpp b/source/lib/rocprof-sys/library/tracing.cpp similarity index 87% rename from source/lib/omnitrace/library/tracing.cpp rename to source/lib/rocprof-sys/library/tracing.cpp index 3a2c06a1..2670a012 100644 --- a/source/lib/omnitrace/library/tracing.cpp +++ b/source/lib/rocprof-sys/library/tracing.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -30,7 +30,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace tracing { @@ -57,10 +57,10 @@ get_timemory_hash_aliases(int64_t _tid) } } // namespace -bool debug_push = tim::get_env("OMNITRACE_DEBUG_PUSH", false) || get_debug_env(); -bool debug_pop = tim::get_env("OMNITRACE_DEBUG_POP", false) || get_debug_env(); -bool debug_mark = tim::get_env("OMNITRACE_DEBUG_MARK", false) || get_debug_env(); -bool debug_user = tim::get_env("OMNITRACE_DEBUG_USER_REGIONS", false) || get_debug_env(); +bool debug_push = tim::get_env("ROCPROFSYS_DEBUG_PUSH", false) || get_debug_env(); +bool debug_pop = tim::get_env("ROCPROFSYS_DEBUG_POP", false) || get_debug_env(); +bool debug_mark = tim::get_env("ROCPROFSYS_DEBUG_MARK", false) || get_debug_env(); +bool debug_user = tim::get_env("ROCPROFSYS_DEBUG_USER_REGIONS", false) || get_debug_env(); std::unordered_map& get_perfetto_track_uuids() @@ -81,8 +81,8 @@ copy_timemory_hash_ids() // copy these over so that all hashes are known auto& _hmain = tim::hash::get_main_hash_ids(); auto& _amain = tim::hash::get_main_hash_aliases(); - OMNITRACE_REQUIRE(_hmain != nullptr) << "no main timemory hash ids"; - OMNITRACE_REQUIRE(_amain != nullptr) << "no main timemory hash aliases"; + ROCPROFSYS_REQUIRE(_hmain != nullptr) << "no main timemory hash ids"; + ROCPROFSYS_REQUIRE(_amain != nullptr) << "no main timemory hash aliases"; // combine all the hash and alias info into one container for(size_t i = 0; i < thread_info::get_peak_num_threads(); ++i) @@ -159,7 +159,7 @@ thread_init() auto _tidx = (_tinfo && _tinfo->index_data) ? _tinfo->index_data->sequent_value : threading::get_id(); - OMNITRACE_REQUIRE(_tidx >= 0) + ROCPROFSYS_REQUIRE(_tidx >= 0) << "thread setup failed. thread info not initialized: " << [&_tinfo]() { if(_tinfo) return JOIN("", *_tinfo); return std::string{ "no thread_info" }; @@ -167,15 +167,15 @@ thread_init() if(_tidx > 0) threading::set_thread_name(JOIN(" ", "Thread", _tidx).c_str()); thread_data::construct( - JOIN('/', "omnitrace/process", process::get_id(), "thread", _tidx), + JOIN('/', "rocprofsys/process", process::get_id(), "thread", _tidx), quirk::config{}); // save the hash maps get_timemory_hash_ids(_tidx) = tim::get_hash_ids(); get_timemory_hash_aliases(_tidx) = tim::get_hash_aliases(); - OMNITRACE_REQUIRE(get_timemory_hash_ids(_tidx) != nullptr) + ROCPROFSYS_REQUIRE(get_timemory_hash_ids(_tidx) != nullptr) << "no timemory hash ids pointer for thread " << _tidx; - OMNITRACE_REQUIRE(get_timemory_hash_aliases(_tidx) != nullptr) + ROCPROFSYS_REQUIRE(get_timemory_hash_aliases(_tidx) != nullptr) << "no timemory hash aliases pointer for thread " << _tidx; record_thread_start_time(); @@ -193,7 +193,7 @@ thread_init() auto _use_sampling = get_use_sampling(); if(_use_causal || _use_sampling) { - OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false); + ROCPROFSYS_SCOPED_SAMPLING_ON_CHILD_THREADS(false); if(_use_causal) causal::sampling::setup(); else if(_use_sampling) @@ -209,4 +209,4 @@ thread_init() (void) _sample_setup; } } // namespace tracing -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/tracing.hpp b/source/lib/rocprof-sys/library/tracing.hpp similarity index 93% rename from source/lib/omnitrace/library/tracing.hpp rename to source/lib/rocprof-sys/library/tracing.hpp index 3fa6e028..3db7fe5a 100644 --- a/source/lib/omnitrace/library/tracing.hpp +++ b/source/lib/rocprof-sys/library/tracing.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -60,7 +60,7 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace tracing { @@ -77,10 +77,10 @@ using perfetto_annotate_component_types = tim::mpl::available_t& get_perfetto_track_uuids(); @@ -146,7 +146,7 @@ auto get_perfetto_category_uuid(Args&&... _args) { return tim::hash::get_hash_id( - tim::hash::get_hash_id(JOIN('_', "omnitrace", trait::name::value)), + tim::hash::get_hash_id(JOIN('_', "rocprofsys", trait::name::value)), std::forward(_args)...); } @@ -166,28 +166,28 @@ get_perfetto_track(CategoryT, FuncT&& _desc_generator, Args&&... _args) _desc.set_name(_name); ::perfetto::TrackEvent::SetTrackDescriptor(_track, _desc); - OMNITRACE_VERBOSE_F(4, "[%s] Created %s(%zu) with description: \"%s\"\n", - trait::name::value, demangle().c_str(), - _uuid, _name.c_str()); + ROCPROFSYS_VERBOSE_F(4, "[%s] Created %s(%zu) with description: \"%s\"\n", + trait::name::value, demangle().c_str(), + _uuid, _name.c_str()); _track_uuids.emplace(_uuid, _name); } // guard this with ppdefs in addition to runtime check to avoid // overhead of generating string during releases -#if defined(OMNITRACE_CI) && OMNITRACE_CI > 0 +#if defined(ROCPROFSYS_CI) && ROCPROFSYS_CI > 0 auto _name = std::forward(_desc_generator)(std::forward(_args)...); - OMNITRACE_CI_THROW(_track_uuids.at(_uuid) != _name, - "Error! Multiple invocations of UUID %zu produced different " - "descriptions: \"%s\" and \"%s\"\n", - _uuid, _track_uuids.at(_uuid).c_str(), _name.c_str()); + ROCPROFSYS_CI_THROW(_track_uuids.at(_uuid) != _name, + "Error! Multiple invocations of UUID %zu produced different " + "descriptions: \"%s\" and \"%s\"\n", + _uuid, _track_uuids.at(_uuid).c_str(), _name.c_str()); #endif return TrackT(_uuid, ::perfetto::ProcessTrack::Current()); } template -OMNITRACE_INLINE auto +ROCPROFSYS_INLINE auto now() { return ::tim::get_clock_real_now(); @@ -287,7 +287,7 @@ push_timemory(CategoryT, std::string_view name, Args&&... args) if(category_push_disabled()) return; auto& _data = tracing::get_instrumentation_bundles(); - if(OMNITRACE_LIKELY(_data != nullptr)) + if(ROCPROFSYS_LIKELY(_data != nullptr)) { // this generates a hash for the raw string array auto _hash = tim::add_hash_id(name); @@ -307,15 +307,15 @@ get_timemory(CategoryT, std::string_view name) auto _hash = tim::hash::get_hash_id(name); auto& _data = tracing::get_instrumentation_bundles(); - if(OMNITRACE_UNLIKELY(_data == nullptr || _data->empty())) + if(ROCPROFSYS_UNLIKELY(_data == nullptr || _data->empty())) { - OMNITRACE_DEBUG("[%s] skipped %s :: empty bundle stack\n", "omnitrace_pop_trace", - name.data()); + ROCPROFSYS_DEBUG("[%s] skipped %s :: empty bundle stack\n", + "rocprofsys_pop_trace", name.data()); return return_type{ nullptr, -1 }; } auto*& _v_back = _data->back(); - if(OMNITRACE_LIKELY(_v_back->get_hash() == _hash)) + if(ROCPROFSYS_LIKELY(_v_back->get_hash() == _hash)) { return std::make_pair(_v_back, _data->size() - 1); } @@ -357,7 +357,7 @@ destroy_timemory(std::pair _data) if(_data.first) { auto& _bundles = tracing::get_instrumentation_bundles(); - if(OMNITRACE_LIKELY(_bundles != nullptr)) + if(ROCPROFSYS_LIKELY(_bundles != nullptr)) _bundles->destroy(_data.first, _data.second); } } @@ -652,4 +652,4 @@ mark_perfetto_track(CategoryT, const char* name, ::perfetto::Track _track, uint6 _track, _ts, std::forward(args)...); } } // namespace tracing -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/rocprof-sys/library/tracing/CMakeLists.txt b/source/lib/rocprof-sys/library/tracing/CMakeLists.txt new file mode 100644 index 00000000..660857db --- /dev/null +++ b/source/lib/rocprof-sys/library/tracing/CMakeLists.txt @@ -0,0 +1,6 @@ +# +set(tracing_sources ${CMAKE_CURRENT_LIST_DIR}/annotation.cpp) +set(tracing_headers ${CMAKE_CURRENT_LIST_DIR}/annotation.hpp) + +target_sources(rocprofiler-systems-object-library PRIVATE ${tracing_sources} + ${tracing_headers}) diff --git a/source/lib/omnitrace/library/tracing/annotation.cpp b/source/lib/rocprof-sys/library/tracing/annotation.cpp similarity index 82% rename from source/lib/omnitrace/library/tracing/annotation.cpp rename to source/lib/rocprof-sys/library/tracing/annotation.cpp index 4cbb8baf..3434c076 100644 --- a/source/lib/omnitrace/library/tracing/annotation.cpp +++ b/source/lib/rocprof-sys/library/tracing/annotation.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -22,16 +22,16 @@ #include "library/tracing/annotation.hpp" -namespace omnitrace +namespace rocprofsys { namespace tracing { void -add_perfetto_annotation(perfetto_event_context_t& ctx, - const omnitrace_annotation_t& _annotation) +add_perfetto_annotation(perfetto_event_context_t& ctx, + const rocprofsys_annotation_t& _annotation) { add_perfetto_annotation( - ctx, _annotation, utility::make_index_sequence_range<1, OMNITRACE_VALUE_LAST>{}); + ctx, _annotation, utility::make_index_sequence_range<1, ROCPROFSYS_VALUE_LAST>{}); } } // namespace tracing -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/lib/omnitrace/library/tracing/annotation.hpp b/source/lib/rocprof-sys/library/tracing/annotation.hpp similarity index 79% rename from source/lib/omnitrace/library/tracing/annotation.hpp rename to source/lib/rocprof-sys/library/tracing/annotation.hpp index 714be668..80e6af66 100644 --- a/source/lib/omnitrace/library/tracing/annotation.hpp +++ b/source/lib/rocprof-sys/library/tracing/annotation.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -29,14 +29,14 @@ #include "core/perfetto.hpp" #include "core/state.hpp" #include "core/utility.hpp" -#include "omnitrace/categories.h" // in omnitrace-user +#include "rocprofiler-systems/categories.h" // in rocprof-sys-user #include #include #include -namespace omnitrace +namespace rocprofsys { namespace tracing { @@ -48,26 +48,26 @@ struct annotation_value_type; template using annotation_value_type_t = typename annotation_value_type::type; -#define OMNITRACE_DEFINE_ANNOTATION_TYPE(ENUM, TYPE) \ +#define ROCPROFSYS_DEFINE_ANNOTATION_TYPE(ENUM, TYPE) \ template <> \ struct annotation_value_type \ { \ using type = TYPE; \ }; -OMNITRACE_DEFINE_ANNOTATION_TYPE(OMNITRACE_VALUE_CSTR, const char*) -OMNITRACE_DEFINE_ANNOTATION_TYPE(OMNITRACE_VALUE_SIZE_T, size_t) -OMNITRACE_DEFINE_ANNOTATION_TYPE(OMNITRACE_VALUE_INT16, int16_t) -OMNITRACE_DEFINE_ANNOTATION_TYPE(OMNITRACE_VALUE_INT32, int32_t) -OMNITRACE_DEFINE_ANNOTATION_TYPE(OMNITRACE_VALUE_INT64, int64_t) -OMNITRACE_DEFINE_ANNOTATION_TYPE(OMNITRACE_VALUE_UINT16, uint16_t) -OMNITRACE_DEFINE_ANNOTATION_TYPE(OMNITRACE_VALUE_UINT32, uint32_t) -OMNITRACE_DEFINE_ANNOTATION_TYPE(OMNITRACE_VALUE_UINT64, uint64_t) -OMNITRACE_DEFINE_ANNOTATION_TYPE(OMNITRACE_VALUE_FLOAT32, float) -OMNITRACE_DEFINE_ANNOTATION_TYPE(OMNITRACE_VALUE_FLOAT64, double) -OMNITRACE_DEFINE_ANNOTATION_TYPE(OMNITRACE_VALUE_VOID_P, void*) +ROCPROFSYS_DEFINE_ANNOTATION_TYPE(ROCPROFSYS_VALUE_CSTR, const char*) +ROCPROFSYS_DEFINE_ANNOTATION_TYPE(ROCPROFSYS_VALUE_SIZE_T, size_t) +ROCPROFSYS_DEFINE_ANNOTATION_TYPE(ROCPROFSYS_VALUE_INT16, int16_t) +ROCPROFSYS_DEFINE_ANNOTATION_TYPE(ROCPROFSYS_VALUE_INT32, int32_t) +ROCPROFSYS_DEFINE_ANNOTATION_TYPE(ROCPROFSYS_VALUE_INT64, int64_t) +ROCPROFSYS_DEFINE_ANNOTATION_TYPE(ROCPROFSYS_VALUE_UINT16, uint16_t) +ROCPROFSYS_DEFINE_ANNOTATION_TYPE(ROCPROFSYS_VALUE_UINT32, uint32_t) +ROCPROFSYS_DEFINE_ANNOTATION_TYPE(ROCPROFSYS_VALUE_UINT64, uint64_t) +ROCPROFSYS_DEFINE_ANNOTATION_TYPE(ROCPROFSYS_VALUE_FLOAT32, float) +ROCPROFSYS_DEFINE_ANNOTATION_TYPE(ROCPROFSYS_VALUE_FLOAT64, double) +ROCPROFSYS_DEFINE_ANNOTATION_TYPE(ROCPROFSYS_VALUE_VOID_P, void*) -#undef OMNITRACE_DEFINE_ANNOTATION_TYPE +#undef ROCPROFSYS_DEFINE_ANNOTATION_TYPE template auto @@ -75,7 +75,7 @@ add_perfetto_annotation( perfetto_event_context_t& ctx, Np&& _name, Tp&& _val, int64_t _idx = -1, std::enable_if_t< !std::is_same>, - omnitrace_annotation_t>::value, + rocprofsys_annotation_t>::value, int> = 0) { using named_type = std::remove_reference_t>>; @@ -145,13 +145,13 @@ add_perfetto_annotation( template void -add_perfetto_annotation(perfetto_event_context_t& ctx, - const omnitrace_annotation_t& _annotation, +add_perfetto_annotation(perfetto_event_context_t& ctx, + const rocprofsys_annotation_t& _annotation, std::index_sequence) { - static_assert(Idx > OMNITRACE_VALUE_NONE && Idx < OMNITRACE_VALUE_LAST, + static_assert(Idx > ROCPROFSYS_VALUE_NONE && Idx < ROCPROFSYS_VALUE_LAST, "Error! index sequence should only contain values which are greater " - "than OMNITRACE_VALUE_NONE and less than OMNITRACE_VALUE_LAST"); + "than ROCPROFSYS_VALUE_NONE and less than ROCPROFSYS_VALUE_LAST"); // in some situations the user might want to short circuit by setting // the name to a null pointer, type to none, or value to a null pointer @@ -178,15 +178,16 @@ add_perfetto_annotation(perfetto_event_context_t& ctx, else { // the first "iteration": check whether annotation type has valid range - if constexpr(Idx == OMNITRACE_VALUE_NONE + 1) + if constexpr(Idx == ROCPROFSYS_VALUE_NONE + 1) { - if(!(_annotation.type > OMNITRACE_VALUE_NONE && - _annotation.type < OMNITRACE_VALUE_LAST)) + if(!(_annotation.type > ROCPROFSYS_VALUE_NONE && + _annotation.type < ROCPROFSYS_VALUE_LAST)) { - OMNITRACE_FAIL_F("Error! annotation '%s' has an invalid type designation " - "%lu which is outside of acceptable range [%i, %i]\n", - _annotation.name, _annotation.type, - OMNITRACE_VALUE_NONE + 1, OMNITRACE_VALUE_LAST - 1); + ROCPROFSYS_FAIL_F( + "Error! annotation '%s' has an invalid type designation " + "%lu which is outside of acceptable range [%i, %i]\n", + _annotation.name, _annotation.type, ROCPROFSYS_VALUE_NONE + 1, + ROCPROFSYS_VALUE_LAST - 1); } } @@ -196,17 +197,17 @@ add_perfetto_annotation(perfetto_event_context_t& ctx, } else { - throw ::omnitrace::exception( + throw ::rocprofsys::exception( "invalid annotation value type"); } } } void -add_perfetto_annotation(perfetto_event_context_t& ctx, - const omnitrace_annotation_t& _annotation); +add_perfetto_annotation(perfetto_event_context_t& ctx, + const rocprofsys_annotation_t& _annotation); } // namespace tracing -} // namespace omnitrace +} // namespace rocprofsys #include @@ -214,7 +215,7 @@ namespace tim { namespace operation { -using perfetto_event_context_t = ::omnitrace::tracing::perfetto_event_context_t; +using perfetto_event_context_t = ::rocprofsys::tracing::perfetto_event_context_t; template struct annotate @@ -249,7 +250,7 @@ struct annotate { auto&& _label = std::get<1>(_obj_data).at(i); auto&& _value = std::get<2>(_obj_data).at(i); - ::omnitrace::tracing::add_perfetto_annotation(_ctx, _label, _value); + ::rocprofsys::tracing::add_perfetto_annotation(_ctx, _label, _value); } } (void) _ctx; diff --git a/source/lib/omnitrace/progress.cpp b/source/lib/rocprof-sys/progress.cpp similarity index 68% rename from source/lib/omnitrace/progress.cpp rename to source/lib/rocprof-sys/progress.cpp index f5e46ca1..42a6a9f1 100644 --- a/source/lib/omnitrace/progress.cpp +++ b/source/lib/rocprof-sys/progress.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -27,19 +27,19 @@ #include "library/tracing.hpp" extern "C" void -omnitrace_progress_hidden(const char* _name) +rocprofsys_progress_hidden(const char* _name) { // mark the progress point - omnitrace::component::category_region::mark< - omnitrace::quirk::causal>(_name); + rocprofsys::component::category_region::mark< + rocprofsys::quirk::causal>(_name); } extern "C" void -omnitrace_annotated_progress_hidden(const char* _name, - omnitrace_annotation_t* _annotations, - size_t _annotation_count) +rocprofsys_annotated_progress_hidden(const char* _name, + rocprofsys_annotation_t* _annotations, + size_t _annotation_count) { // mark the progress point - omnitrace::component::category_region::mark< - omnitrace::quirk::causal>(_name, _annotations, _annotation_count); + rocprofsys::component::category_region::mark< + rocprofsys::quirk::causal>(_name, _annotations, _annotation_count); } diff --git a/source/lib/omnitrace/regions.cpp b/source/lib/rocprof-sys/regions.cpp similarity index 68% rename from source/lib/omnitrace/regions.cpp rename to source/lib/rocprof-sys/regions.cpp index 7f2799f2..2cdfc1c9 100644 --- a/source/lib/omnitrace/regions.cpp +++ b/source/lib/rocprof-sys/regions.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -31,7 +31,7 @@ # pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #endif -namespace omnitrace +namespace rocprofsys { namespace impl { @@ -39,13 +39,13 @@ namespace { template void -invoke_category_region_start(omnitrace_category_t _category, const char* name, - omnitrace_annotation_t* _annotations, +invoke_category_region_start(rocprofsys_category_t _category, const char* name, + rocprofsys_annotation_t* _annotations, size_t _annotation_count, std::index_sequence) { - static_assert(Idx > OMNITRACE_CATEGORY_NONE && Idx < OMNITRACE_CATEGORY_LAST, + static_assert(Idx > ROCPROFSYS_CATEGORY_NONE && Idx < ROCPROFSYS_CATEGORY_LAST, "Error! index sequence should only contain values which are greater " - "than OMNITRACE_CATEGORY_NONE and less than OMNITRACE_CATEGORY_LAST"); + "than ROCPROFSYS_CATEGORY_NONE and less than ROCPROFSYS_CATEGORY_LAST"); if(_category == Idx) { @@ -74,13 +74,13 @@ invoke_category_region_start(omnitrace_category_t _category, const char* name, template void -invoke_category_region_stop(omnitrace_category_t _category, const char* name, - omnitrace_annotation_t* _annotations, +invoke_category_region_stop(rocprofsys_category_t _category, const char* name, + rocprofsys_annotation_t* _annotations, size_t _annotation_count, std::index_sequence) { - static_assert(Idx > OMNITRACE_CATEGORY_NONE && Idx < OMNITRACE_CATEGORY_LAST, + static_assert(Idx > ROCPROFSYS_CATEGORY_NONE && Idx < ROCPROFSYS_CATEGORY_LAST, "Error! index sequence should only contain values which are greater " - "than OMNITRACE_CATEGORY_NONE and less than OMNITRACE_CATEGORY_LAST"); + "than ROCPROFSYS_CATEGORY_NONE and less than ROCPROFSYS_CATEGORY_LAST"); if(_category == Idx) { @@ -108,20 +108,20 @@ invoke_category_region_stop(omnitrace_category_t _category, const char* name, } } // namespace } // namespace impl -} // namespace omnitrace +} // namespace rocprofsys //======================================================================================// extern "C" void -omnitrace_push_trace_hidden(const char* name) +rocprofsys_push_trace_hidden(const char* name) { - omnitrace::component::category_region::start(name); + rocprofsys::component::category_region::start(name); } extern "C" void -omnitrace_pop_trace_hidden(const char* name) +rocprofsys_pop_trace_hidden(const char* name) { - omnitrace::component::category_region::stop(name); + rocprofsys::component::category_region::stop(name); } //======================================================================================// @@ -131,15 +131,15 @@ omnitrace_pop_trace_hidden(const char* name) //======================================================================================// extern "C" void -omnitrace_push_region_hidden(const char* name) +rocprofsys_push_region_hidden(const char* name) { - omnitrace::component::category_region::start(name); + rocprofsys::component::category_region::start(name); } extern "C" void -omnitrace_pop_region_hidden(const char* name) +rocprofsys_pop_region_hidden(const char* name) { - omnitrace::component::category_region::stop(name); + rocprofsys::component::category_region::stop(name); } //======================================================================================// @@ -149,23 +149,23 @@ omnitrace_pop_region_hidden(const char* name) //======================================================================================// extern "C" void -omnitrace_push_category_region_hidden(omnitrace_category_t _category, const char* name, - omnitrace_annotation_t* _annotations, - size_t _annotation_count) +rocprofsys_push_category_region_hidden(rocprofsys_category_t _category, const char* name, + rocprofsys_annotation_t* _annotations, + size_t _annotation_count) { - omnitrace::impl::invoke_category_region_start( + rocprofsys::impl::invoke_category_region_start( _category, name, _annotations, _annotation_count, - omnitrace::utility::make_index_sequence_range<1, OMNITRACE_CATEGORY_LAST>{}); + rocprofsys::utility::make_index_sequence_range<1, ROCPROFSYS_CATEGORY_LAST>{}); } extern "C" void -omnitrace_pop_category_region_hidden(omnitrace_category_t _category, const char* name, - omnitrace_annotation_t* _annotations, - size_t _annotation_count) +rocprofsys_pop_category_region_hidden(rocprofsys_category_t _category, const char* name, + rocprofsys_annotation_t* _annotations, + size_t _annotation_count) { - omnitrace::impl::invoke_category_region_stop( + rocprofsys::impl::invoke_category_region_stop( _category, name, _annotations, _annotation_count, - omnitrace::utility::make_index_sequence_range<1, OMNITRACE_CATEGORY_LAST>{}); + rocprofsys::utility::make_index_sequence_range<1, ROCPROFSYS_CATEGORY_LAST>{}); } #if defined(__GNUC__) && (__GNUC__ == 7) diff --git a/source/lib/omnitrace/timeout.cpp b/source/lib/rocprof-sys/timeout.cpp similarity index 81% rename from source/lib/omnitrace/timeout.cpp rename to source/lib/rocprof-sys/timeout.cpp index ac72f46c..9f9bb969 100644 --- a/source/lib/omnitrace/timeout.cpp +++ b/source/lib/rocprof-sys/timeout.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -37,12 +37,12 @@ #include #include -namespace omnitrace +namespace rocprofsys { namespace timeout { void -setup() OMNITRACE_INTERNAL_API; +setup() ROCPROFSYS_INTERNAL_API; namespace { @@ -76,7 +76,7 @@ ci_timeout_backtrace(int) static auto _mutex = locking::atomic_mutex{}; auto _lk = locking::atomic_lock{ _mutex }; - OMNITRACE_PRINT("%s\n", _err.str().c_str()); + ROCPROFSYS_PRINT("%s\n", _err.str().c_str()); ++ci_timeout_backtrace_global_done; } @@ -88,7 +88,7 @@ ensure_ci_timeout_backtrace(double _ci_timeout_seconds, _ci_timeout_ready.set_value(); thread_info::init(true); - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Disabled); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Disabled); auto _factor = 3.0; while(_ci_timeout_seconds <= _factor) @@ -97,9 +97,9 @@ ensure_ci_timeout_backtrace(double _ci_timeout_seconds, uint64_t _ci_timeout_nitr = 0; int64_t _ci_timeout_nanosec = (_ci_timeout_seconds - _factor) * units::sec; auto _ci_timeout_total_count = - get_env("OMNITRACE_CI_TIMEOUT_COUNT", 1, false); + get_env("ROCPROFSYS_CI_TIMEOUT_COUNT", 1, false); const auto root_pid = - get_env("OMNITRACE_ROOT_PROCESS", process::get_id(), false); + get_env("ROCPROFSYS_ROOT_PROCESS", process::get_id(), false); while(get_state() < State::Finalized && _ci_timeout_nitr < _ci_timeout_total_count) { @@ -127,18 +127,18 @@ ensure_ci_timeout_backtrace(double _ci_timeout_seconds, const auto& _info = thread_info::get(_handle); if(_info) { - OMNITRACE_WARNING_F( + ROCPROFSYS_WARNING_F( 0, "pthread_kill(%zu, %i) failed for thread %zi (info: %s)\n", _handle, timeout_signal_v, _info->index_data->sequent_value, _info->as_string().c_str()); } else { - OMNITRACE_WARNING_F(0, - "pthread_kill(%zu, %i) failed. executing generic " - "kill(%i, %i)...\n", - _handle, timeout_signal_v, process::get_id(), - timeout_signal_v); + ROCPROFSYS_WARNING_F( + 0, + "pthread_kill(%zu, %i) failed. executing generic " + "kill(%i, %i)...\n", + _handle, timeout_signal_v, process::get_id(), timeout_signal_v); } ::kill(process::get_id(), timeout_signal_v); @@ -151,18 +151,18 @@ ensure_ci_timeout_backtrace(double _ci_timeout_seconds, }; _tids.erase(main_thread_native_handle); - OMNITRACE_WARNING_F(-127, - "timeout after %8.3f seconds... Generating backtraces for " - "%zu threads...\n", - _ci_timeout_seconds, _tids.size() + 1); + ROCPROFSYS_WARNING_F(-127, + "timeout after %8.3f seconds... Generating backtraces for " + "%zu threads...\n", + _ci_timeout_seconds, _tids.size() + 1); for(auto itr : _tids) _kill_thread(itr); _kill_thread(main_thread_native_handle); - ::omnitrace::debug::flush(); - ::omnitrace::debug::lock _debug_lk{}; + ::rocprofsys::debug::flush(); + ::rocprofsys::debug::lock _debug_lk{}; if(++_ci_timeout_nitr >= _ci_timeout_total_count) { @@ -176,7 +176,7 @@ ensure_ci_timeout_backtrace(double _ci_timeout_seconds, } } - OMNITRACE_WARNING_F(0, "timeout thread exiting...\n"); + ROCPROFSYS_WARNING_F(0, "timeout thread exiting...\n"); } } // namespace @@ -188,18 +188,18 @@ setup() if(ci_timeout_active) return; - // in CI mode, if OMNITRACE_CI_TIMEOUT or OMNITRACE_CI_TIMEOUT_OVERRIDE is + // in CI mode, if ROCPROFSYS_CI_TIMEOUT or ROCPROFSYS_CI_TIMEOUT_OVERRIDE is // set, start a thread that will print out the backtrace for each thread // before the timeout is hit (i.e. killed by CTest) so we can potentially // diagnose where the code is stuck - auto _ci = get_env("OMNITRACE_CI", false, false); + auto _ci = get_env("ROCPROFSYS_CI", false, false); if(_ci) { // set by CTest - auto _ci_timeout_default = get_env("OMNITRACE_CI_TIMEOUT", -1.0, false); + auto _ci_timeout_default = get_env("ROCPROFSYS_CI_TIMEOUT", -1.0, false); // allow override by user auto _ci_timeout_seconds = - get_env("OMNITRACE_CI_TIMEOUT_OVERRIDE", _ci_timeout_default, false); + get_env("ROCPROFSYS_CI_TIMEOUT_OVERRIDE", _ci_timeout_default, false); if(_ci_timeout_seconds > 0.0) { @@ -207,8 +207,8 @@ setup() ci_timeout_active = true; _lk.unlock(); - OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); - OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false); + ROCPROFSYS_SCOPED_THREAD_STATE(ThreadState::Internal); + ROCPROFSYS_SCOPED_SAMPLING_ON_CHILD_THREADS(false); // enable the signal handler for when the timeout is reached struct sigaction _action = {}; @@ -228,4 +228,4 @@ setup() } } } // namespace timeout -} // namespace omnitrace +} // namespace rocprofsys diff --git a/source/python/CMakeLists.txt b/source/python/CMakeLists.txt index eaad46f9..f160caa8 100644 --- a/source/python/CMakeLists.txt +++ b/source/python/CMakeLists.txt @@ -1,12 +1,12 @@ # ######################################################################################## # -# omnitrace (Python) +# rocprofsys (Python) # # ######################################################################################## -if(OMNITRACE_BUILD_STATIC_LIBSTDCXX) - # omnitrace_message(FATAL_ERROR "static libstdc++ is not compatible with python - # bindings") +if(ROCPROFSYS_BUILD_STATIC_LIBSTDCXX) + # rocprofiler_systems_message(FATAL_ERROR "static libstdc++ is not compatible with + # python bindings") endif() # if set, will screw up loading library @@ -17,27 +17,27 @@ set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME python) # ######################################################################################## -function(OMNITRACE_CONFIGURE_PYTARGET _TARGET _VERSION) +function(ROCPROFILER_SYSTEMS_CONFIGURE_PYTARGET _TARGET _VERSION) - add_library(omnitrace::${_TARGET} ALIAS ${_TARGET}) - target_link_libraries(${_TARGET} PRIVATE libpyomnitrace-interface) - add_dependencies(libpyomnitrace ${_TARGET}) + add_library(rocprofiler-systems::${_TARGET} ALIAS ${_TARGET}) + target_link_libraries(${_TARGET} PRIVATE libpyrocprofiler-systems-interface) + add_dependencies(libpyrocprofsys ${_TARGET}) set_target_properties( ${_TARGET} PROPERTIES PREFIX "" - OUTPUT_NAME libpyomnitrace + OUTPUT_NAME libpyrocprofsys 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,71 +54,72 @@ function(OMNITRACE_CONFIGURE_PYTARGET _TARGET _VERSION) install( TARGETS ${_TARGET} - DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/omnitrace + DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/rocprofsys OPTIONAL) endfunction() # ######################################################################################## -add_library(omnitrace-python-compile-options INTERFACE) -add_library(omnitrace::omnitrace-python-compile-options ALIAS - omnitrace-python-compile-options) +add_library(rocprofiler-systems-python-compile-options INTERFACE) +add_library(rocprofiler-systems::rocprofiler-systems-python-compile-options ALIAS + rocprofiler-systems-python-compile-options) add_target_cxx_flag_if_avail( - omnitrace-python-compile-options "-Wno-unused-value" "-Wno-range-loop-analysis" - "-Wno-deprecated-declarations" "-Wno-unused-but-set-parameter" - "-ftls-model=global-dynamic") + rocprofiler-systems-python-compile-options "-Wno-unused-value" + "-Wno-range-loop-analysis" "-Wno-deprecated-declarations" + "-Wno-unused-but-set-parameter" "-ftls-model=global-dynamic") -file(GLOB pyheaders ${CMAKE_CURRENT_LIST_DIR}/libpyomnitrace*.hpp) -set(pysources ${CMAKE_CURRENT_LIST_DIR}/libpyomnitrace.cpp) +file(GLOB pyheaders ${CMAKE_CURRENT_LIST_DIR}/libpyrocprofsys*.hpp) +set(pysources ${CMAKE_CURRENT_LIST_DIR}/libpyrocprofsys.cpp) set(pybind_libs pybind11::module) -add_library(libpyomnitrace-interface INTERFACE) +add_library(libpyrocprofiler-systems-interface INTERFACE) target_link_libraries( - libpyomnitrace-interface + libpyrocprofiler-systems-interface INTERFACE pybind11::module timemory::timemory-headers - omnitrace::omnitrace-headers - omnitrace::omnitrace-compile-options - omnitrace::omnitrace-static-libgcc-optional - omnitrace::omnitrace-lto - omnitrace::omnitrace-dl-library - omnitrace::omnitrace-user-library - omnitrace::omnitrace-python - omnitrace::omnitrace-python-compile-options) + rocprofiler-systems::rocprofiler-systems-headers + rocprofiler-systems::rocprofiler-systems-compile-options + rocprofiler-systems::rocprofiler-systems-static-libgcc-optional + rocprofiler-systems::rocprofiler-systems-lto + rocprofiler-systems::rocprofiler-systems-dl-library + rocprofiler-systems::rocprofiler-systems-user-library + rocprofiler-systems::rocprofiler-systems-python + rocprofiler-systems::rocprofiler-systems-python-compile-options) -omnitrace_target_compile_definitions(libpyomnitrace-interface - INTERFACE OMNITRACE_PYBIND11_SOURCE) +rocprofiler_systems_target_compile_definitions(libpyrocprofiler-systems-interface + INTERFACE ROCPROFSYS_PYBIND11_SOURCE) -add_custom_target(libpyomnitrace) +add_custom_target(libpyrocprofsys) -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") +rocprofiler_systems_python_console_script("${BINARY_NAME_PREFIX}-python" "rocprofsys") set(_INDEX 0) -foreach(_VERSION ${OMNITRACE_PYTHON_VERSIONS}) - # add_library(libpyomnitrace MODULE ${pysources} ${pyheaders}) - list(GET OMNITRACE_PYTHON_ROOT_DIRS ${_INDEX} Python3_ROOT_DIR) - omnitrace_pybind11_add_module( - libpyomnitrace-${_VERSION} MODULE +foreach(_VERSION ${ROCPROFSYS_PYTHON_VERSIONS}) + # add_library(libpyrocprofsys MODULE ${pysources} ${pyheaders}) + list(GET ROCPROFSYS_PYTHON_ROOT_DIRS ${_INDEX} Python3_ROOT_DIR) + rocprofiler_systems_pybind11_add_module( + libpyrocprofiler-systems-${_VERSION} MODULE PYTHON_VERSION ${_VERSION} VISIBILITY "hidden" ${pysources} ${pyheaders}) - omnitrace_configure_pytarget(libpyomnitrace-${_VERSION} ${_VERSION}) + rocprofiler_systems_configure_pytarget(libpyrocprofiler-systems-${_VERSION} + ${_VERSION}) - if(OMNITRACE_USE_PYTHON) - omnitrace_python_console_script( - "omnitrace-python" "omnitrace" + if(ROCPROFSYS_USE_PYTHON) + rocprofiler_systems_python_console_script( + "${BINARY_NAME_PREFIX}-python" "rocprofsys" VERSION ${_VERSION} ROOT_DIR "${Python3_ROOT_DIR}") endif() diff --git a/source/python/cmake/ConfigPython.cmake b/source/python/cmake/ConfigPython.cmake index 06bcc64e..b2676e4b 100644 --- a/source/python/cmake/ConfigPython.cmake +++ b/source/python/cmake/ConfigPython.cmake @@ -54,20 +54,21 @@ foreach(_VAR FIND_STRATEGY FIND_VIRTUALENV FIND_FRAMEWORK FIND_IMPLEMENTATIONS if(DEFINED Python3_${_VAR}) set(Python_${_VAR} "${Python3_${_VAR}}" - CACHE STRING "Set via Python3_${_VAR} setting (omnitrace)") + CACHE STRING "Set via Python3_${_VAR} setting (rocprofsys)") mark_as_advanced(Python_${_VAR}) mark_as_advanced(Python3_${_VAR}) endif() endforeach() # display version -omnitrace_add_feature(OMNITRACE_PYTHON_VERSIONS "Python version for omnitrace" DOC) +rocprofiler_systems_add_feature(ROCPROFSYS_PYTHON_VERSIONS + "Python version for rocprofsys" DOC) option(PYBIND11_INSTALL "Enable Pybind11 installation" OFF) -if(OMNITRACE_BUILD_PYTHON AND NOT TARGET pybind11) +if(ROCPROFSYS_BUILD_PYTHON AND NOT TARGET pybind11) # checkout PyBind11 if not checked out - omnitrace_checkout_git_submodule( + rocprofiler_systems_checkout_git_submodule( RECURSIVE RELATIVE_PATH external/pybind11 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} @@ -78,15 +79,16 @@ if(OMNITRACE_BUILD_PYTHON AND NOT TARGET pybind11) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF) endif() set(PYBIND11_NOPYTHON ON) - omnitrace_save_variables(IPO VARIABLES CMAKE_INTERPROCEDURAL_OPTIMIZATION) + rocprofiler_systems_save_variables(IPO VARIABLES CMAKE_INTERPROCEDURAL_OPTIMIZATION) add_subdirectory(${PROJECT_SOURCE_DIR}/external/pybind11) - omnitrace_restore_variables(IPO VARIABLES CMAKE_INTERPROCEDURAL_OPTIMIZATION) + rocprofiler_systems_restore_variables(IPO + VARIABLES CMAKE_INTERPROCEDURAL_OPTIMIZATION) endif() execute_process( COMMAND ${PYTHON_EXECUTABLE} -c "import time ; print('{} {}'.format(time.ctime(), time.tzname[0]))" - OUTPUT_VARIABLE OMNITRACE_INSTALL_DATE + OUTPUT_VARIABLE ROCPROFSYS_INSTALL_DATE OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) -string(REPLACE " " " " OMNITRACE_INSTALL_DATE "${OMNITRACE_INSTALL_DATE}") +string(REPLACE " " " " ROCPROFSYS_INSTALL_DATE "${ROCPROFSYS_INSTALL_DATE}") diff --git a/source/python/cmake/PyBind11Tools.cmake b/source/python/cmake/PyBind11Tools.cmake index b555e29a..d400f971 100644 --- a/source/python/cmake/PyBind11Tools.cmake +++ b/source/python/cmake/PyBind11Tools.cmake @@ -1,5 +1,5 @@ # -function(OMNITRACE_FIND_PYTHON _VAR) +function(ROCPROFILER_SYSTEMS_FIND_PYTHON _VAR) set(options REQUIRED QUIET) set(args VERSION ROOT_DIR) set(kwargs COMPONENTS) @@ -68,13 +68,13 @@ function(OMNITRACE_FIND_PYTHON _VAR) "${_PYTHON_VERSION_LIST}" PARENT_SCOPE) else() - omnitrace_message(WARNING "${_PYTHON_ERROR_VALUE}") + rocprofiler_systems_message(WARNING "${_PYTHON_ERROR_VALUE}") endif() endif() endfunction() # # Internal: find the appropriate link time optimization flags for this compiler -function(_OMNITRACE_PYBIND11_ADD_LTO_FLAGS target_name prefer_thin_lto) +function(_ROCPROFSYS_PYBIND11_ADD_LTO_FLAGS target_name prefer_thin_lto) # Checks whether the given CXX/linker flags can compile and link a cxx file. cxxflags # and linkerflags are lists of flags to use. The result variable is a unique variable # name for each set of flags: the compilation result will be cached base on the result @@ -141,9 +141,9 @@ function(_OMNITRACE_PYBIND11_ADD_LTO_FLAGS target_name prefer_thin_lto) endif() if(PYBIND11_LTO_CXX_FLAGS) - omnitrace_message(STATUS "${target_name} :: LTO enabled") + rocprofiler_systems_message(STATUS "${target_name} :: LTO enabled") else() - omnitrace_message( + rocprofiler_systems_message( STATUS "${target_name} :: LTO disabled (not supported by the compiler and/or linker)" ) @@ -162,14 +162,14 @@ function(_OMNITRACE_PYBIND11_ADD_LTO_FLAGS target_name prefer_thin_lto) endif() endfunction() # -function(OMNITRACE_PYBIND11_ADD_MODULE target_name) +function(ROCPROFILER_SYSTEMS_PYBIND11_ADD_MODULE target_name) set(options MODULE SHARED EXCLUDE_FROM_ALL NO_EXTRAS SYSTEM THIN_LTO LTO) set(args PYTHON_VERSION VISIBILITY CXX_STANDARD) set(kwargs) cmake_parse_arguments(ARG "${options}" "${args}" "${kwargs}" ${ARGN}) if(ARG_MODULE AND ARG_SHARED) - omnitrace_message(FATAL_ERROR "Can't be both MODULE and SHARED") + rocprofiler_systems_message(FATAL_ERROR "Can't be both MODULE and SHARED") elseif(ARG_SHARED) set(lib_type SHARED) else() @@ -261,7 +261,7 @@ function(OMNITRACE_PYBIND11_ADD_MODULE target_name) endif() if(ARG_LTO OR ARG_THIN_LTO) - _omnitrace_pybind11_add_lto_flags(${target_name} ${ARG_THIN_LTO}) + _rocprofiler_systems_pybind11_add_lto_flags(${target_name} ${ARG_THIN_LTO}) endif() if(NOT MSVC AND NOT ${CMAKE_BUILD_TYPE} MATCHES Debug|RelWithDebInfo) diff --git a/source/python/gui/MANIFEST.in b/source/python/gui/MANIFEST.in index ccf3c356..3130dbcd 100644 --- a/source/python/gui/MANIFEST.in +++ b/source/python/gui/MANIFEST.in @@ -16,6 +16,6 @@ global-exclude *__pycache__* # recursive excludes -recursive-exclude omnitrace_causal_viewer.egg-info * +recursive-exclude rocprofsys_causal_viewer.egg-info * recursive-exclude build * recursive-exclude dist * diff --git a/source/python/gui/README.md b/source/python/gui/README.md index 0851fb12..eb571f9f 100644 --- a/source/python/gui/README.md +++ b/source/python/gui/README.md @@ -1,4 +1,4 @@ -# Omnitrace Causal Viewer +# ROCm Systems Profiler Causal Viewer ## Installation @@ -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 b4d1b3f0..16c5602b 100644 --- a/source/python/gui/setup.cfg +++ b/source/python/gui/setup.cfg @@ -1,10 +1,10 @@ [metadata] -name = omnitrace-causal-viewer -url = https://github.com/ROCm/omnitrace -download_url = https://github.com/ROCm/omnitrace.git +name = rocprof-sys-causal-viewer +url = https://github.com/ROCm/rocprofiler-systems +download_url = https://github.com/ROCm/rocprofiler-systems.git maintainer = AMD Research license = MIT -description = GUI for viewing Omnitrace causal profiles +description = GUI for viewing ROCm Systems Profiler causal profiles keywords = gui causal profiling @@ -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 e35d5826..c85667ac 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,8 @@ 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 fa17d6e5..ac4dcb4a 100644 --- a/source/python/gui/source/__main__.py +++ b/source/python/gui/source/__main__.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # MIT License # -# Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2023-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 @@ -24,7 +24,7 @@ from __future__ import absolute_import __author__ = "AMD Research" -__copyright__ = "Copyright 2023, Advanced Micro Devices, Inc." +__copyright__ = "Copyright 2023-2024, Advanced Micro Devices, Inc." __license__ = "MIT" __maintainer__ = "AMD Research" __status__ = "Development" @@ -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: @@ -143,18 +143,18 @@ def main(): settings[key] = value my_parser = argparse.ArgumentParser( - description="AMD's OmniTrace Causal Profiling GUI", + description="AMD's ROCm Systems Profiler Causal Profiling GUI", prog="tool", allow_abbrev=False, formatter_class=lambda prog: argparse.RawTextHelpFormatter( 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,9 @@ 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/source/python/gui/source/parser.py b/source/python/gui/source/parser.py index 0886d785..13df92a3 100644 --- a/source/python/gui/source/parser.py +++ b/source/python/gui/source/parser.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # MIT License # -# Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2023-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 @@ -24,7 +24,7 @@ from __future__ import absolute_import __author__ = "AMD Research" -__copyright__ = "Copyright 2023, Advanced Micro Devices, Inc." +__copyright__ = "Copyright 2023-2024, Advanced Micro Devices, Inc." __license__ = "MIT" __maintainer__ = "AMD Research" __status__ = "Development" @@ -270,7 +270,7 @@ def __lt__(self, rhs): def process_samples(data, _data): if not _data: return data - for record in _data["omnitrace"]["causal"]["records"]: + for record in _data["rocprofsys"]["causal"]["records"]: for samp in record["samples"]: _info = samp["info"] _count = samp["count"] @@ -303,7 +303,7 @@ def find_or_insert(_data, _value, _type): _selection_filter = re.compile(experiments) _progresspt_filter = re.compile(progress_points) - for record in _data["omnitrace"]["causal"]["records"]: + for record in _data["rocprofsys"]["causal"]["records"]: for exp in record["experiments"]: _speedup = exp["virtual_speedup"] _duration = exp["duration"] @@ -612,8 +612,8 @@ def name_wo_ext(x): with open(file, "r") as j: _data = json.load(j) dict_data = {} - # make sure the JSON is an omnitrace causal JSON - if "omnitrace" not in _data or "causal" not in _data["omnitrace"]: + # make sure the JSON is an rocprof-sys causal JSON + if "rocprofsys" not in _data or "causal" not in _data["rocprofsys"]: continue dict_data[file] = process_data({}, _data, experiments, progress_points) samps = process_samples({}, _data) @@ -831,8 +831,8 @@ def find_causal_files_helper(inp, _files): with open(itr, "r") as f: inp_data = json.load(f) if ( - "omnitrace" not in inp_data.keys() - or "causal" not in inp_data["omnitrace"].keys() + "rocprofsys" not in inp_data.keys() + or "causal" not in inp_data["rocprofsys"].keys() ): if verbose >= 2: print(f"{itr} is not a causal profile") diff --git a/source/python/libpyomnitrace.cpp b/source/python/libpyrocprofsys.cpp similarity index 89% rename from source/python/libpyomnitrace.cpp rename to source/python/libpyrocprofsys.cpp index 79803862..e5d42079 100644 --- a/source/python/libpyomnitrace.cpp +++ b/source/python/libpyrocprofsys.cpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -20,12 +20,12 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include "libpyomnitrace.hpp" +#include "libpyrocprofsys.hpp" #include "dl/dl.hpp" #include "library/coverage.hpp" #include "library/coverage/impl.hpp" -#include "omnitrace/categories.h" -#include "omnitrace/user.h" +#include "rocprofiler-systems/categories.h" +#include "rocprofiler-systems/user.h" #include #include @@ -53,10 +53,10 @@ #include #include -#define OMNITRACE_PYTHON_VERSION \ +#define ROCPROFSYS_PYTHON_VERSION \ ((10000 * PY_MAJOR_VERSION) + (100 * PY_MINOR_VERSION) + PY_MICRO_VERSION) -namespace pyomnitrace +namespace pyrocprofsys { namespace pyprofile { @@ -73,17 +73,17 @@ namespace pyuser py::module generate(py::module& _pymod); } -} // namespace pyomnitrace +} // namespace pyrocprofsys template using uomap_t = std::unordered_map; -PYBIND11_MODULE(libpyomnitrace, omni) +PYBIND11_MODULE(libpyrocprofsys, omni) { - using namespace pyomnitrace; + using namespace pyrocprofsys; - py::doc("Omnitrace Python bindings for profiling, user API, and code coverage " - "post-processing"); + py::doc("ROCm Systems Profiler Python bindings for profiling, user API, and " + "code coverage post-processing"); static bool _is_initialized = false; static bool _is_finalized = false; @@ -110,22 +110,22 @@ PYBIND11_MODULE(libpyomnitrace, omni) "initialize", [](const std::string& _v) { if(_is_initialized) - throw std::runtime_error("Error! omnitrace is already initialized"); + throw std::runtime_error("Error! rocprofsys is already initialized"); _is_initialized = true; - omnitrace_set_mpi(_get_use_mpi(), false); - omnitrace_init("trace", false, _v.c_str()); + rocprofsys_set_mpi(_get_use_mpi(), false); + rocprofsys_init("trace", false, _v.c_str()); }, - "Initialize omnitrace"); + "Initialize rocprofsys"); omni.def( "initialize", [](const py::list& _v) { if(_is_initialized) - throw std::runtime_error("Error! omnitrace is already initialized"); + throw std::runtime_error("Error! rocprofsys is already initialized"); _is_initialized = true; - omnitrace_set_instrumented( - static_cast(omnitrace::dl::InstrumentMode::PythonProfile)); - omnitrace_set_mpi(_get_use_mpi(), false); + rocprofsys_set_instrumented( + static_cast(rocprofsys::dl::InstrumentMode::PythonProfile)); + rocprofsys_set_mpi(_get_use_mpi(), false); std::string _cmd = {}; std::string _cmd_line = {}; for(auto&& itr : _v) @@ -136,46 +136,46 @@ PYBIND11_MODULE(libpyomnitrace, omni) if(!_cmd_line.empty()) { _cmd_line = _cmd_line.substr(_cmd_line.find_first_not_of(' ')); - tim::set_env("OMNITRACE_COMMAND_LINE", _cmd_line, 0); + tim::set_env("ROCPROFSYS_COMMAND_LINE", _cmd_line, 0); } - omnitrace_init("trace", false, _cmd.c_str()); + rocprofsys_init("trace", false, _cmd.c_str()); }, - "Initialize omnitrace"); + "Initialize rocprofsys"); omni.def( "finalize", []() { if(_is_finalized) - throw std::runtime_error("Error! omnitrace is already finalized"); + throw std::runtime_error("Error! rocprofsys is already finalized"); _is_finalized = true; - omnitrace_finalize(); + rocprofsys_finalize(); }, - "Finalize omnitrace"); + "Finalize rocprofsys"); pyprofile::generate(omni); pycoverage::generate(omni); pyuser::generate(omni); - auto _python_path = tim::get_env("OMNITRACE_PATH", std::string{}, false); - auto _libpath = std::string{ "libomnitrace-dl.so" }; + auto _python_path = tim::get_env("ROCPROFSYS_PATH", std::string{}, false); + 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); + _libpath = tim::get_env("ROCPROFSYS_DL_LIBRARY", _libpath); // this is necessary when building with -static-libstdc++ - // without it, loading libomnitrace.so within libomnitrace-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 = TIMEMORY_JOIN("", "dlopen(\"", _libpath, "\", RTLD_NOW | RTLD_GLOBAL)"); perror(_msg.c_str()); - fprintf(stderr, "[omnitrace][dl][pid=%i] %s :: %s\n", getpid(), _msg.c_str(), + fprintf(stderr, "[rocprofsys][dl][pid=%i] %s :: %s\n", getpid(), _msg.c_str(), dlerror()); } } //======================================================================================// // -namespace pyomnitrace +namespace pyrocprofsys { namespace pyprofile { @@ -185,7 +185,7 @@ using profiler_vec_t = std::vector; using profiler_label_map_t = std::unordered_map; using profiler_index_map_t = std::unordered_map; using strset_t = std::unordered_set; -using note_t = omnitrace_annotation_t; +using note_t = rocprofsys_annotation_t; using annotations_t = std::array; // namespace @@ -223,12 +223,12 @@ struct config strset_t exclude_functions = default_exclude_functions; strset_t exclude_filenames = default_exclude_filenames; std::vector records = {}; - annotations_t annotations = { note_t{ "file", OMNITRACE_STRING, nullptr }, - note_t{ "line", OMNITRACE_INT32, nullptr }, - note_t{ "lasti", OMNITRACE_INT32, nullptr }, - note_t{ "argcount", OMNITRACE_INT32, nullptr }, - note_t{ "nlocals", OMNITRACE_INT32, nullptr }, - note_t{ "stacksize", OMNITRACE_INT32, nullptr } }; + annotations_t annotations = { note_t{ "file", ROCPROFSYS_STRING, nullptr }, + note_t{ "line", ROCPROFSYS_INT32, nullptr }, + note_t{ "lasti", ROCPROFSYS_INT32, nullptr }, + note_t{ "argcount", ROCPROFSYS_INT32, nullptr }, + note_t{ "nlocals", ROCPROFSYS_INT32, nullptr }, + note_t{ "stacksize", ROCPROFSYS_INT32, nullptr } }; }; // inline config& @@ -268,7 +268,7 @@ get_config() int get_frame_lineno(PyFrameObject* frame) { -#if OMNITRACE_PYTHON_VERSION >= 31100 +#if ROCPROFSYS_PYTHON_VERSION >= 31100 return PyFrame_GetLineNumber(frame); #else return frame->f_lineno; @@ -278,7 +278,7 @@ get_frame_lineno(PyFrameObject* frame) int get_frame_lasti(PyFrameObject* frame) { -#if OMNITRACE_PYTHON_VERSION >= 31100 +#if ROCPROFSYS_PYTHON_VERSION >= 31100 return PyFrame_GetLasti(frame); #else return frame->f_lasti; @@ -288,7 +288,7 @@ get_frame_lasti(PyFrameObject* frame) auto get_frame_code(PyFrameObject* frame) { -#if OMNITRACE_PYTHON_VERSION >= 31100 +#if ROCPROFSYS_PYTHON_VERSION >= 31100 return PyFrame_GetCode(frame); #else return frame->f_code; @@ -311,7 +311,7 @@ profiler_function(py::object pframe, const char* swhat, py::object arg) if(pframe.is_none() || pframe.ptr() == nullptr) return; - static auto _omnitrace_path = _config.base_module_path; + static auto _rocprofsys_path = _config.base_module_path; auto* frame = reinterpret_cast(pframe.ptr()); @@ -454,7 +454,7 @@ profiler_function(py::object pframe, const char* swhat, py::object arg) : _full; if(!_config.include_internal && - strncmp(_full.c_str(), _omnitrace_path.c_str(), _omnitrace_path.length()) == 0) + strncmp(_full.c_str(), _rocprofsys_path.c_str(), _rocprofsys_path.length()) == 0) { if(_config.verbose > 2) TIMEMORY_PRINT_HERE("Skipping internal function: %s", _func.c_str()); @@ -514,14 +514,15 @@ profiler_function(py::object pframe, const char* swhat, py::object arg) } _config.records.emplace_back([&_label_ref, _annotate]() { - omnitrace_pop_category_region(OMNITRACE_CATEGORY_PYTHON, _label_ref.c_str(), - (_annotate) ? _config.annotations.data() - : nullptr, - _config.annotations.size()); + rocprofsys_pop_category_region(ROCPROFSYS_CATEGORY_PYTHON, _label_ref.c_str(), + (_annotate) ? _config.annotations.data() + : nullptr, + _config.annotations.size()); }); - omnitrace_push_category_region(OMNITRACE_CATEGORY_PYTHON, _label_ref.c_str(), - (_annotate) ? _config.annotations.data() : nullptr, - _config.annotations.size()); + rocprofsys_push_category_region(ROCPROFSYS_CATEGORY_PYTHON, _label_ref.c_str(), + (_annotate) ? _config.annotations.data() + : nullptr, + _config.annotations.size()); }; // stop function @@ -556,7 +557,7 @@ generate(py::module& _pymod) try { auto _file = - py::module::import("omnitrace").attr("__file__").cast(); + py::module::import("rocprofsys").attr("__file__").cast(); if(_file.find('/') != std::string::npos) _file = _file.substr(0, _file.find_last_of('/')); get_config().base_module_path = _file; @@ -675,7 +676,7 @@ namespace pycoverage py::module generate(py::module& _pymod) { - namespace coverage = omnitrace::coverage; + namespace coverage = rocprofsys::coverage; using coverage_data_vector_t = std::vector; py::module _pycov = _pymod.def_submodule("coverage", "Code coverage"); @@ -774,7 +775,7 @@ generate(py::module& _pymod) try { - ar->setNextName("omnitrace"); + ar->setNextName("rocprofsys"); ar->startNode(); ar->setNextName("coverage"); ar->startNode(); @@ -798,7 +799,7 @@ generate(py::module& _pymod) auto ar = tim::policy::output_archive::get(oss); - ar->setNextName("omnitrace"); + ar->setNextName("rocprofsys"); ar->startNode(); ar->setNextName("coverage"); ar->startNode(); @@ -812,7 +813,7 @@ generate(py::module& _pymod) std::ofstream ofs{}; if(tim::filepath::open(ofs, _name)) { - tim::operation::file_output_message{}( + tim::operation::file_output_message{}( _name, std::string{ "coverage" }); ofs << oss.str() << "\n"; } @@ -930,25 +931,25 @@ generate(py::module& _pymod) { py::module _pyuser = _pymod.def_submodule("user", "User instrumentation"); - _pyuser.def("start_trace", &omnitrace_user_start_trace, + _pyuser.def("start_trace", &rocprofsys_user_start_trace, "Enable tracing on this thread and all subsequently created threads"); - _pyuser.def("stop_trace", &omnitrace_user_stop_trace, + _pyuser.def("stop_trace", &rocprofsys_user_stop_trace, "Disable tracing on this thread and all subsequently created threads"); _pyuser.def( - "start_thread_trace", &omnitrace_user_start_thread_trace, + "start_thread_trace", &rocprofsys_user_start_thread_trace, "Enable tracing on this thread. Does not apply to subsequently created threads"); _pyuser.def( - "stop_thread_trace", &omnitrace_user_stop_thread_trace, + "stop_thread_trace", &rocprofsys_user_stop_thread_trace, "Enable tracing on this thread. Does not apply to subsequently created threads"); - _pyuser.def("push_region", &omnitrace_user_push_region, + _pyuser.def("push_region", &rocprofsys_user_push_region, "Start a user-defined region"); - _pyuser.def("pop_region", &omnitrace_user_pop_region, "Start a user-defined region"); - _pyuser.def("error_string", &omnitrace_user_error_string, + _pyuser.def("pop_region", &rocprofsys_user_pop_region, "Start a user-defined region"); + _pyuser.def("error_string", &rocprofsys_user_error_string, "Return a descriptor for the provided error code"); return _pyuser; } } // namespace pyuser -} // namespace pyomnitrace +} // namespace pyrocprofsys // //======================================================================================// diff --git a/source/python/libpyomnitrace.hpp b/source/python/libpyrocprofsys.hpp similarity index 91% rename from source/python/libpyomnitrace.hpp rename to source/python/libpyrocprofsys.hpp index 353a0695..3d9386c4 100644 --- a/source/python/libpyomnitrace.hpp +++ b/source/python/libpyrocprofsys.hpp @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +// Copyright (c) 2022-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 @@ -21,6 +21,7 @@ // SOFTWARE. #pragma once +#define PYBIND11_DETAILED_ERROR_MESSAGES #include #include @@ -48,9 +49,9 @@ #include #include -namespace pyomnitrace +namespace pyrocprofsys { namespace py = pybind11; using namespace std::placeholders; // for _1, _2, _3... using namespace py::literals; -} // namespace pyomnitrace +} // namespace pyrocprofsys diff --git a/source/python/omnitrace/__init__.py b/source/python/rocprofsys/__init__.py similarity index 79% rename from source/python/omnitrace/__init__.py rename to source/python/rocprofsys/__init__.py index 0773cbbe..6f083270 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" """ @@ -37,23 +37,23 @@ try: import os - os.environ["OMNITRACE_PATH"] = os.path.abspath( + os.environ["ROCPROFSYS_PATH"] = os.path.abspath( os.path.join(os.path.dirname(__file__), "../../..") ) - from .libpyomnitrace import coverage + from .libpyrocprofsys import coverage from . import user from .profiler import Profiler, FakeProfiler - from .libpyomnitrace.profiler import ( + from .libpyrocprofsys.profiler import ( profiler_function, profiler_init, profiler_finalize, ) - from .libpyomnitrace import initialize - from .libpyomnitrace import finalize - from .libpyomnitrace import is_initialized - from .libpyomnitrace import is_finalized - from .libpyomnitrace.profiler import config as Config + from .libpyrocprofsys import initialize + from .libpyrocprofsys import finalize + from .libpyrocprofsys import is_initialized + from .libpyrocprofsys import is_finalized + from .libpyrocprofsys.profiler import config as Config config = Config profile = Profiler diff --git a/source/python/omnitrace/__main__.py b/source/python/rocprofsys/__main__.py similarity index 88% rename from source/python/omnitrace/__main__.py rename to source/python/rocprofsys/__main__.py index a4f43ec4..21dba2e4 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 @@ -40,7 +40,7 @@ import traceback PY3 = sys.version_info[0] == 3 -_OMNITRACE_PYTHON_SCRIPT_FILE = None +_ROCPROFSYS_PYTHON_SCRIPT_FILE = None # Python 3.x compatibility utils: execfile try: @@ -81,7 +81,7 @@ def parse_args(args=None): if args is None: args = sys.argv[1:] - from .libpyomnitrace.profiler import config as _profiler_config + from .libpyrocprofsys.profiler import config as _profiler_config def str2bool(v): if isinstance(v, bool): @@ -102,9 +102,9 @@ def str2bool(v): _default_label.append("line") parser = argparse.ArgumentParser( - "omnitrace", + "rocprofsys", add_help=True, - epilog="usage: {} -m omnitrace --