def run_tasks( args, configs, ): """ Runs the specified set of tasks (configs) """ start = datetime.now() num_failed = 0 jobs = create_jobs(args, configs) run_dirs = {} for config in configs: task_dir = find_task_dir(config) task_run_dir = get_next_run_dir(task_dir) run_dirs[config.task_name] = task_run_dir # We could potentially support other 'run' systems (e.g. a cluster), # rather than just the local machine if args.system == "local": assert args.j > 0, "Invalid number of processors" if args.run: num_failed = run_parallel(args, jobs, run_dirs) print("Elapsed time: {}".format( format_elapsed_time(datetime.now() - start))) if args.parse: start = datetime.now() print("\nParsing test results...") if len(args.list_file) > 0: print("scripts/parse_vtr_task.py -l {}".format( args.list_file[0])) parse_tasks(configs, jobs) print("Elapsed time: {}".format( format_elapsed_time(datetime.now() - start))) if args.create_golden: create_golden_results_for_tasks(configs) if args.check_golden: num_failed += check_golden_results_for_tasks(configs) if args.calc_geomean: summarize_qor(configs) calc_geomean(args, configs) # This option generates a shell script (vtr_flow.sh) for each architecture, # circuit, script_params # The generated can be used to be submitted on a large cluster elif args.system == "scripts": for _, value in run_dirs.items(): Path(value).mkdir(parents=True) run_scripts = create_run_scripts(jobs, run_dirs) for script in run_scripts: print(script) else: raise VtrError( "Unrecognized run system {system}".format(system=args.system)) return num_failed
def vtr_command_main(arg_list, prog=None): """ Running VTR with the specified arguemnts. """ start = datetime.now() # Load the arguments args, unknown_args = vtr_command_argparser(prog).parse_known_args(arg_list) error_status = "Error" if args.temp_dir is None: temp_dir = Path("./temp") else: temp_dir = Path(args.temp_dir) # Specify how command should be run command_runner = vtr.CommandRunner( track_memory=True, max_memory_mb=args.limit_memory_usage, timeout_sec=args.timeout, verbose=args.verbose, show_failures=args.show_failures, valgrind=args.valgrind, ) exit_status = 0 return_status = 0 try: vpr_args = process_unknown_args(unknown_args) vpr_args = process_vpr_args(args, prog, temp_dir, vpr_args) if args.sdc_file: vpr_args["sdc_file"] = get_sdc_file(args.sdc_file, prog) print( args.name if args.name else Path(args.architecture_file).stem + "/" + Path(args.circuit_file).stem, end="\t\t", ) # Run the flow vtr.run( Path(args.architecture_file), Path(args.circuit_file), power_tech_file=args.power_tech, temp_dir=temp_dir, start_stage=args.start, end_stage=args.end, command_runner=command_runner, vpr_args=vpr_args, abc_args=process_abc_args(args), odin_args=process_odin_args(args), keep_intermediate_files=args.keep_intermediate_files, keep_result_files=args.keep_result_files, min_hard_mult_size=args.min_hard_mult_size, min_hard_adder_size=args.min_hard_adder_size, check_equivalent=args.check_equivalent, check_incremental_sta_consistency=args. check_incremental_sta_consistency, use_old_abc_script=args.use_old_abc_script, relax_w_factor=args.relax_w_factor, ) error_status = "OK" except vtr.VtrError as error: error_status, return_status, exit_status = except_vtr_error( error, args.expect_fail, args.verbose) except KeyboardInterrupt as error: print("{} recieved keyboard interrupt".format(prog)) exit_status = 4 return_status = exit_status finally: seconds = datetime.now() - start print("{status} (took {time})".format( status=error_status, time=vtr.format_elapsed_time(seconds))) temp_dir.mkdir(parents=True, exist_ok=True) out = temp_dir / "output.txt" out.touch() with out.open("w") as file: file.write("vpr_status=") if exit_status == 0: file.write("success\n") else: file.write("exited with return code {}\n".format(exit_status)) file.write("vpr_seconds=%d\nrundir=%s\nhostname=%s\nerror=" % (seconds.total_seconds(), str( Path.cwd()), socket.gethostname())) file.write("\n") sys.exit(return_status)