This repository has been archived by the owner on Jul 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
testentry.py
151 lines (128 loc) · 4.15 KB
/
testentry.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021 The SymbiFlow Authors.
#
# Use of this source code is governed by a ISC-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/ISC
#
# SPDX-License-Identifier: ISC
import re
from collections import defaultdict
class Clk:
actual: float
hold_violation: float
met: bool
requested: float
setup_violation: float
class Resources:
bram: int
carry: int
dff: int
glb: int
iob: int
lut: int
pll: int
def sanitize(self):
# FIXME: currenly oxide uses FF instead of DFF, lacks GLB and has LRAM
# https://github.com/SymbiFlow/fpga-tool-perf/pull/342
if hasattr(self, 'ff'):
print('Sanitizing: FF->DFF')
# rename FF to DFF
assert not hasattr(self, 'dff')
self.dff = self.ff
del self.ff
# empty GLB
if not hasattr(self, 'glb'):
self.glb = 0
# ignore LRAM
if hasattr(self, 'lram'):
del self.lram
class Runtime:
bitstream: 'float | None'
checkpoint: 'float | None'
fasm: 'float | None'
fasm2bels: 'float | None'
link_design: 'float | None'
optimization: 'float | None'
overhead: 'float | None'
packing: 'float | None'
phys_opt_deing: 'float | None'
placement: 'float | None'
prepare: 'float | None'
repots: 'float | None'
routing: 'float | None'
synthesis: 'float | None'
total: 'float | None'
class TestEntry:
maxfreq: 'dict[str, Clk]'
maximum_memory_use: float
resources: Resources
runtime: Runtime
wirelength: 'int | None'
def get_configs(json_data: dict):
zipped = zip(json_data['results']['board'],
json_data['results']['toolchain'])
for board, toolchain_dict in zipped:
toolchain, _ = next(iter(toolchain_dict.items()))
yield board, toolchain
def null_generator():
while True:
yield None
def get_entries(json_data: dict):
results = json_data['results']
def make_clks(clkdef: 'dict | float'):
clks = {}
if type(clkdef) is dict:
for clkname, clkvals in clkdef.items():
clk = Clk()
for k, v in clkvals.items():
setattr(clk, k, v)
clks[clkname] = clk
elif type(clkdef) is float:
clk = Clk()
clk.actual = clkdef
clk.hold_violation = 0.0
clk.met = False
clk.requested = 0.0
clk.setup_violation = 0.0
clks['clk'] = clk
else:
raise Exception('Wrong type for clock definition')
return clks
def make_runtime(runtimedef: dict):
runtime = Runtime()
for k, v in runtimedef.items():
k = k.replace(' ', '_')
setattr(runtime, k, v)
return runtime
def make_resources(resourcesdef: dict):
resources = Resources()
for k, v in resourcesdef.items():
k = k.lower()
if v is None:
v = 'null'
setattr(resources, k, v)
resources.sanitize()
return resources
wirelength = results.get('wirelength')
if not wirelength:
wirelength = null_generator()
zipped = zip(results['board'], results['toolchain'], results['max_freq'],
results['maximum_memory_use'], results['resources'],
results['runtime'], wirelength)
for board, toolchain_dict, max_freq, max_mem_use, resources, runtime, \
wirelength in zipped:
toolchain, _ = next(iter(toolchain_dict.items()))
# Some platforms are cursed and the tests return just a single float
# instead of a dict
clk_config = max_freq
entry = TestEntry()
entry.maximum_memory_use =\
max_mem_use if max_mem_use is not None else 'null'
entry.wirelength = wirelength if wirelength is not None else 'null'
entry.maxfreq = make_clks(clk_config)
entry.runtime = make_runtime(runtime)
entry.resources = make_resources(resources)
yield board, toolchain, entry