示例#1
0
def run_design(designs_queue):
    while not designs_queue.empty():
        design, config, tag, design_name = designs_queue.get(
            timeout=3)  # 3s timeout
        run_path = utils.get_run_path(design=design, tag=tag)
        command = './flow.tcl -design {design} -tag {tag} -overwrite -disable_output -config_tag {config} -no_save'.format(
            design=design, tag=tag, config=config)
        log.info('{design} {tag} running'.format(design=design, tag=tag))
        command = ""
        if show_log_output:
            command = './flow.tcl -design {design} -tag {tag} -overwrite -config_tag {config} -no_save'.format(
                design=design, tag=tag, config=config)
        else:
            command = './flow.tcl -design {design} -tag {tag} -overwrite -disable_output -config_tag {config} -no_save'.format(
                design=design, tag=tag, config=config)
        try:
            if show_log_output:
                process = subprocess.Popen(command.split(),
                                           stderr=subprocess.PIPE,
                                           stdout=subprocess.PIPE)
                while True:
                    output = process.stdout.readline()
                    if not output:
                        break
                    if output:
                        print(str(output.strip())[2:-1])
            else:
                subprocess.check_output(command.split(),
                                        stderr=subprocess.PIPE)
        except subprocess.CalledProcessError as e:
            error_msg = e.stderr.decode(sys.getfilesystemencoding())
            log.error('{design} {tag} failed check {run_path}error.txt'.format(
                design=design, run_path=run_path, tag=tag))
            with open(run_path + "error.txt", "w") as error_file:
                error_file.write(error_msg)

        log.info('{design} {tag} finished\t Writing report..'.format(
            design=design, tag=tag))
        params = ConfigHandler.get_config(design, tag)

        report = Report(design, tag, design_name, params).get_report()
        report_log.info(report)

        with open(run_path + "final_report.txt", "w") as report_file:
            report_file.write(Report.get_header() + "," +
                              ConfigHandler.get_header())
            report_file.write("\n")
            report_file.write(report)

        if args.benchmark is not None:
            log.info('{design} {tag} Comparing vs benchmark results..'.format(
                design=design, tag=tag))
            design_benchmark_comp_cmd = "python3 scripts/compare_regression_design.py -b {benchmark} -r {this_run} -o {output_report} -d {design} -rp {run_path}".format(
                benchmark=args.benchmark,
                this_run=report_file_name + ".csv",
                output_report=report_file_name + "_design_test_report.csv",
                design=design,
                run_path=run_path)
            subprocess.check_output(design_benchmark_comp_cmd.split())

        if args.clean:
            log.info('{design} {tag} Cleaning tmp Directory..'.format(
                design=design, tag=tag))
            moveUnPadded_cmd = "cp {run_path}/tmp/merged_unpadded.lef {run_path}/results/".format(
                run_path=run_path, tag=tag)
            subprocess.check_output(moveUnPadded_cmd.split())

            clean_cmd = "rm -rf {run_path}/tmp/".format(run_path=run_path,
                                                        tag=tag)
            subprocess.check_output(clean_cmd.split())
            log.info('{design} {tag} Cleaning tmp Directory Finished'.format(
                design=design, tag=tag))

        if tarList[0] != "":
            log.info('{design} {tag} Compressing Run Directory..'.format(
                design=design, tag=tag))
            try:
                if 'all' in tarList:
                    tarAll_cmd = "tar -cvzf {run_path}../{design_name}_{tag}.tar.gz {run_path}".format(
                        run_path=run_path, design_name=design_name, tag=tag)
                    subprocess.check_output(tarAll_cmd.split())
                else:
                    tarString = "tar -cvzf {run_path}../{design_name}_{tag}.tar.gz"
                    for dirc in tarList:
                        tarString += " {run_path}" + dirc
                    tar_cmd = tarString.format(run_path=run_path,
                                               design_name=design_name,
                                               tag=tag)
                    subprocess.check_output(tar_cmd.split())
                log.info(
                    '{design} {tag} Compressing Run Directory Finished'.format(
                        design=design, tag=tag))
            except subprocess.CalledProcessError as e:
                log.info(
                    '{design} {tag} Compressing Run Directory Failed'.format(
                        design=design, tag=tag))
        if args.delete:
            log.info('{design} {tag} Deleting Run Directory..'.format(
                design=design, tag=tag))
            deleteDirectory = "rm -rf {run_path}".format(run_path=run_path)
            subprocess.check_output(deleteDirectory.split())

            log.info('{design} {tag} Deleting Run Directory Finished..'.format(
                design=design, tag=tag))

        if print_rem_time is not None:
            if design in rem_designs.keys():
                rem_designs[design] -= 1
                if rem_designs[design] == 0:
                    rem_designs.pop(design)
