Exemple #1
0
def main():
    ccbench.controller()  # handle CLI options

    #handle default/cli args app
    app_bin = BASE_DIR + APP
    input_filename = BASE_DIR + DEFAULT_INPUT_NAME
    report_filename = REPORT_DIR + ccbench.getReportFileName(APP, REPORT_DIR)

    # 1. Parse inputs.txt file
    if (not ccbench.NORUN):
        inputs = ccbench.parseInputFile(input_filename, input_variables,
                                        ccbench.INPUT_TYPE)
        NumDataPointsPerSet = 0

        # Build up the arguments list for each invocation of the benchmark.
        # This is done here, instead of in ccbench.py, because this is custom to each app.
        app_args_list = []
        for num_threads in inputs["NumThreads"]:
            for num_requests in inputs["NumRequests"]:
                for app_size in inputs["AppSize"]:
                    NumDataPointsPerSet += num_threads  #each thread spawns a new entry in band_req_mc!
                    app_args_list.append(str(num_threads) + " " + str(num_requests) + " " +  str(app_size) \
                        + " " + str(inputs["NumIterations"][0]))

        inputs["NumDataPointsPerSet"] = []
        inputs["NumDataPointsPerSet"].append(str(NumDataPointsPerSet))

    # 2. Execute the benchmark and read the report file
    if (not ccbench.NORUN):
        ccbench.runBenchmark(app_bin, app_args_list, inputs, input_variables,
                             report_filename)

    # 3. Extract Data
    data = ccbench.readReportFile(report_filename, variables)
    inputs = ccbench.parseReportFileForInputs(report_filename, input_variables)

    # 4. Plot the Data
    #print data

    if NOPLOT:
        return

    fig = plt.figure(figsize=(9, 5.5))
    p2 = fig.add_subplot(1, 2, 2)
    p1 = fig.add_subplot(1, 2, 1)

    print "Plotting time..."
    num_datapoints = int(data["NumDataPointsPerSet"][0])

    # let's convert "appsizearg(#elm)" to "appsize(KB)"
    for i in range(len(data["AppSize"])):
        data["AppSize"][i] = str(float(data["AppSize"][i]) * 4 / 1024)

    # deal with ticks
#    xtick_range = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,4096*2,16384] #for KB
#    xtick_names = ['1 kB','2 kB','4 kB','8 kB','16 kB','32 kB','64 kB','128 kB','256 kB','512 kB','1 MB','2 MB','4 MB','8 MB','16 MB'] #for KB
    xtick_range = [1, 4, 16, 64, 256, 1024, 4096, 16384]  #for KB
    xtick_names = [
        '1 kB', '4 kB', '16 kB', '64 kB', '256 kB', '1 MB', '4 MB', '16 MB'
    ]

    xmin, xmax = plt.xlim()
    print "xmax = %d" % (xmax)

    #    if (xmax >= 1024*32):
    #    xtick_range = [1,2,4,8,16,32,64, 128,256, 512,1024,2048,4096,4096*2, 16384,16384*2,16384*4,1024*128]
    #    xtick_names = ['1 kB','2 kB','4 kB','8 kB','16 kB','32 kB','64 kB','128 kB','256 kB','512 kB','1 MB','2 MB','4 MB','8 MB','16 MB','32 MB','64 MB','128 MB'] #for KB
    xtick_range = [1, 4, 16, 64, 256, 1024, 4096, 16384, 1024 * 64]  #for KB
    xtick_names = [
        '1 kB', '4 kB', '16 kB', '64 kB', '256 kB', '1 MB', '4 MB', '16 MB',
        '64 MB'
    ]
    plt.xlim((0.5, 1024 * 128))

    #    fig.subplots_adjust(top=0.95, bottom=0.12, left=0.07, right=0.90,wspace=0, hspace=0)
    fig.subplots_adjust(top=0.95,
                        bottom=0.12,
                        left=0.07,
                        right=0.90,
                        wspace=0.13,
                        hspace=0)

    c_counter = 0
    colors = ('b', 'g', 'r', 'c', 'm', 'y', 'k', 'b', 'g', 'r', 'c', 'm')
    line_styles = ('-.', ':', '-.', ':')

    for num_threads in inputs["NumThreads"]:
        #x_array = [int(s) for s in array ]
        #        print "NumThreads, graphing NumThreads: " + str(num_threads)
        l_counter = 0
        color = colors[c_counter % len(colors)]
        c_counter += 1
        # plot a line for each tid in th eexperiment NumThreads
        for num_req in inputs["NumRequests"]:
            line_style = line_styles[l_counter % len(line_styles)]
            l_counter += 1
            for tid in range(num_threads):

                x_array = []
                band_array = []
                aggr_array = []

                for idx in range(len(data["AppSize"])):
                    #                print "   looking at idx: " + str(idx) + " in data[apsize]"
                    if (int(data["ThreadID"][idx]) == int(tid)) and (int(
                            data["NumThreads"][idx]) == num_threads) and (int(
                                data["NumRequests"][idx]) == num_req):
                        #                    print "    appending " + data["AppSize"][idx] + " For ThreadID: " + data["ThreadID"][idx]
                        x_array.append(data["AppSize"][idx])
                        aggr_array.append(data["AggregateBandwidth"][idx])
                        band_array.append(data["Bandwidth"][idx])

                p1.plot(
                    x_array,
                    band_array,
                    #                    linestyle="--",
                    linestyle=line_style,
                    #                    linestyle=" ",
                    marker='.',
                    color=color)

                p2.plot(
                    x_array,
                    aggr_array,
                    #                    linestyle="--",
                    linestyle=line_style,
                    #                    linestyle=" ",
                    marker='.',
                    color=color)

    p1.set_xscale('log')
    p2.set_xscale('log')

    plt.ylabel(data["BandwidthUnits"][0])
    plt.xlabel('Per Thread Working Set')
    ymin, ymax = plt.ylim()
    plt.ylim((0.0, ymax))
    plt.xlim((0.5, 16384))

    p1.xaxis.set_major_locator(plt.NullLocator())
    p1.xaxis.set_minor_locator(plt.NullLocator())
    p2.xaxis.set_major_locator(plt.NullLocator())
    p2.xaxis.set_minor_locator(plt.NullLocator())

    plt.xticks(xtick_range, xtick_names, rotation='-30', size='small')
    p2 = fig.add_subplot(1, 2, 2)
    plt.xticks(xtick_range, xtick_names, rotation='-30', size='small')

    # resize the per thread bandwidth...(to match aggregate bandwidth)
    #p2 = fig.add_subplot(1,2,2)
    #(ylow,yhigh) = plt.ylim()
    #p1 = fig.add_subplot(1,2,1)
    #plt.ylim((ylow,yhigh))

    # plot processor-specific info
    p1 = fig.add_subplot(1, 2, 1)
    (ylow, yhigh) = plt.ylim()
    yhigh = 0.95 * yhigh
    ylow = 0.95 * yhigh
    ccprocstats.plotCacheSizeLines(plt, p1, ccbench.PROCESSOR, ylow, yhigh)

    p2 = fig.add_subplot(1, 2, 2)
    plt.xlabel('Per Thread Working Set')
    (ylow, yhigh) = plt.ylim()
    yhigh = 0.95 * yhigh
    ylow = 0.95 * yhigh
    ccprocstats.plotCacheSizeLines(plt, p2, ccbench.PROCESSOR, ylow, yhigh)

    p2 = fig.add_subplot(1, 2, 2)
    plt.title("Aggregate Bandwidth" + r'', fontstyle='italic')
    p1 = fig.add_subplot(1, 2, 1)
    plt.title("Per Thread Bandwidth" + r'', fontstyle='italic')

    # legend
    colors = ('b', 'g', 'r', 'c', 'm', 'y', 'k', 'b', 'g', 'r', 'c', 'm')
    legend_sz = len(inputs["NumThreads"])
    lines = []

    for i in (range(legend_sz)):
        lines.append(
            plt.Line2D([0, 10], [0, 10],
                       linewidth=3,
                       color=colors[legend_sz - 1 - i],
                       linestyle='-'))

    args = range(legend_sz)
    for i in (range(legend_sz)):
        args[legend_sz - 1 - i] = str(inputs["NumThreads"][i]) + " Threads"
#        args[legend_sz - 1 - i] = "{Thds:" + str(inputs["NumThreads"][i]) + "}" #+ ", Reqs:" + input["NumRequests"][((i)*num_datapoints)] + "}"

    p2 = fig.add_subplot(1, 2, 2)
    plt.legend(lines,
               args,
               'best',
               title="Num of Threads",
               bbox_to_anchor=(0.70, 0.9))

    (ylow, yhigh) = plt.ylim()
    (xmin, xmax) = plt.xlim()
    p2.text(xmax,
            0.9 * yhigh,
            "%d requests / thread" % (inputs["NumRequests"][0]),
            horizontalalignment='center',
            verticalalignment='center',
            size='x-small')

    if (ccbench.PLOT_FILENAME == "none"):
        filename = PLOT_DIR + ccbench.generatePlotFileName(APP)
    else:
        # Pull out the filename path from the full path.
        # This allows us to pull out the requested filename from the path presented
        # (since we always write reports to the report directory, etc.). However, it
        # allows the user to use tab-completion to specify the exact reportfile he
        # wants to use.
        filename = PLOT_DIR + os.path.basename(ccbench.PLOT_FILENAME)
        filename = os.path.splitext(filename)[0]

    plt.savefig(filename)
    print "Used report filename             : " + report_filename
    print "Finished Plotting, saved as file : " + filename + ".pdf"
Exemple #2
0
def main():
    # handle CLI options
    ccbench.controller()

    #handle default/cli args app
    app_bin = BASE_DIR + APP
    input_filename = BASE_DIR + DEFAULT_INPUT_NAME
    report_filename = REPORT_DIR + ccbench.getReportFileName(APP, REPORT_DIR)

    # 1. Parse inputs.txt file.
    if (not ccbench.NORUN):
        inputs = ccbench.parseInputFile(input_filename, variables,
                                        ccbench.INPUT_TYPE)
        inputs["NumDataPointsPerSet"] = []
        inputs["NumDataPointsPerSet"].append(str(len(inputs["AppSize"])))

        # Build up the arguments list for each invocation of the benchmark.
        # This is done here, instead of in ccbench.py, because this is custom to each app.
        app_args_list = []
        for run_type in inputs["RunType"]:
            for app_size in inputs["AppSize"]:
                app_args_list.append(str(app_size) + " " \
                    + str(inputs["NumIterations"][0]) + " " +str(run_type))

    # 2. Execute the benchmark and write to the report file.
    if (not ccbench.NORUN):
        ccbench.runBenchmark(app_bin, app_args_list, inputs, input_variables,
                             report_filename)

    # 3. Extract Data from the report file.
    data = ccbench.readReportFile(report_filename, variables)

    # 4. Plot the Data
    #print data

    if NOPLOT:
        return

    if PLOT_POSTER:
        fig = plt.figure(figsize=(5, 3.5))
        font = {  #'family' : 'normal',
            #'weight' : 'bold',
            'size': 8
        }
        matplotlib.rc('font', **font)
        fig.subplots_adjust(top=0.94,
                            bottom=0.14,
                            left=0.1,
                            right=0.96,
                            wspace=0,
                            hspace=0)
    else:
        fig = plt.figure(figsize=(9, 5.5))
        fig.subplots_adjust(top=0.95,
                            bottom=0.12,
                            left=0.07,
                            right=0.97,
                            wspace=0,
                            hspace=0)

    p1 = fig.add_subplot(1, 1, 1)

    print "Plotting time..."
    num_datapoints = int(data["NumDataPointsPerSet"][0])

    # let's convert "appsizearg(#elm)" to "appsize(KB)"
    for i in range(len(data["AppSize"])):
        data["AppSize"][i] = str(float(data["AppSize"][i]) * 4 / 1024)

    for i in range(len(data["AppSize"]) / num_datapoints):
        srt_idx = i * num_datapoints
        end_idx = (i + 1) * num_datapoints
        p1.plot(data["AppSize"][srt_idx:end_idx],
                data["Time"][srt_idx:end_idx],
                linestyle='--',
                marker='.')

    p1.set_xscale('log')
    p1.set_yscale('log')
    plt.ylabel(data["TimeUnits"][0])
    plt.xlabel('Array Size')
    plt.ylim((1, 320))

    xmin, xmax = plt.xlim()
    plt.xlim((0.5, 1024 * 64))

    # deal with ticks
    xtick_range = [
        1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 4096 * 2,
        16384, 16384 * 2, 16384 * 4
    ]
    xtick_names = [
        '1 kB', '2 kB', '4 kB', '8 kB', '16 kB', '32 kB', '64 kB', '128 kB',
        '256 kB', '512 kB', '1 MB', '2 MB', '4 MB', '8 MB', '16 MB', '32 MB',
        '64 MB'
    ]  #for KB
    ytick_range = [1, 2, 4, 8, 16, 32, 64, 128, 256]  # in ns / iteration
    ytick_names = ['1', '2', '4', '8', '16', '32', '64', '128', '256']

    if (xmax > 1024 * 65):
        xtick_range = [
            1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 4096 * 2,
            16384, 16384 * 2, 16384 * 4, 1024 * 128
        ]
        xtick_names = [
            '1 kB', '2 kB', '4 kB', '8 kB', '16 kB', '32 kB', '64 kB',
            '128 kB', '256 kB', '512 kB', '1 MB', '2 MB', '4 MB', '8 MB',
            '16 MB', '32 MB', '64 MB', '128 MB'
        ]  #for KB
        plt.xlim((0.5, 1024 * 128))

    if (xmax > 1024 * 128):
        xtick_range = [
            1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 4096 * 2,
            16384, 16384 * 2, 16384 * 4, 1024 * 128, 1024 * 256
        ]
        xtick_names = [
            '1 kB', '2 kB', '4 kB', '8 kB', '16 kB', '32 kB', '64 kB',
            '128 kB', '256 kB', '512 kB', '1 MB', '2 MB', '4 MB', '8 MB',
            '16 MB', '32 MB', '64 MB', '128 MB', '256 MB'
        ]  #for KB
        plt.xlim((0.5, 1024 * 256))

    p1.xaxis.set_major_locator(plt.NullLocator())
    p1.xaxis.set_minor_locator(plt.NullLocator())
    p1.yaxis.set_major_locator(plt.NullLocator())
    p1.yaxis.set_minor_locator(plt.NullLocator())
    plt.xticks(xtick_range, xtick_names, rotation='-30', size='small')
    plt.yticks(ytick_range, ytick_names)

    # annotate the graph with pretty cache size lines and info!
    ylow = 160
    yhigh = 200
    ccprocstats.plotCacheSizeLines(plt, p1, ccbench.PROCESSOR, ylow, yhigh)

    # customize figure title and other doodads based on the processor the test was run on
    print " "
    if (ccbench.PROCESSOR == "merom"):
        outputAccessLatency(data, 8, "L1      ", 2.33)
        outputAccessLatency(data, 64, "L2      ", 2.33)
        outputAccessLatency(data, 16384, "Off-chip", 2.33)
    if (ccbench.PROCESSOR == "ivybridge"):
        outputAccessLatency(data, 8, "L1      ", 2.3)
        outputAccessLatency(data, 128, "L2      ", 2.3)
        outputAccessLatency(data, 3072, "L3      ", 2.3)
        outputAccessLatency(data, 16384, "Off-chip", 2.3)
    elif (ccbench.PROCESSOR == "cuda1"):
        outputAccessLatency(data, 8, "L1      ", 2.4)
        outputAccessLatency(data, 64, "L2      ", 2.4)
        outputAccessLatency(data, 16384, "Off-chip", 2.4)
    elif (ccbench.PROCESSOR == "tegra2"):
        outputAccessLatency(data, 8, "L1      ", 0.4)
        #umnown
        outputAccessLatency(data, 64, "L2      ", 0.4)
        outputAccessLatency(data, 16384, "Off-chip", 0.4)
    elif (ccbench.PROCESSOR == "tilera"):
        outputAccessLatency(data, 4, "L1      ", 0.7)
        outputAccessLatency(data, 32, "L2      ", 0.7)
        outputAccessLatency(data, 1024, "L3*     ", 0.7)
        outputAccessLatency(data, 16384, "Off-chip", 0.7)
    elif (ccbench.PROCESSOR == "tilera-l3"):  #unknown
        outputAccessLatency(data, 4, "L1      ", 0.7)
        outputAccessLatency(data, 32, "L2      ", 0.7)
        outputAccessLatency(data, 1024, "L3      ", 0.7)
        outputAccessLatency(data, 16384, "Off-chip", 0.7)
    elif (ccbench.PROCESSOR == "arrandale"):
        outputAccessLatency(data, 8, "L1      ", 3.0)
        #unknwno
        outputAccessLatency(data, 64, "L2      ", 3.0)
        outputAccessLatency(data, 1024, "L3      ", 3.0)
        outputAccessLatency(data, 16384, "Off-chip", 3.0)
    elif (ccbench.PROCESSOR == "bloomfield"):
        outputAccessLatency(data, 8, "L1      ", 3.4)
        #unknown
        outputAccessLatency(data, 64, "L2      ", 3.4)
        outputAccessLatency(data, 1024, "L3      ", 3.4)
        outputAccessLatency(data, 16384, "Off-chip", 3.4)
    elif (ccbench.PROCESSOR == "emerald"):
        outputAccessLatency(data, 8, "L1      ", 2.27)
        outputAccessLatency(data, 64, "L2      ", 2.27)
        outputAccessLatency(data, 1024, "L3      ", 2.27)
        outputAccessLatency(data, 16384, "L3      ", 2.27)
        outputAccessLatency(data, 128 * 1024, "Off-chip", 2.27)
    elif (ccbench.PROCESSOR == "boxboro"
          ):  #boxboro.millennium machine (westmere-ex)
        outputAccessLatency(data, 8, "L1      ", 2.27)
        outputAccessLatency(data, 64, "L2      ", 2.27)
        outputAccessLatency(data, 1024, "L3      ", 2.27)
        outputAccessLatency(data, 65536, "Off-chip", 2.27)
        outputAccessLatency(data, 262144, "DRAM    ", 2.27)
    elif (ccbench.PROCESSOR == "bridge"):
        outputAccessLatency(data, 8, "L1      ", 3.4)
        outputAccessLatency(data, 64, "L2      ", 3.4)
        outputAccessLatency(data, 1024, "L3      ", 3.4)
        outputAccessLatency(data, 262144, "DRAM    ", 3.4)
    else:
        plt.title("Cache Hierarchy" + r'', fontstyle='italic')
        print "  Unknown processor - cycle count is assuming a 1 GHz clock"
        outputAccessLatency(data, 8, "", 1.0)
        outputAccessLatency(data, 64, "", 1.0)
        outputAccessLatency(data, 1024, "", 1.0)
        outputAccessLatency(data, 16384, "", 1.0)
    print " "

    if (ccbench.PLOT_FILENAME == "none"):
        filename = PLOT_DIR + ccbench.generatePlotFileName(APP)
    else:
        # Pull out the filename path from the full path.
        # This allows us to pull out the requested filename from the path presented
        # (since we always write reports to the report directory, etc.). However, it
        # allows the user to use tab-completion to specify the exact reportfile he
        # wants to use.
        filename = PLOT_DIR + os.path.basename(ccbench.PLOT_FILENAME)
        filename = os.path.splitext(filename)[0]

    plt.savefig(filename)
    print "Used report filename             : " + report_filename
    print "Finished Plotting, saved as file : " + filename + ".pdf"
