Skip to content

Commit ab6ecb5

Browse files
authored
Merge pull request #351 from IntelPython/feature/required_framework_packages
Feature/required framework packages
2 parents 2838206 + 583ee26 commit ab6ecb5

File tree

12 files changed

+85
-25
lines changed

12 files changed

+85
-25
lines changed

.github/workflows/conda-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,11 @@ jobs:
196196
# we want to make sure that configuration files are geting populated
197197
- name: Run npbench benchmark
198198
run: |
199-
dpbench -i numpy -b azimint_hist run --npbench --precision=${{matrix.precision}}
199+
dpbench -i numpy -b azimint_hist run --experimental-npbench --precision=${{matrix.precision}}
200200
201201
- name: Run rodinia benchmark
202202
run: |
203-
dpbench run --rodinia --no-dpbench --no-validate -r 1 --precision=${{matrix.precision}}
203+
dpbench run --experimental-rodinia --no-dpbench --no-validate -r 1 --precision=${{matrix.precision}}
204204
205205
upload_anaconda:
206206
name: Upload dppy/label/dev ['${{ matrix.os }}', python='${{ matrix.python }}']

README.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ SPDX-License-Identifier: Apache-2.0
117117
4. All available options are available using `dpbench --help` and `dpbench <command> --help`:
118118

