kernel iteration filtering for counter collection (#911)
* kernel filtering for counter collection * fixing trace tests * removing print statements * fix CI fail * handling preload and updating docs * minor fix * misc fix * misc fix * Typo fix * Update rocprofv3 + input schema - "application_passes" -> "jobs" - removed nesting in YAML/JSON inputs - improved customAction (now booleanArgAction) - supports --<name> (defaults to true) - supports --<name>=<truth-value> - supports --<name> <truth-value> - added --kernel-iteration-range to command-line - automatically support new command-line options in YAML/JSON input - standardized PMC return from text input to match PMC from YAML/JSON input - added support for --log-level env - updated various input*.(yml|json) to modified schema * Update config.cpp - added recommended code to get_kernel_filter_range * Fixing iteration * misc fix * support only [-] for iteration * bug fix * Fix using-rocprofv3.rst * Update config.cpp - patch get_kernel_filter_range --------- Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
This commit is contained in:
@@ -274,7 +274,7 @@ main()
|
||||
HIP_API_CALL(hipGetDeviceCount(&device_count));
|
||||
|
||||
for(int i = 0; i < device_count; ++i)
|
||||
run(4, i);
|
||||
run(8, i);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -6,3 +6,4 @@ add_subdirectory(input1)
|
||||
add_subdirectory(input2)
|
||||
add_subdirectory(input3)
|
||||
add_subdirectory(list_metrics)
|
||||
add_subdirectory(kernel_filtering)
|
||||
|
||||
@@ -43,20 +43,21 @@ add_test(
|
||||
NAME rocprofv3-test-counter-collection-json-pmc1-validate
|
||||
COMMAND
|
||||
${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/validate.py --agent-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_1/out_json_agent_info.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pass_1/out_json_agent_info.csv
|
||||
--counter-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_1/out_json_counter_collection.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pass_1/out_json_counter_collection.csv
|
||||
--agent-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_2/out_json_agent_info.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pass_2/out_json_agent_info.csv
|
||||
--counter-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_2/out_json_counter_collection.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pass_2/out_json_counter_collection.csv
|
||||
)
|
||||
|
||||
set(JSON_VALIDATION_FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_1/out_json_agent_info.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_1/out_json_counter_collection.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_2/out_json_agent_info.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_2/out_json_counter_collection.csv)
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pass_1/out_json_agent_info.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pass_1/out_json_counter_collection.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pass_2/out_json_agent_info.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pass_2/out_json_counter_collection.csv
|
||||
)
|
||||
|
||||
set_tests_properties(
|
||||
rocprofv3-test-counter-collection-json-pmc1-validate
|
||||
@@ -75,20 +76,21 @@ add_test(
|
||||
NAME rocprofv3-test-counter-collection-yaml-pmc1-validate
|
||||
COMMAND
|
||||
${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/validate.py --agent-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_1/out_yaml_agent_info.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pass_1/out_yaml_agent_info.csv
|
||||
--counter-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_1/out_yaml_counter_collection.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pass_1/out_yaml_counter_collection.csv
|
||||
--agent-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_2/out_yaml_agent_info.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pass_2/out_yaml_agent_info.csv
|
||||
--counter-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_2/out_yaml_counter_collection.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pass_2/out_yaml_counter_collection.csv
|
||||
)
|
||||
|
||||
set(YAML_VALIDATION_FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_1/out_yaml_agent_info.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_1/out_yaml_counter_collection.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_2/out_yaml_agent_info.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_2/out_yaml_counter_collection.csv)
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pass_1/out_yaml_agent_info.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pass_1/out_yaml_counter_collection.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pass_2/out_yaml_agent_info.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pass_2/out_yaml_counter_collection.csv
|
||||
)
|
||||
|
||||
set_tests_properties(
|
||||
rocprofv3-test-counter-collection-yaml-pmc1-validate
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
{
|
||||
"metrics": [
|
||||
{
|
||||
"pmc": [
|
||||
"SQ_WAVES",
|
||||
"GRBM_COUNT"
|
||||
]
|
||||
},
|
||||
{
|
||||
"pmc": [
|
||||
"GRBM_GUI_ACTIVE"
|
||||
]
|
||||
}
|
||||
]
|
||||
"jobs": [
|
||||
{
|
||||
"pmc": [
|
||||
"SQ_WAVES",
|
||||
"GRBM_COUNT"
|
||||
]
|
||||
},
|
||||
{
|
||||
"pmc": [
|
||||
"GRBM_GUI_ACTIVE"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
metrics:
|
||||
jobs:
|
||||
- pmc:
|
||||
- SQ_WAVES
|
||||
- GRBM_COUNT
|
||||
- SQ_WAVES
|
||||
- GRBM_COUNT
|
||||
- pmc:
|
||||
- GRBM_GUI_ACTIVE
|
||||
- GRBM_GUI_ACTIVE
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
#
|
||||
# rocprofv3 tool test
|
||||
#
|
||||
cmake_minimum_required(VERSION 3.21.0 FATAL_ERROR)
|
||||
|
||||
project(
|
||||
rocprofiler-tests-counter-collection
|
||||
LANGUAGES CXX
|
||||
VERSION 0.0.0)
|
||||
|
||||
find_package(rocprofiler-sdk REQUIRED)
|
||||
|
||||
rocprofiler_configure_pytest_files(CONFIG pytest.ini COPY validate.py conftest.py
|
||||
input.txt input.json input.yml)
|
||||
|
||||
# pmc1
|
||||
add_test(
|
||||
NAME rocprofv3-test-cc-kernel-filtering-input-json-execute
|
||||
COMMAND
|
||||
$<TARGET_FILE:rocprofiler-sdk::rocprofv3> -i
|
||||
${CMAKE_CURRENT_BINARY_DIR}/input.json -d ${CMAKE_CURRENT_BINARY_DIR}/json_input
|
||||
-- $<TARGET_FILE:vector-ops>)
|
||||
|
||||
string(REPLACE "LD_PRELOAD=" "ROCPROF_PRELOAD=" PRELOAD_ENV
|
||||
"${ROCPROFILER_MEMCHECK_PRELOAD_ENV}")
|
||||
|
||||
set(cc-env-kernel-filtering "${PRELOAD_ENV}")
|
||||
|
||||
set_tests_properties(
|
||||
rocprofv3-test-cc-kernel-filtering-input-json-execute
|
||||
PROPERTIES TIMEOUT 45 LABELS "integration-tests" ENVIRONMENT
|
||||
"${cc-env-kernel-filtering}" FAIL_REGULAR_EXPRESSION
|
||||
"${ROCPROFILER_DEFAULT_FAIL_REGEX}")
|
||||
|
||||
add_test(
|
||||
NAME rocprofv3-test-cc-kernel-filtering-input-cmd-execute
|
||||
COMMAND
|
||||
$<TARGET_FILE:rocprofiler-sdk::rocprofv3> -i
|
||||
${CMAKE_CURRENT_BINARY_DIR}/input.txt --kernel-include-regex ".*kernel"
|
||||
--kernel-exclude-regex "multiply" -T -d ${CMAKE_CURRENT_BINARY_DIR}/cmd_input -o
|
||||
out --output-format csv -- $<TARGET_FILE:vector-ops>)
|
||||
|
||||
set_tests_properties(
|
||||
rocprofv3-test-cc-kernel-filtering-input-cmd-execute
|
||||
PROPERTIES TIMEOUT 45 LABELS "integration-tests" ENVIRONMENT
|
||||
"${cc-env-kernel-filtering}" FAIL_REGULAR_EXPRESSION
|
||||
"${ROCPROFILER_DEFAULT_FAIL_REGEX}")
|
||||
|
||||
# pmc1
|
||||
add_test(
|
||||
NAME rocprofv3-test-cc-kernel-filtering-input-yaml-execute
|
||||
COMMAND
|
||||
$<TARGET_FILE:rocprofiler-sdk::rocprofv3> -i
|
||||
${CMAKE_CURRENT_BINARY_DIR}/input.yml -T -d
|
||||
${CMAKE_CURRENT_BINARY_DIR}/yaml_input -o out --output-format csv json --
|
||||
$<TARGET_FILE:vector-ops>)
|
||||
|
||||
set_tests_properties(
|
||||
rocprofv3-test-cc-kernel-filtering-input-yaml-execute
|
||||
PROPERTIES TIMEOUT 45 LABELS "integration-tests" ENVIRONMENT
|
||||
"${cc-env-kernel-filtering}" FAIL_REGULAR_EXPRESSION
|
||||
"${ROCPROFILER_DEFAULT_FAIL_REGEX}")
|
||||
add_test(
|
||||
NAME rocprofv3-test-cc-kernel-filtering-input-json-validate
|
||||
COMMAND
|
||||
${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/validate.py -k _pass
|
||||
--input-csv-pass1
|
||||
${CMAKE_CURRENT_BINARY_DIR}/json_input/pass_1/out_counter_collection.csv
|
||||
--input-json-pass1 ${CMAKE_CURRENT_BINARY_DIR}/json_input/pass_1/out_results.json
|
||||
--input-csv-pass2
|
||||
${CMAKE_CURRENT_BINARY_DIR}/json_input/pass_2/out_counter_collection.csv
|
||||
--input-json-pass2 ${CMAKE_CURRENT_BINARY_DIR}/json_input/pass_2/out_results.json
|
||||
--input-csv-pass3
|
||||
${CMAKE_CURRENT_BINARY_DIR}/json_input/pass_3/out_counter_collection.csv
|
||||
--input-json-pass3 ${CMAKE_CURRENT_BINARY_DIR}/json_input/pass_3/out_results.json)
|
||||
|
||||
add_test(
|
||||
NAME rocprofv3-test-cc-kernel-filtering-input-yaml-validate
|
||||
COMMAND
|
||||
${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/validate.py -k _pass
|
||||
--input-csv-pass1
|
||||
${CMAKE_CURRENT_BINARY_DIR}/yaml_input/pass_1/out_counter_collection.csv
|
||||
--input-json-pass1 ${CMAKE_CURRENT_BINARY_DIR}/yaml_input/pass_1/out_results.json
|
||||
--input-csv-pass2
|
||||
${CMAKE_CURRENT_BINARY_DIR}/yaml_input/pass_2/out_counter_collection.csv
|
||||
--input-json-pass2 ${CMAKE_CURRENT_BINARY_DIR}/yaml_input/pass_2/out_results.json
|
||||
--input-csv-pass3
|
||||
${CMAKE_CURRENT_BINARY_DIR}/yaml_input/pass_3/out_counter_collection.csv
|
||||
--input-json-pass3 ${CMAKE_CURRENT_BINARY_DIR}/yaml_input/pass_3/out_results.json)
|
||||
|
||||
add_test(
|
||||
NAME rocprofv3-test-cc-kernel-filtering-input-cmd-validate
|
||||
COMMAND
|
||||
${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/validate.py -k
|
||||
test_validate_counter_collection_csv_pmc1 --input-csv-pmc1
|
||||
${CMAKE_CURRENT_BINARY_DIR}/cmd_input/pmc_1/out_counter_collection.csv)
|
||||
|
||||
set_tests_properties(
|
||||
rocprofv3-test-cc-kernel-filtering-input-json-validate
|
||||
PROPERTIES TIMEOUT 45 LABELS "integration-tests" DEPENDS
|
||||
"rocprofv3-test-cc-kernel-filtering-input-json-execute"
|
||||
FAIL_REGULAR_EXPRESSION "${ROCPROFILER_DEFAULT_FAIL_REGEX}")
|
||||
|
||||
set_tests_properties(
|
||||
rocprofv3-test-cc-kernel-filtering-input-cmd-validate
|
||||
PROPERTIES TIMEOUT 45 LABELS "integration-tests" DEPENDS
|
||||
"rocprofv3-test-cc-kernel-filtering-input-cmd-execute"
|
||||
FAIL_REGULAR_EXPRESSION "${ROCPROFILER_DEFAULT_FAIL_REGEX}")
|
||||
|
||||
set_tests_properties(
|
||||
rocprofv3-test-cc-kernel-filtering-input-yaml-validate
|
||||
PROPERTIES TIMEOUT 45 LABELS "integration-tests" DEPENDS
|
||||
"rocprofv3-test-cc-kernel-filtering-input-yaml-execute"
|
||||
FAIL_REGULAR_EXPRESSION "${ROCPROFILER_DEFAULT_FAIL_REGEX}")
|
||||
@@ -0,0 +1,102 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import json
|
||||
import pytest
|
||||
import pandas as pd
|
||||
|
||||
from rocprofiler_sdk.pytest_utils.dotdict import dotdict
|
||||
from rocprofiler_sdk.pytest_utils import collapse_dict_list
|
||||
|
||||
|
||||
def pytest_addoption(parser):
|
||||
|
||||
parser.addoption(
|
||||
"--input-json-pass1",
|
||||
action="store",
|
||||
help="Path to JSON file.",
|
||||
)
|
||||
|
||||
parser.addoption(
|
||||
"--input-csv-pass1",
|
||||
action="store",
|
||||
help="Path to CSV file.",
|
||||
)
|
||||
|
||||
parser.addoption(
|
||||
"--input-json-pass2",
|
||||
action="store",
|
||||
help="Path to JSON file.",
|
||||
)
|
||||
|
||||
parser.addoption(
|
||||
"--input-csv-pass2",
|
||||
action="store",
|
||||
help="Path to JSON file.",
|
||||
)
|
||||
|
||||
parser.addoption(
|
||||
"--input-json-pass3",
|
||||
action="store",
|
||||
help="Path to JSON file.",
|
||||
)
|
||||
|
||||
parser.addoption(
|
||||
"--input-csv-pass3",
|
||||
action="store",
|
||||
help="Path to JSON file.",
|
||||
)
|
||||
|
||||
parser.addoption(
|
||||
"--input-csv-pmc1",
|
||||
action="store",
|
||||
help="Path to CSV file.",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def input_csv_pass1(request):
|
||||
filename = request.config.getoption("--input-csv-pass1")
|
||||
with open(filename, "r") as inp:
|
||||
return pd.read_csv(inp)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def input_csv_pass2(request):
|
||||
filename = request.config.getoption("--input-csv-pass2")
|
||||
with open(filename, "r") as inp:
|
||||
return pd.read_csv(inp)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def input_csv_pass3(request):
|
||||
filename = request.config.getoption("--input-csv-pass3")
|
||||
with open(filename, "r") as inp:
|
||||
return pd.read_csv(inp)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def input_csv_pmc1(request):
|
||||
filename = request.config.getoption("--input-csv-pmc1")
|
||||
with open(filename, "r") as inp:
|
||||
return pd.read_csv(inp)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def input_json_pass1(request):
|
||||
filename = request.config.getoption("--input-json-pass1")
|
||||
with open(filename, "r") as inp:
|
||||
return dotdict(collapse_dict_list(json.load(inp)))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def input_json_pass2(request):
|
||||
filename = request.config.getoption("--input-json-pass2")
|
||||
with open(filename, "r") as inp:
|
||||
return dotdict(collapse_dict_list(json.load(inp)))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def input_json_pass3(request):
|
||||
filename = request.config.getoption("--input-json-pass3")
|
||||
with open(filename, "r") as inp:
|
||||
return dotdict(collapse_dict_list(json.load(inp)))
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"jobs": [
|
||||
{
|
||||
"pmc": [
|
||||
"SQ_WAVES"
|
||||
],
|
||||
"kernel_include_regex": ".*_kernel",
|
||||
"kernel_exclude_regex": "multiply",
|
||||
"kernel_iteration_range": "[1-2]",
|
||||
"output_file": "out",
|
||||
"output_format": [
|
||||
"csv",
|
||||
"json"
|
||||
],
|
||||
"truncate_kernels": true
|
||||
},
|
||||
{
|
||||
"pmc": [
|
||||
"GRBM_COUNT"
|
||||
],
|
||||
"kernel_include_regex": ".*_kernel",
|
||||
"kernel_iteration_range": "[2-3]",
|
||||
"output_file": "out",
|
||||
"output_format": [
|
||||
"csv",
|
||||
"json"
|
||||
],
|
||||
"truncate_kernels": true
|
||||
},
|
||||
{
|
||||
"pmc": [
|
||||
"GRBM_GUI_ACTIVE"
|
||||
],
|
||||
"kernel_include_regex": ".*_kernel",
|
||||
"kernel_exclude_regex": "",
|
||||
"output_file": "out",
|
||||
"output_format": [
|
||||
"csv",
|
||||
"json"
|
||||
],
|
||||
"truncate_kernels": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
pmc: SQ_WAVES
|
||||
@@ -0,0 +1,15 @@
|
||||
jobs:
|
||||
- pmc: [SQ_WAVES]
|
||||
kernel_include_regex: ".*_kernel"
|
||||
kernel_exclude_regex: "multiply"
|
||||
kernel_iteration_range:
|
||||
- "[1-2]"
|
||||
- "[3-4]"
|
||||
- "[5-6]"
|
||||
- pmc:
|
||||
- GRBM_COUNT
|
||||
kernel_include_regex: ".*_kernel"
|
||||
kernel_iteration_range: "[2-3]"
|
||||
- pmc: [GRBM_GUI_ACTIVE]
|
||||
kernel_include_regex: ".*_kernel"
|
||||
kernel_exclude_regex: ""
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
[pytest]
|
||||
addopts = --durations=20 -rA -s -vv
|
||||
testpaths = validate.py
|
||||
pythonpath = @ROCPROFILER_SDK_TESTS_BINARY_DIR@/pytest-packages
|
||||
@@ -0,0 +1,138 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import pytest
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import re
|
||||
|
||||
|
||||
def unique(lst):
|
||||
return list(set(lst))
|
||||
|
||||
|
||||
def validate_csv(df, kernel_list, counter_name):
|
||||
|
||||
assert not df.empty
|
||||
assert (df["Agent_Id"].astype(int).values > 0).all()
|
||||
assert (df["Queue_Id"].astype(int).values > 0).all()
|
||||
assert (df["Process_Id"].astype(int).values > 0).all()
|
||||
assert len(df["Kernel_Name"]) > 0
|
||||
|
||||
counter_collection_pmc1_kernel_list = [
|
||||
x
|
||||
for x in sorted(df["Kernel_Name"].unique().tolist())
|
||||
if not re.search(r"__amd_rocclr_.*", x)
|
||||
]
|
||||
|
||||
assert kernel_list == counter_collection_pmc1_kernel_list
|
||||
|
||||
kernel_count = dict([[itr, 0] for itr in kernel_list])
|
||||
assert len(kernel_count) == len(kernel_list)
|
||||
for itr in df["Kernel_Name"]:
|
||||
if re.search(r"__amd_rocclr_.*", itr):
|
||||
continue
|
||||
kernel_count[itr] += 1
|
||||
kn_cnt = [itr for _, itr in kernel_count.items()]
|
||||
assert min(kn_cnt) == max(kn_cnt) and len(unique(kn_cnt)) == 1
|
||||
|
||||
assert len(df["Counter_Value"]) > 0
|
||||
assert df["Counter_Name"].str.contains(counter_name).all()
|
||||
assert (df["Counter_Value"].astype(int).values > 0).all()
|
||||
|
||||
|
||||
def validate_json(json_data, counter_name, check_dispatch):
|
||||
|
||||
data = json_data["rocprofiler-sdk-tool"]
|
||||
counter_collection_data = data["callback_records"]["counter_collection"]
|
||||
dispatch_ids = []
|
||||
# at present, AQLProfile has bugs when reporting the counters for below architectures
|
||||
skip_gfx = ("gfx1101", "gfx1102")
|
||||
|
||||
def get_kernel_name(kernel_id):
|
||||
return data["kernel_symbols"][kernel_id]["formatted_kernel_name"]
|
||||
|
||||
def get_agent(agent_id):
|
||||
for agent in data["agents"]:
|
||||
if agent["id"]["handle"] == agent_id["handle"]:
|
||||
return agent
|
||||
return None
|
||||
|
||||
def get_counter(counter_id):
|
||||
for counter in data["counters"]:
|
||||
if counter["id"]["handle"] == counter_id["handle"]:
|
||||
return counter
|
||||
return None
|
||||
|
||||
for counter in counter_collection_data:
|
||||
dispatch_data = counter["dispatch_data"]["dispatch_info"]
|
||||
|
||||
assert dispatch_data["dispatch_id"] > 0
|
||||
assert dispatch_data["agent_id"]["handle"] > 0
|
||||
assert dispatch_data["queue_id"]["handle"] > 0
|
||||
|
||||
agent = get_agent(dispatch_data["agent_id"])
|
||||
kernel_name = get_kernel_name(dispatch_data["kernel_id"])
|
||||
|
||||
assert agent is not None
|
||||
assert len(kernel_name) > 0
|
||||
|
||||
dispatch_ids.append(dispatch_data["dispatch_id"])
|
||||
if not re.search(r"__amd_rocclr_.*", kernel_name):
|
||||
for record in counter["records"]:
|
||||
counter = get_counter(record["counter_id"])
|
||||
assert counter is not None, f"record:\n\t{record}"
|
||||
assert (
|
||||
counter["name"] == counter_name
|
||||
), f"record:\n\t{record}\ncounter:\n\t{counter}"
|
||||
if agent["name"] not in skip_gfx:
|
||||
assert (
|
||||
record["value"] > 0
|
||||
), f"record: {record}\ncounter: {counter}\nagent: {agent}"
|
||||
|
||||
if check_dispatch:
|
||||
di_uniq = list(set(sorted(dispatch_ids)))
|
||||
# make sure the dispatch ids are unique and ordered
|
||||
di_expect = [idx + 1 for idx in range(len(dispatch_ids))]
|
||||
assert di_expect == di_uniq
|
||||
|
||||
|
||||
def test_validate_counter_collection_csv_pass1(input_csv_pass1: pd.DataFrame):
|
||||
kernel_list = sorted(["addition_kernel", "subtract_kernel", "divide_kernel"])
|
||||
validate_csv(input_csv_pass1, kernel_list, "SQ_WAVES")
|
||||
|
||||
|
||||
def test_validate_counter_collection_csv_pmc1(input_csv_pmc1: pd.DataFrame):
|
||||
kernel_list = sorted(["addition_kernel", "subtract_kernel", "divide_kernel"])
|
||||
validate_csv(input_csv_pmc1, kernel_list, "SQ_WAVES")
|
||||
|
||||
|
||||
def test_validate_counter_collection_csv_pass2(input_csv_pass2: pd.DataFrame):
|
||||
kernel_list = sorted(
|
||||
["addition_kernel", "subtract_kernel", "multiply_kernel", "divide_kernel"]
|
||||
)
|
||||
validate_csv(input_csv_pass2, kernel_list, "GRBM_COUNT")
|
||||
|
||||
|
||||
def test_validate_counter_collection_csv_pass3(input_csv_pass3: pd.DataFrame):
|
||||
kernel_list = sorted(
|
||||
["addition_kernel", "subtract_kernel", "multiply_kernel", "divide_kernel"]
|
||||
)
|
||||
validate_csv(input_csv_pass3, kernel_list, "GRBM_GUI_ACTIVE")
|
||||
|
||||
|
||||
def test_validate_counter_collection_json_pass1(input_json_pass1):
|
||||
validate_json(input_json_pass1, "SQ_WAVES", False)
|
||||
|
||||
|
||||
def test_validate_counter_collection_json_pass2(input_json_pass2):
|
||||
validate_json(input_json_pass2, "GRBM_COUNT", False)
|
||||
|
||||
|
||||
def test_validate_counter_collection_json_pass3(input_json_pass3):
|
||||
validate_json(input_json_pass3, "GRBM_GUI_ACTIVE", True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit_code = pytest.main(["-x", __file__] + sys.argv[1:])
|
||||
sys.exit(exit_code)
|
||||
@@ -10,7 +10,8 @@ project(
|
||||
|
||||
find_package(rocprofiler-sdk REQUIRED)
|
||||
|
||||
rocprofiler_configure_pytest_files(CONFIG pytest.ini COPY validate.py conftest.py)
|
||||
rocprofiler_configure_pytest_files(CONFIG pytest.ini COPY validate.py conftest.py
|
||||
input.json)
|
||||
|
||||
# basic-metrics
|
||||
add_test(NAME rocprofv3-test-list-metrics-execute
|
||||
@@ -19,7 +20,8 @@ add_test(NAME rocprofv3-test-list-metrics-execute
|
||||
|
||||
# list-metrics-stdout
|
||||
add_test(NAME rocprofv3-test-list-metrics-std-out-execute
|
||||
COMMAND $<TARGET_FILE:rocprofiler-sdk::rocprofv3> --list-metrics)
|
||||
COMMAND $<TARGET_FILE:rocprofiler-sdk::rocprofv3> -i
|
||||
${CMAKE_CURRENT_BINARY_DIR}/input.json)
|
||||
|
||||
string(REPLACE "LD_PRELOAD=" "ROCPROF_PRELOAD=" PRELOAD_ENV
|
||||
"${ROCPROFILER_MEMCHECK_PRELOAD_ENV}")
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"jobs": [
|
||||
{
|
||||
"list_metrics": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -16,6 +16,14 @@ else()
|
||||
set(LOG_LEVEL "info")
|
||||
endif()
|
||||
|
||||
string(REPLACE "LD_PRELOAD=" "ROCPROF_PRELOAD=" PRELOAD_ENV
|
||||
"${ROCPROFILER_MEMCHECK_PRELOAD_ENV}")
|
||||
|
||||
set(tracing-env "${PRELOAD_ENV}")
|
||||
|
||||
rocprofiler_configure_pytest_files(
|
||||
CONFIG pytest.ini COPY validate.py conftest.py input_systrace.json input_trace.json)
|
||||
|
||||
add_test(
|
||||
NAME rocprofv3-test-trace-execute
|
||||
COMMAND
|
||||
@@ -24,11 +32,6 @@ add_test(
|
||||
out --output-format pftrace csv json --log-level ${LOG_LEVEL} --
|
||||
$<TARGET_FILE:simple-transpose>)
|
||||
|
||||
string(REPLACE "LD_PRELOAD=" "ROCPROF_PRELOAD=" PRELOAD_ENV
|
||||
"${ROCPROFILER_MEMCHECK_PRELOAD_ENV}")
|
||||
|
||||
set(tracing-env "${PRELOAD_ENV}")
|
||||
|
||||
set_tests_properties(
|
||||
rocprofv3-test-trace-execute
|
||||
PROPERTIES
|
||||
@@ -42,7 +45,26 @@ set_tests_properties(
|
||||
"HSA_API|HIP_API|HIP_COMPILER_API|MARKER_CORE_API|MARKER_CONTROL_API|MARKER_NAME_API|KERNEL_DISPATCH|CODE_OBJECT"
|
||||
)
|
||||
|
||||
rocprofiler_configure_pytest_files(CONFIG pytest.ini COPY validate.py conftest.py)
|
||||
add_test(
|
||||
NAME rocprofv3-test-trace-input-json-execute
|
||||
COMMAND
|
||||
$<TARGET_FILE:rocprofiler-sdk::rocprofv3> -i
|
||||
${CMAKE_CURRENT_BINARY_DIR}/input_trace.json -d
|
||||
${CMAKE_CURRENT_BINARY_DIR}/%argt%-trace-input-json --log-level ${LOG_LEVEL} --
|
||||
$<TARGET_FILE:simple-transpose>)
|
||||
|
||||
set_tests_properties(
|
||||
rocprofv3-test-trace-input-json-execute
|
||||
PROPERTIES
|
||||
TIMEOUT
|
||||
45
|
||||
LABELS
|
||||
"integration-tests"
|
||||
ENVIRONMENT
|
||||
"${tracing-env}"
|
||||
FAIL_REGULAR_EXPRESSION
|
||||
"HSA_API|HIP_API|HIP_COMPILER_API|MARKER_CORE_API|MARKER_CONTROL_API|MARKER_NAME_API|KERNEL_DISPATCH|CODE_OBJECT"
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME rocprofv3-test-trace-validate
|
||||
@@ -61,6 +83,24 @@ add_test(
|
||||
--pftrace-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-trace/out_results.pftrace)
|
||||
|
||||
add_test(
|
||||
NAME rocprofv3-test-trace-input-json-validate
|
||||
COMMAND
|
||||
${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/validate.py --hsa-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-trace-input-json/out_hsa_api_trace.csv
|
||||
--kernel-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-trace-input-json/out_kernel_trace.csv
|
||||
--memory-copy-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-trace-input-json/out_memory_copy_trace.csv
|
||||
--marker-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-trace-input-json/out_marker_api_trace.csv
|
||||
--agent-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-trace-input-json/out_agent_info.csv
|
||||
--json-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-trace-input-json/out_results.json
|
||||
--pftrace-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-trace-input-json/out_results.pftrace)
|
||||
|
||||
set(VALIDATION_FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-trace/out_results.pftrace
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-trace/out_results.json
|
||||
@@ -68,7 +108,14 @@ set(VALIDATION_FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-trace/out_hsa_api_trace.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-trace/out_kernel_trace.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-trace/out_marker_api_trace.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-trace/out_agent_info.csv)
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-trace/out_agent_info.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-trace-input-json/out_results.pftrace
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-trace-input-json/out_results.json
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-trace-input-json/out_memory_copy_trace.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-trace-input-json/out_hsa_api_trace.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-trace-input-json/out_kernel_trace.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-trace-input-json/out_marker_api_trace.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-trace-input-json/out_agent_info.csv)
|
||||
|
||||
set_tests_properties(
|
||||
rocprofv3-test-trace-validate
|
||||
@@ -83,6 +130,19 @@ set_tests_properties(
|
||||
ATTACHED_FILES_ON_FAIL
|
||||
"${VALIDATION_FILES}")
|
||||
|
||||
set_tests_properties(
|
||||
rocprofv3-test-trace-input-json-validate
|
||||
PROPERTIES TIMEOUT
|
||||
45
|
||||
LABELS
|
||||
"integration-tests"
|
||||
DEPENDS
|
||||
"rocprofv3-test-trace-input-json-execute"
|
||||
FAIL_REGULAR_EXPRESSION
|
||||
"AssertionError"
|
||||
ATTACHED_FILES_ON_FAIL
|
||||
"${VALIDATION_FILES}")
|
||||
|
||||
# sys-trace test: tests --sys-trace command with mangled kernel names and validates
|
||||
# generated files
|
||||
|
||||
@@ -106,6 +166,26 @@ set_tests_properties(
|
||||
"HSA_API|HIP_API|HIP_COMPILER_API|MARKER_CORE_API|MARKER_CONTROL_API|MARKER_NAME_API|KERNEL_DISPATCH|CODE_OBJECT"
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME rocprofv3-test-systrace-input-json-execute
|
||||
COMMAND
|
||||
$<TARGET_FILE:rocprofiler-sdk::rocprofv3> -i
|
||||
${CMAKE_CURRENT_BINARY_DIR}/input_systrace.json -d
|
||||
${CMAKE_CURRENT_BINARY_DIR}/%argt%-systrace-input-json --
|
||||
$<TARGET_FILE:simple-transpose>)
|
||||
|
||||
set_tests_properties(
|
||||
rocprofv3-test-systrace-input-json-execute
|
||||
PROPERTIES
|
||||
TIMEOUT
|
||||
45
|
||||
LABELS
|
||||
"integration-tests"
|
||||
ENVIRONMENT
|
||||
"${tracing-env}"
|
||||
FAIL_REGULAR_EXPRESSION
|
||||
"HSA_API|HIP_API|HIP_COMPILER_API|MARKER_CORE_API|MARKER_CONTROL_API|MARKER_NAME_API|KERNEL_DISPATCH|CODE_OBJECT"
|
||||
)
|
||||
add_test(
|
||||
NAME rocprofv3-test-systrace-validate
|
||||
COMMAND
|
||||
@@ -125,6 +205,26 @@ add_test(
|
||||
--pftrace-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace/out_results.pftrace)
|
||||
|
||||
add_test(
|
||||
NAME rocprofv3-test-systrace-input-json-validate
|
||||
COMMAND
|
||||
${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/validate.py -k
|
||||
"not test_hsa_api_trace" --hsa-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace-input-json/out_hsa_api_trace.csv
|
||||
--kernel-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace-input-json/out_kernel_trace.csv
|
||||
--memory-copy-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace-input-json/out_memory_copy_trace.csv
|
||||
--marker-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace-input-json/out_marker_api_trace.csv
|
||||
--agent-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace-input-json/out_agent_info.csv
|
||||
--json-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace-input-json/out_results.json
|
||||
--pftrace-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace-input-json/out_results.pftrace
|
||||
)
|
||||
|
||||
set(SYS_VALIDATION_FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace/out_results.pftrace
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace/out_results.json
|
||||
@@ -132,7 +232,14 @@ set(SYS_VALIDATION_FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace/out_hsa_api_trace.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace/out_kernel_trace.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace/out_marker_api_trace.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace/out_agent_info.csv)
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace/out_agent_info.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace-input-json/out_results.pftrace
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace-input-json/out_results.json
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace-input-json/out_memory_copy_trace.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace-input-json/out_hsa_api_trace.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace-input-json/out_kernel_trace.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace-input-json/out_marker_api_trace.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace-input-json/out_agent_info.csv)
|
||||
|
||||
set_tests_properties(
|
||||
rocprofv3-test-systrace-validate
|
||||
@@ -146,3 +253,16 @@ set_tests_properties(
|
||||
"AssertionError"
|
||||
ATTACHED_FILES_ON_FAIL
|
||||
"${SYS_VALIDATION_FILES}")
|
||||
|
||||
set_tests_properties(
|
||||
rocprofv3-test-systrace-input-json-validate
|
||||
PROPERTIES TIMEOUT
|
||||
45
|
||||
LABELS
|
||||
"integration-tests"
|
||||
DEPENDS
|
||||
"rocprofv3-test-systrace-input-json-execute"
|
||||
FAIL_REGULAR_EXPRESSION
|
||||
"AssertionError"
|
||||
ATTACHED_FILES_ON_FAIL
|
||||
"${SYS_VALIDATION_FILES}")
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"jobs": [
|
||||
{
|
||||
"sys_trace": true,
|
||||
"output_file": "out",
|
||||
"output_format": [
|
||||
"csv",
|
||||
"json",
|
||||
"pftrace"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"jobs": [
|
||||
{
|
||||
"hsa_trace": true,
|
||||
"kernel_trace": true,
|
||||
"memory_copy_trace": true,
|
||||
"marker_trace": true,
|
||||
"output_file": "out",
|
||||
"output_format": [
|
||||
"csv",
|
||||
"json",
|
||||
"pftrace"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user