Exemplo n.º 1
0
def build_unsharp(app_data, g_size=None, t_size=None):
    pipe_data = app_data['pipe_data']
    out_unsharp, inline_func = unsharp_mask(pipe_data)
    R = pipe_data['R']
    C = pipe_data['C']
    threshold = pipe_data['threshold']
    weight = pipe_data['weight']

    live_outs = [out_unsharp]
    pipe_name = app_data['app']

    rows = app_data['rows'] - 2
    cols = app_data['cols'] - 2

    p_estimates = [(R, rows), (C, cols)]
    p_constraints = [ Condition(R, "==", rows), \
                      Condition(C, "==", cols) ]
    if (t_size == None):
        t_size = [1, 8, 256]
    if (g_size == None):
        g_size = 4
    opts = []
    if app_data['early_free']:
        opts += ['early_free']
    if app_data['optimize_storage']:
        opts += ['optimize_storage']
    if app_data['pool_alloc']:
        opts += ['pool_alloc']
    if app_data['inline']:
        opts += ['inline']
    if app_data['multi-level-tiling']:
        opts += ['multi-level-tiling']
    if app_data['dpfuse']:
        opts += ['dpfuse']

    if app_data['logdpchoices']:
        opts += ['logdpchoices']
    if app_data['logmaxchildren']:
        logmaxchildren = app_data['logmaxchildren']

    pipe = buildPipeline(live_outs,
                         param_estimates=p_estimates,
                         param_constraints=p_constraints,
                         tile_sizes=t_size,
                         group_size=g_size,
                         options=opts,
                         pipe_name=pipe_name,
                         logMaxChildren=logmaxchildren)

    return pipe
Exemplo n.º 2
0
def build_unsharp(app_data):
    pipe_data = app_data['pipe_data']
    out_unsharp = unsharp_mask(pipe_data)
    R = pipe_data['R']
    C = pipe_data['C']
    threshold = pipe_data['threshold']
    weight = pipe_data['weight']

    live_outs = [out_unsharp]
    pipe_name = app_data['app']

    rows = app_data['rows']-2
    cols = app_data['cols']-2

    p_estimates = [(R, rows), (C, cols)]
    p_constraints = [ Condition(R, "==", rows), \
                      Condition(C, "==", cols) ]
    t_size = [16, 16]
    g_size = 11
    opts = []
    if app_data['early_free']:
        opts += ['early_free']
    if app_data['optimize_storage']:
        opts += ['optimize_storage']
    if app_data['pool_alloc']:
        opts += ['pool_alloc']

    pipe = buildPipeline(live_outs,
                         param_estimates=p_estimates,
                         param_constraints=p_constraints,
                         tile_sizes = t_size,
                         group_size = g_size,
                         options = opts,
                         pipe_name = pipe_name)

    return pipe
Exemplo n.º 3
0
def build_unsharp(app_data):
    pipe_data = app_data['pipe_data']
    out_unsharp = unsharp_mask(pipe_data)
    R = pipe_data['R']
    C = pipe_data['C']
    threshold = pipe_data['threshold']
    weight = pipe_data['weight']

    live_outs = [out_unsharp]
    pipe_name = app_data['app']

    rows = app_data['rows'] - 2
    cols = app_data['cols'] - 2

    p_estimates = [(R, rows), (C, cols)]
    p_constraints = [ Condition(R, "==", rows), \
                      Condition(C, "==", cols) ]
    t_size = [16, 16]
    g_size = 11
    opts = []
    if app_data['early_free']:
        opts += ['early_free']
    if app_data['optimize_storage']:
        opts += ['optimize_storage']
    if app_data['pool_alloc']:
        opts += ['pool_alloc']

    pipe = buildPipeline(live_outs,
                         param_estimates=p_estimates,
                         param_constraints=p_constraints,
                         tile_sizes=t_size,
                         group_size=g_size,
                         options=opts,
                         pipe_name=pipe_name)

    return pipe