Exemple #3
0
def main():
    # handle CLI options
    ccbench.controller()  

    #handle default/cli args app
    app_bin = BASE_DIR + APP
    input_filename = BASE_DIR +  DEFAULT_INPUT_NAME
    report_filename = REPORT_DIR + ccbench.getReportFileName(APP, REPORT_DIR)   
    
    # 1. Parse inputs.txt file.
    if (not ccbench.NORUN):
        inputs = ccbench.parseInputFile(input_filename, variables, ccbench.INPUT_TYPE)
        inputs["NumDataPointsPerSet"] = []
        inputs["NumDataPointsPerSet"].append(str(len(inputs["AppSize"])))

        # Build up the arguments list for each invocation of the benchmark.
        # This is done here, instead of in ccbench.py, because this is custom to each app.
        app_args_list = []
        for app_size in inputs["AppSize"]:
            app_args_list.append(str(app_size) + " " + str(inputs["NumIterations"][0]))


    # 2. Execute the benchmark and write to the report file.
    if (not ccbench.NORUN):
        ccbench.runBenchmark(app_bin, app_args_list, inputs, input_variables, report_filename)
        
    
    # 3. Extract Data from the report file.
    data = ccbench.readReportFile(report_filename, variables)

    
    # 4. Plot the Data
    #print data
    
    if NOPLOT:
        return

     
    if PLOT_PPT:
        font = {#'family' : 'normal',
            #'weight' : 'bold',
            'size'   : 30}
        matplotlib.rc('font', **font)
        fig.subplots_adjust(top=0.90, bottom=0.25, left=0.18, right=0.97,wspace=0, hspace=0)
        xtick_range = [1,32,256, 4096*2,16384*4]
        xtick_names = ['1 kB','32 kB','256 kB','8 MB','64 MB'] #for KB
    elif PLOT_POSTER:
        fig = plt.figure(figsize=(5,3.5))
        font = {#'family' : 'normal',
            #'weight' : 'bold',
            'size'   : 8}
        matplotlib.rc('font', **font)
        fig.subplots_adjust(top=0.94, bottom=0.14, left=0.1, right=0.96,wspace=0, hspace=0)
    else:
        fig = plt.figure(figsize=(9,5.5))
        fig.subplots_adjust(top=0.95, bottom=0.12, left=0.07, right=0.97,wspace=0, hspace=0)
        fig.subplots_adjust(top=0.95, bottom=0.12, left=0.1, right=0.97,wspace=0, hspace=0)
        

    p1 = fig.add_subplot(1,1,1)

    print "Plotting time..."
    num_datapoints = int(data["NumDataPointsPerSet"][0])
 
    # let's convert "appsizearg(#elm)" to "appsize(KB)"
    for i in range(len(data["AppSize"])):
        data["AppSize"][i] = str(float(data["AppSize"][i]) * 4 / 1024)
    
    
    for i in range(len(data["AppSize"])/num_datapoints):
        srt_idx = i*num_datapoints
        end_idx = (i+1)*num_datapoints
        p1.plot(
            data["AppSize"][srt_idx:end_idx],
            data["Output"][srt_idx:end_idx],
            linestyle='--',
            marker='.'#,
#            linewidth=2
            )
    
    p1.set_xscale('log')
    p1.set_yscale('log')
    plt.ylabel(data["Units"][0])
    plt.xlabel('Array Size')
