-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinstall_config.py
executable file
·261 lines (211 loc) · 10.9 KB
/
install_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
import os
from config import *
from subprocess import call
# This is the install script for the extra plugins to the Snipersim
# Invoke this script from the same folder it is present in to install the extra features
# This function makes the extra.cfg file which has some of the parameters
# Additionally this will make the a header filer config-paths.h which will store the same parameters
# New Directory Structure
# ...... sniper-6.1
# |______ HotSpot-6.0/
# | |______ hotspot.config
# | |______ my_floorplan.flp (generated thorugh the script : )
# |
# |______ extra-files/
# | |______ design-time-mapping.txt
# | |______ mapping-file.txt
# | |______ temp-power-trace.ptrace (Used by HotSpot generated by us)
# | |______ temp-steady-file.ttrace (Output of HoptSpot used by algorithm)
# | |______ runtime-mapping.txt (Expected file out of the Runtime Approach)
# | |______ mttf-file.txt (Output of RMU Module)
# |______|______ pv-file.txt
# |______ mttf/
# |______ power/
# |______ temp/
# Do not change this as this contains the modified Hotspot, which includes some additional feature. See manual for details.
hotspot_folder = "HotSpot-6.0"
# It is not recommended to change this also.
extra_folder_name = "extra-files"
algorithm_folder_name = "algorithm"
# Configurable parameter INTERVAL_TO_RUN_HOTSPOT. Specified in femto-seconds. Can be changed to seconds or any other unit
if runtime_intervention == False :
interval_to_run_hotspot = int(time_of_intervention) # Don't care
runtime_intervention = 0
else :
runtime_intervention = 1
interval_to_run_hotspot = int(time_of_intervention)
# Setting up all the paths required
pwd = os.getcwd()
path_to_input_to_thermal_simulation = pwd + "/" + extra_folder_name + "/" + "design-time-mapping.txt"
path_to_ptrace = pwd + "/" + extra_folder_name + "/" + "temp-power-trace.ptrace"
path_to_ttrace = pwd + "/" + extra_folder_name + "/" + "temp-steady-file.ttrace"
path_to_mapping_file = pwd + "/" + extra_folder_name + "/" + "mapping-file.txt"
path_to_hotspot = pwd + "/" + hotspot_folder + "/"
path_to_extra_folder = pwd + "/" + extra_folder_name
# Override this if, HotSpot is not used but a custom thermal model has to be used.
hotspot_command = path_to_hotspot + "hotspot" + " -c " + path_to_hotspot + "hotspot.config" + " -f " + path_to_hotspot + "my_floorplan.flp" + " -p " + path_to_ptrace + " -steady_file " + path_to_ttrace
path_to_extra_cfg = pwd + "/" + "config" + "/" + "extra.cfg"
path_to_header_file = pwd + "/" + "common" + "/" + "config-paths.h"
path_to_current_mapping_file = pwd + "/" + extra_folder_name + "/" + "current-mapping-file.txt"
path_to_time_file = pwd + "/" + extra_folder_name + "/" + "time-file.txt"
new_path_to_input_to_thermal_simulation = pwd + "/" + extra_folder_name + "/" + "runtime-mapping.txt"
path_to_mttf_file = pwd + "/" + extra_folder_name + "/" + "mttf-file.txt"
path_to_dvfs_file = pwd + "/" + extra_folder_name + "/" + "dvfs-file.txt"
path_to_ic_file = pwd + "/" + extra_folder_name + "/" + "ic-file.txt"
if not os.path.exists (path_to_extra_folder) :
os.makedirs(path_to_extra_folder)
if path_to_pv_file == "" :
path_to_pv_file = pwd + "/" + extra_folder_name + "/" + "pv-file.txt"
with open (path_to_pv_file,"w") as just_a_pv_file :
temp_string = ""
for _ in xrange (num_cores):
temp_string += "1.0 "
temp_string = temp_string[:len(temp_string)-1]
temp_string += "\n"
just_a_pv_file.write (temp_string)
num_app_per_hyper_period = len(app_list)
benchmarks_string = ""
num_threads_per_hyper_period = 0
for app in app_list :
benchmark_name,app_name,num_threads = app.split('-')
benchmarks_string += benchmark_name+"-"+app_name+"-"+input_size+"-"+num_threads+","
num_threads_per_hyper_period += int(num_threads)
benchmarks_string = benchmarks_string[:len(benchmarks_string)-1]
save_benchmark_string = benchmarks_string
for _ in xrange (number_of_epochs-1):
save_benchmark_string += "," + benchmarks_string
benchmarks_string = save_benchmark_string
if not os.path.exists (pwd + "/" + extra_folder_name + "/" + "power") :
os.makedirs(pwd + "/" + extra_folder_name + "/" + "power")
if not os.path.exists (pwd + "/" + extra_folder_name + "/" + "temp") :
os.makedirs(pwd + "/" + extra_folder_name + "/" + "temp")
if not os.path.exists (pwd + "/" + extra_folder_name + "/" + "mttf") :
os.makedirs(pwd + "/" + extra_folder_name + "/" + "mttf")
# This is to scale up the pwoer to the required values for simulation
power_factor = 20.0
# The config file to be used from Sniper, it should be "kingscross"
sniper_config = "gainestown"
# The most important part. This is to generate the command to run the simulation in Sniper
command_string = ""
command_string += "./run-sniper" + " " + "-n" + str(num_cores) + " " + "-c" + " " + sniper_config + " -c extra --sim-end=last -senergystats --benchmarks=" + benchmarks_string + "\n"
algorithm_command = ""
if path_to_algorithm_file == "temp_min" :
algorithm_command = pwd + "/" + algorithm_folder_name + "/" + "dvfs_example"
with open (path_to_mapping_file,"w") as mapping_file :
mapping_file.write ("0\n")
elif path_to_algorithm_file == "round-robin" :
algorithm_command = ""
# Function to generate the design-time and run-time mappings in a raound robin format
def make_round_robin():
threads_per_app = []
for application in app_list:
b_n,a_n,n_t = app.split('-')
threads_per_app.append(int(n_t))
core_id = 0
app_id = 0
with open (path_to_input_to_thermal_simulation,"w") as inp_file :
with open (new_path_to_input_to_thermal_simulation,"w") as inp_file2 :
for num_threads in threads_per_app :
for i in xrange (num_threads):
inp_file.write (str(core_id) + " " + str(app_id) + " " + str(i)+"\n")
inp_file2.write (str(core_id) + " " + str(app_id) + " " + str(i)+"\n")
core_id += 1
if core_id == num_cores :
core_id = 0
app_id += 1
# This part deals with conveying the process-variation to the Sniper.
pv_line = ""
with open (path_to_pv_file,"r") as pv_file :
pv_line = pv_file.readline()
pv_line = pv_line.replace(" ",",")
pv_values = map(float,pv_line.split(','))
frequency_line = ""
for i in xrange (num_cores):
frequency_line += str(pv_values[i]*(frequency/1000)) + ","
frequency_line = frequency_line[:len(frequency_line)-1]
# Populates the DVFS file with the inital values of frequencies
def make_intial_dvfs_file():
with open (path_to_dvfs_file,"w") as dvfs_file :
for i in xrange (num_cores):
dvfs_file.write (str(int(pv_values[i]*frequency)) + " ")
# Makes the floow-plan as required by HotSpot
def make_floor_plan():
width = 5.610359007978394 * 0.001
height = 5.610359007978394 * 0.001
count = 0
with open (path_to_hotspot+ "my_floorplan.flp","w") as flp_file :
for i in xrange (X) :
for j in xrange (Y) :
flp_file.write("C"+str(count)+" "+str(width)+" "+str(height)+" "+str(j*width)+" "+str(i*height) + "\n")
count += 1
# Makes the extra.cfg file after populating it with a ll teh values and configurations to be give to Sniper
def make_config_file() :
with open (path_to_extra_cfg,"w") as extra_cfg_file:
extra_cfg_file.write ("[general]" + "\n")
extra_cfg_file.write ("some_random_key = 1729" + "\n") # Dummy Key
extra_cfg_file.write ("path_to_input_to_thermal_simulation = \"" + path_to_input_to_thermal_simulation+ "\"\n")
extra_cfg_file.write ("path_to_ptrace = \"" + path_to_ptrace + "\"\n")
extra_cfg_file.write ("path_to_ttrace = \"" + path_to_ttrace + "\"\n")
extra_cfg_file.write ("path_to_mapping_file = \"" + path_to_mapping_file + "\"\n")
extra_cfg_file.write ("hotspot_command = \"" + hotspot_command+ "\"\n")
extra_cfg_file.write ("interval_to_run_hotspot = " + str(interval_to_run_hotspot) + "\n")
extra_cfg_file.write ("path_to_current_mapping_file = \"" + path_to_current_mapping_file + "\"\n")
extra_cfg_file.write ("path_to_time_file = \"" + path_to_time_file + "\"\n")
extra_cfg_file.write ("path_to_pv_file = \"" + path_to_pv_file + "\"\n")
extra_cfg_file.write ("num_app_per_hyper_period = " + str(num_app_per_hyper_period) + "\n")
extra_cfg_file.write ("num_threads_per_hyper_period = " + str(num_threads_per_hyper_period) + "\n")
extra_cfg_file.write ("new_path_to_input_to_thermal_simulation = \"" + new_path_to_input_to_thermal_simulation+ "\"\n")
extra_cfg_file.write ("runtime_intervention = " + str(runtime_intervention) + "\n")
extra_cfg_file.write ("power_factor = " + str(power_factor) + "\n")
extra_cfg_file.write ("failure_criterion = " + str(failure_criterion) + "\n")
extra_cfg_file.write ("max_mttf_years = " + str(max_mttf_years) + "\n")
extra_cfg_file.write ("epoch_length = " + str(epoch_length) + "\n")
extra_cfg_file.write ("path_to_mttf_file = \"" + path_to_mttf_file + "\"\n")
extra_cfg_file.write ("failure_mechanism = \"" + failure_mechanism + "\"\n")
extra_cfg_file.write ("algorithm_command = \"" + algorithm_command + "\"\n")
extra_cfg_file.write ("dvfs_file = \"" + path_to_dvfs_file + "\"\n")
extra_cfg_file.write ("path_to_extra_folder = \"" + path_to_extra_folder + "\"\n")
extra_cfg_file.write ("path_to_ic_file = \"" + path_to_ic_file + "\"\n")
extra_cfg_file.write ("[perf_model/core]\n")
extra_cfg_file.write ("frequency = " + frequency_line + "\n")
def make_header_file_for_users() :
with open (pwd +"/"+algorithm_folder_name+"/"+"paths.h","w") as header_file :
header_file.write ("#define " + "PATH_TO_TTRACE \"" + path_to_ttrace + "\"" + "\n")
header_file.write ("#define " + "PATH_TO_DVFS_FILE \"" + path_to_dvfs_file + "\"" + "\n")
header_file.write ("#define " + "NUM_CORES " + str(num_cores) + "\n")
header_file.write ("#define " + "PATH_TO_IC_FILE \"" + path_to_ic_file + "\"\n")
os.system("./install_algorithms.sh")
# Make the final header file with the appropriate tags :
# DEBUG_PRINT
# MODIFIED_CODE
# PERIODIC_WORKLOAD
# USE_RMU
def make_header_file():
with open (path_to_header_file,"w") as header_file :
header_file.write("#define DEBUG_PRINT\n")
if runtime_intervention == True :
header_file.write ("#define MODIFIED_CODE\n")
elif periodic_benchmarks == True :
header_file.write ("#define MODIFIED_CODE\n")
header_file.write ("#define PERIODIC_WORKLOAD\n")
header_file.write ("#define USE_RMU\n")
# Performs basic sanity checks for the files that should be present before the start of simulation
def sanity_checks():
if not os.path.isfile(path_to_pv_file) :
print "Error : Process Variation file not found in the path : " + path_to_pv_file
if not os.path.isfile(path_to_input_to_thermal_simulation) :
print "Error : Design time mapping file not found in the path : " + path_to_input_to_thermal_simulation
# Call all the functions one-by-one and get things done
make_floor_plan()
make_config_file()
make_intial_dvfs_file()
make_header_file_for_users()
if path_to_algorithm_file == "round-robin" :
make_round_robin()
make_header_file()
# To generate the run-script
with open (pwd+"/"+"benchmarks/new_run_b.sh","w") as run_file :
run_file.write(command_string+"\n")
# To re-complite sniper after the changes made
call(["make"])
sanity_checks()