-
Notifications
You must be signed in to change notification settings - Fork 0
/
actinj2.py
319 lines (270 loc) · 12.6 KB
/
actinj2.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
# basic requirements:
# - the cache size should be scaled per core
# - make sure we are running all traces
import yaml
import os
import random
from argparse import ArgumentParser
import itertools
import random
BASH_HEADER = "#!/bin/bash\n"
# the command line slurm will execute
'''
SBATCH_COMMAND_LINE = "\
sbatch --cpus-per-task=1 --nodes=1 --ntasks=1 \
--workdir={ramulator_dir} \
--output={output_file_name} \
--error={error_file_name} \
--partition=slurm_part \
--job-name='{job_name}' \
{ramulator_dir}/run_scripts/{config_name}{config_extension}-{workload}.sh"
'''
# the command line slurm will execute
SBATCH_COMMAND_LINE = "\
sbatch --cpus-per-task=1 --nodes=1 --ntasks=1 \
--chdir={ramulator_dir} \
--output={output_file_name} \
--error={error_file_name} \
--partition=cpu_part \
--job-name='{job_name}' \
{ramulator_dir}/run_scripts/{config_name}{config_extension}-{workload}.sh"
# the script executed by the command line slurm executes
BASE_COMMAND_LINE = "\
LD_LIBRARY_PATH=/mnt/panzer/aolgun/EXT_LIBS \
{ramulator_dir}/ramulator "
# nRH sweep all mechanisms
RH32_configs = [
#'/mnt/panzer/fatmab/cms-ramulator/configs/ArtifactEvaluation/AttackPresent/CoMeT500-3-RH32.yaml',
'/mnt/panzer/fatmab/cms-ramulator/configs/ArtifactEvaluation/AttackPresent/CoMeT500-3-NM-RH32.yaml',
#'/mnt/panzer/fatmab/cms-ramulator/configs/ArtifactEvaluation/AttackPresent/CoMeT500-RH32.yaml',
#'/mnt/panzer/fatmab/cms-ramulator/configs/ArtifactEvaluation/AttackPresent/Baseline-RH32.yaml',
#'/mnt/panzer/fatmab/cms-ramulator/configs/ArtifactEvaluation/AttackPresent/Graphene500-RH32.yaml',
#'/mnt/panzer/fatmab/cms-ramulator/configs/ArtifactEvaluation/AttackPresent/REGA500-RH32.yaml',
#'/mnt/panzer/fatmab/cms-ramulator/configs/ArtifactEvaluation/AttackPresent/PARA500-RH32.yaml',
#'/mnt/panzer/fatmab/cms-ramulator/configs/ArtifactEvaluation/AttackPresent/Hydra500-RH32.yaml',
]
AH_configs = [
#'/mnt/panzer/fatmab/cms-ramulator/configs/ArtifactEvaluation/AttackPresent/CoMeT500-3-AH.yaml',
#'/mnt/panzer/fatmab/cms-ramulator/configs/ArtifactEvaluation/AttackPresent/CoMeT500-AH.yaml',
#'/mnt/panzer/fatmab/cms-ramulator/configs/ArtifactEvaluation/AttackPresent/Baseline-AH.yaml',
#'/mnt/panzer/fatmab/cms-ramulator/configs/ArtifactEvaluation/AttackPresent/Graphene500-AH.yaml',
#'/mnt/panzer/fatmab/cms-ramulator/configs/ArtifactEvaluation/AttackPresent/REGA500-AH.yaml',
#'/mnt/panzer/fatmab/cms-ramulator/configs/ArtifactEvaluation/AttackPresent/PARA500-AH.yaml',
#'/mnt/panzer/fatmab/cms-ramulator/configs/ArtifactEvaluation/AttackPresent/Hydra500-AH.yaml',
]
AAH_configs = [
'/mnt/panzer/fatmab/cms-ramulator/configs/ArtifactEvaluation/AttackPresent/CoMeT500-3-NM-AAH.yaml',
#'/mnt/panzer/fatmab/cms-ramulator/configs/ArtifactEvaluation/AttackPresent/CoMeT500-3-AAH.yaml',
#'/mnt/panzer/fatmab/cms-ramulator/configs/ArtifactEvaluation/AttackPresent/CoMeT500-AAH.yaml',
#'/mnt/panzer/fatmab/cms-ramulator/configs/ArtifactEvaluation/AttackPresent/Baseline-AAH.yaml',
#'/mnt/panzer/fatmab/cms-ramulator/configs/ArtifactEvaluation/AttackPresent/Graphene500-AAH.yaml',
#'/mnt/panzer/fatmab/cms-ramulator/configs/ArtifactEvaluation/AttackPresent/REGA500-AAH.yaml',
#'/mnt/panzer/fatmab/cms-ramulator/configs/ArtifactEvaluation/AttackPresent/PARA500-AAH.yaml',
#'/mnt/panzer/fatmab/cms-ramulator/configs/ArtifactEvaluation/AttackPresent/Hydra500-AAH.yaml',
]
#AAH_configs = ['/mnt/panzer/fatmab/cms-ramulator/configs/Paragraph/AttackPresent/CMS-refresh-AAH.yaml']
#new_aah = ['/mnt/panzer/aolgun/ramulator/configs/Paragraph/Revision/Paragraph500-PerRank-GrapheneOnly-AAH-Big.yaml']
#new_ah = ['/mnt/panzer/aolgun/ramulator/configs/Paragraph/Revision/Paragraph500-PerRank-GrapheneOnly-AH-Big.yaml']
#new_rh32 = ['/mnt/panzer/aolgun/ramulator/configs/Paragraph/Revision/Paragraph500-PerRank-GrapheneOnly-RH32-Big.yaml']
traces = [
#"random_10.trace",
#"stream_10.trace",
"401.bzip2",
"403.gcc",
"429.mcf",
"433.milc",
"434.zeusmp",
"435.gromacs",
"436.cactusADM",
"437.leslie3d",
"444.namd",
"445.gobmk",
"447.dealII",
"450.soplex",
"456.hmmer",
"458.sjeng",
"459.GemsFDTD",
"462.libquantum",
"464.h264ref",
"470.lbm",
"471.omnetpp",
"473.astar",
"481.wrf",
"482.sphinx3",
"483.xalancbmk",
"500.perlbench",
"502.gcc",
"505.mcf",
"507.cactuBSSN",
"508.namd",
"510.parest",
"511.povray",
"519.lbm",
"520.omnetpp",
"523.xalancbmk",
"525.x264",
"526.blender",
"531.deepsjeng",
"538.imagick",
"541.leela",
"544.nab",
"549.fotonik3d",
"557.xz",
#]
#traces = [
"bfs_dblp",
"bfs_cm2003",
"bfs_ny",
"grep_map0",
"h264_decode",
"h264_encode",
"jp2_decode",
"jp2_encode",
"tpcc64",
"tpch17",
"tpch2",
"tpch6",
"wc_8443", # wordcount-8443
"wc_map0", # wordcount-map0
"ycsb_abgsave",
"ycsb_aserver",
"ycsb_bserver",
"ycsb_cserver",
"ycsb_dserver",
"ycsb_eserver"
]
#traces = ["519.lbm"]
LOW_RBMPKI = ['531.deepsjeng', '502.gcc', '541.leela', '435.gromacs', '481.wrf', '458.sjeng', '445.gobmk', '444.namd', '508.namd', '401.bzip2', '456.hmmer', '403.gcc', '464.h264ref', '526.blender', '447.dealII', '544.nab', '523.xalancbmk', '500.perlbench', '538.imagick', '525.x264', '507.cactuBSSN', '511.povray']
MED_RBMPKI = ['462.libquantum', '473.astar', '510.parest', '482.sphinx3', '505.mcf', '557.xz', '471.omnetpp', '483.xalancbmk', '436.cactusADM']
HIGH_RBMPKI = ['520.omnetpp', '450.soplex', '470.lbm', '519.lbm', '434.zeusmp', '433.milc', '459.GemsFDTD', '549.fotonik3d', '429.mcf', '437.leslie3d']
# @returns SBATCH command used to invoke the ramulator script
def generateExecutionSetup(ramulator_dir, output_dir, trace_dir, adversarial_trace, config, workload_name_list):
CMD = BASE_COMMAND_LINE.format(
ramulator_dir = ramulator_dir,
)
ramulator_config=None
with open(config) as f:
ramulator_config = yaml.load(f, Loader=yaml.FullLoader)
bare_config = config.split('/')[-1]
workload_name_list_dir = [(trace_dir + "/" + x) for x in workload_name_list]
ramulator_config["processor"]["trace"] = workload_name_list_dir
#ramulator_config["processor"]["cache"]["L3"]["capacity"] = str(int(len(workload_name_list_dir) * 2)) + "MB"
ramulator_config["processor"]["cache"]["L3"]["capacity"] = str(int(len(workload_name_list_dir) * 4)) + "MB"
ramulator_config["memory"]["controller"]["act_injector"]["trace"] = trace_dir + "/" + adversarial_trace
#ramulator_config["memory"]["controller"]["act_injector"]["trace"] = trace_dir + "/hydra_adv_1K_r500.trace"
ramulator_config["memory"]["controller"]["act_injector"]["debug"] = False
# ramulator_config["memory"]["translation"]["type"] = "None"
SBATCH_CMD = SBATCH_COMMAND_LINE.format(
ramulator_dir = ramulator_dir,
output_file_name = '{output_file_name}',
error_file_name = '{error_file_name}',
config_extension = '',
job_name = '{job_name}',
config_name = bare_config,
workload = '{workload}'
)
prog_list = ""
length = len(workload_name_list)
for j in range(length-1):
prog_list += workload_name_list[j] + '-'
prog_list += workload_name_list[length-1]
stats_prefix = output_dir + '/' + bare_config + '/' + prog_list + '/'
ramulator_config["stats"]["prefix"] = stats_prefix
activate_dump_file_name = output_dir + '/' + bare_config + '/' + prog_list + '/activate_commands.txt'
period_dump_file_name = output_dir + '/' + bare_config + '/' + prog_list + '/activate_periods.txt'
ramulator_config["memory"]["controller"]["activation_count_dump_file"] = activate_dump_file_name
if "refresh_based_defense" in ramulator_config["post_warmup_settings"]["memory"]["controller"]:
ramulator_config["post_warmup_settings"]["memory"]["controller"]["refresh_based_defense"]["activation_period_file_name"] = period_dump_file_name
#ramulator_config["post_warmup_settings"]["memory"]["controller"]["refresh_based_defense"]["debug"] = True
# Finalize CMD
CMD += "\"" + yaml.dump(ramulator_config) + "\""
SBATCH_CMD = SBATCH_CMD.format(
output_file_name = output_dir + '/' + bare_config + '/' + prog_list + '/output.txt',
error_file_name = output_dir + '/' + bare_config + '/' + prog_list + '/error.txt',
job_name = prog_list,
workload = prog_list
)
os.system('mkdir -p ' + output_dir + '/' + bare_config + '/' + prog_list)
f = open(ramulator_dir + '/run_scripts/' + bare_config + '-' + prog_list + '.sh', 'w')
f.write(BASH_HEADER)
f.write(CMD)
f.close()
return SBATCH_CMD
ramulator_dir = '/mnt/panzer/fatmab/cms-ramulator'
output_dir = '/mnt/panzer/fatmab/cms-ramulator/ae-results'
trace_dir = '/mnt/panzer/fatmab/cms-ramulator/cputraces'
# remove scripts
os.system('rm -r ' + ramulator_dir + '/run_scripts')
os.system('mkdir -p ' + output_dir)
os.system('mkdir -p ' + ramulator_dir + '/run_scripts')
all_sbatch_commands = []
all_sbatch_commands.append(BASH_HEADER)
'''
for config in RH32_configs:
os.system('mkdir -p ' + output_dir + '/' + config.split('/')[-1])
# single core traces
for trace in traces:
print(trace)
all_sbatch_commands.append(generateExecutionSetup(ramulator_dir, output_dir, trace_dir, "rh32_new.trace", config, [trace]))
# for workload in traces:
# print([workload] * 7)
# all_sbatch_commands.append(generateExecutionSetup(ramulator_dir, output_dir, trace_dir, config, [workload] * 7))
for config in AH_configs:
os.system('mkdir -p ' + output_dir + '/' + config.split('/')[-1])
# single core traces
for trace in traces:
print(trace)
all_sbatch_commands.append(generateExecutionSetup(ramulator_dir, output_dir, trace_dir, "hydra_adv_1K_r500_new.trace", config, [trace]))
for config in AAH_configs:
os.system('mkdir -p ' + output_dir + '/' + config.split('/')[-1])
# single core traces
for trace in traces:
print(trace)
all_sbatch_commands.append(generateExecutionSetup(ramulator_dir, output_dir, trace_dir, "SAC_adv_i32_new.trace", config, [trace]))
'''
for config in RH32_configs:
os.system('mkdir -p ' + output_dir + '/' + config.split('/')[-1])
# single core traces
for trace in traces:
#print(trace)
if not os.path.exists(output_dir + '/' + config.split('/')[-1] + '/' + trace + '/DDR4stats.stats'):
all_sbatch_commands.append(generateExecutionSetup(ramulator_dir, output_dir, trace_dir, "rh32_new.trace", config, [trace]))
continue
if os.path.getsize(output_dir + '/' + config.split('/')[-1] + '/' + trace + '/DDR4stats.stats') == 0:
all_sbatch_commands.append(generateExecutionSetup(ramulator_dir, output_dir, trace_dir, "rh32_new.trace", config, [trace]))
else:
continue
for config in AH_configs:
os.system('mkdir -p ' + output_dir + '/' + config.split('/')[-1])
# single core traces
for trace in traces:
#print(trace)
if not os.path.exists(output_dir + '/' + config.split('/')[-1] + '/' + trace + '/DDR4stats.stats'):
all_sbatch_commands.append(generateExecutionSetup(ramulator_dir, output_dir, trace_dir, "hydra_adv_1K_r500_new.trace", config, [trace]))
continue
if os.path.getsize(output_dir + '/' + config.split('/')[-1] + '/' + trace + '/DDR4stats.stats') == 0:
all_sbatch_commands.append(generateExecutionSetup(ramulator_dir, output_dir, trace_dir, "hydra_adv_1K_r500_new.trace", config, [trace]))
else:
continue
for config in AAH_configs:
os.system('mkdir -p ' + output_dir + '/' + config.split('/')[-1])
# single core traces
for trace in traces:
#print(trace)
if not os.path.exists(output_dir + '/' + config.split('/')[-1] + '/' + trace + '/DDR4stats.stats'):
#print(output_dir.replace("/mnt/panzer/fatmab/cms-ramulator/","") + '/' + config.split('/')[-1] + '/' + trace + '/DDR4stats.stats')
all_sbatch_commands.append(generateExecutionSetup(ramulator_dir, output_dir, trace_dir, "comet_adv.trace", config, [trace]))
#all_sbatch_commands.append(generateExecutionSetup(ramulator_dir, output_dir, trace_dir, config, newlist))
continue
if os.path.getsize(output_dir + '/' + config.split('/')[-1] + '/' + trace + '/DDR4stats.stats') == 0:
# print the path of the empty file
#print(output_dir.replace("/mnt/panzer/fatmab/cms-ramulator/","") + '/' + config.split('/')[-1] + '/' + trace + '/DDR4stats.stats')
all_sbatch_commands.append(generateExecutionSetup(ramulator_dir, output_dir, trace_dir, "comet_adv.trace", config, [trace]))
#all_sbatch_commands.append(generateExecutionSetup(ramulator_dir, output_dir, trace_dir, config, newlist))
else:
continue
#all_sbatch_commands.append(generateExecutionSetup(ramulator_dir, output_dir, trace_dir, "comet_adv.trace", config, [trace]))
with open('run.sh', 'w') as f:
f.write('\n'.join(all_sbatch_commands))
os.system('chmod uog+x run.sh')
# print("REMEMBER TO CHANGE TRANSLATION")