-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from SimeonEhrig/ruleNoNvccHost
add filter rule, which forbids nvcc as host compiler
- Loading branch information
Showing
11 changed files
with
189 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Contains default filter chain and avoids circular import""" | ||
|
||
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_backend import backend_filter | ||
from bashi.filter_software_dependency import software_dependency_filter | ||
|
||
|
||
@typechecked | ||
def get_default_filter_chain( | ||
custom_filter_function: FilterFunction = lambda _: True, | ||
) -> FilterFunction: | ||
"""Concatenate the bashi filter functions in the default order and return them as one function | ||
with a single entry point. | ||
Args: | ||
custom_filter_function (FilterFunction): This function is added as the last filter level and | ||
allows the user to add custom filter rules without having to create the entire filter | ||
chain from scratch. Defaults to lambda_:True. | ||
Returns: | ||
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) | ||
and backend_filter(row) | ||
and software_dependency_filter(row) | ||
and custom_filter_function(row) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# pylint: disable=missing-docstring | ||
import unittest | ||
import io | ||
|
||
from collections import OrderedDict as OD | ||
from utils_test import parse_param_val as ppv | ||
from bashi.globals import * # pylint: disable=wildcard-import,unused-wildcard-import | ||
from bashi.filter_compiler_name import compiler_name_filter | ||
|
||
|
||
class TestNvccHostCompilerFilter(unittest.TestCase): | ||
def test_valid_combination_rule_n1(self): | ||
self.assertTrue( | ||
compiler_name_filter( | ||
OD({HOST_COMPILER: ppv((GCC, 10)), DEVICE_COMPILER: ppv((NVCC, 11.2))}) | ||
) | ||
) | ||
|
||
# version should not matter | ||
self.assertTrue( | ||
compiler_name_filter( | ||
OD({HOST_COMPILER: ppv((CLANG, 0)), DEVICE_COMPILER: ppv((NVCC, 0))}) | ||
) | ||
) | ||
|
||
self.assertTrue( | ||
compiler_name_filter( | ||
OD( | ||
{ | ||
HOST_COMPILER: ppv((CLANG, 0)), | ||
DEVICE_COMPILER: ppv((NVCC, 0)), | ||
CMAKE: ppv((CMAKE, "3.23")), | ||
BOOST: ppv((BOOST, "1.81")), | ||
} | ||
) | ||
) | ||
) | ||
|
||
# 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( | ||
OD( | ||
{ | ||
DEVICE_COMPILER: ppv((NVCC, 0)), | ||
CMAKE: ppv((CMAKE, "3.23")), | ||
BOOST: ppv((BOOST, "1.81")), | ||
} | ||
) | ||
) | ||
) | ||
|
||
self.assertTrue(compiler_name_filter(OD())) | ||
|
||
def test_invalid_combination_rule_n1(self): | ||
self.assertFalse( | ||
compiler_name_filter( | ||
OD({HOST_COMPILER: ppv((NVCC, 11.2)), DEVICE_COMPILER: ppv((NVCC, 11.2))}) | ||
) | ||
) | ||
|
||
self.assertFalse( | ||
compiler_name_filter( | ||
OD({HOST_COMPILER: ppv((NVCC, 11.2)), DEVICE_COMPILER: ppv((GCC, 11))}) | ||
) | ||
) | ||
|
||
self.assertFalse( | ||
compiler_name_filter( | ||
OD({HOST_COMPILER: ppv((NVCC, 12.2)), DEVICE_COMPILER: ppv((HIPCC, 5.1))}) | ||
) | ||
) | ||
|
||
self.assertFalse(compiler_name_filter(OD({HOST_COMPILER: ppv((NVCC, 10.2))}))) | ||
|
||
def test_reason_rule_n1(self): | ||
reason_msg = io.StringIO() | ||
self.assertFalse(compiler_name_filter(OD({HOST_COMPILER: ppv((NVCC, 10.2))}), reason_msg)) | ||
self.assertEqual(reason_msg.getvalue(), "nvcc is not allowed as host compiler") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters