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

Merged

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

src/odb/src/lefin/lefTechLayerCutSpacingTableParser.cpp Outdated Show resolved Hide resolved
src/odb/src/lefin/lefTechLayerCutSpacingTableParser.cpp Outdated Show resolved Hide resolved
src/odb/src/lefin/lefin.cpp Outdated Show resolved Hide resolved
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?

Copy link
Member

Choose a reason for hiding this comment

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

I think he has just locked every method. The key ones are ::create*/replace* methods which will block simultaneous parsing.

@LucasYuki I think some of these do nothing more than set a manipulate local variables and not the db and therefore do not need locks (eg ctor, dtor, skip). Please analyze it a bit more.

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

1 similar comment
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@maliberty
Copy link
Member

@QuantamHD are your concerns resolved?

@QuantamHD
Copy link
Collaborator

I am, but could we add a comment to the mutexes that explains why they exist. Specifically mentioning that the defin and lefin parsers rely on static vars.

@maliberty
Copy link
Member

@LucasYuki please add the comment to this PR.

Signed-off-by: Lucas Yuki Imamura <[email protected]>
@maliberty maliberty enabled auto-merge January 13, 2025 22:20
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@maliberty maliberty merged commit 30d94cf into The-OpenROAD-Project:master Jan 13, 2025
11 checks passed
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.

3 participants