-
Notifications
You must be signed in to change notification settings - Fork 773
mpl: halos for specific macros #9315
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
base: master
Are you sure you want to change the base?
mpl: halos for specific macros #9315
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a new command, set_macro_halo, which allows setting specific halos for individual macros. The implementation correctly integrates this feature into the macro placement flow, with logic to use these specific halos or fall back to global defaults. The changes are well-structured, including updates to the TCL interface, core placement logic, and GUI visualization. My review identified a couple of minor issues: the documentation for the new command in README.md is incorrect due to a copy-paste error, and there's a small redundancy in the new TCL command's implementation. Addressing these will improve the clarity and correctness of the new feature.
src/mpl/README.md
Outdated
| set_macro_guidance_region | ||
| -macro_name macro_name | ||
| -region region | ||
| ``` | ||
|
|
||
| #### Options | ||
|
|
||
| | Switch Name | Description | | ||
| | ----- | ----- | | ||
| | `-macro_name` | The name of a macro of the design. | | ||
| | `-region` | The lower left corner and upper right corner {lx ly ux uy} of the region in microns. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation for the new set_macro_halo command appears to be a copy-paste from set_macro_guidance_region and is incorrect. The command name, arguments, and descriptions should be updated to reflect the new functionality.
Specifically:
- The command in the example should be
set_macro_halo. - The argument should be
-haloinstead of-region. - The description for
-haloshould state that it's a list of two values:{width height}in microns.
| set_macro_guidance_region | |
| -macro_name macro_name | |
| -region region | |
| ``` | |
| #### Options | |
| | Switch Name | Description | | |
| | ----- | ----- | | |
| | `-macro_name` | The name of a macro of the design. | | |
| | `-region` | The lower left corner and upper right corner {lx ly ux uy} of the region in microns. | | |
| set_macro_halo | |
| -macro_name macro_name | |
| -halo {width height} |
Options
| Switch Name | Description |
|---|---|
-macro_name |
The name of a macro of the design. |
-halo |
The horizontal and vertical halo {width height} around the macro in microns. |
| set width $width | ||
| set height $height |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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/mpl/include/mpl/rtl_mp.h
Outdated
|
|
||
| void setMacroPlacementFile(const std::string& file_name); | ||
| void addGuidanceRegion(odb::dbInst* macro, odb::Rect region); | ||
| void addMacroHalo(odb::dbInst* macro, std::pair<int, int> halo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::pair" is directly included [misc-include-cleaner]
src/mpl/include/mpl/rtl_mp.h:8:
- #include <vector>
+ #include <utility>
+ #include <vector>
src/mpl/src/hier_rtlmp.h
Outdated
| void setHaloHeight(int halo_height); | ||
| void setGuidanceRegions( | ||
| const std::map<odb::dbInst*, odb::Rect>& guidance_regions); | ||
| void setMacroHalos(const std::map<odb::dbInst*, std::pair<int, int>>& halos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::pair" is directly included [misc-include-cleaner]
src/mpl/src/hier_rtlmp.h:9:
- #include <vector>
+ #include <utility>
+ #include <vector>
src/mpl/src/rtl_mp.cpp
Outdated
| guidance_regions_[macro] = region; | ||
| } | ||
|
|
||
| void MacroPlacer::addMacroHalo(odb::dbInst* macro, std::pair<int, int> halo) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::pair" is directly included [misc-include-cleaner]
src/mpl/src/rtl_mp.cpp:7:
- #include <vector>
+ #include <utility>
+ #include <vector>Signed-off-by: João Mai <jmai@precisioninno.com>
Signed-off-by: João Mai <jmai@precisioninno.com>
Signed-off-by: João Mai <jmai@precisioninno.com>
Signed-off-by: João Mai <jmai@precisioninno.com>
Signed-off-by: João Mai <jmai@precisioninno.com>
Signed-off-by: João Mai <jmai@precisioninno.com>
Signed-off-by: João Mai <jmai@precisioninno.com>
Signed-off-by: João Mai <jmai@precisioninno.com>
112fab5 to
4ec524b
Compare
There was a problem hiding this 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/mpl/include/mpl/rtl_mp.h
Outdated
| odb::dbDatabase* db_ = nullptr; | ||
|
|
||
| std::map<odb::dbInst*, odb::Rect> guidance_regions_; | ||
| std::map<odb::dbInst*, std::pair<int, int>> macro_halos_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::pair" is directly included [misc-include-cleaner]
src/mpl/include/mpl/rtl_mp.h:8:
- #include <vector>
+ #include <utility>
+ #include <vector>Signed-off-by: João Mai <jmai@precisioninno.com>
Signed-off-by: João Mai <jmai@precisioninno.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
AcKoucher
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, address the code assist comment in the .mpl file.
Also, take a look at why the tests with fixed macros are failing (I suspect it has something to do with the new method for creating HardMacros).
src/mpl/src/rtl_mp.cpp
Outdated
| void MacroPlacer::addMacroHalo(odb::dbInst* macro, | ||
| int halo_width, | ||
| int halo_height) | ||
| { | ||
| hier_rtlmp_->addMacroHalo(macro, halo_width, halo_height); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the name setMacroHalo makes more sense, as a macro won't have more than one Halo.
src/mpl/src/mpl.i
Outdated
| } | ||
|
|
||
| void | ||
| add_macro_halo(odb::dbInst* macro, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set_macro_halo
src/mpl/src/hier_rtlmp.h
Outdated
|
|
||
| std::map<std::string, odb::Rect> fences_; // macro_name, fence | ||
| std::map<odb::dbInst*, odb::Rect> guides_; // Macro -> Guidance Region | ||
| std::map<odb::dbInst*, HardMacro::Halo> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
macro_to_halo_ and drop the comment.
src/mpl/include/mpl/rtl_mp.h
Outdated
|
|
||
| void setMacroPlacementFile(const std::string& file_name); | ||
| void addGuidanceRegion(odb::dbInst* macro, odb::Rect region); | ||
| void addMacroHalo(odb::dbInst* macro, int halo_width, int halo_height); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setMacroHalo
src/mpl/src/clusterEngine.cpp
Outdated
| const int width = master->getWidth() + (2 * tree_->halo_width); | ||
| const int height = master->getHeight() + (2 * tree_->halo_height); | ||
| macro_with_halo_area += (width * static_cast<int64_t>(height)); | ||
| macro_with_halo_area += tree_->maps.inst_to_hard[unfixed_macro]->getArea(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use std::map::at as the map is not being modified.
src/mpl/src/hier_rtlmp.cpp
Outdated
| clustering_engine_ = std::make_unique<ClusteringEngine>( | ||
| block_, network_, logger_, tritonpart_, graphics_.get()); | ||
|
|
||
| createHardMacros(block_->getTopModule()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I liked that you separated this in one function :-)
I've been trying to make the ClusteringEngine the object that populates/changes the tree_.
That said, I think this method should belong to the ClusteringEngine and not to HierRTLMP. (Ideally it should belong to a placement engine, but that is for one day in the future when the stars align).
| odb::Rect halo_bbox(macro.getX(), | ||
| macro.getY(), | ||
| macro.getX() + macro.getWidth(), | ||
| macro.getY() + macro.getHeight()); | ||
| odb::Rect macro_bbox(macro.getRealX(), | ||
| macro.getRealY(), | ||
| macro.getRealX() + width, | ||
| macro.getRealY() + height); | ||
|
|
||
| painter.drawRect(bbox); | ||
| painter.drawString(bbox.xCenter(), | ||
| bbox.yCenter(), | ||
| halo_bbox.moveDelta(outline_.xMin(), outline_.yMin()); | ||
| macro_bbox.moveDelta(outline_.xMin(), outline_.yMin()); | ||
|
|
||
| painter.setBrush(gui::Painter::kDarkRed); | ||
| painter.drawRect(halo_bbox); | ||
|
|
||
| painter.setBrush(gui::Painter::kRed); | ||
| painter.drawRect(macro_bbox); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
Signed-off-by: João Mai <jmai@precisioninno.com>
Signed-off-by: João Mai <jmai@precisioninno.com>
Signed-off-by: João Mai <jmai@precisioninno.com>
|
The new code from #9362 will require changes in this PR. |
Signed-off-by: João Mai <jmai@precisioninno.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
AcKoucher
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| auto macro_insts | ||
| = block_->getInsts() | std::ranges::views::filter(&odb::dbInst::isBlock); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool
This PR adds a new command to MPL:
set_macro_halo, which sets a halo for a specified macro. Currently, this halo works only for placement, the blockages generated later still use the values in MACRO_PLACE_HALO (or MACRO_BLOCKAGE_HALO).Blockage generation will be updated in an upcoming PR.