示例#2
0
parser.add_argument('--design', '-d', required=True, help='Design Path')

parser.add_argument('--design_name', '-dn', required=True, help='Design Name')

parser.add_argument('--tag', '-t', required=True, help='Run Tag')

parser.add_argument('--run_path', '-r', default=None, help='Run Path')

parser.add_argument('--output_file', '-o', required=True, help='Output File')

args = parser.parse_args()
design = args.design
design_name = args.design_name
tag = args.tag
run_path = args.run_path
output_file = args.output_file

# Extracting Configurations
params = ConfigHandler.get_config(design, tag, run_path)
# Extracting Report
report = Report(design, tag, design_name, params, run_path).get_report()
# write into file
outputFileOpener = open(output_file, "w")
outputFileOpener.write(Report.get_header() + "," + ConfigHandler.get_header())
outputFileOpener.write("\n")
outputFileOpener.write(report)
outputFileOpener.close()

# Adding Extra Attributes computed from configs and reported statistics
utils.addComputedStatistics(output_file)
示例#3
0
def run_design(designs_queue):
    while not designs_queue.empty():
        design, config, tag, design_name = designs_queue.get(
            timeout=3)  # 3s timeout
        run_path = utils.get_run_path(design=design, tag=tag)
        log.info("{design} {tag} running".format(design=design, tag=tag))
        command = ""
        if show_log_output:
            command = "{ol_entry} -design {design} -tag {tag} -overwrite -config_tag {config} -no_save".format(
                ol_entry=os.getenv("OPENLANE_ENTRY") or "./flow.tcl",
                design=design,
                tag=tag,
                config=config,
            )
        else:
            command = "{ol_entry} -design {design} -tag {tag} -overwrite -disable_output -config_tag {config} -no_save".format(
                ol_entry=os.getenv("OPENLANE_ENTRY") or "./flow.tcl",
                design=design,
                tag=tag,
                config=config,
            )
        skip_rm_from_rems = False
        try:
            if show_log_output:
                process = subprocess.Popen(command.split(),
                                           stderr=subprocess.PIPE,
                                           stdout=subprocess.PIPE)
                while True:
                    output = process.stdout.readline()
                    if not output:
                        break
                    if output:
                        print(str(output.strip())[2:-1])
            else:
                subprocess.check_output(command.split(),
                                        stderr=subprocess.PIPE)
        except subprocess.CalledProcessError as e:
            if print_rem_time is not None:
                rmDesignFromPrintList(design)
                skip_rm_from_rems = True
            error_msg = e.stderr.decode(sys.getfilesystemencoding())
            log.error("{design} {tag} failed check {run_path}error.txt".format(
                design=design, run_path=run_path, tag=tag))
            with open(run_path + "error.txt", "w") as error_file:
                error_file.write(error_msg)

        if print_rem_time is not None and not skip_rm_from_rems:
            rmDesignFromPrintList(design)

        log.info("{design} {tag} finished\t Writing report...".format(
            design=design, tag=tag))
        params = ConfigHandler.get_config(design, tag)

        report = Report(design, tag, design_name, params).get_report()
        report_log.info(report)

        with open(run_path + "final_report.txt", "w") as report_file:
            report_file.write(Report.get_header() + "," +
                              ConfigHandler.get_header())
            report_file.write("\n")
            report_file.write(report)

        if args.benchmark is not None:
            try:

                log.info("{design} {tag} Comparing with benchmark results...".
                         format(design=design, tag=tag))
                design_benchmark_comp_cmd = "python3 scripts/compare_regression_design.py -b {benchmark} -r {this_run} -o {output_report} -d {design} -rp {run_path}".format(
                    benchmark=args.benchmark,
                    this_run=report_file_name + ".csv",
                    output_report=report_file_name + "_design_test_report.csv",
                    design=design,
                    run_path=run_path,
                )
                subprocess.check_output(design_benchmark_comp_cmd.split())
            except subprocess.CalledProcessError as e:
                error_msg = e.stderr.decode(sys.getfilesystemencoding())
                log.error(
                    "{design} {tag} failed to compare with benchmark: {error_msg}"
                    .format(design=design, tag=tag, error_msg=error_msg))

        if args.clean:
            try:
                log.info("{design} {tag} Cleaning tmp/...".format(
                    design=design, tag=tag))
                moveUnPadded_cmd = (
                    "cp {run_path}/tmp/merged_unpadded.lef {run_path}/results/"
                    .format(run_path=run_path, tag=tag))
                subprocess.check_output(moveUnPadded_cmd.split())

                clean_cmd = "rm -rf {run_path}/tmp/".format(run_path=run_path,
                                                            tag=tag)
                subprocess.check_output(clean_cmd.split())
                log.info("{design} {tag} tmp/  cleaned.".format(design=design,
                                                                tag=tag))
            except subprocess.CalledProcessError as e:
                error_msg = e.stderr.decode(sys.getfilesystemencoding())
                log.error(
                    "{design} {tag} failed to clean the tmp directory: {error_msg}"
                    .format(design=design, tag=tag, error_msg=error_msg))

        if tarList[0] != "":
            log.info("{design} {tag} Compressing run directory...".format(
                design=design, tag=tag))
            try:
                if "all" in tarList:
                    tarAll_cmd = "tar -cvzf {run_path}../{design_name}_{tag}.tar.gz {run_path}".format(
                        run_path=run_path, design_name=design_name, tag=tag)
                    subprocess.check_output(tarAll_cmd.split())
                else:
                    tarString = "tar -cvzf {run_path}../{design_name}_{tag}.tar.gz"
                    for dirc in tarList:
                        tarString += " {run_path}" + dirc
                    tar_cmd = tarString.format(run_path=run_path,
                                               design_name=design_name,
                                               tag=tag)
                    subprocess.check_output(tar_cmd.split())
                log.info(
                    "{design} {tag} Compressing Run Directory Finished".format(
                        design=design, tag=tag))
            except subprocess.CalledProcessError as e:
                log.info(
                    "{design} {tag} Compressing Run Directory Failed".format(
                        design=design, tag=tag))

        if args.delete:
            try:
                log.info("{design} {tag} Deleting run directory...".format(
                    design=design, tag=tag))
                deleteDirectory = "rm -rf {run_path}".format(run_path=run_path)
                subprocess.check_output(deleteDirectory.split())

                log.info("{design} {tag} Run directory deleted.".format(
                    design=design, tag=tag))
            except subprocess.CalledProcessError as e:
                error_msg = e.stderr.decode(sys.getfilesystemencoding())
                log.error(
                    "{design} {tag} failed to delete the run directory: {error_msg}"
                    .format(design=design, tag=tag, error_msg=error_msg))
