Skip to content

Commit

Permalink
Draft:Adding new filter rule
Browse files Browse the repository at this point in the history
  • Loading branch information
YuriiPerets committed Sep 9, 2024
1 parent cc789bd commit b903be7
Show file tree
Hide file tree
Showing 4 changed files with 299 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/bashi/filter_software_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@
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 (
DEVICE_COMPILER,
HOST_COMPILER,
GCC,
UBUNTU,
CLANG_CUDA,
CMAKE,
ALPAKA_ACC_GPU_CUDA_ENABLE,
OFF_VER,
)
from bashi.utils import reason


Expand Down Expand Up @@ -104,4 +113,28 @@ def software_dependency_filter(
)
return False

# Rule: d3
# Ubuntu 20.04 and newer is not available with CUDA older than 10.2
"""
if UBUNTU in row and row[UBUNTU].version >= pkv.parse("20.04"):
if ALPAKA_ACC_GPU_CUDA_ENABLE in row and row[ALPAKA_ACC_GPU_CUDA_ENABLE].version != OFF_VER:
if row[ALPAKA_ACC_GPU_CUDA_ENABLE].version < pkv.parse("10.2"):
reason(
output,
f"CUDA {row[ALPAKA_ACC_GPU_CUDA_ENABLE].version} "
"is not available in Ubuntu "
f"{__ubuntu_version_to_string(row[UBUNTU].version)}",
)
return False
"""
if UBUNTU in row and row[UBUNTU].version >= pkv.parse("20.04"):
if ALPAKA_ACC_GPU_CUDA_ENABLE in row and row[ALPAKA_ACC_GPU_CUDA_ENABLE].version != OFF_VER:
if row[ALPAKA_ACC_GPU_CUDA_ENABLE].version < pkv.parse("10.2"):
reason(
output,
f"CUDA {row[ALPAKA_ACC_GPU_CUDA_ENABLE].version} "
"is not available in Ubuntu "
f"{__ubuntu_version_to_string(row[UBUNTU].version)}",
)
return False
return True
17 changes: 17 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_unsupported_cuda_versions_for_ubuntu(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,19 @@ def _remove_unsupported_cmake_versions_for_clangcuda(
value_name2=CMAKE,
value_version2=">3.18",
)


def _remove_unsupported_cuda_versions_for_ubuntu(
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_CUDA_ENABLE,
value_name2=ALPAKA_ACC_GPU_CUDA_ENABLE,
value_version2=">10.2",
)
122 changes: 122 additions & 0 deletions tests/test_filter_software_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,125 @@ 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_cuda_versions_for_ubuntu_d3(self):
for CUDA_version in [10.2, 11.4, 15]:
self.assertTrue(
software_dependency_filter_typechecked(
OD(
{
ALPAKA_ACC_GPU_CUDA_ENABLE: ppv(
(ALPAKA_ACC_GPU_CUDA_ENABLE, CUDA_version)
),
UBUNTU: ppv((UBUNTU, "22.04")),
}
),
)
)

self.assertTrue(
software_dependency_filter_typechecked(
OD(
{
ALPAKA_ACC_GPU_CUDA_ENABLE: ppv(
(ALPAKA_ACC_GPU_CUDA_ENABLE, CUDA_version)
),
UBUNTU: ppv((UBUNTU, "22.04")),
}
),
)
)
for CUDA_version in [10.2, 11.4, 15]:
self.assertTrue(
software_dependency_filter_typechecked(
OD(
{
ALPAKA_ACC_GPU_CUDA_ENABLE: ppv(
(ALPAKA_ACC_GPU_CUDA_ENABLE, CUDA_version)
),
UBUNTU: ppv((UBUNTU, "20.04")),
}
),
)
)

self.assertTrue(
software_dependency_filter_typechecked(
OD(
{
ALPAKA_ACC_GPU_CUDA_ENABLE: ppv(
(ALPAKA_ACC_GPU_CUDA_ENABLE, CUDA_version)
),
UBUNTU: ppv((UBUNTU, "20.04")),
}
),
)
)
for CUDA_version in [2, 6, 10.1, 10.2, 11.4, 15]:
self.assertTrue(
software_dependency_filter_typechecked(
OD(
{
ALPAKA_ACC_GPU_CUDA_ENABLE: ppv(
(ALPAKA_ACC_GPU_CUDA_ENABLE, CUDA_version)
),
UBUNTU: ppv((UBUNTU, "18.04")),
}
),
)
)

self.assertTrue(
software_dependency_filter_typechecked(
OD(
{
ALPAKA_ACC_GPU_CUDA_ENABLE: ppv(
(ALPAKA_ACC_GPU_CUDA_ENABLE, CUDA_version)
),
UBUNTU: ppv((UBUNTU, "18.04")),
}
),
)
)

def test_not_valid_cuda_versions_for_ubuntu_d3(self):
for CUDA_version in [1, 6, 10.1]:
reason_msg = io.StringIO()
self.assertFalse(
software_dependency_filter_typechecked(
OD(
{
ALPAKA_ACC_GPU_CUDA_ENABLE: ppv(
(ALPAKA_ACC_GPU_CUDA_ENABLE, CUDA_version)
),
UBUNTU: ppv((UBUNTU, "20.04")),
}
),
reason_msg,
),
f"CUDA {CUDA_version} is not available in Ubuntu 20.04",
)
self.assertEqual(
reason_msg.getvalue(),
f"CUDA {CUDA_version} is not available in Ubuntu 20.04",
)
for gcc_version in [1, 6, 10.1]:
reason_msg = io.StringIO()
self.assertFalse(
software_dependency_filter_typechecked(
OD(
{
ALPAKA_ACC_GPU_CUDA_ENABLE: ppv(
(ALPAKA_ACC_GPU_CUDA_ENABLE, CUDA_version)
),
UBUNTU: ppv((UBUNTU, "22.04")),
}
),
reason_msg,
),
f"CUDA {CUDA_version} is not available in Ubuntu 22.04",
)
self.assertEqual(
reason_msg.getvalue(),
f"CUDA {CUDA_version} is not available in Ubuntu 22.04",
)
126 changes: 126 additions & 0 deletions tests/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_unsupported_cuda_versions_for_ubuntu,
)
from bashi.versions import NvccHostSupport, NVCC_GCC_MAX_VERSION

