|
| 1 | +#!/usr/bin/python |
| 2 | +""" |
| 3 | +
|
| 4 | +This script generates a series of commands to do parameter sweeps. One way to |
| 5 | +use this script is to generate a big matrix of configurations and then run them |
| 6 | +on different binaries to diff the output. This can be used as a poor man's |
| 7 | +regression test when doing code cleanups (i.e. where functionality is not |
| 8 | +supposed to change as a result of a commit. |
| 9 | +
|
| 10 | +Or, if you just set a single binary and comment out the diff stuff at the |
| 11 | +bottom, it is just a convenient way to do parameter sweeps. |
| 12 | +
|
| 13 | +Since this uses the command line overrides (-o flag), it needs a fairly recent |
| 14 | +commit of DRAMSim2 |
| 15 | +( see: https://github.com/dramninjasUMD/DRAMSim2/commit/e46f525bd274a0b3312002dce3efe83c769ea2ce ) |
| 16 | +
|
| 17 | +Just redirect the output of this command to a file and then run it in bash. |
| 18 | +
|
| 19 | +""" |
| 20 | + |
| 21 | +import itertools |
| 22 | + |
| 23 | +parameters = {'QUEUING_STRUCTURE': ['per_rank', 'per_rank_per_bank'], |
| 24 | + 'ROW_BUFFER_POLICY': ['open_page', 'close_page'], |
| 25 | + 'SCHEDULING_POLICY': ['rank_then_bank_round_robin','bank_then_rank_round_robin'] |
| 26 | + } |
| 27 | + |
| 28 | +devices = ['DDR3_micron_64M_8B_x4_sg15.ini', 'DDR2_micron_32M_4B_x4_sg3E.ini']; |
| 29 | + |
| 30 | +traces = ['k6_bsc_vector1.trc', 'k6_video_tracking_128kL2_trace.trc', 'k6_aoe_02_short.trc'] |
| 31 | +binaries = ['DRAMSim.master', 'DRAMSim.cleanup'] |
| 32 | + |
| 33 | +dramsim_flags = '-c 2000000 -n -S 8192 -q ' |
| 34 | + |
| 35 | +# get the parameter permutations |
| 36 | + |
| 37 | +master_list = [] |
| 38 | +for k,v in parameters.iteritems(): |
| 39 | +# print v |
| 40 | + master_list.append(v) |
| 41 | + |
| 42 | +paramOverrideList=[] |
| 43 | +for i in itertools.product(*master_list): |
| 44 | + tmp=[] |
| 45 | + for j,param in enumerate(i): |
| 46 | + tmp.append("%s=%s"%(parameters.keys()[j],param)) |
| 47 | + paramOverrideList.append(",".join(tmp)) |
| 48 | +#print paramOverrideList |
| 49 | + |
| 50 | +print "#!/bin/bash" |
| 51 | +print "rm DRAMSim.*.vis" |
| 52 | +i=0 |
| 53 | +for trace in traces: |
| 54 | + for device in devices: |
| 55 | + for paramOverrides in paramOverrideList: |
| 56 | + for executable in binaries: |
| 57 | + output_file = "%s_%d"%(executable, i) |
| 58 | + print "./%s -s system.ini -d ini/%s -t traces/%s -o %s %s -v %s &"%(executable, device, trace, paramOverrides, dramsim_flags, output_file) |
| 59 | + i+=1 |
| 60 | + |
| 61 | +print "echo -n waiting" |
| 62 | +print "wait" |
| 63 | +print "echo OK" |
| 64 | +print "echo Starting diff phase" |
| 65 | +for x in range(i): |
| 66 | + diff_args="%s_%d.vis %s_%d.vis"%(binaries[0],x,binaries[1],x) |
| 67 | + print "echo %s_%d.vis and %s_%d.vis:"%(binaries[0],x,binaries[1],x) |
| 68 | + print "is_different=`diff -q %s`"%(diff_args) |
| 69 | + print "if [ -n \"$is_different\" ] ; then" |
| 70 | + print "diff -u %s"%(diff_args); |
| 71 | + print "fi" |
0 commit comments