Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

odb: protecting LefParser and DefParser namespaces #6475

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

LucasYuki
Copy link
Contributor

Protects the global and static variables in the LefParser and DefParser namespaces (issue #5981)

Changes:

  • lefin class splitted into lefin and lefinReader:
    • lefin: interface used by OR;
    • lefinReader: interface used by the Lef module.
  • lefin and defin methods protected with a lock;

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

{
odb::dbTechLayerCutSpacingTableOrthRule* rule
= odb::dbTechLayerCutSpacingTableOrthRule::create(parser->layer);
std::vector<std::pair<int, int>> table;
for (const auto& item : params)
table.push_back(
{lefin->dbdist(at_c<0>(item)), lefin->dbdist(at_c<1>(item))});
table.push_back({lefinReader->dbdist(at_c<0>(item)),
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 'push_back' is called inside a loop; consider pre-allocating the container capacity before the loop [performance-inefficient-vector-operation]

src/odb/src/lefin/lefTechLayerCutSpacingTableParser.cpp:46:

-   for (const auto& item : params)
+   table.reserve(params.size());
+ for (const auto& item : params)

Comment on lines +48 to +49
table.push_back({lefinReader->dbdist(at_c<0>(item)),
lefinReader->dbdist(at_c<1>(item))});
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: use emplace_back instead of push_back [modernize-use-emplace]

Suggested change
table.push_back({lefinReader->dbdist(at_c<0>(item)),
lefinReader->dbdist(at_c<1>(item))});
table.emplace_back(lefinReader->dbdist(at_c<0>(item)),
lefinReader->dbdist(at_c<1>(item)));

@@ -110,11 +111,11 @@ void lefin::init()
}
}

lefin::~lefin()
lefinReader::~lefinReader()
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: use '= default' to define a trivial destructor [modernize-use-equals-default]

src/odb/src/lefin/lefin.cpp:114:

- {
- }
+ = default;

Comment on lines +40 to +50
std::mutex defin::_def_mutex;

defin::defin(dbDatabase* db, utl::Logger* logger, MODE mode)
{
std::lock_guard<std::mutex> lock(_def_mutex);
_reader = new definReader(db, logger, mode);
}

defin::~defin()
{
std::lock_guard<std::mutex> lock(_def_mutex);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not clear the locking is doing anything here. It kind of looks like this is trying to protect two defin's from running at the same time on the same database, but what we're really concerned about is two different defin's running on two different databases.

What are these locks here to do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants