Skip to content

Commit

Permalink
thread issues
Browse files Browse the repository at this point in the history
Signed-off-by: James Cherry <[email protected]>
  • Loading branch information
jjcherry56 committed Nov 8, 2024
1 parent 23eccdd commit b4be3c5
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 22 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,8 @@ set(CXX_FLAGS -Wall -Wextra -pedantic -Wcast-qual -Wredundant-decls -Wformat-sec

if(USE_SANITIZE)
message(STATUS "Sanitize: ${USE_SANITIZE}")
set(CXX_FLAGS "${CXX_FLAGS};-fsanitize=address;-fno-omit-frame-pointer;-fno-common")
set(CMAKE_EXE_LINKER_FLAGS "-fsanitize=address")
set(CXX_FLAGS "${CXX_FLAGS};-fsanitize=thread")
set(CMAKE_EXE_LINKER_FLAGS "-fsanitize=thread")
endif()

target_compile_options(OpenSTA
Expand Down
2 changes: 2 additions & 0 deletions include/sta/Search.hh
Original file line number Diff line number Diff line change
Expand Up @@ -583,12 +583,14 @@ protected:
// Entries in tags_ may be missing where previous filter tags were deleted.
TagIndex tag_capacity_;
Tag **tags_;
Tag **tags_prev_;
TagIndex tag_next_;
// Holes in tags_ left by deleting filter tags.
std::vector<TagIndex> tag_free_indices_;
std::mutex tag_lock_;
TagGroupSet *tag_group_set_;
TagGroup **tag_groups_;
TagGroup **tag_groups_prev_;
TagGroupIndex tag_group_next_;
// Holes in tag_groups_ left by deleting filter tag groups.
std::vector<TagIndex> tag_group_free_indices_;
Expand Down
2 changes: 1 addition & 1 deletion parasitics/ConcreteParasitics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -946,9 +946,9 @@ ConcreteParasitics::findPiElmore(const Pin *drvr_pin,
const RiseFall *rf,
const ParasiticAnalysisPt *ap) const
{
LockGuard lock(lock_);
if (!drvr_parasitic_map_.empty()) {
int ap_rf_index = parasiticAnalysisPtIndex(ap, rf);
LockGuard lock(lock_);
ConcreteParasitic **parasitics = drvr_parasitic_map_.findKey(drvr_pin);
if (parasitics) {
ConcreteParasitic *parasitic = parasitics[ap_rf_index];
Expand Down
11 changes: 8 additions & 3 deletions search/PathGroup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,25 +95,30 @@ PathGroup::~PathGroup()
bool
PathGroup::savable(PathEnd *path_end)
{
float threshold;
{
LockGuard lock(lock_);
threshold = threshold_;
}
bool savable = false;
if (compare_slack_) {
// Crpr increases the slack, so check the slack
// without crpr first because it is expensive to find.
Slack slack = path_end->slackNoCrpr(sta_);
if (!delayIsInitValue(slack, min_max_)
&& delayLessEqual(slack, threshold_, sta_)
&& delayLessEqual(slack, threshold, sta_)
&& delayLessEqual(slack, slack_max_, sta_)) {
// Now check with crpr.
slack = path_end->slack(sta_);
savable = delayLessEqual(slack, threshold_, sta_)
savable = delayLessEqual(slack, threshold, sta_)
&& delayLessEqual(slack, slack_max_, sta_)
&& delayGreaterEqual(slack, slack_min_, sta_);
}
}
else {
const Arrival &arrival = path_end->dataArrivalTime(sta_);
savable = !delayIsInitValue(arrival, min_max_)
&& delayGreaterEqual(arrival, threshold_, min_max_, sta_);
&& delayGreaterEqual(arrival, threshold, min_max_, sta_);
}
return savable;
}
Expand Down
36 changes: 20 additions & 16 deletions search/Search.cc
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,10 @@ Search::init(StaState *sta)
clk_info_set_ = new ClkInfoSet(ClkInfoLess(sta));
tag_next_ = 0;
tags_ = new Tag*[tag_capacity_];
tags_prev_ = nullptr;
tag_group_capacity_ = 127;
tag_groups_ = new TagGroup*[tag_group_capacity_];
tag_groups_prev_ = nullptr;
tag_group_next_ = 0;
tag_group_set_ = new TagGroupSet(tag_group_capacity_);
pending_latch_outputs_ = new VertexSet(graph_);
Expand Down Expand Up @@ -270,7 +272,9 @@ Search::~Search()
delete tag_set_;
delete clk_info_set_;
delete [] tags_;
delete [] tags_prev_;
delete [] tag_groups_;
delete [] tag_groups_prev_;
delete tag_group_set_;
delete search_adj_;
delete eval_pred_;
Expand Down Expand Up @@ -2647,15 +2651,15 @@ Search::findTagGroup(TagGroupBldr *tag_bldr)
// std::vector doesn't seem to follow this protocol so multi-thread
// search fails occasionally if a vector is used for tag_groups_.
if (tag_group_next_ == tag_group_capacity_) {
TagGroupIndex new_capacity = nextMersenne(tag_group_capacity_);
TagGroup **new_tag_groups = new TagGroup*[new_capacity];
memcpy(new_tag_groups, tag_groups_,
TagGroupIndex tag_capacity = tag_group_capacity_ * 2;
TagGroup **tag_groups = new TagGroup*[tag_capacity];
memcpy(tag_groups, tag_groups_,
tag_group_capacity_ * sizeof(TagGroup*));
TagGroup **old_tag_groups = tag_groups_;
tag_groups_ = new_tag_groups;
tag_group_capacity_ = new_capacity;
delete [] old_tag_groups;
tag_group_set_->reserve(new_capacity);
delete [] tag_groups_prev_;
tag_groups_prev_ = tag_groups_;
tag_groups_ = tag_groups;
tag_group_capacity_ = tag_capacity;
tag_group_set_->reserve(tag_capacity);
}
if (tag_group_next_ > tag_group_index_max)
report_->critical(1510, "max tag group index exceeded");
Expand Down Expand Up @@ -2888,14 +2892,14 @@ Search::findTag(const RiseFall *rf,
// std::vector doesn't seem to follow this protocol so multi-thread
// search fails occasionally if a vector is used for tags_.
if (tag_next_ == tag_capacity_) {
TagIndex new_capacity = nextMersenne(tag_capacity_);
Tag **new_tags = new Tag*[new_capacity];
memcpy(new_tags, tags_, tag_capacity_ * sizeof(Tag*));
Tag **old_tags = tags_;
tags_ = new_tags;
delete [] old_tags;
tag_capacity_ = new_capacity;
tag_set_->reserve(new_capacity);
TagIndex tag_capacity = tag_capacity_ * 2;
Tag **tags = new Tag*[tag_capacity];
memcpy(tags, tags_, tag_capacity_ * sizeof(Tag*));
delete [] tags_prev_;
tags_prev_ = tags_;
tags_ = tags;
tag_capacity_ = tag_capacity;
tag_set_->reserve(tag_capacity);
}
if (tag_next_ == tag_index_max)
report_->critical(1511, "max tag index exceeded");
Expand Down

0 comments on commit b4be3c5

Please sign in to comment.