Exemplo n.º 4
0
def auto_tune(app_data):
    pipe_data = app_data['pipe_data']

    app_name = app_data['app_name']
    pipe_name = app_data['app']
    pipe_func_name = "pipeline_" + pipe_name

    out_unsharp, inline_func = unsharp_mask(pipe_data)
    live_outs = [out_unsharp]

    R = pipe_data['R']
    C = pipe_data['C']

    rows = app_data['rows'] - 2
    cols = app_data['cols'] - 2
    threshold = app_data['threshold']
    weight = app_data['weight']

    param_estimates = [(R, rows), (C, cols)]
    param_constraints = [ Condition(R, "==", rows), \
                          Condition(C, "==", cols) ]

    dst_path = "/tmp"

    group_size_configs = [int(i * 4) for i in [0.2, 0.4, 0.5]]

    #group_size_configs = [10]

    tile_size_configs = []

    tile_size_configs.append([64, 256])
    tile_size_configs.append([64, 128])

    tile_size_configs.append([32, 512])
    tile_size_configs.append([32, 256])
    tile_size_configs.append([32, 128])
    tile_size_configs.append([32, 64])

    tile_size_configs.append([16, 512])
    tile_size_configs.append([16, 256])
    tile_size_configs.append([16, 128])
    tile_size_configs.append([16, 64])

    tile_size_configs.append([8, 512])
    tile_size_configs.append([8, 256])
    tile_size_configs.append([8, 128])
    tile_size_configs.append([8, 64])
    tile_size_configs.append([8, 32])

    # relative path to root directory from app dir
    ROOT = app_data['ROOT']
    opts = []
    if app_data['early_free']:
        opts += ['early_free']
    if app_data['optimize_storage']:
        opts += ['optimize_storage']
    if app_data['pool_alloc']:
        opts += ['pool_alloc']
    if app_data['dpfuse']:
        opts += ['dpfuse']

    gen_compile_string(app_data)
    cxx_string = app_data['cxx_string']

    # Generate Variants for Tuning
    # ============================

    gen_config = {
        "_tuner_app_name": app_name,
        "_tuner_live_outs": live_outs,
        "_tuner_param_constraints": param_constraints,  #optional
        "_tuner_param_estimates": param_estimates,  #optional
        "_tuner_tile_size_configs": tile_size_configs,  #optional
        "_tuner_group_size_configs": group_size_configs,  #optional
        "_tuner_opts": opts,  #optional
        "_tuner_dst_path": dst_path,  # optional
        "_tuner_cxx_string": cxx_string,  # optional
        "_tuner_root_path": ROOT,  # needed if pool_alloc is set
        "_tuner_debug_flag": True,  # optional
        "_tuner_opt_datadict": app_data
    }

    _tuner_src_path, _tuner_configs_count, _tuner_pipe = \
        tuner.generate(gen_config)
    '''
    _tuner_src_path = '/tmp/PolycNUUEYoLt2Mage'
    _tuner_configs_count = 75
    _tuner_pipe = buildPipeline(live_outs)
    '''

    img_data = app_data['img_data']
    IN = img_data['IN']
    OUT = img_data['OUT']

    pipe_args = {}
    pipe_args['R'] = rows
    pipe_args['C'] = cols
    pipe_args['threshold'] = threshold
    pipe_args['weight'] = weight
    pipe_args['img'] = IN
    pipe_args['mask'] = OUT

    # Execute the generated variants
    # ==============================

    exec_config = {
        "_tuner_app_name": app_name,
        "_tuner_pipe": _tuner_pipe,
        "_tuner_pipe_arg_data": pipe_args,
        "_tuner_src_path": _tuner_src_path,  # optional
        "_tuner_configs_count": _tuner_configs_count,  # optional
        "_tuner_omp_threads": 4,  # optional
        "_tuner_nruns": int(app_data['app_args'].runs),  # optional
        "_tuner_debug_flag": True,  # optional
        #"_tuner_custom_executor": minimal_exec_mg,
        "_tuner_app_data": app_data
    }

    tuner.execute(exec_config)
Exemplo n.º 5
0
def auto_tune(app_data):
    pipe_data = app_data['pipe_data']

    app_name = app_data['app_name']
    pipe_name = app_data['app']
    pipe_func_name = "pipeline_"+pipe_name

    out_unsharp = unsharp_mask(pipe_data)
    live_outs = [out_unsharp]
    
    R = pipe_data['R']
    C = pipe_data['C']

    rows = app_data['rows']-2
    cols = app_data['cols']-2
    threshold = app_data['threshold']
    weight = app_data['weight']

    param_estimates = [(R, rows), (C, cols)]
    param_constraints = [ Condition(R, "==", rows), \
                          Condition(C, "==", cols) ]
    
    dst_path = "/tmp"

    group_size_configs = [3, 5, 7, 9, 10]
    #group_size_configs = [10]


    tile_size_configs = []
    
    tile_size_configs.append([64, 256])
    tile_size_configs.append([64, 128])
    
    tile_size_configs.append([32, 512])
    tile_size_configs.append([32, 256])
    tile_size_configs.append([32, 128])
    tile_size_configs.append([32, 64])

    tile_size_configs.append([16, 512])
    tile_size_configs.append([16, 256])
    tile_size_configs.append([16, 128])
    tile_size_configs.append([16, 64])

    tile_size_configs.append([8, 512])
    tile_size_configs.append([8, 256])
    tile_size_configs.append([8, 128])
    tile_size_configs.append([8, 64])
    tile_size_configs.append([8, 32])
   
    # relative path to root directory from app dir
    ROOT = app_data['ROOT']
    opts = []
    if app_data['early_free']:
        opts += ['early_free']
    if app_data['optimize_storage']:
        opts += ['optimize_storage']
    if app_data['pool_alloc']:
        opts += ['pool_alloc']

    gen_compile_string(app_data)
    cxx_string = app_data['cxx_string']

    # Generate Variants for Tuning
    # ============================

    gen_config = {"_tuner_app_name": app_name,
                  "_tuner_live_outs": live_outs,
                  "_tuner_param_constraints": param_constraints, #optional
                  "_tuner_param_estimates": param_estimates, #optional
                  "_tuner_tile_size_configs": tile_size_configs, #optional
                  "_tuner_group_size_configs": group_size_configs, #optional
                  "_tuner_opts": opts, #optional
                  "_tuner_dst_path" : dst_path, # optional
                  "_tuner_cxx_string" : cxx_string, # optional
                  "_tuner_root_path" : ROOT, # needed if pool_alloc is set
                  "_tuner_debug_flag": True, # optional
                  "_tuner_opt_datadict": app_data
                 }

    _tuner_src_path, _tuner_configs_count, _tuner_pipe = \
        tuner.generate(gen_config)

    '''
    _tuner_src_path = '/tmp/PolycNUUEYoLt2Mage'
    _tuner_configs_count = 75
    _tuner_pipe = buildPipeline(live_outs)
    '''

    img_data = app_data['img_data']
    IN = img_data['IN']
    OUT = img_data['OUT']

    pipe_args = {}
    pipe_args['R'] = rows
    pipe_args['C'] = cols
    pipe_args['threshold'] = threshold
    pipe_args['weight'] = weight
    pipe_args['img'] = IN 
    pipe_args['mask'] = OUT 


    # Execute the generated variants
    # ==============================

    exec_config = {"_tuner_app_name": app_name,
                   "_tuner_pipe": _tuner_pipe,
                   "_tuner_pipe_arg_data": pipe_args,
                   "_tuner_src_path": _tuner_src_path, # optional
                   "_tuner_configs_count": _tuner_configs_count, # optional
                   "_tuner_omp_threads": 4, # optional
                   "_tuner_nruns": 1, # optional
                   "_tuner_debug_flag": True, # optional
                   #"_tuner_custom_executor": minimal_exec_mg,
                   "_tuner_app_data": app_data
                  }

    tuner.execute(exec_config)