Skip to content

Commit 6005dbe

Browse files
authored
Merge pull request #4841 from oharboe/write-on-failure
flow: write <step>-failed.odb/.sdc when any step fails, drop the per-call catches
2 parents 16b87d0 + f36f7e1 commit 6005dbe

14 files changed

Lines changed: 73 additions & 48 deletions

‎docs/contrib/EndpointSlackTracking.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ Every step then writes `$(REPORTS_DIR)/<step>_endpoint_slack.json`, e.g.
2424
It works in the single-process `flow/scripts/flow.tcl` flow as well. Steps
2525
that just copy their input (`orfs_copy_db`, e.g. `5_3_fillcell` without fill
2626
cells) re-time the design if it is loaded, or else copy the previous step's
27-
snapshot. Intermediate `.odb` files written through `orfs_write_db` (e.g. CTS's
28-
`4_1_error.odb`) also get a snapshot; `*-failed` ones don't.
27+
snapshot. Intermediate `.odb` files written through `orfs_write_db` also get
28+
a snapshot; the `<step>-failed.odb` that `run_step.tcl` writes does not.
2929

3030
A placed step is timed with the parasitics OpenROAD has for it: a bare
3131
`estimate_parasitics` estimates from the global routes when there are any,

‎docs/contrib/MakefileContract.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ Several of the rules exist for them.
7979
variable and is recorded.
8080
*Breaks:* caching a step's result, the QoR check against a baseline, and
8181
bisecting a regression.
82-
- **A failing step never calls `exit`.** It writes `<step>-failed.odb` and
83-
calls `error`, as `flow/scripts/global_place.tcl` does.
82+
- **A failing step never calls `exit`.** It calls `error`, and
83+
`flow/scripts/run_step.tcl` writes `<step>-failed.odb` and `.sdc`
84+
(`WRITE_ON_FAILURE`).
8485
*Breaks:* the log and the exit status stop saying where the step failed,
8586
and there is no checkpoint to inspect.
8687
- **A `PRE_<STEP>_TCL` hook never runs before the design is loaded.** Hooks

‎docs/contrib/TclContract.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ to follow.
7070
*Breaks:* the guard is a code path no CI run exercises, and a missing
7171
variable or file shows up later, somewhere else, as a wrong result.
7272
- **A failing step never writes the file a successful step writes.** It
73-
writes `<step>-failed.odb` and calls `error`, as
74-
`flow/scripts/global_place.tcl` does.
73+
calls `error`, and `flow/scripts/run_step.tcl` writes
74+
`<step>-failed.odb` and `.sdc` (`WRITE_ON_FAILURE`).
7575
*Breaks:* make, and any flow built on it, takes the file as proof that the
7676
step succeeded.
7777
- **A script never adds error numbers or checks that belong in OpenROAD.**

‎docs/user/FlowVariables.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ configuration file.
350350
| <a name="VIA_IN_PIN_MIN_LAYER"></a>VIA_IN_PIN_MIN_LAYER| Passed as -via_in_pin_bottom_layer to pin_access and detailed_route.| |
351351
| <a name="WIRE_LOAD_MODEL"></a>WIRE_LOAD_MODEL| Name of a Liberty wire_load group applied with set_wire_load_model whenever open.tcl reads timing. OpenSTA applies a wire-load model only to nets without parasitics, so it gives wire delay to timing read before placement and leaves placed and routed timing unaffected. An unknown name is an error. Empty, the default, applies none. A platform whose libraries define no wire_load group can supply one in a Liberty file listed in ADDITIONAL_LIBS.| |
352352
| <a name="WRITE_ODB_AND_SDC_EACH_STAGE"></a>WRITE_ODB_AND_SDC_EACH_STAGE| Save out .sdc and .odb file after each stage, useful to disable when using a single OpenROAD instance to run all stages of the flow.| 1|
353+
| <a name="WRITE_ON_FAILURE"></a>WRITE_ON_FAILURE| If set to 1, a step that fails writes the design as it was at the failure to $RESULTS_DIR/<step>-failed.odb and .sdc, then fails with the original error. `make web_<step>-failed.odb` opens it, e.g. `make web_3_3_place_gp-failed.odb`. Set to 0 where writing a large design on failure costs too much time or disk.| 1|
353354
| <a name="YOSYS_FLAGS"></a>YOSYS_FLAGS| Flags to pass to yosys.| -v 3|
354355
## synth variables
355356