Expand Down Expand Up @@ -2356,3 +2357,128 @@ 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_unsupported_cuda_versions_for_ubuntu(self):
test_param_value_pairs: List[ParameterValuePair] = parse_expected_val_pairs(
[
OD(
{
UBUNTU: (UBUNTU, "20.04"),
ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, "10.1"),
}
),
OD(
{
UBUNTU: (UBUNTU, "22.04"),
ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, "10.1"),
}
),
OD(
{
UBUNTU: (UBUNTU, "22.04"),
ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, "12"),
}
),
OD(
{
UBUNTU: (UBUNTU, "18.04"),
ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, "10.1"),
}
),
OD(
{
UBUNTU: (UBUNTU, "20.04"),
ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, "10.2"),
}
),
OD(
{
UBUNTU: (UBUNTU, "20.04"),
ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, "11.1"),
}
),
OD(
{
UBUNTU: (UBUNTU, "20.04"),
ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, "14.1"),
}
),
OD(
{
UBUNTU: (UBUNTU, "20.04"),
ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, "7.4"),
}
),
OD(
{
UBUNTU: (UBUNTU, "20.04"),
ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, OFF),
}
),
OD(
{
UBUNTU: (UBUNTU, "18.04"),
ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, OFF),
}
),
]
)
expected_results = parse_expected_val_pairs(
[
OD(
{
UBUNTU: (UBUNTU, "22.04"),
ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, "12"),
}
),
OD(
{
UBUNTU: (UBUNTU, "20.04"),
ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, OFF),
}
),
OD(
{
UBUNTU: (UBUNTU, "18.04"),
ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, OFF),
}
),
OD(
{
UBUNTU: (UBUNTU, "20.04"),
ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, "10.2"),
}
),
OD(
{
UBUNTU: (UBUNTU, "18.04"),
ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, "10.1"),
}
),
OD(
{
UBUNTU: (UBUNTU, "20.04"),
ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, "14.1"),
}
),
OD(
{
UBUNTU: (UBUNTU, "20.04"),
ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, "11.1"),
}
),
OD({HOST_COMPILER: (GCC, 12), UBUNTU: (UBUNTU, 22.04)}),
OD({HOST_COMPILER: (CLANG_CUDA, 14), CMAKE: (CMAKE, "3.19")}),
]
)
default_remove_test(
_remove_unsupported_cuda_versions_for_ubuntu,
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),
)

0 comments on commit b903be7

Please sign in to comment.