Skip to content

Commit b75944f

Browse files
committed
Added cost_index_is_invalid() to check if RRIndexedDataId < 0
Signed-off-by: Ethan Rogers <[email protected]>
1 parent 75018b5 commit b75944f

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

vpr/src/device/rr_graph_view.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,11 @@ class RRGraphView {
249249
return node_storage_.node_cost_index(node);
250250
}
251251

252+
/** @brief Check if a node cost index is invalid (ie less than 0). This function is inlined for runtime optimization. */
253+
bool cost_index_is_invalid(RRNodeId node) const {
254+
return node_storage_.cost_index_is_invalid(node);
255+
}
256+
252257
/** @brief Return the fast look-up data structure for queries from client functions */
253258
const RRSpatialLookup& node_lookup() const {
254259
return node_lookup_;

vpr/src/route/check_rr_graph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ void check_rr_node(int inode, enum e_route_type route_type, const DeviceContext&
327327
"in check_rr_node: inode %d (type %d) had a ptc_num of %d.\n", inode, rr_type, ptc_num);
328328
}
329329

330-
if ((size_t)cost_index < 0 || (size_t)cost_index >= (int)device_ctx.rr_indexed_data.size()) {
330+
if (rr_graph.cost_index_is_invalid(rr_node) || (size_t)cost_index >= (int)device_ctx.rr_indexed_data.size()) {
331331
VPR_FATAL_ERROR(VPR_ERROR_ROUTE,
332332
"in check_rr_node: node %d cost index (%d) is out of range.\n", inode, cost_index);
333333
}

vpr/src/route/rr_graph_storage.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ class t_rr_graph_storage {
189189
return RRIndexedDataId(node_storage_[id].cost_index_);
190190
}
191191

192+
bool cost_index_is_invalid(RRNodeId id) const {
193+
return node_storage_[id].cost_index_ < 0;
194+
}
195+
192196
Direction node_direction(RRNodeId id) const {
193197
return get_node_direction(
194198
vtr::array_view_id<RRNodeId, const t_rr_node_data>(

0 commit comments

Comments
 (0)