|
14 | 14 | # ============================================================================== |
15 | 15 |
|
16 | 16 |
|
17 | | -def get_hash(f): |
18 | | - # content hash for the result file alongside .log file is useful to |
19 | | - # debug divergent results under what should be identical |
20 | | - # builds(such as local and CI builds) |
21 | | - for ext in [".odb", ".rtlil", ".v"]: |
| 17 | +# Primary data artifacts first, then derived/exported artifacts and |
| 18 | +# the SDC constraint file: yosys emits .v / .rtlil; OpenROAD stages |
| 19 | +# emit .odb (and often .def / .sdc); routing emits .spef; finish |
| 20 | +# emits .gds. |
| 21 | +RESULT_EXTS = [".v", ".rtlil", ".odb", ".def", ".spef", ".gds", ".sdc"] |
| 22 | + |
| 23 | + |
| 24 | +def get_hashes(f): |
| 25 | + """Return [(ext, sha1), ...] for every result file alongside log |
| 26 | + `f` whose extension is in RESULT_EXTS. A yosys stage typically |
| 27 | + produces both `.v` and `.sdc`; a floorplan/route stage produces |
| 28 | + `.odb` (and often `.sdc`); the canonicalize stage produces |
| 29 | + `.rtlil`. Hashing each separately makes "the netlist changed" |
| 30 | + distinguishable from "the SDC changed" in the elapsed-time table |
| 31 | + used to triage divergent local vs CI builds. |
| 32 | +
|
| 33 | + Falls back to a single ("", "N/A") entry when no result file |
| 34 | + exists so the caller always emits at least one row per stage. |
| 35 | + """ |
| 36 | + results = [] |
| 37 | + for ext in RESULT_EXTS: |
22 | 38 | result_file = pathlib.Path( |
23 | 39 | str(f).replace("logs/", "results/").replace(".log", ext) |
24 | 40 | ) |
25 | 41 | if result_file.exists(): |
26 | 42 | hasher = hashlib.sha1() |
27 | | - with open(result_file, "rb") as odb_f: |
| 43 | + with open(result_file, "rb") as rf: |
28 | 44 | while True: |
29 | | - chunk = odb_f.read(16 * 1024 * 1024) |
| 45 | + chunk = rf.read(16 * 1024 * 1024) |
30 | 46 | if not chunk: |
31 | 47 | break |
32 | 48 | hasher.update(chunk) |
33 | | - return hasher.hexdigest() |
34 | | - return "N/A" |
| 49 | + results.append((ext, hasher.hexdigest())) |
| 50 | + if not results: |
| 51 | + results.append(("", "N/A")) |
| 52 | + return results |
35 | 53 |
|
36 | 54 |
|
37 | 55 | def print_log_dir_times(logdir, args): |
@@ -87,37 +105,49 @@ def print_log_dir_times(logdir, args): |
87 | 105 | ) |
88 | 106 | break |
89 | 107 |
|
90 | | - odb_hash = get_hash(f) |
| 108 | + hashes = get_hashes(f) |
91 | 109 |
|
92 | 110 | if not found: |
93 | 111 | print("No elapsed time found in", str(f), file=sys.stderr) |
94 | 112 | continue |
95 | 113 |
|
96 | | - # Print the name of the step and the corresponding elapsed time |
97 | | - format_str = "%-25s %10s %14s %20s" |
| 114 | + # Print the name of the step and the corresponding elapsed time. |
| 115 | + # One row per (stage, result-file-ext); only the first row of a |
| 116 | + # stage shows elapsed/peak. |
| 117 | + format_str = "%-25s %-6s %10s %14s %20s" |
98 | 118 | if elapsedTime is not None and peak_memory is not None: |
99 | 119 | if first and not args.noHeader: |
100 | 120 | print( |
101 | 121 | format_str |
102 | | - % ("Log", "Elapsed/s", "Peak Memory/MB", "sha1sum result [0:20)") |
| 122 | + % ( |
| 123 | + "Log", |
| 124 | + "Ext", |
| 125 | + "Elapsed/s", |
| 126 | + "Peak Memory/MB", |
| 127 | + "sha1sum result [0:20)", |
| 128 | + ) |
103 | 129 | ) |
104 | 130 | first = False |
105 | | - print( |
106 | | - format_str |
107 | | - % ( |
108 | | - stem, |
109 | | - elapsedTime, |
110 | | - peak_memory, |
111 | | - odb_hash[0:20], |
| 131 | + stage_first = True |
| 132 | + for ext, h in hashes: |
| 133 | + print( |
| 134 | + format_str |
| 135 | + % ( |
| 136 | + stem, |
| 137 | + ext, |
| 138 | + elapsedTime if stage_first else "", |
| 139 | + peak_memory if stage_first else "", |
| 140 | + h[0:20], |
| 141 | + ) |
112 | 142 | ) |
113 | | - ) |
| 143 | + stage_first = False |
114 | 144 | if elapsedTime is not None: |
115 | 145 | totalElapsed += elapsedTime |
116 | 146 | if peak_memory is not None: |
117 | 147 | total_max_memory = max(total_max_memory, int(peak_memory)) |
118 | 148 |
|
119 | 149 | if totalElapsed != 0 and not args.match: |
120 | | - print(format_str % ("Total", totalElapsed, total_max_memory, "")) |
| 150 | + print(format_str % ("Total", "", totalElapsed, total_max_memory, "")) |
121 | 151 |
|
122 | 152 |
|
123 | 153 | def scan_logs(args): |
|
0 commit comments