Example #1
0
def plot(problem, **kwargs):
    """
    Plotting mode to generate plots for performance analysis.
    """
    backend = kwargs.pop('backend')
    resultsdir = kwargs.pop('resultsdir')
    max_bw = kwargs.pop('max_bw')
    flop_ceils = kwargs.pop('flop_ceil')
    point_runtime = kwargs.pop('point_runtime')

    arch = kwargs['arch']
    space_order = "[%s]" % ",".join(str(i) for i in kwargs['space_order'])
    time_order = kwargs['time_order']
    shape = "[%s]" % ",".join(str(i) for i in kwargs['shape'])

    RooflinePlotter = get_ob_plotter()
    bench = get_ob_bench(problem, resultsdir, kwargs)

    bench.load()
    if not bench.loaded:
        warning("Could not load any results, nothing to plot. Exiting...")
        sys.exit(0)

    gflopss = bench.lookup(params=kwargs, measure="gflopss", event='main')
    oi = bench.lookup(params=kwargs, measure="oi", event='main')
    time = bench.lookup(params=kwargs, measure="timings", event='main')

    # What plot am I?
    modes = [
        i for i in ['dse', 'dle', 'autotune']
        if len(set(dict(j)[i] for j in gflopss)) > 1
    ]

    # Filename
    figname = "%s_dim%s_so%s_to%s_arch[%s]_bkend[%s].pdf" % (
        problem, shape, space_order, time_order, arch, backend)

    # Legend setup. Do not plot a legend if there's no variation in performance
    # options (dse, dle, autotune)
    if modes:
        legend = {'loc': 'upper left', 'fontsize': 7, 'ncol': 4}
    else:
        legend = 'drop'

    avail_colors = ['r', 'g', 'b', 'y', 'k', 'm']
    avail_markers = ['o', 'x', '^', 'v', '<', '>']

    used_colors = {}
    used_markers = {}

    # Find min and max runtimes for instances having the same OI
    min_max = {v: [0, sys.maxsize] for v in oi.values()}
    for k, v in time.items():
        i = oi[k]
        min_max[i][0] = v if min_max[i][0] == 0 else min(v, min_max[i][0])
        min_max[i][1] = v if min_max[i][1] == sys.maxsize else max(
            v, min_max[i][1])

    with RooflinePlotter(figname=figname,
                         plotdir=resultsdir,
                         max_bw=max_bw,
                         flop_ceils=flop_ceils,
                         fancycolor=True,
                         legend=legend) as plot:
        for k, v in gflopss.items():
            so = dict(k)['space_order']

            oi_value = oi[k]
            time_value = time[k]

            run = tuple(dict(k)[i] for i in modes)
            label = ("<%s>" % ','.join(run)) if run else None

            color = used_colors[
                run] if run in used_colors else avail_colors.pop(0)
            used_colors.setdefault(run, color)
            marker = used_markers[
                so] if so in used_markers else avail_markers.pop(0)
            used_markers.setdefault(so, marker)

            oi_loc = 0.076 if len(str(so)) == 1 else 0.09
            oi_annotate = {
                's': 'SO=%s' % so,
                'size': 6,
                'xy': (oi_value, oi_loc)
            }
            if time_value in min_max[oi_value] and point_runtime:
                # Only annotate min and max runtimes on each OI line, to avoid
                # polluting the plot too much
                point_annotate = {
                    's': "%.0fs" % time_value,
                    'xytext': (0.0, 5.5),
                    'size': 6,
                    'rotation': 0
                }
            else:
                point_annotate = None
            oi_line = time_value == min_max[oi_value][0]
            if oi_line:
                perf_annotate = {'size': 6, 'xytext': (-4, 5)}

            plot.add_point(gflops=v,
                           oi=oi_value,
                           marker=marker,
                           color=color,
                           oi_line=oi_line,
                           label=label,
                           perf_annotate=perf_annotate,
                           oi_annotate=oi_annotate,
                           point_annotate=point_annotate)
