12 return [e/denom for e in x]
15 return [e * a for e in x]
17 def argcmp(x, comp, predicate):
20 for i in xrange(len(x)):
21 if not predicate(x[i]):
23 if idx is None or comp(x[i], val):
28 raise Exception("no argmin satisfiying predicate")
31 def argmin(x, predicate):
32 return argcmp(x, lambda a, b: a < b, predicate)
34 def argmax(x, predicate):
35 return argcmp(x, lambda a, b: a > b, predicate)
37 def allocate(nworkers, weights):
38 approx = map(int, map(math.ceil, scale(weights, nworkers)))
39 diff = sum(approx) - nworkers
42 i = argmin(approx, predicate=lambda x: x > 0)
46 i = argmax(approx, lambda x: True)
51 ret.append(range(acc, acc + x))
56 print >>sys.stderr, '[INFO] running command %s' % str(cmd)
57 p = subprocess.Popen(cmd, stdin=open('/dev/null', 'r'), stdout=subprocess.PIPE)
62 if __name__ == '__main__':
63 (_, outfile) = sys.argv
65 STRATEGIES = ['epoch', 'epoch-compress']
66 NCORES = [1, 2, 4, 8, 16, 24, 32]
69 #STRATEGIES = ['epoch']
73 node = platform.node()
78 ('/data/scidb/001/2/stephentu/data.log', 1.),
79 ('/data/scidb/001/3/stephentu/data.log', 1.),
84 ('/f0/stephentu/data.log', 2./3.),
87 print "unknown node", node
88 assert False, "Unknown node!"
90 weights = normalize([x[1] for x in LOGGERS])
91 logfile_cmds = list(itertools.chain.from_iterable([['--logfile', f] for f, _ in LOGGERS]))
94 for strat, ncores, ws in itertools.product(STRATEGIES, NCORES, WSET):
95 allocations = allocate(ncores, weights)
97 itertools.chain.from_iterable([['--assignment', ','.join(map(str, alloc))] for alloc in allocations]))
98 cmd = ['./persist_test'] + \
101 ['--num-threads', str(ncores),
103 '--writeset', str(ws),
106 res = float(output.strip())
107 results.append(((strat, ncores, ws), res))
109 with open(outfile, 'w') as fp:
110 pickle.dump(results, fp)