odb: impl 3dblox parser path asserstions#10055
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements path assertion validation within the 3DBlox checker. It introduces a 'blackbox' attribute for chips to handle components without detailed routing and adds a CSR-based RoutingGraph to model design connectivity. The checker now utilizes a BFS-based algorithm to verify reachability constraints defined in path assertions. Feedback was provided regarding the use of magic numbers for buffer capacities in the BFS state.
| queue.reserve(std::min<uint32_t>(n, 4096u)); | ||
| dirty_blocked.reserve(64); | ||
| dirty_target.reserve(64); |
There was a problem hiding this comment.
The values 4096u and 64 are magic numbers. To improve readability and maintainability, they should be defined as named constants. This also aligns with the general rule to avoid hardcoded magic numbers for tunable parameters.
For example, you could add them to the BfsState struct:
struct BfsState
{
static constexpr uint32_t kInitialBfsQueueCapacity = 4096u;
static constexpr uint32_t kInitialDirtyListCapacity = 64u;
std::vector<uint8_t> is_blocked;
// ...
explicit BfsState(uint32_t n)
: is_blocked(n, 0), is_target(n, 0), visited(n, 0)
{
queue.reserve(std::min<uint32_t>(n, kInitialBfsQueueCapacity));
dirty_blocked.reserve(kInitialDirtyListCapacity);
dirty_target.reserve(kInitialDirtyListCapacity);
}
// ...
};References
- Define tunable parameters as named constants instead of using hardcoded magic numbers.
|
clang-tidy review says "All clean, LGTM! 👍" |
| static std::vector<std::string> splitPath(const std::string& path) | ||
| { | ||
| std::vector<std::string> parts; | ||
| std::istringstream stream(path); | ||
| std::string part; | ||
|
|
||
| while (std::getline(stream, part, '/')) { | ||
| if (!part.empty()) { | ||
| parts.push_back(part); | ||
| } | ||
| } | ||
|
|
||
| return parts; | ||
| } |
| @@ -0,0 +1,33 @@ | |||
| // SPDX-License-Identifier: BSD-3-Clause | |||
| // Copyright (c) 2023-2026, The OpenROAD Authors | |||
| @@ -0,0 +1,133 @@ | |||
| // SPDX-License-Identifier: BSD-3-Clause | |||
| // Copyright (c) 2023-2026, The OpenROAD Authors | |||
| if (!conn.top_region || !conn.bottom_region) { | ||
| continue; // Virtual (ground) connection — no region-to-region edge. | ||
| } |
There was a problem hiding this comment.
I don't think we should check if top_region is null because that looks like a fail safe. At this point, top_region should never be null, right?
There was a problem hiding this comment.
I'm not sure if top or bottom are what we expect to be connected to ground. I think defensive programming is better. If you know that top must not be null tell me and I'll check and error.
There was a problem hiding this comment.
According to the standard, only the bottom region is allowed to be ~ (virtual plane). So the top cannot null. In general, I am against defensive programming because it leads to having major issues unnoticed. I would rather a crashing program than a silently wrong one.
There was a problem hiding this comment.
I agree with "I would rather a crashing program than a silently wrong one" as I said I'll error in the bad case. I won't continue.
| if (it_top == region_to_idx.end() || it_bot == region_to_idx.end()) { | ||
| continue; | ||
| } |
There was a problem hiding this comment.
Another fail safe that shouldn't happen. A connection should never hold a region that is not defined already in the unfolded model.
There was a problem hiding this comment.
You're right, this should be an error (assert) not continue.
There was a problem hiding this comment.
assert is sufficient if you think it is needed.
There was a problem hiding this comment.
Asserts might be dropped out in a release build. I think we should error.
| const auto it_b = region_to_idx.find(®ions[b]); | ||
| if (it_b == region_to_idx.end()) { | ||
| continue; | ||
| } |
| edges.push_back({u, v}); | ||
| g.offsets[u + 1]++; | ||
| g.offsets[v + 1]++; |
There was a problem hiding this comment.
Actually, even in blackbox, connecting all regions is not correct according to the standard.
There was a problem hiding this comment.
From the spec: "During the blackbox stage, all intra-chiplet regions are assumed to be internally connected".
There was a problem hiding this comment.
It depends on the chiplet type and whether it is TSV or not.
| void setBlackbox(bool blackbox); | ||
|
|
||
| bool isBlackbox() const; | ||
|
|
There was a problem hiding this comment.
I don't think that the blackbox state should be user defined. It should be inferred from the current state of the chiplet. From looking at the code, I can see that you set it once and never change it again even if the netlist is added later with routing.
For now let's remove it and assume that the path assertions are in the scope of the blockbox state only.
There was a problem hiding this comment.
Agreed, I did not mean for this to be used by a user. I wanted the system to change it. Do you think there is a better mechanism to track what stage the system is in? I'll check if we have something already.
| #include "objects.h" | ||
| #include "odb/db.h" | ||
| #include "utl/Logger.h" | ||
| #include "yaml-cpp/yaml.h" |
| struct RoutingGraph | ||
| { | ||
| std::vector<uint32_t> offsets; // size num_nodes+1; CSR row pointers | ||
| std::vector<uint32_t> neighbors; // all adjacency lists concatenated | ||
| uint32_t num_nodes = 0; | ||
| }; |
There was a problem hiding this comment.
use boost::compressed_sparse_row_graph
Signed-off-by: Ahmed R. Mohamed <ahmed@precisioninno.com>
Use boost graph library Implement all spec region connection rules. Signed-off-by: Ahmed R. Mohamed <ahmed@precisioninno.com>
5fadd7d to
1ffe304
Compare
|
clang-tidy review says "All clean, LGTM! 👍" |
Summary
Add path assertion checking to the 3DBlox checker. Path assertions (parsed from
.3dbxfiles) specify must-touch and do-not-touch region constraints. The checker validates these by building a CSR routing graph from the unfolded model and running BFS connectivity queries to detect violations.Key changes:
PathAssertionEntry/PathAssertionstructs in the public header with aregion_instfield resolved at parse timegetPathAssertions()/setPathAssertions()API onThreeDBloxcheckPathAssertionsin the checker using a CSR routing graph + BFSdbChip::setIsBlackbox()/isBlackbox()so blackbox chips get intra-chip clique edges in the routing graphroutingGraph.cpp/hfor O(V+E) CSR graph constructionType of Change
Impact
ThreeDBlox::check()now validates path assertions in addition to existing checks (logical connectivity, floating chips, overlaps, etc.)blackbox_field ondbChip; backward-compatible with schema 128 databasesVerification
./etc/Build.sh).Related Issues
Closes: #9300