Files
rocm-systems/tests/rocprofv3/pc-sampling/host-trap/transpose-multiple-agents/validate.py
T
Rawat, Swati 97b7a6315d update copyright date to 2025 (#102)
* Update LICENSE

* Update conf.py

* Update copyright year

* [fix] Update copyright year

* Update copyright year "ROCm Developer Tools"

* Add license headers to c++ files

* Add license to *.py

* Update licenses in rocdecode sources

---------

Co-authored-by: srawat <120587655+SwRaw@users.noreply.github.com>
Co-authored-by: Mythreya <mythreya.kuricheti@amd.com>
Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
2025-01-22 19:11:20 -06:00

87 lines
3.3 KiB
Python

#!/usr/bin/env python3
# MIT License
#
# Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import itertools
import sys
import pytest
import numpy as np
import pandas as pd
def test_multi_agent_support(
input_samples_csv: pd.DataFrame,
input_kernel_trace_csv: pd.DataFrame,
input_agent_info_csv: pd.DataFrame,
):
transpose_kernel_source_line_start = 137
transpose_kernel_source_line_end = 145
mi2xx_mi3xx_agents_df = input_agent_info_csv[
input_agent_info_csv["Name"].apply(
lambda name: name == "gfx90a" or name.startswith("gfx94")
)
]
# Extract samples that originates from know code object it
samples_df = input_samples_csv[input_samples_csv["Dispatch_Id"] != 0].copy()
# Determine the agent on which sample was generated
samples_df["Agent_Id"] = (
samples_df["Dispatch_Id"]
.map(input_kernel_trace_csv.set_index("Dispatch_Id")["Agent_Id"])
.astype(np.uint64)
)
sampled_agents = samples_df["Agent_Id"].unique()
sampled_agents_num = len(sampled_agents)
# all agents must be sampled
assert sampled_agents_num == len(mi2xx_mi3xx_agents_df)
# separate samples per agents
grouped_samples_per_agent = samples_df.groupby("Agent_Id")
for agent_id, agent_samples_df in grouped_samples_per_agent:
sampled_dispatches = agent_samples_df["Dispatch_Id"].unique()
# at least 1 sampled dispatch per agent
assert len(sampled_dispatches) >= 1
# extract decoded samples that are mapped to the transpose.cpp file
transpose_samples_df = samples_df[
samples_df["Instruction_Comment"].apply(
lambda comment: "transpose-all-agents.cpp" in comment
)
].copy()
# determine the line number for each sample
transpose_samples_df["Source_Line_Num"] = transpose_samples_df[
"Instruction_Comment"
].apply(lambda source_line: int(source_line.split(":")[-1]))
# assert that line belongs to a kernel range
assert (
(transpose_samples_df["Source_Line_Num"] >= transpose_kernel_source_line_start)
& (transpose_samples_df["Source_Line_Num"] <= transpose_kernel_source_line_end)
).all()
if __name__ == "__main__":
exit_code = pytest.main(["-x", __file__] + sys.argv[1:])
sys.exit(exit_code)