21 Generate benchmarks.json for the web frontend 22 @author Michael Thies, Christoph Ostrau 24 from __future__
import print_function
25 from builtins
import str
26 from builtins
import range
28 import CppHeaderParser
33 simulators = [
"nest",
"spinnaker",
"nmpm1",
"spikey"]
34 web_simulators = [
"NEST",
"SpiNNaker",
"BrainScaleS",
36 bench_index = [
"Single Core/Smallest Network",
"Single Chip",
37 "Small System",
"Large System"]
42 Iterates through the dictionary, gathers all entries with lists 44 dictionary -- dict to iteratively search for lists 50 if type(dictionary[i]) == list:
51 temp_dict[i] = dictionary[i]
52 if(length < len(dictionary[i])):
53 length = len(dictionary[i])
55 if type(dictionary[i]) == dict:
61 return temp_dict, length
66 Checks the dictionary for lists of every simulator to gather information 67 about which simulator is available at which network size 69 dictionary -- config file to search for dictionaries 73 for simulator
in simulators:
76 if length > global_length:
77 global_length = length
78 avail_list.append(length)
82 if global_length == 0:
83 avail_list = [1
for i
in avail_list]
86 for i, simulator
in enumerate(simulators):
87 if "invalid" in dictionary[simulator]:
88 if dictionary[simulator][
"invalid"]:
96 for root, dirs, files
in os.walk(os.path.abspath(
"../source/SNABs/")):
98 list_files.append(os.path.join(root, file))
100 for headername
in list_files:
101 if not headername.endswith(
".hpp"):
104 cppHeader = CppHeaderParser.CppHeader(headername)
105 except CppHeaderParser.CppParseError
as e:
112 for classname
in cppHeader.classes:
114 clazz = cppHeader.classes[classname]
115 if not os.path.exists(
"../config/" + clazz[
'name'] +
".json"):
117 print(
'class', clazz[
'name'])
119 if 'doxygen' in clazz:
120 comment = clazz[
'doxygen']
122 comment = re.sub(
r'^/\*+\s*\n',
'', comment)
124 comment = re.sub(
r'\n\s*\*/',
'', comment)
126 comment = re.sub(
r'^\s*\*\s*',
'', comment, 0, re.MULTILINE)
128 comment = comment.replace(
'\n',
' ')
132 snab_dict[
"model"] = {
"name": clazz[
'name'],
133 "description": comment}
136 with open(
"../config/" + clazz[
'name'] +
".json")
as temp:
137 json_temp = json.load(temp)
145 for i
in range(0, length):
148 task_dict[
"name"] = bench_index[i]
149 task_dict[
"command"] =
"benchmark.py {system} " 150 task_dict[
"target"] = []
151 for j
in range(0, len(simulators)):
152 if i < avail_list[j]:
153 task_dict[
"target"].append(web_simulators[j])
157 task_dict[
"command"] += clazz[
'name'] +
" " +
str(i)
158 task_dict[
"config"] = {}
159 if i < avail_list[2]:
160 task_dict[
"config"] [web_simulators[2]]= {}
161 task_dict[
"config"] [web_simulators[2]][
"WAFER_MODULE"] = 33
162 if "wafer" in json_temp[simulators[2]][
"setup"]:
163 task_dict[
"config"] [web_simulators[2]][
"WAFER_MODULE"] = json_temp[simulators[2]][
"setup"][
"wafer"]
164 if not task_dict[
"config"]:
165 task_dict.pop(
'config',
None)
166 tasks.append(task_dict)
171 snab_dict[
"tasks"] = tasks
172 global_json.append(snab_dict)
177 with open(
'benchmarks.json',
'w')
as file:
178 json.dump(global_json, file, indent=4, sort_keys=
True)
def get_available_simulators(dictionary)
def get_key_arrays(dictionary)