Ejemplo n.º 1
0
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()
Ejemplo n.º 2
0
        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())
Ejemplo n.º 3
0
    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())