Skip to content

Commit

Permalink
Adding new filter rule: All ROCm images are Ubuntu 20.04 based
Browse files Browse the repository at this point in the history
  • Loading branch information
YuriiPerets committed Sep 11, 2024
1 parent cc789bd commit 9abf557
Show file tree
Hide file tree
Showing 6 changed files with 363 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/bashi/filter_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ def compiler_filter(
):
reason(output, "hipcc does not support the CUDA backend.")
return False
# Rule: c19
#
if UBUNTU in row and row[UBUNTU].version < pkv.parse("20.04"):
reason(output, "hipcc does not support UBUNTU as compiler older than 20.04")
return False

if compiler in row and row[compiler].name == ICPX:
# Rule: c12
Expand Down
15 changes: 13 additions & 2 deletions src/bashi/filter_software_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -103,5 +103,16 @@ def software_dependency_filter(
f"{row[CMAKE].version}",
)
return False

# Rule: d4
# all ROCm images are Ubuntu 20.04 based

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,
f"ROCm images "
"is not available in UBUNTU "
f"{__ubuntu_version_to_string(row[UBUNTU].version)}",
)
return False
return True
28 changes: 28 additions & 0 deletions src/bashi/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ 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_non_ubuntu2004_based(param_val_pair_list, removed_param_val_pair_list)
return (param_val_pair_list, removed_param_val_pair_list)


Expand Down Expand Up @@ -792,3 +793,30 @@ def _remove_unsupported_cmake_versions_for_clangcuda(
value_name2=CMAKE,
value_version2=">3.18",
)


def _remove_all_rocm_images_non_ubuntu2004_based(
parameter_value_pairs: List[ParameterValuePair],
removed_parameter_value_pairs: List[ParameterValuePair],
):
remove_parameter_value_pairs(
parameter_value_pairs,
removed_parameter_value_pairs,
value_name1=UBUNTU,
parameter1=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,
value_name1=UBUNTU,
parameter1=UBUNTU,
value_version1=">=20.04",
parameter2=compiler_type,
value_name2=HIPCC,
value_version2=ANY_VERSION,
)
45 changes: 45 additions & 0 deletions tests/test_filter_software_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,48 @@ 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)),
}
),
),
)

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 images is not available in UBUNTU {UBUNTU_version}",
)
self.assertEqual(
reason_msg.getvalue(),
f"ROCm images is not available in UBUNTU {UBUNTU_version}",
)
136 changes: 136 additions & 0 deletions tests/test_hipcc_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,142 @@ 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")),
}
)
)
)

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(), "hipcc does not support UBUNTU as compiler 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(), "hipcc does not support UBUNTU as compiler 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(), "hipcc does not support UBUNTU as compiler 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(), "hipcc does not support UBUNTU as compiler older than 20.04"
)

def test_hip_and_cuda_backend_cannot_be_active_at_the_same_time_b3(self):
self.assertTrue(
backend_filter_typechecked(
Expand Down
Loading

0 comments on commit 9abf557

Please sign in to comment.