Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding filter rule: GCC 6 and older is not available on Ubuntu 20.04 #46

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 53 additions & 4 deletions src/bashi/filter_software_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,44 @@
"""

from typing import Optional, IO
import packaging.version as pkv
from typeguard import typechecked
from bashi.types import ParameterValueTuple
from bashi.globals import DEVICE_COMPILER, HOST_COMPILER, GCC, UBUNTU
from bashi.utils import reason


YuriiPerets marked this conversation as resolved.
Show resolved Hide resolved
def __ubuntu_version_to_string(version: pkv.Version) -> str:
"""Returns the Ubuntu version representation correctly. Ubuntu versions
use a leading 0 in their version scheme for months before October. pkv.parse()`
parses e.g. the 04 from 20.04 to 4. Therefore the string representation of
str(pkv.parse(“20.04”)) is `20.4`. This function returns the correct version scheme.
For Ubuntu `20.04` it is `20.04`.

Args:
version (pkv.Version): Ubuntu version

Returns:
str: string representation of the Ubuntu version
"""
return f"{version.major}.{version.minor:02}"


def __pretty_name_compiler(constant: str) -> str:
"""Returns the string representation of the constants HOST_COMPILER and DEVICE_COMPILER in a
human-readable version.

Args:
constant (str): Ether HOST_COMPILER or DEVICE_COMPILER

Returns:
str: human-readable string representation of HOST_COMPILER or DEVICE_COMPILER
"""
if constant == HOST_COMPILER:
return "host compiler"
if constant == DEVICE_COMPILER:
return "device compiler"
return "unknown compiler type"


@typechecked
Expand All @@ -23,11 +59,9 @@ def software_dependency_filter_typechecked(
return software_dependency_filter(row, output)


# TODO(SimeonEhrig): remove disable=unused-argument
# only required for the CI at the moment
def software_dependency_filter(
row: ParameterValueTuple, # pylint: disable=unused-argument
output: Optional[IO[str]] = None, # pylint: disable=unused-argument
row: ParameterValueTuple,
output: Optional[IO[str]] = None,
) -> bool:
"""Filter rules handling software dependencies and compiler settings.

Expand All @@ -40,4 +74,19 @@ def software_dependency_filter(
Returns:
bool: True, if parameter-value-tuple is valid.
"""

# Rule: d1
# GCC 6 and older is not available in Ubuntu 20.04 and newer
if UBUNTU in row and row[UBUNTU].version >= pkv.parse("20.04"):
for compiler_type in (HOST_COMPILER, DEVICE_COMPILER):
if compiler_type in row and row[compiler_type].name == GCC:
if row[compiler_type].version <= pkv.parse("6"):
reason(
output,
f"{__pretty_name_compiler(compiler_type)} GCC {row[compiler_type].version} "
"is not available in Ubuntu "
f"{__ubuntu_version_to_string(row[UBUNTU].version)}",
)
return False

return True
27 changes: 26 additions & 1 deletion src/bashi/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ def get_expected_bashi_parameter_value_pairs(
_remove_unsupported_clang_sdk_versions_for_clang_cuda(
param_val_pair_list, removed_param_val_pair_list
)

_remove_unsupported_gcc_versions_for_ubuntu2004(
param_val_pair_list, removed_param_val_pair_list
)
return (param_val_pair_list, removed_param_val_pair_list)


Expand Down Expand Up @@ -747,3 +749,26 @@ def filter_func(param_val_pair: ParameterValuePair) -> bool:
return True

bi_filter(parameter_value_pairs, removed_parameter_value_pairs, filter_func)


def _remove_unsupported_gcc_versions_for_ubuntu2004(
parameter_value_pairs: List[ParameterValuePair],
removed_parameter_value_pairs: List[ParameterValuePair],
):
"""Remove pairs where GCC version 6 and older is used with Ubuntu 20.04 or newer.

Args:
parameter_value_pairs (List[ParameterValuePair]): List of parameter-value pairs.
"""
for compiler_type in (HOST_COMPILER, DEVICE_COMPILER):
for gcc_version in range(1, 7):
remove_parameter_value_pairs(
parameter_value_pairs,
removed_parameter_value_pairs,
parameter1=compiler_type,
value_name1=GCC,
value_version1=gcc_version,
parameter2=UBUNTU,
value_name2=UBUNTU,
value_version2="<20.04",
)
135 changes: 135 additions & 0 deletions tests/test_filter_software_dependency.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# pylint: disable=missing-docstring
import unittest
import io

from collections import OrderedDict as OD
from utils_test import parse_param_val as ppv
from bashi.globals import * # pylint: disable=wildcard-import,unused-wildcard-import
from bashi.filter_software_dependency import software_dependency_filter_typechecked


class TestOldGCCVersionInUbuntu2004(unittest.TestCase):
def test_valid_gcc_is_in_ubuntu_2004_d1(self):
SimeonEhrig marked this conversation as resolved.
Show resolved Hide resolved
for gcc_version in [7, 13, 99]:
self.assertTrue(
software_dependency_filter_typechecked(
OD({HOST_COMPILER: ppv((GCC, gcc_version)), UBUNTU: ppv((UBUNTU, "22.04"))}),
)
)

self.assertTrue(
software_dependency_filter_typechecked(
OD(
{
DEVICE_COMPILER: ppv((GCC, gcc_version)),
UBUNTU: ppv((UBUNTU, "22.04")),
}
),
)
)
for gcc_version in [7, 13, 99]:
self.assertTrue(
software_dependency_filter_typechecked(
OD({HOST_COMPILER: ppv((GCC, gcc_version)), UBUNTU: ppv((UBUNTU, "20.04"))}),
)
)

self.assertTrue(
software_dependency_filter_typechecked(
OD(
{
DEVICE_COMPILER: ppv((GCC, gcc_version)),
UBUNTU: ppv((UBUNTU, "20.04")),
}
),
)
)
for gcc_version in [1, 3, 6, 7, 13, 99]:
self.assertTrue(
software_dependency_filter_typechecked(
OD({HOST_COMPILER: ppv((GCC, gcc_version)), UBUNTU: ppv((UBUNTU, "18.04"))}),
)
)
for gcc_version in [1, 3, 6, 7, 13, 99]:
self.assertTrue(
software_dependency_filter_typechecked(
OD({DEVICE_COMPILER: ppv((GCC, gcc_version)), UBUNTU: ppv((UBUNTU, "18.04"))}),
)
)
for gcc_version in [1, 3, 6, 7, 13, 99]:
self.assertTrue(
software_dependency_filter_typechecked(
OD(
{
DEVICE_COMPILER: ppv((GCC, gcc_version)),
UBUNTU: ppv((UBUNTU, "18.04")),
}
),
)
)
for gcc_version in [1, 3, 6, 7, 13, 99]:
self.assertTrue(
software_dependency_filter_typechecked(
OD(
{
HOST_COMPILER: ppv((GCC, gcc_version)),
UBUNTU: ppv((UBUNTU, "18.04")),
}
),
)
)

def test_not_valid_gcc_is_in_ubuntu_2004_d1(self):
for gcc_version in [6, 3, 1]:
reason_msg = io.StringIO()
self.assertFalse(
software_dependency_filter_typechecked(
OD({HOST_COMPILER: ppv((GCC, gcc_version)), UBUNTU: ppv((UBUNTU, "20.04"))}),
reason_msg,
),
f"host compiler GCC {gcc_version} + Ubuntu 20.04",
)
self.assertEqual(
reason_msg.getvalue(),
f"host compiler GCC {gcc_version} is not available in Ubuntu 20.04",
)
for gcc_version in [6, 3, 1]:
reason_msg = io.StringIO()
self.assertFalse(
software_dependency_filter_typechecked(
OD({HOST_COMPILER: ppv((GCC, gcc_version)), UBUNTU: ppv((UBUNTU, "22.04"))}),
reason_msg,
),
f"host compiler GCC {gcc_version} + Ubuntu 22.04",
)
self.assertEqual(
reason_msg.getvalue(),
f"host compiler GCC {gcc_version} is not available in Ubuntu 22.04",
)

for gcc_version in [6, 3, 1]:
reason_msg = io.StringIO()
self.assertFalse(
SimeonEhrig marked this conversation as resolved.
Show resolved Hide resolved
software_dependency_filter_typechecked(
OD({DEVICE_COMPILER: ppv((GCC, gcc_version)), UBUNTU: ppv((UBUNTU, "20.04"))}),
reason_msg,
),
f"device compiler GCC {gcc_version} + Ubuntu 20.04",
)
self.assertEqual(
reason_msg.getvalue(),
f"device compiler GCC {gcc_version} is not available in Ubuntu 20.04",
)
for gcc_version in [6, 3, 1]:
reason_msg = io.StringIO()
self.assertFalse(
software_dependency_filter_typechecked(
OD({DEVICE_COMPILER: ppv((GCC, gcc_version)), UBUNTU: ppv((UBUNTU, "22.04"))}),
reason_msg,
),
f"device compiler GCC {gcc_version} + Ubuntu 22.04",
)
self.assertEqual(
reason_msg.getvalue(),
f"device compiler GCC {gcc_version} is not available in Ubuntu 22.04",
)
54 changes: 54 additions & 0 deletions tests/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
_remove_device_compiler_gcc_clang_enabled_cuda_backend,
_remove_specific_cuda_clang_combinations,
_remove_unsupported_clang_sdk_versions_for_clang_cuda,
_remove_unsupported_gcc_versions_for_ubuntu2004,
)
from bashi.versions import NvccHostSupport, NVCC_GCC_MAX_VERSION

Expand Down Expand Up @@ -2248,3 +2249,56 @@ def test_remove_unsupported_clang_sdk_versions_for_clang_cuda(self):
expected_results,
self,
)

def test_remove_unsupported_gcc_versions_for_ubuntu2004_and_later(self):
test_param_value_pairs: List[ParameterValuePair] = parse_expected_val_pairs(
[
OD({DEVICE_COMPILER: (GCC, 6), UBUNTU: (UBUNTU, "20.04")}),
OD({HOST_COMPILER: (GCC, 6), UBUNTU: (UBUNTU, "20.04")}),
OD({DEVICE_COMPILER: (GCC, 6), UBUNTU: (UBUNTU, "22.04")}),
OD({HOST_COMPILER: (GCC, 6), UBUNTU: (UBUNTU, "22.04")}),
OD({HOST_COMPILER: (GCC, 3), UBUNTU: (UBUNTU, "22.04")}),
OD({HOST_COMPILER: (GCC, 12), UBUNTU: (UBUNTU, "22.04")}),
OD({HOST_COMPILER: (GCC, 7), UBUNTU: (UBUNTU, "20.04")}),
OD({HOST_COMPILER: (GCC, 3), UBUNTU: (UBUNTU, "20.04")}),
OD({HOST_COMPILER: (GCC, 13), UBUNTU: (UBUNTU, "20.04")}),
OD({HOST_COMPILER: (GCC, 99), UBUNTU: (UBUNTU, "20.04")}),
OD({DEVICE_COMPILER: (GCC, 6), UBUNTU: (UBUNTU, "18.04")}),
OD({DEVICE_COMPILER: (GCC, 6), UBUNTU: (UBUNTU, "18.04")}),
OD({HOST_COMPILER: (GCC, 6), UBUNTU: (UBUNTU, "18.04")}),
OD({HOST_COMPILER: (GCC, 7), UBUNTU: (UBUNTU, "18.04")}),
OD({HOST_COMPILER: (GCC, 3), UBUNTU: (UBUNTU, "18.04")}),
OD({HOST_COMPILER: (GCC, 6), DEVICE_COMPILER: (GCC, 6)}),
OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}),
OD({HOST_COMPILER: (GCC, 6), DEVICE_COMPILER: (NVCC, 11.2)}),
OD({HOST_COMPILER: (GCC, 3), DEVICE_COMPILER: (NVCC, 12.2)}),
]
)
expected_results = parse_expected_val_pairs(
[
OD({HOST_COMPILER: (GCC, 7), UBUNTU: (UBUNTU, "20.04")}),
OD({HOST_COMPILER: (GCC, 12), UBUNTU: (UBUNTU, "22.04")}),
OD({HOST_COMPILER: (GCC, 13), UBUNTU: (UBUNTU, "20.04")}),
OD({HOST_COMPILER: (GCC, 99), UBUNTU: (UBUNTU, "20.04")}),
OD({DEVICE_COMPILER: (GCC, 6), UBUNTU: (UBUNTU, "18.04")}),
OD({HOST_COMPILER: (GCC, 6), UBUNTU: (UBUNTU, "18.04")}),
OD({DEVICE_COMPILER: (GCC, 6), UBUNTU: (UBUNTU, "18.04")}),
OD({HOST_COMPILER: (GCC, 7), UBUNTU: (UBUNTU, "18.04")}),
OD({HOST_COMPILER: (GCC, 3), UBUNTU: (UBUNTU, "18.04")}),
OD({HOST_COMPILER: (GCC, 6), DEVICE_COMPILER: (GCC, 6)}),
OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}),
OD({HOST_COMPILER: (GCC, 6), DEVICE_COMPILER: (NVCC, 11.2)}),
OD({HOST_COMPILER: (GCC, 3), DEVICE_COMPILER: (NVCC, 12.2)}),
]
)
default_remove_test(
_remove_unsupported_gcc_versions_for_ubuntu2004,
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),
)
Loading