コード例 #1
0
def fullscale_comp(lang,
                   plot_std=True,
                   homedir=None,
                   cache_opt_default=False,
                   smem_default=False,
                   loc_override=None,
                   text_loc=None,
                   fontsize=10,
                   color_list=['b', 'g', 'r', 'k']):
    if lang == 'c':
        langs = ['c', 'tchem']
        desc = 'cpu'
        smem_default = False
    elif lang == 'cuda':
        langs = ['cuda']
        desc = 'gpu'
    else:
        raise Exception('unknown lang {}'.format(lang))

    def thefilter(x):
        return x.cache_opt == cache_opt_default and x.smem == smem_default

    fit_vals = []
    data = get_data(homedir)
    data = [x for x in data if x.lang in langs]
    data = filter(thefilter, data)
    data = get_fullscale(data)
    if not len(data):
        print 'no data found... exiting'
        sys.exit(-1)

    fig, ax = plt.subplots()
    miny = None

    linestyle = ''

    fitvals = []
    retdata = []
    color_ind = 0
    text_ind = None
    if text_loc:
        text_ind = 0

    #FD
    plotdata = [x for x in data if x.finite_difference]
    if plotdata:
        color = color_list[color_ind]
        color_ind += 1
        miny, they, thez = plot(plotdata,
                                FD_marker,
                                'Finite Difference',
                                miny,
                                return_y=True,
                                color=color)
        theloc = None
        if text_ind is not None:
            theloc = text_loc[text_ind]
            text_ind += 1
        fitvals.append(
            fit_order(plotdata,
                      they,
                      thez,
                      None,
                      color,
                      text_loc=theloc,
                      fontsize=fontsize))
        retdata.append(they)

    for lang in langs:
        plotdata = [
            x for x in data if not x.finite_difference and x.lang == lang
        ]
        color = color_list[color_ind]
        color_ind += 1
        if plotdata:
            name, marker = nice_names(plotdata[0])
            miny, they, thez = plot(plotdata,
                                    marker,
                                    name,
                                    miny,
                                    return_y=True,
                                    color=color)
            theloc = None
            if text_ind is not None:
                theloc = text_loc[text_ind]
                text_ind += 1
            fitvals.append(
                fit_order(plotdata,
                          they,
                          thez,
                          None,
                          color,
                          text_loc=theloc,
                          fontsize=fontsize))
            retdata.append(they)

    ax.set_yscale('log')
    ax.set_ylim(ymin=miny * 0.95)
    loc = 0 if loc_override is None else loc_override
    ax.legend(loc=loc, numpoints=1, fontsize=10)
    # add some text for labels, title and axes ticks
    ax.set_ylabel('Mean evaluation time / condition (ms)')
    #ax.set_title('GPU Jacobian Evaluation Performance for {} mechanism'.format(thedir))
    ax.set_xlabel('Number of Reactions')
    #ax.legend(loc=0)
    plt.savefig('{}_norm.pdf'.format(desc))
    plt.close()

    return fitvals, retdata
コード例 #2
0
# x position of text label, and multiplier for y position
label_locs = [(10, 1.75),
              (10, 0.6),
              (10, 1.75),
              (10, 1.75)
              ]


if home_dir is None:
    home_dir = os.path.join(sys.path[0], '../')
    home_dir = os.path.realpath(home_dir)
d = os.path.join(home_dir, 'figures')

# Get CUDA pyJac datapoints, without cache optimization or shared memory
data = get_data()
plotdata = [x for x in data if x.lang == 'cuda'
            and not x.cache_opt
            and not x.smem
            and not x.finite_difference
            ]

fig, ax = plt.subplots()
minx, miny = plot_scaling(plotdata, legend_markers, legend_colors,
                          label_locs=label_locs
                          )
ax.set_yscale('log')
ax.set_xscale('log')
ax.set_ylim(ymin=miny*0.85)
ax.set_xlim(xmin=minx*0.85)
#ax.legend(loc=0, numpoints=1, frameon=False)
コード例 #3
0
ファイル: fullscale_comp.py プロジェクト: goldmanm/pyJac
def fullscale_comp(lang, plot_std=True, homedir=None,
                        cache_opt_default=False,
                        smem_default=False,
                        loc_override=None,
                        text_loc=None, fontsize=10,
                        color_list=['b', 'g', 'r', 'k']):
    if lang == 'c':
        langs = ['c', 'tchem']
        desc = 'cpu'
        smem_default=False
    elif lang == 'cuda':
        langs = ['cuda']
        desc = 'gpu'
    else:
        raise Exception('unknown lang {}'.format(lang))

    def thefilter(x):
        return x.cache_opt==cache_opt_default and x.smem == smem_default
    
    fit_vals = []
    data = get_data(homedir)
    data = [x for x in data if x.lang in langs]
    data = filter(thefilter, data)
    data = get_fullscale(data)
    if not len(data):
        print 'no data found... exiting'
        sys.exit(-1)

    fig, ax = plt.subplots()
    miny = None

    linestyle = ''

    fitvals = []
    retdata = []
    color_ind = 0
    text_ind = None
    if text_loc:
        text_ind = 0

    #FD
    plotdata = [x for x in data if x.finite_difference]
    if plotdata:
        color = color_list[color_ind]
        color_ind += 1
        miny, they, thez = plot(plotdata, FD_marker, 'Finite Difference', miny, return_y=True, color=color)
        theloc = None
        if text_ind is not None:
            theloc = text_loc[text_ind]
            text_ind += 1
        fitvals.append(
            fit_order(plotdata, they, thez, None, color, text_loc=theloc, fontsize=fontsize)
            )
        retdata.append(they)

    for lang in langs:
        plotdata = [x for x in data if not x.finite_difference
                        and x.lang == lang]
        color = color_list[color_ind]
        color_ind += 1
        if plotdata:
            name, marker = nice_names(plotdata[0])
            miny, they, thez = plot(plotdata, marker, name, miny, return_y=True, color=color)
            theloc = None
            if text_ind is not None:
                theloc = text_loc[text_ind]
                text_ind += 1
            fitvals.append(
                fit_order(plotdata, they, thez, None, color, text_loc=theloc, fontsize=fontsize)
            )
            retdata.append(they)

    ax.set_yscale('log')
    ax.set_ylim(ymin=miny*0.95)
    loc = 0 if loc_override is None else loc_override
    ax.legend(loc=loc, numpoints=1, fontsize=10)
    # add some text for labels, title and axes ticks
    ax.set_ylabel('Mean evaluation time / condition (ms)')
    #ax.set_title('GPU Jacobian Evaluation Performance for {} mechanism'.format(thedir))
    ax.set_xlabel('Number of Reactions')
    #ax.legend(loc=0)
    plt.savefig('{}_norm.pdf'.format(desc))
    plt.close()

    return fitvals, retdata
