def bench(problem, **kwargs): """ Complete benchmark with multiple simulation and performance parameters. """ try: from opescibench import Benchmark, Executor except: raise ImportError( 'Could not import opescibench utility package.\n' 'Please install https://github.com/opesci/opescibench') run = tti_run if problem == 'tti' else acoustic_run resultsdir = kwargs.pop('resultsdir') repeats = kwargs.pop('repeats') class BenchExecutor(Executor): """Executor class that defines how to run the benchmark""" def run(self, *args, **kwargs): gflopss, oi, timings, _ = run(*args, **kwargs) for key in timings.keys(): self.register(gflopss[key], measure="gflopss", event=key) self.register(oi[key], measure="oi", event=key) self.register(timings[key], measure="timings", event=key) clear_cache() bench = Benchmark(name=problem, resultsdir=resultsdir, parameters=kwargs) bench.execute(BenchExecutor(), warmups=0, repeats=repeats) bench.save()
class DiffusionExecutor(Executor): """Executor class that defines how to run the benchmark""" def setup(self, **kwargs): self.ui = ring_initial(spacing=kwargs['spacing']) def run(self, *args, **kwargs): u, time = exec_func[kwargs['mode']]( self.ui, spacing=kwargs['spacing'], timesteps=kwargs['timesteps']) self.register(time) # Run benchmark across parameters and save the result bench = Benchmark(name='Diffusion', resultsdir=args.resultsdir, parameters=parameters) bench.execute(DiffusionExecutor(), warmups=0, repeats=1) bench.save() elif args.execmode == 'plot': # Load previously generated benchmark data bench = Benchmark(name='Diffusion', resultsdir=args.resultsdir, parameters=parameters) bench.load() # Generate the plot from loaded benchmark data plotter = Plotter() plotter.plot_comparison('DiffusionModes.pdf', args.mode, bench.lookup())
class BenchExecutor(Executor): """Executor class that defines how to run the benchmark""" def run(self, *args, **kwargs): gflopss, oi, timings, _ = run(*args, **kwargs) for key in timings.keys(): self.register(gflopss[key], measure="gflopss", event=key) self.register(oi[key], measure="oi", event=key) self.register(timings[key], measure="timings", event=key) clear_cache() bench = Benchmark(name=args.problem, resultsdir=args.resultsdir, parameters=parameters) bench.execute(BenchExecutor(), warmups=0, repeats=args.repeats) bench.save() elif args.execmode == "plot": try: from opescibench import Benchmark, RooflinePlotter except: raise ImportError( "Could not import opescibench utility package.\n" "Please install https://github.com/opesci/opescibench " "and Matplotlib to plot performance results") bench = Benchmark(name=args.problem, resultsdir=args.resultsdir, parameters=parameters) bench.load()
elif args.execmode == 'bench': if Benchmark is None: raise ImportError("Could not find opescibench utility package.\n" "Please install from https://github.com/opesci/opescibench") class DiffusionExecutor(Executor): """Executor class that defines how to run the benchmark""" def setup(self, **kwargs): self.ui = ring_initial(spacing=kwargs['spacing']) def run(self, *args, **kwargs): u, time = exec_func[kwargs['mode']](self.ui, spacing=kwargs['spacing'], timesteps=kwargs['timesteps']) self.register(time) # Run benchmark across parameters and save the result bench = Benchmark(name='Diffusion', resultsdir=args.resultsdir, parameters=parameters) bench.execute(DiffusionExecutor(), warmups=0, repeats=1) bench.save() elif args.execmode == 'plot': # Load previously generated benchmark data bench = Benchmark(name='Diffusion', resultsdir=args.resultsdir, parameters=parameters) bench.load() # Generate the plot from loaded benchmark data plotter = Plotter() plotter.plot_comparison('DiffusionModes.pdf', args.mode, bench.lookup())
class BenchExecutor(Executor): """Executor class that defines how to run the benchmark""" def run(self, *args, **kwargs): gflopss, oi, timings, _ = run(*args, **kwargs) for key in timings.keys(): self.register(gflopss[key], measure="gflopss", event=key) self.register(oi[key], measure="oi", event=key) self.register(timings[key], measure="timings", event=key) clear_cache() bench = Benchmark(name=args.problem, resultsdir=args.resultsdir, parameters=parameters) bench.execute(BenchExecutor(), warmups=0) bench.save() elif args.execmode == "plot": bench = Benchmark(name=args.problem, resultsdir=args.resultsdir, parameters=parameters) bench.load() if not bench.loaded: warning("Could not load any results, nothing to plot. Exiting...") sys.exit(0) gflopss = bench.lookup(params=parameters, measure="gflopss", event="loop_body") oi = bench.lookup(params=parameters, measure="oi", event="loop_body")
class BenchExecutor(Executor): """Executor class that defines how to run the benchmark""" def run(self, *args, **kwargs): gflopss, oi, timings, _ = run(*args, **kwargs) for key in timings.keys(): self.register(gflopss[key], measure="gflopss", event=key) self.register(oi[key], measure="oi", event=key) self.register(timings[key], measure="timings", event=key) clear_cache() bench = Benchmark(name=args.problem, resultsdir=args.resultsdir, parameters=parameters) bench.execute(BenchExecutor(), warmups=0, repeats=3) bench.save() elif args.execmode == "plot": try: from opescibench import Benchmark, RooflinePlotter except: raise ImportError( "Could not import opescibench utility package.\n" "Please install https://github.com/opesci/opescibench " "and Matplotlib to plot performance results") bench = Benchmark(name=args.problem, resultsdir=args.resultsdir, parameters=parameters) bench.load()