示例#4
0
def run_design(designs_queue):
    while not designs_queue.empty():
        design, config, tag = designs_queue.get(timeout=3)  # 3s timeout
        run_path = utils.get_run_path(design=design, tag=tag)
        command = './flow.tcl -design {design} -tag {tag} -overwrite -disable_output -config_tag {config} -no_save'.format(
            design=design, tag=tag, config=config)
        log.info('{design} {tag} running'.format(design=design, tag=tag))
        try:
            subprocess.check_output(command.split(), stderr=subprocess.PIPE)
        except subprocess.CalledProcessError as e:
            error_msg = e.stderr.decode(sys.getfilesystemencoding())
            #print(error_msg)
            log.error('{design} {tag} failed check {run_path}error.txt'.format(
                design=design, run_path=run_path, tag=tag))
            #report_log.error('{design} {tag} failed'.format(design=design, tag=tag))
            with open(run_path + "error.txt", "w") as error_file:
                error_file.write(error_msg)

            #continue

        log.info('{design} {tag} finished\t Writing report..'.format(
            design=design, tag=tag))
        params = ConfigHandler.get_config(design, tag)

        report = Report(design, tag, params).get_report()
        report_log.info(report)

        with open(run_path + "final_report.txt", "w") as report_file:
            report_file.write(Report.get_header() + ", " +
                              ConfigHandler.get_header())
            report_file.write("\n")
            report_file.write(report)

        if args.clean:
            log.info('{design} {tag} Cleaning tmp Directory..'.format(
                design=design, tag=tag))
            moveUnPadded_cmd = "cp ./designs/{design}/runs/{tag}/tmp/merged_unpadded.lef ./designs/{design}/runs/{tag}/results/".format(
                design=design, tag=tag)
            subprocess.check_output(moveUnPadded_cmd.split())

            clean_cmd = "rm -rf ./designs/{design}/runs/{tag}/tmp/".format(
                design=design, tag=tag)
            subprocess.check_output(clean_cmd.split())
            log.info('{design} {tag} Cleaning tmp Directory Finished'.format(
                design=design, tag=tag))

        if tarList[0] != "":
            log.info('{design} {tag} Compressing Run Directory..'.format(
                design=design, tag=tag))
            if 'all' in tarList:
                tarAll_cmd = "tar -cvzf ./designs/{design}/runs/{design}_{tag}.tar.gz ./designs/{design}/runs/{tag}/".format(
                    design=design, tag=tag)
                subprocess.check_output(tarAll_cmd.split())

            else:
                tarString = "tar -cvzf ./designs/{design}/runs/{design}_{tag}.tar.gz"
                for dirc in tarList:
                    tarString += " ./designs/{design}/runs/{tag}/" + dirc
                tar_cmd = tarString.format(design=design, tag=tag)
                subprocess.check_output(tar_cmd.split())
            log.info(
                '{design} {tag} Compressing Run Directory Finished'.format(
                    design=design, tag=tag))

        if args.delete:
            log.info('{design} {tag} Deleting Run Directory..'.format(
                design=design, tag=tag))

            deleteDirectory = "rm -rf ./designs/{design}/runs/{tag}/".format(
                design=design, tag=tag)
            subprocess.check_output(deleteDirectory.split())

            log.info('{design} {tag} Deleting Run Directory Finished..'.format(
                design=design, tag=tag))
