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

drt: decoupling of the Graphics classes and stable drt_lib & graphic Factory #6642

Merged
merged 11 commits into from
Feb 12, 2025

Conversation

bnmfw
Copy link
Contributor

@bnmfw bnmfw commented Feb 5, 2025

Tackles 6532.

This is PR #6550 but better.

The branch is the same and every new addition can be found starting from the "graphic factory" commit.

Graphics Factory

Instead of passing the three DR classes during the initialization of TritonRoute, now a new class, GraphicsFactory is responsible for providing both unique pointers and simple pointers for all the three classes. Whenever initDesign is called, initGraphics which passes the necessary arguments for these classes is called, ensuring they are up to date.

bnmfw and others added 9 commits February 5, 2025 01:46
Signed-off-by: bernardo <[email protected]>
Signed-off-by: bernardo <[email protected]>
Signed-off-by: bernardo <[email protected]>
Signed-off-by: bernardo <[email protected]>
Signed-off-by: bernardo <[email protected]>
Signed-off-by: bernardo <[email protected]>
Signed-off-by: Matt Liberty <[email protected]>

drt: clang-format

Signed-off-by: bernardo <[email protected]>
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

@maliberty
Copy link
Member

ready for review?

@bnmfw bnmfw added the drt Detailed Routing label Feb 5, 2025
Signed-off-by: bernardo <[email protected]>
@bnmfw bnmfw self-assigned this Feb 5, 2025
@bnmfw bnmfw requested a review from maliberty February 5, 2025 18:29
@bnmfw
Copy link
Contributor Author

bnmfw commented Feb 5, 2025

@maliberty now it is

Copy link
Member

@maliberty maliberty left a comment

Choose a reason for hiding this comment

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

Partial review as I'd like to get clarity on the change in ownership semantics.

Comment on lines 56 to 58
virtual AbstractDRGraphics* getDRGraphics() = 0;
virtual AbstractTAGraphics* getTAGraphics() = 0;
virtual AbstractPAGraphics* getPAGraphics() = 0;
Copy link
Member

Choose a reason for hiding this comment

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

Why does the factory have get methods? It is unusual for the pattern.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Answered bellow

Comment on lines 248 to 250
AbstractDRGraphics* graphics
= debug_->debugDR ? graphics_factory_->getDRGraphics() : nullptr;
worker->setGraphics(graphics);
Copy link
Member

Choose a reason for hiding this comment

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

Why not create and give ownership to the worker as before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the worker actually did not get the ownership of the pointer before. It just got a raw pointer and ownership was kept to the "scope of the function". I made the getXXGraphics to accommodate for this. Besides that I made every method for all three tools for the sake of keeping the pattern, even though I do not use all.

Copy link
Member

Choose a reason for hiding this comment

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

Now the ownership is not with the "scope of the function" but factory class itself. What is the advantage of that? I don't expect a factory to own its products.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment on lines +67 to +70
// Define swig TCL commands.
auto tcl_interp = openroad->tclInterp();
Drt_Init(tcl_interp);
sta::evalTclInit(tcl_interp, sta::drt_tcl_inits);
Copy link
Member

Choose a reason for hiding this comment

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

Did this need to be moved? Does the factory ctor depend on tcl somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This came before the factory, it was part of the old PR. tcl_interp being on TritonRoute.cpp creates linking issues. In most other tools on the project tcl_interp is always on the Make.cpp file. This is both for keeping this patterns and to allow for the drt_lib

Comment on lines -633 to +628
FlexTA ta(getDesign(), logger_, router_cfg_.get(), distributed_);
ta.setDebug(debug_.get(), db_);
ta.main();
std::unique_ptr<FlexTA> ta = std::make_unique<FlexTA>(
getDesign(), logger_, router_cfg_.get(), distributed_);
if (debug_->debugTA) {
ta->setDebug(graphics_factory_->makeUniqueTAGraphics());
}
ta->main();
Copy link
Member

Choose a reason for hiding this comment

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

What motivates the change from stack to unique_ptr?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Kinda arbitrary tbh. PA will have to be a unique_ptr created at initialization at some point for the GRT with PA to be possible. I planned to make this with DR, TA and PA, started it but reverted for this PR. This change is residual, I can revert it if you want, but at some point I think it will become a unique_ptr anyway.

@bnmfw bnmfw changed the title drt: graphic factory drt: decoupling of the Graphics classes and stable drt_lib & graphic Factory Feb 6, 2025
Signed-off-by: bernardo <[email protected]>
@maliberty maliberty merged commit 8b0ffd7 into The-OpenROAD-Project:master Feb 12, 2025
11 checks passed
@bnmfw bnmfw deleted the drt_linker branch February 13, 2025 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
drt Detailed Routing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants