def cli_test(problem, **kwargs): """ Test numerical correctness with different parameters. """ set_log_level('ERROR') test(problem, **kwargs)
def cli_test(problem, **kwargs): """`click` interface for the `test` mode.""" set_log_level('ERROR') test(problem, **kwargs)
gflopss, oi, timings, _ = self.func(*args, **kwargs) for key in timings.keys(): self.register(gflopss[key], measure="gflopss", event=key.name) self.register(oi[key], measure="oi", event=key.name) self.register(timings[key], measure="timings", event=key.name) return DevitoExecutor(func) if __name__ == "__main__": # If running with MPI, we emit logging messages from rank0 only try: MPI.Init() # Devito starts off with MPI disabled! set_log_level('DEBUG', comm=MPI.COMM_WORLD) if MPI.COMM_WORLD.size > 1 and not configuration['mpi']: warning( "It seems that you're running over MPI with %d processes, but " "DEVITO_MPI is unset. Setting `DEVITO_MPI=basic`..." % MPI.COMM_WORLD.size) configuration['mpi'] = 'basic' except TypeError: # MPI not available pass # Profiling at max level configuration['profiling'] = 'advanced' benchmark()
def run(problem, **kwargs): """ A single run with a specific set of performance parameters. """ setup = model_type[problem]['setup'] options = {} time_order = kwargs.pop('time_order')[0] space_order = kwargs.pop('space_order')[0] autotune = kwargs.pop('autotune') options['autotune'] = autotune block_shapes = as_tuple(kwargs.pop('block_shape')) operator = kwargs.pop('operator', 'forward') warmup = kwargs.pop('warmup') # Should a specific block-shape be used? Useful if one wants to skip # the autotuning pass as a good block-shape is already known # Note: the following piece of code is horribly *hacky*, but it works for now for i, block_shape in enumerate(block_shapes): for n, level in enumerate(block_shape): for d, s in zip(['x', 'y', 'z'], level): options['%s%d_blk%d_size' % (d, i, n)] = s solver = setup(space_order=space_order, time_order=time_order, **kwargs) if warmup: info("Performing warm-up run ...") set_log_level('ERROR', comm=MPI.COMM_WORLD) run_op(solver, operator, **options) set_log_level('DEBUG', comm=MPI.COMM_WORLD) info("DONE!") retval = run_op(solver, operator, **options) try: rank = MPI.COMM_WORLD.rank except AttributeError: # MPI not available rank = 0 dumpfile = kwargs.pop('dump_summary') if dumpfile: if configuration['profiling'] != 'advanced': raise RuntimeError( "Must set DEVITO_PROFILING=advanced (or, alternatively, " "DEVITO_LOGGING=PERF) with --dump-summary") if rank == 0: with open(dumpfile, 'w') as f: summary = retval[-1] assert isinstance(summary, PerformanceSummary) f.write(str(summary.globals_all)) dumpfile = kwargs.pop('dump_norms') if dumpfile: norms = [ "'%s': %f" % (i.name, norm(i)) for i in retval[:-1] if isinstance(i, DiscreteFunction) ] if rank == 0: with open(dumpfile, 'w') as f: f.write("{%s}" % ', '.join(norms)) return retval