Example #2
0
            ('aggressive', 'speculative'): ('s', 'b')
        }

        # Find min and max runtimes for instances having the same OI
        min_max = {v: [0, sys.maxint] for v in oi.values()}
        for k, v in time.items():
            i = oi[k]
            min_max[i][0] = v if min_max[i][0] == 0 else min(v, min_max[i][0])
            min_max[i][1] = v if min_max[i][1] == sys.maxint else max(
                v, min_max[i][1])

        with RooflinePlotter(title=title,
                             figname=name,
                             plotdir=args.plotdir,
                             max_bw=args.max_bw,
                             max_flops=args.max_flops,
                             fancycolor=True,
                             legend={
                                 'fontsize': 5,
                                 'ncol': 4
                             }) as plot:
            for key, gflopss in gflopss.items():
                oi_value = oi[key]
                time_value = time[key]
                key = dict(key)
                run = (key["dse"], key["dle"])
                label = "<%s,%s>" % run
                oi_loc = 0.05 if len(str(key["space_order"])) == 1 else 0.06
                oi_annotate = {
                    's': 'SO=%s' % key["space_order"],
                    'size': 4,
                    'xy': (oi_value, oi_loc)
Example #3
0
def plot(problem, **kwargs):
    """
    Plotting mode to generate plots for performance analysis.
    """
    resultsdir = kwargs.pop('resultsdir')
    max_bw = kwargs.pop('max_bw')
    flop_ceils = kwargs.pop('flop_ceil')
    point_runtime = kwargs.pop('point_runtime')

    arch = kwargs['arch']
    space_order = "[%s]" % ",".join(str(i) for i in kwargs['space_order'])
    time_order = kwargs['time_order']
    tn = kwargs['tn']
    shape = "[%s]" % ",".join(str(i) for i in kwargs['shape'])

    RooflinePlotter = get_ob_plotter()
    bench = get_ob_bench(problem, resultsdir, kwargs)

    bench.load()
    if not bench.loaded:
        warning("Could not load any results, nothing to plot. Exiting...")
        sys.exit(0)

    gflopss = bench.lookup(params=kwargs, measure="gflopss", event='main')
    oi = bench.lookup(params=kwargs, measure="oi", event='main')
    time = bench.lookup(params=kwargs, measure="timings", event='main')

    # Filaneme
    figname = "%s_dim%s_so%s_to%s_arch[%s].pdf" % (problem, shape, space_order,
                                                   time_order, arch)

    # Plot title
    name = {'acoustic': 'Acoustic', 'tti': 'TTI'}[problem]
    problem = "%s<grid=%s, TO=%s, sim=%sms>" % (name, shape, time_order, tn)
    varying = [
        i for i in ['dse', 'dle', 'autotune']
        if len(set(dict(j)[i] for j in gflopss)) > 1
    ]
    varying = ("varying<%s>" % ",".join(varying)) if varying else None
    arch = "arch<%s>" % arch
    backend = "backend<%s>" % configuration['backend']
    title = ", ".join(i for i in [problem, varying, arch, backend] if i)

    # Legend setup. Do not plot a legend if there's no variation in performance
    # options (dse, dle, autotuning)
    if varying is not None:
        legend = {'loc': 'upper left', 'fontsize': 5, 'ncol': 4}
    else:
        legend = 'drop'

    # Plot style setup {<dse, dle> -> <marker, color>}
    styles = {
        # DLE basic
        ('basic', 'basic'): ('D', 'r'),
        ('advanced', 'basic'): ('D', 'g'),
        ('aggressive', 'basic'): ('D', 'b'),
        # DLE advanced
        ('basic', 'advanced'): ('o', 'r'),
        ('advanced', 'advanced'): ('o', 'g'),
        ('aggressive', 'advanced'): ('o', 'b'),
    }

    # Find min and max runtimes for instances having the same OI
    min_max = {v: [0, sys.maxsize] for v in oi.values()}
    for k, v in time.items():
        i = oi[k]
        min_max[i][0] = v if min_max[i][0] == 0 else min(v, min_max[i][0])
        min_max[i][1] = v if min_max[i][1] == sys.maxsize else max(
            v, min_max[i][1])

    with RooflinePlotter(title=title,
                         figname=figname,
                         plotdir=resultsdir,
                         max_bw=max_bw,
                         flop_ceils=flop_ceils,
                         fancycolor=True,
                         legend=legend) as plot:
        for key, gflopss in gflopss.items():
            oi_value = oi[key]
            time_value = time[key]
            key = dict(key)
            run = (key["dse"], key["dle"])
            label = "<%s,%s>" % run
            oi_loc = 0.05 if len(str(key["space_order"])) == 1 else 0.06
            oi_annotate = {
                's': 'SO=%s' % key["space_order"],
                'size': 4,
                'xy': (oi_value, oi_loc)
            } if run[0] else None
            if time_value in min_max[oi_value] and point_runtime:
                # Only annotate min and max runtimes on each OI line, to avoid
                # polluting the plot too much
                point_annotate = {
                    's': "%.1f s" % time_value,
                    'xytext': (0, 5.2),
                    'size': 3.5,
                    'weight': 'bold',
                    'rotation': 0
                }
            else:
                point_annotate = None
            oi_line = time_value == min_max[oi_value][0]
            if oi_line:
                perf_annotate = {'size': 4, 'xytext': (-4, 4)}
            plot.add_point(gflops=gflopss,
                           oi=oi_value,
                           marker=styles[run][0],
                           color=styles[run][1],
                           oi_line=oi_line,
                           label=label,
                           perf_annotate=perf_annotate,
                           oi_annotate=oi_annotate,
                           point_annotate=point_annotate)
Example #4
0
            used_colors = {}
            used_markers = {}

            # Find min and max runtimes for instances having the same OI
            min_max = {v: [0, sys.maxsize] for v in oi.values()}
            for k, v in time.items():
                i = oi[k]
                min_max[i][0] = v if min_max[i][0] == 0 else min(
                    v, min_max[i][0])
                min_max[i][1] = (v if min_max[i][1] == sys.maxsize else max(
                    v, min_max[i][1]))

            with RooflinePlotter(figname=figname,
                                 plotdir=resultsdir,
                                 max_bw=max_bw,
                                 flop_ceils=flop_ceils,
                                 fancycolor=True,
                                 legend='drop') as plot:
                for k, v in gflopss.items():
                    so = dict(k)['space_order']

                    oi_value = oi[k]
                    time_value = time[k]
                    label = "SO %s" % so

                    color = used_colors[
                        so] if so in used_colors else avail_colors.pop(0)
                    used_colors.setdefault(so, color)
                    marker = (used_markers[so]
                              if so in used_markers else avail_markers.pop(0))
                    used_markers.setdefault(so, marker)
Example #5
0
def plot(problem, **kwargs):
    """
    Plotting mode to generate plots for performance analysis.
    """
    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")
    resultsdir = kwargs.pop('resultsdir')
    plotdir = kwargs.pop('plotdir')
    arch = kwargs.pop('arch')
    max_bw = kwargs.pop('max_bw')
    max_flops = kwargs.pop('max_flops')
    point_runtime = kwargs.pop('point_runtime')

    bench = Benchmark(name=problem, resultsdir=resultsdir, parameters=kwargs)
    bench.load()
    if not bench.loaded:
        warning("Could not load any results, nothing to plot. Exiting...")
        sys.exit(0)

    gflopss = bench.lookup(params=kwargs, measure="gflopss", event='main')
    oi = bench.lookup(params=kwargs, measure="oi", event='main')
    time = bench.lookup(params=kwargs, measure="timings", event='main')

    name = "%s_dim%s_so%s_to%s_arch[%s].pdf" % (problem, kwargs['shape'],
                                                kwargs['space_order'],
                                                kwargs['time_order'], arch)
    name = name.replace(' ', '')
    problem_styles = {'acoustic': 'Acoustic', 'tti': 'TTI'}
    title = "%s [grid=%s, TO=%s, duration=%sms], varying <DSE,DLE> on %s" %\
        (problem_styles[problem], list(kwargs['shape']), kwargs['time_order'],
         kwargs['tn'], arch)

    styles = {  # (marker, color)
        # DLE basic
        ('basic', 'basic'): ('D', 'r'),
        ('advanced', 'basic'): ('D', 'g'),
        ('speculative', 'basic'): ('D', 'y'),
        ('aggressive', 'basic'): ('D', 'b'),
        # DLE advanced
        ('basic', 'advanced'): ('o', 'r'),
        ('advanced', 'advanced'): ('o', 'g'),
        ('speculative', 'advanced'): ('o', 'y'),
        ('aggressive', 'advanced'): ('o', 'b'),
        # DLE speculative
        ('basic', 'speculative'): ('s', 'r'),
        ('advanced', 'speculative'): ('s', 'g'),
        ('speculative', 'speculative'): ('s', 'y'),
        ('aggressive', 'speculative'): ('s', 'b')
    }

    # Find min and max runtimes for instances having the same OI
    min_max = {v: [0, sys.maxsize] for v in oi.values()}
    for k, v in time.items():
        i = oi[k]
        min_max[i][0] = v if min_max[i][0] == 0 else min(v, min_max[i][0])
        min_max[i][1] = v if min_max[i][1] == sys.maxsize else max(
            v, min_max[i][1])

    with RooflinePlotter(title=title,
                         figname=name,
                         plotdir=plotdir,
                         max_bw=max_bw,
                         max_flops=max_flops,
                         fancycolor=True,
                         legend={
                             'fontsize': 5,
                             'ncol': 4
                         }) as plot:
        for key, gflopss in gflopss.items():
            oi_value = oi[key]
            time_value = time[key]
            key = dict(key)
            run = (key["dse"], key["dle"])
            label = "<%s,%s>" % run
            oi_loc = 0.05 if len(str(key["space_order"])) == 1 else 0.06
            oi_annotate = {
                's': 'SO=%s' % key["space_order"],
                'size': 4,
                'xy': (oi_value, oi_loc)
            } if run[0] else None
            if time_value in min_max[oi_value] and point_runtime:
                # Only annotate min and max runtimes on each OI line, to avoid
                # polluting the plot too much
                point_annotate = {
                    's': "%.1f s" % time_value,
                    'xytext': (0, 5.2),
                    'size': 3.5,
                    'weight': 'bold',
                    'rotation': 0
                }
            else:
                point_annotate = None
            oi_line = time_value == min_max[oi_value][0]
            if oi_line:
                perf_annotate = {'size': 4, 'xytext': (-4, 4)}
            plot.add_point(gflops=gflopss,
                           oi=oi_value,
                           marker=styles[run][0],
                           color=styles[run][1],
                           oi_line=oi_line,
                           label=label,
                           perf_annotate=perf_annotate,
                           oi_annotate=oi_annotate,
                           point_annotate=point_annotate)
Example #6
0
            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")

        name = "%s_dim%s_so%s_to%s.pdf" % (
            args.problem, parameters["dimensions"], parameters["space_order"],
            parameters["time_order"])
        title = "%s - grid: %s, time order: %s" % (args.problem.capitalize(),
                                                   parameters["dimensions"],
                                                   parameters["time_order"])
        with RooflinePlotter(figname=name,
                             plotdir=args.plotdir,
                             max_bw=args.max_bw,
                             max_flops=args.max_flops) as plot:
            for key, gflopss in gflopss.items():
                oi_value = oi[key]
                key = dict(key)
                at = key["auto_tuning"]
                style = '%s%s' % (plot.color[0] if at else plot.color[1],
                                  plot.marker[0] if at else plot.marker[1])
                plot.add_point(gflops=gflopss,
                               oi=oi_value,
                               style=style,
                               oi_line=at,
                               label='Auto-tuned' if at else 'No Auto-tuning',
                               oi_annotate='SO: %s' %
                               key["space_order"] if at else None)
Example #7
0
            (('basic', 'factorize'), 'speculative'): 'sg',
            (('basic', 'glicm'), 'speculative'): 'sy',
            ('advanced', 'speculative'): 'sb',
        }

        # Find min and max runtimes for instances having the same OI
        min_max = {v: [0, sys.maxint] for v in oi.values()}
        for k, v in time.items():
            i = oi[k]
            min_max[i][0] = v if min_max[i][0] == 0 else min(v, min_max[i][0])
            min_max[i][1] = v if min_max[i][1] == sys.maxint else max(
                v, min_max[i][1])

        with RooflinePlotter(title=title,
                             figname=name,
                             plotdir=args.plotdir,
                             max_bw=args.max_bw,
                             max_flops=args.max_flops,
                             legend={'fontsize': 7}) as plot:
            for key, gflopss in gflopss.items():
                oi_value = oi[key]
                time_value = time[key]
                key = dict(key)
                run = (key["dse"], key["dle"])
                label = "<%s,%s>" % run
                oi_loc = 0.06 if len(str(key["space_order"])) == 1 else 0.07
                oi_annotate = {
                    's': 'SO=%s' % key["space_order"],
                    'size': 5,
                    'xy': (oi_value, oi_loc)
                } if run[0] else None
                if time_value in min_max[oi_value]: