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
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
8585cd8e8f
Коммит
000fd4f5b2
+38
-51
@@ -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"
|
||||
|
||||
Ссылка в новой задаче
Block a user