Skip to content

Commit

Permalink
Merge pull request devitocodes#1261 from devitocodes/bench-add-dump
Browse files Browse the repository at this point in the history
bench: Add --dump-summary option
  • Loading branch information
mloubout authored Apr 30, 2020
2 parents cf8a96a + bd8b9ce commit 28e6abb
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions benchmarks/user/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import click
import os
from devito import (clear_cache, configuration, info, warning, set_log_level,
switchconfig)
switchconfig, norm)
from devito.compiler import IntelCompiler
from devito.mpi import MPI
from devito.operator.profiling import PerformanceSummary
from devito.tools import all_equal, as_tuple, sweep
from devito.types.dense import DiscreteFunction

from benchmarks.user.tools import Driver, Executor, RooflinePlotter

Expand Down Expand Up @@ -180,6 +182,10 @@ def config_autotuning(ctx, param, value):
@benchmark.command(name='run')
@option_simulation
@option_performance
@click.option('--dump-summary', default=False,
help='File where the performance results are saved')
@click.option('--dump-norms', default=False,
help='File where the output norms are saved')
def cli_run(problem, **kwargs):
"""`click` interface for the `run` mode."""
configuration['develop-mode'] = False
Expand Down Expand Up @@ -208,7 +214,23 @@ def run(problem, **kwargs):
options['%s%d_blk%d_size' % (d, i, n)] = s

solver = setup(space_order=space_order, time_order=time_order, **kwargs)
return solver.forward(autotune=autotune, **options)
retval = solver.forward(autotune=autotune, **options)

dumpfile = kwargs.pop('dump_summary')
if dumpfile:
with open(dumpfile, 'w') as f:
summary = retval[-1]
assert isinstance(summary, PerformanceSummary)
f.write(str(summary.globals['fdlike']))

dumpfile = kwargs.pop('dump_norms')
if dumpfile:
norms = ["'%s': %f" % (i.name, norm(i)) for i in retval[:-1]
if isinstance(i, DiscreteFunction)]
with open(dumpfile, 'w') as f:
f.write("{%s}" % ', '.join(norms))

return retval


@benchmark.command(name='run-jit-backdoor')
Expand Down

0 comments on commit 28e6abb

Please sign in to comment.