#    plt.ylim((1, 50000))
    if (ccbench.PROCESSOR == "tilera-l3"):
        plt.ylim((100, 10000))
    elif (ccbench.PROCESSOR == "tilera"):
        plt.ylim((100, 10000))
    else:
        plt.ylim((1000, 100000))

    plt.xlim((0.5, 16384*4))
   
    if not PLOT_PPT:
        # deal with ticks
        xtick_range = [1,2,4,8,16,32,64, 128,256, 512,1024,2048,4096,4096*2, 16384,16384*2,16384*4]
        xtick_names = ['1 kB','2 kB','4 kB','8 kB','16 kB','32 kB','64 kB','128 kB','256 kB','512 kB','1 MB','2 MB','4 MB','8 MB','16 MB','32 MB','64 MB'] #for KB
#    ytick_range = [1,10,100,,1000,10000]
#    ytick_names = ['1','10','100','1e3','10e3']

    p1.xaxis.set_major_locator( plt.NullLocator() )
    p1.xaxis.set_minor_locator( plt.NullLocator() )
#    p1.yaxis.set_major_locator( plt.NullLocator() )
#    p1.yaxis.set_minor_locator( plt.NullLocator() )
    plt.xticks(
        xtick_range,
        xtick_names,
        rotation='-30',
        size='small' 
        )
#    plt.yticks(ytick_range,ytick_names)
    

    (ymin, ymax) = plt.ylim()

    print "ymax=%d log(ymax) = %f, " % (ymax, np.log(ymax))
#    print "log(7) = %f, 2^3 = 8 (%f) " % (np.log(7), np.exp(2))
    yvalue_top = np.exp2((np.log2(ymax) + np.log2(ymin))*0.42)
    yvalue_bot = np.exp2((np.log2(ymax) + np.log2(ymin))*0.40) 
#    yvalue_top = ymax*0.95 #np.exp(np.log(ymax) + np.log(ymin)/(2))
#    yvalue_bot = yvalue_top*0.95 #np.exp(np.log(ymax) + np.log(ymin)/(2)) 
    ccprocstats.plotCacheSizeLines(plt, p1, ccbench.PROCESSOR, yvalue_bot, yvalue_top)

    
    
    if (ccbench.PLOT_FILENAME == "none"):
        filename = ccbench.generatePlotFileName(APP)
    else:
        filename = PLOT_DIR + os.path.basename(ccbench.PLOT_FILENAME)
        filename = os.path.splitext(filename)[0]

    plt.savefig(filename)
    print "Used report filename             : " + report_filename 
    print "Finished Plotting, saved as file : " + filename + ".pdf"
Exemple #4
0
def main(args=None, report_dir=None):
    global REPORT_DIR
    global PLOT_DIR
    # handle CLI options
    if (report_dir != None):
        REPORT_DIR = report_dir
        PLOT_DIR = report_dir
    ccbench.controller(args)  

    #handle default/cli args app
    app_bin = BASE_DIR + APP
    #input_filename = BASE_DIR +  DEFAULT_INPUT_NAME
    report_filename = REPORT_DIR + ccbench.getReportFileName(APP, REPORT_DIR)   
    report_csv_filename = REPORT_DIR + ccbench.getReportFileName(APP, REPORT_DIR, ".csv")
    # 1. Parse inputs.txt file.
    # Build up the arguments list for each invocation of the benchmark.
    # This is done here, instead of in ccbench.py, because this is custom to each app.
    app_args_list = []
    if (ccbench.CONFIG != 'none'):
        ccbench.parseConfigFile(APP)

    app_args_list.append(ccbench.SIZE + " " + ccbench.MIN_RUN_TIME)#ccbench.ITERATIONS)



    # 2. Execute the benchmark and write to the report file.
    ccbench.runBenchmark(app_bin, app_args_list, report_filename)
        
    # 3. Extract Data from the report file.
    data = ccbench.readReportFile(report_filename, variables)
    
    # 4. Plot the Data
    #print data
    if (not ccbench.NOPLOT):
        if PLOT_POSTER:
            fig = plt.figure(figsize=(5,3.5))
            font = {#'family' : 'normal',
                #'weight' : 'bold',
                'size'   : 8}
            matplotlib.rc('font', **font)
            fig.subplots_adjust(top=0.94, bottom=0.14, left=0.1, right=0.96,wspace=0, hspace=0)
        else:
            fig = plt.figure(figsize=(9,5.5))
            fig.subplots_adjust(top=0.95, bottom=0.12, left=0.07, right=0.97,wspace=0, hspace=0)
        
        p1 = fig.add_subplot(1,1,1)

        print("Plotting time...")

    sets = collections.OrderedDict()
    if  (ccbench.NOPLOT):
        csv_file = open(report_csv_filename, "a+")
        header = "totalTime"
        data_list = []

    for i in range(len(data["thread"])):
        thread = data["thread"][i]
        if thread in sets:
            sets[thread][0].append(data["totalTime"][i])
            sets[thread][1].append(data["rate"][i])
        else:
            sets[thread] = [[data["totalTime"][i]],[data["rate"][i]]]

    for key, value in sets.items():
        if  (ccbench.NOPLOT):
            header += ",{}".format(key)
            for i in range(len(value[0])):
                data_list.append(value[0][i] + "," + (","*int(key)) + value[1][i] + ("," *(len(sets)-1 - int(key)))+"\n")
        else:
            plot_label = 'Thread ' + key
            p1.plot(
                [float(i) for i in value[0]],
                [float(i) for i in value[1]],
                label= plot_label
            )
    if (ccbench.NOPLOT):
        csv_file.write(header+"\n")
        csv_file.writelines(data_list)
        csv_file.close()
        print("Saved data in CSV -> " + report_csv_filename)
    else:
        plt.legend(loc='upper left')
        plt.ylabel("rate (MB/s)")
        plt.xlabel('Time (s)')
        
    
        #ytick_range = [1,2,4,8,16,32,64,128,256] # in ns / iteration
        #ytick_names = ['1','2','4','8','16','32','64','128','256']
        
        #p1.yaxis.set_major_locator( plt.NullLocator() )
        #p1.yaxis.set_minor_locator( plt.NullLocator() )
        #plt.yticks(ytick_range,ytick_names)
        

        if (ccbench.PLOT_FILENAME == "none"):
            filename = PLOT_DIR + ccbench.generatePlotFileName(APP)
        else:
            # Pull out the filename path from the full path.
            # This allows us to pull out the requested filename from the path presented
            # (since we always write reports to the report directory, etc.). However, it
            # allows the user to use tab-completion to specify the exact reportfile he
            # wants to use.
            filename = PLOT_DIR + os.path.basename(ccbench.PLOT_FILENAME)
            filename = os.path.splitext(filename)[0]
            
        plt.savefig(filename)
        print( "Used report filename             : " + report_filename)
        print("Finished Plotting, saved as file : " + filename + ".pdf")
