Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding perfetto-validation-script #66

Merged
merged 17 commits into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .cmake-format.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ parse:
PASS_REGEX: '*'
FAIL_REGEX: '*'
SKIP_REGEX: '*'
omnitrace_add_python_validation_test:
kwargs:
NAME: '*'
ARGS: '*'
PERFETTO_FILE: '*'
TIMEMORY_FILE: '*'
TIMEMORY_METRIC: '*'
rocm_version_message:
flags:
- STATUS
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,27 @@ on:
branches: [ main, develop ]

jobs:
python-formatting:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.8]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: black format
run: |
black --diff --check .

cmake-format:
runs-on: ubuntu-20.04

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/opensuse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Install Packages
timeout-minutes: 5
run:
for i in 6 7 8 9 10; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy; done
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
run:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ubuntu-bionic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ jobs:
apt-get install -y build-essential m4 autoconf libtool python3-pip ${{ matrix.compiler }} ${{ matrix.mpi }} &&
python3 -m pip install --upgrade pip &&
python3 -m pip install numpy &&
python3 -m pip install perfetto &&
python3 -m pip install 'cmake==3.16.3' &&
for i in 6 7 8 9; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy; done
for i in 6 7 8 9; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy perfetto dataclasses; done

- name: Install Kokkos
timeout-minutes: 5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu-focal-external-rocm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
apt-get install -y build-essential m4 autoconf libtool python3-pip clang libomp-dev ${{ matrix.compiler }} libudev-dev libnuma-dev rocm-dev rocm-utils roctracer-dev rocprofiler-dev hip-base hsa-amd-aqlprofile hsa-rocr-dev hsakmt-roct-dev libpapi-dev libopenmpi-dev curl &&
python3 -m pip install --upgrade pip &&
python3 -m pip install 'cmake==3.16.3' &&
for i in 6 7 8 9; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy; done
for i in 6 7 8 9; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy perfetto dataclasses; done

- name: Configure Env
run:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ubuntu-focal-external.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ jobs:
apt-get install -y build-essential m4 autoconf libtool python3-pip libiberty-dev clang libomp-dev ${{ matrix.compiler }} &&
python3 -m pip install --upgrade pip &&
python3 -m pip install numpy &&
python3 -m pip install perfetto &&
python3 -m pip install 'cmake==3.16.3' &&
for i in 6 7 8 9; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy; done
for i in 6 7 8 9; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy perfetto dataclasses; done

- name: Configure Env
run:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ubuntu-focal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
sudo apt-get install -y build-essential m4 autoconf libtool python3-pip libtbb-dev libboost-{atomic,system,thread,date-time,filesystem,timer}-dev clang libomp-dev ${{ matrix.compiler }} ${{ matrix.mpi }} &&
python3 -m pip install --upgrade pip &&
python3 -m pip install numpy &&
python3 -m pip install perfetto &&
python3 -m pip install 'cmake==3.16.3'

- name: Configure Env
Expand Down
8 changes: 2 additions & 6 deletions examples/python/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,8 @@ def run(n):
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("-n", "--num-iterations", help="Number", type=int, default=3)
parser.add_argument("-v", "--value", help="Starting value", type=int, default=20)
args = parser.parse_args()

_prefix = os.path.basename(__file__)
Expand Down
8 changes: 2 additions & 6 deletions examples/python/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,8 @@ def run(n):
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("-n", "--num-iterations", help="Number", type=int, default=3)
parser.add_argument("-v", "--value", help="Starting value", type=int, default=20)
args = parser.parse_args()

_prefix = os.path.basename(__file__)
Expand Down
8 changes: 2 additions & 6 deletions examples/python/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,8 @@ def run(n):
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("-n", "--num-iterations", help="Number", type=int, default=3)
parser.add_argument("-v", "--value", help="Starting value", type=int, default=20)
args = parser.parse_args()

_prefix = os.path.basename(__file__)
Expand Down
31 changes: 31 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[build-system]
requires = [
"setuptools >= 40.0.4",
"setuptools_scm >= 2.0.0",
"wheel >= 0.29.0",
]
build-backend = 'setuptools.build_meta'

[tool.black]
line-length = 90
target-version = ['py38']
include = '\.py'
exclude = '''
(
/(
\.eggs
| \.git
| \.github
| \.tox
| \.venv
| \.misc
| \.vscode
| dist
| external
| .pytest_cache
| build
| build-release
| build-omnitrace
)/
)
'''
26 changes: 13 additions & 13 deletions source/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,26 +110,26 @@ def install(package):
html_static_path = ["_static"]

