thread issues

Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
James Cherry 2024-11-07 17:18:27 -08:00
parent 23eccdd467
commit b4be3c537a
5 changed files with 33 additions and 22 deletions

View File

@ -562,8 +562,8 @@ set(CXX_FLAGS -Wall -Wextra -pedantic -Wcast-qual -Wredundant-decls -Wformat-sec
if(USE_SANITIZE) if(USE_SANITIZE)
message(STATUS "Sanitize: ${USE_SANITIZE}") message(STATUS "Sanitize: ${USE_SANITIZE}")
set(CXX_FLAGS "${CXX_FLAGS};-fsanitize=address;-fno-omit-frame-pointer;-fno-common") set(CXX_FLAGS "${CXX_FLAGS};-fsanitize=thread")
set(CMAKE_EXE_LINKER_FLAGS "-fsanitize=address") set(CMAKE_EXE_LINKER_FLAGS "-fsanitize=thread")
endif() endif()
target_compile_options(OpenSTA target_compile_options(OpenSTA

View File

@ -583,12 +583,14 @@ protected:
// Entries in tags_ may be missing where previous filter tags were deleted. // Entries in tags_ may be missing where previous filter tags were deleted.
TagIndex tag_capacity_; TagIndex tag_capacity_;
Tag **tags_; Tag **tags_;
Tag **tags_prev_;
TagIndex tag_next_; TagIndex tag_next_;
// Holes in tags_ left by deleting filter tags. // Holes in tags_ left by deleting filter tags.
std::vector<TagIndex> tag_free_indices_; std::vector<TagIndex> tag_free_indices_;
std::mutex tag_lock_; std::mutex tag_lock_;
TagGroupSet *tag_group_set_; TagGroupSet *tag_group_set_;
TagGroup **tag_groups_; TagGroup **tag_groups_;
TagGroup **tag_groups_prev_;
TagGroupIndex tag_group_next_; TagGroupIndex tag_group_next_;
// Holes in tag_groups_ left by deleting filter tag groups. // Holes in tag_groups_ left by deleting filter tag groups.
std::vector<TagIndex> tag_group_free_indices_; std::vector<TagIndex> tag_group_free_indices_;

View File

@ -946,9 +946,9 @@ ConcreteParasitics::findPiElmore(const Pin *drvr_pin,
const RiseFall *rf, const RiseFall *rf,
const ParasiticAnalysisPt *ap) const const ParasiticAnalysisPt *ap) const
{ {
LockGuard lock(lock_);
if (!drvr_parasitic_map_.empty()) { if (!drvr_parasitic_map_.empty()) {
int ap_rf_index = parasiticAnalysisPtIndex(ap, rf); int ap_rf_index = parasiticAnalysisPtIndex(ap, rf);
LockGuard lock(lock_);
ConcreteParasitic **parasitics = drvr_parasitic_map_.findKey(drvr_pin); ConcreteParasitic **parasitics = drvr_parasitic_map_.findKey(drvr_pin);
if (parasitics) { if (parasitics) {
ConcreteParasitic *parasitic = parasitics[ap_rf_index]; ConcreteParasitic *parasitic = parasitics[ap_rf_index];

View File

@ -95,17 +95,22 @@ PathGroup::~PathGroup()
bool bool
PathGroup::savable(PathEnd *path_end) PathGroup::savable(PathEnd *path_end)
{ {
float threshold;
{
LockGuard lock(lock_);
threshold = threshold_;
}
bool savable = false; bool savable = false;
if (compare_slack_) { if (compare_slack_) {
// Crpr increases the slack, so check the slack // Crpr increases the slack, so check the slack
// without crpr first because it is expensive to find. // without crpr first because it is expensive to find.
Slack slack = path_end->slackNoCrpr(sta_); Slack slack = path_end->slackNoCrpr(sta_);
if (!delayIsInitValue(slack, min_max_) if (!delayIsInitValue(slack, min_max_)
&& delayLessEqual(slack, threshold_, sta_) && delayLessEqual(slack, threshold, sta_)
&& delayLessEqual(slack, slack_max_, sta_)) { && delayLessEqual(slack, slack_max_, sta_)) {
// Now check with crpr. // Now check with crpr.
slack = path_end->slack(sta_); slack = path_end->slack(sta_);
savable = delayLessEqual(slack, threshold_, sta_) savable = delayLessEqual(slack, threshold, sta_)
&& delayLessEqual(slack, slack_max_, sta_) && delayLessEqual(slack, slack_max_, sta_)
&& delayGreaterEqual(slack, slack_min_, sta_); && delayGreaterEqual(slack, slack_min_, sta_);
} }
@ -113,7 +118,7 @@ PathGroup::savable(PathEnd *path_end)
else { else {
const Arrival &arrival = path_end->dataArrivalTime(sta_); const Arrival &arrival = path_end->dataArrivalTime(sta_);
savable = !delayIsInitValue(arrival, min_max_) savable = !delayIsInitValue(arrival, min_max_)
&& delayGreaterEqual(arrival, threshold_, min_max_, sta_); && delayGreaterEqual(arrival, threshold, min_max_, sta_);
} }
return savable; return savable;
} }

View File

@ -237,8 +237,10 @@ Search::init(StaState *sta)
clk_info_set_ = new ClkInfoSet(ClkInfoLess(sta)); clk_info_set_ = new ClkInfoSet(ClkInfoLess(sta));
tag_next_ = 0; tag_next_ = 0;
tags_ = new Tag*[tag_capacity_]; tags_ = new Tag*[tag_capacity_];
tags_prev_ = nullptr;
tag_group_capacity_ = 127; tag_group_capacity_ = 127;
tag_groups_ = new TagGroup*[tag_group_capacity_]; tag_groups_ = new TagGroup*[tag_group_capacity_];
tag_groups_prev_ = nullptr;
tag_group_next_ = 0; tag_group_next_ = 0;
tag_group_set_ = new TagGroupSet(tag_group_capacity_); tag_group_set_ = new TagGroupSet(tag_group_capacity_);
pending_latch_outputs_ = new VertexSet(graph_); pending_latch_outputs_ = new VertexSet(graph_);
@ -270,7 +272,9 @@ Search::~Search()
delete tag_set_; delete tag_set_;
delete clk_info_set_; delete clk_info_set_;
delete [] tags_; delete [] tags_;
delete [] tags_prev_;
delete [] tag_groups_; delete [] tag_groups_;
delete [] tag_groups_prev_;
delete tag_group_set_; delete tag_group_set_;
delete search_adj_; delete search_adj_;
delete eval_pred_; delete eval_pred_;
@ -2647,15 +2651,15 @@ Search::findTagGroup(TagGroupBldr *tag_bldr)
// std::vector doesn't seem to follow this protocol so multi-thread // std::vector doesn't seem to follow this protocol so multi-thread
// search fails occasionally if a vector is used for tag_groups_. // search fails occasionally if a vector is used for tag_groups_.
if (tag_group_next_ == tag_group_capacity_) { if (tag_group_next_ == tag_group_capacity_) {
TagGroupIndex new_capacity = nextMersenne(tag_group_capacity_); TagGroupIndex tag_capacity = tag_group_capacity_ * 2;
TagGroup **new_tag_groups = new TagGroup*[new_capacity]; TagGroup **tag_groups = new TagGroup*[tag_capacity];
memcpy(new_tag_groups, tag_groups_, memcpy(tag_groups, tag_groups_,
tag_group_capacity_ * sizeof(TagGroup*)); tag_group_capacity_ * sizeof(TagGroup*));
TagGroup **old_tag_groups = tag_groups_; delete [] tag_groups_prev_;
tag_groups_ = new_tag_groups; tag_groups_prev_ = tag_groups_;
tag_group_capacity_ = new_capacity; tag_groups_ = tag_groups;
delete [] old_tag_groups; tag_group_capacity_ = tag_capacity;
tag_group_set_->reserve(new_capacity); tag_group_set_->reserve(tag_capacity);
} }
if (tag_group_next_ > tag_group_index_max) if (tag_group_next_ > tag_group_index_max)
report_->critical(1510, "max tag group index exceeded"); report_->critical(1510, "max tag group index exceeded");
@ -2888,14 +2892,14 @@ Search::findTag(const RiseFall *rf,
// std::vector doesn't seem to follow this protocol so multi-thread // std::vector doesn't seem to follow this protocol so multi-thread
// search fails occasionally if a vector is used for tags_. // search fails occasionally if a vector is used for tags_.
if (tag_next_ == tag_capacity_) { if (tag_next_ == tag_capacity_) {
TagIndex new_capacity = nextMersenne(tag_capacity_); TagIndex tag_capacity = tag_capacity_ * 2;
Tag **new_tags = new Tag*[new_capacity]; Tag **tags = new Tag*[tag_capacity];
memcpy(new_tags, tags_, tag_capacity_ * sizeof(Tag*)); memcpy(tags, tags_, tag_capacity_ * sizeof(Tag*));
Tag **old_tags = tags_; delete [] tags_prev_;
tags_ = new_tags; tags_prev_ = tags_;
delete [] old_tags; tags_ = tags;
tag_capacity_ = new_capacity; tag_capacity_ = tag_capacity;
tag_set_->reserve(new_capacity); tag_set_->reserve(tag_capacity);
} }
if (tag_next_ == tag_index_max) if (tag_next_ == tag_index_max)
report_->critical(1511, "max tag index exceeded"); report_->critical(1511, "max tag index exceeded");