diff --git a/projects/rocprofiler-compute/CHANGELOG.md b/projects/rocprofiler-compute/CHANGELOG.md index b385de2a1f..6a3424106d 100644 --- a/projects/rocprofiler-compute/CHANGELOG.md +++ b/projects/rocprofiler-compute/CHANGELOG.md @@ -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 diff --git a/projects/rocprofiler-compute/src/utils/rooflines/roofline-azurelinux3-rocm7 b/projects/rocprofiler-compute/src/utils/rooflines/roofline-azurelinux3-rocm7 new file mode 100755 index 0000000000..ecc2de60ac Binary files /dev/null and b/projects/rocprofiler-compute/src/utils/rooflines/roofline-azurelinux3-rocm7 differ diff --git a/projects/rocprofiler-compute/src/utils/utils.py b/projects/rocprofiler-compute/src/utils/utils.py index 4e963bf764..d331365ccd 100644 --- a/projects/rocprofiler-compute/src/utils/utils.py +++ b/projects/rocprofiler-compute/src/utils/utils.py @@ -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] = [] diff --git a/projects/rocprofiler-compute/tests/test_utils.py b/projects/rocprofiler-compute/tests/test_utils.py index 2b950fe322..4d34623a11 100644 --- a/projects/rocprofiler-compute/tests/test_utils.py +++ b/projects/rocprofiler-compute/tests/test_utils.py @@ -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)