""" Created on Sep 14, 2015 @author: yogev.vaknin """ import logging from glue import Gluer if __name__ == "__main__": logging.getLogger().setLevel(logging.DEBUG) glue = Gluer() files = glue.collectAllFiles("../benchmark/") print files glue.genBitcodeForAllFiles(files) glue.genAllOutput(files)
def main(argv=None): debug = True if (debug): logging.getLogger().setLevel(logging.DEBUG) else: logging.getLogger().setLevel(logging.INFO) program_name = os.path.basename(sys.argv[0]) if argv is None: argv = sys.argv[1:] # setup option parser parser = OptionParser() parser.add_option("-r", "--run_cmd", dest="run_cmd", help="cmd for running the benchmark") parser.add_option("-b", "--build_cmd", dest="build_cmd", help="cmd for building the program (should support openML lib)") parser.add_option("-d", "--src_dir", dest="src_dir", help="source directory") # process options (opts, args) = parser.parse_args(argv) print("run_cmd = %s" % opts.run_cmd) print("build_cmd = %s" % opts.build_cmd) print("src_dir = %s" % opts.src_dir) os.system("rm -f ./input.txt") os.system("rm -f ./input_final.txt") os.system("rm -f ./new_file.txt") os.system("rm -f ./raw_input.txt") os.system("rm -f ./raw_input_filtered.txt") glue = Gluer() files = glue.collectAllFiles(opts.src_dir) logging.debug('work files %s', files) glue.genBitcodeForAllFiles(files) glue.genAllOutput(files) lineInj = LineInjector() injPlanner = InjectPlanner() os.system("cat ./raw_input.txt | grep Independent_Loop > ./raw_input_filtered.txt") injPlanner.reworkLoopFile("./raw_input_filtered.txt","./input.txt") renameAllOrigFiles("input.txt") injPlan = injPlanner.plan("input.txt", PlanType.noPar) logging.debug('plan no par %s', injPlan) for fileName in injPlan: lineInj.inject(fileName, fileName[:-5],injPlan[fileName]) if (debug): shutil.copy(fileName[:-5], fileName[:-5] + "_no_par") os.system(opts.build_cmd) os.system(opts.run_cmd + " > out_no_par.txt ") revertAllOrigFiles("input.txt") renameAllOrigFiles("input.txt") injPlan = injPlanner.plan("input.txt", PlanType.par) logging.debug('plan par %s', injPlan) for fileName in injPlan: lineInj.inject(fileName, fileName[:-5],injPlan[fileName]) if (debug): shutil.copy(fileName[:-5], fileName[:-5] + "_par") os.system(opts.build_cmd) os.system(opts.run_cmd + " > out_par.txt ") injPlanner.calcOut("input.txt", "out_no_par.txt" , "out_par.txt", "new_file.txt") revertAllOrigFiles("input.txt") renameAllOrigFiles("input.txt") os.system("cat new_file.txt| uniq > ./input_final.txt") injPlan = injPlanner.plan("./input_final.txt", PlanType.final) logging.debug('plan final %s', injPlan) for fileName in injPlan: lineInj.inject(fileName, fileName[:-5],injPlan[fileName])