From 87a2c9089ce2df640dffffae511df182c81be3e6 Mon Sep 17 00:00:00 2001 From: YuriiPerets Date: Tue, 10 Sep 2024 00:05:48 +0300 Subject: [PATCH] Adding new filter rule: Remove all ROCm images older than Ubuntu 20.04 based --- src/bashi/filter_compiler.py | 9 + src/bashi/filter_software_dependency.py | 16 +- src/bashi/results.py | 35 ++++ tests/test_filter_software_dependency.py | 113 +++++++++++++ tests/test_hipcc_filter.py | 207 +++++++++++++++++++++++ tests/test_results.py | 136 +++++++++++++++ 6 files changed, 514 insertions(+), 2 deletions(-) diff --git a/src/bashi/filter_compiler.py b/src/bashi/filter_compiler.py index 9a20540..a4541d6 100644 --- a/src/bashi/filter_compiler.py +++ b/src/bashi/filter_compiler.py @@ -198,6 +198,15 @@ def compiler_filter( ): reason(output, "hipcc does not support the CUDA backend.") return False + # Rule: c19 + # all ROCm images are Ubuntu 20.04 based or newer + # related to rule d3 + if UBUNTU in row and row[UBUNTU].version < pkv.parse("20.04"): + reason( + output, + "ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04", + ) + return False if compiler in row and row[compiler].name == ICPX: # Rule: c12 diff --git a/src/bashi/filter_software_dependency.py b/src/bashi/filter_software_dependency.py index 9ddd4cb..6244a7e 100644 --- a/src/bashi/filter_software_dependency.py +++ b/src/bashi/filter_software_dependency.py @@ -11,7 +11,7 @@ import packaging.version as pkv from typeguard import typechecked from bashi.types import ParameterValueTuple -from bashi.globals import DEVICE_COMPILER, HOST_COMPILER, GCC, UBUNTU, CLANG_CUDA, CMAKE +from bashi.globals import * # pylint: disable=wildcard-import,unused-wildcard-import from bashi.utils import reason @@ -103,5 +103,17 @@ def software_dependency_filter( f"{row[CMAKE].version}", ) return False - + # Rule: d3 + # all ROCm images are Ubuntu 20.04 based or newer + # related to rule c19 + + if UBUNTU in row and row[UBUNTU].version < pkv.parse("20.04"): + if ALPAKA_ACC_GPU_HIP_ENABLE in row and row[ALPAKA_ACC_GPU_HIP_ENABLE].version != OFF_VER: + reason( + output, + "ROCm and also the hipcc compiler " + "is not available on Ubuntu " + "older than 20.04", + ) + return False return True diff --git a/src/bashi/results.py b/src/bashi/results.py index 2ba218c..bff2586 100644 --- a/src/bashi/results.py +++ b/src/bashi/results.py @@ -81,6 +81,9 @@ def get_expected_bashi_parameter_value_pairs( _remove_unsupported_cmake_versions_for_clangcuda( param_val_pair_list, removed_param_val_pair_list ) + _remove_all_rocm_images_older_than_ubuntu2004_based( + param_val_pair_list, removed_param_val_pair_list + ) return (param_val_pair_list, removed_param_val_pair_list) @@ -792,3 +795,35 @@ def _remove_unsupported_cmake_versions_for_clangcuda( value_name2=CMAKE, value_version2=">3.18", ) + + +def _remove_all_rocm_images_older_than_ubuntu2004_based( + parameter_value_pairs: List[ParameterValuePair], + removed_parameter_value_pairs: List[ParameterValuePair], +): + """Remove all pairs where Ubuntu is older than 20.04 and the HIP backend is enabled or the host + or device compiler is HIPCC. + Args: + parameter_value_pairs (List[ParameterValuePair]): List of parameter-value pairs. + """ + remove_parameter_value_pairs( + parameter_value_pairs, + removed_parameter_value_pairs, + parameter1=UBUNTU, + value_name1=UBUNTU, + value_version1=">=20.04", + parameter2=ALPAKA_ACC_GPU_HIP_ENABLE, + value_name2=ALPAKA_ACC_GPU_HIP_ENABLE, + value_version2=ON, + ) + for compiler_type in (HOST_COMPILER, DEVICE_COMPILER): + remove_parameter_value_pairs( + parameter_value_pairs, + removed_parameter_value_pairs, + parameter1=UBUNTU, + value_name1=UBUNTU, + value_version1=">=20.04", + parameter2=compiler_type, + value_name2=HIPCC, + value_version2=ANY_VERSION, + ) diff --git a/tests/test_filter_software_dependency.py b/tests/test_filter_software_dependency.py index edd695d..20419f1 100644 --- a/tests/test_filter_software_dependency.py +++ b/tests/test_filter_software_dependency.py @@ -189,3 +189,116 @@ def test_not_valid_cmake_versions_for_clangcuda_d2(self): reason_msg.getvalue(), f"device compiler CLANG_CUDA is not available in CMAKE {cmake_version}", ) + + def test_valid_ROCm_images_Ubuntu2004_based_d4(self): + for UBUNTU_version in ["20.04", "22.04", "21.04"]: + self.assertTrue( + software_dependency_filter_typechecked( + OD( + { + ALPAKA_ACC_GPU_HIP_ENABLE: ppv((ALPAKA_ACC_GPU_HIP_ENABLE, ON)), + UBUNTU: ppv((UBUNTU, UBUNTU_version)), + } + ), + ) + ) + + for UBUNTU_version in ["16.04", "18.04", "19.04", "20.04", "22.04", "21.04"]: + self.assertTrue( + software_dependency_filter_typechecked( + OD( + { + ALPAKA_ACC_GPU_HIP_ENABLE: ppv((ALPAKA_ACC_GPU_HIP_ENABLE, OFF)), + UBUNTU: ppv((UBUNTU, UBUNTU_version)), + } + ), + ), + ) + self.assertTrue( + software_dependency_filter_typechecked( + OD( + { + HOST_COMPILER: ppv((HIPCC, 1)), + DEVICE_COMPILER: ppv((HIPCC, 1)), + ALPAKA_ACC_GPU_HIP_ENABLE: ppv((ALPAKA_ACC_GPU_HIP_ENABLE, OFF)), + UBUNTU: ppv((UBUNTU, "18.04")), + } + ), + ), + ) + + def test_non_valid_ROCm_images_Ubuntu2004_based_d4(self): + for UBUNTU_version in ["16.04", "18.04", "19.04"]: + reason_msg = io.StringIO() + self.assertFalse( + software_dependency_filter_typechecked( + OD( + { + ALPAKA_ACC_GPU_HIP_ENABLE: ppv((ALPAKA_ACC_GPU_HIP_ENABLE, ON)), + UBUNTU: ppv((UBUNTU, UBUNTU_version)), + } + ), + reason_msg, + ), + f"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04", + ) + self.assertEqual( + reason_msg.getvalue(), + f"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04", + ) + + for host_name, device_name, hip_backend, ubuntu_version, error_msg in [ + ( + HIPCC, + HIPCC, + ON, + "18.04", + "ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04", + ), + ( + HIPCC, + GCC, + ON, + "18.04", + "ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04", + ), + ( + CLANG, + HIPCC, + ON, + "18.04", + "ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04", + ), + ( + GCC, + HIPCC, + ON, + "18.04", + "ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04", + ), + ( + HIPCC, + CLANG, + ON, + "18.04", + "ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04", + ), + ]: + test_row = OD( + { + HOST_COMPILER: ppv((host_name, 1)), + DEVICE_COMPILER: ppv((device_name, 1)), + ALPAKA_ACC_GPU_HIP_ENABLE: ppv((ALPAKA_ACC_GPU_HIP_ENABLE, hip_backend)), + UBUNTU: ppv((UBUNTU, ubuntu_version)), + }, + ) + reason_msg = io.StringIO() + self.assertFalse( + software_dependency_filter_typechecked(test_row, reason_msg), + f"{test_row}", + ) + self.assertEqual( + reason_msg.getvalue(), + error_msg, + f"{test_row}", + ) diff --git a/tests/test_hipcc_filter.py b/tests/test_hipcc_filter.py index c70d75a..f262ae9 100644 --- a/tests/test_hipcc_filter.py +++ b/tests/test_hipcc_filter.py @@ -728,6 +728,213 @@ def test_hipcc_requires_disabled_cuda_backend_not_pass_c11(self): ) self.assertEqual(reason_msg5.getvalue(), "hipcc does not support the CUDA backend.") + def test_hipcc_requires_ubuntu2004_pass_c19(self): + for version in (4.5, 5.3, 6.0): + self.assertTrue( + compiler_filter_typechecked( + OD( + { + HOST_COMPILER: ppv((HIPCC, version)), + UBUNTU: ppv((UBUNTU, "20.04")), + } + ) + ) + ) + + self.assertTrue( + compiler_filter_typechecked( + OD( + { + DEVICE_COMPILER: ppv((HIPCC, version)), + UBUNTU: ppv((UBUNTU, "20.04")), + } + ) + ) + ) + + self.assertTrue( + compiler_filter_typechecked( + OD( + { + HOST_COMPILER: ppv((HIPCC, version)), + UBUNTU: ppv((UBUNTU, "22.04")), + } + ) + ) + ) + + self.assertTrue( + compiler_filter_typechecked( + OD( + { + DEVICE_COMPILER: ppv((HIPCC, version)), + UBUNTU: ppv((UBUNTU, "22.04")), + } + ) + ) + ) + self.assertTrue( + compiler_filter_typechecked( + OD( + { + DEVICE_COMPILER: ppv((HIPCC, version)), + HOST_COMPILER: ppv((HIPCC, version)), + UBUNTU: ppv((UBUNTU, "22.04")), + } + ) + ) + ) + self.assertTrue( + compiler_filter_typechecked( + OD( + { + DEVICE_COMPILER: ppv((HIPCC, version)), + HOST_COMPILER: ppv((HIPCC, version)), + UBUNTU: ppv((UBUNTU, "20.04")), + } + ) + ) + ) + self.assertTrue( + compiler_filter_typechecked( + OD( + { + HOST_COMPILER: ppv((GCC, 1)), + DEVICE_COMPILER: ppv((GCC, 1)), + ALPAKA_ACC_GPU_HIP_ENABLE: ppv((ALPAKA_ACC_GPU_HIP_ENABLE, ON)), + UBUNTU: ppv((UBUNTU, "18.04")), + } + ), + ) + ) + + def test_hipcc_requires_ubuntu2004_not_pass_c19(self): + for version in (4.5, 5.3, 6.0): + reason_msg1 = io.StringIO() + self.assertFalse( + compiler_filter_typechecked( + OD( + { + HOST_COMPILER: ppv((HIPCC, version)), + UBUNTU: ppv((UBUNTU, "18.04")), + } + ), + reason_msg1, + ) + ) + self.assertEqual( + reason_msg1.getvalue(), + "ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04", + ) + + reason_msg2 = io.StringIO() + self.assertFalse( + compiler_filter_typechecked( + OD( + { + DEVICE_COMPILER: ppv((HIPCC, version)), + UBUNTU: ppv((UBUNTU, "18.04")), + } + ), + reason_msg2, + ) + ) + self.assertEqual( + reason_msg2.getvalue(), + "ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04", + ) + + reason_msg3 = io.StringIO() + self.assertFalse( + compiler_filter_typechecked( + OD( + { + HOST_COMPILER: ppv((HIPCC, version)), + DEVICE_COMPILER: ppv((HIPCC, version)), + UBUNTU: ppv((UBUNTU, "18.04")), + } + ), + reason_msg3, + ) + ) + self.assertEqual( + reason_msg3.getvalue(), + "ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04", + ) + + reason_msg4 = io.StringIO() + self.assertFalse( + compiler_filter_typechecked( + OD( + { + HOST_COMPILER: ppv((HIPCC, version)), + DEVICE_COMPILER: ppv((HIPCC, version)), + UBUNTU: ppv((UBUNTU, "16.04")), + } + ), + reason_msg4, + ) + ) + self.assertEqual( + reason_msg4.getvalue(), + "ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04", + ) + for host_name, device_name, hip_backend, ubuntu_version, error_msg in [ + ( + HIPCC, + HIPCC, + ON, + "18.04", + "ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04", + ), + ( + HIPCC, + GCC, + ON, + "18.04", + "host and device compiler name must be the same (except for nvcc)", + ), + ( + CLANG, + HIPCC, + ON, + "18.04", + "host and device compiler name must be the same (except for nvcc)", + ), + ( + GCC, + HIPCC, + OFF, + "18.04", + "host and device compiler name must be the same (except for nvcc)", + ), + ( + HIPCC, + CLANG, + OFF, + "18.04", + "host and device compiler name must be the same (except for nvcc)", + ), + ]: + test_row = OD( + { + HOST_COMPILER: ppv((host_name, 1)), + DEVICE_COMPILER: ppv((device_name, 1)), + ALPAKA_ACC_GPU_HIP_ENABLE: ppv((ALPAKA_ACC_GPU_HIP_ENABLE, hip_backend)), + UBUNTU: ppv((UBUNTU, ubuntu_version)), + }, + ) + reason_msg = io.StringIO() + self.assertFalse( + compiler_filter_typechecked(test_row, reason_msg), + f"{test_row}", + ) + self.assertEqual( + reason_msg.getvalue(), + error_msg, + f"{test_row}", + ) + def test_hip_and_cuda_backend_cannot_be_active_at_the_same_time_b3(self): self.assertTrue( backend_filter_typechecked( diff --git a/tests/test_results.py b/tests/test_results.py index dd27269..4702fa8 100644 --- a/tests/test_results.py +++ b/tests/test_results.py @@ -44,6 +44,7 @@ _remove_unsupported_clang_sdk_versions_for_clang_cuda, _remove_unsupported_gcc_versions_for_ubuntu2004, _remove_unsupported_cmake_versions_for_clangcuda, + _remove_all_rocm_images_older_than_ubuntu2004_based, ) from bashi.versions import NvccHostSupport, NVCC_GCC_MAX_VERSION @@ -2356,3 +2357,138 @@ def test_remove_unsupported_cmake_versions_for_clangcuda(self): expected_results, create_diff_parameter_value_pairs(test_param_value_pairs, expected_results), ) + + def test_remove_all_rocm_images_older_than_ubuntu2004_based(self): + test_param_value_pairs: List[ParameterValuePair] = parse_expected_val_pairs( + [ + OD( + { + ALPAKA_ACC_GPU_HIP_ENABLE: (ALPAKA_ACC_GPU_HIP_ENABLE, OFF), + UBUNTU: (UBUNTU, "20.04"), + } + ), + OD( + { + HOST_COMPILER: (HIPCC, "4"), + UBUNTU: (UBUNTU, "20.04"), + } + ), + OD( + { + HOST_COMPILER: (HIPCC, "6"), + UBUNTU: (UBUNTU, "20.04"), + } + ), + OD( + { + HOST_COMPILER: (HIPCC, "6"), + UBUNTU: (UBUNTU, "16.04"), + } + ), + OD( + { + HOST_COMPILER: (HIPCC, "8"), + UBUNTU: (UBUNTU, "22.04"), + } + ), + OD( + { + DEVICE_COMPILER: (HIPCC, "7"), + UBUNTU: (UBUNTU, "18.04"), + } + ), + OD( + { + ALPAKA_ACC_GPU_HIP_ENABLE: (ALPAKA_ACC_GPU_HIP_ENABLE, ON), + UBUNTU: (UBUNTU, "22.04"), + } + ), + OD( + { + ALPAKA_ACC_GPU_HIP_ENABLE: (ALPAKA_ACC_GPU_HIP_ENABLE, OFF), + UBUNTU: (UBUNTU, "22.04"), + } + ), + OD( + { + ALPAKA_ACC_GPU_HIP_ENABLE: (ALPAKA_ACC_GPU_HIP_ENABLE, OFF), + UBUNTU: (UBUNTU, "18.04"), + } + ), + OD( + { + ALPAKA_ACC_GPU_HIP_ENABLE: (ALPAKA_ACC_GPU_HIP_ENABLE, ON), + UBUNTU: (UBUNTU, "18.04"), + } + ), + OD( + { + ALPAKA_ACC_GPU_HIP_ENABLE: (ALPAKA_ACC_GPU_HIP_ENABLE, ON), + UBUNTU: (UBUNTU, "20.04"), + } + ), + ] + ) + expected_results = parse_expected_val_pairs( + [ + OD( + { + HOST_COMPILER: (HIPCC, "8"), + UBUNTU: (UBUNTU, "22.04"), + } + ), + OD( + { + HOST_COMPILER: (HIPCC, "4"), + UBUNTU: (UBUNTU, "20.04"), + } + ), + OD( + { + HOST_COMPILER: (HIPCC, "6"), + UBUNTU: (UBUNTU, "20.04"), + } + ), + OD( + { + ALPAKA_ACC_GPU_HIP_ENABLE: (ALPAKA_ACC_GPU_HIP_ENABLE, OFF), + UBUNTU: (UBUNTU, "20.04"), + } + ), + OD( + { + ALPAKA_ACC_GPU_HIP_ENABLE: (ALPAKA_ACC_GPU_HIP_ENABLE, ON), + UBUNTU: (UBUNTU, "20.04"), + } + ), + OD( + { + ALPAKA_ACC_GPU_HIP_ENABLE: (ALPAKA_ACC_GPU_HIP_ENABLE, ON), + UBUNTU: (UBUNTU, "22.04"), + } + ), + OD( + { + ALPAKA_ACC_GPU_HIP_ENABLE: (ALPAKA_ACC_GPU_HIP_ENABLE, OFF), + UBUNTU: (UBUNTU, "22.04"), + } + ), + OD( + { + ALPAKA_ACC_GPU_HIP_ENABLE: (ALPAKA_ACC_GPU_HIP_ENABLE, OFF), + UBUNTU: (UBUNTU, "18.04"), + } + ), + ] + ) + default_remove_test( + _remove_all_rocm_images_older_than_ubuntu2004_based, + test_param_value_pairs, + expected_results, + self, + ) + self.assertEqual( + test_param_value_pairs, + expected_results, + create_diff_parameter_value_pairs(test_param_value_pairs, expected_results), + )