-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
87 lines (73 loc) · 2.14 KB
/
run.py
File metadata and controls
87 lines (73 loc) · 2.14 KB
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
"""
Memory Compression Measurement program runner.
A python script that automates calling to driver program
and data gathering and parsing.
By Yuqing Liu
HEAP Lab, Virginia Tech
Jan 2020
"""
import os
import multiprocessing
import subprocess
#edit this part or create "run_config.py"
flags = [] #additional flags for driver
#files to run
folders = [] #prior is not empty
files = [] #quits if both empty
compressions = [] #To compile
layouts = [] #To compile
#If both empty, compiles everything
interest = [] #Outputs to be processed
outputfile = "default.out"
driver = "./bin/driver"
threads = multiprocessing.cpu_count() + 1
path = os.path.dirname(os.path.abspath(__file__))
of = open(outputfile, "w")
os.chdir(path)
#reads a seperate file to potentially replace above run specs
if os.path.exists("run_config.py"):
execfile("run_config.py")
p = subprocess.check_call(["make", "clean"])
if (len(compressions) + len(layouts) == 0):
p = subprocess.check_call(["make", "-j"+str(threads), "default"])
else:
p = subprocess.check_call(["make", "-j"+str(threads), "bootstrap", "driver"] + compressions + layouts)
output = []
index = 0
l = []
d = ""
if (len(folders) == 0):
l = files
else:
d = folders[0]
l = os.listdir(d)
while True:
l.sort()
for f in [f for f in l if os.path.isfile(os.path.join(d, f))]:
cmd = [driver, "-n", str(threads), "-f", os.path.join(d, f)] + flags
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
o = p.communicate()[0]
of.write(o)
output.append(o)
print f
print
#sample data parsing part
for j in interest:
print j
for i in output:
lines = i.strip("\n").split("\n")
l0 = lines[0].strip(",").split(",")
l1 = lines[1].strip(",").split(",")
for k in xrange(len(l0)):
if (l0[k] == j):
print l1[k]
break
print
output = []
index = index + 1
if (index >= len(folders)):
break
d = folders[index]
l = os.listdir(d)
of.write("\n")
of.close()