odb: extend dbChip callbacks and slim UnfoldedModel for dynamic updates#10394
odb: extend dbChip callbacks and slim UnfoldedModel for dynamic updates#10394osamahammad21 wants to merge 6 commits into
Conversation
Signed-off-by: osamahammad21 <osama21@aucegypt.edu>
Signed-off-by: osamahammad21 <osama21@aucegypt.edu>
…chips) Signed-off-by: osamahammad21 <osama21@aucegypt.edu>
Signed-off-by: osamahammad21 <osama21@aucegypt.edu>
| explicit UnfoldedChipObserver(UnfoldedModel* model) : model_(model) {} | ||
|
|
||
| private: | ||
| UnfoldedModel* model_; |
There was a problem hiding this comment.
warning: private field 'model_' is not used [clang-diagnostic-unused-private-field]
UnfoldedModel* model_;
^| explicit UnfoldedBlockObserver(UnfoldedModel* model) : model_(model) {} | ||
|
|
||
| private: | ||
| UnfoldedModel* model_; |
There was a problem hiding this comment.
warning: private field 'model_' is not used [clang-diagnostic-unused-private-field]
UnfoldedModel* model_;
^|
|
||
| const std::deque<UnfoldedChip>& getChips() const { return unfolded_chips_; } | ||
| const std::vector<UnfoldedConnection>& getConnections() const | ||
| const std::vector<std::unique_ptr<UnfoldedChip>>& getChips() const |
There was a problem hiding this comment.
warning: no header providing "std::unique_ptr" is directly included [misc-include-cleaner]
src/odb/include/odb/unfoldedModel.h:7:
- #include <string>
+ #include <memory>
+ #include <string>|
|
||
| #include <algorithm> | ||
| #include <cstddef> | ||
| #include <cstdint> |
There was a problem hiding this comment.
warning: included header cstddef is not used directly [misc-include-cleaner]
| #include <cstdint> | |
| #include <cstdint> |
| return uf_region.region_inst->getId() < inst->getId(); | ||
| }; | ||
|
|
||
| auto it = std::lower_bound(regions.begin(), regions.end(), inst, comp); |
There was a problem hiding this comment.
warning: use a ranges version of this algorithm [modernize-use-ranges]
| auto it = std::lower_bound(regions.begin(), regions.end(), inst, comp); | |
| auto it = std::ranges::lower_bound(regions,, inst, comp); |
| return uf_bump.bump_inst->getId() < bump_inst->getId(); | ||
| }; | ||
| auto it = std::lower_bound( | ||
| region->bumps.begin(), region->bumps.end(), bump_inst, comp); |
There was a problem hiding this comment.
warning: use a ranges version of this algorithm [modernize-use-ranges]
| region->bumps.begin(), region->bumps.end(), bump_inst, comp); | |
| auto it = std::ranges::lower_bound( | |
| region->bumps,, bump_inst, comp); |
| // Transform cuboid to global space | ||
| uf_chip.transform.apply(uf_chip.cuboid); | ||
| unfoldRegions(uf_chip, inst); | ||
| std::unique_ptr<UnfoldedChip> uf_chip = std::make_unique<UnfoldedChip>(); |
There was a problem hiding this comment.
warning: no header providing "std::make_unique" is directly included [misc-include-cleaner]
std::unique_ptr<UnfoldedChip> uf_chip = std::make_unique<UnfoldedChip>();
^| // Transform cuboid to global space | ||
| uf_chip.transform.apply(uf_chip.cuboid); | ||
| unfoldRegions(uf_chip, inst); | ||
| std::unique_ptr<UnfoldedChip> uf_chip = std::make_unique<UnfoldedChip>(); |
There was a problem hiding this comment.
warning: no header providing "std::unique_ptr" is directly included [misc-include-cleaner]
src/odb/src/db/unfoldedModel.cpp:10:
- #include <string>
+ #include <memory>
+ #include <string>| { | ||
| auto regions = inst->getRegions(); | ||
| std::sort(region_insts.begin(), | ||
| region_insts.end(), |
There was a problem hiding this comment.
warning: use a ranges version of this algorithm [modernize-use-ranges]
| region_insts.end(), | |
| std::ranges::sort(region_insts, | |
| , |
| bump_insts.push_back(bump_inst); | ||
| } | ||
| std::sort(bump_insts.begin(), | ||
| bump_insts.end(), |
There was a problem hiding this comment.
warning: use a ranges version of this algorithm [modernize-use-ranges]
| bump_insts.end(), | |
| std::ranges::sort(bump_insts, | |
| , |
There was a problem hiding this comment.
Code Review
This pull request introduces an observer pattern to keep the UnfoldedModel synchronized with database updates, adding callback triggers to dbChipConn, dbChipInst, and dbChipNet. It refactors UnfoldedChip, UnfoldedRegion, and UnfoldedBump to calculate geometric properties dynamically and replaces map-based lookups with binary search on sorted collections. I have no feedback to provide.
Summary
Two related changes that prepare
UnfoldedModelto react to chip-level mutations:dbChipCallBackObjwith new virtual hooks fordbChipInst(create / destroy / pre- and post-move),dbChipConn(create / destroy), anddbChipNet(create / destroy / connect-bump). The correspondingdbChipInst.cpp,dbChipConn.cpp, anddbChipNet.cppnow fire these callbacks at the right points.UnfoldedModeland wired it to those callbacks viaUnfoldedChipObserver/UnfoldedBlockObserver. While here, the model was tightened up:Cuboid,name, andglobal_positionfields fromUnfoldedChip/UnfoldedRegion/UnfoldedBump; they are now computed on demand viagetCuboid(),getFullName(), andgetGlobalPosition().unordered_map<dbChipRegionInst*, UnfoldedRegion*>andunordered_map<dbChipBumpInst*, UnfoldedBump*>with sorted-by-getId()storage plusstd::lower_boundlookup. The storage is the index — no separate hash table.deque<UnfoldedChip>tovector<unique_ptr<UnfoldedChip>>so chip addresses stay stable regardless of container mutation.Chiplet3DWidgetandCheckerto use the new accessors (getCuboid(),getFullName(),getGlobalPosition(),unique_ptr-dereferenced chips).Type of Change
Impact
No user-visible behavioral change today: the unfolded model is still built once at construction. The callback plumbing is now in place so a follow-up can implement incremental updates (chip-inst create/destroy, conn/net create/destroy) without further changes to the storage shape or to consumers.
Internally:
UnfoldedRegion/UnfoldedBump/UnfoldedChipare smaller per instance (no cached cuboids, names, or precomputed global positions).dbSetorder to sorted-by-getId()order — verified against existing golden tests.Verification
./etc/Build.sh).Related Issues
N/A