-
Notifications
You must be signed in to change notification settings - Fork 2
/
parse_bench_results
executable file
·56 lines (49 loc) · 2.64 KB
/
parse_bench_results
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
#!/usr/bin/env python
import optparse, fileinput, re, numpy, os.path, sys, itertools, pprint
from common import *
if __name__ == "__main__":
parser = optparse.OptionParser(usage = "usage: %prog [options] <space separated list of result directories>\n")
parser.add_option("-f", dest = "filter", help = "find filter for results", default = None)
parser.add_option("-p", dest = "print_best", action = "store_true", default = False, help = "print best result dir")
(options, args) = parser.parse_args()
resultdirs = set([arg.rstrip("/") for arg in args])
cluster_results = dict()
cluster_max = dict()
cluster_name_re = re.compile("^(\w+)-\d+")
num_cores_re = re.compile("-num_cores-(\d+)-")
hplout_gflops_re = re.compile("^\w+\s+\d+\s+\d+\s+\d+\s+\d+\s+[0-9.]+\s+([0-9.e+-]+)$")
find_opts = list(resultdirs) + [ "-name", "HPL.out" ]
if options.filter:
find_opts += [ '-and \( ' + options.filter + ' \)' ]
resultfiles = find_files(*find_opts)
for resultfile in resultfiles:
dirs = resultfile.split("/")
cluster_name_mo = cluster_name_re.match(dirs[-2])
num_cores_mo = num_cores_re.search(dirs[-3])
if cluster_name_mo and num_cores_mo:
cluster = cluster_name_mo.group(1)
num_cores = int(num_cores_mo.group(1))
if not cluster_results.has_key((cluster, num_cores)):
cluster_results[(cluster, num_cores)] = []
if not cluster_max.has_key((cluster, num_cores)):
cluster_max[(cluster, num_cores)] = [-1, None]
for line in fileinput.input(resultfile):
hplout_glfops_mo = hplout_gflops_re.search(line)
if hplout_glfops_mo:
gflops = float(hplout_glfops_mo.group(1))
cluster_results[(cluster, num_cores)].append(gflops)
if cluster_max[(cluster, num_cores)][0] < gflops:
cluster_max[(cluster, num_cores)][0] = gflops
cluster_max[(cluster, num_cores)][1] = dirs[-3]
else:
print >> sys.stderr, "error parsing filename %s" % (resultfile,)
def clusterkeyfunc(tuple):
return tuple[0]
for (key, group) in itertools.groupby(sorted(cluster_results.keys(), key = clusterkeyfunc), clusterkeyfunc):
print key
for (cluster, num_cores) in sorted(group, key = lambda tuple: tuple[1]):
print " num_cores = %i - gflops max = %f" % (num_cores, numpy.amax(cluster_results[cluster, num_cores])),
if options.print_best:
print " - %s" % (cluster_max[(cluster, num_cores)][1])
else:
print