コード例 #4
0
ファイル: gpu_scaling_comp.py プロジェクト: goldmanm/pyJac
        }
        if hollow:
            argdict['markerfacecolor'] = 'None'
            argdict['label'] += ' (smem)'
        if plot_std:
            argdict['yerr'] = thez
        if plot_std:
            line = plt.errorbar(**argdict)
        else:
            line = plt.plot(**argdict)
    return miny


legend_markers = ['o', 'v', 's', '>']

data = get_data()
plotdata = [
    x for x in data if x.lang == 'cuda' and not x.cache_opt and not x.smem
    and not x.finite_difference
]

fig, ax = plt.subplots()
miny = None

miny = plot_scaling(plotdata, legend_markers, miny)
ax.set_yscale('log')
ax.set_xscale('log')
ax.set_ylim(ymin=miny * 0.95)
ax.legend(loc=0, numpoints=1)
# add some text for labels, title and axes ticks
ax.set_ylabel('Mean evaluation time')
コード例 #5
0
def fullscale_comp(lang, plot_std=True, homedir=None,
                   cache_opt_default=False,
                   smem_default=False,
                   loc_override=None,
                   text_loc=None,
                   color_list=['b', 'g', 'r', 'k']
                   ):
    if lang == 'c':
        langs = ['c', 'tchem']
        desc = 'cpu'
        smem_default = False
    elif lang == 'cuda':
        langs = ['cuda']
        desc = 'gpu'
    else:
        raise Exception('unknown lang {}'.format(lang))

    def thefilter(x):
        return (x.cache_opt==cache_opt_default and
                x.smem == smem_default and
                x.lang in langs
                )

    fit_vals = []
    data = get_data(homedir)
    data = [x for x in data if thefilter(x)]
    data = get_fullscale(data)
    if not len(data):
        print('no data found... exiting')
        sys.exit(-1)

    fig, ax = plt.subplots()

    linestyle = ''

    fitvals = []
    retdata = []
    color_ind = 0
    text_ind = None
    if text_loc:
        text_ind = 0

    # finite difference
    plotdata = [x for x in data if x.finite_difference]
    if plotdata:
        color = color_list[color_ind]
        color_ind += 1
        (minx, miny), y_vals, err_vals = plot(plotdata, FD_marker,
                                              'Finite Difference',
                                              return_y=True, color=color
                                              )
        theloc = None
        if text_ind is not None:
            theloc = text_loc[text_ind]
            text_ind += 1
        fitvals.append(
            fit_order(plotdata, y_vals, err_vals, color=color, text_loc=theloc)
            )
        retdata.append(y_vals)

    for lang in langs:
        plotdata = [x for x in data if not x.finite_difference
                    and x.lang == lang
                    ]
        color = color_list[color_ind]
        color_ind += 1
        if plotdata:
            name, marker = nice_names(plotdata[0])
            (minx, miny), y_vals, err_vals = plot(plotdata, marker, name,
                                                  minx, miny,
                                                  return_y=True, color=color
                                                  )
            theloc = None
            if text_ind is not None:
                theloc = text_loc[text_ind]
                text_ind += 1
            fitvals.append(
                fit_order(plotdata, y_vals, err_vals, None, color, text_loc=theloc)
                )
            retdata.append(y_vals)

    ax.set_yscale('log')
    ax.set_ylim(ymin=miny*0.85)
    ax.set_xlim(xmin=0)
    loc = 0 if loc_override is None else loc_override
    ax.legend(loc=loc, numpoints=1, fontsize=font_size,
              shadow=True, fancybox=True
              )
    # add some text for labels, title and axes ticks
    ax.set_ylabel('Mean evaluation time / condition (ms)', fontsize=font_size)
    ax.set_xlabel('Number of Reactions', fontsize=font_size)

    if homedir is None:
        homedir = os.path.join(sys.path[0], '../')
        homedir = os.path.realpath(homedir)
    d = os.path.join(homedir, 'figures')

    pp = PdfPages(os.path.join(d, '{}_performance_comparison.pdf'.format(desc)))
    pp.savefig()
    pp.close()

    plt.close()

    return fitvals, retdata