diff --git a/.azuredevops/rocm-ci.yml b/.azuredevops/rocm-ci.yml new file mode 100644 index 000000000..ae8122aef --- /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 }}/omnitrace.yml@pipelines_repo diff --git a/.github/dependabot.yml b/.github/dependabot.yml index fe22a4c3d..d24c82f8f 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 db5441d79..0f001ea1d 100644 --- a/.github/workflows/containers.yml +++ b/.github/workflows/containers.yml @@ -7,7 +7,7 @@ on: schedule: - cron: 0 5 * * * push: - branches: [main, amd-mainline] + branches: [amd-staging] paths: - '.github/workflows/containers.yml' - 'docker/**' diff --git a/.github/workflows/cpack.yml b/.github/workflows/cpack.yml index a564b6899..fa1b01933 100644 --- a/.github/workflows/cpack.yml +++ b/.github/workflows/cpack.yml @@ -4,7 +4,7 @@ run-name: cpack on: workflow_dispatch: push: - branches: [main, amd-mainline, release/**] + branches: [amd-staging, amd-mainline, release/**] tags: - "v[1-9].[0-9]+.[0-9]+*" - "rocm-[1-9].[0-9]+.[0-9]+*" @@ -13,7 +13,7 @@ on: - 'docs/**' - 'source/docs/**' pull_request: - branches: [main, amd-mainline] + branches: [amd-staging] paths: - '.github/workflows/cpack.yml' - 'docker/**' diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 4b2340fd3..eec86ee60 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -3,14 +3,14 @@ name: Documentation on: workflow_dispatch: push: - branches: [main, amd-mainline, gh-pages] + branches: [amd-staging, amd-mainline, gh-pages] paths: - '*.md' - 'source/docs/**' - '.github/workflows/docs.yml' - 'VERSION' pull_request: - branches: [main, amd-mainline] + branches: [amd-staging, amd-mainline] paths: - '*.md' - 'source/docs/**' diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml index f3e4b7df0..f41db760e 100644 --- a/.github/workflows/formatting.yml +++ b/.github/workflows/formatting.yml @@ -4,9 +4,9 @@ run-name: formatting on: push: - branches: [ main, develop, amd-mainline, amd-staging, release/** ] + branches: [ amd-mainline, amd-staging, release/** ] pull_request: - branches: [ main, develop, amd-mainline, amd-staging, release/** ] + branches: [ amd-mainline, amd-staging, release/** ] concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/opensuse.yml b/.github/workflows/opensuse.yml index ecec47ece..60541f254 100644 --- a/.github/workflows/opensuse.yml +++ b/.github/workflows/opensuse.yml @@ -3,7 +3,7 @@ run-name: opensuse-15 on: push: - branches: [ main, develop, amd-mainline, amd-staging, release/** ] + branches: [ amd-mainline, amd-staging, release/** ] paths-ignore: - '*.md' - 'docs/**' @@ -15,7 +15,7 @@ on: - '.github/workflows/formatting.yml' - 'docker/**' pull_request: - branches: [ main, develop, amd-mainline, amd-staging, release/** ] + branches: [ amd-mainline, amd-staging, release/** ] paths-ignore: - '*.md' - 'docs/**' @@ -61,9 +61,9 @@ jobs: 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 + python3 -m pip install --upgrade numpy perfetto dataclasses && + python3 -m pip install 'cmake==3.18.4' && + for i in 6 7 8 9 10 11; do /opt/conda/envs/py3.${i}/bin/python -m pip install --upgrade numpy perfetto dataclasses; done - name: Configure Env run: diff --git a/.github/workflows/redhat.yml b/.github/workflows/redhat.yml index 0a3869d80..2070f5771 100644 --- a/.github/workflows/redhat.yml +++ b/.github/workflows/redhat.yml @@ -3,7 +3,7 @@ run-name: redhat on: push: - branches: [ main, develop, amd-mainline, amd-staging, release/** ] + branches: [ amd-mainline, amd-staging, release/** ] paths-ignore: - '*.md' - 'docs/**' @@ -15,7 +15,7 @@ on: - '.github/workflows/formatting.yml' - 'docker/**' pull_request: - branches: [ main, develop, amd-mainline, amd-staging, release/** ] + branches: [ amd-mainline, amd-staging, release/** ] paths-ignore: - '*.md' - 'docs/**' @@ -72,10 +72,12 @@ jobs: 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 + yum install -y epel-release && yum install -y 'dnf-command(config-manager)' && crb enable && \ + yum install -y curl dpkg-devel numactl-devel openmpi-devel papi-devel python3-pip texinfo wget which zlib-devel && 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 + python3 -m pip install --upgrade numpy perfetto dataclasses && + python3 -m pip install 'cmake==3.18.4' && + for i in 6 7 8 9 10 11; do /opt/conda/envs/py3.${i}/bin/python -m pip install --upgrade numpy perfetto dataclasses; done - name: Install ROCm Packages if: ${{ matrix.rocm-version > 0 }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 085c884b8..d2c91c535 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,8 @@ on: workflow_dispatch: push: tags: - - v* + - "v[1-9].[0-9]+.[0-9]+*" + - "rocm-[1-9].[0-9]+.[0-9]+*" concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/ubuntu-focal.yml b/.github/workflows/ubuntu-focal.yml index 5be371a0d..3ced6959a 100644 --- a/.github/workflows/ubuntu-focal.yml +++ b/.github/workflows/ubuntu-focal.yml @@ -3,7 +3,7 @@ run-name: ubuntu-focal on: push: - branches: [ main, develop, amd-mainline, amd-staging, release/** ] + branches: [ amd-mainline, amd-staging, release/** ] paths-ignore: - '*.md' - 'docs/**' @@ -15,7 +15,7 @@ on: - '.github/workflows/formatting.yml' - 'docker/**' pull_request: - branches: [ main, develop, amd-mainline, amd-staging, release/** ] + branches: [ amd-mainline, amd-staging, release/** ] paths-ignore: - '*.md' - 'docs/**' @@ -93,13 +93,13 @@ jobs: add-apt-repository -y ppa:ubuntu-toolchain-r/test && 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 }} && + apt-get install -y autoconf bison build-essential clang environment-modules libiberty-dev libmpich-dev libtool m4 mpich python3-pip texinfo ${{ 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 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 && + python3 -m pip install --upgrade numpy perfetto dataclasses && + python3 -m pip install 'cmake==3.18.4' && + for i in 6 7 8 9 10 11; do /opt/conda/envs/py3.${i}/bin/python -m pip install --upgrade numpy perfetto dataclasses; done && apt-get -y --purge autoremove && apt-get -y clean && /opt/conda/bin/conda clean -y -a @@ -275,13 +275,13 @@ jobs: wget -q -O - https://repo.radeon.com/rocm/rocm.gpg.key | apt-key add - && 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 && + apt-get install -y autoconf bison build-essential clang curl hip-base hsa-amd-aqlprofile hsa-rocr-dev hsakmt-roct-dev libfabric-dev libnuma1 libomp-dev libopenmpi-dev libpapi-dev libtool libudev1 m4 openmpi-bin python3-pip rccl-dev rocm-dev rocm-smi-lib rocm-utils rocprofiler-dev roctracer-dev texinfo ${{ 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 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 && + python3 -m pip install --upgrade numpy perfetto dataclasses && + python3 -m pip install 'cmake==3.18.4' && + for i in 6 7 8 9 10 11; do /opt/conda/envs/py3.${i}/bin/python -m pip install --upgrade numpy perfetto dataclasses; done && apt-get -y --purge autoremove && apt-get -y clean && /opt/conda/bin/conda clean -y -a @@ -436,14 +436,14 @@ jobs: max_attempts: 5 command: | sudo apt-get update && - sudo apt-get install -y build-essential m4 autoconf libtool python3-pip clang libomp-dev environment-modules ${{ matrix.deps }} ${{ matrix.compiler }} && + sudo apt-get install -y autoconf bison build-essential clang environment-modules gettext libomp-dev libtool m4 python3-pip texinfo ${{ matrix.compiler }} ${{ matrix.deps }} && 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 perfetto dataclasses && - python3 -m pip install 'cmake==3.16.3' && + python3 -m pip install --upgrade numpy perfetto dataclasses && + python3 -m pip install 'cmake==3.18.4' && sudo apt-get -y --purge autoremove && sudo apt-get -y clean @@ -591,13 +591,13 @@ jobs: max_attempts: 5 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 && + apt-get install -y autoconf bison build-essential clang environment-modules gcc g++ libmpich-dev libomp-dev libtool m4 mpich python3-pip 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 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 && + python3 -m pip install --upgrade numpy perfetto dataclasses && + python3 -m pip install 'cmake==3.18.4' && + for i in 6 7 8 9 10; do /opt/conda/envs/py3.${i}/bin/python -m pip install --upgrade numpy perfetto dataclasses; done && apt-get -y --purge autoremove && apt-get -y clean && /opt/conda/bin/conda clean -y -a diff --git a/.github/workflows/ubuntu-jammy.yml b/.github/workflows/ubuntu-jammy.yml index a7d1d5331..b6ee40205 100644 --- a/.github/workflows/ubuntu-jammy.yml +++ b/.github/workflows/ubuntu-jammy.yml @@ -3,7 +3,7 @@ run-name: ubuntu-jammy on: push: - branches: [ main, develop, amd-mainline, amd-staging, release/** ] + branches: [ amd-mainline, amd-staging, release/** ] paths-ignore: - '*.md' - 'docs/**' @@ -15,7 +15,7 @@ on: - '.github/workflows/formatting.yml' - 'docker/**' pull_request: - branches: [ main, develop, amd-mainline, amd-staging, release/** ] + branches: [ amd-mainline, amd-staging, release/** ] paths-ignore: - '*.md' - 'docs/**' @@ -109,13 +109,13 @@ jobs: apt-get update && 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 }} && + apt-get install -y autoconf bison build-essential clang environment-modules libfabric-dev libiberty-dev libomp-dev libopenmpi-dev libtool m4 openmpi-bin python3-pip texinfo ${{ 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 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 + python3 -m pip install --upgrade numpy perfetto dataclasses && + python3 -m pip install 'cmake==3.18.4' && + for i in 6 7 8 9 10 11; do /opt/conda/envs/py3.${i}/bin/python -m pip install --upgrade numpy perfetto dataclasses; done - name: Install ROCm Packages timeout-minutes: 25 diff --git a/.gitmodules b/.gitmodules index 0b1ce3d02..2aecf69e2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "external/timemory"] path = external/timemory - url = https://github.com/NERSC/timemory.git + url = https://github.com/ROCm/timemory.git [submodule "external/perfetto"] path = external/perfetto url = https://github.com/google/perfetto.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d7bf08e2..0cb9a8b07 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16 FATAL_ERROR) +cmake_minimum_required(VERSION 3.18.4 FATAL_ERROR) if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) diff --git a/README.md b/README.md index 9abe9c8cc..7722756ab 100755 --- a/README.md +++ b/README.md @@ -8,8 +8,9 @@ [![Documentation](https://github.com/ROCm/omnitrace/actions/workflows/docs.yml/badge.svg)](https://github.com/ROCm/omnitrace/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/#!/). +> Omnitrace is being rebranded to ROCm Systems Profiler and its new home is . +All future development will occur in the new repository; this includes upgrading the tool to use [rocprofiler-sdk](https://github.com/ROCm/rocprofiler-sdk). +This repository will remain open for some time and can be used with versions of ROCm before the introduction of rocprofiler-sdk (that is, before ROCm version 6.2). ## Overview diff --git a/cmake/Packages.cmake b/cmake/Packages.cmake index a391408b6..5aad9003f 100644 --- a/cmake/Packages.cmake +++ b/cmake/Packages.cmake @@ -648,7 +648,7 @@ mark_as_advanced(TIMEMORY_PROJECT_NAME) omnitrace_checkout_git_submodule( RELATIVE_PATH external/timemory WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - REPO_URL https://github.com/NERSC/timemory.git + REPO_URL https://github.com/ROCm/timemory.git REPO_BRANCH omnitrace) omnitrace_save_variables( diff --git a/docs/how-to/understanding-omnitrace-output.rst b/docs/how-to/understanding-omnitrace-output.rst index 08d560992..2ce574211 100644 --- a/docs/how-to/understanding-omnitrace-output.rst +++ b/docs/how-to/understanding-omnitrace-output.rst @@ -323,11 +323,6 @@ absolute path, then all ``OMNITRACE_OUTPUT_PATH`` and similar settings are ignored. Visit `ui.perfetto.dev `_ and open this file. -.. important:: - 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 `_, - then try using `Perfetto UI v46.0 `_. - .. image:: ../data/omnitrace-perfetto.png :alt: Visualization of a performance graph in Perfetto diff --git a/docs/sphinx/requirements.in b/docs/sphinx/requirements.in index b1eb21341..ad94caa9e 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.3 diff --git a/docs/sphinx/requirements.txt b/docs/sphinx/requirements.txt index 5ba5428ea..1b5eb1e04 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,21 +16,16 @@ 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 charset-normalizer==3.3.2 # via requests click==8.1.7 - # via - # click-log - # doxysphinx - # sphinx-external-toc -click-log==0.4.0 - # via doxysphinx + # via sphinx-external-toc cryptography==43.0.1 # via pyjwt deprecated==1.2.14 @@ -41,15 +36,13 @@ docutils==0.21.2 # myst-parser # pydata-sphinx-theme # sphinx -doxysphinx==3.3.9 - # via rocm-docs-core fastjsonschema==2.20.0 # via rocm-docs-core 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 @@ -57,26 +50,18 @@ jinja2==3.1.4 # via # myst-parser # sphinx -libsass==0.22.0 - # via doxysphinx -lxml==4.9.4 - # via doxysphinx markdown-it-py==3.0.0 # via # mdit-py-plugins # 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 packaging==24.1 # via # pydata-sphinx-theme @@ -87,23 +72,18 @@ 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 # accessible-pygments - # mpire # pydata-sphinx-theme # 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 - # via doxysphinx -pyyaml==6.0.1 +pyyaml==6.0.2 # via # myst-parser # rocm-docs-core @@ -112,15 +92,15 @@ requests==2.32.3 # via # pygithub # sphinx -rocm-docs-core[api-reference]==1.4.1 +rocm-docs-core[api-reference]==1.8.3 # 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 +115,31 @@ 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 - # 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/docs/what-is-omnitrace.rst b/docs/what-is-omnitrace.rst index 4ad340b8c..9fc7f9440 100644 --- a/docs/what-is-omnitrace.rst +++ b/docs/what-is-omnitrace.rst @@ -15,11 +15,6 @@ A visualization of the comprehensive Omnitrace results can be observed in any mo web browser. Upload the Perfetto (``.proto``) output files produced by Omnitrace at `ui.perfetto.dev `_ to see the details. -.. important:: - 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 `_, - then try using `Perfetto UI v46.0 `_. - Aggregated high-level results are available as human-readable text files and JSON files for programmatic analysis. The JSON output files are compatible with the `hatchet `_ Python package. Hatchet converts diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 8c8451e30..70bd687df 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16 FATAL_ERROR) +cmake_minimum_required(VERSION 3.18.4 FATAL_ERROR) project(omnitrace-examples LANGUAGES C CXX) diff --git a/examples/causal/CMakeLists.txt b/examples/causal/CMakeLists.txt index a3bba08bf..d03297865 100644 --- a/examples/causal/CMakeLists.txt +++ b/examples/causal/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16 FATAL_ERROR) +cmake_minimum_required(VERSION 3.18.4 FATAL_ERROR) project(omnitrace-causal-example LANGUAGES CXX) diff --git a/examples/code-coverage/CMakeLists.txt b/examples/code-coverage/CMakeLists.txt index 94a265a9b..d119c8ead 100644 --- a/examples/code-coverage/CMakeLists.txt +++ b/examples/code-coverage/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.18.4 FATAL_ERROR) project(omnitrace-code-coverage-example LANGUAGES CXX) diff --git a/examples/fork/CMakeLists.txt b/examples/fork/CMakeLists.txt index 909b18bbb..0b8ba94ac 100644 --- a/examples/fork/CMakeLists.txt +++ b/examples/fork/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.18.4 FATAL_ERROR) project(omnitrace-fork LANGUAGES CXX) diff --git a/examples/lulesh/CMakeLists.txt b/examples/lulesh/CMakeLists.txt index 8dd45dd28..60f8fce7b 100644 --- a/examples/lulesh/CMakeLists.txt +++ b/examples/lulesh/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16 FATAL_ERROR) +cmake_minimum_required(VERSION 3.18.4 FATAL_ERROR) project(omnitrace-lulesh-example LANGUAGES C CXX) diff --git a/examples/mpi/CMakeLists.txt b/examples/mpi/CMakeLists.txt index 4c9452928..3884885ce 100644 --- a/examples/mpi/CMakeLists.txt +++ b/examples/mpi/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16 FATAL_ERROR) +cmake_minimum_required(VERSION 3.18.4 FATAL_ERROR) project(omnitrace-mpi-examples LANGUAGES C CXX) diff --git a/examples/openmp/CMakeLists.txt b/examples/openmp/CMakeLists.txt index f63893aba..6b88d754c 100644 --- a/examples/openmp/CMakeLists.txt +++ b/examples/openmp/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16 FATAL_ERROR) +cmake_minimum_required(VERSION 3.18.4 FATAL_ERROR) project(omnitrace-openmp LANGUAGES CXX) @@ -53,3 +53,5 @@ if(OMNITRACE_INSTALL_EXAMPLES) DESTINATION bin COMPONENT omnitrace-examples) endif() + +add_subdirectory(target) diff --git a/examples/openmp/target/CMakeLists.txt b/examples/openmp/target/CMakeLists.txt new file mode 100644 index 000000000..13e91865d --- /dev/null +++ b/examples/openmp/target/CMakeLists.txt @@ -0,0 +1,108 @@ +# +# +# +cmake_minimum_required(VERSION 3.18.4 FATAL_ERROR) + +# try to find a compatible HIP version +if(ROCmVersion_MAJOR_VERSION AND ROCmVersion_MAJOR_VERSION GREATER_EQUAL 6) + find_package(hip ${ROCmVersion_MAJOR_VERSION}.0.0) +else() + find_package(hip) +endif() + +if(NOT hip_FOUND) + message(WARNING "ROCm >= 5.6 not found. Skipping OpenMP target example.") + return() +elseif(hip_FOUND AND hip_VERSION VERSION_LESS 5.6.0) + message( + WARNING + "ROCm >= 5.6 not found (found ${hip_VERSION}). Skipping OpenMP target example." + ) + return() +endif() + +if(NOT OMP_TARGET_COMPILER) + find_program( + amdclangpp_EXECUTABLE + NAMES amdclang++ + HINTS ${ROCM_PATH} ENV ROCM_PATH /opt/rocm + PATHS ${ROCM_PATH} ENV ROCM_PATH /opt/rocm + PATH_SUFFIXES bin llvm/bin) + mark_as_advanced(amdclangpp_EXECUTABLE) + + if(amdclangpp_EXECUTABLE) + set(OMP_TARGET_COMPILER + "${amdclangpp_EXECUTABLE}" + CACHE FILEPATH "OpenMP target compiler") + else() + message(WARNING "OpenMP target compiler not found. Skipping this example.") + return() + endif() +endif() + +project(omnitrace-example-openmp-target-lib LANGUAGES CXX) + +set(CMAKE_BUILD_TYPE "RelWithDebInfo") + +set(DEFAULT_GPU_TARGETS + "gfx900" + "gfx906" + "gfx908" + "gfx90a" + "gfx940" + "gfx941" + "gfx942" + "gfx1030" + "gfx1010" + "gfx1100" + "gfx1101" + "gfx1102") + +set(GPU_TARGETS + "${DEFAULT_GPU_TARGETS}" + CACHE STRING "GPU targets to compile for") + +find_package(Threads REQUIRED) + +add_library(openmp-target-lib SHARED) +target_sources(openmp-target-lib PRIVATE library.cpp) +target_link_libraries(openmp-target-lib PUBLIC Threads::Threads) +target_compile_options(openmp-target-lib PRIVATE -fopenmp -ggdb) +target_link_options(openmp-target-lib PUBLIC -fopenmp) + +foreach(_TARGET ${GPU_TARGETS}) + target_compile_options(openmp-target-lib PRIVATE --offload-arch=${_TARGET}) + target_link_options(openmp-target-lib PUBLIC --offload-arch=${_TARGET}) +endforeach() + +message(STATUS "Using OpenMP target compiler: ${OMP_TARGET_COMPILER}") + +get_filename_component(OMP_TARGET_COMPILER_DIR ${OMP_TARGET_COMPILER} PATH) +get_filename_component(OMP_TARGET_COMPILER_DIR ${OMP_TARGET_COMPILER_DIR} PATH) + +message(STATUS "Using OpemMP target compiler directory: ${OMP_TARGET_COMPILER_DIR}") + +if(NOT EXISTS ${OMP_TARGET_COMPILER_DIR}/llvm/lib) + message(FATAL_ERROR "${OMP_TARGET_COMPILER_DIR}/llvm/lib does not exist") +endif() +set_target_properties( + openmp-target-lib + PROPERTIES BUILD_RPATH + "${OMP_TARGET_COMPILER_DIR}/llvm/lib:${OMP_TARGET_COMPILER_DIR}/lib" + OUTPUT_NAME "openmp-target" + POSITION_INDEPENDENT_CODE ON) + +omnitrace_custom_compilation(TARGET openmp-target-lib COMPILER ${OMP_TARGET_COMPILER}) + +add_executable(openmp-target) +target_sources(openmp-target PRIVATE main.cpp) +target_link_libraries(openmp-target PRIVATE openmp-target-lib) +target_compile_options(openmp-target PRIVATE -ggdb) + +set_target_properties( + openmp-target + PROPERTIES BUILD_RPATH + "${OMP_TARGET_COMPILER_DIR}/llvm/lib:${OMP_TARGET_COMPILER_DIR}/lib" + POSITION_INDEPENDENT_CODE ON) + +omnitrace_custom_compilation(TARGET openmp-target COMPILER ${OMP_TARGET_COMPILER}) diff --git a/examples/openmp/target/library.cpp b/examples/openmp/target/library.cpp new file mode 100644 index 000000000..580721dfc --- /dev/null +++ b/examples/openmp/target/library.cpp @@ -0,0 +1,149 @@ +// MIT License +// +// Copyright (c) 2023 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 +#include +#include +#include +#include +#include +#include +#include +#include + +constexpr float EPS_FLOAT = 1.0e-7f; +constexpr double EPS_DOUBLE = 1.0e-15; + +#pragma omp declare target +template +T +mul(T a, T b) +{ + T c; + c = a * b; + return c; +} +#pragma omp end declare target + +template +void +vmul(T* a, T* b, T* c, int N) +{ +#pragma omp target map(to : a [0:N], b [0:N]) map(from : c [0:N]) +#pragma omp teams distribute parallel for + for(int i = 0; i < N; i++) + { + c[i] = mul(a[i], b[i]); + } +} + +int +run_impl() +{ + std::this_thread::sleep_for(std::chrono::milliseconds{ 50 }); + + constexpr int N = 100000; + constexpr int Nc = N / 100; + int a_i[N], b_i[N], c_i[N], validate_i[N]; + float a_f[N], b_f[N], c_f[N], validate_f[N]; + double a_d[N], b_d[N], c_d[N], validate_d[N]; + int N_errors = 0; + bool flag = false; + +#pragma omp parallel for schedule(dynamic, Nc) + for(int i = 0; i < N; ++i) + { + a_f[i] = a_i[i] = i + 1; + b_f[i] = b_i[i] = i + 2; + a_d[i] = a_i[i]; + b_d[i] = b_i[i]; + validate_i[i] = a_i[i] * b_i[i]; + validate_f[i] = a_f[i] * b_f[i]; + validate_d[i] = a_d[i] * b_d[i]; + } + + for(int i = 0; i < 2; ++i) + { + vmul(a_i, b_i, c_i, N); + vmul(a_f, b_f, c_f, N); + vmul(a_d, b_d, c_d, N); + } + + for(int i = 0; i < N; i++) + { + if(c_i[i] != validate_i[i]) + { + ++N_errors; + // print 1st bad index + if(!flag) + { + printf("First fail: c_i[%d](%d) != validate_i[%d](%d)\n", i, c_i[i], i, + validate_i[i]); + flag = true; + } + } + } + flag = false; + for(int i = 0; i < N; i++) + { + if(fabs(c_f[i] - validate_f[i]) > EPS_FLOAT) + { + ++N_errors; + // print 1st bad index + if(!flag) + { + printf("First fail: c_f[%d](%f) != validate_f[%d](%f)\n", i, + static_cast(c_f[i]), i, + static_cast(validate_f[i])); + flag = true; + } + } + } + flag = false; + for(int i = 0; i < N; i++) + { + if(fabs(c_d[i] - validate_d[i]) > EPS_DOUBLE) + { + ++N_errors; + // print 1st bad index + if(!flag) + { + printf("First fail: c_d[%d](%f) != validate_d[%d](%f)\n", i, c_d[i], i, + validate_d[i]); + flag = true; + } + } + } + + return N_errors; +} + +int +run() +{ +#pragma omp parallel + { + run_impl(); + } + + return 0; +} diff --git a/examples/openmp/target/main.cpp b/examples/openmp/target/main.cpp new file mode 100644 index 000000000..081c03b9b --- /dev/null +++ b/examples/openmp/target/main.cpp @@ -0,0 +1,52 @@ +// MIT License +// +// Copyright (c) 2023 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 +#include +#include +#include +#include +#include +#include +#include + +extern int +run(); + +int +main() +{ + auto N_errors = run(); + auto _ec = EXIT_SUCCESS; + if(N_errors == 0) + { + printf("Success\n"); + } + else + { + printf("Total %d failures\n", N_errors); + printf("Fail\n"); + _ec = EXIT_FAILURE; + } + + return _ec; +} diff --git a/examples/parallel-overhead/CMakeLists.txt b/examples/parallel-overhead/CMakeLists.txt index 1458e138a..1f127f5b8 100644 --- a/examples/parallel-overhead/CMakeLists.txt +++ b/examples/parallel-overhead/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16 FATAL_ERROR) +cmake_minimum_required(VERSION 3.18.4 FATAL_ERROR) project(omnitrace-parallel-overhead-example LANGUAGES CXX) diff --git a/examples/python/CMakeLists.txt b/examples/python/CMakeLists.txt index 9f810ed3c..dfeb5fe0d 100644 --- a/examples/python/CMakeLists.txt +++ b/examples/python/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16 FATAL_ERROR) +cmake_minimum_required(VERSION 3.18.4 FATAL_ERROR) project(omnitrace-python) diff --git a/examples/rccl/CMakeLists.txt b/examples/rccl/CMakeLists.txt index 4b0d860d7..afebbdc89 100644 --- a/examples/rccl/CMakeLists.txt +++ b/examples/rccl/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16 FATAL_ERROR) +cmake_minimum_required(VERSION 3.18.4 FATAL_ERROR) project(omnitrace-rccl-example LANGUAGES CXX) diff --git a/examples/rewrite-caller/CMakeLists.txt b/examples/rewrite-caller/CMakeLists.txt index 75f60d922..26e384d8c 100644 --- a/examples/rewrite-caller/CMakeLists.txt +++ b/examples/rewrite-caller/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.18.4 FATAL_ERROR) project(omnitrace-rewrite-caller-example LANGUAGES CXX) diff --git a/examples/trace-time-window/CMakeLists.txt b/examples/trace-time-window/CMakeLists.txt index fe68dc16f..fd72f9820 100644 --- a/examples/trace-time-window/CMakeLists.txt +++ b/examples/trace-time-window/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.18.4 FATAL_ERROR) project(omnitrace-trace-time-window-example LANGUAGES CXX) diff --git a/examples/transpose/CMakeLists.txt b/examples/transpose/CMakeLists.txt index 25792c923..872991600 100644 --- a/examples/transpose/CMakeLists.txt +++ b/examples/transpose/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16 FATAL_ERROR) +cmake_minimum_required(VERSION 3.18.4 FATAL_ERROR) project(omnitrace-transpose-example LANGUAGES CXX) diff --git a/examples/user-api/CMakeLists.txt b/examples/user-api/CMakeLists.txt index 754e08eb0..bfad50aec 100644 --- a/examples/user-api/CMakeLists.txt +++ b/examples/user-api/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16 FATAL_ERROR) +cmake_minimum_required(VERSION 3.18.4 FATAL_ERROR) project(omnitrace-user-api-example LANGUAGES CXX) diff --git a/external/timemory b/external/timemory index 9ce43f329..68ce42008 160000 --- a/external/timemory +++ b/external/timemory @@ -1 +1 @@ -Subproject commit 9ce43f32939dd71aa8905f5c72537e9a3ffcc7c2 +Subproject commit 68ce420086bfd73cbf0986c5ad10d811c8934f78 diff --git a/scripts/run-ci.sh b/scripts/run-ci.sh index f66fa6669..f4d596953 100755 --- a/scripts/run-ci.sh +++ b/scripts/run-ci.sh @@ -207,7 +207,7 @@ EOF verbose-run cd ${BINARY_DIR} cat << EOF > dashboard.cmake -cmake_minimum_required(VERSION 3.16 FATAL_ERROR) +cmake_minimum_required(VERSION 3.18.4 FATAL_ERROR) include("\${CMAKE_CURRENT_LIST_DIR}/CTestCustom.cmake") diff --git a/scripts/test-find-package.sh b/scripts/test-find-package.sh index f397d7705..6a056e581 100755 --- a/scripts/test-find-package.sh +++ b/scripts/test-find-package.sh @@ -112,7 +112,7 @@ verbose-run cp -v -r ${EXAMPLE_DIR}/${EXAMPLE_NAME}/* ${SOURCE_DIR}/ verbose-run pushd ${SOURCE_DIR} cat << EOF > CMakeLists.txt -cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.18.4 FATAL_ERROR) project(test LANGUAGES C CXX) diff --git a/scripts/write-omnitrace-install.cmake b/scripts/write-omnitrace-install.cmake index d823c5700..00cbcf2df 100644 --- a/scripts/write-omnitrace-install.cmake +++ b/scripts/write-omnitrace-install.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.8) +cmake_minimum_required(VERSION 3.18.4) if(NOT DEFINED OMNITRACE_VERSION) file(READ "${CMAKE_CURRENT_LIST_DIR}/../VERSION" FULL_VERSION_STRING LIMIT_COUNT 1) diff --git a/source/lib/core/config.cpp b/source/lib/core/config.cpp index d7bb5d959..1d89a21d2 100644 --- a/source/lib/core/config.cpp +++ b/source/lib/core/config.cpp @@ -2440,18 +2440,38 @@ tmp_file::~tmp_file() remove(); } -bool -tmp_file::open(std::ios::openmode _mode) +void +tmp_file::touch() const { - OMNITRACE_BASIC_VERBOSE(2, "Opening temporary file '%s'...\n", filename.c_str()); - if(!filepath::exists(filename)) { // if the filepath does not exist, open in out mode to create it - std::ofstream _ofs{}; + auto _ofs = std::ofstream{}; filepath::open(_ofs, filename); } +} + +bool +tmp_file::open(int _mode, int _perms) +{ + OMNITRACE_BASIC_VERBOSE(2, "Opening temporary file '%s'...\n", filename.c_str()); + + touch(); + m_pid = getpid(); + fd = ::open(filename.c_str(), _mode, _perms); + + return (fd > 0); +} + +bool +tmp_file::open(std::ios::openmode _mode) +{ + OMNITRACE_BASIC_VERBOSE(2, "Opening temporary file '%s'...\n", filename.c_str()); + + touch(); + + m_pid = getpid(); stream.open(filename, _mode); return (stream.is_open() && stream.good()); @@ -2462,14 +2482,10 @@ tmp_file::fopen(const char* _mode) { OMNITRACE_BASIC_VERBOSE(2, "Opening temporary file '%s'...\n", filename.c_str()); - if(!filepath::exists(filename)) - { - // if the filepath does not exist, open in out mode to create it - std::ofstream _ofs{}; - filepath::open(_ofs, filename); - } + touch(); - file = filepath::fopen(filename, _mode); + m_pid = getpid(); + file = filepath::fopen(filename, _mode); if(file) fd = ::fileno(file); return (file != nullptr && fd > 0); @@ -2478,6 +2494,8 @@ tmp_file::fopen(const char* _mode) bool tmp_file::flush() { + if(m_pid != getpid()) return false; + if(stream.is_open()) { stream.flush(); @@ -2494,6 +2512,18 @@ tmp_file::flush() } return (_ret == 0); } + else if(fd > 0) + { + int _ret = ::fsync(fd); + int _cnt = 0; + while(_ret == EAGAIN || _ret == EINTR) + { + std::this_thread::sleep_for(std::chrono::milliseconds{ 100 }); + _ret = ::fsync(fd); + if(++_cnt > 10) break; + } + return (_ret == 0); + } return true; } @@ -2503,6 +2533,8 @@ tmp_file::close() { flush(); + if(m_pid != getpid()) return false; + if(stream.is_open()) { stream.close(); @@ -2518,6 +2550,15 @@ tmp_file::close() } return (_ret == 0); } + else if(fd > 0) + { + auto _ret = ::close(fd); + if(_ret == 0) + { + fd = -1; + } + return (_ret == 0); + } return true; } @@ -2525,6 +2566,8 @@ tmp_file::close() bool tmp_file::remove() { + if(m_pid != getpid()) return false; + close(); if(filepath::exists(filename)) { @@ -2538,7 +2581,9 @@ tmp_file::remove() tmp_file::operator bool() const { - return (stream.is_open() && stream.good()) || (file != nullptr && fd > 0); + return (m_pid == getpid()) && + ((stream.is_open() && stream.good()) || (file != nullptr && fd > 0) || + (file == nullptr && fd > 0)); } std::shared_ptr diff --git a/source/lib/core/config.hpp b/source/lib/core/config.hpp index dac62fc3f..1d4b1a17b 100644 --- a/source/lib/core/config.hpp +++ b/source/lib/core/config.hpp @@ -374,6 +374,7 @@ struct tmp_file tmp_file(std::string); ~tmp_file(); + bool open(int, int); bool open(std::ios::openmode = std::ios::binary | std::ios::in | std::ios::out); bool fopen(const char* = "r+"); bool flush(); @@ -386,6 +387,12 @@ struct tmp_file std::fstream stream = {}; FILE* file = nullptr; int fd = -1; + +private: + void touch() const; + +private: + pid_t m_pid = getpid(); }; std::shared_ptr diff --git a/source/lib/core/perfetto.cpp b/source/lib/core/perfetto.cpp index a4725aea8..eacb6ef09 100644 --- a/source/lib/core/perfetto.cpp +++ b/source/lib/core/perfetto.cpp @@ -22,10 +22,13 @@ #include "perfetto.hpp" #include "config.hpp" +#include "debug.hpp" #include "library/runtime.hpp" #include "perfetto_fwd.hpp" #include "utility.hpp" +#include + namespace omnitrace { namespace perfetto @@ -120,18 +123,18 @@ start() if(!_tmp_file) { _tmp_file = config::get_tmp_file("perfetto-trace", "proto"); - _tmp_file->fopen("w+"); - } - else - { - OMNITRACE_VERBOSE(2, "Resuming perfetto...\n"); - _tmp_file->fopen("a+"); + _tmp_file->open(O_RDWR | O_CREAT | O_TRUNC, 0600); } } OMNITRACE_VERBOSE(2, "Setup perfetto...\n"); int _fd = (_tmp_file) ? _tmp_file->fd : -1; auto& cfg = get_config(); + tracing_session->SetOnErrorCallback([](::perfetto::TracingError _err) { + if(_err.code == ::perfetto::TracingError::kTracingFailed) + OMNITRACE_WARNING(0, "perfetto encountered a tracing error: %s\n", + _err.message.c_str()); + }); tracing_session->Setup(cfg, _fd); tracing_session->StartBlocking(); } @@ -173,8 +176,8 @@ post_process(tim::manager* _timemory_manager, bool& _perfetto_output_error) if(_tmp_file && *_tmp_file) { _tmp_file->close(); - FILE* _fdata = fopen(_tmp_file->filename.c_str(), "rb"); + FILE* _fdata = ::fopen(_tmp_file->filename.c_str(), "rb"); if(!_fdata) { OMNITRACE_VERBOSE( @@ -183,22 +186,25 @@ post_process(tim::manager* _timemory_manager, bool& _perfetto_output_error) return char_vec_t{ tracing_session->ReadTraceBlocking() }; } - fseek(_fdata, 0, SEEK_END); - size_t _fnum_elem = ftell(_fdata); - fseek(_fdata, 0, SEEK_SET); // same as rewind(f); + ::fseek(_fdata, 0, SEEK_END); + size_t _fnum_elem = ::ftell(_fdata); + ::fseek(_fdata, 0, SEEK_SET); // same as rewind(f); - _data.resize(_fnum_elem + 1); - auto _fnum_read = fread(_data.data(), sizeof(char), _fnum_elem, _fdata); - fclose(_fdata); + _data.resize(_fnum_elem, '\0'); + auto _fnum_read = ::fread(_data.data(), sizeof(char), _fnum_elem, _fdata); + ::fclose(_fdata); OMNITRACE_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); } + else + { + _data = char_vec_t{ tracing_session->ReadTraceBlocking() }; + } - return utility::combine(_data, - char_vec_t{ tracing_session->ReadTraceBlocking() }); + return _data; }; auto trace_data = char_vec_t{}; @@ -250,7 +256,7 @@ post_process(tim::manager* _timemory_manager, bool& _perfetto_output_error) else { // Write the trace into a file. - ofs.write(&trace_data[0], trace_data.size()); + ofs.write(trace_data.data(), trace_data.size()); if(config::get_verbose() >= 0) _fom.append("%s", "Done"); // NOLINT if(_timemory_manager) _timemory_manager->add_file_output("protobuf", "perfetto", _filename); diff --git a/source/lib/omnitrace/library/ompt.cpp b/source/lib/omnitrace/library/ompt.cpp index 843c5bf83..eedc4b57f 100644 --- a/source/lib/omnitrace/library/ompt.cpp +++ b/source/lib/omnitrace/library/ompt.cpp @@ -30,27 +30,171 @@ #if defined(OMNITRACE_USE_OMPT) && OMNITRACE_USE_OMPT > 0 +# include "binary/link_map.hpp" # include "core/components/fwd.hpp" # include "library/components/category_region.hpp" +# include "library/tracing.hpp" # include +# include +# include +# include # include +# include # include # include +# include +# include +# include +# include +# include +# include # include +# include +# include -using api_t = TIMEMORY_API; -using ompt_handle_t = tim::component::ompt_handle; -using ompt_context_t = tim::openmp::context_handler; -using ompt_toolset_t = typename ompt_handle_t::toolset_type; -using ompt_bundle_t = tim::component_tuple; +using api_t = tim::project::omnitrace; -extern "C" +namespace omnitrace { - ompt_start_tool_result_t* ompt_start_tool(unsigned int, - const char*) OMNITRACE_PUBLIC_API; -} +namespace component +{ +struct ompt : comp::base +{ + using value_type = void; + using base_type = comp::base; + using context_info_t = tim::openmp::context_info; + + static std::string label() { return "ompt"; } + static std::string description() { return "OpenMP tools tracing"; } + + ompt() = default; + ~ompt() = default; + ompt(const ompt&) = default; + ompt(ompt&&) noexcept = default; + + ompt& operator=(const ompt&) = default; + ompt& operator=(ompt&&) noexcept = default; + + template + void start(const context_info_t& _ctx_info, Args&&...) const + { + category_region::start(m_prefix); + + auto _ts = tracing::now(); + uint64_t _cid = + (_ctx_info.target_arguments) ? _ctx_info.target_arguments->host_op_id : 0; + auto _annotate = [&](::perfetto::EventContext ctx) { + if(config::get_perfetto_annotations()) + { + tracing::add_perfetto_annotation(ctx, "begin_ns", _ts); + for(const auto& itr : _ctx_info.arguments) + tracing::add_perfetto_annotation(ctx, itr.label, itr.value); + } + }; + + if(_cid > 0) + { + category_region::start( + (_ctx_info.func.empty()) ? m_prefix : _ctx_info.func, _ts, + ::perfetto::Flow::ProcessScoped(_cid), std::move(_annotate)); + } + else + { + category_region::start( + (_ctx_info.func.empty()) ? m_prefix : _ctx_info.func, _ts, + std::move(_annotate)); + } + } + + template + void stop(const context_info_t& _ctx_info, Args&&...) const + { + category_region::stop(m_prefix); + + auto _ts = tracing::now(); + uint64_t _cid = + (_ctx_info.target_arguments) ? _ctx_info.target_arguments->host_op_id : 0; + auto _annotate = [&](::perfetto::EventContext ctx) { + if(config::get_perfetto_annotations()) + { + tracing::add_perfetto_annotation(ctx, "end_ns", _ts); + for(const auto& itr : _ctx_info.arguments) + tracing::add_perfetto_annotation(ctx, itr.label, itr.value); + } + }; + + if(_cid > 0) + { + category_region::stop( + (_ctx_info.func.empty()) ? m_prefix : _ctx_info.func, _ts, + std::move(_annotate)); + } + else + { + category_region::stop( + (_ctx_info.func.empty()) ? m_prefix : _ctx_info.func, _ts, + std::move(_annotate)); + } + } + + template + void store(const context_info_t& _ctx_info, Args&&... _args) const + { + start(_ctx_info, std::forward(_args)...); + stop(_ctx_info, std::forward(_args)...); + } + + static void record(std::string_view name, ompt_id_t id, uint64_t beg_time, + uint64_t end_time, uint64_t thrd_id, uint64_t targ_id, + const context_info_t& common) + { + (void) thrd_id; + (void) targ_id; + + auto _annotate = [&](::perfetto::EventContext ctx) { + if(config::get_perfetto_annotations()) + { + for(const auto& itr : common.arguments) + tracing::add_perfetto_annotation(ctx, itr.label, itr.value); + } + }; + + auto _track = tracing::get_perfetto_track( + category::ompt{}, + [](uint64_t _targ_id_v) { + return ::timemory::join::join("", "OMP Target ", _targ_id_v); + }, + targ_id); + + category_region::start( + name, _track, beg_time, ::perfetto::Flow::ProcessScoped(id), + std::move(_annotate)); + + category_region::stop(name, _track, + end_time); + } + + void set_prefix(std::string_view _v) { m_prefix = _v; } + +private: + std::string_view m_prefix = {}; +}; +} // namespace component +} // namespace omnitrace + +namespace tim +{ +namespace trait +{ +template <> +struct ompt_handle +{ + using type = component_tuple<::omnitrace::component::ompt>; +}; +} // namespace trait +} // namespace tim namespace omnitrace { @@ -58,6 +202,11 @@ namespace ompt { namespace { +using ompt_handle_t = tim::component::ompt_handle; +using ompt_context_t = tim::openmp::context_handler; +using ompt_toolset_t = typename ompt_handle_t::toolset_type; +using ompt_bundle_t = tim::component_tuple; + std::unique_ptr f_bundle = {}; bool _init_toolset_off = (trait::runtime_enabled::set(false), trait::runtime_enabled::set(false), true); @@ -70,10 +219,7 @@ setup() if(!tim::settings::enabled()) return; trait::runtime_enabled::set(true); trait::runtime_enabled::set(true); - comp::user_ompt_bundle::global_init(); - 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", quirk::config{}); } @@ -91,10 +237,15 @@ shutdown() ompt_context_t::cleanup(); trait::runtime_enabled::set(false); trait::runtime_enabled::set(false); - comp::user_ompt_bundle::reset(); pthread_gotcha::shutdown(); // call the OMPT finalize callback - if(f_finalize) (*f_finalize)(); + if(f_finalize) + { + for(const auto& itr : tim::openmp::get_ompt_device_functions()) + if(itr.second.stop_trace) itr.second.stop_trace(itr.second.device); + (*f_finalize)(); + f_finalize = nullptr; + } } f_bundle.reset(); _protect = false; @@ -115,21 +266,231 @@ tool_initialize(ompt_function_lookup_t lookup, int initial_device_num, { if(!omnitrace::settings_are_configured()) { - OMNITRACE_BASIC_WARNING( + OMNITRACE_BASIC_WARNING_F( 0, "[%s] invoked before omnitrace was initialized. In instrumentation mode, " "settings exported to the environment have not been propagated yet...\n", __FUNCTION__); - omnitrace::configure_settings(); + use_tool() = get_env("OMNITRACE_USE_OMPT", true, false); + } + else + { + use_tool() = omnitrace::config::get_use_ompt(); } - use_tool() = omnitrace::config::get_use_ompt(); if(use_tool()) { - TIMEMORY_PRINTF(stderr, "OpenMP-tools configuring for initial device %i\n\n", - initial_device_num); - f_finalize = tim::ompt::configure( - lookup, initial_device_num, tool_data); + OMNITRACE_BASIC_VERBOSE_F(2, "OpenMP-tools configuring for initial device %i\n\n", + initial_device_num); + + static auto _generate_key = [](std::string_view _key_v, + const ::tim::openmp::argument_array_t& _args_v) { + return std::string{ _key_v }; + (void) _args_v; + }; + + tim::openmp::get_codeptr_ra_resolver() = + [](tim::openmp::context_info& _ctx_info) { + const auto& _key = _ctx_info.label; + const auto* codeptr_ra = _ctx_info.codeptr_ra; + auto& _args = _ctx_info.arguments; + + OMNITRACE_BASIC_VERBOSE(2, "resolving codeptr return address for %s\n", + _key.data()); + + if(!codeptr_ra) return _generate_key(_key, _args); + + static thread_local auto _once = std::once_flag{}; + std::call_once(_once, []() { ::tim::unwind::update_file_maps(); }); + + auto _info = ::omnitrace::binary::lookup_ipaddr_entry( + reinterpret_cast(codeptr_ra)); + + if(_info) + { + _ctx_info.func = tim::demangle(_info->name); + if(_info->lineno > 0) + { + auto _linfo = _info->lineinfo.rget([](const auto& _v) -> bool { + return (_v && !_v.location.empty() && _v.line > 0); + }); + + if(_linfo) + { + _ctx_info.file = _linfo.location; + _ctx_info.line = _linfo.line; + _args.emplace_back("file", _ctx_info.file); + _args.emplace_back("lineinfo", + ::timemory::join::join("@", _ctx_info.file, + _ctx_info.line)); + } + else + { + _ctx_info.file = _info->location; + _args.emplace_back("file", _ctx_info.file); + } + + return _generate_key( + ::timemory::join::join(" @ ", _key, _ctx_info.func), _args); + } + else + { + return _generate_key( + ::timemory::join::join(" @ ", _key, _ctx_info.func), _args); + } + } + else + { + auto _dl_info = Dl_info{ nullptr, nullptr, nullptr, nullptr }; + if(dladdr(codeptr_ra, &_dl_info) != 0) + { + _ctx_info.file = _dl_info.dli_fname; + _ctx_info.func = tim::demangle(_dl_info.dli_sname); + _args.emplace_back("file", _ctx_info.file); + return _generate_key( + ::timemory::join::join( + " @ ", _key, + ::timemory::join::join("", _ctx_info.func, " [", + _ctx_info.file, "]")), + _args); + } + } + + // since no line info could be deduced, include the codeptr return address + auto _args_codeptr_v = _args; + _args_codeptr_v.emplace_back("codeptr_ra", codeptr_ra); + return _generate_key(_key, _args_codeptr_v); + }; + + tim::openmp::get_function_lookup_callback< + api_t>() = [](ompt_function_lookup_t, + const std::optional& + params) { + if(!params) return; + + OMNITRACE_VERBOSE(3, "[ompt] configuring device %i...\n", params->device_num); + + auto& device_funcs = + tim::openmp::get_ompt_device_functions().at(params->device_num); + + device_funcs.set_trace_ompt(params->device, 1, ompt_callback_target_data_op); + device_funcs.set_trace_ompt(params->device, 1, ompt_callback_target_submit); + + static ompt_callback_buffer_request_t request = + [](int device_num, ompt_buffer_t** buffer, size_t* bytes) { + OMNITRACE_VERBOSE(3, "[ompt] buffer request...\n"); + *bytes = ::tim::units::get_page_size(); + *buffer = mmap(nullptr, *bytes, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + (void) device_num; + }; + + static ompt_callback_buffer_complete_t complete = [](int device_num, + ompt_buffer_t* buffer, + size_t bytes, + ompt_buffer_cursor_t + begin, + int buffer_owned) { + OMNITRACE_VERBOSE(3, "[ompt] buffer complete...\n"); + tim::consume_parameters(device_num, buffer, bytes, begin, buffer_owned); + + auto _funcs = + tim::openmp::get_ompt_device_functions().at(device_num); + auto _skew = omnitrace::tracing::get_clock_skew( + [&_funcs]() { return _funcs.get_device_time(_funcs.device); }); + + ompt_buffer_cursor_t _cursor = begin; + size_t _nrecords = 0; + do + { + if(_cursor == 0) break; + ++_nrecords; + auto* _record = _funcs.get_record_ompt(buffer, _cursor); + if(_record) + { + const char* _type = tim::openmp::get_enum_label(_record->type); + auto _thrd_id = _record->thread_id; + auto _targ_id = _record->target_id; + + unsigned long beg_time = _record->time + _skew; + unsigned long end_time = 0; + ompt_id_t id = 0; + const char* _name = tim::openmp::get_enum_label(_record->type); + + if(_record->type == ompt_callback_target_submit) + { + auto& _data = _record->record.target_kernel; + end_time = _data.end_time + _skew; + id = _data.host_op_id; + + auto _ctx_info = tim::openmp::argument_array_t{ + { "begin_ns", beg_time }, + { "end_ns", end_time }, + { "type", _type }, + { "thread_id", _thrd_id }, + { "target_id", _targ_id }, + { "host_op_id", id }, + { "requested_num_teams", _data.requested_num_teams }, + { "granted_num_teams", _data.granted_num_teams } + }; + + component::ompt::record( + _name, id, beg_time, end_time, _thrd_id, _targ_id, + tim::openmp::context_info{ _name, nullptr, _ctx_info }); + } + else if(_record->type == ompt_callback_target_data_op) + { + auto& _data = _record->record.target_data_op; + end_time = _data.end_time + _skew; + id = _data.host_op_id; + const auto* _opname = + tim::openmp::get_enum_label(_data.optype); + + auto _ctx_info = tim::openmp::argument_array_t{ + { "begin_ns", beg_time }, + { "end_ns", end_time }, + { "type", _type }, + { "thread_id", _thrd_id }, + { "target_id", _targ_id }, + { "host_op_id", id }, + { "optype", _opname }, + { "src_addr", reinterpret_cast(_data.src_addr) }, + { "dst_addr", reinterpret_cast(_data.dest_addr) }, + { "src_device_num", _data.src_device_num }, + { "dst_device_num", _data.dest_device_num }, + { "bytes", _data.bytes }, + }; + + component::ompt::record( + _opname, id, beg_time, end_time, _thrd_id, _targ_id, + tim::openmp::context_info{ _name, nullptr, _ctx_info }); + } + + OMNITRACE_VERBOSE( + 3, + "type=%i, type_name=%s, start=%lu, end=%lu, delta=%lu, " + "tid=%lu, target_id=%lu, host_id=%lu\n", + _record->type, tim::openmp::get_enum_label(_record->type), + beg_time, end_time, (end_time - beg_time), _record->thread_id, + _record->target_id, id); + } + + _funcs.advance_buffer_cursor(_funcs.device, buffer, bytes, _cursor, + &_cursor); + } while(_cursor != 0); + + OMNITRACE_VERBOSE(3, "[ompt] number of records: %zu\n", _nrecords); + + if(buffer_owned == 1) + { + ::munmap(buffer, bytes); + } + }; + + device_funcs.start_trace(params->device, request, complete); + }; + + f_finalize = tim::ompt::configure(lookup, initial_device_num, tool_data); } return 1; // success } @@ -143,20 +504,25 @@ tool_finalize(ompt_data_t*) } // namespace ompt } // namespace omnitrace -extern "C" ompt_start_tool_result_t* -ompt_start_tool(unsigned int omp_version, const char* runtime_version) +extern "C" { - 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); + ompt_start_tool_result_t* ompt_start_tool(unsigned int, + const char*) OMNITRACE_PUBLIC_API; - static auto* data = new ompt_start_tool_result_t{ &omnitrace::ompt::tool_initialize, - &omnitrace::ompt::tool_finalize, - { 0 } }; - return data; -} + 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); + static auto* data = new ompt_start_tool_result_t{ + &omnitrace::ompt::tool_initialize, &omnitrace::ompt::tool_finalize, { 0 } + }; + return data; + } +} #else namespace omnitrace { diff --git a/source/lib/omnitrace/library/roctracer.cpp b/source/lib/omnitrace/library/roctracer.cpp index 224f59728..c383e16e0 100644 --- a/source/lib/omnitrace/library/roctracer.cpp +++ b/source/lib/omnitrace/library/roctracer.cpp @@ -163,55 +163,18 @@ get_clock_skew() static auto _use = tim::get_env("OMNITRACE_USE_ROCTRACER_CLOCK_SKEW", true); if(!_use) return 0; static auto _v = []() { - namespace cpu = tim::cpu; - // synchronize timestamps - // We'll take a CPU timestamp before and after taking a GPU timestmp, then - // take the average of those two, hoping that it's roughly at the same time - // as the GPU timestamp. - static auto _cpu_now = []() { - cpu::fence(); - return comp::wall_clock::record(); - }; - - static auto _gpu_now = []() { - cpu::fence(); + auto _gpu_now = []() { uint64_t _ts = 0; - OMNITRACE_ROCTRACER_CALL(roctracer_get_timestamp(&_ts)); + roctracer_get_timestamp(&_ts); return _ts; }; - do - { - // warm up cache and allow for any static initialization - (void) _cpu_now(); - (void) _gpu_now(); - } while(false); - - auto _compute = [](volatile uint64_t& _cpu_ts, volatile uint64_t& _gpu_ts) { - _cpu_ts = 0; - _gpu_ts = 0; - _cpu_ts += _cpu_now() / 2; - _gpu_ts += _gpu_now() / 1; - _cpu_ts += _cpu_now() / 2; - return static_cast(_cpu_ts) - static_cast(_gpu_ts); - }; - constexpr int64_t _n = 10; - int64_t _cpu_ave = 0; - int64_t _gpu_ave = 0; - int64_t _diff = 0; - for(int64_t i = 0; i < _n; ++i) - { - volatile uint64_t _cpu_ts = 0; - volatile uint64_t _gpu_ts = 0; - _diff += _compute(_cpu_ts, _gpu_ts); - _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); + // discard (warm-up) + (void) tracing::get_clock_skew(_gpu_now, 1); + + auto _diff = tracing::get_clock_skew(_gpu_now, 10); OMNITRACE_BASIC_VERBOSE(1, "CPU/HIP timestamp skew: %li (used: %s)\n", _diff, _use ? "yes" : "no"); - _diff /= _n; return _diff; }(); return _v; diff --git a/source/lib/omnitrace/library/runtime.cpp b/source/lib/omnitrace/library/runtime.cpp index 66cb12eb3..508eaad19 100644 --- a/source/lib/omnitrace/library/runtime.cpp +++ b/source/lib/omnitrace/library/runtime.cpp @@ -62,11 +62,11 @@ auto& get_sampling_on_child_threads_history(int64_t _idx = utility::get_thread_index()) { static auto _v = utility::get_filled_array( - []() { return utility::get_reserved_vector(32); }); + []() { return utility::get_reserved_vector(64); }); if(_idx >= OMNITRACE_MAX_THREADS) { - static thread_local auto _tl_v = utility::get_reserved_vector(32); + static thread_local auto _tl_v = utility::get_reserved_vector(128); return _tl_v; } diff --git a/source/lib/omnitrace/library/tracing.hpp b/source/lib/omnitrace/library/tracing.hpp index 3fa6e0289..a50b5435c 100644 --- a/source/lib/omnitrace/library/tracing.hpp +++ b/source/lib/omnitrace/library/tracing.hpp @@ -651,5 +651,41 @@ mark_perfetto_track(CategoryT, const char* name, ::perfetto::Track _track, uint6 TRACE_EVENT_INSTANT(trait::name::value, ::perfetto::DynamicString{ name }, _track, _ts, std::forward(args)...); } + +template +int64_t +get_clock_skew(FuncT&& _timestamp_func, int64_t _n = 1) +{ + namespace cpu = tim::cpu; + // synchronize timestamps + // We'll take a CPU timestamp before and after taking a GPU timestmp, then + // take the average of those two, hoping that it's roughly at the same time + // as the GPU timestamp. + auto _cpu_now = []() { + cpu::fence(); + return now(); + }; + + auto _gpu_now = [&_timestamp_func]() { + cpu::fence(); + return std::forward(_timestamp_func)(); + }; + + auto _compute = [&_cpu_now, &_gpu_now]() { + volatile uint64_t _cpu_ts = 0; + volatile uint64_t _gpu_ts = 0; + _cpu_ts += _cpu_now(); + _gpu_ts += _gpu_now(); + _cpu_ts += _cpu_now(); + return static_cast(_cpu_ts / 2) - static_cast(_gpu_ts); + }; + + int64_t _diff = 0; + for(int64_t i = 0; i < _n; ++i) + { + _diff += _compute(); + } + return (_diff / _n); +} } // namespace tracing } // namespace omnitrace diff --git a/tests/omnitrace-openmp-tests.cmake b/tests/omnitrace-openmp-tests.cmake index f0293fbf1..021f3bd61 100644 --- a/tests/omnitrace-openmp-tests.cmake +++ b/tests/omnitrace-openmp-tests.cmake @@ -37,6 +37,16 @@ omnitrace_add_test( REWRITE_RUN_PASS_REGEX "${_OMPT_PASS_REGEX}" REWRITE_FAIL_REGEX "0 instrumented loops in procedure") +omnitrace_add_test( + SKIP_RUNTIME SKIP_REWRITE + NAME openmp-target + TARGET openmp-target + GPU ON + LABELS "openmp;openmp-target" + ENVIRONMENT + "${_ompt_environment};OMNITRACE_ROCTRACER_HSA_ACTIVITY=OFF;OMNITRACE_ROCTRACER_HSA_API=OFF" + ) + set(_ompt_sampling_environ "${_ompt_environment}" "OMNITRACE_VERBOSE=2"