Skip to content

Commit

Permalink
Merge pull request #8 from SimeonEhrig/filters
Browse files Browse the repository at this point in the history
Add filters and setup pairwise generator
  • Loading branch information
SimeonEhrig authored Feb 7, 2024
2 parents 763ec06 + b323da5 commit 47e1bf6
Show file tree
Hide file tree
Showing 19 changed files with 1,317 additions and 59 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/testDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: rickstaa/action-black@v1
- uses: psf/black@stable
with:
black_args: ". --check"
options: "--check --verbose"
src: "./"
version: "~= 24.0"

unit-tests:
runs-on: ubuntu-latest
Expand Down
22 changes: 22 additions & 0 deletions bashi/filter_backend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Filter rules basing on backend names and versions."""

from typing import Optional, IO
from bashi.types import ParameterValueTuple


def backend_filter(
row: ParameterValueTuple,
output: Optional[IO[str]] = None,
) -> bool:
"""Filter rules basing on backend names and versions.
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.
"""
return True
22 changes: 22 additions & 0 deletions bashi/filter_compiler_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Filter rules basing on host and device compiler names."""

from typing import Optional, IO
from bashi.types import ParameterValueTuple


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.
"""
return True
22 changes: 22 additions & 0 deletions bashi/filter_compiler_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Filter rules basing on host and device compiler names and versions."""

from typing import Optional, IO
from bashi.types import ParameterValueTuple


def compiler_version_filter(
row: ParameterValueTuple,
output: Optional[IO[str]] = None,
) -> bool:
"""Filter rules basing on host and device compiler names and versions.
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.
"""
return True
22 changes: 22 additions & 0 deletions bashi/filter_software_dependency.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Filter rules handling software dependencies and compiler settings."""

from typing import Optional, IO
from bashi.types import ParameterValueTuple


def software_dependency_filter(
row: ParameterValueTuple,
output: Optional[IO[str]] = None,
) -> bool:
"""Filter rules handling software dependencies and compiler settings.
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.
"""
return True
55 changes: 51 additions & 4 deletions bashi/generator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,53 @@
def foo():
print("Hello bashi.")
"""Functions to generate the combination-list"""

from typing import Dict, List
from collections import OrderedDict

def add(x: int, y: int):
return x + y
from covertable import make

from bashi.types import (
Parameter,
ParameterValue,
ParameterValueMatrix,
FilterFunction,
Combination,
CombinationList,
)
from bashi.utils import get_default_filter_chain


def generate_combination_list(
parameter_value_matrix: ParameterValueMatrix,
custom_filter: FilterFunction = lambda _: True,
) -> CombinationList:
"""Generate combination-list from the parameter-value-matrix. The combination list contains
all valid parameter-value-pairs at least one time.
Args:
parameter_value_matrix (ParameterValueMatrix): Input matrix with parameter and
parameter-values.
custom_filter (FilterFunction, optional): Custom filter function to extend bashi
filters. Defaults is lambda _: True.
Returns:
CombinationList: combination-list
"""
filter_chain = get_default_filter_chain(custom_filter)

comb_list: CombinationList = []

all_pairs: List[Dict[Parameter, ParameterValue]] = make(
factors=parameter_value_matrix,
length=2,
pre_filter=filter_chain,
) # type: ignore

# convert List[Dict[Parameter, ParameterValue]] to CombinationList
for all_pair in all_pairs:
tmp_comb: Combination = OrderedDict()
# covertable does not keep the ordering of the parameters
# therefore we sort it
for param in parameter_value_matrix.keys():
tmp_comb[param] = all_pair[param]
comb_list.append(tmp_comb)

return comb_list
20 changes: 20 additions & 0 deletions bashi/globals.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
"""This module contains constants used in the bashi library."""

from typing import List
import packaging.version


# parameter key names, whit special meaning
HOST_COMPILER: str = "host_compiler"
DEVICE_COMPILER: str = "device_compiler"
Expand All @@ -12,6 +16,8 @@
HIPCC: str = "hipcc"
ICPX: str = "icpx"

COMPILERS: List[str] = [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"
ALPAKA_ACC_CPU_B_SEQ_T_THREADS_ENABLE: str = "alpaka_ACC_CPU_B_SEQ_T_THREADS_ENABLE"
Expand All @@ -22,8 +28,22 @@
ALPAKA_ACC_GPU_HIP_ENABLE: str = "alpaka_ACC_GPU_HIP_ENABLE"
ALPAKA_ACC_SYCL_ENABLE: str = "alpaka_ACC_SYCL_ENABLE"

BACKENDS: List[str] = [
ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLE,
ALPAKA_ACC_CPU_B_SEQ_T_THREADS_ENABLE,
ALPAKA_ACC_CPU_B_TBB_T_SEQ_ENABLE,
ALPAKA_ACC_CPU_B_OMP2_T_SEQ_ENABLE,
ALPAKA_ACC_CPU_B_SEQ_T_OMP2_ENABLE,
ALPAKA_ACC_GPU_CUDA_ENABLE,
ALPAKA_ACC_GPU_HIP_ENABLE,
ALPAKA_ACC_SYCL_ENABLE,
]

# software dependencies and compiler configurations
UBUNTU: str = "ubuntu"
CMAKE: str = "cmake"
BOOST: str = "boost"
CXX_STANDARD: str = "cxx_standard"

OFF_VER: packaging.version.Version = packaging.version.parse("0.0.0")
ON_VER: packaging.version.Version = packaging.version.parse("1.0.0")
8 changes: 7 additions & 1 deletion bashi/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
ParameterValue = NamedTuple("ParameterValue", [("name", ValueName), ("version", ValueVersion)])
ParameterValueList: TypeAlias = List[ParameterValue]
ParameterValueMatrix: TypeAlias = OrderedDict[Parameter, ParameterValueList]
ParameterValuePair: TypeAlias = OrderedDict[Parameter, ParameterValue]
ParameterValueSingle = NamedTuple(
"ParameterValueSingle", [("parameter", Parameter), ("parameterValue", ParameterValue)]
)
ParameterValuePair = NamedTuple(
"ParameterValuePair",
[("first", ParameterValueSingle), ("second", ParameterValueSingle)],
)
ParameterValueTuple: TypeAlias = OrderedDict[Parameter, ParameterValue]
Combination: TypeAlias = OrderedDict[Parameter, ParameterValue]
CombinationList: TypeAlias = List[Combination]
Expand Down
Loading

0 comments on commit 47e1bf6

Please sign in to comment.