2024-03-07 22:21:26 -06:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
2024-01-22 19:06:25 -06:00
|
|
|
import sys
|
|
|
|
|
import pytest
|
2024-03-07 22:21:26 -06:00
|
|
|
import numpy as np
|
|
|
|
|
import pandas as pd
|
2024-04-02 01:39:24 -05:00
|
|
|
import re
|
2024-01-22 19:06:25 -06:00
|
|
|
|
2024-03-07 22:21:26 -06:00
|
|
|
kernel_list = sorted(
|
|
|
|
|
["addition_kernel", "subtract_kernel", "multiply_kernel", "divide_kernel"]
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def unique(lst):
|
|
|
|
|
return list(set(lst))
|
2024-02-29 04:38:28 +05:30
|
|
|
|
2024-01-22 19:06:25 -06:00
|
|
|
|
|
|
|
|
def test_validate_counter_collection_pmc1(input_data: pd.DataFrame):
|
|
|
|
|
df = input_data
|
|
|
|
|
|
2024-03-07 22:21:26 -06:00
|
|
|
assert not df.empty
|
2024-02-29 04:38:28 +05:30
|
|
|
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()
|
2024-03-07 22:21:26 -06:00
|
|
|
assert len(df["Kernel_Name"]) > 0
|
|
|
|
|
|
2024-04-02 01:39:24 -05:00
|
|
|
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
|
2024-03-07 22:21:26 -06:00
|
|
|
|
|
|
|
|
kernel_count = dict([[itr, 0] for itr in kernel_list])
|
|
|
|
|
assert len(kernel_count) == len(kernel_list)
|
|
|
|
|
for itr in df["Kernel_Name"]:
|
2024-04-02 01:39:24 -05:00
|
|
|
if re.search(r"__amd_rocclr_.*", itr):
|
|
|
|
|
continue
|
2024-03-07 22:21:26 -06:00
|
|
|
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
|
|
|
|
|
|
2024-02-29 04:38:28 +05:30
|
|
|
assert len(df["Counter_Value"]) > 0
|
2024-03-07 22:21:26 -06:00
|
|
|
assert df["Counter_Name"].str.contains("SQ_WAVES").all()
|
|
|
|
|
assert (df["Counter_Value"].astype(int).values > 0).all()
|
|
|
|
|
|
|
|
|
|
di_list = df["Dispatch_Id"].astype(int).values.tolist()
|
|
|
|
|
di_uniq = sorted(df["Dispatch_Id"].unique().tolist())
|
|
|
|
|
# make sure the dispatch ids are unique and ordered
|
|
|
|
|
di_expect = [idx + 1 for idx in range(len(di_list))]
|
|
|
|
|
assert di_expect == di_uniq
|
2024-01-22 19:06:25 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
exit_code = pytest.main(["-x", __file__] + sys.argv[1:])
|
|
|
|
|
sys.exit(exit_code)
|