Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/est/include/est/EstimateParasitics.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class EstimateParasitics : public sta::dbStaState, public ParasiticsService
void parasiticsInvalid(const odb::dbNet* net);
void eraseParasitics(const sta::Net* net);
bool parasiticsValid() const;
size_t invalidNetCount() const { return parasitics_invalid_.size(); }

ParasiticsSrc getParasiticsSrc() { return parasitics_src_; }
void setParasiticsSrc(ParasiticsSrc src);
Expand Down
27 changes: 23 additions & 4 deletions src/rsz/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ cc_library(
"src/ConcreteSwapArithModules.cc",
"src/ConcreteSwapArithModules.hh",
"src/DelayEstimator.cc",
"src/DelayEstimatorBufferTree.cc",
"src/DelayEstimatorInternal.hh",
"src/DelayEstimatorReporter.cc",
"src/DelayEstimatorReporter.hh",
"src/LRSubproblem.cc",
"src/LRSubproblem.hh",
"src/MoveCommitter.cc",
"src/MoveTracker.cc",
"src/OdbCallBack.cc",
"src/OptimizationPolicyConfig.cc",
"src/OptimizationPolicyConfig.hh",
"src/Optimizer.cc",
"src/Optimizer.hh",
Expand All @@ -35,7 +38,6 @@ cc_library(
"src/PreChecks.cc",
"src/PreChecks.hh",
"src/Rebuffer.cc",
"src/Rebuffer.hh",
"src/RecoverPower.cc",
"src/RecoverPower.hh",
"src/RepairDesign.cc",
Expand All @@ -45,11 +47,11 @@ cc_library(
"src/RepairSetupProfiler.cc",
"src/RepairTargetCollector.cc",
"src/Resizer.cc",
"src/SequentialTimingEstimator.cc",
"src/SwapArithModules.hh",
"src/move/BufferCandidate.cc",
"src/move/BufferCandidate.hh",
"src/move/BufferGenerator.cc",
"src/move/BufferGenerator.hh",
"src/move/BufferToInvertersCandidate.cc",
"src/move/BufferToInvertersCandidate.hh",
"src/move/BufferToInvertersGenerator.cc",
Expand All @@ -60,6 +62,11 @@ cc_library(
"src/move/CloneGenerator.hh",
"src/move/MoveCandidate.cc",
"src/move/MoveGenerator.cc",
"src/move/RebufferMtCandidate.cc",
"src/move/RebufferMtCandidate.hh",
"src/move/RebufferMtGenerator.cc",
"src/move/RebufferPlannerPool.cc",
"src/move/RebufferPlannerPool.hh",
"src/move/RerouteCandidate.cc",
"src/move/RerouteCandidate.hh",
"src/move/RerouteGenerator.cc",
Expand All @@ -77,9 +84,7 @@ cc_library(
"src/move/SizeUpMatchGenerator.cc",
"src/move/SizeUpMatchGenerator.hh",
"src/move/SizeUpMtCandidate.cc",
"src/move/SizeUpMtCandidate.hh",
"src/move/SizeUpMtGenerator.cc",
"src/move/SizeUpMtGenerator.hh",
"src/move/SplitLoadCandidate.cc",
"src/move/SplitLoadCandidate.hh",
"src/move/SplitLoadGenerator.cc",
Expand All @@ -99,10 +104,13 @@ cc_library(
"src/move/VtSwapMtCandidate.cc",
"src/move/VtSwapMtGenerator.cc",
"src/move/VtSwapMtGenerator.hh",
"src/policy/BatchSelector.cc",
"src/policy/BottleneckAnalysis.cc",
"src/policy/GlobalSizingPolicy.cc",
"src/policy/GlobalSizingPolicy.hh",
"src/policy/OptimizationPolicy.cc",
"src/policy/OptimizationPolicy.hh",
"src/policy/ParallelEvalState.cc",
"src/policy/ProgressReporter.cc",
"src/policy/ProgressReporter.hh",
"src/policy/SetupCritVtSwapPolicy.cc",
Expand All @@ -113,6 +121,7 @@ cc_library(
"src/policy/SetupLastGaspPolicy.hh",
"src/policy/SetupLegacyBase.cc",
"src/policy/SetupLegacyPolicy.cc",
"src/policy/SetupParallelEvalPolicy.cc",
"src/policy/SetupReroutePolicy.cc",
"src/policy/SetupReroutePolicy.hh",
"src/policy/SetupTnsPolicy.cc",
Expand All @@ -129,16 +138,26 @@ cc_library(
"src/MoveCommitter.hh",
"src/MoveTracker.hh",
"src/OptimizerTypes.hh",
"src/Rebuffer.hh",
"src/RepairSetupContext.hh",
"src/RepairSetupProfiler.hh",
"src/RepairTargetCollector.hh",
"src/ResizerObserver.hh",
"src/SequentialTimingEstimator.hh",
"src/move/BufferGenerator.hh",
"src/move/MoveCandidate.hh",
"src/move/MoveGenerator.hh",
"src/move/RebufferMtGenerator.hh",
"src/move/SizeUpMatchGenerator.hh",
"src/move/SizeUpMtCandidate.hh",
"src/move/SizeUpMtGenerator.hh",
"src/move/VtSwapMtCandidate.hh",
"src/policy/BatchSelector.hh",
"src/policy/BottleneckAnalysis.hh",
"src/policy/ParallelEvalState.hh",
"src/policy/SetupLegacyBase.hh",
"src/policy/SetupLegacyPolicy.hh",
"src/policy/SetupParallelEvalPolicy.hh",
],
includes = [
"include",
Expand Down
46 changes: 44 additions & 2 deletions src/rsz/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ repair_timing
[-skip_vt_swap]
[-skip_crit_vt_swap]
[-skip_crpr]
[-effort low|medium|high]
[-profile_mode mode]
[-profile_dir dir]
[-repair_tns tns_end_percent]
[-max_passes passes]
[-max_iterations iterations]
Expand All @@ -259,7 +262,7 @@ repair_timing
| `-hold_margin` | Add additional hold slack margin. |
| `-allow_setup_violations` | While repairing hold violations, buffers are not inserted that will cause setup violations unless `-allow_setup_violations` is specified. |
| `-sequence` | Specify a particular order of setup timing optimization moves. The default is "unbuffer vt_swap sizeup swap buffer clone split". Obeys skip flags also. |
| `-phases` | Specify a particular order of setup timing optimization phases. The default is "LEGACY LAST_GASP CRIT_VT_SWAP". |
| `-phases` | Specify a particular order of setup timing optimization phases. The default is "LEGACY LAST_GASP CRIT_VT_SWAP". The experimental `PARALLEL_EVAL` policy is described in [PARALLEL_EVAL Policy](#parallel_eval-policy). |
| `-path_group` | Restrict setup and hold repair to one path group: `reg2reg`, `in2reg`, `reg2out`, `in2out` or `gated_clock`. Any other name warns and repairs every path group, which is the default. A supported group that the SDC has no `group_path` for is created, so timing reports group paths the same way `repair_timing` optimizes them. |
| `-skip_pin_swap` | Flag to skip pin swap. The default is to perform pin swap transform during setup fixing. |
| `-skip_gate_cloning` | Flag to skip gate cloning. The default is to perform gate cloning transform during setup fixing. |
Expand All @@ -271,8 +274,9 @@ repair_timing
| `-skip_vt_swap` | Flag to skip threshold voltage (VT) swap optimizations. The default is to perform VT swap optimization to improve timing QoR. |
| `-skip_crit_vt_swap` | Flag to skip critical threshold voltage (VT) swap optimizations at the end of optimization. The default is to perform critical VT swap optimization to improve timing QoR beyond repairing just the worst path per each violating endpoint. |
| `-skip_crpr` | Disable Clock Reconvergence Pessimism Removal (CRPR) in clock paths during repair to reduce runtime at the expense of increased area and power. Timing reported during repair excludes CRPR. |
| `-effort` | Optimization effort of the `PARALLEL_EVAL` policy: `low`, `medium` or `high` (default). `low` stops when the batches stall and skips the WNS tail on the worst endpoints. `medium` declares the batch stall after half as many batches, asks twice the progress to reset it, and gives the WNS tail a quarter of the maximum tail endpoints and a quarter of the work budget of `high`. `high` runs the full tail. Other policies ignore the option, and `repair_timing` warns when `-phases` does not list `PARALLEL_EVAL`. |
| `-repair_tns` | Percentage of violating endpoints to repair (0-100). When `tns_end_percent` is zero, only the worst endpoint is repaired. When `tns_end_percent` is 100 (default), all violating endpoints are repaired. |
| `-profile_mode` | Setup repair profiler level: `0` (default) writes nothing, `1` records the WNS/TNS trajectory, `2` adds the pass events. Each `repair_timing -setup` call writes one `run_N` directory under `-profile_dir`. |
| `-profile_mode` | Setup repair profiler level: `0` (default) writes nothing, `1` records the WNS/TNS trajectory, `2` adds the pass and batch events. Each `repair_timing -setup` call writes one `run_N` directory under `-profile_dir`. |
| `-profile_dir` | Directory of the profiler output; the default is `repair_setup_profile` under the current directory. |
| `-max_repairs_per_pass` | Maximum repairs per pass, default is 1. On the worst paths, the maximum number of repairs is attempted. It gradually decreases until the final violations which only get 1 repair per pass. |
| `-max_utilization` | Defines the percentage of core area used. |
Expand Down Expand Up @@ -309,6 +313,44 @@ Use`-recover_power` to specify the percent of paths with positive slack which
will be considered for gate resizing to save power. It is recommended that
this option be used with global routing based parasitics.

#### PARALLEL_EVAL Policy

`-phases PARALLEL_EVAL` repairs setup timing in batches: worker threads
estimate the moves of many targets at once, the non-conflicting moves with the
best estimates are committed as one batch, and one timing update judges the
batch against its checkpoint. Batches stop when they stall, and a WNS tail
then works on the worst endpoints one batch at a time. The policy differs from
`LEGACY` in these ways:

- Threads: `set_thread_count` gives the policy its workers (the thread count
minus one). The result does not depend on the thread count. Endpoint scans
of 4096 endpoints or more also run on the workers. Buffer tree planning on
the workers counts its warnings instead of logging them, and the phase ends
with one warning that lists the counts; a single-thread run logs each one.
- Area: a batch that leaves the design above `-max_utilization` is undone,
and the first such batch prints a warning. The design area counts the
standard cells, not macros or fillers. Without `-max_utilization` there is
no area limit, as in `LEGACY`.
- Iterations: `-max_iterations` counts batches, the WNS tail included.
- Retries: an instance in three undone batches is not tried again in the
run, the WNS tail included.
- Progress: without `-verbose` the progress table prints the first and the
final row only; `-verbose` prints a row per batch.
- Effort: `-effort` tunes the stall and WNS tail limits.
- Moves: `-sequence` lists the moves of the batches; the default is
`vt_swap sizeup buffer`, and the `-skip_*` options apply. Buffering plans
up to three buffer trees per driver with fewer than 20 loads.
- Endpoints: `-repair_tns` limits each batch to that share of the violating
endpoints, as `LEGACY` limits the endpoints it repairs.
- Path groups: under `-path_group` a batch is judged by the group's WNS and
TNS, as in `LEGACY`. The paths beside a move are still kept above the
design's worst slack, whatever group they belong to.
- No effect: `-max_passes` and `-max_repairs_per_pass` drive the
per-endpoint policies only; `repair_timing` warns when they are given and
`-phases` lists only `PARALLEL_EVAL`.
- Profiling: `-profile_mode` records the batch decisions under
`-profile_dir`.

#### Instance Name Prefixes

`repair_timing` uses the following prefixes for the buffer and gate instances that it inserts:
Expand Down
6 changes: 5 additions & 1 deletion src/rsz/doc/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ owned by `Resizer` / `dbNetwork`, not by individual `Target` objects.
|---|---|---|
| Swappable-cell cache | SizeUp and SizeUpMt candidate selection | Avoid repeated `getSwappableCells()` and VT metadata work. |
| VT-equivalent-cell cache | VtSwap and VtSwapMt candidate selection | Avoid repeated `getVTEquivCells()` and VT metadata work. |
| Driver-pin cache | MT max-cap checks | Force `dbNetwork::drivers()` lazy cache population on the caller thread before worker-side checks. |

The prewarm stage is a pragmatic guard for experimental MT policies. Some APIs
look read-only from the caller but can populate internal caches on first use.
Expand Down Expand Up @@ -544,6 +543,11 @@ Current generator/candidate families:

- Currently, only VtSwap and SizeUp moves have simple multi-threading versions, which should be enhanced further.

A generator that keeps state per worker thread sets it up in `startPhase()`,
which learns the worker count, and releases it in `finishPhase()`.
`PARALLEL_EVAL` calls both on the main thread from its `start()` and
`finish()`; the default keeps no state.

## Threading Model

`utl::ThreadPool` was added as a common utility, not an rsz-local class.
Expand Down
44 changes: 44 additions & 0 deletions src/rsz/include/rsz/Resizer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ enum class MoveType : uint8_t
kCount
};

// How long repair_timing -setup keeps working once WNS and TNS converge.
// Only PARALLEL_EVAL reads it: low skips the WNS tail, medium stalls the
// batches and the tail sooner, and high runs the full tail.
enum class RepairEffort : uint8_t
{
kLow,
kMedium,
kHigh
};

// Voltage Threshold (VT) category identifier
struct VTCategory
{
Expand Down Expand Up @@ -187,6 +197,7 @@ struct LibraryAnalysisData

class OdbCallBack;

// Owns timing-driven netlist repair and its OpenDB/STA services.
class Resizer : public sta::dbStaState, public sta::dbNetworkObserver
{
public:
Expand Down Expand Up @@ -371,6 +382,7 @@ class Resizer : public sta::dbStaState, public sta::dbNetworkObserver
bool skip_last_gasp,
bool skip_vt_swap,
bool skip_crit_vt_swap,
RepairEffort effort = RepairEffort::kHigh,
int profile_mode = 0,
const char* profile_dir = "");
// For testing.
Expand Down Expand Up @@ -564,6 +576,8 @@ class Resizer : public sta::dbStaState, public sta::dbNetworkObserver
void setDebugGraphics(std::shared_ptr<ResizerObserver> graphics);

static std::vector<MoveType> parseMoveSequence(const std::string& sequence);
// "low" or "medium"; anything else is the default, high.
static RepairEffort repairEffortFromString(const std::string& effort);
void fullyRebuffer(sta::Pin* pin);

bool hasFanout(sta::Vertex* drvr);
Expand Down Expand Up @@ -897,6 +911,34 @@ class Resizer : public sta::dbStaState, public sta::dbNetworkObserver
const sta::LibertyCell* replacement);
bool checkMaxCapOK(const sta::Pin* drvr_pin, float cap_delta);

// One driver's current load, cap limit, and violation state.
struct DriverCapLimit
{
// Total load currently driven on this net.
float cap{0.0f};
// Effective max-cap limit for this driver.
float max_cap{0.0f};
// True when the driver's current max-cap check has negative slack.
bool negative_slack{false};
};

// Cached fanin max-cap headroom for one input pin of a candidate cell.
struct InputCapBudget
{
// Current cell's Liberty input port matched to candidate ports.
const sta::LibertyPort* port{nullptr};
// Input capacitance of that current port.
float current_cap{0.0f};
// Limits for all drivers that STA associates with the input net.
std::vector<DriverCapLimit> driver_limits;
};

// Capture fanin max-cap state once before screening equivalent cells.
std::vector<InputCapBudget> inputCapBudgets(sta::Instance* inst);
// Test a replacement using captured headroom without new STA queries.
bool replacementFitsInputCapBudgets(
const std::vector<InputCapBudget>& budgets,
const sta::LibertyCell* replacement) const;
bool estimateInputSlewImpact(
sta::Instance* instance,
const sta::Scene* scene,
Expand Down Expand Up @@ -957,6 +999,8 @@ class Resizer : public sta::dbStaState, public sta::dbNetworkObserver
void journalRestore();
void journalMakeBuffer(sta::Instance* buffer);
void initForJournalRestore();
// An ECO undo skips the incremental area updates of the undone edits.
void recountDesignAreaAfterUndo();
void updateParasiticsAndTiming();
void invalidateParasitics(sta::Net* net);
void addAcceptedLegacyMoveCount(int count);
Expand Down
10 changes: 10 additions & 0 deletions src/rsz/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,22 @@ add_library(rsz_lib
policy/ProgressReporter.cc
Optimizer.cc
OptimizerTypes.cc
OptimizationPolicyConfig.cc
DelayEstimator.cc
DelayEstimatorBufferTree.cc
DelayEstimatorReporter.cc
SequentialTimingEstimator.cc
LRSubproblem.cc
policy/SetupCritVtSwapPolicy.cc
policy/SetupDirectionalPolicy.cc
policy/SetupLastGaspPolicy.cc
policy/SetupLegacyPolicy.cc
policy/SetupTnsPolicy.cc
policy/SetupWnsPolicy.cc
policy/BottleneckAnalysis.cc
policy/BatchSelector.cc
policy/ParallelEvalState.cc
policy/SetupParallelEvalPolicy.cc
policy/SetupReroutePolicy.cc
policy/GlobalSizingPolicy.cc
Resizer.cc
Expand All @@ -51,6 +58,9 @@ add_library(rsz_lib
move/CloneGenerator.cc
move/MoveCandidate.cc
move/MoveGenerator.cc
move/RebufferMtCandidate.cc
move/RebufferMtGenerator.cc
move/RebufferPlannerPool.cc
move/RerouteCandidate.cc
move/RerouteGenerator.cc
move/SizeDownFanoutCandidate.cc
Expand Down
Loading
Loading