|
| 1 | +import os |
| 2 | +import sys |
| 3 | +from subprocess import call |
| 4 | +import re |
| 5 | + |
| 6 | +# |
| 7 | +# Expected directory tree: |
| 8 | +# |
| 9 | +# root (eg: 'results') |
| 10 | +# | -- problemname (eg: acoustic, tti) |
| 11 | +# | | -- backend (eg: core, yask) |
| 12 | +# | | | -- benchmode (eg: O2, dse) |
| 13 | +# | | | | -- archname (eg: knl7250) |
| 14 | +# | | | | | -- grid512 -- files |
| 15 | +# | | | | | -- grid768 -- files |
| 16 | +# | | | | | -- grid1024 -- files |
| 17 | +# |
| 18 | +# E.g.: results/acoustic/core/bmO2/knl7250/grid512 |
| 19 | +# |
| 20 | + |
| 21 | +if len(sys.argv) != 2: |
| 22 | + print("Usage: python plot.py absolute/path/to/root") |
| 23 | + sys.exit(0) |
| 24 | + |
| 25 | +machines = {} |
| 26 | +exec(open("machines.txt").read(), {}, machines) |
| 27 | + |
| 28 | +subfolders = ['problemname', 'backend', 'benchmode', 'archname', 'grid'] |
| 29 | + |
| 30 | +benchmarkpy = os.path.join(os.environ['DEVITO_HOME'], 'examples', 'seismic', 'benchmark.py') |
| 31 | + |
| 32 | +root = sys.argv[1] |
| 33 | +dirs = [x[0] for x in os.walk(root)] |
| 34 | + |
| 35 | +root_depth = len(root.split('/')) |
| 36 | +plot_dirs = [i for i in dirs if len(i.split('/')) - len(subfolders) == root_depth] |
| 37 | + |
| 38 | +for i in plot_dirs: |
| 39 | + problem, backend, benchmode, arch, _ = i.split('/')[root_depth:] |
| 40 | + files = [f for f in os.listdir(i) if f.endswith('json')] |
| 41 | + if not files: |
| 42 | + print("No data files?") |
| 43 | + sys.exit(0) |
| 44 | + |
| 45 | + if arch not in machines: |
| 46 | + print("Don't own any information for %s architecture" % arch) |
| 47 | + sys.exit(0) |
| 48 | + machine = machines[arch] |
| 49 | + |
| 50 | + grid = re.search(r"shape\[([A-Za-z0-9_,]+)\]", files[0]).group(1).split(',') |
| 51 | + space_orders = sorted(set([int(re.search(r"so\[(\w+)\]", j).group(1)) for j in files])) |
| 52 | + tn = re.search(r"tn\[(\w+)\]", files[0]).group(1) |
| 53 | + autotune = re.search(r"at\[([A-Za-z0-9_,]+)\]", files[0]).group(1) |
| 54 | + |
| 55 | + args = ['python', benchmarkpy, 'plot', '-P', problem, '-bm', benchmode] # plot cmd |
| 56 | + args += ['-d'] + grid # grid shape |
| 57 | + for j in space_orders: |
| 58 | + args += ['-so', str(j)] # space orders tested |
| 59 | + args += ['-to', '2', '--tn', tn] # time-related simulation parameters |
| 60 | + args += ['-r', i] # plot dir |
| 61 | + args += ['--autotune', autotune] |
| 62 | + args += ['--backend', backend] |
| 63 | + args += ['--arch', arch, '--max-bw', str(machine['dram-stream-bw']), # arch params |
| 64 | + '--flop-ceil', str(machine['machine-peak']), 'ideal', |
| 65 | + '--flop-ceil', str(machine['linpack-peak']), 'linpack'] |
| 66 | + call(' '.join(args), shell=True) |
0 commit comments