2024-01-22 19:06:25 -06:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
|
|
import csv
|
|
|
|
|
import pytest
|
2024-05-22 00:53:42 -05:00
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
from rocprofiler_sdk.pytest_utils.dotdict import dotdict
|
|
|
|
|
from rocprofiler_sdk.pytest_utils import collapse_dict_list
|
2024-05-22 15:51:12 -05:00
|
|
|
from rocprofiler_sdk.pytest_utils.perfetto_reader import PerfettoReader
|
2024-01-22 19:06:25 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def pytest_addoption(parser):
|
2024-04-09 05:25:28 -05:00
|
|
|
parser.addoption(
|
|
|
|
|
"--agent-input",
|
|
|
|
|
action="store",
|
|
|
|
|
help="Path to agent info CSV file.",
|
|
|
|
|
)
|
2024-01-22 19:06:25 -06:00
|
|
|
parser.addoption(
|
|
|
|
|
"--hsa-input",
|
|
|
|
|
action="store",
|
|
|
|
|
help="Path to HSA API tracing CSV file.",
|
|
|
|
|
)
|
|
|
|
|
parser.addoption(
|
|
|
|
|
"--kernel-input",
|
|
|
|
|
action="store",
|
|
|
|
|
help="Path to kernel tracing CSV file.",
|
|
|
|
|
)
|
|
|
|
|
parser.addoption(
|
|
|
|
|
"--memory-copy-input",
|
|
|
|
|
action="store",
|
|
|
|
|
help="Path to memory-copy tracing CSV file.",
|
|
|
|
|
)
|
2024-01-24 16:32:54 -06:00
|
|
|
parser.addoption(
|
|
|
|
|
"--marker-input",
|
|
|
|
|
action="store",
|
|
|
|
|
help="Path to marker API tracing CSV file.",
|
|
|
|
|
)
|
|
|
|
|
parser.addoption(
|
|
|
|
|
"--hip-input",
|
|
|
|
|
action="store",
|
|
|
|
|
help="Path to HIP runtime and compiler API tracing CSV file.",
|
|
|
|
|
)
|
2024-05-22 00:53:42 -05:00
|
|
|
parser.addoption(
|
|
|
|
|
"--json-input",
|
|
|
|
|
action="store",
|
|
|
|
|
help="Path to JSON file.",
|
|
|
|
|
)
|
2024-05-22 15:51:12 -05:00
|
|
|
parser.addoption(
|
|
|
|
|
"--pftrace-input",
|
|
|
|
|
action="store",
|
|
|
|
|
help="Path to Perfetto trace file.",
|
|
|
|
|
)
|
2024-01-22 19:06:25 -06:00
|
|
|
|
|
|
|
|
|
2024-04-09 05:25:28 -05:00
|
|
|
@pytest.fixture
|
|
|
|
|
def agent_info_input_data(request):
|
|
|
|
|
filename = request.config.getoption("--agent-input")
|
|
|
|
|
data = []
|
|
|
|
|
with open(filename, "r") as inp:
|
|
|
|
|
reader = csv.DictReader(inp)
|
|
|
|
|
for row in reader:
|
|
|
|
|
data.append(row)
|
|
|
|
|
|
|
|
|
|
return data
|
|
|
|
|
|
|
|
|
|
|
2024-01-22 19:06:25 -06:00
|
|
|
@pytest.fixture
|
|
|
|
|
def hsa_input_data(request):
|
|
|
|
|
filename = request.config.getoption("--hsa-input")
|
|
|
|
|
data = []
|
|
|
|
|
with open(filename, "r") as inp:
|
|
|
|
|
reader = csv.DictReader(inp)
|
|
|
|
|
for row in reader:
|
|
|
|
|
data.append(row)
|
|
|
|
|
|
|
|
|
|
return data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def kernel_input_data(request):
|
|
|
|
|
filename = request.config.getoption("--kernel-input")
|
|
|
|
|
data = []
|
|
|
|
|
with open(filename, "r") as inp:
|
|
|
|
|
reader = csv.DictReader(inp)
|
|
|
|
|
for row in reader:
|
|
|
|
|
data.append(row)
|
|
|
|
|
|
|
|
|
|
return data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def memory_copy_input_data(request):
|
|
|
|
|
filename = request.config.getoption("--memory-copy-input")
|
|
|
|
|
data = []
|
|
|
|
|
with open(filename, "r") as inp:
|
|
|
|
|
reader = csv.DictReader(inp)
|
|
|
|
|
for row in reader:
|
|
|
|
|
data.append(row)
|
|
|
|
|
|
|
|
|
|
return data
|
2024-01-24 16:32:54 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def marker_input_data(request):
|
|
|
|
|
filename = request.config.getoption("--marker-input")
|
|
|
|
|
data = []
|
|
|
|
|
with open(filename, "r") as inp:
|
|
|
|
|
reader = csv.DictReader(inp)
|
|
|
|
|
for row in reader:
|
|
|
|
|
data.append(row)
|
|
|
|
|
|
|
|
|
|
return data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def hip_input_data(request):
|
|
|
|
|
filename = request.config.getoption("--hip-input")
|
|
|
|
|
data = []
|
|
|
|
|
with open(filename, "r") as inp:
|
|
|
|
|
reader = csv.DictReader(inp)
|
|
|
|
|
for row in reader:
|
|
|
|
|
data.append(row)
|
|
|
|
|
|
|
|
|
|
return data
|
2024-05-22 00:53:42 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def json_data(request):
|
|
|
|
|
filename = request.config.getoption("--json-input")
|
|
|
|
|
with open(filename, "r") as inp:
|
|
|
|
|
return dotdict(collapse_dict_list(json.load(inp)))
|
2024-05-22 15:51:12 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def pftrace_data(request):
|
|
|
|
|
filename = request.config.getoption("--pftrace-input")
|
|
|
|
|
return PerfettoReader(filename).read()[0]
|