[core] debugging

This commit is contained in:
tangxifan 2023-03-03 22:55:14 -08:00
parent 4423d917fa
commit 81e9187aac
3 changed files with 24 additions and 11 deletions

View File

@ -39,25 +39,22 @@ RRNodeId RRClockSpatialLookup::find_node(int x, int y, const ClockTreeId& tree,
return RRNodeId::INVALID();
}
auto result_tree = rr_node_indices_[dir][x][y].find(tree);
if (result_tree == rr_node_indices_[dir][x][y].end()) {
if (size_t(tree) >= rr_node_indices_[dir][x][y].size()) {
VTR_LOG("Tree id out of range");
return RRNodeId::INVALID();
}
auto result_lvl = result_tree->second.find(lvl);
if (result_lvl == result_tree->second.end()) {
if (size_t(lvl) == rr_node_indices_[dir][x][y][size_t(tree)].size()) {
VTR_LOG("Level id out of range");
return RRNodeId::INVALID();
}
auto result_pin = result_lvl->second.find(pin);
if (result_pin == result_lvl->second.end()) {
if (size_t(pin) == rr_node_indices_[dir][x][y][size_t(tree)][size_t(lvl)].size()) {
VTR_LOG("Pin id out of range");
return RRNodeId::INVALID();
}
return result_pin->second;
return rr_node_indices_[dir][x][y][size_t(tree)][size_t(lvl)][size_t(pin)];
}
void RRClockSpatialLookup::add_node(RRNodeId node, int x, int y,
@ -70,9 +67,21 @@ void RRClockSpatialLookup::add_node(RRNodeId node, int x, int y,
VTR_ASSERT_SAFE(2 == rr_node_indices_[dir].ndims());
resize_nodes(x, y, direction);
if (size_t(tree) >= rr_node_indices_[dir][x][y].size()) {
rr_node_indices_[dir][x][y].resize(size_t(tree) + 1);
}
if (size_t(lvl) >= rr_node_indices_[dir][x][y][size_t(tree)].size()) {
rr_node_indices_[dir][x][y][size_t(tree)].resize(size_t(lvl) + 1);
}
if (size_t(pin) >= rr_node_indices_[dir][x][y][size_t(tree)][size_t(lvl)].size()) {
rr_node_indices_[dir][x][y][size_t(tree)][size_t(lvl)].resize(size_t(pin) + 1);
}
/* Resize on demand finished; Register the node */
rr_node_indices_[dir][x][y][tree][lvl][pin] = node;
rr_node_indices_[dir][x][y][size_t(tree)][size_t(lvl)][size_t(pin)] = node;
}
void RRClockSpatialLookup::resize_nodes(int x, int y,

View File

@ -99,8 +99,7 @@ class RRClockSpatialLookup {
*/
std::array<
vtr::NdMatrix<
std::map<ClockTreeId,
std::map<ClockLevelId, std::map<ClockTreePinId, RRNodeId>>>,
std::vector<std::vector<std::vector<RRNodeId>>>,
2>,
2>
rr_node_indices_;

View File

@ -163,9 +163,12 @@ static void add_rr_graph_clock_nodes(RRGraphBuilder& rr_graph_builder,
add_rr_graph_block_clock_nodes(rr_graph_builder, clk_rr_lookup,
rr_graph_view, clk_ntwk, chanx_coord,
CHANX, CHANX_COST_INDEX_START, verbose);
VTR_ASSERT(rr_graph_view.valid_node(clk_rr_lookup.find_node(1, 0, ClockTreeId(0), ClockLevelId(0), ClockTreePinId(0), Direction::INC)));
}
}
VTR_ASSERT(rr_graph_view.valid_node(clk_rr_lookup.find_node(1, 0, ClockTreeId(0), ClockLevelId(0), ClockTreePinId(0), Direction::INC)));
/* Add Y-direction clock nodes */
for (size_t ix = 0; ix < grids.width() - 1; ++ix) {
for (size_t iy = 1; iy < grids.height() - 1; ++iy) {
@ -179,8 +182,10 @@ static void add_rr_graph_clock_nodes(RRGraphBuilder& rr_graph_builder,
add_rr_graph_block_clock_nodes(
rr_graph_builder, clk_rr_lookup, rr_graph_view, clk_ntwk, chany_coord,
CHANY, CHANX_COST_INDEX_START + rr_graph_view.num_rr_segments(), verbose);
VTR_ASSERT(rr_graph_view.valid_node(clk_rr_lookup.find_node(1, 0, ClockTreeId(0), ClockLevelId(0), ClockTreePinId(0), Direction::INC)));
}
}
VTR_ASSERT(rr_graph_view.valid_node(clk_rr_lookup.find_node(1, 0, ClockTreeId(0), ClockLevelId(0), ClockTreePinId(0), Direction::INC)));
}
/********************************************************************
@ -463,7 +468,7 @@ static void add_rr_graph_block_clock_edges(
RRGraphBuilder& rr_graph_builder, size_t& num_edges_to_create,
const RRClockSpatialLookup& clk_rr_lookup, const RRGraphView& rr_graph_view,
const DeviceGrid& grids, const ClockNetwork& clk_ntwk,
const vtr::Point<size_t> chan_coord, const t_rr_type& chan_type,
const vtr::Point<size_t>& chan_coord, const t_rr_type& chan_type,
const bool& verbose) {
size_t edge_count = 0;
for (auto itree : clk_ntwk.trees()) {