@@ -673,6 +674,7 @@ configuration file.
673674
- [SWAP_ARITH_OPERATORS](#SWAP_ARITH_OPERATORS)
674675
- [SYNTH_WRAPPED_OPERATORS](#SYNTH_WRAPPED_OPERATORS)
675676
- [WRITE_ODB_AND_SDC_EACH_STAGE](#WRITE_ODB_AND_SDC_EACH_STAGE)
677+
- [WRITE_ON_FAILURE](#WRITE_ON_FAILURE)
676678

677679
## generate_abstract variables
678680

‎flow/Makefile‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,6 @@ web_$(1):
387387
$(2)=$(RESULTS_DIR)/$(1) $(OPENROAD_WEB_CMD) $(SCRIPTS_DIR)/open.tcl
388388
endef
389389

390-
# Enables "make gui_5_1_grt-failed"
391-
$(eval $(call OPEN_GUI_SHORTCUT,5_1_grt-failed,5_1_grt-failed.odb))
392-
393390
# Separate dependency checking and doing a step. This can
394391
# be useful to retest a stage without having to delete the
395392
# target, or when building a wafer thin layer on top of
@@ -425,6 +422,9 @@ ifeq ($(if $(4),$(4),.odb),.odb)
425422
$(1): $(RESULTS_DIR)/$(1).odb
426423

427424
$(eval $(call OPEN_GUI_SHORTCUT,$(1),$(1).odb))
425+
# "make gui_<step>-failed" opens the checkpoint run_step.tcl writes when
426+
# the step fails
427+
$(eval $(call OPEN_GUI_SHORTCUT,$(1)-failed,$(1)-failed.odb))
428428
endif
429429

430430
.PHONY: do-$(1)

‎flow/scripts/cts.tcl‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@ set_placement_padding -global \
4040
-left $::env(CELL_PAD_IN_SITES_DETAIL_PLACEMENT) \
4141
-right $::env(CELL_PAD_IN_SITES_DETAIL_PLACEMENT)
4242

43-
set result [catch { detailed_placement_helper -quiet } msg]
44-
if { $result != 0 } {
45-
orfs_write_db $::env(RESULTS_DIR)/4_1_error.odb
46-
error "Detailed placement failed in CTS: $msg"
47-
}
43+
detailed_placement_helper -quiet
4844

4945
log_cmd estimate_parasitics
5046

@@ -61,11 +57,7 @@ if { !$::env(SKIP_CTS_REPAIR_TIMING) } {
6157
run_lec_test 4_rsz 4_before_rsz_lec.v 4_after_rsz_lec.v
6258
}
6359

64-
set result [catch { detailed_placement_helper -quiet } msg]
65-
if { $result != 0 } {
66-
orfs_write_db $::env(RESULTS_DIR)/4_1_error.odb
67-
error "Detailed placement failed in CTS: $msg"
68-
}
60+
detailed_placement_helper -quiet
6961

7062
log_cmd check_placement -placeable -verbose
7163

‎flow/scripts/detail_place.tcl‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@ proc do_dpl { } {
2929
log_cmd estimate_parasitics
3030
}
3131

32-
set result [catch { do_dpl } errMsg]
33-
if { $result != 0 } {
34-
orfs_write_db $::env(RESULTS_DIR)/3_5_place_dp-failed.odb
35-
error $errMsg
36-
}
32+
do_dpl
3733

3834
report_metrics 3 "detailed place" true false
3935

‎flow/scripts/flow.sh‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,19 @@ RUN_CMD="${RUN_CMD:-$PYTHON_EXE $SCRIPTS_DIR/run_command.py}"
1010

1111
echo "Running $2.tcl, stage $1"
1212

13+
# A failure checkpoint left by an earlier run of this step is stale.
14+
rm -f "$RESULTS_DIR/$1-failed.odb" "$RESULTS_DIR/$1-failed.sdc"
15+
1316
(
1417
trap 'mv "$LOG_DIR/$1.tmp.log" "$LOG_DIR/$1.log"' EXIT
18+
export STEP_NAME="$1"
19+
export STEP_TCL="$SCRIPTS_DIR/$2.tcl"
1520

1621
eval "$OPENROAD_EXE $OPENROAD_ARGS -exit \"$SCRIPTS_DIR/noop.tcl\"" \
1722
>"$LOG_DIR/$1.tmp.log" 2>&1
1823

1924
$RUN_CMD --log "$(realpath "$LOG_DIR/$1.tmp.log")" --append --tee -- \
20-
$OPENROAD_CMD -no_splash "$SCRIPTS_DIR/$2.tcl" -metrics "$LOG_DIR/$1.json"
25+
$OPENROAD_CMD -no_splash "$SCRIPTS_DIR/run_step.tcl" -metrics "$LOG_DIR/$1.json"
2126
)
2227

2328
# Log the hash for this step. The summary "make elapsed" in "make finish",

‎flow/scripts/global_place.tcl‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,10 @@ proc do_placement { global_placement_args } {
6868
log_cmd global_placement {*}$all_args
6969
}
7070

71-
set result [catch { do_placement $global_placement_args } errMsg]
71+
do_placement $global_placement_args
7272
if { $place_ios } {
7373
log_cmd reset_place_config
7474
}
75-
if { $result != 0 } {
76-
orfs_write_db $::env(RESULTS_DIR)/3_3_place_gp-failed.odb
77-
error $errMsg
78-
}
7975

8076
log_cmd estimate_parasitics
8177

‎flow/scripts/global_route.tcl‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@ proc set_grt_seed { } {
2727
}
2828
}
2929

30-
proc run_global_route_and_catch_failures { args } {
31-
if { [catch { log_cmd global_route {*}$args } errMsg] } {
32-
log_cmd write_db $::env(RESULTS_DIR)/5_1_grt-failed.odb
33-
log_cmd write_sdc -no_timestamp $::env(RESULTS_DIR)/5_1_grt-failed.sdc
34-
error $errMsg
35-
}
36-
}
37-
3830
proc do_global_route { res_aware use_cugr } {
3931
set_grt_seed
4032
# CUGR runs a full 3D maze pass per iteration; use a tighter default.
@@ -46,7 +38,7 @@ proc do_global_route { res_aware use_cugr } {
4638
-congestion_report_file $::global_route_congestion_report] \
4739
$cong_iters $::env(GLOBAL_ROUTE_ARGS) {*}$res_aware {*}$use_cugr]
4840

49-
run_global_route_and_catch_failures {*}$all_args
41+
log_cmd global_route {*}$all_args
5042
}
5143
set additional_args ""
5244
append_env_var additional_args dbProcessNode -db_process_node 1
@@ -86,7 +78,7 @@ if { !$::env(SKIP_INCREMENTAL_REPAIR) } {
8678
log_cmd global_route -start_incremental {*}$allow_congestion
8779
detailed_placement_helper -quiet
8880
# Route only the modified net by DPL
89-
run_global_route_and_catch_failures -end_incremental {*}$res_aware \
81+
log_cmd global_route -end_incremental {*}$res_aware \
9082
{*}$allow_congestion \
9183
-congestion_report_file $::env(REPORTS_DIR)/congestion_post_repair_design.rpt
9284
utl::pop_metrics_stage
@@ -106,7 +98,7 @@ if { !$::env(SKIP_INCREMENTAL_REPAIR) } {
10698
detailed_placement_helper -quiet
10799
log_cmd check_placement -placeable -verbose
108100
# Route only the modified net by DPL
109-
run_global_route_and_catch_failures -end_incremental {*}$res_aware \
101+
log_cmd global_route -end_incremental {*}$res_aware \
110102
{*}$allow_congestion \
111103
-congestion_report_file $::env(REPORTS_DIR)/congestion_post_repair_timing.rpt
112104
utl::pop_metrics_stage
@@ -135,7 +127,7 @@ if { !$::env(OPT_POST_GRT_WNS) } {
135127
log_cmd global_route -start_incremental {*}$allow_congestion
136128
recover_power_helper
137129
# Route the modified nets by rsz journal restore
138-
run_global_route_and_catch_failures -end_incremental {*}$res_aware \
130+
log_cmd global_route -end_incremental {*}$res_aware \
139131
{*}$allow_congestion \
140132
-congestion_report_file $::env(REPORTS_DIR)/congestion_post_recover_power.rpt
141133
utl::pop_metrics_stage

0 commit comments

Comments
 (0)