Skip to content

Commit 597782b

Browse files
committed
Structure frameworks
1 parent cc8ad76 commit 597782b

21 files changed

+162
-129
lines changed

dpbench/config/config.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
"""Configuration root related configuration classes."""
66

7-
from dataclasses import dataclass
7+
from dataclasses import dataclass, field
88

99
from .benchmark import Benchmark
1010
from .framework import Framework
@@ -15,7 +15,8 @@
1515
class Config:
1616
"""Root of the configuration."""
1717

18-
frameworks: list[Framework]
19-
benchmarks: list[Benchmark]
20-
implementations: list[Implementation]
21-
dtypes: dict[str, dict[str, str]]
18+
frameworks: list[Framework] = field(default_factory=list)
19+
benchmarks: list[Benchmark] = field(default_factory=list)
20+
# deprecated. Use frameworks.postfixes instead
21+
implementations: list[Implementation] = field(default_factory=list)
22+
dtypes: dict[str, dict[str, str]] = field(default_factory=dict)

dpbench/config/framework.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
"""Framework related configuration classes."""
66

7-
from dataclasses import dataclass
8-
from typing import Any
7+
from dataclasses import dataclass, field
8+
from typing import Any, List
9+
10+
from .implementation_postfix import Implementation
911

1012

1113
@dataclass
@@ -18,6 +20,8 @@ class Framework:
1820
class_: str
1921
arch: str
2022
sycl_device: str
23+
dpcpp_version: str
24+
postfixes: List[Implementation] = field(default_factory=list)
2125

2226
@staticmethod
2327
def from_dict(obj: Any) -> "Framework":
@@ -28,6 +32,18 @@ def from_dict(obj: Any) -> "Framework":
2832
_class = str(obj.get("class") or "")
2933
_arch = str(obj.get("arch") or "")
3034
_sycl_device = str(obj.get("sycl_device") or "")
35+
_dpcpp_version = str(obj.get("dpcpp_version") or "")
36+
_postfixes = obj.get("postfixes") or []
37+
for i, _postfix in enumerate(_postfixes):
38+
_postfixes[i] = Implementation.from_dict(_postfix)
39+
_postfixes = list[Implementation](_postfixes)
3140
return Framework(
32-
_simple_name, _full_name, _prefix, _class, _arch, _sycl_device
41+
_simple_name,
42+
_full_name,
43+
_prefix,
44+
_class,
45+
_arch,
46+
_sycl_device,
47+
_dpcpp_version,
48+
_postfixes,
3349
)

dpbench/config/module.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ class Module:
1414
benchmark_configs_path: str = ""
1515
benchmark_configs_recursive: bool = False
1616
framework_configs_path: str = ""
17-
impl_postfix_path: str = ""
1817
precision_dtypes_path: str = ""
1918

2019
benchmarks_module: str = ""

dpbench/config/reader.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import pkgutil
1111
import re
1212
import sys
13-
from typing import Callable
1413

1514
import tomli
1615

@@ -34,7 +33,7 @@ def read_configs( # noqa: C901: TODO: move modules into config
3433
Returns:
3534
Configuration object with populated configurations.
3635
"""
37-
config: Config = Config([], [], [], None)
36+
config: Config = Config()
3837

3938
dirname: str = os.path.dirname(__file__)
4039

@@ -48,9 +47,6 @@ def read_configs( # noqa: C901: TODO: move modules into config
4847
framework_configs_path=os.path.join(
4948
dirname, "../configs/framework_info"
5049
),
51-
impl_postfix_path=os.path.join(
52-
dirname, "../configs/impl_postfix.toml"
53-
),
5450
precision_dtypes_path=os.path.join(
5551
dirname, "../configs/precision_dtypes.toml"
5652
),
@@ -97,13 +93,14 @@ def read_configs( # noqa: C901: TODO: move modules into config
9793
)
9894
if mod.framework_configs_path != "":
9995
read_frameworks(config, mod.framework_configs_path)
100-
if mod.impl_postfix_path != "":
101-
read_implementation_postfixes(config, mod.impl_postfix_path)
10296
if mod.precision_dtypes_path != "":
10397
read_precision_dtypes(config, mod.precision_dtypes_path)
10498
if mod.path != "":
10599
sys.path.append(mod.path)
106100

101+
for framework in config.frameworks:
102+
config.implementations += framework.postfixes
103+
107104
if implementations is None:
108105
implementations = [impl.postfix for impl in config.implementations]
109106

dpbench/configs/framework_info/dpcpp.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@ postfix = "dpcpp"
1010
class = "DpcppFramework"
1111
arch = "cpu"
1212
sycl_device = "cpu"
13+
dpcpp_version = "IntelLLVM 2023.1.0"
14+
15+
[[framework.postfixes]]
16+
impl_postfix = "sycl"
17+
description = "DPC++ native ext."

dpbench/configs/framework_info/dpcpp_version.toml

Lines changed: 0 additions & 5 deletions
This file was deleted.

dpbench/configs/framework_info/dpnp.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ simple_name = "dpnp"
77
full_name = "dpnp"
88
prefix = "dp"
99
postfix = "dpnp"
10-
class = "Framework"
10+
class = "DpnpFramework"
1111
arch = "cpu"
1212
sycl_device = "cpu"
13+
14+
[[framework.postfixes]]
15+
impl_postfix = "dpnp"
16+
description = "dpnp"

dpbench/configs/framework_info/numba.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,15 @@ full_name = "Numba"
88
prefix = "nb"
99
class = "NumbaFramework"
1010
arch = "cpu"
11+
12+
[[framework.postfixes]]
13+
impl_postfix = "numba_n"
14+
description = "Numba nopython"
15+
16+
[[framework.postfixes]]
17+
impl_postfix = "numba_np"
18+
description = "Numba nopython, Parallel=True"
19+
20+
[[framework.postfixes]]
21+
impl_postfix = "numba_npr"
22+
description = "Numba nopython, Parallel=True, prange"

dpbench/configs/framework_info/numba_dpex.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,15 @@ prefix = "dpex"
99
class = "NumbaDpexFramework"
1010
arch = "cpu"
1111
sycl_device = "cpu"
12+
13+
[[framework.postfixes]]
14+
impl_postfix = "numba_dpex_k"
15+
description = "Numba-dpex kernel"
16+
17+
[[framework.postfixes]]
18+
impl_postfix = "numba_dpex_p"
19+
description = "Numba-dpex prange"
20+
21+
[[framework.postfixes]]
22+
impl_postfix = "numba_dpex_n"
23+
description = "Numba-dpex NumPy API"

dpbench/configs/framework_info/numpy.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ prefix = "np"
99
postfix = "numpy"
1010
class = "Framework"
1111
arch = "cpu"
12+
13+
[[framework.postfixes]]
14+
impl_postfix = "numpy"
15+
description = "NumPy"

0 commit comments

Comments
 (0)