diff --git a/bashi/globals.py b/bashi/globals.py index a914a29..f3fa401 100644 --- a/bashi/globals.py +++ b/bashi/globals.py @@ -2,21 +2,21 @@ from typing import List import packaging.version - +from bashi.types import Parameter, ValueName, ValueVersion # parameter key names, whit special meaning -HOST_COMPILER: str = "host_compiler" -DEVICE_COMPILER: str = "device_compiler" +HOST_COMPILER: Parameter = "host_compiler" +DEVICE_COMPILER: Parameter = "device_compiler" # name of the used compilers -GCC: str = "gcc" -CLANG: str = "clang" -NVCC: str = "nvcc" -CLANG_CUDA: str = "clang-cuda" -HIPCC: str = "hipcc" -ICPX: str = "icpx" +GCC: ValueName = "gcc" +CLANG: ValueName = "clang" +NVCC: ValueName = "nvcc" +CLANG_CUDA: ValueName = "clang-cuda" +HIPCC: ValueName = "hipcc" +ICPX: ValueName = "icpx" -COMPILERS: List[str] = [GCC, CLANG, NVCC, CLANG_CUDA, HIPCC, ICPX] +COMPILERS: List[ValueName] = [GCC, CLANG, NVCC, CLANG_CUDA, HIPCC, ICPX] # alpaka backend names ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE: str = "alpaka_ACC_CPU_B_SEQ_T_SEQ_ENABLE" @@ -47,5 +47,10 @@ OFF: str = "0.0.0" ON: str = "1.0.0" -OFF_VER: packaging.version.Version = packaging.version.parse(OFF) -ON_VER: packaging.version.Version = packaging.version.parse(ON) +OFF_VER: ValueVersion = packaging.version.parse(OFF) +ON_VER: ValueVersion = packaging.version.parse(ON) + +# values are used for remove_parameter_value_pair +ANY_PARAM: Parameter = "*" +ANY_NAME: ValueName = "*" +ANY_VERSION: str = "*" diff --git a/bashi/results.py b/bashi/results.py new file mode 100644 index 0000000..fa49a17 --- /dev/null +++ b/bashi/results.py @@ -0,0 +1,255 @@ +"""Create list of expected parameter-value-pairs respecting bashi filter rules""" + +import copy +from typing import List, Optional +from typeguard import typechecked +from packaging.specifiers import SpecifierSet +from bashi.types import ParameterValue, ParameterValuePair, ParameterValueMatrix +from bashi.utils import ( + get_expected_parameter_value_pairs, + remove_parameter_value_pairs, +) + +from bashi.globals import * # pylint: disable=wildcard-import,unused-wildcard-import +from bashi.versions import ( + COMPILERS, + NVCC_GCC_MAX_VERSION, + NVCC_CLANG_MAX_VERSION, + NvccHostSupport, +) + + +@typechecked +def get_expected_bashi_parameter_value_pairs( + parameter_matrix: ParameterValueMatrix, +) -> List[ParameterValuePair]: + """Takes parameter-value-matrix and creates a list of all expected parameter-values-pairs + allowed by the bashi library. First it generates a complete list of parameter-value-pairs and + then it removes all pairs that are not allowed by filter rules. + + Args: + parameter_matrix (ParameterValueMatrix): matrix of parameter values + + Returns: + List[ParameterValuePair]: list of all parameter-value-pairs supported by bashi + """ + local_parameter_matrix = copy.deepcopy(parameter_matrix) + + def remove_host_compiler_nvcc(param_val: ParameterValue) -> bool: + if param_val.name == NVCC: + return False + return True + + # remove nvcc as host compiler + local_parameter_matrix[HOST_COMPILER] = list( + filter(remove_host_compiler_nvcc, local_parameter_matrix[HOST_COMPILER]) + ) + + # remove clang-cuda 13 and older + def remove_unsupported_clang_cuda_version(param_val: ParameterValue) -> bool: + if param_val.name == CLANG_CUDA and param_val.version < packaging.version.parse("14"): + return False + return True + + local_parameter_matrix[HOST_COMPILER] = list( + filter(remove_unsupported_clang_cuda_version, local_parameter_matrix[HOST_COMPILER]) + ) + local_parameter_matrix[DEVICE_COMPILER] = list( + filter(remove_unsupported_clang_cuda_version, local_parameter_matrix[DEVICE_COMPILER]) + ) + + param_val_pair_list = get_expected_parameter_value_pairs(local_parameter_matrix) + + _remove_unsupported_nvcc_host_compiler(param_val_pair_list) + _remove_different_compiler_names(param_val_pair_list) + _remove_different_compiler_versions(param_val_pair_list) + _remove_nvcc_unsupported_gcc_versions(param_val_pair_list) + _remove_nvcc_unsupported_clang_versions(param_val_pair_list) + _remove_specific_nvcc_clang_combinations(param_val_pair_list) + + return param_val_pair_list + + +def _remove_unsupported_nvcc_host_compiler(parameter_value_pairs: List[ParameterValuePair]): + """Remove all combinations where nvcc is device compiler and the host compiler is not gcc or + clang. + + Args: + parameter_value_pairs (List[ParameterValuePair]): parameter-value-pair list + """ + for compiler_name in set(COMPILERS) - set([GCC, CLANG, NVCC]): + remove_parameter_value_pairs( + parameter_value_pairs, + parameter1=HOST_COMPILER, + value_name1=compiler_name, + parameter2=DEVICE_COMPILER, + value_name2=NVCC, + ) + + +def _remove_different_compiler_names(parameter_value_pairs: List[ParameterValuePair]): + """Remove all combinations, where host and device compiler name are different except the device + compiler name is nvcc. + + Args: + parameter_value_pairs (List[ParameterValuePair]): parameter-value-pair list + """ + # remove all combinations, where host and device compiler name are different except the device + # compiler name is nvcc + for host_compiler_name in set(COMPILERS) - set([NVCC]): + for device_compiler_name in set(COMPILERS) - set([NVCC]): + if host_compiler_name != device_compiler_name: + remove_parameter_value_pairs( + parameter_value_pairs, + parameter1=HOST_COMPILER, + value_name1=host_compiler_name, + parameter2=DEVICE_COMPILER, + value_name2=device_compiler_name, + ) + + +def _remove_different_compiler_versions(parameter_value_pairs: List[ParameterValuePair]): + """Remove all combinations, where host and device compiler name are equal and versions are + different except the compiler name is nvcc. + + Args: + parameter_value_pairs (List[ParameterValuePair]): parameter-value-pair list + """ + + def filter_function(param_val_pair: ParameterValuePair) -> bool: + param_names = (HOST_COMPILER, DEVICE_COMPILER) + compiler_names = set(COMPILERS) - set([NVCC]) + + if ( + param_val_pair.first.parameter in param_names + and param_val_pair.second.parameter in param_names + and param_val_pair.first.parameterValue.name + == param_val_pair.second.parameterValue.name + and param_val_pair.first.parameterValue.name in compiler_names + and param_val_pair.first.parameterValue.version + != param_val_pair.second.parameterValue.version + ): + return False + + return True + + parameter_value_pairs[:] = list(filter(filter_function, parameter_value_pairs)) + + +def _remove_nvcc_unsupported_gcc_versions(parameter_value_pairs: List[ParameterValuePair]): + """Remove all gcc version, which are to new for a specific nvcc version. + + Args: + parameter_value_pairs (List[ParameterValuePair]): parameter-value-pair list + """ + _remove_unsupported_nvcc_host_compiler_versions( + parameter_value_pairs, GCC, NVCC_GCC_MAX_VERSION + ) + + +def _remove_nvcc_unsupported_clang_versions(parameter_value_pairs: List[ParameterValuePair]): + """Remove all clang version, which are to new for a specific nvcc version. + + Args: + parameter_value_pairs (List[ParameterValuePair]): parameter-value-pair list + """ + _remove_unsupported_nvcc_host_compiler_versions( + parameter_value_pairs, CLANG, NVCC_CLANG_MAX_VERSION + ) + + +def _remove_unsupported_nvcc_host_compiler_versions( + parameter_value_pairs: List[ParameterValuePair], + host_compiler_name: str, + support_list: List[NvccHostSupport], +): + # pylint: disable=too-few-public-methods + class _FilterFunctor: + def __init__( + self, + host_compiler_name: str, + inklusiv_min_version: Optional[NvccHostSupport] = None, + exklusiv_max_version: Optional[NvccHostSupport] = None, + ) -> None: + self.host_compiler_name = host_compiler_name + if inklusiv_min_version and exklusiv_max_version: + if inklusiv_min_version.host == exklusiv_max_version.host: + self.host_specifier_set = SpecifierSet(f">{exklusiv_max_version.host}") + else: + self.host_specifier_set = SpecifierSet(f">={exklusiv_max_version.host}") + self.nvcc_specifier_set = SpecifierSet( + f">={inklusiv_min_version.nvcc},<{exklusiv_max_version.nvcc}" + ) + elif inklusiv_min_version: + self.host_specifier_set = SpecifierSet(f">{inklusiv_min_version.host}") + self.nvcc_specifier_set = SpecifierSet(f"=={inklusiv_min_version.nvcc}") + elif exklusiv_max_version: + self.host_specifier_set = SpecifierSet(f">{exklusiv_max_version.host}") + self.nvcc_specifier_set = SpecifierSet(f"=={exklusiv_max_version.nvcc}") + else: + raise RuntimeError( + "at least inklusiv_min_version or exklusiv_max_version needs to be set" + ) + + def __call__(self, param_val_pair: ParameterValuePair) -> bool: + if ( + param_val_pair.first.parameter == HOST_COMPILER + and param_val_pair.second.parameter == DEVICE_COMPILER + ): + host_param_val = param_val_pair.first.parameterValue + nvcc_param_val = param_val_pair.second.parameterValue + elif ( + param_val_pair.first.parameter == HOST_COMPILER + and param_val_pair.second.parameter == DEVICE_COMPILER + ): + host_param_val = param_val_pair.second.parameterValue + nvcc_param_val = param_val_pair.first.parameterValue + else: + return True + + if host_param_val.name == self.host_compiler_name and nvcc_param_val.name == NVCC: + if ( + nvcc_param_val.version in self.nvcc_specifier_set + and host_param_val.version in self.host_specifier_set + ): + return False + + return True + + oldest_nvcc_first = sorted(support_list) + + for index in range(len(oldest_nvcc_first) - 1): + filter_function = _FilterFunctor( + host_compiler_name, oldest_nvcc_first[index], oldest_nvcc_first[index + 1] + ) + + parameter_value_pairs[:] = filter(filter_function, parameter_value_pairs) + + # lower bound + parameter_value_pairs[:] = filter( + _FilterFunctor(host_compiler_name, inklusiv_min_version=oldest_nvcc_first[0]), + parameter_value_pairs, + ) + # upper bound + parameter_value_pairs[:] = filter( + _FilterFunctor(host_compiler_name, exklusiv_max_version=oldest_nvcc_first[-1]), + parameter_value_pairs, + ) + + +def _remove_specific_nvcc_clang_combinations(parameter_value_pairs: List[ParameterValuePair]): + """Remove all pairs, where clang is host-compiler for nvcc 11.3, 11.4 and 11.5 as device + compiler. + + Args: + parameter_value_pairs (List[ParameterValuePair]): parameter-value-pair list + """ + remove_parameter_value_pairs( + parameter_value_pairs, + parameter1=HOST_COMPILER, + value_name1=CLANG, + value_version1=ANY_VERSION, + parameter2=DEVICE_COMPILER, + value_name2=NVCC, + value_version2="!=11.3,!=11.4,!=11.5", + ) diff --git a/bashi/utils.py b/bashi/utils.py index 90afef4..1d99d44 100644 --- a/bashi/utils.py +++ b/bashi/utils.py @@ -2,11 +2,11 @@ import dataclasses import sys -import copy from collections import OrderedDict -from typing import IO, Dict, List, Optional, Union +from typing import IO, Dict, List, Optional, Union, Callable import packaging.version +from packaging.specifiers import SpecifierSet, InvalidSpecifier from typeguard import typechecked from bashi.types import ( @@ -18,8 +18,8 @@ ParameterValuePair, ParameterValueSingle, ParameterValueTuple, + ValueName, ) -from bashi.versions import COMPILERS, VERSIONS, NVCC_GCC_MAX_VERSION, NVCC_CLANG_MAX_VERSION from bashi.globals import * # pylint: disable=wildcard-import,unused-wildcard-import @@ -186,81 +186,134 @@ def _loop_over_parameter_values( ) +# pylint: disable=too-many-locals @typechecked -def remove_parameter_value_pair( - to_remove: Union[ParameterValueSingle, ParameterValuePair], +def remove_parameter_value_pairs( # pylint: disable=too-many-arguments parameter_value_pairs: List[ParameterValuePair], - all_versions: bool = False, + parameter1: Parameter = ANY_PARAM, + value_name1: ValueName = ANY_NAME, + value_version1: Union[int, float, str] = ANY_VERSION, + parameter2: Parameter = ANY_PARAM, + value_name2: ValueName = ANY_NAME, + value_version2: Union[int, float, str] = ANY_VERSION, + symmetric: bool = True, ) -> bool: - """Removes a parameter-value pair with one or two entries from the parameter-value-pair list. If - the parameter-value-pair only has one parameter value, all parameter-value-pairs that contain - the parameter value are removed. + """Removes a parameter-value-pair from a list based on the specified search criteria. A + parameter-value pair must match all specified search criteria to be removed if none of the + criteria is `ANY_*`. If a criterion is `ANY_*`, it is ignored and it is always a match. Args: - to_remove (Union[ParameterValueSingle, ParameterValuePair]): Parameter-value-single or - parameter-value-pair to remove - param_val_pairs (List[ParameterValuePair]): List of parameter-value-pairs. Will be modified. - all_versions (bool): If it is `True` and `to_remove` has type of `ParameterValuePair`, - removes all parameter-value-pairs witch matches the value-names independent of the - value-version. Defaults to False. - Raises: - RuntimeError: If `all_versions=True` and `to_remove` is a `ParameterValueSingle` + parameter_value_pairs (List[ParameterValuePair]): list where parameter-value-pairs will be + removed + parameter1 (Parameter, optional): Name of the first parameter. Defaults to ANY_PARAM. + value_name1 (ValueName, optional): Name of the first value-name. Defaults to ANY_NAME. + value_version1 (Union[int, float, str], optional): Name of the first value-version. Either + as a single version or as a version range that can be parsed into a + `packaging.specifier.SpecifierSet`. If it is a version range, all versions that are not + within this range are removed. Defaults to ANY_VERSION. + parameter2 (Parameter, optional): Name of the second parameter. Defaults to ANY_PARAM. + value_name2 (ValueName, optional): Name of the second value-name. Defaults to ANY_NAME. + value_version2 (Union[int, float, str], optional): Name of the second value-name. Either as + a single version or as a version range that can be parsed into a + `packaging.specifier.SpecifierSet`. If it is a version range, all versions that are not + within this range are removed. Defaults to ANY_VERSION. + symmetric (bool, optional): If symmetric is true, it does not matter whether a group of + parameters, value-name and value-version was found in the first or second + parameter-value. If false, it is taken into account whether the search criterion was + found in the first or second parameter value. Defaults to True. Returns: - bool: True if entry was removed from parameter_value_pairs + bool: Return True, if parameter-value-pair was removed. """ - if isinstance(to_remove, ParameterValueSingle): - if all_versions: - raise RuntimeError("all_versions=True is not support for ParameterValueSingle") + filter_list: List[Callable[[ParameterValuePair], bool]] = [] + if parameter1 != ANY_PARAM: + filter_list.append(lambda param_val: param_val.first.parameter == parameter1) - return _remove_single_entry_parameter_value_pair(to_remove, parameter_value_pairs) + if value_name1 != ANY_NAME: + filter_list.append(lambda param_val: param_val.first.parameterValue.name == value_name1) - if all_versions: - return _remove_parameter_value_pair_all_versions(to_remove, parameter_value_pairs) + if parameter2 != ANY_PARAM: + filter_list.append(lambda param_val: param_val.second.parameter == parameter2) - try: - parameter_value_pairs.remove(to_remove) - return True - except ValueError: - return False + if value_name2 != ANY_NAME: + filter_list.append(lambda param_val: param_val.second.parameterValue.name == value_name2) + def is_specifier_set(version: Union[int, float, str]) -> bool: + try: + SpecifierSet(str(version)) + return True + except InvalidSpecifier: + return False -@typechecked -def _remove_single_entry_parameter_value_pair( - to_remove: ParameterValueSingle, param_val_pairs: List[ParameterValuePair] -) -> bool: - len_before = len(param_val_pairs) + if ( + value_version1 != ANY_VERSION + and value_version2 != ANY_VERSION + and is_specifier_set(value_version1) + and is_specifier_set(value_version2) + ): + specifier_set_version1 = SpecifierSet(str(value_version1)) + specifier_set_version2 = SpecifierSet(str(value_version2)) + + filter_list.append( + lambda param_val: not ( + param_val.first.parameterValue.version in specifier_set_version1 + and param_val.second.parameterValue.version in specifier_set_version2 + ) + ) - def filter_function(param_val_pair: ParameterValuePair) -> bool: - for param_val_entry in param_val_pair: - if param_val_entry == to_remove: - return False - return True + else: + if value_version1 != ANY_VERSION: + try: + specifier_set_version1 = SpecifierSet(str(value_version1)) + filter_list.append( + lambda param_val: not param_val.first.parameterValue.version + in specifier_set_version1 + ) + except InvalidSpecifier: + parsed_value_version1 = packaging.version.parse(str(value_version1)) + filter_list.append( + lambda param_val: param_val.first.parameterValue.version + == parsed_value_version1 + ) - param_val_pairs[:] = list(filter(filter_function, param_val_pairs)) + if value_version2 != ANY_VERSION: + try: + specifier_set_version2 = SpecifierSet(str(value_version2)) + filter_list.append( + lambda param_val: not param_val.second.parameterValue.version + in specifier_set_version2 + ) + except InvalidSpecifier: + parsed_value_version2 = packaging.version.parse(str(value_version2)) + filter_list.append( + lambda param_val: param_val.second.parameterValue.version + == parsed_value_version2 + ) - return len_before != len(param_val_pairs) + def filter_func(param_value_pair: ParameterValuePair) -> bool: + return_value = True + for f in filter_list: + return_value = return_value and f(param_value_pair) -@typechecked -def _remove_parameter_value_pair_all_versions( - to_remove: ParameterValuePair, param_val_pairs: List[ParameterValuePair] -) -> bool: - len_before = len(param_val_pairs) + return not return_value - def filter_function(param_val_pair: ParameterValuePair) -> bool: - if ( - param_val_pair.first.parameter == to_remove.first.parameter - and param_val_pair.second.parameter == to_remove.second.parameter - and param_val_pair.first.parameterValue.name == to_remove.first.parameterValue.name - and param_val_pair.second.parameterValue.name == to_remove.second.parameterValue.name - ): - return False - return True + len_before = len(parameter_value_pairs) + parameter_value_pairs[:] = list(filter(filter_func, parameter_value_pairs)) - param_val_pairs[:] = list(filter(filter_function, param_val_pairs)) + if symmetric: + remove_parameter_value_pairs( + parameter_value_pairs, + parameter2, + value_name2, + value_version2, + parameter1, + value_name1, + value_version1, + symmetric=False, + ) - return len_before != len(param_val_pairs) + return len_before != len(parameter_value_pairs) @typechecked @@ -315,161 +368,3 @@ def reason(output: Optional[IO[str]], msg: str): file=output, end="", ) - - -# TODO(SimeonEhrig) modularize the function -# pylint: disable=too-many-branches -# pylint: disable=too-many-locals -@typechecked -def get_expected_bashi_parameter_value_pairs( - parameter_matrix: ParameterValueMatrix, -) -> List[ParameterValuePair]: - """Takes parameter-value-matrix and creates a list of all expected parameter-values-pairs - allowed by the bashi library. First it generates a complete list of parameter-value-pairs and - then it removes all pairs that are not allowed by filter rules. - - Args: - parameter_matrix (ParameterValueMatrix): matrix of parameter values - - Returns: - List[ParameterValuePair]: list of all parameter-value-pairs supported by bashi - """ - local_parameter_matrix = copy.deepcopy(parameter_matrix) - - def remove_host_compiler_nvcc(param_val: ParameterValue) -> bool: - if param_val.name == NVCC: - return False - return True - - # remove nvcc as host compiler - local_parameter_matrix[HOST_COMPILER] = list( - filter(remove_host_compiler_nvcc, local_parameter_matrix[HOST_COMPILER]) - ) - - # remove clang-cuda 13 and older - def remove_unsupported_clang_cuda_version(param_val: ParameterValue) -> bool: - if param_val.name == CLANG_CUDA and param_val.version < packaging.version.parse("14"): - return False - return True - - local_parameter_matrix[HOST_COMPILER] = list( - filter(remove_unsupported_clang_cuda_version, local_parameter_matrix[HOST_COMPILER]) - ) - local_parameter_matrix[DEVICE_COMPILER] = list( - filter(remove_unsupported_clang_cuda_version, local_parameter_matrix[DEVICE_COMPILER]) - ) - - param_val_pair_list = get_expected_parameter_value_pairs(local_parameter_matrix) - - extend_versions = copy.deepcopy(VERSIONS) - extend_versions[CLANG_CUDA] = extend_versions[CLANG] - - # remove all combinations where nvcc is device compiler and the host compiler is not gcc or - # clang - for compiler_name in set(COMPILERS) - set([GCC, CLANG, NVCC]): - remove_parameter_value_pair( - to_remove=create_parameter_value_pair( - HOST_COMPILER, compiler_name, 0, DEVICE_COMPILER, NVCC, 0 - ), - parameter_value_pairs=param_val_pair_list, - all_versions=True, - ) - - # remove all combinations, where host and device compiler name are different except the device - # compiler name is nvcc - for host_compiler_name in set(COMPILERS) - set([NVCC]): - for device_compiler_name in set(COMPILERS) - set([NVCC]): - if host_compiler_name != device_compiler_name: - remove_parameter_value_pair( - to_remove=create_parameter_value_pair( - HOST_COMPILER, - host_compiler_name, - 0, - DEVICE_COMPILER, - device_compiler_name, - 0, - ), - parameter_value_pairs=param_val_pair_list, - all_versions=True, - ) - - # remove all combinations, where host and device compiler version are different except the - # compiler name is nvcc - for compiler_name in set(COMPILERS) - set([NVCC]): - for compiler_version1 in extend_versions[compiler_name]: - for compiler_version2 in extend_versions[compiler_name]: - if compiler_version1 != compiler_version2: - remove_parameter_value_pair( - to_remove=create_parameter_value_pair( - HOST_COMPILER, - compiler_name, - compiler_version1, - DEVICE_COMPILER, - compiler_name, - compiler_version2, - ), - parameter_value_pairs=param_val_pair_list, - all_versions=False, - ) - - # remove all gcc version, which are to new for a specific nvcc version - nvcc_versions = [packaging.version.parse(str(v)) for v in VERSIONS[NVCC]] - nvcc_versions.sort() - gcc_versions = [packaging.version.parse(str(v)) for v in VERSIONS[GCC]] - gcc_versions.sort() - for nvcc_version in nvcc_versions: - for max_nvcc_gcc_version in NVCC_GCC_MAX_VERSION: - if nvcc_version >= max_nvcc_gcc_version.nvcc: - for gcc_version in gcc_versions: - if gcc_version > max_nvcc_gcc_version.host: - remove_parameter_value_pair( - to_remove=create_parameter_value_pair( - HOST_COMPILER, - GCC, - gcc_version, - DEVICE_COMPILER, - NVCC, - nvcc_version, - ), - parameter_value_pairs=param_val_pair_list, - ) - break - - clang_versions = [packaging.version.parse(str(v)) for v in VERSIONS[CLANG]] - clang_versions.sort() - - # remove all clang version, which are to new for a specific nvcc version - for nvcc_version in nvcc_versions: - for max_nvcc_clang_version in NVCC_CLANG_MAX_VERSION: - if nvcc_version >= max_nvcc_clang_version.nvcc: - for clang_version in clang_versions: - if clang_version > max_nvcc_clang_version.host: - remove_parameter_value_pair( - to_remove=create_parameter_value_pair( - HOST_COMPILER, - CLANG, - clang_version, - DEVICE_COMPILER, - NVCC, - nvcc_version, - ), - parameter_value_pairs=param_val_pair_list, - ) - break - - # remove all pairs, where clang is host-compiler for nvcc 11.3, 11.4 and 11.5 as device compiler - for nvcc_version in [packaging.version.parse(str(v)) for v in [11.3, 11.4, 11.5]]: - for clang_version in clang_versions: - remove_parameter_value_pair( - to_remove=create_parameter_value_pair( - HOST_COMPILER, - CLANG, - clang_version, - DEVICE_COMPILER, - NVCC, - nvcc_version, - ), - parameter_value_pairs=param_val_pair_list, - ) - - return param_val_pair_list diff --git a/bashi/versions.py b/bashi/versions.py index ce4ee1a..9b0d21d 100644 --- a/bashi/versions.py +++ b/bashi/versions.py @@ -70,6 +70,8 @@ def __str__(self) -> str: ], CXX_STANDARD: [17, 20], } +# Clang and Clang-CUDA has the same version numbers +VERSIONS[CLANG_CUDA] = copy.copy(VERSIONS[CLANG]) # define the maximum supported gcc version for a specific nvcc version # the latest supported nvcc version must be added, even if the supported gcc version does not @@ -122,12 +124,9 @@ def get_parameter_value_matrix() -> ParameterValueMatrix: """ param_val_matrix: ParameterValueMatrix = OrderedDict() - extended_version = copy.deepcopy(VERSIONS) - extended_version[CLANG_CUDA] = extended_version[CLANG] - for compiler_type in [HOST_COMPILER, DEVICE_COMPILER]: param_val_matrix[compiler_type] = [] - for sw_name, sw_versions in extended_version.items(): + for sw_name, sw_versions in VERSIONS.items(): if sw_name in COMPILERS: for sw_version in sw_versions: param_val_matrix[compiler_type].append( @@ -137,7 +136,7 @@ def get_parameter_value_matrix() -> ParameterValueMatrix: for backend in BACKENDS: if backend == ALPAKA_ACC_GPU_CUDA_ENABLE: param_val_matrix[backend] = [ParameterValue(backend, OFF_VER)] - for cuda_version in extended_version[NVCC]: + for cuda_version in VERSIONS[NVCC]: param_val_matrix[backend].append( ParameterValue(backend, pkv.parse(str(cuda_version))) ) @@ -147,7 +146,7 @@ def get_parameter_value_matrix() -> ParameterValueMatrix: ParameterValue(backend, ON_VER), ] - for other, versions in extended_version.items(): + for other, versions in VERSIONS.items(): if not other in COMPILERS + BACKENDS: param_val_matrix[other] = [] for version in versions: @@ -177,7 +176,6 @@ def is_supported_version(name: ValueName, version: ValueVersion) -> bool: local_versions = copy.deepcopy(VERSIONS) - local_versions[CLANG_CUDA] = local_versions[CLANG] local_versions[ALPAKA_ACC_GPU_CUDA_ENABLE] = [OFF] local_versions[ALPAKA_ACC_GPU_CUDA_ENABLE] += VERSIONS[NVCC] diff --git a/example/example.py b/example/example.py index eb7daa4..9c7ec6f 100644 --- a/example/example.py +++ b/example/example.py @@ -17,11 +17,10 @@ import sys from bashi.generator import generate_combination_list from bashi.utils import ( - get_expected_bashi_parameter_value_pairs, check_parameter_value_pair_in_combination_list, - remove_parameter_value_pair, - create_parameter_value_pair, + remove_parameter_value_pairs, ) +from bashi.results import get_expected_bashi_parameter_value_pairs from bashi.types import ( ParameterValuePair, ParameterValueTuple, @@ -72,28 +71,14 @@ def verify(combination_list: CombinationList, param_value_matrix: ParameterValue other_backend_versions = [ON] for other_backend_version in other_backend_versions: - - remove_parameter_value_pair( - to_remove=create_parameter_value_pair( - gpu_backend, - gpu_backend, - gpu_version, - other_backend, - other_backend, - other_backend_version, - ), - parameter_value_pairs=expected_param_val_tuple, - ) - remove_parameter_value_pair( - to_remove=create_parameter_value_pair( - other_backend, - other_backend, - other_backend_version, - gpu_backend, - gpu_backend, - gpu_version, - ), - parameter_value_pairs=expected_param_val_tuple, + remove_parameter_value_pairs( + expected_param_val_tuple, + parameter1=gpu_backend, + value_name1=gpu_backend, + value_version1=gpu_version, + parameter2=other_backend, + value_name2=other_backend, + value_version2=other_backend_version, ) cpu_backends = set(BACKENDS) - gpu_backends @@ -102,27 +87,14 @@ def verify(combination_list: CombinationList, param_value_matrix: ParameterValue for cpu_backend in cpu_backends: for other_cpu_backend in cpu_backends: if cpu_backend != other_cpu_backend: - remove_parameter_value_pair( - to_remove=create_parameter_value_pair( - cpu_backend, - cpu_backend, - ON_VER, - other_cpu_backend, - other_cpu_backend, - OFF_VER, - ), - parameter_value_pairs=expected_param_val_tuple, - ) - remove_parameter_value_pair( - to_remove=create_parameter_value_pair( - other_cpu_backend, - other_cpu_backend, - OFF_VER, - cpu_backend, - cpu_backend, - ON_VER, - ), - parameter_value_pairs=expected_param_val_tuple, + remove_parameter_value_pairs( + expected_param_val_tuple, + parameter1=cpu_backend, + value_name1=cpu_backend, + value_version1=ON, + parameter2=other_cpu_backend, + value_name2=other_cpu_backend, + value_version2=OFF, ) return check_parameter_value_pair_in_combination_list( diff --git a/tests/test_expected_parameter_value_pairs.py b/tests/test_expected_parameter_value_pairs.py index 555cce0..fa28398 100644 --- a/tests/test_expected_parameter_value_pairs.py +++ b/tests/test_expected_parameter_value_pairs.py @@ -2,11 +2,16 @@ import unittest import copy from typing import List, Dict -from collections import OrderedDict +from collections import OrderedDict as OD import io import packaging.version as pkv -from utils_test import parse_param_val, parse_param_vals, parse_expected_val_pairs +from utils_test import ( + parse_param_val, + parse_param_vals, + parse_expected_val_pairs, + create_diff_parameter_value_pairs, +) from covertable import make from bashi.types import ( Parameter, @@ -20,7 +25,7 @@ from bashi.utils import ( get_expected_parameter_value_pairs, check_parameter_value_pair_in_combination_list, - remove_parameter_value_pair, + remove_parameter_value_pairs, create_parameter_value_pair, ) @@ -180,7 +185,7 @@ def test_create_parameter_value_pair_type_mixed(self): class TestExpectedValuePairs(unittest.TestCase): @classmethod def setUpClass(cls): - cls.param_matrix: ParameterValueMatrix = OrderedDict() + cls.param_matrix: ParameterValueMatrix = OD() cls.param_matrix[HOST_COMPILER] = parse_param_vals( [(GCC, 10), (GCC, 11), (GCC, 12), (CLANG, 16), (CLANG, 17)] @@ -195,8 +200,6 @@ def setUpClass(cls): get_expected_parameter_value_pairs(cls.param_matrix) ) - OD = OrderedDict - cls.expected_param_val_pairs: List[ParameterValuePair] = parse_expected_val_pairs( [ OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), @@ -360,8 +363,6 @@ def test_check_parameter_value_pair_in_combination_list_empty_input(self): ) def test_check_parameter_value_pair_in_combination_list_less_valid_input(self): - OD = OrderedDict - # all pairs exists in the combination list, but not all pairs are tested self.assertTrue( check_parameter_value_pair_in_combination_list( @@ -385,8 +386,6 @@ def test_check_parameter_value_pair_in_combination_list_complete_valid_input(sel ) def test_check_parameter_value_pair_in_combination_list_single_wrong_input(self): - OD = OrderedDict - single_wrong_pair = parse_expected_val_pairs( [ OD({HOST_COMPILER: (GCC, 11), DEVICE_COMPILER: (NVCC, 11.2)}), @@ -413,8 +412,6 @@ def test_check_parameter_value_pair_in_combination_list_single_wrong_input(self) ) def test_check_parameter_value_pair_in_combination_list_many_wrong_input(self): - OD = OrderedDict - many_wrong_pairs = parse_expected_val_pairs( [ OD({HOST_COMPILER: (GCC, 11), DEVICE_COMPILER: (NVCC, 11.2)}), @@ -450,8 +447,6 @@ def test_check_parameter_value_pair_in_combination_list_many_wrong_input(self): self.assertEqual(output_wrong_many_pairs_list, expected_output_many_wrong_pairs_list) def test_check_parameter_value_pair_in_combination_list_complete_list_plus_wrong_input(self): - OD = OrderedDict - many_wrong_pairs = parse_expected_val_pairs( [ OD({HOST_COMPILER: (GCC, 11), DEVICE_COMPILER: (NVCC, 11.2)}), @@ -497,18 +492,16 @@ def test_unrestricted_covertable_generator(self): ) # type: ignore for all_pair in all_pairs: - comb_list.append(OrderedDict(all_pair)) + comb_list.append(OD(all_pair)) self.assertTrue( check_parameter_value_pair_in_combination_list(comb_list, self.expected_param_val_pairs) ) -class TestRemoveExpectedParameterValuePair(unittest.TestCase): +class TestRemoveExpectedParameterValuePairs(unittest.TestCase): def test_remove_parameter_value_pair(self): - OD = OrderedDict - - expected_param_value_pairs: List[ParameterValuePair] = parse_expected_val_pairs( + test_param_value_pairs: List[ParameterValuePair] = parse_expected_val_pairs( [ OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.0)}), @@ -516,234 +509,746 @@ def test_remove_parameter_value_pair(self): OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), ] ) - original_length = len(expected_param_value_pairs) + original_length = len(test_param_value_pairs) + + t1_no_remove = copy.deepcopy(test_param_value_pairs) self.assertFalse( - remove_parameter_value_pair( - create_parameter_value_pair(HOST_COMPILER, GCC, 9, DEVICE_COMPILER, NVCC, 11.2), - expected_param_value_pairs, + remove_parameter_value_pairs( + t1_no_remove, + HOST_COMPILER, + GCC, + 9, + DEVICE_COMPILER, + NVCC, + 11.2, ) ) - self.assertEqual(len(expected_param_value_pairs), original_length) + t1_no_remove.sort() + t1_expected = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + ] + ) + ) + self.assertEqual( + t1_no_remove, t1_expected, create_diff_parameter_value_pairs(t1_no_remove, t1_expected) + ) + self.assertEqual(len(t1_no_remove), original_length) + + t2_remove_single_entry = copy.deepcopy(t1_no_remove) self.assertTrue( - remove_parameter_value_pair( - create_parameter_value_pair(HOST_COMPILER, GCC, 10, DEVICE_COMPILER, NVCC, 12.0), - expected_param_value_pairs, + remove_parameter_value_pairs( + t2_remove_single_entry, + HOST_COMPILER, + GCC, + 10, + DEVICE_COMPILER, + NVCC, + 12.0, + ) + ) + + t2_remove_single_entry.sort() + t2_expected = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + ] ) ) - self.assertEqual(len(expected_param_value_pairs), original_length - 1) + self.assertEqual( + t2_remove_single_entry, + t2_expected, + create_diff_parameter_value_pairs(t2_remove_single_entry, t2_expected), + ) + self.assertEqual(len(t2_remove_single_entry), original_length - 1) + t3_remove_another_entry = copy.deepcopy(t2_remove_single_entry) self.assertTrue( - remove_parameter_value_pair( - create_parameter_value_pair(CMAKE, CMAKE, 3.23, BOOST, BOOST, 1.83), - expected_param_value_pairs, + remove_parameter_value_pairs( + t3_remove_another_entry, + CMAKE, + CMAKE, + 3.23, + BOOST, + BOOST, + 1.83, ) ) - self.assertEqual(len(expected_param_value_pairs), original_length - 2) - def test_remove_parameter_value_single(self): - OD = OrderedDict - ppv = parse_param_val + t3_remove_another_entry.sort() + t3_expected = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 12.0)}), + ] + ) + ) + self.assertEqual( + t3_remove_another_entry, + t3_expected, + create_diff_parameter_value_pairs(t3_remove_another_entry, t3_expected), + ) + self.assertEqual(len(t3_remove_another_entry), original_length - 2) - expected_param_value_pairs: List[ParameterValuePair] = parse_expected_val_pairs( + def test_all_white_card(self): + test_param_value_pairs: List[ParameterValuePair] = parse_expected_val_pairs( [ OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.0)}), - OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.2)}), OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 12.0)}), OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), ] ) - original_length = len(expected_param_value_pairs) - # all_versions=True is not support for ParameterValueSingle - self.assertRaises( - RuntimeError, - remove_parameter_value_pair, - ParameterValueSingle(HOST_COMPILER, ppv((GCC, 12))), - expected_param_value_pairs, - True, + self.assertTrue( + remove_parameter_value_pairs( + test_param_value_pairs, + parameter1=ANY_PARAM, + value_name1=ANY_NAME, + value_version1=ANY_VERSION, + parameter2=ANY_PARAM, + value_name2=ANY_NAME, + value_version2=ANY_VERSION, + ) ) - self.assertFalse( - remove_parameter_value_pair( - ParameterValueSingle(HOST_COMPILER, ppv((GCC, 12))), - expected_param_value_pairs, + self.assertEqual(len(test_param_value_pairs), 0) + + def test_single_white_card(self): + test_param_value_pairs: List[ParameterValuePair] = parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (CLANG, 17)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (GCC, 17)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({HOST_COMPILER: (CLANG, 10), BOOST: (BOOST, 1.83)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (NVCC, 12.0)}), + ] + ) + test_original_len = len(test_param_value_pairs) + + t1_any_version1_param_value_pairs = copy.deepcopy(test_param_value_pairs) + self.assertTrue( + remove_parameter_value_pairs( + t1_any_version1_param_value_pairs, + parameter1=HOST_COMPILER, + value_name1=GCC, + value_version1=ANY_VERSION, + parameter2=DEVICE_COMPILER, + value_name2=NVCC, + value_version2=12.0, + ) + ) + t1_any_version1_param_value_pairs.sort() + t1_expected = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (CLANG, 17)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (GCC, 17)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({HOST_COMPILER: (CLANG, 10), BOOST: (BOOST, 1.83)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (NVCC, 12.0)}), + ] ) ) - self.assertEqual(len(expected_param_value_pairs), original_length) + self.assertEqual( + t1_any_version1_param_value_pairs, + t1_expected, + create_diff_parameter_value_pairs(t1_any_version1_param_value_pairs, t1_expected), + ) + self.assertEqual(len(t1_any_version1_param_value_pairs), test_original_len - 2) - self.assertFalse( - remove_parameter_value_pair( - ParameterValueSingle(HOST_COMPILER, ppv((CLANG, 12))), - expected_param_value_pairs, + t2_any_name1_param_value_pairs = copy.deepcopy(test_param_value_pairs) + self.assertTrue( + remove_parameter_value_pairs( + t2_any_name1_param_value_pairs, + parameter1=HOST_COMPILER, + value_name1=ANY_NAME, + value_version1=10, + parameter2=DEVICE_COMPILER, + value_name2=NVCC, + value_version2=12.0, ) ) - self.assertEqual(len(expected_param_value_pairs), original_length) - self.assertFalse( - remove_parameter_value_pair( - ParameterValueSingle(UBUNTU, ppv((UBUNTU, 20.04))), - expected_param_value_pairs, + t2_any_name1_param_value_pairs.sort() + t2_expected = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (CLANG, 17)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (GCC, 17)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({HOST_COMPILER: (CLANG, 10), BOOST: (BOOST, 1.83)}), + ] ) ) - self.assertEqual(len(expected_param_value_pairs), original_length) + self.assertEqual( + t2_any_name1_param_value_pairs, + t2_expected, + create_diff_parameter_value_pairs(t2_any_name1_param_value_pairs, t2_expected), + ) + self.assertEqual(len(t2_any_name1_param_value_pairs), test_original_len - 2) + + def test_white_card_multi_parameter(self): + t1_any_parameter_param_value_pairs: List[ParameterValuePair] = parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({BOOST: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (CLANG, 17)}), + OD({HOST_COMPILER: (CLANG, 17), DEVICE_COMPILER: (CLANG, 16)}), + OD({CMAKE: (GCC, 10), UBUNTU: (NVCC, 11.2)}), + ] + ) + test_original_len = len(t1_any_parameter_param_value_pairs) self.assertTrue( - remove_parameter_value_pair( - ParameterValueSingle(HOST_COMPILER, ppv((GCC, 9))), - expected_param_value_pairs, + remove_parameter_value_pairs( + t1_any_parameter_param_value_pairs, + parameter1=ANY_PARAM, + value_name1=GCC, + value_version1=10, + parameter2=ANY_PARAM, + value_name2=NVCC, + value_version2=11.2, + ) + ) + + t1_any_parameter_param_value_pairs.sort() + t1_expected = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (CLANG, 17)}), + OD({HOST_COMPILER: (CLANG, 17), DEVICE_COMPILER: (CLANG, 16)}), + ] ) ) - self.assertEqual(len(expected_param_value_pairs), original_length - 2) self.assertEqual( - expected_param_value_pairs, + t1_any_parameter_param_value_pairs, + t1_expected, + create_diff_parameter_value_pairs(t1_any_parameter_param_value_pairs, t1_expected), + ) + self.assertEqual(len(t1_any_parameter_param_value_pairs), test_original_len - 3) + + def test_remove_all_gcc_host(self): + test_param_value_pairs: List[ParameterValuePair] = parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (CLANG, 17)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (GCC, 17)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({HOST_COMPILER: (CLANG, 10), BOOST: (BOOST, 1.83)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (NVCC, 12.0)}), + ] + ) + test_original_len = len(test_param_value_pairs) + + self.assertTrue( + remove_parameter_value_pairs( + test_param_value_pairs, + parameter1=HOST_COMPILER, + value_name1=GCC, + value_version1=ANY_VERSION, + ) + ) + + test_param_value_pairs.sort() + t_expected = sorted( + parse_expected_val_pairs( + [ + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({HOST_COMPILER: (CLANG, 10), BOOST: (BOOST, 1.83)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (NVCC, 12.0)}), + ] + ) + ) + self.assertEqual( + test_param_value_pairs, + t_expected, + create_diff_parameter_value_pairs(test_param_value_pairs, t_expected), + ) + self.assertEqual(len(test_param_value_pairs), test_original_len - 5) + + def test_symmetric(self): + test_param_value_pairs: List[ParameterValuePair] = parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({DEVICE_COMPILER: (NVCC, 11.2), HOST_COMPILER: (GCC, 10)}), + OD({DEVICE_COMPILER: (NVCC, 12.0), HOST_COMPILER: (GCC, 10)}), + OD({BOOST: (BOOST, 1.83), CMAKE: (CMAKE, 3.23)}), + ] + ) + test_original_len = len(test_param_value_pairs) + + t1_single_hit_symmetric_param_value_pairs = copy.deepcopy(test_param_value_pairs) + self.assertTrue( + remove_parameter_value_pairs( + t1_single_hit_symmetric_param_value_pairs, + parameter1=HOST_COMPILER, + value_name1=GCC, + value_version1=10, + parameter2=DEVICE_COMPILER, + value_name2=NVCC, + value_version2=12.0, + ) + ) + + t1_single_hit_symmetric_param_value_pairs.sort() + t1_expected = sorted( parse_expected_val_pairs( [ OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), - OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.0)}), OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({DEVICE_COMPILER: (NVCC, 11.2), HOST_COMPILER: (GCC, 10)}), + OD({BOOST: (BOOST, 1.83), CMAKE: (CMAKE, 3.23)}), ] + ) + ) + + self.assertEqual( + t1_single_hit_symmetric_param_value_pairs, + t1_expected, + create_diff_parameter_value_pairs( + t1_single_hit_symmetric_param_value_pairs, t1_expected ), ) + self.assertEqual(len(t1_single_hit_symmetric_param_value_pairs), test_original_len - 2) + + t2_single_hit_no_symmetric_param_value_pairs = copy.deepcopy(test_param_value_pairs) + self.assertTrue( + remove_parameter_value_pairs( + t2_single_hit_no_symmetric_param_value_pairs, + parameter1=HOST_COMPILER, + value_name1=GCC, + value_version1=10, + parameter2=DEVICE_COMPILER, + value_name2=NVCC, + value_version2=12.0, + symmetric=False, + ) + ) - def test_remove_parameter_value_pair_all_versions(self): - versions = { - GCC: [9, 10, 11, 12, 13], - CLANG: [13, 14, 15, 16, 17], - NVCC: [11.0, 11.1, 11.2, 11.3, 11.4], - HIPCC: [5.0, 5.1, 5.2, 5.3], - CMAKE: [3.22, 3.23, 3.24], - BOOST: [1.80, 1.81, 1.82], - } + t2_single_hit_no_symmetric_param_value_pairs.sort() + t2_expected = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({DEVICE_COMPILER: (NVCC, 11.2), HOST_COMPILER: (GCC, 10)}), + OD({DEVICE_COMPILER: (NVCC, 12.0), HOST_COMPILER: (GCC, 10)}), + OD({BOOST: (BOOST, 1.83), CMAKE: (CMAKE, 3.23)}), + ] + ) + ) - param_val_matrix: ParameterValueMatrix = OrderedDict() - for compiler in [HOST_COMPILER, DEVICE_COMPILER]: - param_val_matrix[compiler] = [] - for compiler_name in [GCC, CLANG, NVCC, HIPCC]: - for compiler_version in versions[compiler_name]: - param_val_matrix[compiler].append( - ParameterValue(compiler_name, pkv.parse(str(compiler_version))) - ) + self.assertEqual( + t2_single_hit_no_symmetric_param_value_pairs, + t2_expected, + create_diff_parameter_value_pairs( + t2_single_hit_no_symmetric_param_value_pairs, t2_expected + ), + ) + self.assertEqual(len(t2_single_hit_no_symmetric_param_value_pairs), test_original_len - 1) - for sw in [CMAKE, BOOST]: - param_val_matrix[sw] = [] - for version in versions[sw]: - param_val_matrix[sw].append(ParameterValue(sw, pkv.parse(str(version)))) + t3_single_hit_no_symmetric_param_value_pairs = copy.deepcopy(test_param_value_pairs) + self.assertTrue( + remove_parameter_value_pairs( + t3_single_hit_no_symmetric_param_value_pairs, + parameter1=DEVICE_COMPILER, + value_name1=NVCC, + value_version1=12.0, + parameter2=HOST_COMPILER, + value_name2=GCC, + value_version2=10, + symmetric=False, + ) + ) - reduced_param_value_pairs = get_expected_parameter_value_pairs(param_val_matrix) + t3_single_hit_no_symmetric_param_value_pairs.sort() + t3_expected = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({DEVICE_COMPILER: (NVCC, 11.2), HOST_COMPILER: (GCC, 10)}), + OD({BOOST: (BOOST, 1.83), CMAKE: (CMAKE, 3.23)}), + ] + ) + ) - expected_number_of_reduced_pairs = len(reduced_param_value_pairs) + self.assertEqual( + t3_single_hit_no_symmetric_param_value_pairs, + t3_expected, + create_diff_parameter_value_pairs( + t3_single_hit_no_symmetric_param_value_pairs, t3_expected + ), + ) + self.assertEqual(len(t3_single_hit_no_symmetric_param_value_pairs), test_original_len - 1) - expected_reduced_param_value_pairs = copy.deepcopy(reduced_param_value_pairs) + t4_multi_hit_symmetric_param_value_pairs = copy.deepcopy(test_param_value_pairs) + self.assertTrue( + remove_parameter_value_pairs( + t4_multi_hit_symmetric_param_value_pairs, + parameter1=HOST_COMPILER, + value_name1=GCC, + value_version1=ANY_VERSION, + ) + ) - # remove single value to verify that default flag is working - example_single_pair = create_parameter_value_pair( - HOST_COMPILER, - NVCC, - 11.0, - DEVICE_COMPILER, - NVCC, - 11.3, + t4_multi_hit_symmetric_param_value_pairs.sort() + t4_expected = sorted( + parse_expected_val_pairs( + [ + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({BOOST: (BOOST, 1.83), CMAKE: (CMAKE, 3.23)}), + ] + ) ) - expected_reduced_param_value_pairs.remove(example_single_pair) + self.assertEqual( + t4_multi_hit_symmetric_param_value_pairs, + t4_expected, + create_diff_parameter_value_pairs( + t4_multi_hit_symmetric_param_value_pairs, t4_expected + ), + ) + self.assertEqual(len(t4_multi_hit_symmetric_param_value_pairs), test_original_len - 4) + t5_multi_hit_no_symmetric_param_value_pairs = copy.deepcopy(test_param_value_pairs) self.assertTrue( - remove_parameter_value_pair( - to_remove=example_single_pair, - parameter_value_pairs=reduced_param_value_pairs, + remove_parameter_value_pairs( + t5_multi_hit_no_symmetric_param_value_pairs, + parameter2=HOST_COMPILER, + value_name2=GCC, + value_version2=ANY_VERSION, + symmetric=False, ) ) - # remove single entry - expected_number_of_reduced_pairs -= 1 - self.assertEqual(len(reduced_param_value_pairs), expected_number_of_reduced_pairs) - - reduced_param_value_pairs.sort() - expected_reduced_param_value_pairs.sort() - self.assertEqual(reduced_param_value_pairs, expected_reduced_param_value_pairs) + t5_multi_hit_no_symmetric_param_value_pairs.sort() + t5_expected = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({BOOST: (BOOST, 1.83), CMAKE: (CMAKE, 3.23)}), + ] + ) + ) - # remove all expected tuples, where host and device compiler is nvcc - def filter_function1(param_val_pair: ParameterValuePair) -> bool: - if ( - param_val_pair.first.parameter == HOST_COMPILER - and param_val_pair.second.parameter == DEVICE_COMPILER - ): - if ( - param_val_pair.first.parameterValue.name == NVCC - and param_val_pair.second.parameterValue.name == NVCC - ): - return False + self.assertEqual( + t5_multi_hit_no_symmetric_param_value_pairs, + t5_expected, + create_diff_parameter_value_pairs( + t5_multi_hit_no_symmetric_param_value_pairs, t5_expected + ), + ) + self.assertEqual(len(t5_multi_hit_no_symmetric_param_value_pairs), test_original_len - 2) - return True + def test_single_specifier_set(self): + test_param_value_pairs: List[ParameterValuePair] = parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.0)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.1)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.3)}), + OD({HOST_COMPILER: (GCC, 7), DEVICE_COMPILER: (NVCC, 11.4)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.5)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.6)}), + OD({HOST_COMPILER: (GCC, 8), DEVICE_COMPILER: (NVCC, 11.7)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.8)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (GCC, 11), DEVICE_COMPILER: (NVCC, 12.1)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.2)}), + OD({HOST_COMPILER: (GCC, 7), DEVICE_COMPILER: (NVCC, 12.3)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + ] + ) + test_original_len = len(test_param_value_pairs) - expected_reduced_param_value_pairs[:] = list( - filter(filter_function1, expected_reduced_param_value_pairs) + t1_remove_cuda11 = copy.deepcopy(test_param_value_pairs) + self.assertTrue( + remove_parameter_value_pairs( + t1_remove_cuda11, + parameter2=DEVICE_COMPILER, + value_name2=NVCC, + value_version2=">=12", + ) ) + t1_remove_cuda11.sort() + t1_expected = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (GCC, 11), DEVICE_COMPILER: (NVCC, 12.1)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.2)}), + OD({HOST_COMPILER: (GCC, 7), DEVICE_COMPILER: (NVCC, 12.3)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + ] + ) + ) + self.assertEqual( + sorted(t1_remove_cuda11), + t1_expected, + create_diff_parameter_value_pairs(t1_remove_cuda11, t1_expected), + ) + self.assertEqual(len(t1_remove_cuda11), test_original_len - 9) + t2_cuda113_to_cuda122_ignore_cuda116 = copy.deepcopy(test_param_value_pairs) self.assertTrue( - remove_parameter_value_pair( - to_remove=create_parameter_value_pair( - HOST_COMPILER, - NVCC, - 0, - DEVICE_COMPILER, - NVCC, - 0, - ), - parameter_value_pairs=reduced_param_value_pairs, - all_versions=True, + remove_parameter_value_pairs( + t2_cuda113_to_cuda122_ignore_cuda116, + parameter2=DEVICE_COMPILER, + value_name2=NVCC, + value_version2=">=11.3,<12.3,!=11.6", ) ) - # remove number of pairs, where host and device compiler is nvcc - # -1 because we removed already a combination manually before - expected_number_of_reduced_pairs -= len(versions[NVCC]) * len(versions[NVCC]) - 1 - self.assertEqual(len(reduced_param_value_pairs), expected_number_of_reduced_pairs) + t2_cuda113_to_cuda122_ignore_cuda116.sort() + t2_expected = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.3)}), + OD({HOST_COMPILER: (GCC, 7), DEVICE_COMPILER: (NVCC, 11.4)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.5)}), + OD({HOST_COMPILER: (GCC, 8), DEVICE_COMPILER: (NVCC, 11.7)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.8)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (GCC, 11), DEVICE_COMPILER: (NVCC, 12.1)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.2)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + ] + ) + ) + self.assertEqual( + t2_cuda113_to_cuda122_ignore_cuda116, + t2_expected, + create_diff_parameter_value_pairs(t2_cuda113_to_cuda122_ignore_cuda116, t2_expected), + ) + self.assertEqual(len(t2_cuda113_to_cuda122_ignore_cuda116), test_original_len - 5) - reduced_param_value_pairs.sort() - expected_reduced_param_value_pairs.sort() - self.assertEqual(reduced_param_value_pairs, expected_reduced_param_value_pairs) + t3_gcc_8_and_9 = copy.deepcopy(test_param_value_pairs) + self.assertTrue( + remove_parameter_value_pairs( + t3_gcc_8_and_9, + parameter1=HOST_COMPILER, + value_name1=GCC, + value_version1=">=8,<=9", + ) + ) - # remove all combinations where HIPCC is the host compiler and nvcc the device compiler - def filter_function2(param_val_pair: ParameterValuePair) -> bool: - if ( - param_val_pair.first.parameter == HOST_COMPILER - and param_val_pair.second.parameter == DEVICE_COMPILER - ): - if ( - param_val_pair.first.parameterValue.name == HIPCC - and param_val_pair.second.parameterValue.name == NVCC - ): - return False + t3_gcc_8_and_9.sort() + t3_expected = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.6)}), + OD({HOST_COMPILER: (GCC, 8), DEVICE_COMPILER: (NVCC, 11.7)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.8)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + ] + ) + ) + self.assertEqual( + t3_gcc_8_and_9, + t3_expected, + create_diff_parameter_value_pairs(t3_gcc_8_and_9, t3_expected), + ) + self.assertEqual(len(t3_gcc_8_and_9), test_original_len - 9) - return True + def test_multi_specifier_set(self): + test_param_value_pairs: List[ParameterValuePair] = parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.0)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.1)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.3)}), + OD({HOST_COMPILER: (GCC, 7), DEVICE_COMPILER: (NVCC, 11.4)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.5)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.6)}), + OD({HOST_COMPILER: (GCC, 8), DEVICE_COMPILER: (NVCC, 11.7)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.8)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (GCC, 11), DEVICE_COMPILER: (NVCC, 12.1)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.2)}), + OD({HOST_COMPILER: (GCC, 7), DEVICE_COMPILER: (NVCC, 12.3)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + ] + ) + test_original_len = len(test_param_value_pairs) - expected_reduced_param_value_pairs[:] = list( - filter(filter_function2, expected_reduced_param_value_pairs) + t1_remove_specific_gcc_and_cuda = copy.deepcopy(test_param_value_pairs) + self.assertTrue( + remove_parameter_value_pairs( + t1_remove_specific_gcc_and_cuda, + parameter1=HOST_COMPILER, + value_name1=GCC, + value_version1=">=10", + parameter2=DEVICE_COMPILER, + value_name2=NVCC, + value_version2=">=11.3,<=12.2,!=11.6", + ) + ) + t1_remove_specific_gcc_and_cuda.sort() + t1_expected = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.3)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.5)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (GCC, 11), DEVICE_COMPILER: (NVCC, 12.1)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.2)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + ] + ) + ) + self.assertEqual( + sorted(t1_remove_specific_gcc_and_cuda), + t1_expected, + create_diff_parameter_value_pairs(t1_remove_specific_gcc_and_cuda, t1_expected), ) + self.assertEqual(len(t1_remove_specific_gcc_and_cuda), test_original_len - 8) + def test_version_and_specifier_set(self): + test_param_value_pairs: List[ParameterValuePair] = parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.0)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.1)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.3)}), + OD({HOST_COMPILER: (GCC, 7), DEVICE_COMPILER: (NVCC, 11.4)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.5)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.6)}), + OD({HOST_COMPILER: (GCC, 8), DEVICE_COMPILER: (NVCC, 11.7)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.8)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (GCC, 11), DEVICE_COMPILER: (NVCC, 12.1)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.2)}), + OD({HOST_COMPILER: (GCC, 7), DEVICE_COMPILER: (NVCC, 12.3)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + ] + ) + test_original_len = len(test_param_value_pairs) + + t1_remove_specific_gcc_and_cuda = copy.deepcopy(test_param_value_pairs) self.assertTrue( - remove_parameter_value_pair( - to_remove=create_parameter_value_pair( - HOST_COMPILER, - HIPCC, - 0, - DEVICE_COMPILER, - NVCC, - 0, - ), - parameter_value_pairs=reduced_param_value_pairs, - all_versions=True, + remove_parameter_value_pairs( + t1_remove_specific_gcc_and_cuda, + parameter1=HOST_COMPILER, + value_name1=GCC, + value_version1="10", + parameter2=DEVICE_COMPILER, + value_name2=NVCC, + value_version2=">=11.3,<=12.2,!=11.6", + ) + ) + t1_remove_specific_gcc_and_cuda.sort() + t1_expected = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.3)}), + OD({HOST_COMPILER: (GCC, 7), DEVICE_COMPILER: (NVCC, 11.4)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.5)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.6)}), + OD({HOST_COMPILER: (GCC, 8), DEVICE_COMPILER: (NVCC, 11.7)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.8)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (GCC, 11), DEVICE_COMPILER: (NVCC, 12.1)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.2)}), + OD({HOST_COMPILER: (GCC, 7), DEVICE_COMPILER: (NVCC, 12.3)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + ] ) ) + self.assertEqual( + sorted(t1_remove_specific_gcc_and_cuda), + t1_expected, + create_diff_parameter_value_pairs(t1_remove_specific_gcc_and_cuda, t1_expected), + ) + self.assertEqual(len(t1_remove_specific_gcc_and_cuda), test_original_len - 2) - # remove number pairs, where host compiler is HIPCC and device compiler is nvcc - expected_number_of_reduced_pairs -= len(versions[HIPCC]) * len(versions[NVCC]) - self.assertEqual(len(reduced_param_value_pairs), expected_number_of_reduced_pairs) + def test_specifier_set_and_version(self): + test_param_value_pairs: List[ParameterValuePair] = parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.0)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.1)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.3)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.3)}), + OD({HOST_COMPILER: (GCC, 11), DEVICE_COMPILER: (NVCC, 11.3)}), + OD({HOST_COMPILER: (GCC, 7), DEVICE_COMPILER: (NVCC, 11.3)}), + OD({HOST_COMPILER: (GCC, 7), DEVICE_COMPILER: (NVCC, 11.4)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.5)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.6)}), + OD({HOST_COMPILER: (GCC, 8), DEVICE_COMPILER: (NVCC, 11.7)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.8)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (GCC, 11), DEVICE_COMPILER: (NVCC, 12.1)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.2)}), + OD({HOST_COMPILER: (GCC, 7), DEVICE_COMPILER: (NVCC, 12.3)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + ] + ) + test_original_len = len(test_param_value_pairs) - reduced_param_value_pairs.sort() - expected_reduced_param_value_pairs.sort() - self.assertEqual(reduced_param_value_pairs, expected_reduced_param_value_pairs) + t1_remove_specific_gcc_and_cuda = copy.deepcopy(test_param_value_pairs) + self.assertTrue( + remove_parameter_value_pairs( + t1_remove_specific_gcc_and_cuda, + parameter1=HOST_COMPILER, + value_name1=GCC, + value_version1=">=10", + parameter2=DEVICE_COMPILER, + value_name2=NVCC, + value_version2="11.3", + ) + ) + t1_remove_specific_gcc_and_cuda.sort() + t1_expected = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.0)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.1)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.3)}), + OD({HOST_COMPILER: (GCC, 11), DEVICE_COMPILER: (NVCC, 11.3)}), + OD({HOST_COMPILER: (GCC, 7), DEVICE_COMPILER: (NVCC, 11.4)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.5)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.6)}), + OD({HOST_COMPILER: (GCC, 8), DEVICE_COMPILER: (NVCC, 11.7)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.8)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (GCC, 11), DEVICE_COMPILER: (NVCC, 12.1)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 12.2)}), + OD({HOST_COMPILER: (GCC, 7), DEVICE_COMPILER: (NVCC, 12.3)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + ] + ) + ) + self.assertEqual( + sorted(t1_remove_specific_gcc_and_cuda), + t1_expected, + create_diff_parameter_value_pairs(t1_remove_specific_gcc_and_cuda, t1_expected), + ) + self.assertEqual(len(t1_remove_specific_gcc_and_cuda), test_original_len - 2) diff --git a/tests/test_generate_combination_list.py b/tests/test_generate_combination_list.py index 67c39cf..bb2c821 100644 --- a/tests/test_generate_combination_list.py +++ b/tests/test_generate_combination_list.py @@ -9,14 +9,12 @@ from bashi.versions import get_parameter_value_matrix from bashi.generator import generate_combination_list from bashi.utils import ( - get_expected_bashi_parameter_value_pairs, check_parameter_value_pair_in_combination_list, - remove_parameter_value_pair, - create_parameter_value_pair, + remove_parameter_value_pairs, ) +from bashi.results import get_expected_bashi_parameter_value_pairs from bashi.types import ( ParameterValue, - ParameterValueSingle, ParameterValuePair, ParameterValueTuple, ParameterValueMatrix, @@ -150,25 +148,23 @@ def custom_filter(row: ParameterValueTuple) -> bool: for device_compiler in self.param_matrix[DEVICE_COMPILER]: if device_compiler.name == NVCC: self.assertTrue( - remove_parameter_value_pair( - ParameterValueSingle( - DEVICE_COMPILER, ParameterValue(NVCC, device_compiler.version) - ), + remove_parameter_value_pairs( reduced_expected_param_val_pairs, + parameter1=DEVICE_COMPILER, + value_name1=NVCC, + value_version1=str(device_compiler.version), ) ) self.assertTrue( - remove_parameter_value_pair( - create_parameter_value_pair( - CMAKE, - CMAKE, - "3.23", - BOOST, - BOOST, - "1.82", - ), + remove_parameter_value_pairs( reduced_expected_param_val_pairs, + parameter1=CMAKE, + value_name1=CMAKE, + value_version1="3.23", + parameter2=BOOST, + value_name2=BOOST, + value_version2="1.82", ) ) @@ -217,9 +213,14 @@ def custom_filter(row: ParameterValueTuple) -> bool: ) self.assertTrue( - remove_parameter_value_pair( - create_parameter_value_pair(CMAKE, CMAKE, "3.23", BOOST, BOOST, "1.82"), + remove_parameter_value_pairs( reduced_expected_param_val_pairs, + parameter1=CMAKE, + value_name1=CMAKE, + value_version1="3.23", + parameter2=BOOST, + value_name2=BOOST, + value_version2="1.82", ) ) diff --git a/tests/test_params_value_matrix_generator.py b/tests/test_params_value_matrix_generator.py index fc1de63..7923c98 100644 --- a/tests/test_params_value_matrix_generator.py +++ b/tests/test_params_value_matrix_generator.py @@ -1,6 +1,5 @@ # pylint: disable=missing-docstring import unittest -import copy from bashi.versions import VERSIONS, get_parameter_value_matrix from bashi.globals import * # pylint: disable=wildcard-import,unused-wildcard-import @@ -25,14 +24,9 @@ def test_all_params_in(self): ) def test_number_host_device_compiler(self): - extended_versions = copy.deepcopy(VERSIONS) - # filter clang-cuda 13 and older because the pair-wise generator cannot filter it out - # afterwards - extended_versions[CLANG_CUDA] = extended_versions[CLANG] - number_of_host_compilers = 0 for compiler in COMPILERS: - number_of_host_compilers += len(extended_versions[compiler]) + number_of_host_compilers += len(VERSIONS[compiler]) # NVCC is only as device compiler added number_of_device_compilers = number_of_host_compilers diff --git a/tests/test_results.py b/tests/test_results.py new file mode 100644 index 0000000..bdaa698 --- /dev/null +++ b/tests/test_results.py @@ -0,0 +1,688 @@ +# pylint: disable=missing-docstring +import unittest +import copy +from typing import List +from collections import OrderedDict as OD +import packaging.version as pkv +from utils_test import parse_expected_val_pairs, create_diff_parameter_value_pairs + + +from bashi.types import ParameterValue, ParameterValueSingle, ParameterValuePair +from bashi.globals import * # pylint: disable=wildcard-import,unused-wildcard-import + +# pyright: reportPrivateUsage=false +from bashi.results import ( + _remove_unsupported_nvcc_host_compiler, + _remove_different_compiler_names, + _remove_different_compiler_versions, + _remove_unsupported_nvcc_host_compiler_versions, + _remove_nvcc_unsupported_gcc_versions, + _remove_nvcc_unsupported_clang_versions, + _remove_specific_nvcc_clang_combinations, +) +from bashi.versions import NvccHostSupport, NVCC_GCC_MAX_VERSION + + +class TestExpectedBashiParameterValuesPairs(unittest.TestCase): + def test_nvcc_host_compiler_names(self): + test_param_value_pairs: List[ParameterValuePair] = parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (NVCC, 11.0)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.7)}), + OD({HOST_COMPILER: (HIPCC, 5.1), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (HIPCC, 6.0), DEVICE_COMPILER: (NVCC, 11.3)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (GCC, 10)}), + OD({HOST_COMPILER: (ICPX, "2023.2.0"), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (GCC, 11)}), + OD( + { + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE: (ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE, ON), + ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, 12.2), + } + ), + OD({HOST_COMPILER: (CLANG_CUDA, 16), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (ICPX, "2023.2.0"), DEVICE_COMPILER: (ICPX, "2023.2.0")}), + ] + ) + + _remove_unsupported_nvcc_host_compiler(test_param_value_pairs) + + test_param_value_pairs.sort() + expected_results = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (NVCC, 11.0)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.7)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (GCC, 10)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (GCC, 11)}), + OD( + { + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE: ( + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE, + ON, + ), + ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, 12.2), + } + ), + OD({HOST_COMPILER: (ICPX, "2023.2.0"), DEVICE_COMPILER: (ICPX, "2023.2.0")}), + ] + ) + ) + + self.assertEqual( + test_param_value_pairs, + expected_results, + create_diff_parameter_value_pairs(test_param_value_pairs, expected_results), + ) + + def test_remove_different_compiler_names(self): + test_param_value_pairs: List[ParameterValuePair] = parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (CLANG_CUDA, 16), DEVICE_COMPILER: (CLANG_CUDA, 16)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (CLANG_CUDA, 10)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (CLANG, 7)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.7)}), + OD({HOST_COMPILER: (HIPCC, 5.1), DEVICE_COMPILER: (ICPX, "2024.2.1")}), + OD({HOST_COMPILER: (HIPCC, 6.0), DEVICE_COMPILER: (NVCC, 11.3)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (GCC, 10)}), + OD({HOST_COMPILER: (ICPX, "2023.2.0"), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (GCC, 11)}), + OD( + { + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE: ( + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE, + ON, + ), + ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, 12.2), + } + ), + OD({HOST_COMPILER: (CLANG_CUDA, 16), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (HIPCC, 4.3), DEVICE_COMPILER: (HIPCC, 5.7)}), + OD({HOST_COMPILER: (ICPX, "2023.2.0"), DEVICE_COMPILER: (ICPX, "2023.2.0")}), + ] + ) + + _remove_different_compiler_names(test_param_value_pairs) + + test_param_value_pairs.sort() + expected_results = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (CLANG_CUDA, 16), DEVICE_COMPILER: (CLANG_CUDA, 16)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (CLANG, 7)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.7)}), + OD({HOST_COMPILER: (HIPCC, 6.0), DEVICE_COMPILER: (NVCC, 11.3)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (GCC, 10)}), + OD({HOST_COMPILER: (ICPX, "2023.2.0"), DEVICE_COMPILER: (NVCC, 12.0)}), + OD( + { + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE: ( + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE, + ON, + ), + ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, 12.2), + } + ), + OD({HOST_COMPILER: (CLANG_CUDA, 16), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (HIPCC, 4.3), DEVICE_COMPILER: (HIPCC, 5.7)}), + OD({HOST_COMPILER: (ICPX, "2023.2.0"), DEVICE_COMPILER: (ICPX, "2023.2.0")}), + ] + ) + ) + + self.assertEqual( + test_param_value_pairs, + expected_results, + create_diff_parameter_value_pairs(test_param_value_pairs, expected_results), + ) + + def test_remove_different_compiler_versions(self): + test_param_value_pairs: List[ParameterValuePair] = parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (CLANG_CUDA, 16), DEVICE_COMPILER: (CLANG_CUDA, 16)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (CLANG_CUDA, 10)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (CLANG, 7)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.7)}), + OD({HOST_COMPILER: (HIPCC, 5.3), DEVICE_COMPILER: (HIPCC, 5.3)}), + OD({HOST_COMPILER: (HIPCC, 5.1), DEVICE_COMPILER: (ICPX, "2024.2.1")}), + OD({HOST_COMPILER: (HIPCC, 6.0), DEVICE_COMPILER: (NVCC, 11.3)}), + OD({HOST_COMPILER: (CLANG_CUDA, 6), DEVICE_COMPILER: (CLANG_CUDA, 5)}), + OD({HOST_COMPILER: (GCC, 7), DEVICE_COMPILER: (GCC, 10)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (GCC, 10)}), + OD({HOST_COMPILER: (ICPX, "2023.2.0"), DEVICE_COMPILER: (ICPX, "2022.0.0")}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (GCC, 11)}), + OD( + { + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE: ( + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE, + ON, + ), + ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, 12.2), + } + ), + OD({HOST_COMPILER: (CLANG_CUDA, 16), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (HIPCC, 4.3), DEVICE_COMPILER: (HIPCC, 5.7)}), + OD({HOST_COMPILER: (ICPX, "2023.2.0"), DEVICE_COMPILER: (ICPX, "2023.2.0")}), + ] + ) + + _remove_different_compiler_versions(test_param_value_pairs) + + test_param_value_pairs.sort() + expected_results = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (CLANG_CUDA, 16), DEVICE_COMPILER: (CLANG_CUDA, 16)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (CLANG_CUDA, 10)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.7)}), + OD({HOST_COMPILER: (HIPCC, 5.3), DEVICE_COMPILER: (HIPCC, 5.3)}), + OD({HOST_COMPILER: (HIPCC, 5.1), DEVICE_COMPILER: (ICPX, "2024.2.1")}), + OD({HOST_COMPILER: (HIPCC, 6.0), DEVICE_COMPILER: (NVCC, 11.3)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (GCC, 10)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (GCC, 11)}), + OD( + { + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE: ( + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE, + ON, + ), + ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, 12.2), + } + ), + OD({HOST_COMPILER: (CLANG_CUDA, 16), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (ICPX, "2023.2.0"), DEVICE_COMPILER: (ICPX, "2023.2.0")}), + ] + ) + ) + + self.assertEqual( + test_param_value_pairs, + expected_results, + create_diff_parameter_value_pairs(test_param_value_pairs, expected_results), + ) + + def test_remove_specific_nvcc_clang_combinations(self): + test_param_value_pairs: List[ParameterValuePair] = parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (CLANG_CUDA, 16), DEVICE_COMPILER: (CLANG_CUDA, 16)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.4)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (NVCC, 11.3)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (NVCC, 11.4)}), + OD({HOST_COMPILER: (CLANG, 11), DEVICE_COMPILER: (NVCC, 11.4)}), + OD({HOST_COMPILER: (CLANG, 18), DEVICE_COMPILER: (NVCC, 11.4)}), + OD({HOST_COMPILER: (CLANG, 14), DEVICE_COMPILER: (NVCC, 11.5)}), + OD({HOST_COMPILER: (CLANG, 13), DEVICE_COMPILER: (NVCC, 11.6)}), + OD({HOST_COMPILER: (CLANG, 17), DEVICE_COMPILER: (NVCC, 10.1)}), + OD({HOST_COMPILER: (CLANG, 7), DEVICE_COMPILER: (NVCC, 12.3)}), + OD( + { + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE: ( + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE, + ON, + ), + ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, 12.2), + } + ), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + ] + ) + + _remove_specific_nvcc_clang_combinations(test_param_value_pairs) + + test_param_value_pairs.sort() + expected_results = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (CLANG_CUDA, 16), DEVICE_COMPILER: (CLANG_CUDA, 16)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.4)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (CLANG, 13), DEVICE_COMPILER: (NVCC, 11.6)}), + OD({HOST_COMPILER: (CLANG, 17), DEVICE_COMPILER: (NVCC, 10.1)}), + OD({HOST_COMPILER: (CLANG, 7), DEVICE_COMPILER: (NVCC, 12.3)}), + OD( + { + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE: ( + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE, + ON, + ), + ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, 12.2), + } + ), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + ] + ) + ) + + self.assertEqual( + test_param_value_pairs, + expected_results, + create_diff_parameter_value_pairs(test_param_value_pairs, expected_results), + ) + + +TEST_HOST_COMPILER: str = "test_host_compiler" + + +class TestExpectedBashiParameterValuesPairsNvccHostCompilerVersions(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.gcc_param_value_matrix: List[ParameterValuePair] = parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (CLANG_CUDA, 16), DEVICE_COMPILER: (CLANG_CUDA, 16)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 11), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 12), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 17), DEVICE_COMPILER: (NVCC, 99.0)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.7)}), + OD({HOST_COMPILER: (GCC, 11), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (GCC, 12), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (GCC, 13), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (GCC, 11), DEVICE_COMPILER: (NVCC, 11.8)}), + OD({HOST_COMPILER: (GCC, 12), DEVICE_COMPILER: (NVCC, 11.8)}), + OD({HOST_COMPILER: (GCC, 12), DEVICE_COMPILER: (NVCC, 12.3)}), + OD({HOST_COMPILER: (GCC, 13), DEVICE_COMPILER: (NVCC, 12.3)}), + OD({HOST_COMPILER: (GCC, 7), DEVICE_COMPILER: (NVCC, 10.1)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 10.1)}), + OD({HOST_COMPILER: (HIPCC, 5.3), DEVICE_COMPILER: (HIPCC, 5.3)}), + OD({HOST_COMPILER: (GCC, 7), DEVICE_COMPILER: (GCC, 10)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (GCC, 11)}), + OD( + { + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE: ( + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE, + ON, + ), + ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, 12.2), + } + ), + ] + ) + + cls.test_host_compiler_param_value_pairs: List[ParameterValuePair] = [] + for param_value_pair in cls.gcc_param_value_matrix: + if param_value_pair.first.parameterValue.name == GCC: + cls.test_host_compiler_param_value_pairs.append( + ParameterValuePair( + ParameterValueSingle( + param_value_pair.first.parameter, + ParameterValue( + TEST_HOST_COMPILER, param_value_pair.first.parameterValue.version + ), + ), + param_value_pair.second, + ) + ) + else: + cls.test_host_compiler_param_value_pairs.append(copy.deepcopy(param_value_pair)) + + cls.test_host_compiler_param_value_pairs += parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 12), DEVICE_COMPILER: (NVCC, 12.5)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 13), DEVICE_COMPILER: (NVCC, 12.5)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 14), DEVICE_COMPILER: (NVCC, 12.5)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 12), DEVICE_COMPILER: (NVCC, 12.8)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 13), DEVICE_COMPILER: (NVCC, 12.8)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 14), DEVICE_COMPILER: (NVCC, 12.8)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 15), DEVICE_COMPILER: (NVCC, 12.8)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 16), DEVICE_COMPILER: (NVCC, 12.8)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 12), DEVICE_COMPILER: (NVCC, 12.9)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 13), DEVICE_COMPILER: (NVCC, 12.9)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 14), DEVICE_COMPILER: (NVCC, 12.9)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 15), DEVICE_COMPILER: (NVCC, 12.9)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 16), DEVICE_COMPILER: (NVCC, 12.9)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 5), DEVICE_COMPILER: (NVCC, 10.0)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 6), DEVICE_COMPILER: (NVCC, 10.0)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 7), DEVICE_COMPILER: (NVCC, 10.0)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 52), DEVICE_COMPILER: (NVCC, 9.2)}), + ] + ) + + cls.test_host_compiler_support_list: List[NvccHostSupport] = [ + NvccHostSupport("12.0", "12"), + NvccHostSupport("11.4", "11"), + NvccHostSupport("11.1", "10"), + NvccHostSupport("11.0", "9"), + NvccHostSupport("10.1", "8"), + NvccHostSupport("10.0", "6"), + ] + cls.test_host_compiler_support_list.sort(reverse=True) + + def test_remove_nvcc_unsupported_host_compiler_versions_same_compiler_version_end(self): + test_param_value_pairs: List[ParameterValuePair] = copy.deepcopy( + self.test_host_compiler_param_value_pairs + ) + test_support_list = copy.deepcopy(self.test_host_compiler_support_list) + test_support_list.append(NvccHostSupport("12.7", "13")) + test_support_list.append(NvccHostSupport("12.8", "13")) + + _remove_unsupported_nvcc_host_compiler_versions( + test_param_value_pairs, TEST_HOST_COMPILER, test_support_list + ) + + test_param_value_pairs.sort() + expected_results = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (CLANG_CUDA, 16), DEVICE_COMPILER: (CLANG_CUDA, 16)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 9), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 17), DEVICE_COMPILER: (NVCC, 99.0)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 9), DEVICE_COMPILER: (NVCC, 11.7)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 11), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 12), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 11), DEVICE_COMPILER: (NVCC, 11.8)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 12), DEVICE_COMPILER: (NVCC, 12.3)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 52), DEVICE_COMPILER: (NVCC, 9.2)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 5), DEVICE_COMPILER: (NVCC, 10.0)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 6), DEVICE_COMPILER: (NVCC, 10.0)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 7), DEVICE_COMPILER: (NVCC, 10.1)}), + OD({HOST_COMPILER: (HIPCC, 5.3), DEVICE_COMPILER: (HIPCC, 5.3)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 7), DEVICE_COMPILER: (GCC, 10)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (GCC, 11)}), + OD( + { + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE: ( + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE, + ON, + ), + ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, 12.2), + } + ), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 12), DEVICE_COMPILER: (NVCC, 12.5)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 12), DEVICE_COMPILER: (NVCC, 12.8)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 13), DEVICE_COMPILER: (NVCC, 12.8)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 12), DEVICE_COMPILER: (NVCC, 12.9)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 13), DEVICE_COMPILER: (NVCC, 12.9)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 14), DEVICE_COMPILER: (NVCC, 12.9)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 15), DEVICE_COMPILER: (NVCC, 12.9)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 16), DEVICE_COMPILER: (NVCC, 12.9)}), + ] + ) + ) + self.assertEqual( + test_param_value_pairs, + expected_results, + create_diff_parameter_value_pairs(test_param_value_pairs, expected_results), + ) + + def test_remove_nvcc_unsupported_host_compiler_versions_different_compiler_version_end(self): + test_param_value_pairs: List[ParameterValuePair] = copy.deepcopy( + self.test_host_compiler_param_value_pairs + ) + test_support_list = copy.deepcopy(self.test_host_compiler_support_list) + test_support_list.append(NvccHostSupport("12.7", "13")) + test_support_list.append(NvccHostSupport("12.8", "14")) + + _remove_unsupported_nvcc_host_compiler_versions( + test_param_value_pairs, TEST_HOST_COMPILER, test_support_list + ) + + test_param_value_pairs.sort() + expected_results = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (CLANG_CUDA, 16), DEVICE_COMPILER: (CLANG_CUDA, 16)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 9), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 17), DEVICE_COMPILER: (NVCC, 99.0)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 9), DEVICE_COMPILER: (NVCC, 11.7)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 11), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 12), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 11), DEVICE_COMPILER: (NVCC, 11.8)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 12), DEVICE_COMPILER: (NVCC, 12.3)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 7), DEVICE_COMPILER: (NVCC, 10.1)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 5), DEVICE_COMPILER: (NVCC, 10.0)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 6), DEVICE_COMPILER: (NVCC, 10.0)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 52), DEVICE_COMPILER: (NVCC, 9.2)}), + OD({HOST_COMPILER: (HIPCC, 5.3), DEVICE_COMPILER: (HIPCC, 5.3)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 7), DEVICE_COMPILER: (GCC, 10)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (GCC, 11)}), + OD( + { + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE: ( + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE, + ON, + ), + ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, 12.2), + } + ), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 12), DEVICE_COMPILER: (NVCC, 12.5)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 12), DEVICE_COMPILER: (NVCC, 12.8)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 13), DEVICE_COMPILER: (NVCC, 12.8)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 14), DEVICE_COMPILER: (NVCC, 12.8)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 12), DEVICE_COMPILER: (NVCC, 12.9)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 13), DEVICE_COMPILER: (NVCC, 12.9)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 14), DEVICE_COMPILER: (NVCC, 12.9)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 15), DEVICE_COMPILER: (NVCC, 12.9)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 16), DEVICE_COMPILER: (NVCC, 12.9)}), + ] + ) + ) + self.assertEqual( + test_param_value_pairs, + expected_results, + create_diff_parameter_value_pairs(test_param_value_pairs, expected_results), + ) + + def test_remove_nvcc_unsupported_host_compiler_versions_different_compiler_version_end2(self): + test_param_value_pairs: List[ParameterValuePair] = copy.deepcopy( + self.test_host_compiler_param_value_pairs + ) + test_support_list = copy.deepcopy(self.test_host_compiler_support_list) + test_support_list.append(NvccHostSupport("12.7", "13")) + test_support_list.append(NvccHostSupport("12.8", "15")) + + _remove_unsupported_nvcc_host_compiler_versions( + test_param_value_pairs, TEST_HOST_COMPILER, test_support_list + ) + + test_param_value_pairs.sort() + expected_results = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (CLANG_CUDA, 16), DEVICE_COMPILER: (CLANG_CUDA, 16)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 9), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 17), DEVICE_COMPILER: (NVCC, 99.0)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 9), DEVICE_COMPILER: (NVCC, 11.7)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 11), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 12), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 11), DEVICE_COMPILER: (NVCC, 11.8)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 12), DEVICE_COMPILER: (NVCC, 12.3)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 7), DEVICE_COMPILER: (NVCC, 10.1)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 5), DEVICE_COMPILER: (NVCC, 10.0)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 6), DEVICE_COMPILER: (NVCC, 10.0)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 52), DEVICE_COMPILER: (NVCC, 9.2)}), + OD({HOST_COMPILER: (HIPCC, 5.3), DEVICE_COMPILER: (HIPCC, 5.3)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 7), DEVICE_COMPILER: (GCC, 10)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (GCC, 11)}), + OD( + { + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE: ( + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE, + ON, + ), + ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, 12.2), + } + ), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 12), DEVICE_COMPILER: (NVCC, 12.5)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 12), DEVICE_COMPILER: (NVCC, 12.8)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 13), DEVICE_COMPILER: (NVCC, 12.8)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 14), DEVICE_COMPILER: (NVCC, 12.8)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 15), DEVICE_COMPILER: (NVCC, 12.8)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 12), DEVICE_COMPILER: (NVCC, 12.9)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 13), DEVICE_COMPILER: (NVCC, 12.9)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 14), DEVICE_COMPILER: (NVCC, 12.9)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 15), DEVICE_COMPILER: (NVCC, 12.9)}), + OD({HOST_COMPILER: (TEST_HOST_COMPILER, 16), DEVICE_COMPILER: (NVCC, 12.9)}), + ] + ) + ) + self.assertEqual( + test_param_value_pairs, + expected_results, + create_diff_parameter_value_pairs(test_param_value_pairs, expected_results), + ) + + def test_remove_nvcc_unsupported_gcc_versions(self): + supported_nvcc_versions = [ver.nvcc for ver in NVCC_GCC_MAX_VERSION] + # we assume for the test, that the this nvcc versions are supported by bashi + for nvcc_version in ["10.0", "10.1", "11.0", "11.1", "11.4", "12.0"]: + self.assertIn(pkv.parse(nvcc_version), supported_nvcc_versions) + + # for the test, it is required that CUDA 99.0 is not supported + self.assertFalse(pkv.parse("99.0") in supported_nvcc_versions) + + test_param_value_pairs = copy.deepcopy(self.gcc_param_value_matrix) + + _remove_nvcc_unsupported_gcc_versions(test_param_value_pairs) + + test_param_value_pairs.sort() + expected_results = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (CLANG_CUDA, 16), DEVICE_COMPILER: (CLANG_CUDA, 16)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (GCC, 17), DEVICE_COMPILER: (NVCC, 99.0)}), + OD({HOST_COMPILER: (GCC, 9), DEVICE_COMPILER: (NVCC, 11.7)}), + OD({HOST_COMPILER: (GCC, 11), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (GCC, 12), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (GCC, 11), DEVICE_COMPILER: (NVCC, 11.8)}), + OD({HOST_COMPILER: (GCC, 12), DEVICE_COMPILER: (NVCC, 12.3)}), + OD({HOST_COMPILER: (GCC, 7), DEVICE_COMPILER: (NVCC, 10.1)}), + OD({HOST_COMPILER: (HIPCC, 5.3), DEVICE_COMPILER: (HIPCC, 5.3)}), + OD({HOST_COMPILER: (GCC, 7), DEVICE_COMPILER: (GCC, 10)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (GCC, 11)}), + OD( + { + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE: ( + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE, + ON, + ), + ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, 12.2), + } + ), + ] + ) + ) + + self.assertEqual( + test_param_value_pairs, + expected_results, + create_diff_parameter_value_pairs(test_param_value_pairs, expected_results), + ) + + def test_remove_nvcc_unsupported_clang_versions(self): + supported_nvcc_versions = [ver.nvcc for ver in NVCC_GCC_MAX_VERSION] + # we assume for the test, that the this nvcc versions are supported by bashi + for nvcc_version in ["10.0", "10.1", "11.0", "11.1", "11.4", "12.0"]: + self.assertIn(pkv.parse(nvcc_version), supported_nvcc_versions) + + # for the test, it is required that CUDA 99.0 is not supported + self.assertFalse(pkv.parse("99.0") in supported_nvcc_versions) + + test_param_value_pairs = parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (CLANG_CUDA, 16), DEVICE_COMPILER: (CLANG_CUDA, 16)}), + OD({HOST_COMPILER: (CLANG, 9), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (CLANG, 11), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (CLANG, 12), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (CLANG, 17), DEVICE_COMPILER: (NVCC, 99.0)}), + OD({HOST_COMPILER: (CLANG, 9), DEVICE_COMPILER: (NVCC, 11.7)}), + OD({HOST_COMPILER: (CLANG, 11), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (CLANG, 14), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (CLANG, 17), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (CLANG, 12), DEVICE_COMPILER: (NVCC, 11.8)}), + OD({HOST_COMPILER: (CLANG, 14), DEVICE_COMPILER: (NVCC, 11.8)}), + OD({HOST_COMPILER: (CLANG, 15), DEVICE_COMPILER: (NVCC, 12.3)}), + OD({HOST_COMPILER: (CLANG, 16), DEVICE_COMPILER: (NVCC, 12.3)}), + OD({HOST_COMPILER: (CLANG, 17), DEVICE_COMPILER: (NVCC, 12.3)}), + OD({HOST_COMPILER: (CLANG, 7), DEVICE_COMPILER: (NVCC, 10.1)}), + OD({HOST_COMPILER: (CLANG, 6), DEVICE_COMPILER: (NVCC, 10.0)}), + OD({HOST_COMPILER: (CLANG, 7), DEVICE_COMPILER: (NVCC, 10.0)}), + OD({HOST_COMPILER: (CLANG, 9), DEVICE_COMPILER: (NVCC, 10.1)}), + OD({HOST_COMPILER: (HIPCC, 5.3), DEVICE_COMPILER: (HIPCC, 5.3)}), + OD({HOST_COMPILER: (GCC, 7), DEVICE_COMPILER: (GCC, 10)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (GCC, 11)}), + OD( + { + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE: ( + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE, + ON, + ), + ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, 12.2), + } + ), + ] + ) + + _remove_nvcc_unsupported_clang_versions(test_param_value_pairs) + + test_param_value_pairs.sort() + expected_results = sorted( + parse_expected_val_pairs( + [ + OD({HOST_COMPILER: (CLANG_CUDA, 16), DEVICE_COMPILER: (CLANG_CUDA, 16)}), + OD({HOST_COMPILER: (CLANG, 9), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (CLANG, 11), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({HOST_COMPILER: (CLANG, 17), DEVICE_COMPILER: (NVCC, 99.0)}), + OD({HOST_COMPILER: (CLANG, 9), DEVICE_COMPILER: (NVCC, 11.7)}), + OD({HOST_COMPILER: (CLANG, 11), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (CLANG, 14), DEVICE_COMPILER: (NVCC, 12.0)}), + OD({HOST_COMPILER: (CLANG, 12), DEVICE_COMPILER: (NVCC, 11.8)}), + OD({HOST_COMPILER: (CLANG, 15), DEVICE_COMPILER: (NVCC, 12.3)}), + OD({HOST_COMPILER: (CLANG, 16), DEVICE_COMPILER: (NVCC, 12.3)}), + OD({HOST_COMPILER: (CLANG, 7), DEVICE_COMPILER: (NVCC, 10.1)}), + OD({HOST_COMPILER: (CLANG, 6), DEVICE_COMPILER: (NVCC, 10.0)}), + OD({HOST_COMPILER: (HIPCC, 5.3), DEVICE_COMPILER: (HIPCC, 5.3)}), + OD({HOST_COMPILER: (GCC, 7), DEVICE_COMPILER: (GCC, 10)}), + OD({HOST_COMPILER: (GCC, 10), DEVICE_COMPILER: (NVCC, 11.2)}), + OD({CMAKE: (CMAKE, 3.23), BOOST: (BOOST, 1.83)}), + OD({HOST_COMPILER: (CLANG, 10), DEVICE_COMPILER: (GCC, 11)}), + OD( + { + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE: ( + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE, + ON, + ), + ALPAKA_ACC_GPU_CUDA_ENABLE: (ALPAKA_ACC_GPU_CUDA_ENABLE, 12.2), + } + ), + ] + ) + ) + + self.assertEqual( + test_param_value_pairs, + expected_results, + create_diff_parameter_value_pairs(test_param_value_pairs, expected_results), + ) diff --git a/tests/utils_test.py b/tests/utils_test.py index f6753f4..196e558 100644 --- a/tests/utils_test.py +++ b/tests/utils_test.py @@ -80,3 +80,37 @@ def parse_expected_val_pairs( ) return expected_val_pairs + + +def create_diff_parameter_value_pairs( + given_result: List[ParameterValuePair], expected_result: List[ParameterValuePair] +) -> str: + """Returns a string for a readable output, if two lists of parameter-value-pairs are different. + + Args: + given_result (List[ParameterValuePair]): Results from the test + expected_result (List[ParameterValuePair]): Expected results + + Returns: + str: Output string + """ + output = f"\ngiven ({len(given_result)} elements):\n" + for g_result in sorted(given_result): + output += ( + f" {g_result.first.parameter}=" + f"{g_result.first.parameterValue.name} {g_result.first.parameterValue.version} + " + f"{g_result.second.parameter}=" + f"{g_result.second.parameterValue.name} {g_result.second.parameterValue.version}\n" + ) + + output += f"expected ({len(expected_result)} elements):\n" + + for e_result in sorted(expected_result): + output += ( + f" {e_result.first.parameter}=" + f"{e_result.first.parameterValue.name} {e_result.first.parameterValue.version} + " + f"{e_result.second.parameter}=" + f"{e_result.second.parameterValue.name} {e_result.second.parameterValue.version}\n" + ) + + return output