Exemple #5
0
def main():
    # handle CLI options
    ccbench.controller()  

    #handle default/cli args app
    app_bin = BASE_DIR + APP
    input_filename = BASE_DIR +  DEFAULT_INPUT_NAME
    report_filename = REPORT_DIR + ccbench.getReportFileName(APP, REPORT_DIR)   
   
    # 1. Parse inputs.txt file.
    if (not ccbench.NORUN):
        inputs = ccbench.parseInputFile(input_filename, variables, ccbench.INPUT_TYPE)
        inputs["NumDataPointsPerSet"] = []
        inputs["NumDataPointsPerSet"].append(str(len(inputs["AppSize"])))

        # Build up the arguments list for each invocation of the benchmark.
        # This is done here, instead of in ccbench.py, because this is custom to each app.
        app_args_list = []
        for run_type in inputs["RunType"]: 
            for app_size in inputs["AppSize"]:
                app_args_list.append(str(app_size) + " " \
                    + str(inputs["NumIterations"][0]) + " " +str(run_type))


    # 2. Execute the benchmark and write to the report file.
    if (not ccbench.NORUN):
        ccbench.runBenchmark(app_bin, app_args_list, inputs, input_variables, report_filename)
        
    
    # 3. Extract Data from the report file.
    data = ccbench.readReportFile(report_filename, variables)

    
    # 4. Plot the Data
    #print data
    
    if NOPLOT:
        return

    if PLOT_POSTER:
        fig = plt.figure(figsize=(5,3.5))
        font = {#'family' : 'normal',
            #'weight' : 'bold',
            'size'   : 8}
        matplotlib.rc('font', **font)
        fig.subplots_adjust(top=0.94, bottom=0.14, left=0.1, right=0.96,wspace=0, hspace=0)
    else:
        fig = plt.figure(figsize=(9,5.5))
        fig.subplots_adjust(top=0.95, bottom=0.12, left=0.07, right=0.97,wspace=0, hspace=0)
    
    p1 = fig.add_subplot(1,1,1)

    print "Plotting time..."
    num_datapoints = int(data["NumDataPointsPerSet"][0])
 
    # let's convert "appsizearg(#elm)" to "appsize(KB)"
    for i in range(len(data["AppSize"])):
        data["AppSize"][i] = str(float(data["AppSize"][i]) * 4 / 1024)
    
    
    for i in range(len(data["AppSize"])/num_datapoints):
        srt_idx = i*num_datapoints
        end_idx = (i+1)*num_datapoints
        p1.plot(
            data["AppSize"][srt_idx:end_idx],
            data["Time"][srt_idx:end_idx],
            linestyle='--',
            marker='.'
            )
    
    p1.set_xscale('log')
    p1.set_yscale('log')
    plt.ylabel(data["TimeUnits"][0])
    plt.xlabel('Array Size')
    plt.ylim((1, 320))
    
    xmin,xmax=plt.xlim()
    plt.xlim((0.5, 1024*64))
    
    # deal with ticks
    xtick_range = [1,2,4,8,16,32,64, 128,256, 512,1024,2048,4096,4096*2, 16384,16384*2,16384*4]
    xtick_names = ['1 kB','2 kB','4 kB','8 kB','16 kB','32 kB','64 kB','128 kB','256 kB','512 kB','1 MB','2 MB','4 MB','8 MB','16 MB','32 MB','64 MB'] #for KB
    ytick_range = [1,2,4,8,16,32,64,128,256] # in ns / iteration
    ytick_names = ['1','2','4','8','16','32','64','128','256']
                     
    if (xmax > 1024*65):
        xtick_range = [1,2,4,8,16,32,64, 128,256, 512,1024,2048,4096,4096*2, 16384,16384*2,16384*4,1024*128]
        xtick_names = ['1 kB','2 kB','4 kB','8 kB','16 kB','32 kB','64 kB','128 kB','256 kB','512 kB','1 MB','2 MB','4 MB','8 MB','16 MB','32 MB','64 MB','128 MB'] #for KB
        plt.xlim((0.5,1024*128))
                     
    if (xmax > 1024*128):
        xtick_range = [1,2,4,8,16,32,64, 128,256, 512,1024,2048,4096,4096*2, 16384,16384*2,16384*4,1024*128,1024*256]
        xtick_names = ['1 kB','2 kB','4 kB','8 kB','16 kB','32 kB','64 kB','128 kB','256 kB','512 kB','1 MB','2 MB','4 MB','8 MB','16 MB','32 MB','64 MB','128 MB','256 MB'] #for KB
        plt.xlim((0.5,1024*256))



    p1.xaxis.set_major_locator( plt.NullLocator() )
    p1.xaxis.set_minor_locator( plt.NullLocator() )
    p1.yaxis.set_major_locator( plt.NullLocator() )
    p1.yaxis.set_minor_locator( plt.NullLocator() )
    plt.xticks(
        xtick_range,
        xtick_names,
        rotation='-30',
        size='small' 
        )
    plt.yticks(ytick_range,ytick_names)
    
    # annotate the graph with pretty cache size lines and info!
    ylow = 160
    yhigh = 200
    ccprocstats.plotCacheSizeLines(plt, p1, ccbench.PROCESSOR, ylow, yhigh)

    # customize figure title and other doodads based on the processor the test was run on
    print " ";
    if (ccbench.PROCESSOR == "merom"):
        outputAccessLatency(data,     8, "L1      ", 2.33);
        outputAccessLatency(data,    64, "L2      ", 2.33);
        outputAccessLatency(data, 16384, "Off-chip", 2.33);
    if (ccbench.PROCESSOR == "ivybridge"):
        outputAccessLatency(data,     8, "L1      ", 2.3);
        outputAccessLatency(data,   128, "L2      ", 2.3);
        outputAccessLatency(data,  3072, "L3      ", 2.3);
        outputAccessLatency(data, 16384, "Off-chip", 2.3);
    elif (ccbench.PROCESSOR == "cuda1"):
        outputAccessLatency(data,     8, "L1      ", 2.4);
        outputAccessLatency(data,    64, "L2      ", 2.4);
        outputAccessLatency(data, 16384, "Off-chip", 2.4);
    elif (ccbench.PROCESSOR == "tegra2"):
        outputAccessLatency(data,     8, "L1      ", 0.4);  #umnown
        outputAccessLatency(data,    64, "L2      ", 0.4);
        outputAccessLatency(data, 16384, "Off-chip", 0.4);
    elif (ccbench.PROCESSOR == "tilera"):
        outputAccessLatency(data,     4, "L1      ", 0.7);
        outputAccessLatency(data,    32, "L2      ", 0.7);
        outputAccessLatency(data,  1024, "L3*     ", 0.7);
        outputAccessLatency(data, 16384, "Off-chip", 0.7);
    elif (ccbench.PROCESSOR == "tilera-l3"):              #unknown
        outputAccessLatency(data,     4, "L1      ", 0.7);
        outputAccessLatency(data,    32, "L2      ", 0.7);
        outputAccessLatency(data,  1024, "L3      ", 0.7);
        outputAccessLatency(data, 16384, "Off-chip", 0.7);
    elif (ccbench.PROCESSOR == "arrandale"):
        outputAccessLatency(data,     8, "L1      ", 3.0); #unknwno
        outputAccessLatency(data,    64, "L2      ", 3.0);
        outputAccessLatency(data,  1024, "L3      ", 3.0);
        outputAccessLatency(data, 16384, "Off-chip", 3.0);
    elif (ccbench.PROCESSOR == "bloomfield"):
        outputAccessLatency(data,     8, "L1      ", 3.4); #unknown
        outputAccessLatency(data,    64, "L2      ", 3.4);
        outputAccessLatency(data,  1024, "L3      ", 3.4);
        outputAccessLatency(data, 16384, "Off-chip", 3.4);
    elif (ccbench.PROCESSOR == "emerald"):
        outputAccessLatency(data,     8, "L1      ", 2.27);
        outputAccessLatency(data,    64, "L2      ", 2.27);
        outputAccessLatency(data,  1024, "L3      ", 2.27);
        outputAccessLatency(data, 16384, "L3      ", 2.27);
        outputAccessLatency(data, 128*1024, "Off-chip", 2.27);
    elif (ccbench.PROCESSOR == "boxboro"): #boxboro.millennium machine (westmere-ex)
        outputAccessLatency(data,     8, "L1      ", 2.27);
        outputAccessLatency(data,    64, "L2      ", 2.27);
        outputAccessLatency(data,  1024, "L3      ", 2.27);
        outputAccessLatency(data, 65536, "Off-chip", 2.27);
        outputAccessLatency(data,262144, "DRAM    ", 2.27);
    elif (ccbench.PROCESSOR == "bridge"): 
        outputAccessLatency(data,     8, "L1      ", 3.4);
        outputAccessLatency(data,    64, "L2      ", 3.4);
        outputAccessLatency(data,  1024, "L3      ", 3.4);
        outputAccessLatency(data,262144, "DRAM    ", 3.4);
    else:
        plt.title("Cache Hierarchy" + r'', fontstyle='italic')
        print "  Unknown processor - cycle count is assuming a 1 GHz clock"
        outputAccessLatency(data,     8, "", 1.0);
        outputAccessLatency(data,    64, "", 1.0);
        outputAccessLatency(data,  1024, "", 1.0);
        outputAccessLatency(data, 16384, "", 1.0);
    print " ";

    if (ccbench.PLOT_FILENAME == "none"):
        filename = PLOT_DIR + ccbench.generatePlotFileName(APP)
    else:
        # Pull out the filename path from the full path.
        # This allows us to pull out the requested filename from the path presented
        # (since we always write reports to the report directory, etc.). However, it
        # allows the user to use tab-completion to specify the exact reportfile he
        # wants to use.
        filename = PLOT_DIR + os.path.basename(ccbench.PLOT_FILENAME)
        filename = os.path.splitext(filename)[0]
        
    plt.savefig(filename)
    print "Used report filename             : " + report_filename 
    print "Finished Plotting, saved as file : " + filename + ".pdf"
