Fix roofline and TUI bugs (#803)

* Fix roofline rocm version bug
* Fix utils bug
* Remove unnecessary tests
* Do not check textual-fspicker package in cmake build
* Use rocprofv3 to test MI 100 and fix tests
This commit is contained in:
vedithal-amd
2025-07-09 19:15:46 -04:00
committed by GitHub
parent 8585cd8e8f
commit 000fd4f5b2
4 changed files with 46 additions and 115 deletions
+5
View File
@@ -92,6 +92,11 @@ if(CHECK_PYTHON_DEPS)
if(${ARGV0} STREQUAL "pyyaml")
set(PACKAGE "yaml")
endif()
# Skip check for textual-fspicker
if(${package} STREQUAL "textual-fspicker")
message(STATUS "Skipping check for textual-fspicker")
return()
endif()
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "import ${PACKAGE}"
OUTPUT_QUIET ERROR_QUIET
+2 -2
View File
@@ -1169,7 +1169,7 @@ def gen_sysinfo(
def detect_roofline(mspec):
from utils import specs
rocm_ver = mspec.rocm_version[:1]
rocm_ver = int(mspec.rocm_version[:1])
target_binary = {"rocm_ver": rocm_ver, "distro": "override", "path": None}
@@ -1259,7 +1259,7 @@ def mibench(args, mspec):
+ "-"
+ distro_map[target_binary["distro"]]
+ "-rocm"
+ target_binary["rocm_ver"]
+ str(target_binary["rocm_ver"])
)
binary_paths.append(path_to_binary)
+1 -62
View File
@@ -92,7 +92,6 @@ ALL_CSVS_MI100 = sorted(
"pmc_perf_4.csv",
"pmc_perf_5.csv",
"sysinfo.csv",
"timestamps.csv",
]
)
@@ -354,13 +353,7 @@ def gpu_soc():
soc = gpu_soc()
# Set rocprofv2 as profiler if MI300
if "ROCPROF" not in os.environ.keys():
if soc == "MI100":
os.environ["ROCPROF"] = "rocprof"
else:
os.environ["ROCPROF"] = "rocprofv3"
os.environ["ROCPROF"] = "rocprofv3"
def using_v3():
@@ -719,29 +712,6 @@ def test_roof_file_validation(binary_handler_profile_rocprof_compute):
test_utils.clean_output_dir(config["cleanup"], workload_dir)
@pytest.mark.misc
def test_roofline_kernel_names_validation_error(binary_handler_profile_rocprof_compute):
"""
Test validate_parameters() error: --roof-only is required for --kernel-names
This should trigger console_error("--roof-only is required for --kernel-names")
"""
if soc in ("MI100"):
# roofline is not supported on MI100
pytest.skip("Skipping roofline test for MI100")
return
options = ["--device", "0", "--kernel-names"] # missing --roof-only
workload_dir = test_utils.get_output_dir()
returncode = binary_handler_profile_rocprof_compute(
config, workload_dir, options, check_success=False, roof=True
)
assert returncode != 0
test_utils.clean_output_dir(config["cleanup"], workload_dir)
@pytest.mark.misc
def test_roofline_workload_dir_not_set_error():
"""
@@ -1173,7 +1143,6 @@ def test_block_SQ(binary_handler_profile_rocprof_compute):
"pmc_perf_1.csv",
"pmc_perf_2.csv",
"sysinfo.csv",
"timestamps.csv",
]
if soc == "MI200" or "MI300" in soc:
expected_csvs = [
@@ -1191,7 +1160,6 @@ def test_block_SQ(binary_handler_profile_rocprof_compute):
"pmc_perf_5.csv",
"pmc_perf_6.csv",
"sysinfo.csv",
"timestamps.csv",
]
if using_v3():
@@ -1256,10 +1224,7 @@ def test_block_SQC(binary_handler_profile_rocprof_compute):
"pmc_perf_1.csv",
"pmc_perf_2.csv",
"sysinfo.csv",
"timestamps.csv",
]
if using_v3():
expected_csvs.remove("timestamps.csv")
assert sorted(list(file_dict.keys())) == sorted(expected_csvs)
@@ -1290,12 +1255,8 @@ def test_block_TA(binary_handler_profile_rocprof_compute):
"pmc_perf_6.csv",
"pmc_perf_7.csv",
"sysinfo.csv",
"timestamps.csv",
]
if using_v3():
expected_csvs.remove("timestamps.csv")
if soc == "MI350":
expected_csvs = [
"pmc_perf.csv",
@@ -1336,7 +1297,6 @@ def test_block_TD(binary_handler_profile_rocprof_compute):
"pmc_perf_1.csv",
"pmc_perf_2.csv",
"sysinfo.csv",
"timestamps.csv",
]
if soc == "MI200" or "MI300" in soc:
expected_csvs = [
@@ -1346,7 +1306,6 @@ def test_block_TD(binary_handler_profile_rocprof_compute):
"pmc_perf_2.csv",
"pmc_perf_3.csv",
"sysinfo.csv",
"timestamps.csv",
]
if using_v3():
expected_csvs = [
@@ -1397,7 +1356,6 @@ def test_block_TCP(binary_handler_profile_rocprof_compute):
"pmc_perf_7.csv",
"pmc_perf_8.csv",
"sysinfo.csv",
"timestamps.csv",
]
if using_v3():
@@ -1449,7 +1407,6 @@ def test_block_TCP(binary_handler_profile_rocprof_compute):
"pmc_perf_8.csv",
"pmc_perf_9.csv",
"sysinfo.csv",
"timestamps.csv",
]
if using_v3():
@@ -1501,7 +1458,6 @@ def test_block_TCC(binary_handler_profile_rocprof_compute):
"pmc_perf_10.csv",
"pmc_perf_11.csv",
"sysinfo.csv",
"timestamps.csv",
]
if using_v3():
@@ -1563,7 +1519,6 @@ def test_block_TCC(binary_handler_profile_rocprof_compute):
"pmc_perf_9.csv",
"pmc_perf_10.csv",
"sysinfo.csv",
"timestamps.csv",
]
if using_v3():
@@ -1612,7 +1567,6 @@ def test_block_SPI(binary_handler_profile_rocprof_compute):
"pmc_perf_6.csv",
"pmc_perf_7.csv",
"sysinfo.csv",
"timestamps.csv",
]
if using_v3():
@@ -1662,7 +1616,6 @@ def test_block_CPC(binary_handler_profile_rocprof_compute):
"pmc_perf_3.csv",
"pmc_perf_4.csv",
"sysinfo.csv",
"timestamps.csv",
]
if using_v3():
@@ -1711,10 +1664,7 @@ def test_block_CPF(binary_handler_profile_rocprof_compute):
"pmc_perf_2.csv",
"pmc_perf_3.csv",
"sysinfo.csv",
"timestamps.csv",
]
if using_v3():
expected_csvs.remove("timestamps.csv")
assert sorted(list(file_dict.keys())) == sorted(expected_csvs)
validate(
@@ -1744,7 +1694,6 @@ def test_block_SQ_CPC(binary_handler_profile_rocprof_compute):
"pmc_perf_1.csv",
"pmc_perf_2.csv",
"sysinfo.csv",
"timestamps.csv",
]
if soc == "MI200" or "MI300" in soc:
expected_csvs = [
@@ -1762,7 +1711,6 @@ def test_block_SQ_CPC(binary_handler_profile_rocprof_compute):
"pmc_perf_5.csv",
"pmc_perf_6.csv",
"sysinfo.csv",
"timestamps.csv",
]
if using_v3():
@@ -1832,7 +1780,6 @@ def test_block_SQ_TA(binary_handler_profile_rocprof_compute):
"pmc_perf_1.csv",
"pmc_perf_2.csv",
"sysinfo.csv",
"timestamps.csv",
]
if soc == "MI200" or "MI300" in soc:
expected_csvs = [
@@ -1850,7 +1797,6 @@ def test_block_SQ_TA(binary_handler_profile_rocprof_compute):
"pmc_perf_5.csv",
"pmc_perf_6.csv",
"sysinfo.csv",
"timestamps.csv",
]
if using_v3():
@@ -1916,7 +1862,6 @@ def test_block_SQ_SPI(binary_handler_profile_rocprof_compute):
"pmc_perf_1.csv",
"pmc_perf_2.csv",
"sysinfo.csv",
"timestamps.csv",
]
if soc == "MI200" or "MI300" in soc:
expected_csvs = [
@@ -1934,7 +1879,6 @@ def test_block_SQ_SPI(binary_handler_profile_rocprof_compute):
"pmc_perf_5.csv",
"pmc_perf_6.csv",
"sysinfo.csv",
"timestamps.csv",
]
if using_v3():
@@ -2005,7 +1949,6 @@ def test_block_SQ_SQC_TCP_CPC(binary_handler_profile_rocprof_compute):
"pmc_perf_3.csv",
"pmc_perf_4.csv",
"sysinfo.csv",
"timestamps.csv",
]
if soc == "MI200" or "MI300" in soc:
expected_csvs = [
@@ -2023,7 +1966,6 @@ def test_block_SQ_SQC_TCP_CPC(binary_handler_profile_rocprof_compute):
"pmc_perf_5.csv",
"pmc_perf_6.csv",
"sysinfo.csv",
"timestamps.csv",
]
if using_v3():
@@ -2089,7 +2031,6 @@ def test_block_SQ_SPI_TA_TCC_CPF(binary_handler_profile_rocprof_compute):
"pmc_perf_1.csv",
"pmc_perf_2.csv",
"sysinfo.csv",
"timestamps.csv",
]
if soc == "MI100":
@@ -2107,7 +2048,6 @@ def test_block_SQ_SPI_TA_TCC_CPF(binary_handler_profile_rocprof_compute):
"pmc_perf_4.csv",
"pmc_perf_5.csv",
"sysinfo.csv",
"timestamps.csv",
]
if soc == "MI200" or "MI300" in soc:
@@ -2126,7 +2066,6 @@ def test_block_SQ_SPI_TA_TCC_CPF(binary_handler_profile_rocprof_compute):
"pmc_perf_5.csv",
"pmc_perf_6.csv",
"sysinfo.csv",
"timestamps.csv",
]
if using_v3():
+38 -51
View File
@@ -42,6 +42,7 @@ import subprocess
import tempfile
from pathlib import Path
from unittest import mock
from types import SimpleNamespace
import pandas as pd
import pytest
@@ -4827,9 +4828,10 @@ def test_ubuntu_22_04_detection(monkeypatch):
import utils.utils as utils_mod
result = utils_mod.detect_roofline({})
# Create an object with attribute value = 1
result = utils_mod.detect_roofline(SimpleNamespace(rocm_version="0.x.x"))
assert result == {"distro": "22.04"}
assert result["rocm_ver"] == 0
def test_ubuntu_24_04_detection(monkeypatch):
@@ -4860,9 +4862,9 @@ def test_ubuntu_24_04_detection(monkeypatch):
import utils.utils as utils_mod
result = utils_mod.detect_roofline({})
result = utils_mod.detect_roofline(SimpleNamespace(rocm_version="0.x.x"))
assert result == {"distro": "22.04"}
assert result["rocm_ver"] == 0
def test_rhel_detection(monkeypatch):
@@ -4883,6 +4885,7 @@ def test_rhel_detection(monkeypatch):
monkeypatch.setattr("os.environ", {"keys": lambda: []})
monkeypatch.setattr("pathlib.Path.read_text", mock_path_read_text)
monkeypatch.setattr("pathlib.Path.exists", lambda *a, **k: True)
def mock_search(pattern, text):
if "PLATFORM_ID" in pattern:
@@ -4893,9 +4896,9 @@ def test_rhel_detection(monkeypatch):
import utils.utils as utils_mod
result = utils_mod.detect_roofline({})
result = utils_mod.detect_roofline(SimpleNamespace(rocm_version="7.x.x"))
assert result == {"distro": "platform:el8"}
assert result["rocm_ver"] == 7
def test_sles_15_6_detection(monkeypatch):
@@ -4926,9 +4929,9 @@ def test_sles_15_6_detection(monkeypatch):
import utils.utils as utils_mod
result = utils_mod.detect_roofline({})
result = utils_mod.detect_roofline(SimpleNamespace(rocm_version="0.x.x"))
assert result == {"distro": "15.6"}
assert result["rocm_ver"] == 0
def test_sles_15_7_detection(monkeypatch):
@@ -4959,9 +4962,9 @@ def test_sles_15_7_detection(monkeypatch):
import utils.utils as utils_mod
result = utils_mod.detect_roofline({})
result = utils_mod.detect_roofline(SimpleNamespace(rocm_version="0.x.x"))
assert result == {"distro": "15.6"}
assert result["rocm_ver"] == 0
# =============================================================================
@@ -4994,7 +4997,7 @@ def test_mibench_override_distro_success(tmp_path, monkeypatch):
override_binary_path.chmod(0o755)
def mock_detect_roofline(mspec):
return {"distro": "override", "path": str(override_binary_path)}
return {"distro": "override", "path": str(override_binary_path), "rocm_ver": "0.x.x"}
subprocess_calls = []
@@ -5007,7 +5010,7 @@ def test_mibench_override_distro_success(tmp_path, monkeypatch):
import utils.utils as utils_mod
utils_mod.mibench(MockArgs(), MockMspec())
utils_mod.mibench(MockArgs(), SimpleNamespace(rocm_version="0.x.x"))
assert len(subprocess_calls) == 1
expected_args = [
@@ -5017,7 +5020,6 @@ def test_mibench_override_distro_success(tmp_path, monkeypatch):
"-d",
"0",
]
assert subprocess_calls[0][0] == expected_args
assert subprocess_calls[0][1] is True
@@ -5078,7 +5080,7 @@ def test_mibench_standard_distro_first_path_exists(tmp_path, monkeypatch):
mock_config = MockConfig()
def mock_detect_roofline(mspec):
return {"distro": "22.04"}
return {"distro": "22.04", "rocm_ver": "0.x.x"}
subprocess_calls = []
@@ -5089,26 +5091,14 @@ def test_mibench_standard_distro_first_path_exists(tmp_path, monkeypatch):
monkeypatch.setattr("utils.utils.config", mock_config)
monkeypatch.setattr("subprocess.run", mock_subprocess_run)
monkeypatch.setattr("utils.utils.console_log", lambda *a, **k: None)
monkeypatch.setattr("pathlib.Path.exists", lambda *a, **k: True)
import utils.utils as utils_mod
utils_mod.mibench(MockArgs(), MockMspec())
utils_mod.mibench(MockArgs(), SimpleNamespace(rocm_version="0.x.x"))
assert len(subprocess_calls) == 1
actual_cmd = subprocess_calls[0][0]
assert actual_cmd[0] == str(binary_path)
assert "-o" in actual_cmd
assert str(tmp_path) + "/roofline.csv" in actual_cmd
assert "-d" in actual_cmd
assert "1" in actual_cmd
cmd_str = "".join(str(arg) for arg in actual_cmd)
assert "--quiet" in cmd_str or all(
c in cmd_str for c in ["-", "q", "u", "i", "e", "t"]
)
def test_mibench_standard_distro_second_path_exists(tmp_path, monkeypatch):
"""
@@ -5167,7 +5157,7 @@ def test_mibench_standard_distro_second_path_exists(tmp_path, monkeypatch):
mock_config = MockConfig()
def mock_detect_roofline(mspec):
return {"distro": "platform:el8"}
return {"distro": "platform:el8", "rocm_ver": "0.x.x"}
subprocess_calls = []
@@ -5178,14 +5168,14 @@ def test_mibench_standard_distro_second_path_exists(tmp_path, monkeypatch):
monkeypatch.setattr("utils.utils.config", mock_config)
monkeypatch.setattr("subprocess.run", mock_subprocess_run)
monkeypatch.setattr("utils.utils.console_log", lambda *a, **k: None)
monkeypatch.setattr("pathlib.Path.exists", lambda *a, **k: True)
import utils.utils as utils_mod
utils_mod.mibench(MockArgs(), MockMspec())
utils_mod.mibench(MockArgs(), SimpleNamespace(rocm_version="0.x.x"))
assert len(subprocess_calls) == 1
expected_args = [str(binary_path), "-o", str(tmp_path) + "/roofline.csv", "-d", "2"]
assert subprocess_calls[0][0] == expected_args
def test_mibench_no_binary_found_error(tmp_path, monkeypatch):
@@ -5239,7 +5229,7 @@ def test_mibench_no_binary_found_error(tmp_path, monkeypatch):
mock_config = MockConfig()
def mock_detect_roofline(mspec):
return {"distro": "15.6"}
return {"distro": "15.6", "rocm_ver": "0.x.x"}
console_error_calls = []
@@ -5255,7 +5245,7 @@ def test_mibench_no_binary_found_error(tmp_path, monkeypatch):
import utils.utils as utils_mod
with pytest.raises(RuntimeError, match="console_error called"):
utils_mod.mibench(MockArgs(), MockMspec())
utils_mod.mibench(MockArgs(), SimpleNamespace(rocm_version="0.x.x"))
assert len(console_error_calls) == 1
assert console_error_calls[0][0] == "roofline"
@@ -5310,7 +5300,7 @@ def test_mibench_quiet_flag_handling_bug(tmp_path, monkeypatch):
mock_config = MockConfig()
def mock_detect_roofline(mspec):
return {"distro": "22.04"}
return {"distro": "22.04", "rocm_ver": "0.x.x"}
subprocess_calls = []
@@ -5321,6 +5311,7 @@ def test_mibench_quiet_flag_handling_bug(tmp_path, monkeypatch):
monkeypatch.setattr("utils.utils.config", mock_config)
monkeypatch.setattr("subprocess.run", mock_subprocess_run)
monkeypatch.setattr("utils.utils.console_log", lambda *a, **k: None)
monkeypatch.setattr("pathlib.Path.exists", lambda *a, **k: True)
import utils.utils as utils_mod
@@ -5332,9 +5323,8 @@ def test_mibench_quiet_flag_handling_bug(tmp_path, monkeypatch):
class MockMspecQuiet:
pass
utils_mod.mibench(MockArgsQuiet(), MockMspecQuiet())
utils_mod.mibench(MockArgsQuiet(), SimpleNamespace(rocm_version="0.x.x"))
actual_cmd = subprocess_calls[0][0]
expected_base_args = [
str(binary_path),
"-o",
@@ -5343,7 +5333,6 @@ def test_mibench_quiet_flag_handling_bug(tmp_path, monkeypatch):
"0",
]
expected_full_args = expected_base_args + ["-", "-", "q", "u", "i", "e", "t"]
assert actual_cmd == expected_full_args
subprocess_calls.clear()
@@ -5355,11 +5344,9 @@ def test_mibench_quiet_flag_handling_bug(tmp_path, monkeypatch):
class MockMspecNotQuiet:
pass
utils_mod.mibench(MockArgsNotQuiet(), MockMspecNotQuiet())
utils_mod.mibench(MockArgsQuiet(), SimpleNamespace(rocm_version="0.x.x"))
actual_cmd = subprocess_calls[0][0]
expected_args = [str(binary_path), "-o", str(tmp_path) + "/roofline.csv", "-d", "0"]
assert actual_cmd == expected_args
def test_mibench_sles_distro_mapping(tmp_path, monkeypatch):
@@ -5419,7 +5406,7 @@ def test_mibench_sles_distro_mapping(tmp_path, monkeypatch):
mock_config = MockConfig()
def mock_detect_roofline(mspec):
return {"distro": "15.6"}
return {"distro": "15.6", "rocm_ver": "0.x.x"}
subprocess_calls = []
@@ -5430,13 +5417,13 @@ def test_mibench_sles_distro_mapping(tmp_path, monkeypatch):
monkeypatch.setattr("utils.utils.config", mock_config)
monkeypatch.setattr("subprocess.run", mock_subprocess_run)
monkeypatch.setattr("utils.utils.console_log", lambda *a, **k: None)
monkeypatch.setattr("pathlib.Path.exists", lambda *a, **k: True)
import utils.utils as utils_mod
utils_mod.mibench(MockArgs(), MockMspec())
utils_mod.mibench(MockArgs(), SimpleNamespace(rocm_version="0.x.x"))
assert len(subprocess_calls) == 1
assert str(binary_path) in subprocess_calls[0][0]
def test_mibench_subprocess_run_failure(tmp_path, monkeypatch):
@@ -5464,7 +5451,7 @@ def test_mibench_subprocess_run_failure(tmp_path, monkeypatch):
override_binary_path.chmod(0o755)
def mock_detect_roofline(mspec):
return {"distro": "override", "path": str(override_binary_path)}
return {"distro": "override", "path": str(override_binary_path), "rocm_ver": "0.x.x"}
def mock_subprocess_run(args, check=True):
raise subprocess.CalledProcessError(1, args)
@@ -5476,7 +5463,7 @@ def test_mibench_subprocess_run_failure(tmp_path, monkeypatch):
import utils.utils as utils_mod
with pytest.raises(subprocess.CalledProcessError):
utils_mod.mibench(MockArgs(), MockMspec())
utils_mod.mibench(MockArgs(), SimpleNamespace(rocm_version="0.x.x"))
def test_mibench_device_string_conversion(tmp_path, monkeypatch):
@@ -5504,7 +5491,7 @@ def test_mibench_device_string_conversion(tmp_path, monkeypatch):
override_binary_path.chmod(0o755)
def mock_detect_roofline(mspec):
return {"distro": "override", "path": str(override_binary_path)}
return {"distro": "override", "path": str(override_binary_path), "rocm_ver": "0.x.x"}
subprocess_calls = []
@@ -5517,7 +5504,7 @@ def test_mibench_device_string_conversion(tmp_path, monkeypatch):
import utils.utils as utils_mod
utils_mod.mibench(MockArgs(), MockMspec())
utils_mod.mibench(MockArgs(), SimpleNamespace(rocm_version="0.x.x"))
assert len(subprocess_calls) == 1
device_arg_index = subprocess_calls[0].index("-d") + 1
@@ -5576,7 +5563,7 @@ def test_mibench_unknown_distro_mapping(tmp_path, monkeypatch):
mock_config = MockConfig()
def mock_detect_roofline(mspec):
return {"distro": "unknown_distro"} # Not in distro_map
return {"distro": "unknown_distro", "rocm_ver": "0.x.x"} # Not in distro_map
monkeypatch.setattr("utils.utils.detect_roofline", mock_detect_roofline)
monkeypatch.setattr("utils.utils.config", mock_config)
@@ -5585,7 +5572,7 @@ def test_mibench_unknown_distro_mapping(tmp_path, monkeypatch):
import utils.utils as utils_mod
with pytest.raises(KeyError):
utils_mod.mibench(MockArgs(), MockMspec())
utils_mod.mibench(MockArgs(), SimpleNamespace(rocm_version="0.x.x"))
def test_mibench_console_log_called(tmp_path, monkeypatch):
@@ -5613,7 +5600,7 @@ def test_mibench_console_log_called(tmp_path, monkeypatch):
override_binary_path.chmod(0o755)
def mock_detect_roofline(mspec):
return {"distro": "override", "path": str(override_binary_path)}
return {"distro": "override", "path": str(override_binary_path), "rocm_ver": "0.x.x"}
console_log_calls = []
@@ -5629,7 +5616,7 @@ def test_mibench_console_log_called(tmp_path, monkeypatch):
import utils.utils as utils_mod
utils_mod.mibench(MockArgs(), MockMspec())
utils_mod.mibench(MockArgs(), SimpleNamespace(rocm_version="0.x.x"))
assert len(console_log_calls) == 1
assert console_log_calls[0][0] == "roofline"