<#1720 Multiprocessing for drc_rosetta.py> Issue c...
# openlane-development
g
#1720 Multiprocessing for drc_rosetta.py Issue created by hakan-demirli Description Problem: For a big design consisting of more than 100k cells second portion of the magic DRC takes too long. "Converting Magic DRC database to various tool-readable formats..." OpenLane/scripts/tcl_commands/magic.tcl Line 99 in </The-OpenROAD-Project/OpenLane/commit/e8650c2b2b838989a3fb97172aadf0ee4aa78ee3|e8650c2> Original magic DRC file is around 400 MB. Created rpt, tcl, tr files each around 500 MB. That is a lot of lines of text generated by a single thread. Benefits: All of the previous steps take approximately 4 hours to complete, this one alone takes 5 hours. Proposal • It should speed up quite a lot if we throw more cores to the problem. All I see from the file is bunch of nested for loops processing a string input. For example assuming print order is not important but only the return value, the magic_to_tcl function can be parallelized like this:
Copy code
import multiprocessing

def process_sections(sections):
    result = ""
    with StringIO() as f:
        for i in range(1, len(sections) - 1, 2):
            vio_name = sections[i].strip()
            for vio in sections[i + 1].split("\n"):
                vio = vio.strip()
                if len(vio):
                    print(f'box {vio}; feedback add "{vio_name}" medium', file=f)
        result = f.getvalue()
    return result

def magic_to_tcl_parallel(magic_input: str) -> str:
    sections = magic_input.split(MAGIC_SPLIT_LINE)
    section_lists = [sections[i:i+2] for i in range(1, len(sections) - 1, 2)]
    with multiprocessing.Pool() as pool:
        results = pool.map(process_sections, section_lists)
    return ''.join(results)
Similar thing for the other functions in the file. • Or add variables to skip this section if the output files are not used in the later stages. MAGIC_CONVERT_DRC_TO_RDB MAGIC_CONVERT_DRC_TO_TCL MAGIC_CONVERT_DRC_TO_TR MAGIC_CONVERT_DRC_TO_KLAYOUT The-OpenROAD-Project/OpenLane