Exemple #6
0
def main():
    ccbench.controller()  # handle CLI options

    #handle default/cli args app
    app_bin = BASE_DIR + APP
    input_filename = BASE_DIR +  DEFAULT_INPUT_NAME
    report_filename = REPORT_DIR + ccbench.getReportFileName(APP, REPORT_DIR)   
    
    # 1. Parse inputs.txt file
    if (not ccbench.NORUN):
        inputs = ccbench.parseInputFile(input_filename, input_variables, ccbench.INPUT_TYPE)
        NumDataPointsPerSet = 0

        # Build up the arguments list for each invocation of the benchmark.
        # This is done here, instead of in ccbench.py, because this is custom to each app.
        app_args_list = []
        for num_threads in inputs["NumThreads"]:
            for num_requests in inputs["NumRequests"]:
                for app_size in inputs["AppSize"]:
                    NumDataPointsPerSet += num_threads #each thread spawns a new entry in band_req_mc!
                    app_args_list.append(str(num_threads) + " " + str(num_requests) + " " +  str(app_size) \
                        + " " + str(inputs["NumIterations"][0]))
    
        inputs["NumDataPointsPerSet"] = []
        inputs["NumDataPointsPerSet"].append(str(NumDataPointsPerSet))
    
    # 2. Execute the benchmark and read the report file
    if (not ccbench.NORUN):
        ccbench.runBenchmark(app_bin, app_args_list, inputs, input_variables, report_filename)
        
    
    # 3. Extract Data
    data = ccbench.readReportFile(report_filename, variables)
    inputs = ccbench.parseReportFileForInputs(report_filename, input_variables)

    
    # 4. Plot the Data
    #print data
    
    if NOPLOT:
        return

    fig = plt.figure(figsize=(9,5.5))
    p2 = fig.add_subplot(1,2,2)
    p1 = fig.add_subplot(1,2,1)

    print "Plotting time..."
    num_datapoints = int(data["NumDataPointsPerSet"][0])
 
    # let's convert "appsizearg(#elm)" to "appsize(KB)"
    for i in range(len(data["AppSize"])):
        data["AppSize"][i] = str(float(data["AppSize"][i]) * 4 / 1024)
    
    # deal with ticks
#    xtick_range = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,4096*2,16384] #for KB
#    xtick_names = ['1 kB','2 kB','4 kB','8 kB','16 kB','32 kB','64 kB','128 kB','256 kB','512 kB','1 MB','2 MB','4 MB','8 MB','16 MB'] #for KB
    xtick_range = [1,4,16,64,256,1024,4096,16384] #for KB
    xtick_names = ['1 kB','4 kB','16 kB','64 kB','256 kB','1 MB','4 MB','16 MB'] 

    xmin,xmax = plt.xlim()
    print "xmax = %d" % (xmax)

#    if (xmax >= 1024*32):
#    xtick_range = [1,2,4,8,16,32,64, 128,256, 512,1024,2048,4096,4096*2, 16384,16384*2,16384*4,1024*128]
#    xtick_names = ['1 kB','2 kB','4 kB','8 kB','16 kB','32 kB','64 kB','128 kB','256 kB','512 kB','1 MB','2 MB','4 MB','8 MB','16 MB','32 MB','64 MB','128 MB'] #for KB
    xtick_range = [1,4,16,64,256,1024,4096,16384, 1024*64] #for KB
    xtick_names = ['1 kB','4 kB','16 kB','64 kB','256 kB','1 MB','4 MB','16 MB', '64 MB']
    plt.xlim((0.5,1024*128))
    
    
#    fig.subplots_adjust(top=0.95, bottom=0.12, left=0.07, right=0.90,wspace=0, hspace=0)
    fig.subplots_adjust(top=0.95, bottom=0.12, left=0.07, right=0.90,wspace=0.13, hspace=0)
         

    c_counter = 0
    colors =('b','g','r','c','m','y','k','b','g','r','c','m')
    line_styles=('-.',':','-.',':')

    for num_threads in inputs["NumThreads"]:
        #x_array = [int(s) for s in array ] 
#        print "NumThreads, graphing NumThreads: " + str(num_threads)
        l_counter = 0
        color      = colors     [c_counter % len(colors)]
        c_counter +=1
        # plot a line for each tid in th eexperiment NumThreads
        for num_req in inputs["NumRequests"]:
            line_style = line_styles[l_counter % len(line_styles)]
            l_counter += 1
            for tid in range(num_threads):

                x_array = []
                band_array = []
                aggr_array = []

                for idx in range(len(data["AppSize"])):
#                print "   looking at idx: " + str(idx) + " in data[apsize]"
                    if (int(data["ThreadID"][idx]) == int(tid)) and (int(data["NumThreads"][idx]) == num_threads) and (int(data["NumRequests"][idx]) == num_req):