119119
```
120-
usage: dpbench [-h] [-b [BENCHMARKS]] [-i [IMPLEMENTATIONS]] [-a | --all-implementations | --no-all-implementations] [--version] [-r [RUN_ID]] [--last-run | --no-last-run]
121-
[-d [RESULTS_DB]] [--log-level [{critical,fatal,error,warning,info,debug}]]
122-
{run,report,config} ...
120+
usage: dpbench [-h] [-b [BENCHMARKS]] [-i [IMPLEMENTATIONS]] [-a | --all-implementations | --no-all-implementations] [--version] [-r [RUN_ID]] [--last-run | --no-last-run] [-d [RESULTS_DB]]
121+
[--log-level [{critical,fatal,error,warning,info,debug}]]
122+
{run,report,config} ...
123123

124124
positional arguments:
125125
{run,report,config}
@@ -131,50 +131,52 @@ SPDX-License-Identifier: Apache-2.0
131131
-i [IMPLEMENTATIONS], --implementations [IMPLEMENTATIONS]
132132
Comma separated list of implementations. Use --all-implementations to load all available implementations.
133133
-a, --all-implementations, --no-all-implementations
134-
If set, all available implementations will be loaded. (default: False)
134+
If set, all available implementations will be loaded.
135135
--version show program's version number and exit
136136
-r [RUN_ID], --run-id [RUN_ID]
137137
run_id to perform actions on. Use --last-run to use latest available run, or leave empty to create new one.
138138
--last-run, --no-last-run
139-
Sets run_id to the latest run_id from the database. (default: False)
139+
Sets run_id to the latest run_id from the database.
140140
-d [RESULTS_DB], --results-db [RESULTS_DB]
141141
Path to a database to store results.
142142
--log-level [{critical,fatal,error,warning,info,debug}]
143143
Log level.
144144
```
145145
146146
```
147-
usage: dpbench run [-h] [-p [{S,M,L}]] [-s | --validate | --no-validate] [--dpbench | --no-dpbench] [--npbench | --no-npbench] [--polybench | --no-polybench] [-r [REPEAT]] [-t [TIMEOUT]]
148-
[--precision [{single,double}]] [--print-results | --no-print-results] [--save | --no-save] [--sycl-device [SYCL_DEVICE]]
149-
[--skip-expected-failures | --no-skip-expected-failures]
147+
usage: dpbench run [-h] [-p [{S,M16Gb,M,L}]] [-s | --validate | --no-validate] [--dpbench | --no-dpbench] [--experimental-npbench | --no-experimental-npbench] [--experimental-polybench | --no-experimental-polybench]
148+
[--experimental-rodinia | --no-experimental-rodinia] [-r [REPEAT]] [-t [TIMEOUT]] [--precision [{single,double}]] [--print-results | --no-print-results] [--save | --no-save] [--sycl-device [SYCL_DEVICE]]
149+
[--skip-expected-failures | --no-skip-expected-failures]
150150
151151
Subcommand to run benchmark executions.
152152
153153
options:
154154
-h, --help show this help message and exit
155-
-p [{S,M,L}], --preset [{S,M,L}]
155+
-p [{S,M16Gb,M,L}], --preset [{S,M16Gb,M,L}]
156156
Preset to use for benchmark execution.
157157
-s, --validate, --no-validate
158-
Set if the validation will be run for each benchmark. (default: True)
158+
Set if the validation will be run for each benchmark.
159159
--dpbench, --no-dpbench
160-
Set if run dpbench benchmarks. (default: True)
161-
--npbench, --no-npbench
162-
Set if run npbench benchmarks. (default: False)
163-
--polybench, --no-polybench
164-
Set if run polybench benchmarks. (default: False)
160+
Set if run dpbench benchmarks.
161+
--experimental-npbench, --no-experimental-npbench
162+
Set if run npbench benchmarks.
163+
--experimental-polybench, --no-experimental-polybench
164+
Set if run polybench benchmarks.
165+
--experimental-rodinia, --no-experimental-rodinia
166+
Set if run rodinia benchmarks.
165167
-r [REPEAT], --repeat [REPEAT]
166168
Number of repeats for each benchmark.
167169
-t [TIMEOUT], --timeout [TIMEOUT]
168170
Timeout time in seconds for each benchmark execution.
169171
--precision [{single,double}]
170172
Data precision to use for array initialization.
171173
--print-results, --no-print-results
172-
Show the result summary or not (default: True)
173-
--save, --no-save Either to save execution into database. (default: True)
174+
Show the result summary or not
175+
--save, --no-save Either to save execution into database.
174176
--sycl-device [SYCL_DEVICE]
175177
Sycl device to overwrite for framework configurations.
176178
--skip-expected-failures, --no-skip-expected-failures
177-
Either to save execution into database. (default: True)
179+
Either to save execution into database.
178180
```
179181
180182
```

dpbench/config/reader.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
import tomli
1515

16+
from dpbench.infrastructure.frameworks.fabric import get_framework_class
17+
1618
from .benchmark import Benchmark, BenchmarkImplementation, Presets
1719
from .config import Config
1820
from .framework import Framework
@@ -117,7 +119,7 @@ def read_configs( # noqa: C901: TODO: move modules into config
117119
for framework in config.frameworks:
118120
config.implementations += framework.postfixes
119121

120-
if implementations is None:
122+
if implementations is None or len(implementations) == 0:
121123
implementations = {impl.postfix for impl in config.implementations}
122124

123125
if load_implementations:
@@ -228,6 +230,15 @@ def read_frameworks(
228230
if len(framework.postfixes) == 0:
229231
continue
230232

233+
cls = get_framework_class(framework)
234+
unavailable_pkgs = cls.get_missing_required_packages()
235+
if len(unavailable_pkgs) > 0:
236+
logging.warning(
237+
f"Framework {framework.simple_name} unavailable "
238+
+ f"due to missing packages {unavailable_pkgs}"
239+
)
240+
continue
241+
231242
config.frameworks.append(framework)
232243

233244

dpbench/console/run.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,22 @@ def add_run_arguments(parser: argparse.ArgumentParser):
4747
help="Set if run dpbench benchmarks.",
4848
)
4949
parser.add_argument(
50-
"--npbench",
50+
"--experimental-npbench",
51+
dest="npbench",
5152
action=argparse.BooleanOptionalAction,
5253
default=False,
5354
help="Set if run npbench benchmarks.",
5455
)
5556
parser.add_argument(
56-
"--polybench",
57+
"--experimental-polybench",
58+
dest="polybench",
5759
action=argparse.BooleanOptionalAction,
5860
default=False,
5961
help="Set if run polybench benchmarks.",
6062
)
6163
parser.add_argument(
62-
"--rodinia",
64+
"--experimental-rodinia",
65+
dest="rodinia",
6366
action=argparse.BooleanOptionalAction,
6467
default=False,
6568
help="Set if run rodinia benchmarks.",

dpbench/infrastructure/frameworks/cupy_framework.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ def __init__(self, fname: str = None, config: cfg.Framework = None):
1919

2020
super().__init__(fname, config)
2121

22+
@staticmethod
23+
def required_packages() -> list[str]:
24+
return ["cupy"]
25+
2226
def copy_to_func(self) -> Callable:
2327
"""Returns the copy-method that should be used
2428
for copying the benchmark arguments."""

dpbench/infrastructure/frameworks/dpnp_framework.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ def __init__(self, fname: str = None, config: cfg.Framework = None):
3535
)
3636
raise sdce
3737

38+
@staticmethod
39+
def required_packages() -> list[str]:
40+
return ["dpnp"]
41+
3842
def device_filter_string(self) -> str:
3943
"""Returns the sycl device's filter string if the framework has an
4044
associated sycl device."""

dpbench/infrastructure/frameworks/fabric.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def build_framework_map() -> dict[str, Framework]:
3939
return result
4040

4141

42-
def build_framework(framework_config: cfg.Framework) -> Framework:
42+
def get_framework_class(framework_config: cfg.Framework) -> Framework:
4343
available_classes = [
4444
Framework,
4545
DpcppFramework,
@@ -61,4 +61,9 @@ def build_framework(framework_config: cfg.Framework) -> Framework:
6161
)
6262
constructor = Framework
6363

64+
return constructor
65+
66+
67+
def build_framework(framework_config: cfg.Framework) -> Framework:
68+
constructor = get_framework_class(framework_config)
6469
return constructor(config=framework_config)

dpbench/infrastructure/frameworks/framework.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# SPDX-License-Identifier: BSD-3-Clause
66

77
import logging
8+
from importlib.util import find_spec
89
from typing import Any, Callable, Dict, final
910

1011
import pkg_resources
@@ -45,6 +46,20 @@ def __init__(
4546

4647
self.device_info = cpuinfo.get_cpu_info().get("brand_raw")
4748

49+
@staticmethod
50+
def required_packages() -> list[str]:
51+
return []
52+
53+
@classmethod
54+
def get_missing_required_packages(cls) -> None:
55+
unavailable_packages = []
56+
for pkg in cls.required_packages():
57+
spec = find_spec(pkg)
58+
if spec is None:
59+
unavailable_packages.append(pkg)
60+
61+
return unavailable_packages
62+
4863
def device_filter_string(self) -> str:
4964
"""Returns the sycl device's filter string if the framework has an
5065
associated sycl device."""

dpbench/infrastructure/frameworks/numba_cuda_framework.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ def __init__(self, fname: str = None, config: cfg.Framework = None):
1919

2020
super().__init__(fname, config)
2121

22+
@staticmethod
23+
def required_packages() -> list[str]:
24+
return ["cupy"]
25+
2226
def copy_to_func(self) -> Callable:
2327
"""Returns the copy-method that should be used
2428
for copying the benchmark arguments."""

dpbench/infrastructure/frameworks/numba_dpex_framework.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ def __init__(self, fname: str = None, config: cfg.Framework = None):
3333
)
3434
raise sdce
3535

36+
@staticmethod
37+
def required_packages() -> list[str]:
38+
return ["numba_dpex"]
39+
3640
def device_filter_string(self) -> str:
3741
"""Returns the sycl device's filter string if the framework has an
3842
associated sycl device."""

0 commit comments

Comments
 (0)