Skip to content

Commit

Permalink
Adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
YuriiPerets committed Sep 15, 2024
1 parent 9abf557 commit cc37e3d
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 10 deletions.
8 changes: 6 additions & 2 deletions src/bashi/filter_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,13 @@ 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
# realted to rule d3
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")
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:
Expand Down
5 changes: 3 additions & 2 deletions src/bashi/filter_software_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ def software_dependency_filter(
f"{row[CMAKE].version}",
)
return False
# Rule: d4
# all ROCm images are Ubuntu 20.04 based
# Rule: d3
# all ROCm images are Ubuntu 20.04 based or newer
# realted 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:
Expand Down
9 changes: 7 additions & 2 deletions src/bashi/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,11 @@ def _remove_all_rocm_images_non_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,
Expand All @@ -813,10 +818,10 @@ def _remove_all_rocm_images_non_ubuntu2004_based(
remove_parameter_value_pairs(
parameter_value_pairs,
removed_parameter_value_pairs,
value_name1=UBUNTU,
parameter1=UBUNTU,
value_version1=">=20.04",
value_name1=UBUNTU,
parameter2=compiler_type,
value_version1=">=20.04",
value_name2=HIPCC,
value_version2=ANY_VERSION,
)
12 changes: 12 additions & 0 deletions tests/test_filter_software_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,18 @@ def test_valid_ROCm_images_Ubuntu2004_based_d4(self):
),
),
)
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"]:
Expand Down
24 changes: 20 additions & 4 deletions tests/test_hipcc_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,18 @@ def test_hipcc_requires_ubuntu2004_pass_c19(self):
)
)
)
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):
Expand All @@ -811,7 +823,8 @@ def test_hipcc_requires_ubuntu2004_not_pass_c19(self):
)
)
self.assertEqual(
reason_msg1.getvalue(), "hipcc does not support UBUNTU as compiler older than 20.04"
reason_msg1.getvalue(),
"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04",
)

reason_msg2 = io.StringIO()
Expand All @@ -827,7 +840,8 @@ def test_hipcc_requires_ubuntu2004_not_pass_c19(self):
)
)
self.assertEqual(
reason_msg2.getvalue(), "hipcc does not support UBUNTU as compiler older than 20.04"
reason_msg2.getvalue(),
"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04",
)

reason_msg3 = io.StringIO()
Expand All @@ -844,7 +858,8 @@ def test_hipcc_requires_ubuntu2004_not_pass_c19(self):
)
)
self.assertEqual(
reason_msg3.getvalue(), "hipcc does not support UBUNTU as compiler older than 20.04"
reason_msg3.getvalue(),
"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04",
)

reason_msg4 = io.StringIO()
Expand All @@ -861,7 +876,8 @@ def test_hipcc_requires_ubuntu2004_not_pass_c19(self):
)
)
self.assertEqual(
reason_msg4.getvalue(), "hipcc does not support UBUNTU as compiler older than 20.04"
reason_msg4.getvalue(),
"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04",
)

def test_hip_and_cuda_backend_cannot_be_active_at_the_same_time_b3(self):
Expand Down

0 comments on commit cc37e3d

Please sign in to comment.