#                    print "    appending " + data["AppSize"][idx] + " For ThreadID: " + data["ThreadID"][idx]
                        x_array.append(data["AppSize"][idx])
                        aggr_array.append(data["AggregateBandwidth"][idx])
                        band_array.append(data["Bandwidth"][idx])
                 
                p1.plot(
                    x_array,
                    band_array,
#                    linestyle="--",
                    linestyle=line_style,
#                    linestyle=" ",
                    marker='.',
                    color = color
                    )
                        
                p2.plot(
                    x_array,
                    aggr_array,
#                    linestyle="--",
                    linestyle=line_style,
#                    linestyle=" ",
                    marker='.',
                    color = color
                    )   



    p1.set_xscale('log')
    p2.set_xscale('log')

    plt.ylabel(data["BandwidthUnits"][0])
    plt.xlabel('Per Thread Working Set')
    ymin, ymax = plt.ylim()
    plt.ylim((0.0, ymax))
    plt.xlim((0.5, 16384))

    p1.xaxis.set_major_locator( plt.NullLocator() )
    p1.xaxis.set_minor_locator( plt.NullLocator() )
    p2.xaxis.set_major_locator( plt.NullLocator() )
    p2.xaxis.set_minor_locator( plt.NullLocator() )
     
    plt.xticks(
        xtick_range,
        xtick_names,
        rotation='-30',
        size='small' 
        )
    p2 = fig.add_subplot(1,2,2)
    plt.xticks(
        xtick_range,
        xtick_names,
        rotation='-30',
        size='small' 
        )
 
    # resize the per thread bandwidth...(to match aggregate bandwidth)
    #p2 = fig.add_subplot(1,2,2)
    #(ylow,yhigh) = plt.ylim()
    #p1 = fig.add_subplot(1,2,1)
    #plt.ylim((ylow,yhigh))
    
    # plot processor-specific info
    p1 = fig.add_subplot(1,2,1)
    (ylow,yhigh) = plt.ylim()
    yhigh = 0.95*yhigh
    ylow = 0.95*yhigh
    ccprocstats.plotCacheSizeLines(plt, p1, ccbench.PROCESSOR, ylow, yhigh)
    
    p2 = fig.add_subplot(1,2,2)
    plt.xlabel('Per Thread Working Set')
    (ylow,yhigh) = plt.ylim()
    yhigh = 0.95*yhigh
    ylow = 0.95*yhigh
    ccprocstats.plotCacheSizeLines(plt, p2, ccbench.PROCESSOR, ylow, yhigh)
           
    p2 = fig.add_subplot(1,2,2)
    plt.title("Aggregate Bandwidth" + r'', fontstyle='italic')
    p1 = fig.add_subplot(1,2,1)
    plt.title("Per Thread Bandwidth" + r'', fontstyle='italic')
    
    # legend 
    colors =('b','g','r','c','m','y','k','b','g','r','c','m')
    legend_sz = len(inputs["NumThreads"])
    lines = []

    for i in (range(legend_sz)):
        lines.append(plt.Line2D([0,10], [0,10], linewidth=3, color=colors[legend_sz-1-i], linestyle='-'))
         
    args = range(legend_sz)
    for i in (range(legend_sz)):
        args[legend_sz - 1 - i] = str(inputs["NumThreads"][i]) + " Threads"
#        args[legend_sz - 1 - i] = "{Thds:" + str(inputs["NumThreads"][i]) + "}" #+ ", Reqs:" + input["NumRequests"][((i)*num_datapoints)] + "}"


    p2 = fig.add_subplot(1,2,2)
    plt.legend(lines, args, 'best', title="Num of Threads", bbox_to_anchor=(0.70, 0.9)) 


    (ylow,yhigh) = plt.ylim()
    (xmin,xmax) = plt.xlim()
    p2.text(xmax, 0.9*yhigh, "%d requests / thread" % (inputs["NumRequests"][0]), horizontalalignment='center',verticalalignment='center', size='x-small')
 
    if (ccbench.PLOT_FILENAME == "none"):
        filename = PLOT_DIR + ccbench.generatePlotFileName(APP)
    else:
        # Pull out the filename path from the full path.
        # This allows us to pull out the requested filename from the path presented
        # (since we always write reports to the report directory, etc.). However, it
        # allows the user to use tab-completion to specify the exact reportfile he
        # wants to use.
        filename = PLOT_DIR + os.path.basename(ccbench.PLOT_FILENAME)
        filename = os.path.splitext(filename)[0]
        
    plt.savefig(filename)
    print "Used report filename             : " + report_filename 
    print "Finished Plotting, saved as file : " + filename + ".pdf"
Exemple #7
0
def main():
    # handle CLI options
    ccbench.controller()

    #handle default/cli args app
    app_bin = BASE_DIR + APP
    input_filename = BASE_DIR + DEFAULT_INPUT_NAME
    report_filename = REPORT_DIR + ccbench.getReportFileName(APP, REPORT_DIR)

    # 1. Parse inputs.txt file.
    if (not ccbench.NORUN):
        inputs = ccbench.parseInputFile(input_filename, variables,
                                        ccbench.INPUT_TYPE)
        inputs["NumDataPointsPerSet"] = []
        inputs["NumDataPointsPerSet"].append(str(len(inputs["AppSize"])))

        # Build up the arguments list for each invocation of the benchmark.
        # This is done here, instead of in ccbench.py, because this is custom to each app.
        app_args_list = []
        for app_size in inputs["AppSize"]:
            app_args_list.append(
                str(app_size) + " " + str(inputs["NumIterations"][0]))

    # 2. Execute the benchmark and write to the report file.
    if (not ccbench.NORUN):
        ccbench.runBenchmark(app_bin, app_args_list, inputs, input_variables,
                             report_filename)

    # 3. Extract Data from the report file.
    data = ccbench.readReportFile(report_filename, variables)

    # 4. Plot the Data
    #print data

    if NOPLOT:
        return

    if PLOT_PPT:
        font = {  #'family' : 'normal',
            #'weight' : 'bold',
            'size': 30
        }
        matplotlib.rc('font', **font)
        fig.subplots_adjust(top=0.90,
                            bottom=0.25,
                            left=0.18,
                            right=0.97,
                            wspace=0,
                            hspace=0)
        xtick_range = [1, 32, 256, 4096 * 2, 16384 * 4]
        xtick_names = ['1 kB', '32 kB', '256 kB', '8 MB', '64 MB']  #for KB
    elif PLOT_POSTER:
        fig = plt.figure(figsize=(5, 3.5))
        font = {  #'family' : 'normal',
            #'weight' : 'bold',
            'size': 8
        }
        matplotlib.rc('font', **font)
        fig.subplots_adjust(top=0.94,
                            bottom=0.14,
                            left=0.1,
                            right=0.96,
                            wspace=0,
                            hspace=0)
    else:
        fig = plt.figure(figsize=(9, 5.5))
        fig.subplots_adjust(top=0.95,
                            bottom=0.12,
                            left=0.07,
                            right=0.97,
                            wspace=0,
                            hspace=0)
        fig.subplots_adjust(top=0.95,
                            bottom=0.12,
                            left=0.1,
                            right=0.97,
                            wspace=0,
                            hspace=0)

    p1 = fig.add_subplot(1, 1, 1)

    print "Plotting time..."
    num_datapoints = int(data["NumDataPointsPerSet"][0])

    # let's convert "appsizearg(#elm)" to "appsize(KB)"
    for i in range(len(data["AppSize"])):
        data["AppSize"][i] = str(float(data["AppSize"][i]) * 4 / 1024)

    for i in range(len(data["AppSize"]) / num_datapoints):
        srt_idx = i * num_datapoints
        end_idx = (i + 1) * num_datapoints
        p1.plot(
            data["AppSize"][srt_idx:end_idx],
            data["Output"][srt_idx:end_idx],
            linestyle='--',
            marker='.'  #,
            #            linewidth=2
        )

    p1.set_xscale('log')
    p1.set_yscale('log')
    plt.ylabel(data["Units"][0])
    plt.xlabel('Array Size')
    #    plt.ylim((1, 50000))
    if (ccbench.PROCESSOR == "tilera-l3"):
        plt.ylim((100, 10000))
    elif (ccbench.PROCESSOR == "tilera"):
        plt.ylim((100, 10000))
    else:
        plt.ylim((1000, 100000))

    plt.xlim((0.5, 16384 * 4))

    if not PLOT_PPT:
        # deal with ticks
        xtick_range = [
            1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 4096 * 2,
            16384, 16384 * 2, 16384 * 4
        ]
        xtick_names = [
            '1 kB', '2 kB', '4 kB', '8 kB', '16 kB', '32 kB', '64 kB',
            '128 kB', '256 kB', '512 kB', '1 MB', '2 MB', '4 MB', '8 MB',
            '16 MB', '32 MB', '64 MB'
        ]  #for KB
