Skip to content

Commit 57d1006

Browse files
make rr_node_typename of type vtr::array to index it only with e_rr_type
1 parent 6291e16 commit 57d1006

9 files changed

+22
-19
lines changed

libs/librrgraph/src/base/check_rr_graph.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ void check_rr_graph(const RRGraphView& rr_graph,
164164
if (!(is_chan_to_chan || is_chan_to_ipin || is_opin_to_chan || is_internal_edge)) {
165165
VPR_ERROR(VPR_ERROR_ROUTE,
166166
"in check_rr_graph: node %d (%s) connects to node %d (%s) %zu times - multi-connections only expected for CHAN<->CHAN, CHAN->IPIN, OPIN->CHAN.\n",
167-
inode, rr_node_typename[(size_t)rr_type], to_node, rr_node_typename[(size_t)to_rr_type], num_edges_to_node);
167+
inode, rr_node_typename[rr_type], to_node, rr_node_typename[to_rr_type], num_edges_to_node);
168168
}
169169

170170
//Between two wire segments
@@ -244,7 +244,7 @@ void check_rr_graph(const RRGraphView& rr_graph,
244244
// #TODO: No edges are added for internal pins. However, they need to be checked somehow!
245245
if (ptc_num >= type->num_pins) {
246246
VTR_LOG_ERROR("in check_rr_graph: node %d (%s) type: %s is internal node.\n",
247-
inode, rr_graph.node_type_string(rr_node), rr_node_typename[(size_t)rr_type]);
247+
inode, rr_graph.node_type_string(rr_node), rr_node_typename[rr_type]);
248248
}
249249
}
250250

