Skip to content

odb: extend dbChip callbacks and slim UnfoldedModel for dynamic updates#10394

Open
osamahammad21 wants to merge 6 commits into
The-OpenROAD-Project:masterfrom
osamahammad21:odb-dynamic-unfolded-model
Open

odb: extend dbChip callbacks and slim UnfoldedModel for dynamic updates#10394
osamahammad21 wants to merge 6 commits into
The-OpenROAD-Project:masterfrom
osamahammad21:odb-dynamic-unfolded-model

Conversation

@osamahammad21
Copy link
Copy Markdown
Member

Summary

Two related changes that prepare UnfoldedModel to react to chip-level mutations:

  • Extended dbChipCallBackObj with new virtual hooks for dbChipInst (create / destroy / pre- and post-move), dbChipConn (create / destroy), and dbChipNet (create / destroy / connect-bump). The corresponding dbChipInst.cpp, dbChipConn.cpp, and dbChipNet.cpp now fire these callbacks at the right points.
  • Slimmed UnfoldedModel and wired it to those callbacks via UnfoldedChipObserver / UnfoldedBlockObserver. While here, the model was tightened up:
    • Removed the cached Cuboid, name, and global_position fields from UnfoldedChip / UnfoldedRegion / UnfoldedBump; they are now computed on demand via getCuboid(), getFullName(), and getGlobalPosition().
    • Replaced the per-chip unordered_map<dbChipRegionInst*, UnfoldedRegion*> and unordered_map<dbChipBumpInst*, UnfoldedBump*> with sorted-by-getId() storage plus std::lower_bound lookup. The storage is the index — no separate hash table.
    • Switched the outer deque<UnfoldedChip> to vector<unique_ptr<UnfoldedChip>> so chip addresses stay stable regardless of container mutation.
    • Observers are attached recursively across the chip hierarchy at construction.
  • Updated Chiplet3DWidget and Checker to use the new accessors (getCuboid(), getFullName(), getGlobalPosition(), unique_ptr-dereferenced chips).

Type of Change

  • Refactoring

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 / UnfoldedChip are smaller per instance (no cached cuboids, names, or precomputed global positions).
  • Checker / GUI iteration order over regions and bumps changes from dbSet order to sorted-by-getId() order — verified against existing golden tests.

Verification

  • I have verified that the local build succeeds (./etc/Build.sh).
  • I have run the relevant tests and they pass.
  • My code follows the repository's formatting guidelines.
  • I have signed my commits (DCO).

Related Issues

N/A

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>
Copy link
Copy Markdown
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

explicit UnfoldedChipObserver(UnfoldedModel* model) : model_(model) {}

private:
UnfoldedModel* model_;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: private field 'model_' is not used [clang-diagnostic-unused-private-field]

  UnfoldedModel* model_;
                 ^

explicit UnfoldedBlockObserver(UnfoldedModel* model) : model_(model) {}

private:
UnfoldedModel* model_;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Contributor

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::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>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: included header cstddef is not used directly [misc-include-cleaner]

Suggested change
#include <cstdint>
#include <cstdint>

return uf_region.region_inst->getId() < inst->getId();
};

auto it = std::lower_bound(regions.begin(), regions.end(), inst, comp);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: use a ranges version of this algorithm [modernize-use-ranges]

Suggested change
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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: use a ranges version of this algorithm [modernize-use-ranges]

Suggested change
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>();
Copy link
Copy Markdown
Contributor

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::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>();
Copy link
Copy Markdown
Contributor

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::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(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: use a ranges version of this algorithm [modernize-use-ranges]

Suggested change
region_insts.end(),
std::ranges::sort(region_insts,
,

bump_insts.push_back(bump_inst);
}
std::sort(bump_insts.begin(),
bump_insts.end(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: use a ranges version of this algorithm [modernize-use-ranges]

Suggested change
bump_insts.end(),
std::ranges::sort(bump_insts,
,

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a 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 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant