-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.py
409 lines (310 loc) · 10.7 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
import platform
import os
from dataclasses import dataclass
from pathlib import Path
from typing import Dict, List, Optional
from types import SimpleNamespace as Namespace
from enum import Enum
import lib.util as util
from lib.tool import ToolName
from lib.algorithm import AlgorithmName
"""
System information
"""
SYSTEM = {'Darwin': 'macos', 'Linux': 'linux',
'Windows': 'windows'}[platform.system()]
EXECUTABLE_EXT = {'macos': '', 'windows': '.exe', 'linux': ''}[SYSTEM]
TARGET_SUFFIX = {'macos': '.dylib', 'linux': '.so', 'windows': '.dll'}[SYSTEM]
"""
This repository paths
"""
# Path to the root directory of spla-bench project
ROOT = Path(__file__).parent.parent
# Path to the directory, where datasets will be downloaded
# [MUTABLE]
DATASET_FOLDER = ROOT / 'dataset'
# Path to the deps dataset
DEPS = ROOT / 'deps'
@dataclass
class ToolConfigurations:
"""
Paths and other information about the third party tools
"""
# Path to the sources of tool
sources: Path
# Path to the build directory of tool
build: Path
# Relative paths to the algorithm binaries (from the build directory)
algo_rel: Dict[AlgorithmName, Path]
# Other configurations of the tool
config: Namespace
def algo_exec_paths(self) -> List[Path]:
paths = []
for exec in self.algo_rel.values():
paths.append(self.build / exec.with_suffix(EXECUTABLE_EXT))
return paths
def algo_exec_names(self) -> List[str]:
names = []
for exec in self.algo_rel.values():
names.append(exec.name)
return names
def are_all_built(self) -> bool:
return util.check_paths_exist(self.algo_exec_paths())
class SmArchitecture(Enum):
SM10 = 'SM10'
SM13 = 'SM13'
SM20 = 'SM20'
SM30 = 'SM30'
SM35 = 'SM35'
SM37 = 'SM37'
SM50 = 'SM50'
SM52 = 'SM52'
SM60 = 'SM60'
SM61 = 'SM61'
SM70 = 'SM70'
SM72 = 'SM72'
SM75 = 'SM75'
SM80 = 'SM80'
def __str__(self):
return self.value
TOOL_CONFIG: Dict[ToolName, ToolConfigurations] = {
ToolName.lagraph: ToolConfigurations(
sources=DEPS / 'lagraph',
build=DEPS / 'lagraph' / 'build',
algo_rel={
AlgorithmName.bfs: Path('sources') / 'benchmark' / 'bfs_demo',
AlgorithmName.sssp: Path('sources') / 'benchmark' / 'sssp_demo',
AlgorithmName.tc: Path('sources') / 'benchmark' / 'tc_demo'
},
config=Namespace()
),
ToolName.spla: ToolConfigurations(
sources=DEPS / 'spla',
build=DEPS / 'spla' / 'build',
algo_rel={
AlgorithmName.bfs: Path('spla_bfs'),
AlgorithmName.sssp: Path('spla_sssp'),
AlgorithmName.tc: Path('spla_tc')
},
config=Namespace()
),
ToolName.graphblast: ToolConfigurations(
sources=DEPS / 'graphblast',
build=DEPS / 'graphblast' / 'bin',
algo_rel={
AlgorithmName.bfs: Path('gbfs'),
AlgorithmName.sssp: Path('gsssp'),
AlgorithmName.tc: Path('gtc')
},
config=Namespace(
# 0: do not display per iteration timing, 1: display per iteration timing
# [MUTABLE]
timing=0,
# False: run CPU verification, True: skip CPU algorithm verification
# [MUTABLE]
skip_cpu_verify=False
)
),
ToolName.gunrock: ToolConfigurations(
sources=DEPS / 'gunrock',
build=DEPS / 'gunrock' / 'build',
algo_rel={
AlgorithmName.bfs: Path('') / 'bin' / 'bfs',
AlgorithmName.sssp: Path('') / 'bin' / 'sssp',
AlgorithmName.tc: Path('') / 'bin' / 'gtc',
},
config=Namespace(
# Autodetect target architecture
# [MUTABLE]
autodetect=True,
# Target sm and compute architecture
# [MUTABLE]
gencode=SmArchitecture.SM61
)
)
}
def tool_algo_exec_path(name: ToolName, algo: AlgorithmName):
return TOOL_CONFIG[name].build / TOOL_CONFIG[name].algo_rel[algo].with_suffix(EXECUTABLE_EXT)
"""
Conda repository with GraphBLAS build
[MUTABLE]
"""
CONDA_GRB_REPO = Namespace(
hash={
'macos': 'h4a89273',
'windows': 'h0e60522',
'linux': 'h9c3ff4c'
}[SYSTEM],
platform={
'macos': 'osx-64',
'windows': 'win-64',
'linux': 'linux-64'
}[SYSTEM],
version='6.1.4'
)
"""
Suitesparse.GraphBLAST installation information
[MUTABLE]
There are three ways to use suitesparse.
- Use local version (SUITESPARSE.local)
- Build it from sources, using GitHub repo (SUITESPARSE.repo)
- Download binaries form conda repository (SUITESPARSE.download)
Before starting benchmarks choose exactly one way of usage
and set corresponding values to non-null values
"""
SUITESPARSE = Namespace(
# Paths to the local version of suitesparse
local=Namespace(
# Path to the include directory (Ex. "../graphblas/include/")
include=None,
# Path to the library (Ex. "../graphblas/lib/libgraphblas.so")
library=None
),
# GitHub repository information
repo=Namespace(
url='https://github.com/DrTimothyAldenDavis/GraphBLAS',
branch='v6.1.4',
# Repository local path (where it will be cloned)
dest=DEPS/'suitesparse_graphblast',
# Relative path to the include directory from the repository root
include_rel=Path('Include'),
# Relative path to the build directory, where the library will be built
build_rel=Path('build'),
# Relative path to the library binary
library_rel=(Path('build') / 'libgraphblas').with_suffix(TARGET_SUFFIX)
),
# Conda repository information
download=None,
# Uncomment, if you want to download the library
# download=Namespace(
# url=f'https://anaconda.org/conda-forge/graphblas/{CONDA_GRB_REPO.version}/download/{CONDA_GRB_REPO.platform}/graphblas-{CONDA_GRB_REPO.version}-{CONDA_GRB_REPO.hash}_0.tar.bz2',
# dest=DEPS/'suitesparse_graphblast_conda',
# include_rel=Path('include'),
# library_rel=Path('lib') / 'libgraphblas' + TARGET_SUFFIX
# )
)
"""
Build configurations
"""
BUILD = Namespace(
# Paths to the C/C++/Cuda compilers (let Cmake detect by default)
cc=None,
cxx=None,
cudacxx='/usr/bin/g++-8',
# Number of jobs to build all sources (None will remove flag)
jobs=6,
)
"""
Datasets configuration
"""
@dataclass
class DatasetSizeInfo:
"""
Information about the size of the dataset
"""
# Maximal number of edges for this category of dataset largeness
max_n_edges: Optional[int]
# Number of iterations for the algorithm to execute on the dataset of this size
iterations: int
class DatasetSize(Enum):
"""
Size configurations
Change it to configure on how much iterations you want to
run benchmark on dataset of this size
[MUTABLE]
"""
# `size` = DatasetSizeInfo(`max_edges`, `iterations`)
tiny = DatasetSizeInfo(max_n_edges=5000, iterations=50)
small = DatasetSizeInfo(max_n_edges=80000, iterations=20)
medium = DatasetSizeInfo(max_n_edges=500000, iterations=10)
large = DatasetSizeInfo(max_n_edges=2000000, iterations=5)
extra_large = DatasetSizeInfo(max_n_edges=None, iterations=2)
def iterations(self):
return self.value.iterations
def max_n_edges(self) -> Optional[int]:
return self.value.max_n_edges
def from_n_edges(n_edges: int):
for d_size in list(DatasetSize):
if d_size.max_n_edges() is None or d_size.max_n_edges() >= n_edges:
return d_size
raise Exception(f'Can not get largeness category of {n_edges} edges')
"""
Path to the file with the supportive information about datasets.
It includes if dataset is directed or not and what is the value type
in this dataset (void, float, int)
This file is created automatically
[MUTABLE]
"""
DATASETS_PROPERTIES = DATASET_FOLDER / 'properties.json'
"""
Urls of the datasets and their names
You may add more urls to test more tests
Note: Name of the dataset (key in this dictionary) must match
name of the .mtx file in the archive
Note: All datasets are taken from http://sparse.tamu.edu/
[MUTABLE]
"""
DATASET_URL: Dict[str, str] = {
'1128_bus': 'https://suitesparse-collection-website.herokuapp.com/MM/HB/1138_bus.tar.gz',
'bcspwr03': 'https://suitesparse-collection-website.herokuapp.com/MM/HB/bcspwr03.tar.gz',
'soc-LiveJournal': 'https://suitesparse-collection-website.herokuapp.com/MM/SNAP/soc-LiveJournal1.tar.gz',
'hollywood-09': 'https://suitesparse-collection-website.herokuapp.com/MM/LAW/hollywood-2009.tar.gz',
'Journals': 'https://suitesparse-collection-website.herokuapp.com/MM/Pajek/Journals.tar.gz',
'com-Orcut': 'https://suitesparse-collection-website.herokuapp.com/MM/SNAP/com-Orkut.tar.gz',
'roadNet-CA': 'https://suitesparse-collection-website.herokuapp.com/MM/SNAP/roadNet-CA.tar.gz',
'indochina-2004': 'https://suitesparse-collection-website.herokuapp.com/MM/LAW/indochina-2004.tar.gz',
'cit-Patents': 'https://suitesparse-collection-website.herokuapp.com/MM/SNAP/cit-Patents.tar.gz',
'coAuthorsCiteseer': 'https://suitesparse-collection-website.herokuapp.com/MM/DIMACS10/coAuthorsCiteseer.tar.gz',
'coPapersDBLP': 'https://suitesparse-collection-website.herokuapp.com/MM/DIMACS10/coPapersDBLP.tar.gz'
}
"""
Default source for the path-finding algorithms (bfs, sssp)
[MUTABLE]
"""
DEFAULT_SOURCE = 0
"""
List of the datasets, which will be used for the benchmark
Name must correspond to the key in the DATASET_URL dictionary,
or to the .mtx
[MUTABLE]
"""
BENCHMARK_DATASETS = [
'1128_bus',
'bcspwr03',
'soc-LiveJournal',
'hollywood-09',
'com-Orcut',
'roadNet-CA',
'indochina-2004',
'cit-Patents',
'coAuthorsCiteseer',
'coPapersDBLP'
]
"""
Path to the benchmarks output directory
After each run of ./benchark.py script in the
BENCHMARK_OUTPUT will be created folder with the bechmark results
in .csv or .txt format. The folder will have name of the moment,
when benchmarks were executed. Also, a symlink BENCHMARK_OUTPUT/recent
will be created, which refers at the folder with the results
of the most recent benchmarks run.
[MUTABLE]
"""
BENCHMARK_OUTPUT = ROOT / 'benchmarks'
def jobs_flag() -> str:
assert BUILD.jobs > 0
if BUILD.jobs is None:
return ''
return f'-j{BUILD.jobs}'
def make_build_env() -> Dict[str, str]:
env = os.environ.copy()
additional_vars = {
'CC': BUILD.cc,
'CXX': BUILD.cxx,
'CUDAHOSTCXX': BUILD.cudacxx
}
for k, v in additional_vars.items():
if v is not None:
env[k] = str(v)
print(f'Using env: {additional_vars}')
return env