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
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,16 @@ if { ![catch {package require tclreadline}] } {
The Zlib library is an optional. If CMake finds libz, OpenSTA can
read Liberty, Verilog, SDF, SPF, and SPEF files compressed with gzip.

CUDD is a binary decision diageram (BDD) package that is used to
improve conditional timing arc handling, constant propagation, power
activity propagation and spice netlist generation.
[CUDD](https://github.com/cuddorg/cudd) is a binary decision diagram (BDD)
package that is used to improve conditional timing arc handling, constant
propagation, power activity propagation and spice netlist generation.

CUDD is available
[here](https://github.com/davidkebo/cudd/blob/main/cudd_versions/cudd-3.0.0.tar.gz).

Unpack and build CUDD.
Download and build CUDD:

```
tar xvfz cudd-3.0.0.tar.gz
cd cudd-3.0.0
git clone https://github.com/cuddorg/cudd.git
cd cudd
git checkout 3.0.0
./configure
make
```
Expand Down
1 change: 1 addition & 0 deletions cmake/FindTCL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ if (NOT TCL_LIB_PATHS)
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(TCL_LIB_PATHS
#/opt/homebrew/Cellar/tcl-tk/9.0.3/lib
/opt/homebrew/Cellar/tcl-tk@8/8.6.18/lib
/opt/homebrew/Cellar/tcl-tk@8/8.6.17/lib
/opt/homebrew/Cellar/tcl-tk@8/8.6.16/lib
/opt/homebrew/opt/tcl-tk/lib /usr/local/lib)
Expand Down
9 changes: 0 additions & 9 deletions include/sta/Hash.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#pragma once

#include <cstddef>
#include <cstdint>
#include <string_view>

namespace sta {
Expand Down Expand Up @@ -59,12 +58,4 @@ nextMersenne(size_t n)
size_t
hashString(std::string_view str);

// Pointer hashing is strongly discouraged because it causes results to change
// from run to run. Use Network::id functions instead.
#if __WORDSIZE == 64
#define hashPtr(ptr) (reinterpret_cast<intptr_t>(ptr) >> 3)
#else
#define hashPtr(ptr) (reinterpret_cast<intptr_t>(ptr) >> 2)
#endif

} // namespace sta
4 changes: 4 additions & 0 deletions include/sta/Sta.hh
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,10 @@ public:
const MinMaxAll *min_max,
const RiseFallBoth *rf,
float slew);
void unsetAnnotatedSlew(Vertex *vertex,
const Scene *scene,
const MinMaxAll *min_max,
const RiseFallBoth *rf);
void writeSdf(std::string_view filename,
const Scene *scene,
char divider,
Expand Down
28 changes: 26 additions & 2 deletions search/Sta.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3900,7 +3900,6 @@ Sta::setAnnotatedSlew(Vertex *vertex,
const RiseFallBoth *rf,
float slew)
{
ensureGraph();
for (const MinMax *mm : min_max->range()) {
DcalcAPIndex ap_index = scene->dcalcAnalysisPtIndex(mm);
for (const RiseFall *rf1 : rf->range()) {
Expand All @@ -3912,6 +3911,24 @@ Sta::setAnnotatedSlew(Vertex *vertex,
graph_delay_calc_->delayInvalid(vertex);
}

void
Sta::unsetAnnotatedSlew(Vertex *vertex,
const Scene *scene,
const MinMaxAll *min_max,
const RiseFallBoth *rf)
{
for (const MinMax *mm : min_max->range()) {
DcalcAPIndex ap_index = scene->dcalcAnalysisPtIndex(mm);
for (const RiseFall *rf1 : rf->range()) {
vertex->setSlewAnnotated(false, rf1, ap_index);
}
}
if (vertex->isDriver(network_))
graph_delay_calc_->delayInvalid(vertex);
else
delaysInvalidFromFanin(vertex);
}

void
Sta::writeSdf(std::string_view filename,
const Scene *scene,
Expand Down Expand Up @@ -4316,8 +4333,15 @@ Parasitics *
Sta::makeConcreteParasitics(std::string_view name,
std::string_view filename)
{
// Free the prior entry to avoid leaking it on overwrite.
std::string key(name);
auto it = parasitics_name_map_.find(key);
if (it != parasitics_name_map_.end()) {
delete it->second;
parasitics_name_map_.erase(it);
}
Parasitics *parasitics = new ConcreteParasitics(name, filename, this);
parasitics_name_map_[std::string(name)] = parasitics;
parasitics_name_map_[key] = parasitics;
return parasitics;
Comment on lines +4336 to 4345

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Instead of erasing the old entry and inserting a new one, you can directly update the pointer of the existing map node. Since parasitics_name_map_ uses std::less<> as a transparent comparator, you can also search using std::string_view directly without allocating a temporary std::string key. This avoids rebalancing the map's red-black tree twice and avoids unnecessary string allocations.

  auto it = parasitics_name_map_.find(name);
  if (it != parasitics_name_map_.end()) {
    delete it->second;
    it->second = new ConcreteParasitics(name, filename, this);
    return it->second;
  }
  Parasitics *parasitics = new ConcreteParasitics(name, filename, this);
  parasitics_name_map_[std::string(name)] = parasitics;
  return parasitics;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot do this as it doesn't preserve the filename. It was already pointed by upstream OpenSTA developer that Gemini suggested change is incorrect

}

Expand Down
Empty file.
9 changes: 9 additions & 0 deletions test/make_concrete_parasitics_leak.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Sta::makeConcreteParasitics map-overwrite leak repro.
# Run under -fsanitize=address to verify no leak after the fix.
read_liberty asap7_small.lib.gz
read_verilog reg1_asap7.v
link_design top
# 1st read_spef
read_spef -min reg1_asap7.spef
# 2nd read_spef
read_spef -min reg1_asap7.spef
1 change: 1 addition & 0 deletions test/regression_vars.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ record_public_tests {
liberty_ccsn
liberty_float_as_str
liberty_latch3
make_concrete_parasitics_leak
package_require
path_group_names
power_json
Expand Down