html_theme_options = {
'analytics_id': 'G-1HLBBRSTT9', # Provided by Google in your dashboard
'analytics_anonymize_ip': False,
'logo_only': False,
'display_version': True,
'prev_next_buttons_location': 'bottom',
'style_external_links': False,
'vcs_pageview_mode': '',
"analytics_id": "G-1HLBBRSTT9", # Provided by Google in your dashboard
"analytics_anonymize_ip": False,
"logo_only": False,
"display_version": True,
"prev_next_buttons_location": "bottom",
"style_external_links": False,
"vcs_pageview_mode": "",
# 'style_nav_header_background': 'white',
# Toc options
'collapse_navigation': True,
'sticky_navigation': True,
'navigation_depth': 4,
'includehidden': True,
'titles_only': False
"collapse_navigation": True,
"sticky_navigation": True,
"navigation_depth": 4,
"includehidden": True,
"titles_only": False,
}

# Breathe Configuration
breathe_projects = {"omnitrace": "_doxygen/xml"}
breathe_default_project = "omnitrace"
breathe_default_members = ('members', )
breathe_default_members = ("members",)
breathe_projects_source = {
"auto": (
os.path.join(project_root, "source"),
Expand Down
12 changes: 2 additions & 10 deletions source/python/omnitrace/profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,7 @@ def __exit__(self, exec_type, exec_value, exec_tb):

self.stop()

if (
exec_type is not None
and exec_value is not None
and exec_tb is not None
):
if exec_type is not None and exec_value is not None and exec_tb is not None:
import traceback

traceback.print_exception(exec_type, exec_value, exec_tb, limit=5)
Expand Down Expand Up @@ -390,9 +386,5 @@ def __exit__(self, exec_type, exec_value, exec_tb):

import traceback

if (
exec_type is not None
and exec_value is not None
and exec_tb is not None
):
if exec_type is not None and exec_value is not None and exec_tb is not None:
traceback.print_exception(exec_type, exec_value, exec_tb, limit=5)
74 changes: 62 additions & 12 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -964,24 +964,74 @@ foreach(_VERSION ${OMNITRACE_PYTHON_VERSIONS})
PASS_REGEX "\\\[inefficient\\\]\\\[builtin.py:14\\\]"
DEPENDS python-builtin-${_VERSION}
ENVIRONMENT "${_python_environment}")
else()
omnitrace_message(
WARNING
"Neither 'cat' nor 'cmake -E cat' are available. Python source checks are disabled"
)
endif()

function(OMNITRACE_ADD_PYTHON_VALIDATION_TEST)
cmake_parse_arguments(TEST "" "NAME;TIMEMORY_METRIC;TIMEMORY_FILE;PERFETTO_FILE"
"ARGS" ${ARGN})

omnitrace_add_python_test(
NAME python-source-check
NAME ${TEST_NAME}-validate-timemory
COMMAND
${_PYTHON_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/validate-timemory-json.py
-l run fib fib fib fib fib inefficient _sum -c 5 5 10 20 30 10 5 5 -d 0 1
2 3 4 5 1 2 -m trip_count -i
-m ${TEST_TIMEMORY_METRIC} ${TEST_ARGS} -i
PYTHON_VERSION ${_VERSION}
FILE omnitrace-tests-output/python-source/${_VERSION}/trip_count.json
DEPENDS python-source-${_VERSION}
FILE omnitrace-tests-output/${TEST_NAME}/${_VERSION}/${TEST_TIMEMORY_FILE}
DEPENDS ${TEST_NAME}-${_VERSION}
PASS_REGEX
"omnitrace-tests-output/python-source/${_VERSION}/trip_count.json validated"
"omnitrace-tests-output/${TEST_NAME}/${_VERSION}/${TEST_TIMEMORY_FILE} validated"
ENVIRONMENT "${_python_environment}")
else()
omnitrace_message(
WARNING
"Neither 'cat' nor 'cmake -E cat' are available. Python source checks are disabled"
)
endif()

omnitrace_add_python_test(
NAME ${TEST_NAME}-validate-perfetto
COMMAND
${_PYTHON_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/validate-perfetto-proto.py
${TEST_ARGS} -p -i
PYTHON_VERSION ${_VERSION}
FILE omnitrace-tests-output/${TEST_NAME}/${_VERSION}/${TEST_PERFETTO_FILE}
DEPENDS ${TEST_NAME}-${_VERSION}
PASS_REGEX
"omnitrace-tests-output/${TEST_NAME}/${_VERSION}/${TEST_PERFETTO_FILE} validated"
ENVIRONMENT "${_python_environment}")
endfunction()

omnitrace_add_python_validation_test(
NAME python-source
TIMEMORY_METRIC "trip_count"
TIMEMORY_FILE "trip_count.json"
PERFETTO_FILE "perfetto-trace.proto"
ARGS -l
run
fib
fib
fib
fib
fib
inefficient
_sum
-c
5
5
10
20
30
10
5
5
-d
0
1
2
3
4
5
1
2)

math(EXPR _INDEX "${_INDEX} + 1")
endforeach()
Loading