Files
TheRock/rocm-systems/projects/rocprofiler-systems/tests/pytest/test_minimal.py
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

133 lines
4.1 KiB
Python

# Copyright (c) Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
"""
These tests exercise minimal examples to verify targeted behavior of the profiler.
"""
from __future__ import annotations
import pytest
from pathlib import Path
from conftest import RocprofsysTest
pytestmark = [pytest.mark.minimal]
# =============================================================================
# Fixtures
# =============================================================================
@pytest.fixture
def rocpd_env() -> dict[str, str]:
return {}
@pytest.fixture
def recursion_rules(validation_rules_dir: Path) -> list[Path]:
rules_dir = validation_rules_dir / "minimal"
return [rules_dir / "recursion-rules.json"]
@pytest.fixture
def pthreads_rules(validation_rules_dir: Path) -> list[Path]:
rules_dir = validation_rules_dir / "minimal"
return [rules_dir / "pthreads-rules.json"]
# =============================================================================
# Tests
# =============================================================================
class TestMinimal(RocprofsysTest):
"""Test minimal examples."""
RECURSION_DEPTH = 100
@pytest.mark.rocpd("rocpd_env")
@pytest.mark.parametrize("mode", ["binary_rewrite", "runtime_instrument"])
def test_recursion(self, mode, rocpd_env, recursion_rules):
"""
Ensure that recursion traces are properly present in both
perfetto and rocpd.
"""
env = rocpd_env.copy()
env["ROCPROFSYS_COUT_OUTPUT"] = "ON"
result = self.run_test(
mode,
"minimal-recursion",
env=env,
binary_rewrite_args=["--min-instructions", "0"],
runtime_instrument_args=["--min-instructions", "0"],
run_args=[str(self.RECURSION_DEPTH)],
)
self.assert_regex(result)
# Look for the last line | recurse | 1 | <depth + 1> |
deepest_depth = self.RECURSION_DEPTH + 1
self.assert_perfetto(
result,
subtest_name="Perfetto Recursion Validation",
categories=["host"],
pass_regex=[rf"\|_recurse\s+\|\s+1\s+\|\s+{deepest_depth}\s+\|"],
)
self.assert_rocpd(
result,
subtest_name="ROCpd Recursion Validation",
rules_files=recursion_rules,
)
# Every 'recurse' frame carries a source_object trace-arg
# with the value 'minimal-recursion'
self.assert_perfetto(
result,
subtest_name="Perfetto Debug Validation",
key_names=["source_object"],
key_counts=[deepest_depth],
pass_regex=[
r"key\s*::\s*debug\.source_object",
r"string_value\s*::\s*minimal-recursion",
],
)
@pytest.mark.rocpd("rocpd_env")
@pytest.mark.parametrize("mode", ["binary_rewrite", "runtime_instrument", "sys_run"])
def test_pthreads(self, mode, rocpd_env, pthreads_rules):
"""
Ensure that pthread_create gotcha arguments (the incoming arg0
annotation and the return value) are stored in the trace cache and
surfaced in both perfetto and rocpd.
"""
env = rocpd_env.copy()
env["ROCPROFSYS_COUT_OUTPUT"] = "ON"
result = self.run_test(
mode,
"minimal-pthreads",
env=env,
binary_rewrite_args=["--min-instructions", "0"],
runtime_instrument_args=["--min-instructions", "0"],
)
self.assert_regex(result)
# Both the pthread_create and pthread_join gotcha regions carry a
# "return" trace-arg of 0 (two annotations total)
self.assert_perfetto(
result,
subtest_name="Perfetto pthread Return Validation",
key_names=["return"],
key_counts=[2],
pass_regex=[
r"key\s*::\s*debug\.return",
r"string_value\s*::\s*0",
],
)
self.assert_rocpd(
result,
subtest_name="ROCpd pthread_create Args Validation",
rules_files=pthreads_rules,
)