示例#5
0
    def run_design(designs_queue):
        nonlocal design_failure_flag, flow_failure_flag
        while not designs_queue.empty():
            design, config, tag, design_name = designs_queue.get(
                timeout=3)  # 3s timeout
            run_path = utils.get_run_path(design=design, tag=tag)
            update("START", design)
            command = [
                os.getenv("OPENLANE_ENTRY") or "./flow.tcl", "-design", design,
                "-tag", tag, "-config_tag", config, "-overwrite", "-no_save"
            ] + ([] if show_log_output else ["-disable_output"])
            skip_rm_from_rems = False
            try:
                if show_log_output:
                    subprocess.check_call(command)
                else:
                    subprocess.check_output(command, stderr=subprocess.PIPE)
            except subprocess.CalledProcessError as e:
                if print_rem_time is not None:
                    rmDesignFromPrintList(design)
                    skip_rm_from_rems = True
                run_path_relative = os.path.relpath(run_path, ".")
                update("FAIL",
                       design,
                       f"Check {run_path_relative}/flow_summary.log",
                       error=True)
                design_failure_flag = True

            if print_rem_time is not None and not skip_rm_from_rems:
                rmDesignFromPrintList(design)

            update("DONE", design, "Writing report...")
            params = ConfigHandler.get_config(design, tag)

            report = Report(design, tag, design_name, params).get_report()
            report_log.info(report)

            with open(f"{run_path}/report.csv", "w") as report_file:
                report_file.write(Report.get_header() + "," +
                                  ConfigHandler.get_header())
                report_file.write("\n")
                report_file.write(report)

            if benchmark is not None:
                try:
                    update("DONE", design,
                           "Comparing with benchmark results...")
                    subprocess.check_output([
                        "python3", "./scripts/compare_regression_design.py",
                        "--output-report", f"{report_file_name}.rpt.yml",
                        "--benchmark", benchmark, "--design", design,
                        "--run-path", run_path, f"{report_file_name}.csv"
                    ],
                                            stderr=subprocess.PIPE)
                except subprocess.CalledProcessError as e:
                    error_msg = e.stderr.decode("utf8")
                    update("ERROR", design,
                           f"Failed to compare with benchmark: {error_msg}")
                    flow_failure_flag = True

            if tarList[0] != "":
                update("DONE", design, "Compressing run directory...")
                try:
                    tarball_path = os.path.realpath(
                        os.path.join(run_path, "..",
                                     f"{design_name}_{tag}.tar.gz"))
                    tar_cmd = ["tar", "-czvf", tarball_path]
                    if "all" in tarList:
                        tar_cmd += [run_path]
                    else:
                        tar_cmd += list(
                            map(lambda x: f"{run_path}/{x}", tarList))
                    subprocess.check_output(tar_cmd)
                    update("DONE", design, "Compressed run directory.")
                except subprocess.CalledProcessError as e:
                    update("ERROR",
                           design,
                           "Failed to compress run directory.",
                           error=True)
                    flow_failure_flag = True

            if delete:
                try:
                    update("DONE", design, "Deleting run directory...")
                    shutil.rmtree(run_path)
                    update("DONE", design, "Deleted run directory.")
                except FileNotFoundError as e:
                    pass
                except Exception as e:
                    update("ERROR",
                           design,
                           "Failed to delete run directory.",
                           error=True)
                    flow_failure_flag = True