예제 #1
0
def profile_buf_size(low, high, step, scale):
    arr = []
    # systolic_arr_size, memory_bandwidth, buffer_size
    for size in [0.25, 0.5, 1, 1.5, 2.0, 3.0, 6.0]:
        config = hardware_constraints()
        # print(config[2]*pow(1.2, size)/3.0)
        config[2] = config[2] * size
        # config[2] = config[2]*scale*pow(1.2, size)
        setup_hardware(config)
        setup_hardware3d(config)
        res = opti_dnn()
        arr.append([item[0:4] for item in res])

    # gather results
    res = {"sa_avg":[], "sa_std":[], "buf_avg":[], "buf_std":[], \
            "cycle_avg": [], "traffic_avg": []}

    for ls in arr:
        res["sa_avg"].append(np.mean([i[2] for i in ls]))
        res["sa_std"].append(np.std([i[2] for i in ls]))
        res["buf_avg"].append(np.mean([i[3] for i in ls]))
        res["buf_std"].append(np.std([i[3] for i in ls]))
        res["cycle_avg"].append(np.mean([i[1] for i in ls]))
        res["traffic_avg"].append(np.mean([i[0] for i in ls]))

    print(res)
    # plot_buf_size(res, [0.25, 0.5, 1, 1.5, 2.0, 3.0, 6.0], 1)
    plot_buf_cycle(res, [0.25, 0.5, 1, 1.5, 2.0, 3.0, 6.0], 1)
예제 #2
0
def profile_bw_size(low, high):
    arr = []
    # systolic_arr_size, memory_bandwidth, buffer_size
    for i in range(low, high):
        config = hardware_constraints()
        config[1] = float(pow(2, i))
        setup_hardware(config)
        setup_hardware3d(config)
        res = opti_dnn()
        arr.append([item[0:4] for item in res])

    # gather results
    res = {"sa_avg":[], "sa_std":[], "buf_avg":[], "buf_std":[], \
            "cycle_avg": [], "traffic_avg": []}

    for ls in arr:
        res["sa_avg"].append(np.mean([i[2] for i in ls]))
        res["sa_std"].append(np.std([i[2] for i in ls]))
        res["buf_avg"].append(np.mean([i[3] for i in ls]))
        res["buf_std"].append(np.std([i[3] for i in ls]))
        res["cycle_avg"].append(np.mean([i[1] for i in ls]))
        res["traffic_avg"].append(np.mean([i[0] for i in ls]))

    plot_bw_size(res, low, high)
    plot_bw_cycle(res, low, high)
예제 #3
0
def profile_sa_size(low, high, step):
    for scale in range(1, 7):
        arr = []
        # systolic_arr_size, memory_bandwidth, buffer_size
        for size in range(low, high + step, step):
            config = hardware_constraints(sa_size=16.0,
                                          mem_bw=32.0,
                                          buf=1048576.0 * 0.5 * scale)
            print("SIZE", size)
            config[0] = float(size)
            print(config)
            setup_hardware(config)
            setup_hardware3d(config)
            res = opti_dnn()
            arr.append([item[0:4] for item in res])

        # gather results
        res = {"sa_avg":[], "sa_std":[], "buf_avg":[], "buf_std":[], \
                "cycle_avg": [], "traffic_avg": []}

        for ls in arr:
            res["sa_avg"].append(np.mean([i[2] for i in ls]))
            res["sa_std"].append(np.std([i[2] for i in ls]))
            res["buf_avg"].append(np.mean([i[3] for i in ls]))
            res["buf_std"].append(np.std([i[3] for i in ls]))
            res["cycle_avg"].append(np.mean([i[1] for i in ls]))
            res["traffic_avg"].append(np.mean([i[0] for i in ls]))
        # print >> sys.stderr, ('[%d]' % (scale))
        print >> sys.stderr, str(res["traffic_avg"])
def profile_sa_size(low, high, step):
    arr = []
    # systolic_arr_size, memory_bandwidth, buffer_size
    for size in range(low, high + step, step):
        config = hardware_constraints()
        print("SIZE", size)
        config[0] = float(size)
        print(config)
        setup_hardware(config)
        setup_hardware3d(config)
        res = opti_dnn()
        for j in range(len(res)):
            if res[j] is None:
                res[j] = arr[-1][j]
        arr.append([item[0:4] for item in res])

    # gather results
    res = {"sa_avg":[], "sa_std":[], "buf_avg":[], "buf_std":[], \
            "cycle_avg": [], "traffic_avg": []}

    for ls in arr:
        res["sa_avg"].append(np.mean([i[2] for i in ls]))
        res["sa_std"].append(np.std([i[2] for i in ls]))
        res["buf_avg"].append(np.mean([i[3] for i in ls]))
        res["buf_std"].append(np.std([i[3] for i in ls]))
        res["cycle_avg"].append(np.mean([i[1] for i in ls]))
        res["traffic_avg"].append(np.mean([i[0] for i in ls]))

    print(res)
    plot_sa_size(res, low, high, step)
    plot_sa_cycle(res, low, high, step)
예제 #5
0
    # plot_buf_size(res, [0.25, 0.5, 1, 1.5, 2.0, 3.0, 6.0], 1)
    plot_buf_cycle(res, [0.25, 0.5, 1, 1.5, 2.0, 3.0, 6.0], 1)


if __name__ == '__main__':
    # import the dnn
    import_dnn("dnns/GC_Net.txt")
    # import_dnn("dnns/PSMNet.txt")
    for ln in dnn3d:
        print(ln)
    # exit()
    # check which characterization you want to proceed
    if detail_profile:
        # set up the hardware configuration
        setup_hardware(hardware_constraints())
        # set up the hardware configuration
        setup_hardware3d(hardware_constraints())
        # start the optimization main routine
        res = opti_dnn()
        # plot the result of each layer
        plot_util_dnn(res, suffix)
        profile_layer_cycle(res, suffix)
    else:
        # profile systolic array size impacts
        profile_sa_size(8, 64, 8)
        # profile bandwidth impacts
        # profile_bw_size(-5, 12)
        # profile buffer size impacts
        # profile_buf_size(10, 200, 10, 0.01)
        # profile_buf_size(3, 20, 2, 0.1)