diff --git a/bashi/filter_chain.py b/bashi/filter_chain.py index 16bfe9c..0aa5b2f 100644 --- a/bashi/filter_chain.py +++ b/bashi/filter_chain.py @@ -3,8 +3,7 @@ from typeguard import typechecked from bashi.types import FilterFunction -from bashi.filter_compiler_name import compiler_name_filter -from bashi.filter_compiler_version import compiler_version_filter +from bashi.filter_compiler import compiler_filter from bashi.filter_backend import backend_filter from bashi.filter_software_dependency import software_dependency_filter @@ -25,8 +24,7 @@ def get_default_filter_chain( FilterFunction: The filter function chain, which can be directly used in bashi.FilterAdapter """ return ( - lambda row: compiler_name_filter(row) - and compiler_version_filter(row) + lambda row: compiler_filter(row) and backend_filter(row) and software_dependency_filter(row) and custom_filter_function(row) diff --git a/bashi/filter_compiler_version.py b/bashi/filter_compiler.py similarity index 67% rename from bashi/filter_compiler_version.py rename to bashi/filter_compiler.py index cd1dd80..814bf0d 100644 --- a/bashi/filter_compiler_version.py +++ b/bashi/filter_compiler.py @@ -1,7 +1,7 @@ """Filter rules basing on host and device compiler names and versions. -All rules implemented in this filter have an identifier that begins with "v" and follows a number. -Examples: v1, v42, v678 ... +All rules implemented in this filter have an identifier that begins with "c" and follows a number. +Examples: c1, c42, c678 ... These identifiers are used in the test names, for example, to make it clear which test is testing which rule. @@ -15,6 +15,9 @@ from bashi.versions import NVCC_GCC_MAX_VERSION, NVCC_CLANG_MAX_VERSION from bashi.utils import reason +# uncomment me for debugging +# from bashi.utils import print_row_nice + def get_required_parameters() -> List[Parameter]: """Return list of parameters which will be checked in the filter. @@ -26,18 +29,19 @@ def get_required_parameters() -> List[Parameter]: @typechecked -def compiler_version_filter_typechecked( +def compiler_filter_typechecked( row: ParameterValueTuple, output: Optional[IO[str]] = None, ) -> bool: - """Type-checked version of compiler_version_filter(). Type checking has a big performance cost, - which is why the non type-checked version is used for the pairwise generator. + """Type-checked version of compiler_filter(). Type checking has a big performance cost, which + is why the non type-checked version is used for the pairwise generator. """ - return compiler_version_filter(row, output) + return compiler_filter(row, output) # pylint: disable=too-many-branches -def compiler_version_filter( +# pylint: disable=too-many-return-statements +def compiler_filter( row: ParameterValueTuple, output: Optional[IO[str]] = None, ) -> bool: @@ -52,22 +56,43 @@ def compiler_version_filter( Returns: bool: True, if parameter-value-tuple is valid. """ + # uncomment me for debugging + # print_row_nice(row) - # Rule: v1 - if ( - DEVICE_COMPILER in row - and row[DEVICE_COMPILER].name != NVCC - and HOST_COMPILER in row - and row[HOST_COMPILER].version != row[DEVICE_COMPILER].version - ): - reason(output, "host and device compiler version must be the same (except for nvcc)") + # Rule: c1 + # NVCC as HOST_COMPILER is not allow + # this rule will be never used, because of an implementation detail of the covertable library + # it is not possible to add NVCC as HOST_COMPILER and filter out afterwards + # this rule is only used by bashi-verify + if HOST_COMPILER in row and row[HOST_COMPILER].name == NVCC: + reason(output, "nvcc is not allowed as host compiler") return False + if HOST_COMPILER in row and DEVICE_COMPILER in row: + if NVCC in (row[HOST_COMPILER].name, row[DEVICE_COMPILER].name): + # Rule: c2 + if row[HOST_COMPILER].name not in (GCC, CLANG): + reason(output, "only gcc and clang are allowed as nvcc host compiler") + return False + else: + # Rule: c3 + if row[HOST_COMPILER].name != row[DEVICE_COMPILER].name: + reason(output, "host and device compiler name must be the same (except for nvcc)") + return False + + # Rule: c4 + if row[HOST_COMPILER].version != row[DEVICE_COMPILER].version: + reason( + output, + "host and device compiler version must be the same (except for nvcc)", + ) + return False + # now idea, how remove nested blocks without hitting the performance # pylint: disable=too-many-nested-blocks if DEVICE_COMPILER in row and row[DEVICE_COMPILER].name == NVCC: if HOST_COMPILER in row and row[HOST_COMPILER].name == GCC: - # Rule: v2 + # Rule: c5 # remove all unsupported nvcc gcc version combinations # define which is the latest supported gcc compiler for a nvcc version @@ -87,7 +112,7 @@ def compiler_version_filter( break if HOST_COMPILER in row and row[HOST_COMPILER].name == CLANG: - # Rule: v4 + # Rule: c7 if row[DEVICE_COMPILER].version >= pkv.parse("11.3") and row[ DEVICE_COMPILER ].version <= pkv.parse("11.5"): @@ -97,7 +122,7 @@ def compiler_version_filter( ) return False - # Rule: v3 + # Rule: c6 # remove all unsupported nvcc clang version combinations # define which is the latest supported clang compiler for a nvcc version @@ -116,17 +141,18 @@ def compiler_version_filter( return False break - # Rule: v5 + # Rule: c8 # clang-cuda 13 and older is not supported # this rule will be never used, because of an implementation detail of the covertable library # it is not possible to add the clang-cuda versions and filter it out afterwards # this rule is only used by bashi-verify - if ( - DEVICE_COMPILER in row - and row[DEVICE_COMPILER].name == CLANG_CUDA - and row[DEVICE_COMPILER].version < pkv.parse("14") - ): - reason(output, "all clang versions older than 14 are disabled as CUDA Compiler") - return False + for compiler in (HOST_COMPILER, DEVICE_COMPILER): + if ( + compiler in row + and row[compiler].name == CLANG_CUDA + and row[compiler].version < pkv.parse("14") + ): + reason(output, "all clang versions older than 14 are disabled as CUDA Compiler") + return False return True diff --git a/bashi/filter_compiler_name.py b/bashi/filter_compiler_name.py deleted file mode 100644 index 970969e..0000000 --- a/bashi/filter_compiler_name.py +++ /dev/null @@ -1,81 +0,0 @@ -"""Filter rules basing on host and device compiler names. - -All rules implemented in this filter have an identifier that begins with "n" and follows a number. -Examples: n1, n42, n678 ... - -These identifiers are used in the test names, for example, to make it clear which test is testing -which rule. -""" - -from typing import Optional, IO -from typeguard import typechecked -from bashi.types import Parameter, ParameterValueTuple -from bashi.globals import * # pylint: disable=wildcard-import,unused-wildcard-import -from bashi.utils import reason - - -def get_required_parameters() -> List[Parameter]: - """Return list of parameters which will be checked in the filter. - - Returns: - List[Parameter]: list of checked parameters - """ - return [HOST_COMPILER, DEVICE_COMPILER] - - -@typechecked -def compiler_name_filter_typechecked( - row: ParameterValueTuple, - output: Optional[IO[str]] = None, -) -> bool: - """Type-checked version of compiler_name_filter(). Type checking has a big performance cost, - which is why the non type-checked version is used for the pairwise generator. - """ - return compiler_name_filter(row, output) - - -def compiler_name_filter( - row: ParameterValueTuple, - output: Optional[IO[str]] = None, -) -> bool: - """Filter rules basing on host and device compiler names. - - Args: - row (ParameterValueTuple): parameter-value-tuple to verify. - output (Optional[IO[str]], optional): Writes the reason in the io object why the parameter - value tuple does not pass the filter. If None, no information is provided. The default - value is None. - - Returns: - bool: True, if parameter-value-tuple is valid. - """ - # Rule: n1 - # NVCC as HOST_COMPILER is not allow - # this rule will be never used, because of an implementation detail of the covertable library - # it is not possible to add NVCC as HOST_COMPILER and filter out afterwards - # this rule is only used by bashi-verify - if HOST_COMPILER in row and row[HOST_COMPILER].name == NVCC: - reason(output, "nvcc is not allowed as host compiler") - return False - - # Rule: n2 - if ( - DEVICE_COMPILER in row - and row[DEVICE_COMPILER].name == NVCC - and HOST_COMPILER in row - and not row[HOST_COMPILER].name in [GCC, CLANG] - ): - reason(output, "only gcc and clang are allowed as nvcc host compiler") - return False - - # Rule: n3 - if ( - DEVICE_COMPILER in row - and row[DEVICE_COMPILER].name != NVCC - and HOST_COMPILER in row - and row[HOST_COMPILER].name != row[DEVICE_COMPILER].name - ): - reason(output, "host and device compiler name must be the same (except for nvcc)") - return False - - return True diff --git a/bashi/generator.py b/bashi/generator.py index 35c4702..d65538a 100644 --- a/bashi/generator.py +++ b/bashi/generator.py @@ -2,8 +2,6 @@ from typing import Dict, List from collections import OrderedDict -import copy -import packaging.version as pkv from covertable import make # type: ignore @@ -34,44 +32,12 @@ def generate_combination_list( Returns: CombinationList: combination-list """ - # use local version to do not modify parameter_value_matrix - local_param_val_mat = copy.deepcopy(parameter_value_matrix) - filter_chain = get_default_filter_chain(custom_filter) - def host_compiler_filter(param_val: ParameterValue) -> bool: - # Rule: n1 - # remove nvcc as host compiler - if param_val.name == NVCC: - return False - # Rule: v5 - # remove clang-cuda older than 14 - if param_val.name == CLANG_CUDA and param_val.version < pkv.parse("14"): - return False - - return True - - def device_compiler_filter(param_val: ParameterValue) -> bool: - # Rule: v5 - # remove clang-cuda older than 14 - if param_val.name == CLANG_CUDA and param_val.version < pkv.parse("14"): - return False - - return True - - pre_filters = {HOST_COMPILER: host_compiler_filter, DEVICE_COMPILER: device_compiler_filter} - - # some filter rules requires that specific parameter-values are already removed from the - # parameter-value-matrix - # otherwise the covertable library throws an error - for param, filter_func in pre_filters.items(): - if param in local_param_val_mat: - local_param_val_mat[param] = list(filter(filter_func, local_param_val_mat[param])) - comb_list: CombinationList = [] all_pairs: List[Dict[Parameter, ParameterValue]] = make( - factors=local_param_val_mat, + factors=parameter_value_matrix, length=2, pre_filter=filter_chain, ) # type: ignore @@ -81,7 +47,7 @@ def device_compiler_filter(param_val: ParameterValue) -> bool: tmp_comb: Combination = OrderedDict({}) # covertable does not keep the ordering of the parameters # therefore we sort it - for param in local_param_val_mat.keys(): + for param in parameter_value_matrix.keys(): tmp_comb[param] = all_pair[param] comb_list.append(tmp_comb) diff --git a/bashi/utils.py b/bashi/utils.py index 1d99d44..2a30fb8 100644 --- a/bashi/utils.py +++ b/bashi/utils.py @@ -368,3 +368,43 @@ def reason(output: Optional[IO[str]], msg: str): file=output, end="", ) + + +# do not cover code, because the function is only used for debugging +def print_row_nice(row: ParameterValueTuple, init: str = ""): # pragma: no cover + """Prints a parameter-value-tuple in a short and nice way. + + Args: + row (ParameterValueTuple): row with parameter-value-tuple + init (str, optional): Prefix of the output string. Defaults to "". + """ + s = init + short_name: dict[str, str] = { + HOST_COMPILER: "host", + DEVICE_COMPILER: "device", + ALPAKA_ACC_CPU_B_OMP2_T_SEQ_ENABLE: "bOpenMP2thread", + ALPAKA_ACC_CPU_B_SEQ_T_OMP2_ENABLE: "bOpenMP2block", + ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE: "bSeq", + ALPAKA_ACC_CPU_B_SEQ_T_THREADS_ENABLE: "bThreads", + ALPAKA_ACC_CPU_B_TBB_T_SEQ_ENABLE: "bTBB", + ALPAKA_ACC_GPU_CUDA_ENABLE: "bCUDA", + ALPAKA_ACC_GPU_HIP_ENABLE: "bHIP", + ALPAKA_ACC_SYCL_ENABLE: "bSYCL", + CXX_STANDARD: "c++", + } + nice_version: dict[packaging.version.Version, str] = { + ON_VER: "ON", + OFF_VER: "OFF", + } + + for param, val in row.items(): + if param in [HOST_COMPILER, DEVICE_COMPILER]: + s += ( + f"{short_name.get(param, param)}={short_name.get(val.name, val.name)}-" + f"{nice_version.get(val.version, str(val.version))} " + ) + else: + s += ( + f"{short_name.get(param, param)}={nice_version.get(val.version, str(val.version))} " + ) + print(s) diff --git a/bashi/validate.py b/bashi/validate.py index 6080734..906f8e7 100644 --- a/bashi/validate.py +++ b/bashi/validate.py @@ -15,8 +15,7 @@ from bashi.globals import * # pylint: disable=wildcard-import,unused-wildcard-import from bashi.types import ParameterValue, ParameterValueTuple from bashi.versions import is_supported_version -import bashi.filter_compiler_name -import bashi.filter_compiler_version +import bashi.filter_compiler import bashi.filter_backend import bashi.filter_software_dependency @@ -244,17 +243,9 @@ def check_filter_chain(row: ParameterValueTuple) -> bool: all_true = 0 all_true += int( check_single_filter( - bashi.filter_compiler_name.compiler_name_filter_typechecked, + bashi.filter_compiler.compiler_filter, row, - bashi.filter_compiler_name.get_required_parameters(), - ) - ) - - all_true += int( - check_single_filter( - bashi.filter_compiler_version.compiler_version_filter_typechecked, - row, - bashi.filter_compiler_version.get_required_parameters(), + bashi.filter_compiler.get_required_parameters(), ) ) all_true += int( @@ -273,7 +264,7 @@ def check_filter_chain(row: ParameterValueTuple) -> bool: ) # each filter add a one, if it was successful - return all_true == 4 + return all_true == 3 def main() -> None: diff --git a/tests/test_clang_cuda_filter.py b/tests/test_clang_cuda_filter.py index 5e3adf4..24fd1d5 100644 --- a/tests/test_clang_cuda_filter.py +++ b/tests/test_clang_cuda_filter.py @@ -5,14 +5,14 @@ from collections import OrderedDict as OD from utils_test import parse_param_val as ppv from bashi.globals import * # pylint: disable=wildcard-import,unused-wildcard-import -from bashi.filter_compiler_version import compiler_version_filter_typechecked +from bashi.filter_compiler import compiler_filter_typechecked class TestClangCudaOldVersions(unittest.TestCase): - def test_valid_clang_cuda_versions_rule_v5(self): + def test_valid_clang_cuda_versions_rule_c8(self): for clang_cuda_version in [14, 16, 18, 78]: self.assertTrue( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((CLANG_CUDA, clang_cuda_version)), @@ -22,10 +22,10 @@ def test_valid_clang_cuda_versions_rule_v5(self): ) ) - def test_valid_clang_cuda_versions_multi_row_rule_v5(self): + def test_valid_clang_cuda_versions_multi_row_rule_c8(self): for clang_cuda_version in [14, 16, 18, 78]: self.assertTrue( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((CLANG_CUDA, clang_cuda_version)), @@ -37,11 +37,11 @@ def test_valid_clang_cuda_versions_multi_row_rule_v5(self): ) ) - def test_invalid_clang_cuda_versions_rule_v5(self): + def test_invalid_clang_cuda_versions_rule_c8(self): for clang_cuda_version in [13, 7, 1]: reason_msg = io.StringIO() self.assertFalse( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((CLANG_CUDA, clang_cuda_version)), @@ -56,11 +56,11 @@ def test_invalid_clang_cuda_versions_rule_v5(self): "all clang versions older than 14 are disabled as CUDA Compiler", ) - def test_invalid_clang_cuda_versions_multi_row_rule_v5(self): + def test_invalid_clang_cuda_versions_multi_row_rule_c8(self): for clang_cuda_version in [13, 7, 1]: reason_msg = io.StringIO() self.assertFalse( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((CLANG_CUDA, clang_cuda_version)), diff --git a/tests/test_filter_adapter.py b/tests/test_filter_adapter.py index 61359c0..5dae87b 100644 --- a/tests/test_filter_adapter.py +++ b/tests/test_filter_adapter.py @@ -6,8 +6,7 @@ from typeguard import typechecked from bashi.types import ParameterValueTuple, ParameterValue from bashi.utils import FilterAdapter -from bashi.filter_compiler_name import compiler_name_filter_typechecked -from bashi.filter_compiler_version import compiler_version_filter +from bashi.filter_compiler import compiler_filter_typechecked from bashi.filter_backend import backend_filter from bashi.filter_software_dependency import software_dependency_filter @@ -108,11 +107,11 @@ def test_compiler_name_filter(self): "because the test data should no trigger any rule" ) self.assertTrue( - FilterAdapter(self.param_map, compiler_name_filter_typechecked)(self.test_row), + FilterAdapter(self.param_map, compiler_filter_typechecked)(self.test_row), error_msg, ) self.assertTrue( - FilterAdapter(self.param_map, compiler_version_filter)(self.test_row), error_msg + FilterAdapter(self.param_map, compiler_filter_typechecked)(self.test_row), error_msg ) self.assertTrue(FilterAdapter(self.param_map, backend_filter)(self.test_row), error_msg) self.assertTrue( diff --git a/tests/test_filter_compiler_name.py b/tests/test_filter_compiler_name.py index 93d44a5..5f613d7 100644 --- a/tests/test_filter_compiler_name.py +++ b/tests/test_filter_compiler_name.py @@ -5,38 +5,35 @@ from collections import OrderedDict as OD from utils_test import parse_param_val as ppv from bashi.globals import * # pylint: disable=wildcard-import,unused-wildcard-import -from bashi.filter_compiler_name import compiler_name_filter_typechecked +from bashi.filter_compiler import compiler_filter_typechecked class TestEmptyRow(unittest.TestCase): def test_empty_row_shall_always_pass(self): - self.assertTrue(compiler_name_filter_typechecked(OD())) + self.assertTrue(compiler_filter_typechecked(OD())) class TestHostDeviceCompilerSameName(unittest.TestCase): - def test_valid_combination_rule_n3(self): + def test_valid_combination_rule_c3(self): for comb in [ (ppv((GCC, 10)), ppv((GCC, 10))), - (ppv((GCC, 1)), ppv((GCC, 10))), # version is not important (ppv((HIPCC, 6.0)), ppv((HIPCC, 6.0))), - (ppv((ICPX, 3.0)), ppv((ICPX, 6.0))), + (ppv((ICPX, 6.0)), ppv((ICPX, 6.0))), (ppv((CLANG, 3.0)), ppv((NVCC, 6.0))), # nvcc has device compiler is an exception (ppv((GCC, 3.0)), ppv((NVCC, 6.0))), ]: self.assertTrue( - compiler_name_filter_typechecked( - OD({HOST_COMPILER: comb[0], DEVICE_COMPILER: comb[1]}) - ), + compiler_filter_typechecked(OD({HOST_COMPILER: comb[0], DEVICE_COMPILER: comb[1]})), f"host compiler and device compiler name are not the same: {comb[0]} != {comb[1]}", ) self.assertTrue( - compiler_name_filter_typechecked( + compiler_filter_typechecked( OD( { - HOST_COMPILER: ppv((CLANG_CUDA, 10)), + HOST_COMPILER: ppv((CLANG_CUDA, 15)), ALPAKA_ACC_GPU_CUDA_ENABLE: ppv((ALPAKA_ACC_GPU_CUDA_ENABLE, 11.2)), - DEVICE_COMPILER: ppv((CLANG_CUDA, 10)), + DEVICE_COMPILER: ppv((CLANG_CUDA, 15)), CMAKE: ppv((CMAKE, 3.18)), } ) @@ -44,7 +41,7 @@ def test_valid_combination_rule_n3(self): ) self.assertTrue( - compiler_name_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((CLANG, 10)), @@ -59,7 +56,7 @@ def test_valid_combination_rule_n3(self): ), ) - def test_invalid_combination_rule_n3(self): + def test_invalid_combination_rule_c3(self): for comb in [ (ppv((GCC, 10)), ppv((CLANG, 10))), (ppv((HIPCC, 1)), ppv((GCC, 10))), # version is not important @@ -69,7 +66,7 @@ def test_invalid_combination_rule_n3(self): reason_msg = io.StringIO() self.assertFalse( - compiler_name_filter_typechecked( + compiler_filter_typechecked( OD({HOST_COMPILER: comb[0], DEVICE_COMPILER: comb[1]}), reason_msg ), f"same host compiler and device compiler name should pass: {comb[0]} and {comb[1]}", @@ -81,7 +78,7 @@ def test_invalid_combination_rule_n3(self): reason_msg_multi1 = io.StringIO() self.assertFalse( - compiler_name_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((CLANG_CUDA, 10)), @@ -100,7 +97,7 @@ def test_invalid_combination_rule_n3(self): reason_msg_multi2 = io.StringIO() self.assertFalse( - compiler_name_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((GCC, 15)), diff --git a/tests/test_filter_compiler_version.py b/tests/test_filter_compiler_version.py index 1d44f89..ef206cb 100644 --- a/tests/test_filter_compiler_version.py +++ b/tests/test_filter_compiler_version.py @@ -5,16 +5,16 @@ from collections import OrderedDict as OD from utils_test import parse_param_val as ppv from bashi.globals import * # pylint: disable=wildcard-import,unused-wildcard-import -from bashi.filter_compiler_version import compiler_version_filter_typechecked +from bashi.filter_compiler import compiler_filter_typechecked class TestEmptyRow(unittest.TestCase): def test_empty_row_shall_always_pass(self): - self.assertTrue(compiler_version_filter_typechecked(OD())) + self.assertTrue(compiler_filter_typechecked(OD())) class TestHostDeviceCompilerSameVersion(unittest.TestCase): - def test_valid_combination_rule_v1(self): + def test_valid_combination_rule_c4(self): for comb in [ (ppv((GCC, 10)), ppv((GCC, 10))), (ppv((ICPX, "2040.1.0")), ppv((ICPX, "2040.1.0"))), @@ -23,14 +23,12 @@ def test_valid_combination_rule_v1(self): (ppv((CLANG_CUDA, 17)), ppv((CLANG_CUDA, 17))), ]: self.assertTrue( - compiler_version_filter_typechecked( - OD({HOST_COMPILER: comb[0], DEVICE_COMPILER: comb[1]}) - ), + compiler_filter_typechecked(OD({HOST_COMPILER: comb[0], DEVICE_COMPILER: comb[1]})), f"host compiler and device compiler version are not the same: {comb[0]} != {comb[1]}", ) self.assertTrue( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((CLANG_CUDA, 14)), @@ -43,7 +41,7 @@ def test_valid_combination_rule_v1(self): ) self.assertTrue( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((CLANG, 14)), @@ -58,7 +56,7 @@ def test_valid_combination_rule_v1(self): ), ) - def test_invalid_combination_rule_v1(self): + def test_invalid_combination_rule_c4(self): for comb in [ (ppv((GCC, 10)), ppv((GCC, 11))), (ppv((ICPX, "2023.1.0")), ppv((ICPX, "2040.1.0"))), @@ -69,7 +67,7 @@ def test_invalid_combination_rule_v1(self): reason_msg = io.StringIO() self.assertFalse( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD({HOST_COMPILER: comb[0], DEVICE_COMPILER: comb[1]}), reason_msg ), f"same host compiler and device compiler version should pass: {comb[0]} and {comb[1]}", @@ -81,7 +79,7 @@ def test_invalid_combination_rule_v1(self): reason_msg_multi1 = io.StringIO() self.assertFalse( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((CLANG_CUDA, 10)), @@ -100,7 +98,7 @@ def test_invalid_combination_rule_v1(self): reason_msg_multi2 = io.StringIO() self.assertFalse( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((GCC, 15)), diff --git a/tests/test_generate_combination_list.py b/tests/test_generate_combination_list.py index bb2c821..333918e 100644 --- a/tests/test_generate_combination_list.py +++ b/tests/test_generate_combination_list.py @@ -267,7 +267,7 @@ def setUpClass(cls): [(BOOST, 1.81), (BOOST, 1.82), (BOOST, 1.83)] ) - def test_nvcc_host_compiler_rule_n1(self): + def test_nvcc_host_compiler_rule_c1(self): # test if generate_combination_list() correctly handles nvcc as host compiler param_matrix = copy.deepcopy(self.param_base_matrix) for nvcc_version in [11.2, 11.3, 11.8, 12.0]: @@ -286,7 +286,7 @@ def test_nvcc_host_compiler_rule_n1(self): ) ) - def test_clang_cuda_old_versions_rule_v5(self): + def test_clang_cuda_old_versions_rule_c8(self): # test if generate_combination_list() correctly clang-cuda version 13 and older param_matrix = copy.deepcopy(self.param_base_matrix) diff --git a/tests/test_nvcc_filter.py b/tests/test_nvcc_filter.py index cb4b658..0b74a17 100644 --- a/tests/test_nvcc_filter.py +++ b/tests/test_nvcc_filter.py @@ -7,27 +7,26 @@ from utils_test import parse_param_val as ppv from bashi.globals import * # pylint: disable=wildcard-import,unused-wildcard-import from bashi.versions import VERSIONS, NvccHostSupport -from bashi.filter_compiler_name import compiler_name_filter_typechecked -from bashi.filter_compiler_version import compiler_version_filter_typechecked +from bashi.filter_compiler import compiler_filter_typechecked class TestNoNvccHostCompiler(unittest.TestCase): - def test_valid_combination_rule_n1(self): + def test_valid_combination_rule_c1(self): self.assertTrue( - compiler_name_filter_typechecked( + compiler_filter_typechecked( OD({HOST_COMPILER: ppv((GCC, 10)), DEVICE_COMPILER: ppv((NVCC, 11.2))}) ) ) # version should not matter self.assertTrue( - compiler_name_filter_typechecked( + compiler_filter_typechecked( OD({HOST_COMPILER: ppv((CLANG, 0)), DEVICE_COMPILER: ppv((NVCC, 0))}) ) ) self.assertTrue( - compiler_name_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((CLANG, 0)), @@ -42,7 +41,7 @@ def test_valid_combination_rule_n1(self): # if HOST_COMPILER does not exist in the row, it should pass because HOST_COMPILER can be # added at the next round self.assertTrue( - compiler_name_filter_typechecked( + compiler_filter_typechecked( OD( { DEVICE_COMPILER: ppv((NVCC, 0)), @@ -53,10 +52,10 @@ def test_valid_combination_rule_n1(self): ) ) - def test_invalid_combination_rule_n1(self): + def test_invalid_combination_rule_c1(self): reason_msg1 = io.StringIO() self.assertFalse( - compiler_name_filter_typechecked( + compiler_filter_typechecked( OD({HOST_COMPILER: ppv((NVCC, 11.2)), DEVICE_COMPILER: ppv((NVCC, 11.2))}), reason_msg1, ) @@ -65,7 +64,7 @@ def test_invalid_combination_rule_n1(self): reason_msg2 = io.StringIO() self.assertFalse( - compiler_name_filter_typechecked( + compiler_filter_typechecked( OD({HOST_COMPILER: ppv((NVCC, 11.2)), DEVICE_COMPILER: ppv((GCC, 11))}), reason_msg2 ) ) @@ -73,7 +72,7 @@ def test_invalid_combination_rule_n1(self): reason_msg3 = io.StringIO() self.assertFalse( - compiler_name_filter_typechecked( + compiler_filter_typechecked( OD({HOST_COMPILER: ppv((NVCC, 12.2)), DEVICE_COMPILER: ppv((HIPCC, 5.1))}), reason_msg3, ) @@ -82,18 +81,18 @@ def test_invalid_combination_rule_n1(self): reason_msg4 = io.StringIO() self.assertFalse( - compiler_name_filter_typechecked(OD({HOST_COMPILER: ppv((NVCC, 10.2))}), reason_msg4) + compiler_filter_typechecked(OD({HOST_COMPILER: ppv((NVCC, 10.2))}), reason_msg4) ) self.assertEqual(reason_msg4.getvalue(), "nvcc is not allowed as host compiler") class TestSupportedNvccHostCompiler(unittest.TestCase): - def test_invalid_combination_rule_n2(self): + def test_invalid_combination_rule_c2(self): for compiler_name in [CLANG_CUDA, HIPCC, ICPX, NVCC]: for compiler_version in ["0", "13", "32a2"]: reason_msg = io.StringIO() self.assertFalse( - compiler_name_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((compiler_name, compiler_version)), @@ -112,7 +111,7 @@ def test_invalid_combination_rule_n2(self): reason_msg1 = io.StringIO() self.assertFalse( - compiler_name_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((HIPCC, "5.3")), @@ -131,7 +130,7 @@ def test_invalid_combination_rule_n2(self): reason_msg2 = io.StringIO() self.assertFalse( - compiler_name_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((HIPCC, "5.3")), @@ -149,11 +148,11 @@ def test_invalid_combination_rule_n2(self): "only gcc and clang are allowed as nvcc host compiler", ) - def test_valid_combination_rule_n2(self): + def test_valid_combination_rule_c2(self): for compiler_name in [GCC, CLANG]: - for compiler_version in ["0", "13", "7b2"]: + for compiler_version in ["0", "7", "10"]: self.assertTrue( - compiler_name_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((compiler_name, compiler_version)), @@ -164,10 +163,10 @@ def test_valid_combination_rule_n2(self): ) self.assertTrue( - compiler_name_filter_typechecked( + compiler_filter_typechecked( OD( { - HOST_COMPILER: ppv((GCC, "13")), + HOST_COMPILER: ppv((GCC, "10")), DEVICE_COMPILER: ppv((NVCC, "11.5")), BOOST: ppv((BOOST, "1.84.0")), CMAKE: ppv((CMAKE, "3.23")), @@ -176,10 +175,10 @@ def test_valid_combination_rule_n2(self): ) ) self.assertTrue( - compiler_name_filter_typechecked( + compiler_filter_typechecked( OD( { - HOST_COMPILER: ppv((CLANG, "14")), + HOST_COMPILER: ppv((CLANG, "7")), ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE: ppv( (ALPAKA_ACC_CPU_B_TBB_T_SEQ_ENABLE, ON) ), @@ -276,7 +275,7 @@ def test_sorting(self): class TestNvccSupportedGccVersion(unittest.TestCase): - def test_valid_combination_general_algorithm_rule_v2(self): + def test_valid_combination_general_algorithm_rule_c5(self): # this tests checks, if also version are respected, which are located between two defined # nvcc versions # e.g the following was defined: @@ -324,7 +323,7 @@ def test_valid_combination_general_algorithm_rule_v2(self): for nvcc_version, gcc_version, expected_filter_return_value in expected_results: reason_msg = io.StringIO() self.assertEqual( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((GCC, gcc_version)), @@ -343,7 +342,7 @@ def test_valid_combination_general_algorithm_rule_v2(self): f"nvcc {nvcc_version} " f"does not support gcc {gcc_version}", ) - def test_valid_combination_max_gcc_rule_v2(self): + def test_valid_combination_max_gcc_rule_c5(self): # change the version, if you added a new cuda release # this test is a guard to be sure, that the following test contains the latest nvcc release latest_covered_nvcc_release = "12.3" @@ -394,7 +393,7 @@ def test_valid_combination_max_gcc_rule_v2(self): for nvcc_version, gcc_version, expected_filter_return_value in expected_results: reason_msg = io.StringIO() self.assertEqual( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((GCC, gcc_version)), @@ -413,9 +412,9 @@ def test_valid_combination_max_gcc_rule_v2(self): f"nvcc {nvcc_version} " f"does not support gcc {gcc_version}", ) - def test_valid_multi_row_entries_gcc_rule_v2(self): + def test_valid_multi_row_entries_gcc_rule_c5(self): self.assertTrue( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((GCC, 10)), @@ -428,7 +427,7 @@ def test_valid_multi_row_entries_gcc_rule_v2(self): ) self.assertTrue( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((GCC, 12)), @@ -442,10 +441,10 @@ def test_valid_multi_row_entries_gcc_rule_v2(self): ) ) - def test_invalid_multi_row_entries_gcc_rule_v2(self): + def test_invalid_multi_row_entries_gcc_rule_c5(self): reason_msg1 = io.StringIO() self.assertFalse( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((GCC, 13)), @@ -464,7 +463,7 @@ def test_invalid_multi_row_entries_gcc_rule_v2(self): reason_msg2 = io.StringIO() self.assertFalse( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((GCC, 12)), @@ -483,7 +482,7 @@ def test_invalid_multi_row_entries_gcc_rule_v2(self): "nvcc 11.8 does not support gcc 12", ) - def test_unknown_combination_gcc_rule_v2(self): + def test_unknown_combination_gcc_rule_c5(self): # test an unsupported nvcc version # we assume, that the nvcc supports all gcc versions unsupported_nvcc_version = 42.0 @@ -494,7 +493,7 @@ def test_unknown_combination_gcc_rule_v2(self): ) self.assertTrue( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((GCC, 12)), @@ -508,7 +507,7 @@ def test_unknown_combination_gcc_rule_v2(self): class TestNvccSupportedClangVersion(unittest.TestCase): - def test_valid_combination_max_clang_rule_v3_rule_v4(self): + def test_valid_combination_max_clang_rule_c6_rule_c7(self): # change the version, if you added a new cuda release # this test is a guard to be sure, that the following test contains the latest nvcc release latest_covered_nvcc_release = "12.3" @@ -561,7 +560,7 @@ def test_valid_combination_max_clang_rule_v3_rule_v4(self): for nvcc_version, clang_version, expected_filter_return_value in expected_results: reason_msg = io.StringIO() self.assertEqual( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((CLANG, clang_version)), @@ -590,9 +589,9 @@ def test_valid_combination_max_clang_rule_v3_rule_v4(self): f"nvcc {nvcc_version} " f"does not support clang {clang_version}", ) - def test_valid_multi_row_entries_clang_rule_v3(self): + def test_valid_multi_row_entries_clang_rule_c6(self): self.assertTrue( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((CLANG, 10)), @@ -605,7 +604,7 @@ def test_valid_multi_row_entries_clang_rule_v3(self): ) self.assertTrue( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((CLANG, 12)), @@ -619,10 +618,10 @@ def test_valid_multi_row_entries_clang_rule_v3(self): ) ) - def test_invalid_multi_row_entries_clang_rule_v3(self): + def test_invalid_multi_row_entries_clang_rule_c6(self): reason_msg1 = io.StringIO() self.assertFalse( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((CLANG, 13)), @@ -641,7 +640,7 @@ def test_invalid_multi_row_entries_clang_rule_v3(self): reason_msg2 = io.StringIO() self.assertFalse( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((CLANG, 16)), @@ -660,7 +659,7 @@ def test_invalid_multi_row_entries_clang_rule_v3(self): "nvcc 11.8 does not support clang 16", ) - def test_unknown_combination_clang_rule_v3(self): + def test_unknown_combination_clang_rule_c6(self): # test an unsupported nvcc version # we assume, that the nvcc supports all gcc versions unsupported_nvcc_version = 42.0 @@ -671,7 +670,7 @@ def test_unknown_combination_clang_rule_v3(self): ) self.assertTrue( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((CLANG, 12)), @@ -683,12 +682,12 @@ def test_unknown_combination_clang_rule_v3(self): "version", ) - def test_no_clang_as_host_compiler_rule_v4(self): + def test_no_clang_as_host_compiler_rule_c7(self): for nvcc_version in [11.3, 11.4, 11.5]: for clang_version in [0, 7, 56]: reason_msg = io.StringIO() self.assertFalse( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((CLANG, clang_version)), @@ -704,12 +703,12 @@ def test_no_clang_as_host_compiler_rule_v4(self): "clang as host compiler is disabled for nvcc 11.3 to 11.5", ) - def test_no_clang_as_host_compiler_multi_row_rule_v4(self): + def test_no_clang_as_host_compiler_multi_row_rule_c7(self): for nvcc_version in [11.3, 11.4, 11.5]: for clang_version in [0, 10, 78]: reason_msg = io.StringIO() self.assertFalse( - compiler_version_filter_typechecked( + compiler_filter_typechecked( OD( { HOST_COMPILER: ppv((CLANG, clang_version)),