-
Notifications
You must be signed in to change notification settings - Fork 0
/
collect_data.py
186 lines (140 loc) · 6.23 KB
/
collect_data.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
import re
import glob
import json
import csv
import os
PLATFORM = "SKY130HS"
DESIGN = "jpeg"
design_list = glob.glob("ctest/*")
_2_1_floorplan_all_results_csv = []
_3_3_resizer_all_results_csv = []
_4_1_cts_all_results_csv = []
_6_report_all_results_csv = []
all_results_json = {}
_2_1_floorplan_csv_columns = ["name", "tns", "wns"]
_3_3_resizer_csv_columns = ["name", "tns", "wns"]
_4_1_cts_csv_columns = ["name", "tns", "wns"]
_6_report_csv_columns = ["name", "tns", "wns", "internal_power", "switching_power", "leakage_power", "total_power", "instance_count"]
failed_designs = []
for de# design_list:
logs_f = design + "/logs"
objects_f = design + "/objects"
reports_f = design + "/reports"
results_f = design + "/results"
design_name = design.split("/")[-1]
all_results_json[design_name] = {}
if os.path.isfile(logs_f + "/" + PLATFORM + "/" + DESIGN + "/2_1_floorplan.log"):
with open(logs_f + "/" + PLATFORM + "/" + DESIGN + "/2_1_floorplan.log", "r") as rf:
filedata = rf.read()
tns_group = re.search("tns (.*)", filedata)
wns_group = re.search("wns (.*)", filedata)
results = {}
results["name"] = design_name
try:
tns = tns_group.group(1)
wns = wns_group.group(1)
results["tns"] = tns
results["wns"] = wns
all_results_json[design_name]["2_1_floorplan"] = results
_2_1_floorplan_all_results_csv.append(results)
except:
print("Cannot extract 2_1_floorplan.log from: " + design)
if os.path.isfile(logs_f + "/" + PLATFORM + "/" + DESIGN + "/3_3_resizer.log"):
with open(logs_f + "/" + PLATFORM + "/" + DESIGN + "/3_3_resizer.log", "r") as rf:
filedata = rf.read()
tns_group = re.search("tns (.*)", filedata)
wns_group = re.search("wns (.*)", filedata)
results = {}
results["name"] = design_name
try:
tns = tns_group.group(1)
wns = wns_group.group(1)
results["tns"] = tns
results["wns"] = wns
all_results_json[design_name]["3_3_resizer"] = results
_3_3_resizer_all_results_csv.append(results)
except:
print("Cannot extract 3_3_resizer.log from: " + design)
if os.path.isfile(logs_f + "/" + PLATFORM + "/" + DESIGN + "/4_1_cts.log"):
with open(logs_f + "/" + PLATFORM + "/" + DESIGN + "/4_1_cts.log", "r") as rf:
filedata = rf.read()
tns_group = re.search("tns (.*)", filedata)
wns_group = re.search("wns (.*)", filedata)
results = {}
results["name"] = design_name
try:
tns = tns_group.group(1)
wns = wns_group.group(1)
results["tns"] = tns
results["wns"] = wns
all_results_json[design_name]["4_1_cts"] = results
_4_1_cts_all_results_csv.append(results)
except:
print("Cannot extract 4_1_cts.log from: " + design)
if os.path.isfile(logs_f + "/" + PLATFORM + "/" + DESIGN + "/6_report.log"):
with open(logs_f + "/" + PLATFORM + "/" + DESIGN + "/6_report.log", "r") as rf:
filedata = rf.read()
tns_group = re.search("tns (.*)", filedata)
wns_group = re.search("wns (.*)", filedata)
power_group = re.search("report_power(\n.*)*(Total .*)", filedata)
instance_group = re.search("instance_count(\n.*)\n(\d+)", filedata)
results = {}
results["name"] = design_name
try:
tns = tns_group.group(1)
wns = wns_group.group(1)
power_all = power_group.group(2).split()
internal_poewr = power_all[1]
switching_power = power_all[2]
leakage_power = power_all[3]
total_power = power_all[4]
instance = instance_group.group(2)
results["tns"] = tns
results["wns"] = wns
results["internal_power"] = internal_poewr
results["switching_power"] = switching_power
results["leakage_power"] = leakage_power
results["total_power"] = total_power
with open(logs_f + "/" + PLATFORM + "/" + DESIGN + "/4_2_cts_fillcell.log", "r") as rf:
filler_filedata = rf.read()
filler_group = re.search("Placed (\d+) filler instances", filler_filedata)
if filler_group:
filler_count = filler_group.group(1)
results["instance_count"] = int(instance) - int(filler_count)
else:
print("Cannot find filler nums")
results["instance_count"] = int(instance)
all_results_json[design_name]["6_report"] = results
_6_report_all_results_csv.append(results)
except:
print("Cannot extract 6_report.log from: " + design)
else:
failed_designs.append(design_name)
if not os.path.isdir("doe_reports"):
os.mkdir("doe_reports")
with open("doe_reports/data_stream.json", "w") as wf:
wf.write(json.dumps(all_results_json))
with open("doe_reports/2_1_floorplan_all.csv", "w") as wf:
writer = csv.DictWriter(wf, fieldnames=_2_1_floorplan_csv_columns)
writer.writeheader()
for data in _2_1_floorplan_all_results_csv:
writer.writerow(data)
with open("doe_reports/3_3_resizer_all.csv", "w") as wf:
writer = csv.DictWriter(wf, fieldnames=_3_3_resizer_csv_columns)
writer.writeheader()
for data in _3_3_resizer_all_results_csv:
writer.writerow(data)
with open("doe_reports/4_1_cts_all.csv", "w") as wf:
writer = csv.DictWriter(wf, fieldnames=_4_1_cts_csv_columns)
writer.writeheader()
for data in _4_1_cts_all_results_csv:
writer.writerow(data)
with open("doe_reports/6_report_all.csv", "w") as wf:
writer = csv.DictWriter(wf, fieldnames=_6_report_csv_columns)
writer.writeheader()
for data in _6_report_all_results_csv:
writer.writerow(data)
with open("doe_reports/failed_designs.txt", "w") as wf:
for de# failed_designs:
wf.write(design + "\n")
print("Extraction done, data is stored in the doe_reports folder")