|
10 | 10 | from utils.result import BenchmarkMetadata, BenchmarkTag, Result
|
11 | 11 | from options import options
|
12 | 12 | from utils.utils import download, run
|
| 13 | +from abc import ABC, abstractmethod |
13 | 14 |
|
14 | 15 | benchmark_tags = [
|
15 | 16 | BenchmarkTag("SYCL", "Benchmark uses SYCL runtime"),
|
|
34 | 35 | benchmark_tags_dict = {tag.name: tag for tag in benchmark_tags}
|
35 | 36 |
|
36 | 37 |
|
37 |
| -class Benchmark: |
| 38 | +class Benchmark(ABC): |
38 | 39 | def __init__(self, directory, suite):
|
39 | 40 | self.directory = directory
|
40 | 41 | self.suite = suite
|
41 | 42 |
|
| 43 | + @abstractmethod |
| 44 | + def name(self) -> str: |
| 45 | + pass |
| 46 | + |
| 47 | + @abstractmethod |
| 48 | + def setup(self): |
| 49 | + pass |
| 50 | + |
| 51 | + @abstractmethod |
| 52 | + def teardown(self): |
| 53 | + pass |
| 54 | + |
| 55 | + @abstractmethod |
| 56 | + def run(self, env_vars) -> list[Result]: |
| 57 | + pass |
| 58 | + |
42 | 59 | @staticmethod
|
43 | 60 | def get_adapter_full_path():
|
44 | 61 | for libs_dir_name in ["lib", "lib64"]:
|
@@ -99,24 +116,12 @@ def download(
|
99 | 116 | def lower_is_better(self):
|
100 | 117 | return True
|
101 | 118 |
|
102 |
| - def setup(self): |
103 |
| - raise NotImplementedError() |
104 |
| - |
105 |
| - def run(self, env_vars) -> list[Result]: |
106 |
| - raise NotImplementedError() |
107 |
| - |
108 |
| - def teardown(self): |
109 |
| - raise NotImplementedError() |
110 |
| - |
111 | 119 | def stddev_threshold(self):
|
112 | 120 | return None
|
113 | 121 |
|
114 | 122 | def get_suite_name(self) -> str:
|
115 | 123 | return self.suite.name()
|
116 | 124 |
|
117 |
| - def name(self): |
118 |
| - raise NotImplementedError() |
119 |
| - |
120 | 125 | def description(self):
|
121 | 126 | return ""
|
122 | 127 |
|
@@ -146,12 +151,14 @@ def get_metadata(self) -> BenchmarkMetadata:
|
146 | 151 | )
|
147 | 152 |
|
148 | 153 |
|
149 |
| -class Suite: |
| 154 | +class Suite(ABC): |
| 155 | + @abstractmethod |
150 | 156 | def benchmarks(self) -> list[Benchmark]:
|
151 |
| - raise NotImplementedError() |
| 157 | + pass |
152 | 158 |
|
| 159 | + @abstractmethod |
153 | 160 | def name(self) -> str:
|
154 |
| - raise NotImplementedError() |
| 161 | + pass |
155 | 162 |
|
156 | 163 | def setup(self):
|
157 | 164 | return
|
|
0 commit comments