#    ytick_range = [1,10,100,,1000,10000]
#    ytick_names = ['1','10','100','1e3','10e3']

    p1.xaxis.set_major_locator(plt.NullLocator())
    p1.xaxis.set_minor_locator(plt.NullLocator())
    #    p1.yaxis.set_major_locator( plt.NullLocator() )
    #    p1.yaxis.set_minor_locator( plt.NullLocator() )
    plt.xticks(xtick_range, xtick_names, rotation='-30', size='small')
    #    plt.yticks(ytick_range,ytick_names)

    (ymin, ymax) = plt.ylim()

    print "ymax=%d log(ymax) = %f, " % (ymax, np.log(ymax))
    #    print "log(7) = %f, 2^3 = 8 (%f) " % (np.log(7), np.exp(2))
    yvalue_top = np.exp2((np.log2(ymax) + np.log2(ymin)) * 0.42)
    yvalue_bot = np.exp2((np.log2(ymax) + np.log2(ymin)) * 0.40)
    #    yvalue_top = ymax*0.95 #np.exp(np.log(ymax) + np.log(ymin)/(2))
    #    yvalue_bot = yvalue_top*0.95 #np.exp(np.log(ymax) + np.log(ymin)/(2))
    ccprocstats.plotCacheSizeLines(plt, p1, ccbench.PROCESSOR, yvalue_bot,
                                   yvalue_top)

    if (ccbench.PLOT_FILENAME == "none"):
        filename = ccbench.generatePlotFileName(APP)
    else:
        filename = PLOT_DIR + os.path.basename(ccbench.PLOT_FILENAME)
        filename = os.path.splitext(filename)[0]

    plt.savefig(filename)
    print "Used report filename             : " + report_filename
    print "Finished Plotting, saved as file : " + filename + ".pdf"
Exemple #8
0
def main():
    ccbench.controller()  # handle CLI options

    #handle default/cli args app
    app_bin = BASE_DIR + APP
    input_filename = BASE_DIR +  DEFAULT_INPUT_NAME
    report_filename = REPORT_DIR + ccbench.getReportFileName(APP, REPORT_DIR)   

    # 1. Parse inputs.txt file
    if (not ccbench.NORUN):
        inputs = ccbench.parseInputFile(input_filename, input_variables, ccbench.INPUT_TYPE)
        inputs["NumDataPointsPerSet"] = []
        inputs["NumDataPointsPerSet"].append(str(len(inputs["AppSize"])))

        # Build up the arguments list for each invocation of the benchmark.
        # This is done here, instead of in ccbench.py, because this is custom to each app.
        app_args_list = []
        for num_requests in inputs["NumRequests"]:
            for app_size in inputs["AppSize"]:
                    app_args_list.append(str(num_requests) + " " +  str(app_size) \
                        + " " + str(inputs["NumIterations"][0]))
    
    # 2. Execute the benchmark and read the report file
    if (not ccbench.NORUN):
        ccbench.runBenchmark(app_bin, app_args_list, inputs, input_variables, report_filename)
        
    
    # 3. Extract Data
    data = ccbench.readReportFile(report_filename, variables)

    
    # 4. Plot the Data
    #print data
    
    if NOPLOT:
        return


    if PLOT_POSTER:
        fig = plt.figure(figsize=(5,3.5))
        font = {#'family' : 'normal',
            #'weight' : 'bold',
            'size'   : 8}
        matplotlib.rc('font', **font)
        fig.subplots_adjust(top=0.94, bottom=0.14, left=0.09, right=0.91,wspace=0, hspace=0)
    else:
        fig = plt.figure(figsize=(9,5.5))
        fig.subplots_adjust(top=0.95, bottom=0.12, left=0.07, right=0.90,wspace=0, hspace=0)

    p1 = fig.add_subplot(1,1,1)

    print "Plotting time..."
    num_datapoints = int(data["NumDataPointsPerSet"][0])
 
    # let's convert "appsizearg(#elm)" to "appsize(KB)"
    for i in range(len(data["AppSize"])):
        data["AppSize"][i] = str(float(data["AppSize"][i]) * 4 / 1024)
    
    # deal with ticks
    xtick_range = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,4096*2,16384] #for KB
    xtick_names = ['1 kB','2 kB','4 kB','8 kB','16 kB','32 kB','64 kB','128 kB','256 kB','512 kB','1 MB','2 MB','4 MB','8 MB','16 MB'] #for KB

    xmin,xmax = plt.xlim()
#    print "xmax = %d" % (xmax)

#    if (xmax >= 1024*32):
    xtick_range = [1,2,4,8,16,32,64, 128,256, 512,1024,2048,4096,4096*2, 16384,16384*2,16384*4,1024*128]
    xtick_names = ['1 kB','2 kB','4 kB','8 kB','16 kB','32 kB','64 kB','128 kB','256 kB','512 kB','1 MB','2 MB','4 MB','8 MB','16 MB','32 MB','64 MB','128 MB'] #for KB
    plt.xlim((0.5,1024*128))
    
    
         
    for i in range(len(data["AppSize"])/num_datapoints):
        srt_idx = i*num_datapoints
        end_idx = (i+1)*num_datapoints
        p1.plot(
            data["AppSize"][srt_idx:end_idx-1],
            data["Bandwidth"][srt_idx:end_idx-1],
            linestyle='--',
            marker='.'
            )
    p1.set_xscale('log')

    plt.ylabel(data["BandwidthUnits"][0])
    plt.xlabel('Array Size')
    ymin, ymax = plt.ylim()
    print "ymax = %f" % ymax
    if (ccbench.PROCESSOR == "tegra2" or ccbench.ARCHITECTURE == "arm" or ccbench.ARCHITECTURE == "riscv"):
        plt.ylim((0.0, ymax))
    else:
        plt.ylim((0.0, 2.5e9))
    
    plt.xlim((0.5, 16384))

    p1.xaxis.set_major_locator( plt.NullLocator() )
    p1.xaxis.set_minor_locator( plt.NullLocator() )
    plt.xticks(
        xtick_range,
        xtick_names,
        rotation='-30',
        size='small' 
        )


    # figure out y location of text labels normally you can use normalize
    # coords, except i want to specify the x location exactly :/
    ylow = 0
    for datum in data["Bandwidth"]:
        if (ylow < 1.02*float(datum)):
            ylow = 1.02*float(datum)
    
    (ylow,yhigh) = plt.ylim()
    yhigh = 0.95*yhigh
    ylow = 0.95*yhigh
    ccprocstats.plotCacheSizeLines(plt, p1, ccbench.PROCESSOR, ylow, yhigh)
    
    
    # legend 
    colors =('b','g','r','c','m','y','k','b','g','r','c','m')
    legend_sz = len(data["NumRequests"])/num_datapoints
    lines = []

    #for i in reversed(range(legend_sz)):
    for i in (range(legend_sz)):
        lines.append(plt.Line2D([0,10], [0,10], linewidth=3, color=colors[legend_sz-1-i]))
         
    args = range(legend_sz)
    for i in (range(legend_sz)):
        args[legend_sz - 1 - i] = data["NumRequests"][((i)*num_datapoints)]


    #legend_font= FontProperties()
    #legend_font.set_size('medium')
    #plt.legend(lines, args, 'best', title="Num of\nRequests", prop=legend_font)
    plt.legend(lines, args, 'best', title="Num of\nRequests", bbox_to_anchor=(1.12, 0.9)) 

        
    if (ccbench.PLOT_FILENAME == "none"):
        filename = PLOT_DIR + ccbench.generatePlotFileName(APP)
    else:
        # Pull out the filename path from the full path.
        # This allows us to pull out the requested filename from the path presented
        # (since we always write reports to the report directory, etc.). However, it
        # allows the user to use tab-completion to specify the exact reportfile he
        # wants to use.
        filename = PLOT_DIR + os.path.basename(ccbench.PLOT_FILENAME)
        filename = os.path.splitext(filename)[0]
 
        
    plt.savefig(filename)
    print "Used report filename             : " + report_filename 
    print "Finished Plotting, saved as file : " + filename + ".pdf"