Example #1
0
def main():

    doCreateFolders = 0

    if len(sys.argv) > 1:
        doCreateFolders = int(sys.argv[1])

    finalCombinations = removeCombinations(allCombinations)

    print("Num combinations: " + str(len(finalCombinations)))
    print("vs " + str(len(allCombinations)))



    if doCreateFolders == 1:
        createFolders(
                finalCombinations,
                templateFilepath,
                kernelFilename,
                dirToCopy,
                outRootPath,
                outBasename,
                outKnobFilename,
                logFilename)
    else:
        print("\nNote: To actually create the folders, run:\n" + sys.argv[0] + " 1\n")
def main():

    doCreateFolders = 0

    if len(sys.argv) > 1:
        doCreateFolders = int(sys.argv[1])

    #prob = Problem()

    #prob.addVariable("KNOB_SIMD"                   ,  KNOB_SIMD                  )
    #prob.addVariable("KNOB_COMPUTE_UNITS"          ,  KNOB_COMPUTE_UNITS         )
    #prob.addVariable("KNOB_XYZ_TYPE"               ,  KNOB_XYZ_TYPE              )
    #prob.addVariable("KNOB_ENTRYID_TYPE"           ,  KNOB_ENTRYID_TYPE          )
    #prob.addVariable("KNOB_ENTRYID_NUM_WORK_ITEMS" ,  KNOB_ENTRYID_NUM_WORK_ITEMS)
    #prob.addVariable("KNOB_HARDCODE_DEPTH_SIZE"    ,  KNOB_HARDCODE_DEPTH_SIZE   )
    #prob.addVariable("KNOB_VOXEL_BLOCK_MEM"        ,  KNOB_VOXEL_BLOCK_MEM       )
    #prob.addVariable("KNOB_XYZ_FLATTEN_LOOP"       ,  KNOB_XYZ_FLATTEN_LOOP      )
    #prob.addVariable("KNOB_UNROLL_XYZ"             ,  KNOB_UNROLL_XYZ            )
    #prob.addVariable("KNOB_UNROLL_ENTRYID"         ,  KNOB_UNROLL_ENTRYID        )
    #prob.addVariable("KNOB_UNROLL_VOXEL_BLOCK"     ,  KNOB_UNROLL_VOXEL_BLOCK    )
    #prob.addVariable("KNOB_UNROLL_VOXEL_BLOCK_OUT" ,  KNOB_UNROLL_VOXEL_BLOCK_OUT)
    #prob.addVariable("KNOB_DEPTH_LOCAL"            ,  KNOB_DEPTH_LOCAL           )
    #prob.addVariable("KNOB_MAX_W_CHECK_POSITION"   ,  KNOB_MAX_W_CHECK_POSITION  )

    #prob.addVariable("KNOB2_INTERPOLATE"           ,  KNOB2_INTERPOLATE      )
    #prob.addVariable("KNOB2_RAYCAST_REFINE"        ,  KNOB2_RAYCAST_REFINE   )
    #prob.addVariable("KNOB2_USE_INDEX_CACHE"       ,  KNOB2_USE_INDEX_CACHE  )
    #prob.addVariable("KNOB2_CACHE_HASH_ENTRY"      ,  KNOB2_CACHE_HASH_ENTRY )
    #prob.addVariable("KNOB2_CACHE_VOXEL_DATA"      ,  KNOB2_CACHE_VOXEL_DATA )
    #prob.addVariable("KNOB2_HARDCODE_IMG_SIZE"     ,  KNOB2_HARDCODE_IMG_SIZE)
    #prob.addVariable("KNOB2_USE_ND_RANGE"          ,  KNOB2_USE_ND_RANGE     )
    #prob.addVariable("KNOB2_USE_MINMAXIMG"         ,  KNOB2_USE_MINMAXIMG    )

    #prob.addVariable("KNOB4_INTERPOLATE_POINT"     ,  KNOB4_INTERPOLATE_POINT      )
    #prob.addVariable("KNOB4_INTERPOLATE_NORMAL"    ,  KNOB4_INTERPOLATE_NORMAL     )
    #prob.addVariable("KNOB4_UNROLL_NABLA"          ,  KNOB4_UNROLL_NABLA           )
    #prob.addVariable("KNOB4_UNROLL_HESSIAN"        ,  KNOB4_UNROLL_HESSIAN         )
    #prob.addVariable("KNOB4_SHORT_ITERATION_BRANCH",  KNOB4_SHORT_ITERATION_BRANCH )
    #prob.addVariable("KNOB4_SUM_NABLA_TYPE"        ,  KNOB4_SUM_NABLA_TYPE         )
    #prob.addVariable("KNOB4_SUM_HESSIAN_TYPE"      ,  KNOB4_SUM_HESSIAN_TYPE       )
    #prob.addVariable("KNOB4_SHIFT_REG_SIZE"        ,  KNOB4_SHIFT_REG_SIZE         )
    #prob.addVariable("KNOB4_FLATTEN_LOOP"          ,  KNOB4_FLATTEN_LOOP           )
    #prob.addVariable("KNOB4_USE_ND_RANGE"          ,  KNOB4_USE_ND_RANGE           )
    #prob.addVariable("KNOB4_PIPE_DEPTH"            ,  KNOB4_PIPE_DEPTH             )
    #prob.addVariable("KNOB4_COMPUTE_UNITS"         ,  KNOB4_COMPUTE_UNITS          )

    #prob.addConstraint(lambda a1, a2: not ((a1==1) and (a2==1)), ["KNOB_XYZ_TYPE", "KNOB_ENTRYID_TYPE"])
    #prob.addConstraint(lambda a1, a2, a3: not ((a1>1) and (a2==0) and (a3==0)), ["KNOB_SIMD", "KNOB_XYZ_TYPE", "KNOB_ENTRYID_TYPE"])
    #prob.addConstraint(lambda a1, a2: not ((a1>1) and (a2<2)), ["KNOB_COMPUTE_UNITS", "KNOB_ENTRYID_TYPE"])
    #prob.addConstraint(lambda a1, a2: not ((a1!=1) and (a2!=KNOB_ENTRYID_NUM_WORK_ITEMS[0])), ["KNOB_ENTRYID_TYPE", "KNOB_ENTRYID_NUM_WORK_ITEMS"])
    #prob.addConstraint(lambda a1, a2: not ((a1==0) and (a2!=0)), ["KNOB_HARDCODE_DEPTH_SIZE", "KNOB_DEPTH_LOCAL"])
    #prob.addConstraint(lambda a1, a2: not ((a1!=1) and (a2!=0)), ["KNOB_XYZ_FLATTEN_LOOP", "KNOB_XYZ_TYPE"])
    #prob.addConstraint(lambda a1, a2: not ((a1>1) and (a2!=0)), ["KNOB_UNROLL_XYZ", "KNOB_XYZ_TYPE"])
    #prob.addConstraint(lambda a1, a2: not ((a1>1) and (a2!=0)), ["KNOB_UNROLL_ENTRYID", "KNOB_ENTRYID_NUM_WORK_ITEMS"])
    #prob.addConstraint(lambda a1, a2, a3: not ((a1>1) and ((a2!=0) or (a3!=0))), ["KNOB_UNROLL_VOXEL_BLOCK", "KNOB_XYZ_TYPE", "KNOB_VOXEL_BLOCK_MEM"])
    #prob.addConstraint(lambda a1, a2, a3: not ((a1>1) and ((a2!=0) or (a3!=0))), ["KNOB_UNROLL_VOXEL_BLOCK_OUT", "KNOB_XYZ_TYPE", "KNOB_VOXEL_BLOCK_MEM"])

    #prob.addConstraint(lambda a1, a2, a3: not ((a1!=2) and (a2!=2) and (a3!=2)), ["KNOB4_SUM_NABLA_TYPE", "KNOB4_SUM_HESSIAN_TYPE", "KNOB4_SHIFT_REG_SIZE"])
    #prob.addConstraint(lambda a1, a2: not ((a1==1) and (a2!=0)), ["KNOB4_USE_ND_RANGE", "KNOB4_FLATTEN_LOOP"])
    #prob.addConstraint(lambda a1, a2: not ((a1==0) and (a2!=2)), ["KNOB4_USE_ND_RANGE", "KNOB4_PIPE_DEPTH"])

    #print(sum(1 for _ in prob.getSolutionIter()))

    #for i,sol in enumerate(prob.getSolutionIter()):
    #    if i%100000 == 0: print(i)

    finalCombinations = []

    for c in itertools.product(KNOB_COMBS, KNOB2_COMBS, KNOB4_COMBS):
        finalCombinations.append(list(itertools.chain(*c)))

    #finalCombinations = removeCombinations(allCombinations)

    print("Num combinations: " + str(len(finalCombinations)))
    #print("vs " + str(len(allCombinations)))

    if doCreateFolders == 1:
        createFolders(finalCombinations, templateFilepath, kernelFilename,
                      dirToCopy, outRootPath, outBasename, outKnobFilename,
                      logFilename)
    else:
        print("\nNote: To actually create the folders, run:\n" + sys.argv[0] +
              " 1\n")