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
143 lines
4.7 KiB
Python
143 lines
4.7 KiB
Python
#!/usr/bin/env python3
|
|
|
|
import sys
|
|
import pytest
|
|
import pandas as pd
|
|
|
|
|
|
def _find_table_or_view(conn, base_name):
|
|
for typ in ("view", "table"):
|
|
row = conn.execute(
|
|
"SELECT name FROM sqlite_master WHERE type = ? AND name LIKE ?",
|
|
(typ, f"{base_name}%"),
|
|
).fetchone()
|
|
if row:
|
|
return row[0]
|
|
return None
|
|
|
|
|
|
def test_validate_spm_rocpd_csv(counter_csv: pd.DataFrame, spm_json_data):
|
|
assert not counter_csv.empty
|
|
|
|
kernel_column = "kernel_name" if "kernel_name" in counter_csv else "Kernel_Name"
|
|
counter_column = "counter_name" if "counter_name" in counter_csv else "Counter_Name"
|
|
value_column = "Counter_Value"
|
|
|
|
filtered = counter_csv[counter_csv[kernel_column].str.contains("matrixTranspose")]
|
|
|
|
assert not filtered.empty, "No matrixTranspose entries in counter CSV"
|
|
|
|
filtered = filtered.copy()
|
|
filtered["base_counter"] = filtered[counter_column].str.replace(
|
|
r"\[.*\]$", "", regex=True
|
|
)
|
|
|
|
csv_values = filtered.groupby("base_counter")[value_column].sum().to_dict()
|
|
|
|
assert csv_values
|
|
|
|
def _collect_spm_totals(json_data, kernel_filter):
|
|
data = json_data["rocprofiler-sdk-tool"]
|
|
counters = {itr["id"]["handle"]: itr for itr in data.get("counters", [])}
|
|
kernel_symbols = data.get("kernel_symbols", [])
|
|
|
|
values = {}
|
|
for entry in data["callback_records"]["spm_counter_collection"]:
|
|
dispatch_info = entry["dispatch_data"]["dispatch_info"]
|
|
kernel_id = dispatch_info.get("kernel_id")
|
|
if isinstance(kernel_id, dict):
|
|
kernel_id = kernel_id.get("handle")
|
|
kernel_name = kernel_symbols[kernel_id]["formatted_kernel_name"]
|
|
if kernel_filter not in kernel_name:
|
|
continue
|
|
|
|
for record in entry["records"]:
|
|
counter_id = record["counter_id"]["handle"]
|
|
counter = counters[counter_id]
|
|
counter_name = counter["name"]
|
|
values[counter_name] = values.get(counter_name, 0) + record["value"]
|
|
|
|
return values
|
|
|
|
spm_values = _collect_spm_totals(spm_json_data, "matrixTranspose")
|
|
|
|
assert spm_values
|
|
|
|
for counter_name, csv_value in csv_values.items():
|
|
assert counter_name in spm_values, (
|
|
f"{counter_name} in CSV but not in JSON. "
|
|
f"JSON counters: {sorted(spm_values.keys())}"
|
|
)
|
|
spm_value = spm_values[counter_name]
|
|
assert (
|
|
csv_value == spm_value
|
|
), f"{counter_name}: csv={csv_value} != json={spm_value}"
|
|
|
|
|
|
def test_validate_spm_rocpd(spm_json_data, rocpd_data):
|
|
data = spm_json_data["rocprofiler-sdk-tool"]
|
|
spm_data = data["callback_records"]["spm_counter_collection"]
|
|
|
|
pmc_table = _find_table_or_view(rocpd_data, "rocpd_info_pmc")
|
|
pmc_event_table = _find_table_or_view(rocpd_data, "rocpd_pmc_event")
|
|
|
|
assert pmc_table is not None
|
|
assert pmc_event_table is not None
|
|
|
|
counters = {itr["id"]["handle"]: itr["name"] for itr in data.get("counters", [])}
|
|
|
|
spm_counter_names = set()
|
|
for entry in spm_data:
|
|
for record in entry["records"]:
|
|
spm_counter_names.add(counters[record["counter_id"]["handle"]])
|
|
|
|
assert len(spm_counter_names) > 0
|
|
|
|
placeholders = ",".join(["?"] * len(spm_counter_names))
|
|
pmc_name_list = sorted(spm_counter_names)
|
|
|
|
rocpd_pmc_names = rocpd_data.execute(
|
|
f"SELECT name FROM {pmc_table} WHERE name IN ({placeholders})",
|
|
pmc_name_list,
|
|
).fetchall()
|
|
|
|
assert len(rocpd_pmc_names) > 0
|
|
|
|
rocpd_spm_count = rocpd_data.execute(
|
|
f"SELECT COUNT(*) FROM {pmc_event_table} e "
|
|
f"JOIN {pmc_table} p ON e.pmc_id = p.id "
|
|
f"WHERE p.name IN ({placeholders})",
|
|
pmc_name_list,
|
|
).fetchone()[0]
|
|
|
|
assert rocpd_spm_count > 0
|
|
|
|
|
|
def test_validate_spm_external_correlation_rocpd(rocpd_data):
|
|
spm_view = _find_table_or_view(rocpd_data, "spm_counters")
|
|
assert spm_view is not None
|
|
|
|
rows = rocpd_data.execute(
|
|
f"SELECT DISTINCT correlation_id FROM {spm_view}"
|
|
).fetchall()
|
|
|
|
assert len(rows) > 0, "No SPM records in rocpd"
|
|
for row in rows:
|
|
assert row[0] is not None, "correlation_id should not be NULL"
|
|
|
|
|
|
def test_validate_spm_sample_timestamps(rocpd_data):
|
|
sample_table = _find_table_or_view(rocpd_data, "rocpd_sample")
|
|
assert sample_table is not None
|
|
|
|
rows = rocpd_data.execute(f"SELECT id, timestamp FROM {sample_table}").fetchall()
|
|
|
|
assert len(rows) > 0, "No samples found in rocpd"
|
|
for row in rows:
|
|
assert row[1] > 0, f"sample id={row[0]} has timestamp={row[1]}, expected > 0"
|
|
|
|
|
|
if __name__ == "__main__":
|
|
exit_code = pytest.main(["-x", __file__] + sys.argv[1:])
|
|
sys.exit(exit_code)
|