From 395c330dade439c00cb765591461f8fa44ca50eb Mon Sep 17 00:00:00 2001 From: jamesxu2 Date: Tue, 27 Aug 2024 10:20:48 -0400 Subject: [PATCH 1/7] Fix SWDEV-473314 by avoiding empty unique_ptr dereference (#371) - Revert part of https://github.com/ROCm/omnitrace/pull/78/commits/b134a68110b2c96ce11293d93ad56f38e211fd06 modifying source/lib/omnitrace/library/components/roctracer.cpp --- source/lib/omnitrace/library/components/roctracer.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/source/lib/omnitrace/library/components/roctracer.cpp b/source/lib/omnitrace/library/components/roctracer.cpp index 381508955..a419e46dc 100644 --- a/source/lib/omnitrace/library/components/roctracer.cpp +++ b/source/lib/omnitrace/library/components/roctracer.cpp @@ -314,12 +314,7 @@ void roctracer::shutdown() { auto_lock_t _lk{ type_mutex() }; - if(!roctracer_is_setup()) - { - if(!roctracer_is_init() && tim::storage::instance()) - tim::storage::instance()->reset(); - return; - } + if(!roctracer_is_setup()) return; roctracer_is_setup() = false; From f9e036a40cc8f832ddc8c51777d036776888f126 Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Wed, 28 Aug 2024 08:46:07 -0400 Subject: [PATCH 2/7] Add installers for ROCm 5.6 and 5.7 for SUSE 15.5 (#374) Signed-off-by: David Galiffi --- .github/workflows/cpack.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/cpack.yml b/.github/workflows/cpack.yml index f3bcc30f4..4615511be 100644 --- a/.github/workflows/cpack.yml +++ b/.github/workflows/cpack.yml @@ -130,6 +130,12 @@ jobs: - os-distro: "opensuse" os-version: "15.5" rocm-version: "0.0" + - os-distro: "opensuse" + os-version: "15.5" + rocm-version: "5.6" + - os-distro: "opensuse" + os-version: "15.5" + rocm-version: "5.7" - os-distro: "opensuse" os-version: "15.5" rocm-version: "6.0" From b00d1b35dec4204ead416dab6016c7866093c151 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 4 Sep 2024 17:09:38 -0400 Subject: [PATCH 3/7] Bump cryptography from 42.0.8 to 43.0.1 in /docs/sphinx (#376) Bumps [cryptography](https://github.com/pyca/cryptography) from 42.0.8 to 43.0.1. - [Changelog](https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pyca/cryptography/compare/42.0.8...43.0.1) --- updated-dependencies: - dependency-name: cryptography dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- docs/sphinx/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sphinx/requirements.txt b/docs/sphinx/requirements.txt index 81c604124..5ba5428ea 100644 --- a/docs/sphinx/requirements.txt +++ b/docs/sphinx/requirements.txt @@ -31,7 +31,7 @@ click==8.1.7 # sphinx-external-toc click-log==0.4.0 # via doxysphinx -cryptography==42.0.8 +cryptography==43.0.1 # via pyjwt deprecated==1.2.14 # via pygithub From 702da3a679c687b558cc7ab11c054fa12d67d625 Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Thu, 5 Sep 2024 15:47:16 -0400 Subject: [PATCH 4/7] Install the LICENSE file to ${CMAKE_INSTALL_DOCDIR} (#377) * Install the LICENSE file to ${CMAKE_INSTALL_DOCDIR} ie., {INSTALL_PREFIX}/share/doc/omnitrace/LICENSE Internal ticket: SWDEV-466385 Signed-off-by: David Galiffi * Add CPACK_RPM_PACKAGE_LICENSE = "MIT" Signed-off-by: David Galiffi --------- Signed-off-by: David Galiffi --- CMakeLists.txt | 6 ++++++ cmake/ConfigCPack.cmake | 1 + 2 files changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ac627bb3..d6f8d6c59 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -395,6 +395,12 @@ install( DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/modulefiles/${PROJECT_NAME} COMPONENT setup) +install( + FILES + ${PROJECT_SOURCE_DIR}/LICENSE + DESTINATION ${CMAKE_INSTALL_DOCDIR} + COMPONENT setup) + # ------------------------------------------------------------------------------# # # install diff --git a/cmake/ConfigCPack.cmake b/cmake/ConfigCPack.cmake index 5f8ecbbe3..82c354b51 100644 --- a/cmake/ConfigCPack.cmake +++ b/cmake/ConfigCPack.cmake @@ -214,6 +214,7 @@ set(CPACK_RPM_PACKAGE_PROVIDES "${CPACK_RPM_PACKAGE_PROVIDES}" CACHE STRING "RPM package provides" FORCE) +set(CPACK_RPM_PACKAGE_LICENSE "MIT") set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") set(CPACK_RPM_PACKAGE_RELEASE_DIST ON) set(CPACK_RPM_PACKAGE_AUTOREQPROV ON) From a9face692f86cb674453274d6ff0d74a70d963bb Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Thu, 5 Sep 2024 17:41:53 -0400 Subject: [PATCH 5/7] Fixing CMake Format Signed-off-by: David Galiffi --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d6f8d6c59..8d7bf08e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -396,8 +396,7 @@ install( COMPONENT setup) install( - FILES - ${PROJECT_SOURCE_DIR}/LICENSE + FILES ${PROJECT_SOURCE_DIR}/LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT setup) From 1413ab612d39cbc7ca984a27fffb9001266a9ab2 Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Wed, 11 Sep 2024 14:44:28 -0400 Subject: [PATCH 6/7] Update CODEOWNERS (#382) --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index d9601f509..0cab2fb55 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,4 +1,4 @@ -* @jrmadsen +* @jrmadsen @dgaliffiAMD # Documentation files docs/* @ROCm/rocm-documentation From 96d7b8f0ab679aa5e2ba6cfa38ede1650767fbed Mon Sep 17 00:00:00 2001 From: ajanicijamd Date: Fri, 13 Sep 2024 13:43:26 -0400 Subject: [PATCH 7/7] Update Perfetto and fix tests (#378) Fix for "SWDEV-479652" - Perfetto-based tests are failing. Updated version of perfetto submodule to v46.0. Modified Omnitrace code that uses Perfetto, so it can compile. Modified the testing code, so it can run the version of trace_processor_shell provided (v46.0). --------- Signed-off-by: Aleksandar Janicijevic Co-authored-by: David Galiffi --- .github/workflows/opensuse.yml | 6 ++ .github/workflows/redhat.yml | 11 ++++ .github/workflows/ubuntu-focal.yml | 27 ++++---- .github/workflows/ubuntu-jammy.yml | 4 +- cmake/Packages.cmake | 2 +- cmake/Perfetto.cmake | 4 +- cmake/Templates/args.gn.in | 8 +-- examples/python/source-numpy.py | 83 ++++++++++++++++++++++++ examples/python/source.py | 47 +++++--------- external/perfetto | 2 +- source/lib/core/perfetto.hpp | 11 ++-- source/lib/omnitrace/library/tracing.hpp | 6 +- tests/omnitrace-python-tests.cmake | 3 +- tests/omnitrace-testing.cmake | 1 + tests/validate-perfetto-proto.py | 28 ++++++-- 15 files changed, 173 insertions(+), 70 deletions(-) create mode 100755 examples/python/source-numpy.py diff --git a/.github/workflows/opensuse.yml b/.github/workflows/opensuse.yml index 58ceb6193..34022181c 100644 --- a/.github/workflows/opensuse.yml +++ b/.github/workflows/opensuse.yml @@ -58,6 +58,11 @@ jobs: timeout_minutes: 25 max_attempts: 5 command: | + wget https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v46.0/linux-amd64/trace_processor_shell -P /opt/trace_processor/bin && + chmod +x /opt/trace_processor/bin/trace_processor_shell + python3 -m pip install --upgrade pip && + python3 -m pip install numpy perfetto dataclasses && + python3 -m pip install 'cmake==3.21.4' && for i in 6 7 8 9 10; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy perfetto dataclasses; done - name: Configure Env @@ -87,6 +92,7 @@ jobs: -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" diff --git a/.github/workflows/redhat.yml b/.github/workflows/redhat.yml index e4c996f75..474dac56a 100644 --- a/.github/workflows/redhat.yml +++ b/.github/workflows/redhat.yml @@ -68,6 +68,16 @@ jobs: env - name: Install Packages + shell: bash + run: | + wget https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v46.0/linux-amd64/trace_processor_shell -P /opt/trace_processor/bin && + chmod +x /opt/trace_processor/bin/trace_processor_shell + python3 -m pip install --upgrade pip && + python3 -m pip install numpy perfetto dataclasses && + python3 -m pip install 'cmake==3.21.4' && + for i in 6 7 8 9 10; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy perfetto dataclasses; done + + - name: Install ROCm Packages if: ${{ matrix.rocm-version > 0 }} timeout-minutes: 30 shell: bash @@ -109,6 +119,7 @@ jobs: -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" diff --git a/.github/workflows/ubuntu-focal.yml b/.github/workflows/ubuntu-focal.yml index 58a64d8be..5a4d53379 100644 --- a/.github/workflows/ubuntu-focal.yml +++ b/.github/workflows/ubuntu-focal.yml @@ -94,9 +94,10 @@ jobs: apt-get update && apt-get upgrade -y && apt-get install -y build-essential m4 autoconf libtool python3-pip libiberty-dev clang libmpich-dev mpich environment-modules ${{ matrix.compiler }} && + wget https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v46.0/linux-amd64/trace_processor_shell -P /opt/trace_processor/bin && + chmod +x /opt/trace_processor/bin/trace_processor_shell && python3 -m pip install --upgrade pip && - python3 -m pip install numpy && - python3 -m pip install perfetto && + python3 -m pip install numpy perfetto dataclasses && python3 -m pip install 'cmake==3.16.3' && for i in 6 7 8 9 10; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy perfetto dataclasses; done && apt-get -y --purge autoremove && @@ -246,20 +247,12 @@ jobs: mpi-headers: ['OFF'] build-jobs: ['3'] ctest-exclude: ['-LE "mpi-example|transpose"'] - perfetto-tools: ['OFF'] include: - - compiler: 'g++' - rocm-version: '4.5' - mpi-headers: 'OFF' - build-jobs: '2' - ctest-exclude: '-LE "mpi-example|transpose"' - perfetto-tools: 'ON' - compiler: 'g++' rocm-version: 'debian' mpi-headers: 'ON' build-jobs: '2' ctest-exclude: '-LE transpose' - perfetto-tools: 'OFF' env: BUILD_TYPE: MinSizeRel @@ -283,7 +276,10 @@ jobs: echo "deb [arch=amd64] https://repo.radeon.com/rocm/apt/${{ matrix.rocm-version }}/ ubuntu main" | tee /etc/apt/sources.list.d/rocm.list && apt-get update && apt-get install -y build-essential m4 autoconf libtool python3-pip clang libomp-dev ${{ matrix.compiler }} libudev1 libnuma1 rocm-dev rocm-utils rocm-smi-lib roctracer-dev rocprofiler-dev rccl-dev hip-base hsa-amd-aqlprofile hsa-rocr-dev hsakmt-roct-dev libpapi-dev curl libopenmpi-dev openmpi-bin libfabric-dev && + wget https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v46.0/linux-amd64/trace_processor_shell -P /opt/trace_processor/bin && + chmod +x /opt/trace_processor/bin/trace_processor_shell && python3 -m pip install --upgrade pip && + python3 -m pip install numpy perfetto dataclasses && python3 -m pip install 'cmake==3.21.4' && for i in 6 7 8 9 10; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy perfetto dataclasses; done && apt-get -y --purge autoremove && @@ -345,7 +341,6 @@ jobs: -DOMNITRACE_USE_PYTHON=ON -DOMNITRACE_USE_MPI_HEADERS=${{ matrix.mpi-headers }} -DOMNITRACE_USE_SANITIZER=OFF - -DOMNITRACE_INSTALL_PERFETTO_TOOLS=${{ matrix.perfetto-tools }} -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 }} @@ -444,9 +439,10 @@ jobs: sudo apt-get install -y build-essential m4 autoconf libtool python3-pip clang libomp-dev environment-modules ${{ matrix.deps }} ${{ matrix.compiler }} && if [ "${{ matrix.mpi }}" = "mpich" ]; then sudo apt-get install -y libmpich-dev mpich; fi && if [ "${{ matrix.mpi }}" = "openmpi" ]; then sudo apt-get install -y libopenmpi-dev openmpi-bin libfabric-dev; fi && + wget https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v46.0/linux-amd64/trace_processor_shell -P /opt/trace_processor/bin && + chmod +x /opt/trace_processor/bin/trace_processor_shell && python3 -m pip install --upgrade pip && - python3 -m pip install numpy && - python3 -m pip install perfetto && + python3 -m pip install numpy perfetto dataclasses && python3 -m pip install 'cmake==3.16.3' && sudo apt-get -y --purge autoremove && sudo apt-get -y clean @@ -596,9 +592,10 @@ jobs: command: | apt-get update && apt-get install -y build-essential m4 autoconf libtool python3-pip clang libomp-dev environment-modules gcc g++ mpich libmpich-dev texinfo && + wget https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v46.0/linux-amd64/trace_processor_shell -P /opt/trace_processor/bin && + chmod +x /opt/trace_processor/bin/trace_processor_shell && python3 -m pip install --upgrade pip && - python3 -m pip install numpy && - python3 -m pip install perfetto && + python3 -m pip install numpy perfetto dataclasses && python3 -m pip install 'cmake==3.24.1' && for i in 6 7 8 9 10; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy perfetto dataclasses; done && apt-get -y --purge autoremove && diff --git a/.github/workflows/ubuntu-jammy.yml b/.github/workflows/ubuntu-jammy.yml index 4e4b94ff4..edaae62e9 100644 --- a/.github/workflows/ubuntu-jammy.yml +++ b/.github/workflows/ubuntu-jammy.yml @@ -110,8 +110,10 @@ jobs: apt-get install -y software-properties-common && apt-get upgrade -y && apt-get install -y build-essential m4 autoconf libtool python3-pip libiberty-dev clang libomp-dev libopenmpi-dev libfabric-dev openmpi-bin environment-modules ${{ matrix.compiler }} && + wget https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v46.0/linux-amd64/trace_processor_shell -P /opt/trace_processor/bin && + chmod +x /opt/trace_processor/bin/trace_processor_shell && python3 -m pip install --upgrade pip && - python3 -m pip install numpy && + python3 -m pip install numpy perfetto dataclasses && python3 -m pip install 'cmake==3.21.4' && for i in 6 7 8 9 10; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy perfetto dataclasses; done diff --git a/cmake/Packages.cmake b/cmake/Packages.cmake index 13b831314..c89cdb322 100644 --- a/cmake/Packages.cmake +++ b/cmake/Packages.cmake @@ -483,7 +483,7 @@ omnitrace_checkout_git_submodule( RELATIVE_PATH external/perfetto WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} REPO_URL https://android.googlesource.com/platform/external/perfetto - REPO_BRANCH v28.0 + REPO_BRANCH v46.0 TEST_FILE sdk/perfetto.cc) include(Perfetto) diff --git a/cmake/Perfetto.cmake b/cmake/Perfetto.cmake index 7e8e490f4..aa1f11f25 100644 --- a/cmake/Perfetto.cmake +++ b/cmake/Perfetto.cmake @@ -67,10 +67,10 @@ if(CMAKE_CXX_COMPILER_IS_CLANG) else() set(PERFETTO_IS_CLANG false) set(OMNITRACE_PERFETTO_C_FLAGS - "-static-libgcc -Wno-maybe-uninitialized" + "-static-libgcc -Wno-maybe-uninitialized -Wno-stringop-overflow" CACHE STRING "Perfetto C flags") set(OMNITRACE_PERFETTO_CXX_FLAGS - "-static-libgcc -Wno-maybe-uninitialized" + "-static-libgcc -Wno-maybe-uninitialized -Wno-stringop-overflow -Wno-mismatched-new-delete" CACHE STRING "Perfetto C++ flags") endif() diff --git a/cmake/Templates/args.gn.in b/cmake/Templates/args.gn.in index 33ecf87bc..860a10a84 100644 --- a/cmake/Templates/args.gn.in +++ b/cmake/Templates/args.gn.in @@ -8,19 +8,19 @@ is_clang = @PERFETTO_IS_CLANG@ is_hermetic_clang = false enable_perfetto_benchmarks = false -enable_perfetto_integration_tests = false +enable_perfetto_integration_tests = true enable_perfetto_unittests = false enable_perfetto_fuzzers = false # enable_perfetto_stderr_crash_dump = false enable_perfetto_heapprofd = false enable_perfetto_tools = false -enable_perfetto_trace_processor = false -enable_perfetto_trace_processor_httpd = false +enable_perfetto_trace_processor = true +enable_perfetto_trace_processor_httpd = true enable_perfetto_trace_processor_json = false enable_perfetto_trace_processor_linenoise = false enable_perfetto_trace_processor_percentile = false -enable_perfetto_trace_processor_sqlite = false +enable_perfetto_trace_processor_sqlite = true enable_perfetto_ui = false extra_cflags = "@OMNITRACE_PERFETTO_C_FLAGS@" diff --git a/examples/python/source-numpy.py b/examples/python/source-numpy.py new file mode 100755 index 000000000..2979ae26c --- /dev/null +++ b/examples/python/source-numpy.py @@ -0,0 +1,83 @@ +#!@PYTHON_EXECUTABLE@ + +import os +import sys +import time +import omnitrace +from omnitrace.user import region as omni_user_region + +_prefix = "" + + +def fib(n): + return n if n < 2 else (fib(n - 1) + fib(n - 2)) + + +try: + import numpy as np + + def inefficient(n): + print(f"[{_prefix}] ... running inefficient({n}) (1)") + a = 0 + for i in range(n): + a += i + for j in range(n): + a += j + _len = a * n * n + _ret = np.random.rand(_len).sum() + print(f"[{_prefix}] ... sum of {_len} random elements: {_ret}") + return _ret + +except ImportError as e: + print(f"ImportError: {e}") + import random + + def _sum(arr): + print(f"---- in _sum") + return sum(arr) + + def inefficient(n): + print(f"[{_prefix}] ... running inefficient({n})") + a = 0 + for i in range(n): + a += i + for j in range(n): + a += j + _len = a * n * n + _arr = [random.random() for _ in range(_len)] + _ret = _sum(_arr) + print(f"[{_prefix}] ... sum of {_len} random elements: {_ret}") + return _ret + + +@omnitrace.profile() +def run(n): + _ret = 0 + _ret += fib(n) + _ret += inefficient(n) + return _ret + + +if __name__ == "__main__": + import argparse + + parser = argparse.ArgumentParser() + parser.add_argument("-n", "--num-iterations", help="Number", type=int, default=3) + parser.add_argument("-v", "--value", help="Starting value", type=int, default=20) + parser.add_argument( + "-s", + "--stop-profile", + help="Stop tracing after given iterations", + type=int, + default=0, + ) + args = parser.parse_args() + + _prefix = os.path.basename(__file__) + print(f"[{_prefix}] Executing {args.num_iterations} iterations...\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() + 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 2bef32b7b..44efbe484 100755 --- a/examples/python/source.py +++ b/examples/python/source.py @@ -5,6 +5,7 @@ import time import omnitrace from omnitrace.user import region as omni_user_region +import random _prefix = "" @@ -13,39 +14,23 @@ def fib(n): return n if n < 2 else (fib(n - 1) + fib(n - 2)) -try: - import numpy as np +def _sum(arr): + print(f"---- in _sum") + return sum(arr) - def inefficient(n): - print(f"[{_prefix}] ... running inefficient({n})") - a = 0 - for i in range(n): - a += i - for j in range(n): - a += j - _len = a * n * n - _ret = np.random.rand(_len).sum() - print(f"[{_prefix}] ... sum of {_len} random elements: {_ret}") - return _ret -except ImportError: - import random - - def _sum(arr): - return sum(arr) - - def inefficient(n): - print(f"[{_prefix}] ... running inefficient({n})") - a = 0 - for i in range(n): - a += i - for j in range(n): - a += j - _len = a * n * n - _arr = [random.random() for _ in range(_len)] - _ret = _sum(_arr) - print(f"[{_prefix}] ... sum of {_len} random elements: {_ret}") - return _ret +def inefficient(n): + print(f"[{_prefix}] ... running inefficient({n})") + a = 0 + for i in range(n): + a += i + for j in range(n): + a += j + _len = a * n * n + _arr = [random.random() for _ in range(_len)] + _ret = _sum(_arr) + print(f"[{_prefix}] ... sum of {_len} random elements: {_ret}") + return _ret @omnitrace.profile() diff --git a/external/perfetto b/external/perfetto index 99ead408d..c74251226 160000 --- a/external/perfetto +++ b/external/perfetto @@ -1 +1 @@ -Subproject commit 99ead408d98eaa25b7819c7e059734bea42fa148 +Subproject commit c74251226a8caa0b43377902ee06d2570faa0c15 diff --git a/source/lib/core/perfetto.hpp b/source/lib/core/perfetto.hpp index 78f854486..ac67b3e44 100644 --- a/source/lib/core/perfetto.hpp +++ b/source/lib/core/perfetto.hpp @@ -109,11 +109,12 @@ perfetto_counter_track::emplace(size_t _idx, const std::string& _v, auto _index = _track_data.size(); auto& _name = _name_data.emplace_back(std::make_unique(_v)); const char* _unit_name = (_units && strlen(_units) > 0) ? _units : nullptr; - _track_data.emplace_back(::perfetto::CounterTrack{ _name->c_str() } - .set_unit_name(_unit_name) - .set_category(_category) - .set_unit_multiplier(_mult) - .set_is_incremental(_incr)); + _track_data.emplace_back( + ::perfetto::CounterTrack{ ::perfetto::DynamicString{ _name->c_str() } } + .set_unit_name(_unit_name) + .set_category(_category) + .set_unit_multiplier(_mult) + .set_is_incremental(_incr)); if(config::get_is_continuous_integration()) { for(auto& itr : _missing) diff --git a/source/lib/omnitrace/library/tracing.hpp b/source/lib/omnitrace/library/tracing.hpp index 5e5bc6397..3fa6e0289 100644 --- a/source/lib/omnitrace/library/tracing.hpp +++ b/source/lib/omnitrace/library/tracing.hpp @@ -642,14 +642,14 @@ mark_perfetto_ts(CategoryT, const char* name, uint64_t _ts, Args&&... args) template inline void -mark_perfetto_track(CategoryT, const char*, ::perfetto::Track _track, uint64_t _ts, +mark_perfetto_track(CategoryT, const char* name, ::perfetto::Track _track, uint64_t _ts, Args&&... args) { // skip if category is disabled if(category_mark_disabled()) return; - TRACE_EVENT_INSTANT(trait::name::value, _track, _ts, - std::forward(args)...); + TRACE_EVENT_INSTANT(trait::name::value, ::perfetto::DynamicString{ name }, + _track, _ts, std::forward(args)...); } } // namespace tracing } // namespace omnitrace diff --git a/tests/omnitrace-python-tests.cmake b/tests/omnitrace-python-tests.cmake index 32d4c2c51..5f770a657 100644 --- a/tests/omnitrace-python-tests.cmake +++ b/tests/omnitrace-python-tests.cmake @@ -166,7 +166,8 @@ foreach(_VERSION ${OMNITRACE_PYTHON_VERSIONS}) NAME ${TEST_NAME}-validate-perfetto COMMAND ${_PYTHON_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/validate-perfetto-proto.py - -m ${TEST_PERFETTO_METRIC} ${TEST_ARGS} -p -i + -m ${TEST_PERFETTO_METRIC} ${TEST_ARGS} -p -t + /opt/trace_processor/bin/trace_processor_shell -i PYTHON_VERSION ${_VERSION} FILE omnitrace-tests-output/${TEST_NAME}/${_VERSION}/${TEST_PERFETTO_FILE} DEPENDS ${TEST_NAME}-${_VERSION} diff --git a/tests/omnitrace-testing.cmake b/tests/omnitrace-testing.cmake index 9e4c88619..32250900b 100644 --- a/tests/omnitrace-testing.cmake +++ b/tests/omnitrace-testing.cmake @@ -985,6 +985,7 @@ function(OMNITRACE_ADD_VALIDATION_TEST) ${CMAKE_CURRENT_LIST_DIR}/validate-perfetto-proto.py -m "${TEST_PERFETTO_METRIC}" ${TEST_ARGS} -i ${PROJECT_BINARY_DIR}/omnitrace-tests-output/${TEST_NAME}/${TEST_PERFETTO_FILE} + -t /opt/trace_processor/bin/trace_processor_shell WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) endif() diff --git a/tests/validate-perfetto-proto.py b/tests/validate-perfetto-proto.py index 29facafa0..2d9910424 100755 --- a/tests/validate-perfetto-proto.py +++ b/tests/validate-perfetto-proto.py @@ -1,23 +1,36 @@ #!/usr/bin/env python3 import sys +import os import argparse -from perfetto.trace_processor import TraceProcessor +from perfetto.trace_processor import TraceProcessor, TraceProcessorConfig -def load_trace(inp, max_tries=5, retry_wait=1): +def load_trace(inp, max_tries=5, retry_wait=1, bin_path=None): """Occasionally connecting to the trace processor fails with HTTP errors so this function tries to reduce spurious test failures""" n = 0 tp = None + + # Check if bin_path is set and if it exists + print("trace_processor path: ", bin_path) + if bin_path and not os.path.isfile(bin_path): + print(f"Path {bin_path} does not exist. Using the default path.") + bin_path = None + while tp is None: try: - tp = TraceProcessor(trace=(inp)) + if bin_path: + config = TraceProcessorConfig(bin_path=bin_path) + tp = TraceProcessor(trace=inp, config=config) + else: + tp = TraceProcessor(trace=inp) break - except Exception as e: - sys.stderr.write(f"{e}\n") + except Exception as ex: + sys.stderr.write(f"{ex}\n") sys.stderr.flush() + if n >= max_tries: raise else: @@ -71,6 +84,9 @@ def validate_perfetto(data, labels, counts, depths): "-p", "--print", action="store_true", help="Print the processed perfetto data" ) parser.add_argument("-i", "--input", type=str, help="Input file", required=True) + parser.add_argument( + "-t", "--trace_processor_shell", type=str, help="Path of trace_processor_shell" + ) parser.add_argument( "--key-names", type=str, @@ -93,7 +109,7 @@ def validate_perfetto(data, labels, counts, depths): "The same number of labels, counts, and depths must be specified" ) - tp = load_trace(args.input) + tp = load_trace(args.input, bin_path=args.trace_processor_shell) if tp is None: raise ValueError(f"trace {args.input} could not be loaded")