forked from cmuparlay/pbbsbench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runall
executable file
·239 lines (208 loc) · 7.16 KB
/
runall
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
#!/usr/bin/python
#
# run all tests
#
import os
import sys
os.system("echo HOSTNAME: `hostname`")
tests = [
["integerSort/parallelRadixSort",True,0],
["integerSort/serialRadixSort",False,0],
["comparisonSort/sampleSort",True,0],
["comparisonSort/quickSort",True,1],
["comparisonSort/mergeSort",True,1],
["comparisonSort/stableSampleSort",True,1],
["comparisonSort/serialSort",False,0],
["comparisonSort/ips4o",True,1],
["removeDuplicates/serial_hash", False,0],
["removeDuplicates/serial_sort", False,1],
["removeDuplicates/parlayhash", True,0],
["histogram/sequential",False,0],
["histogram/parallel",True,0],
["wordCounts/histogram",True,0],
# ["wordCounts/histogramStar",True],
["wordCounts/serial",False,0],
["invertedIndex/sequential", False,0],
["invertedIndex/parallel", True,0],
["suffixArray/parallelKS",True,1],
["suffixArray/parallelRange",True,0],
["suffixArray/serialDivsufsort",False,0],
["longestRepeatedSubstring/doubling",True,0],
["classify/decisionTree", True,0],
# ["minSpanningForest/parallelKruskal",True],
["minSpanningForest/parallelFilterKruskal",True,0],
["minSpanningForest/serialMST",False,0],
["spanningForest/incrementalST",True,1],
["spanningForest/ndST",True,0],
["spanningForest/serialST",False,0],
["breadthFirstSearch/simpleBFS",True,1],
["breadthFirstSearch/backForwardBFS",True,0],
["breadthFirstSearch/deterministicBFS",True,1],
["breadthFirstSearch/serialBFS",False,0],
["maximalMatching/serialMatching",False,0],
["maximalMatching/incrementalMatching",True,0],
["maximalIndependentSet/incrementalMIS",True,0],
["maximalIndependentSet/ndMIS",True,1],
["maximalIndependentSet/serialMIS",False,0],
["nearestNeighbors/octTree",True,0],
["rayCast/kdTree",True,0],
["convexHull/quickHull",True,0],
["convexHull/serialHull",False,0],
["delaunayTriangulation/incrementalDelaunay",True,0],
["delaunayRefine/incrementalRefine",True,0],
["rangeQuery2d/parallelPlaneSweep",True,0],
["rangeQuery2d/serial",False,0],
["nBody/parallelCK",True,0],
]
noTime = False
noCheck = False
scale = False
doSmall = False
forceCompile = False
parOnly = False
useNumactl = True
keep_tmp_files = False
extended = False
if (sys.argv.count("-only") > 0):
filteredTests = [l for l in tests if sys.argv.count(l[0]) > 0]
tests = filteredTests
print("Running only: ", tests)
if (sys.argv.count("-from") > 0):
idx = [i for i in range(len(tests)) if sys.argv.count(tests[i][0]) > 0]
if len(idx) > 0 :
tests = tests[idx[0]:len(tests)]
print("Running from: ", tests[0])
if (sys.argv.count("-notime") > 0):
print("Not Timing")
noTime = True
if (sys.argv.count("-ext") > 0):
print("Extended Benchmarks")
extended = True
if (sys.argv.count("-nocheck") > 0):
print("Not Checking")
noCheck = True
if (sys.argv.count("-small") > 0):
print("Small Inputs")
doSmall = True
if (sys.argv.count("-par") > 0):
print("Parallel Only")
parOnly = True
if (sys.argv.count("-scale") > 0):
print("Scale Tests")
scale = True
if (sys.argv.count("-nonuma") > 0):
print("No numactl")
useNumactl = False
if (sys.argv.count("-keep") > 0):
print("Keeping temp data files")
keep_tmp_files = True
if (sys.argv.count("-force") > 0):
print("Forcing Compile")
forceCompile = True
if (sys.argv.count("-h") > 0 or sys.argv.count("-help")):
print("arguments:")
print(" -force : forces compile")
print(" -nonuma : do not use numactl -i all")
print(" -scale : run on a range of number of cores")
print(" -par : only run parallel benchmarks")
print(" -notime : only compile")
print(" -nocheck : do not check results")
print(" -small : run on small data sets")
print(" -keep : keep temporary data files")
print(" -ext : extended set of benchmars")
print(" -only <bnchmrk> : only run given benchmark")
print(" -from <bnchmrk> : only run from given benchmark")
forceCompile = True
exit()
def detectCPUs():
"""
Detects the number of CPUs on a system. Cribbed from pp.
"""
# Linux, Unix and MacOS:
if hasattr(os, "sysconf"):
if os.sysconf_names.has_key("SC_NPROCESSORS_ONLN"):
# Linux & Unix:
ncpus = os.sysconf("SC_NPROCESSORS_ONLN")
if isinstance(ncpus, int) and ncpus > 0:
return ncpus
else: # OSX:
return int(os.popen2("sysctl -n hw.ncpu")[1].read())
# Windows:
if os.environ.has_key("NUMBER_OF_PROCESSORS"):
ncpus = int(os.environ["NUMBER_OF_PROCESSORS"]);
if ncpus > 0:
return ncpus
return 1 # Default
maxcpus = detectCPUs()
def getProcessors() :
if maxcpus <= 16:
processors = [1]+range(2,maxcpus+1,2)
elif maxcpus <= 32:
processors = [1,2]+range(4,maxcpus+1,4)
elif maxcpus <= 40:
processors = [1,4,16,20,40]
elif maxcpus <= 64:
processors = [1,2,4]+range(8,maxcpus+1,8)
elif maxcpus == 144:
processors = [1,4,16,32,72,144]
elif maxcpus == 256:
processors = [1,4,16,32,64,128,256]
else:
processors = [1,2,4,8]+range(16,maxcpus+1,16)
print(processors)
return processors
def compiletest(sdir) :
dir = "benchmarks/" + sdir
if (forceCompile) :
ss = "cd " + dir + " ; make -s cleanall ; make -s"
else :
ss = "cd " + dir + " ; make -s"
os.system("echo")
os.system("echo \"" + ss + "\"")
os.system(ss)
def runtest(test,procs,check) :
if (procs==1) : rounds = 1
elif (procs < 16) : rounds = 3
elif (procs < 64) : rounds = 3
else : rounds = 5
dir = "benchmarks/" + test[0]
numactl = useNumactl and (procs > 1)
options = "-r " + `rounds`
if (doSmall) : testInputs = "./testInputs_small"
else : testInputs = "./testInputs"
if (procs > 0) :
options = options + " -p " + `procs`
if not(check):
options = options + " -x"
if keep_tmp_files:
options = options + " -k"
if numactl:
sc = "cd " + dir + " ; numactl -i all " + testInputs + " " + options
else:
sc = "cd " + dir + " ; " + testInputs + " " + options
os.system("echo \"" + sc + "\"")
x = os.system(sc)
if (x) :
raise NameError(" " + sc)
try :
if scale : processors = getProcessors()
else : os.system("echo " + "\"running on " + `maxcpus` + " threads\"")
for test in tests :
isParallel = test[1]
primary = (int(test[2]) == 0)
if (isParallel or not(parOnly)) and (primary or extended) :
compiletest(test[0])
if not(noTime) :
if (not(isParallel)) :
runtest(test, 1, not(noCheck))
elif (not(scale)) :
runtest(test, maxcpus, not(noCheck))
else :
n = len(processors)
for p in processors[0:n-1] :
runtest(test, p, False)
os.system("echo")
runtest(test, processors[n-1], not(noCheck))
except NameError,v :
x, = v
print "TEST TERMINATED ABNORMALLY:\n"+x