libs/librrgraph/src/base/rr_graph_obj.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ short RRGraph::chan_num_tracks(const short& x, const short& y, const e_rr_type&
451451
/* This function aims to print basic information about a node */
452452
void RRGraph::print_node(const RRNodeId& node) const {
453453
VTR_LOG("Node id: %d\n", node_index(node));
454-
VTR_LOG("Node type: %s\n", rr_node_typename[(size_t)node_type(node)]);
454+
VTR_LOG("Node type: %s\n", rr_node_typename[node_type(node)]);
455455
VTR_LOG("Node xlow: %d\n", node_xlow(node));
456456
VTR_LOG("Node ylow: %d\n", node_ylow(node));
457457
VTR_LOG("Node xhigh: %d\n", node_xhigh(node));

libs/librrgraph/src/base/rr_graph_storage.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -608,10 +608,10 @@ bool t_rr_graph_storage::validate(const vtr::vector<RRSwitchId, t_rr_switch_inf>
608608
}
609609

610610
const char* t_rr_graph_storage::node_type_string(RRNodeId id) const {
611-
return rr_node_typename[(size_t)node_type(id)];
611+
return rr_node_typename[node_type(id)];
612612
}
613613
const char* t_rr_graph_view::node_type_string(RRNodeId id) const {
614-
return rr_node_typename[(size_t)node_type(id)];
614+
return rr_node_typename[node_type(id)];
615615
}
616616

617617
const std::string& t_rr_graph_storage::node_direction_string(RRNodeId id) const {
@@ -675,7 +675,7 @@ static int get_node_pin_num(
675675
RRNodeId id) {
676676
e_rr_type node_type = node_storage[id].type_;
677677
if (node_type != e_rr_type::IPIN && node_type != e_rr_type::OPIN) {
678-
VTR_LOG_ERROR("Attempted to access RR node 'pin_num' for non-IPIN/OPIN type '%s'", rr_node_typename[(size_t)node_type]);
678+
VTR_LOG_ERROR("Attempted to access RR node 'pin_num' for non-IPIN/OPIN type '%s'", rr_node_typename[node_type]);
679679
}
680680
return node_ptc[id].ptc_.pin_num;
681681
}
@@ -686,7 +686,7 @@ static int get_node_track_num(
686686
RRNodeId id) {
687687
e_rr_type node_type = node_storage[id].type_;
688688
if (node_type != e_rr_type::CHANX && node_type != e_rr_type::CHANY) {
689-
VTR_LOG_ERROR("Attempted to access RR node 'track_num' for non-CHANX/CHANY type '%s'", rr_node_typename[(size_t)node_type]);
689+
VTR_LOG_ERROR("Attempted to access RR node 'track_num' for non-CHANX/CHANY type '%s'", rr_node_typename[node_type]);
690690
}
691691
return node_ptc[id].ptc_.track_num;
692692
}
@@ -697,7 +697,7 @@ static int get_node_class_num(
697697
RRNodeId id) {
698698
e_rr_type node_type = node_storage[id].type_;
699699
if (node_type != e_rr_type::SOURCE && node_type != e_rr_type::SINK) {
700-
VTR_LOG_ERROR("Attempted to access RR node 'class_num' for non-SOURCE/SINK type '%s'", rr_node_typename[(size_t)node_type]);
700+
VTR_LOG_ERROR("Attempted to access RR node 'class_num' for non-SOURCE/SINK type '%s'", rr_node_typename[node_type]);
701701
}
702702
return node_ptc[id].ptc_.class_num;
703703
}

libs/librrgraph/src/base/rr_graph_storage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ class t_rr_graph_storage {
783783
auto& node_data = node_storage[id];
784784
if (node_data.type_ != e_rr_type::IPIN && node_data.type_ != e_rr_type::OPIN) {
785785
VTR_LOG_ERROR("Attempted to access RR node 'side' for non-IPIN/OPIN type '%s'",
786-
rr_node_typename[(size_t)node_data.type_]);
786+
rr_node_typename[node_data.type_]);
787787
}
788788
// Return a vector showing only the sides that the node appears
789789
std::bitset<NUM_2D_SIDES> side_tt = node_storage[id].dir_side_.sides;

libs/librrgraph/src/base/rr_node_types.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
#include <array>
88
#include <map>
99
#include <cstdint>
10+
1011
#include "vtr_range.h"
12+
#include "vtr_array.h"
1113
#include "vtr_ndmatrix.h"
1214
#include "rr_graph_fwd.h"
1315

@@ -32,7 +34,8 @@ enum class e_rr_type : unsigned char {
3234

3335
constexpr std::array<e_rr_type, (size_t)e_rr_type::NUM_RR_TYPES> RR_TYPES = {{e_rr_type::SOURCE, e_rr_type::SINK, e_rr_type::IPIN,
3436
e_rr_type::OPIN, e_rr_type::CHANX, e_rr_type::CHANY}};
35-
constexpr std::array<const char*, (size_t)e_rr_type::NUM_RR_TYPES> rr_node_typename{{"SOURCE", "SINK", "IPIN", "OPIN", "CHANX", "CHANY"}};
37+
38+
vtr::array<e_rr_type, const char*, (size_t)e_rr_type::NUM_RR_TYPES> rr_node_typename {"SOURCE", "SINK", "IPIN", "OPIN", "CHANX", "CHANY"};
3639

3740
/**
3841
* @enum Direction
@@ -123,4 +126,4 @@ struct t_rr_rc_data {
123126

124127
// This is the data type of fast lookups of an rr-node given an (rr_type, layer, x, y, and the side)
125128
//[0..num_rr_types-1][0..num_layer-1][0..grid_width-1][0..grid_height-1][0..NUM_2D_SIDES-1][0..max_ptc-1]
126-
typedef std::array<vtr::NdMatrix<std::vector<RRNodeId>, 4>, (size_t)e_rr_type::NUM_RR_TYPES> t_rr_node_indices;
129+
typedef vtr::array<e_rr_type, vtr::NdMatrix<std::vector<RRNodeId>, 4>, (size_t)e_rr_type::NUM_RR_TYPES> t_rr_node_indices;

vpr/src/base/old_traceback.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ void print_traceback(const t_trace* trace) {
120120
const t_trace* prev = nullptr;
121121
while (trace) {
122122
RRNodeId inode(trace->index);
123-
VTR_LOG("%d (%s)", inode, rr_node_typename[(size_t)rr_graph.node_type(inode)]);
123+
VTR_LOG("%d (%s)", inode, rr_node_typename[rr_graph.node_type(inode)]);
124124

125125
if (trace->iswitch == OPEN) {
126126
VTR_LOG(" !"); //End of branch

vpr/src/route/router_lookahead_map_utils.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ t_src_opin_delays compute_router_src_opin_lookahead(bool is_flat) {
411411
//No untried instances of the current tile type left
412412
VTR_LOG_WARN("Found no %ssample locations for %s in %s\n",
413413
(num_sampled_locs == 0) ? "" : "more ",
414-
rr_node_typename[(size_t)rr_type],
414+
rr_node_typename[rr_type],
415415
device_ctx.physical_tile_types[itile].name.c_str());
416416
break;
417417
}
@@ -442,7 +442,7 @@ t_src_opin_delays compute_router_src_opin_lookahead(bool is_flat) {
442442
}
443443
if (reachable_wire_found) {
444444
VTR_LOGV_DEBUG(f_router_debug, "Found no reachable wires from %s (%s) at (%d,%d,%d)\n",
445-
rr_node_typename[(size_t)rr_type],
445+
rr_node_typename[rr_type],
446446
rr_node_arch_name(node_id, is_flat).c_str(),
447447
sample_loc.x,
448448
sample_loc.y,
@@ -783,7 +783,7 @@ t_routing_cost_map get_routing_cost_map(int longest_seg_length,
783783

784784
if (sample_nodes.empty()) {
785785
VTR_LOG_WARN("Unable to find any sample location for segment %s type '%s' (length %d)\n",
786-
rr_node_typename[(size_t)chan_type],
786+
rr_node_typename[chan_type],
787787
segment_inf.name.c_str(),
788788
segment_inf.length);
789789
} else {
@@ -914,7 +914,7 @@ void dump_readable_router_lookahead_map(const std::string& file_name, const std:
914914
auto cost = wire_cost_func(chan_type, seg_index, from_layer_num, dx, dy, to_layer_num);
915915
ofs << from_layer_num << ","
916916
<< to_layer_num << ","
917-
<< rr_node_typename[(size_t)chan_type] << ","
917+
<< rr_node_typename[chan_type] << ","
918918
<< seg_index << ","
919919
<< dx << ","
920920
<< dy << ","

vpr/src/route/rr_graph2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,8 +1554,8 @@ bool verify_rr_node_indices(const DeviceGrid& grid,
15541554

15551555
if (rr_graph.node_type(inode) != rr_type) {
15561556
VPR_ERROR(VPR_ERROR_ROUTE, "RR node type does not match between rr_nodes and rr_node_indices (%s/%s): %s",
1557-
rr_node_typename[(size_t)rr_graph.node_type(inode)],
1558-
rr_node_typename[(size_t)rr_type],
1557+
rr_node_typename[rr_graph.node_type(inode)],
1558+
rr_node_typename[rr_type],
15591559
describe_rr_node(rr_graph, grid, rr_indexed_data, inode, is_flat).c_str());
15601560
}
15611561

vpr/src/route/rr_graph_area.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ void count_bidir_routing_transistors(int num_switch, int wire_to_ipin_switch, fl
228228
VPR_ERROR(VPR_ERROR_ROUTE,
229229
"in count_routing_transistors:\n"
230230
"\tUnexpected connection from node %d (type %s) to node %d (type %s).\n",
231-
from_node, rr_node_typename[(size_t)from_rr_type], size_t(to_node), rr_node_typename[(size_t)to_rr_type]);
231+
from_node, rr_node_typename[from_rr_type], size_t(to_node), rr_node_typename[to_rr_type]);
232232
break;
233233

234234
} /* End switch on to_rr_type. */

0 commit comments

Comments
 (0)