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

Draft: Add filter rule( gcc 9 and older does not support C++ 20 ) #55

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
29 changes: 28 additions & 1 deletion src/bashi/filter_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
from typeguard import typechecked
from bashi.globals import * # pylint: disable=wildcard-import,unused-wildcard-import
from bashi.types import ParameterValueTuple
from bashi.versions import NVCC_GCC_MAX_VERSION, NVCC_CLANG_MAX_VERSION, CLANG_CUDA_MAX_CUDA_VERSION
from bashi.versions import (
NVCC_GCC_MAX_VERSION,
NVCC_CLANG_MAX_VERSION,
CLANG_CUDA_MAX_CUDA_VERSION,
NVCC_CXX_SUPPORT,
)

from bashi.utils import reason

Expand Down Expand Up @@ -206,4 +211,26 @@ def backend_filter(
return False
break

# Rule: b18
# related to rule d5
if CXX_STANDARD in row:
if row[ALPAKA_ACC_GPU_CUDA_ENABLE].version <= NVCC_CXX_SUPPORT[0].nvcc:
for cuda_cxx_comb in NVCC_CXX_SUPPORT:
if row[ALPAKA_ACC_GPU_CUDA_ENABLE].version < cuda_cxx_comb.nvcc:
if row[CXX_STANDARD].version >= cuda_cxx_comb.cxx:
reason(
output,
f"cuda {row[ALPAKA_ACC_GPU_CUDA_ENABLE].version} "
f"does not support cxx {row[CXX_STANDARD].version}",
)
return False
if row[ALPAKA_ACC_GPU_CUDA_ENABLE].version >= cuda_cxx_comb.nvcc:
if row[CXX_STANDARD].version >= cuda_cxx_comb.cxx:
reason(
output,
f"cuda {row[ALPAKA_ACC_GPU_CUDA_ENABLE].version} "
f"does not support cxx {row[CXX_STANDARD].version}",
)
return False
break
return True
18 changes: 15 additions & 3 deletions src/bashi/filter_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from bashi.globals import * # pylint: disable=wildcard-import,unused-wildcard-import
from bashi.types import ParameterValueTuple
from bashi.versions import NVCC_GCC_MAX_VERSION, NVCC_CLANG_MAX_VERSION, CLANG_CUDA_MAX_CUDA_VERSION
from bashi.utils import reason
from bashi.utils import reason, print_row_nice

# uncomment me for debugging
# from bashi.utils import print_row_nice
Expand Down Expand Up @@ -49,7 +49,7 @@ def compiler_filter(
bool: True, if parameter-value-tuple is valid.
"""
# uncomment me for debugging
# print_row_nice(row, bashi_validate=False)
print_row_nice(row, bashi_validate=False)

# Rule: c1
# NVCC as HOST_COMPILER is not allow
Expand Down Expand Up @@ -105,6 +105,10 @@ def compiler_filter(
return False
break

# Rule: c21
# related to rule:
# remove all unsupported nvcc gcc version combinations with cxx

if HOST_COMPILER in row and row[HOST_COMPILER].name == CLANG:
# Rule: c7
# related to rule b11
Expand Down Expand Up @@ -247,7 +251,7 @@ def compiler_filter(
ALPAKA_ACC_GPU_CUDA_ENABLE in row
and row[ALPAKA_ACC_GPU_CUDA_ENABLE].version != OFF_VER
):
# Rule: c16
# Rule: c20
# related to rule b17
# if a clang-cuda version is newer than the latest known clang-cuda version,
# we needs to assume that it supports every CUDA SDK version
Expand All @@ -264,6 +268,14 @@ def compiler_filter(
)
return False
break
if row[compiler].version < version_combination.clang_cuda:
if row[ALPAKA_ACC_GPU_CUDA_ENABLE].version > version_combination.cuda:
reason(
output,
f"clang-cuda {row[compiler].version} does not support "
f"CUDA {row[ALPAKA_ACC_GPU_CUDA_ENABLE].version}.",
)
return False

# Rule: c17
# related to rule b14
Expand Down
75 changes: 74 additions & 1 deletion src/bashi/filter_software_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
from bashi.types import ParameterValueTuple
from bashi.globals import * # pylint: disable=wildcard-import,unused-wildcard-import
from bashi.utils import reason
from bashi.versions import get_oldest_supporting_clang_version_for_cuda
from bashi.versions import (
get_oldest_supporting_clang_version_for_cuda,
GCC_CXX_SUPPORT,
NVCC_CXX_SUPPORT,
CLANG_CXX_SUPPORT,
)


def __ubuntu_version_to_string(version: pkv.Version) -> str:
Expand Down Expand Up @@ -156,4 +161,72 @@ def software_dependency_filter(
f"{__ubuntu_version_to_string(row[UBUNTU].version)}",
)
return False

# Rule: d5
# related to rule b18
# remove all unsupported gcc cxx and nvcc cxx version combinations
if HOST_COMPILER in row and row[HOST_COMPILER].name == CLANG:
if CXX_STANDARD in row:
if row[HOST_COMPILER].version <= CLANG_CXX_SUPPORT[0].clang:
# check the maximum supported gcc version for the given cxx version
for clang_cxx_comb in CLANG_CXX_SUPPORT:
if row[HOST_COMPILER].version < clang_cxx_comb.clang:
if row[CXX_STANDARD].version >= clang_cxx_comb.cxx:
return False
if row[HOST_COMPILER].version >= clang_cxx_comb.clang:
if row[CXX_STANDARD].version >= clang_cxx_comb.cxx:
return False
break

if HOST_COMPILER in row and row[HOST_COMPILER].name == GCC:
if CXX_STANDARD in row:
if row[HOST_COMPILER].version <= GCC_CXX_SUPPORT[0].gcc:
# check the maximum supported gcc version for the given cxx version
for gcc_cxx_comb in GCC_CXX_SUPPORT:
if row[HOST_COMPILER].version < gcc_cxx_comb.gcc:
if row[CXX_STANDARD].version >= gcc_cxx_comb.cxx:
reason(
output,
"host compiler"
f" gcc {row[HOST_COMPILER].version} "
f"does not support cxx {row[CXX_STANDARD].version}",
)
return False
if row[HOST_COMPILER].version >= gcc_cxx_comb.gcc:
if row[CXX_STANDARD].version >= gcc_cxx_comb.cxx:
reason(
output,
"host compiler"
f" gcc {row[HOST_COMPILER].version} "
f"does not support cxx {row[CXX_STANDARD].version}",
)
return False
break

if DEVICE_COMPILER in row and row[DEVICE_COMPILER].name == NVCC:
if CXX_STANDARD in row:
if row[DEVICE_COMPILER].version <= NVCC_CXX_SUPPORT[0].nvcc:
# check the maximum supported nvcc version for the given cxx version
for nvcc_cxx_comb in NVCC_CXX_SUPPORT:
if row[DEVICE_COMPILER].version < nvcc_cxx_comb.nvcc:
print(nvcc_cxx_comb.nvcc)
if row[CXX_STANDARD].version >= nvcc_cxx_comb.cxx:
reason(
output,
"device compiler"
f" nvcc {row[DEVICE_COMPILER].version} "
f"does not support cxx {row[CXX_STANDARD].version}",
)
return False
if row[DEVICE_COMPILER].version >= nvcc_cxx_comb.nvcc:
if row[CXX_STANDARD].version >= nvcc_cxx_comb.cxx:
reason(
output,
"device compiler"
f" nvcc {row[DEVICE_COMPILER].version} "
f"does not support cxx {row[CXX_STANDARD].version}",
)
return False
break
print("passed")
return True
61 changes: 61 additions & 0 deletions src/bashi/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
CLANG_CUDA_MAX_CUDA_VERSION,
NvccHostSupport,
ClangCudaSDKSupport,
GCC_CXX_SUPPORT,
GccCxxSupport,
)


Expand Down Expand Up @@ -83,6 +85,7 @@ def get_expected_bashi_parameter_value_pairs(
param_val_pair_list, removed_param_val_pair_list
)
_remove_unsupported_cuda_versions_for_ubuntu(param_val_pair_list, removed_param_val_pair_list)
_remove_unsupported_cxx_versions_for_gcc(param_val_pair_list, removed_param_val_pair_list)
return (param_val_pair_list, removed_param_val_pair_list)


Expand Down Expand Up @@ -908,3 +911,61 @@ def _remove_unsupported_cuda_versions_for_ubuntu(
value_max_version2=12,
value_max_version2_inclusive=False,
)


def _remove_unsupported_cxx_versions_for_gcc(
parameter_value_pairs: List[ParameterValuePair],
removed_parameter_value_pairs: List[ParameterValuePair],
):
remove_parameter_value_pairs_ranges(
parameter_value_pairs,
removed_parameter_value_pairs,
parameter1=HOST_COMPILER,
value_name1=GCC,
value_max_version1=8,
parameter2=CXX_STANDARD,
value_name2=CXX_STANDARD,
value_min_version2=17,
)
remove_parameter_value_pairs_ranges(
parameter_value_pairs,
removed_parameter_value_pairs,
parameter1=HOST_COMPILER,
value_name1=GCC,
value_min_version1=8,
value_min_version1_inclusive=True,
value_max_version1=10,
parameter2=CXX_STANDARD,
value_name2=CXX_STANDARD,
value_min_version2=20,
value_min_version2_inclusive=True,
)


def _remove_unsupported_cxx_versions_for_nvcc(
parameter_value_pairs: List[ParameterValuePair],
removed_parameter_value_pairs: List[ParameterValuePair],
):
remove_parameter_value_pairs_ranges(
parameter_value_pairs,
removed_parameter_value_pairs,
parameter1=DEVICE_COMPILER,
value_name1=NVCC,
value_max_version1=11.0,
parameter2=CXX_STANDARD,
value_name2=CXX_STANDARD,
value_min_version2=17,
)
remove_parameter_value_pairs_ranges(
parameter_value_pairs,
removed_parameter_value_pairs,
parameter1=DEVICE_COMPILER,
value_name1=NVCC,
value_min_version1=11.0,
value_min_version1_inclusive=True,
value_max_version1=12.0,
parameter2=CXX_STANDARD,
value_name2=CXX_STANDARD,
value_min_version2=20,
value_min_version2_inclusive=True,
)
74 changes: 67 additions & 7 deletions src/bashi/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,54 @@ def __str__(self) -> str:
return f"Clang-CUDA {str(self.clang_cuda)} + CUDA SDK {self.cuda}"


# pylint: disable=too-few-public-methods
class GccCxxSupport(VersionSupportBase):
"""Contains a gcc version and host compiler version. Does automatically parse the input strings
to package.version.Version.

Provides comparision operators for sorting.
"""

def __init__(self, gcc_version: str, cxx_version: str):
VersionSupportBase.__init__(self, gcc_version, cxx_version)
self.gcc: packaging.version.Version = self.version1
self.cxx: packaging.version.Version = self.version2

def __str__(self) -> str:
return f"GCC {str(self.gcc_version)} + CXX {self.cxx_version}"


# pylint: disable=too-few-public-methods
class NvccCxxSupport(VersionSupportBase):
"""Contains a nvcc version and host compiler version. Does automatically parse the input strings
to package.version.Version.

Provides comparision operators for sorting.
"""

def __init__(self, nvcc_version: str, cxx_version: str):
VersionSupportBase.__init__(self, nvcc_version, cxx_version)
self.nvcc: packaging.version.Version = self.version1
self.cxx: packaging.version.Version = self.version2

def __str__(self) -> str:
return f"NVCC {str(self.nvcc_version)} + CXX {self.cxx_version}"


class ClangCxxSupport(VersionSupportBase):
def __init__(self, clang_version: str, cxx_version: str):
VersionSupportBase.__init__(self, clang_version, cxx_version)
self.clang: packaging.version.Version = self.version1
self.cxx: packaging.version.Version = self.version2

def __str__(self) -> str:
return f"Clang {str(self.clang_version)} + cxx {self.cxx_version}"


VERSIONS: Dict[str, List[Union[str, int, float]]] = {
GCC: [6, 7, 8, 9, 10, 11, 12, 13],
CLANG: [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17],
NVCC: [
10.0,
10.1,
10.2,
11.0,
11.1,
11.2,
Expand Down Expand Up @@ -118,11 +159,32 @@ def __str__(self) -> str:
NvccHostSupport("11.4", "11"),
NvccHostSupport("11.1", "10"),
NvccHostSupport("11.0", "9"),
NvccHostSupport("10.1", "8"),
NvccHostSupport("10.0", "7"),
]
NVCC_GCC_MAX_VERSION.sort(reverse=True)


# define the maximum supported cxx version for a specific gcc version
GCC_CXX_SUPPORT: List[GccCxxSupport] = [
GccCxxSupport("8", "17"),
GccCxxSupport("10", "20"),
]
GCC_CXX_SUPPORT.sort(reverse=True)


# define the maximum supported cxx version for a specific nvcc version
NVCC_CXX_SUPPORT: List[NvccCxxSupport] = [
NvccCxxSupport("11.0", "17"), # NVCC versions older than 11.0 does not support C++ 17
NvccCxxSupport("12.0", "20"), # NVCC versions older than 12.0 does not support C++ 20
]
NVCC_CXX_SUPPORT.sort(reverse=True)


CLANG_CXX_SUPPORT: List[ClangCxxSupport] = [
ClangCxxSupport("9", "17"),
ClangCxxSupport("14", "20"),
]
CLANG_CXX_SUPPORT.sort(reverse=True)

# define the maximum supported clang version for a specific nvcc version
# the latest supported nvcc version must be added, even if the supported clang version does not
# increase
Expand All @@ -140,8 +202,6 @@ def __str__(self) -> str:
NvccHostSupport("11.2", "11"),
NvccHostSupport("11.1", "10"),
NvccHostSupport("11.0", "9"),
NvccHostSupport("10.1", "8"),
NvccHostSupport("10.0", "6"),
]
NVCC_CLANG_MAX_VERSION.sort(reverse=True)

Expand Down
Loading
Loading