Refactor roofline binary detection (#933)

* Simplify the roofline binary pickup process by determining which base distribution the system OS is based off of, and select the correct binary.
* Add more OS distribution support to roofline by modifying the detection parameters and adding an AZL binary
* Update changelog to include roofline support additions

---------

Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com>
Bu işleme şunda yer alıyor:
cfallows-amd
2025-09-22 12:04:20 -04:00
işlemeyi yapan: GitHub
ebeveyn 0118184d22
işleme 9819e1cbfc
4 değiştirilmiş dosya ile 51 ekleme ve 51 silme
+2
Dosyayı Görüntüle
@@ -58,6 +58,8 @@ Full documentation for ROCm Compute Profiler is available at [https://rocm.docs.
* L1I-L2 Bandwidth
* sL1D-L2 BW
* Roofline support for Debian 12 and Azure Linux 3.0.
### Changed
* On memory chart, long string of numbers are displayed as scientific notation. It also solves the issue of overflow of displaying long number
İkili dosya gösterilmiyor.
+16 -21
Dosyayı Görüntüle
@@ -1159,10 +1159,13 @@ def detect_roofline(mspec: Any) -> dict[str, str]: # noqa: ANN401
"path": None,
}
# Create distro ID list based off of ID (a string, containing a single distro)
# and ID_LIKE (a string, listing at least one distro, separated by a single space)
# from the system /etc/os-release file
os_release = Path("/etc/os-release").read_text()
ubuntu_distro = specs.search(r'VERSION_ID="(.*?)"', os_release)
rhel_distro = specs.search(r'PLATFORM_ID="(.*?)"', os_release)
sles_distro = specs.search(r'VERSION_ID="(.*?)"', os_release)
id_list = specs.search(r'^ID_LIKE="?(.*?)"?$', os_release) or ""
id = specs.search(r'^ID="?(.*?)"?$', os_release) or ""
id_list = id_list.split() + [id]
if "ROOFLINE_BIN" in os.environ.keys():
rooflineBinary = os.environ["ROOFLINE_BIN"]
@@ -1181,28 +1184,19 @@ def detect_roofline(mspec: Any) -> dict[str, str]: # noqa: ANN401
f"ROOFLINE_BIN = {rooflineBinary}\n",
)
# Must be a valid RHEL machine
elif rhel_distro in {
"platform:el8",
"platform:al8",
"platform:el9",
"platform:el10",
}:
# check that the system OS is based off of one of the following distributions
elif "azurelinux" in id_list:
distro = "azurelinux"
elif "debian" in id_list:
distro = "22.04"
elif "fedora" in id_list:
distro = "platform:el8"
# Must be a valid SLES machine
elif (
isinstance(sles_distro, str)
and len(sles_distro) >= 3
and sles_distro[:2] == "15" # confirm string and len
and int(sles_distro[3]) >= 6 # SLES15 and SP >= 6
):
# Use SP6 binary for all forward compatible service pack versions
elif "suse" in id_list:
distro = "15.6"
# Must be a valid Ubuntu machine
elif ubuntu_distro in {"22.04", "24.04"}:
distro = "22.04"
else:
console_error(
"roofline", "Cannot find a valid binary for your operating system"
@@ -1221,6 +1215,7 @@ def mibench(args: argparse.Namespace, mspec: Any) -> None: # noqa: ANN401
"platform:el8": "rhel8",
"15.6": "sles15sp6",
"22.04": "ubuntu22_04",
"azurelinux": "azurelinux3",
}
binary_paths: list[str] = []
+33 -30
Dosyayı Görüntüle
@@ -4592,18 +4592,18 @@ def test_process_hip_trace_output_invalid_fbase_characters(tmp_path, monkeypatch
# ==============================================================================
def test_ubuntu_22_04_detection(monkeypatch):
def test_ubuntu_detection(monkeypatch):
"""
Test Ubuntu 22.04 detection.
Test Ubuntu detection.
Args:
monkeypatch (pytest.MonkeyPatch): Pytest fixture for patching
Returns:
Verifies that the function correctly identifies Ubuntu 22.04
and returns the appropriate distro
Verifies that the function correctly identifies Ubuntu and
returns the appropriate distro
"""
mock_os_release = 'VERSION_ID="22.04"\nNAME="Ubuntu"'
mock_os_release = "ID=ubuntu\nID_LIKE=debian"
def mock_path_read_text(self):
return mock_os_release
@@ -4613,8 +4613,8 @@ def test_ubuntu_22_04_detection(monkeypatch):
monkeypatch.setattr("pathlib.Path.read_text", mock_path_read_text)
def mock_search(pattern, text):
if "VERSION_ID" in pattern:
return "22.04"
if "ID_LIKE" in pattern:
return "debian"
return None
monkeypatch.setattr("utils.specs.search", mock_search)
@@ -4627,18 +4627,18 @@ def test_ubuntu_22_04_detection(monkeypatch):
assert result["rocm_ver"] == 0
def test_ubuntu_24_04_detection(monkeypatch):
def test_debian_detection(monkeypatch):
"""
Test Ubuntu 24.04 detection.
Test Debian detection.
Args:
monkeypatch (pytest.MonkeyPatch): Pytest fixture for patching
Returns:
Verifies that the function correctly identifies Ubuntu 24.04
Verifies that the function correctly identifies Debian
and returns the appropriate distro
"""
mock_os_release = 'VERSION_ID="24.04"\nNAME="Ubuntu"'
mock_os_release = "ID=debian"
def mock_path_read_text(self):
return mock_os_release
@@ -4648,14 +4648,15 @@ def test_ubuntu_24_04_detection(monkeypatch):
monkeypatch.setattr("pathlib.Path.read_text", mock_path_read_text)
def mock_search(pattern, text):
if "VERSION_ID" in pattern:
return "24.04"
if "ID" in pattern:
return "debian"
return None
monkeypatch.setattr("utils.specs.search", mock_search)
import utils.utils as utils_mod
# Create an object with attribute value = 1
result = utils_mod.detect_roofline(SimpleNamespace(rocm_version="0.x.x"))
assert result["rocm_ver"] == 0
@@ -4672,7 +4673,7 @@ def test_rhel_detection(monkeypatch):
Verifies that the function correctly identifies RHEL
and returns the appropriate distro
"""
mock_os_release = 'PLATFORM_ID="platform:el9"\nNAME="Red Hat Enterprise Linux"'
mock_os_release = 'ID_LIKE="rhel fedora"\nID="rhel"'
def mock_path_read_text(self):
return mock_os_release
@@ -4683,8 +4684,8 @@ def test_rhel_detection(monkeypatch):
monkeypatch.setattr("pathlib.Path.exists", lambda *a, **k: True)
def mock_search(pattern, text):
if "PLATFORM_ID" in pattern:
return "platform:el9"
if "ID_LIKE" in pattern:
return "rhel fedora"
return None
monkeypatch.setattr("utils.specs.search", mock_search)
@@ -4696,18 +4697,18 @@ def test_rhel_detection(monkeypatch):
assert result["rocm_ver"] == 7
def test_sles_15_6_detection(monkeypatch):
def test_azl_detection(monkeypatch):
"""
Test SLES 15.6 detection.
Test Azure Linux distro detection.
Args:
monkeypatch (pytest.MonkeyPatch): Pytest fixture for patching
Returns:
Verifies that the function correctly identifies SLES 15.6
Verifies that the function correctly identifies AZL
and returns the appropriate distro
"""
mock_os_release = 'VERSION_ID="15.6"\nNAME="SLES"'
mock_os_release = "ID=azurelinux"
def mock_path_read_text(self):
return mock_os_release
@@ -4715,32 +4716,34 @@ def test_sles_15_6_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 "VERSION_ID" in pattern:
return "15.6"
if "ID" in pattern:
return "azurelinux"
return None
monkeypatch.setattr("utils.specs.search", mock_search)
import utils.utils as utils_mod
result = utils_mod.detect_roofline(SimpleNamespace(rocm_version="0.x.x"))
result = utils_mod.detect_roofline(SimpleNamespace(rocm_version="7.x.x"))
assert result["rocm_ver"] == 0
assert result["rocm_ver"] == 7
def test_sles_15_7_detection(monkeypatch):
def test_sles_detection(monkeypatch):
"""
Test SLES 15.7 detection (edge case with higher service pack).
Test SLES detection.
Args:
monkeypatch (pytest.MonkeyPatch): Pytest fixture for patching
Returns:
Verifies that the function correctly handles newer SLES service packs
Verifies that the function correctly identifies SLES
and returns the appropriate distro
"""
mock_os_release = 'VERSION_ID="15.7"\nNAME="SLES"'
mock_os_release = 'ID="opensuse-leap"\nID_LIKE="suse opensuse"'
def mock_path_read_text(self):
return mock_os_release
@@ -4750,8 +4753,8 @@ def test_sles_15_7_detection(monkeypatch):
monkeypatch.setattr("pathlib.Path.read_text", mock_path_read_text)
def mock_search(pattern, text):
if "VERSION_ID" in pattern:
return "15.7"
if "ID_LIKE" in pattern:
return "suse openuse"
return None
monkeypatch.setattr("utils.specs.search", mock_search)