def main(): parser = ArgumentParser(description=__description__) parser.add_argument("classification") parser.add_argument("outdir") args = parser.parse_args() db.init("cc1") session = db.make_session() program_ids = [ x[0] for x in session.query(sql.distinct(CLSmithResult.program_id)) \ .filter(CLSmithResult.classification == args.classification).all()] header = fs.read_file(dsmith.data_path("include", "clsmith.h")) fs.mkdir(args.outdir) for program_id in ProgressBar()(program_ids): outpath = fs.path(args.outdir, program_id + ".cl") if not fs.exists(outpath): program = session.query(CLSmithProgram) \ .filter(CLSmithProgram.id == program_id).one() pre, post = program.src.split('#include "CLSmith.h"') inlined = pre + header + post with open(outpath, "w") as outfile: print(inlined, file=outfile)
def main(): parser = ArgumentParser( description="Collect difftest results for a device") parser.add_argument("-H", "--hostname", type=str, default="cc1", help="MySQL database hostname") parser.add_argument("-r", "--result", dest="result_id", type=int, default=None, help="results ID") parser.add_argument("-t", "--table", dest="tablename", default="cl_launcherCLgenResult") parser.add_argument("--report", help="generate bug report of type: {w,bc}") parser.add_argument("-v", "--verbose", action="store_true") args = parser.parse_args() # get testbed information db_hostname = args.hostname db_url = db.init(db_hostname) if reproduce(**vars(args)): sys.exit(1)
def main(): parser = ArgumentParser( description="Collect difftest results for a device") parser.add_argument("-H", "--hostname", type=str, default="cc1", help="MySQL database hostname") parser.add_argument("-r", "--recheck", action="store_true", help="include previously checked kernels") parser.add_argument("-a", "--all", dest="include_all", action="store_true", help="include all kernels, not just wrong-code") args = parser.parse_args() # get testbed information db_hostname = args.hostname db_url = db.init(db_hostname) try: handcheck(recheck=args.recheck, include_all=args.include_all) print("done.") except KeyboardInterrupt: print("\nthanks for playing")
args = parser.parse_args() # Parse command line options platform_id = args.platform_id device_id = args.device_id optimizations = not args.no_opts gsize = parse_ndrange(args.gsize) lsize = parse_ndrange(args.lsize) # get testbed information platform_name = get_platform_name(platform_id) device_name = get_device_name(platform_id, device_id) driver_version = get_driver_version(platform_id, device_id) db.init(args.hostname) # initialize db engine with Session() as session: testbed = get_testbed(session, platform_name, device_name) params = db.get_or_create(session, threads_id, gsize_x=gsize[0], gsize_y=gsize[1], gsize_z=gsize[2], lsize_x=lsize[0], lsize_y=lsize[1], lsize_z=lsize[2]) flags = params.to_flags() print(testbed) print(params) # progress bar num_ran, num_to_run = get_num_progs_to_run(session, testbed, params) bar = progressbar.ProgressBar(init_value=num_ran, max_value=num_to_run)
Majority devices: {majority_count} - {majority_str}\ """ if __name__ == "__main__": parser = ArgumentParser(description=__doc__) parser.add_argument("-H", "--hostname", type=str, default="cc1", help="MySQL database hostname") args = parser.parse_args() db.init(args.hostname) session = db.make_session() clsmith_wrong_code_programs = session.query(CLSmithResult) \ .filter(CLSmithResult.classification == "w") fs.mkdir("../data/difftest/unreduced/clsmith/wrong_code") fs.mkdir("../data/difftest/unreduced/clsmith/wrong_code/reports") for result in clsmith_wrong_code_programs: vendor = vendor_str(result.testbed.platform) with open( f"../data/difftest/unreduced/clsmith/wrong_code/{vendor}-{result.program.id}.cl", "w") as outfile: print(result.program.src, file=outfile) with open(
checksum = crypto.sha1(buf) with open(f"{dir}/{checksum}.pb", "wb") as f: f.write(buf) def export_protobufs(s: session_t) -> None: print("exporting CLSmith results ...") export_todir(s, CLSmithResult, "dataset/clsmith") print("exporting DeepSmith results ...") export_todir(s, CLgenResult, "dataset/dsmith") print("exporting clang results ...") export_todir(s, CLgenClangResult, "dataset/clang") if __name__ == "__main__": parser = ArgumentParser( description="Collect difftest results for a device") parser.add_argument("-H", "--hostname", type=str, default="cc1", help="MySQL database hostname") args = parser.parse_args() # Connect to database db_hostname = args.hostname print("connected to", db.init(db_hostname)) with Session(commit=False) as s: export_protobufs(s)
def main(): parser = ArgumentParser(description="Collect difftest results for a device") parser.add_argument("-H", "--hostname", type=str, default="cc1", help="MySQL database hostname") parser.add_argument("platform_id", metavar="<platform-id>", type=int, help="OpenCL platform ID") parser.add_argument("device_id", metavar="<device-id>", type=int, help="OpenCL device ID") parser.add_argument("--opt", action="store_true", help="Only test with optimizations on") parser.add_argument("--no-opt", action="store_true", help="Only test with optimizations disabled") parser.add_argument("--clsmith", action="store_true", help="Only run CLSmith test cases") parser.add_argument("--clgen", action="store_true", help="Only run CLgen test cases") parser.add_argument("-t", "--timeout", type=str, default="3h", help="timeout(1) duration for batches (default: 3h)") args = parser.parse_args() # get testbed information platform_id, device_id = args.platform_id, args.device_id platform_name = get_platform_name(platform_id) device_name = get_device_name(platform_id, device_id) db_hostname = args.hostname db_url = db.init(db_hostname) print("connected to", db_url) with Session(commit=False) as session: testbed = str(get_testbed(session, platform_name, device_name)) print(testbed) cl_launcher_scripts = [ 'clsmith_run_cl_launcher.py', ] cldrive_scripts = [ 'clgen_run_cldrive.py', ] if args.opt: script_args = [['--opt']] elif args.no_opt: script_args = [['--no-opt']] else: script_args = [['--opt', '--no-opt']] timeout = str(args.timeout) cl_launcher_jobs = [ ['timeout', '-s9', timeout, 'python', script, "--hostname", db_hostname, str(platform_id), str(device_id)] + args for script, args in product(cl_launcher_scripts, script_args) ] cldrive_jobs = [ ['timeout', '-s9', timeout, 'python', script, "--hostname", db_hostname, platform_name, device_name] + args for script, args in product(cldrive_scripts, script_args) ] # Determine which jobs to run jobs = [] if not args.clgen: jobs += cl_launcher_jobs if not args.clsmith: jobs += cldrive_jobs i = 0 try: while len(jobs): i += 1 job = jobs.pop(0) nremaining = len(jobs) # run job print(f'\033[1mjob {i} ({nremaining} remaining)\033[0m', *job) p = Popen(job) p.communicate() # repeat job if it fails if p.returncode == -9: print('\033[1m\033[91m>>>> TIMEOUT', p.returncode, '\033[0m') jobs.append(job) elif p.returncode: print('\033[1m\033[91m>>>> EXIT STATUS', p.returncode, '\033[0m') jobs.append(job) print("done") except KeyboardInterrupt: print("\ninterrupting, abort.")