diff --git a/vpr/src/base/vpr_context.h b/vpr/src/base/vpr_context.h index 75ec2d3f489..ec5fc63bfd2 100644 --- a/vpr/src/base/vpr_context.h +++ b/vpr/src/base/vpr_context.h @@ -149,7 +149,7 @@ struct DeviceContext : public Context { */ t_rr_graph_storage rr_nodes; // autogenerated in build_rr_graph - std::vector rr_indexed_data; // [0 .. num_rr_indexed_data-1] + vtr::vector rr_indexed_data; // [0 .. num_rr_indexed_data-1] ///@brief Fly-weighted Resistance/Capacitance data for RR Nodes std::vector rr_rc_data; diff --git a/vpr/src/device/rr_graph_fwd.h b/vpr/src/device/rr_graph_fwd.h index ff74fe75058..29e07854596 100644 --- a/vpr/src/device/rr_graph_fwd.h +++ b/vpr/src/device/rr_graph_fwd.h @@ -15,11 +15,13 @@ class RRGraph; struct rr_node_id_tag; struct rr_edge_id_tag; +struct rr_indexed_data_id_tag; struct rr_switch_id_tag; struct rr_segment_id_tag; typedef vtr::StrongId RRNodeId; typedef vtr::StrongId RREdgeId; +typedef vtr::StrongId RRIndexedDataId; typedef vtr::StrongId RRSwitchId; typedef vtr::StrongId RRSegmentId; diff --git a/vpr/src/device/rr_graph_obj.cpp b/vpr/src/device/rr_graph_obj.cpp index 67a833d3b39..68c6f305b95 100644 --- a/vpr/src/device/rr_graph_obj.cpp +++ b/vpr/src/device/rr_graph_obj.cpp @@ -151,9 +151,9 @@ short RRGraph::node_class_num(const RRNodeId& node) const { return node_ptc_num(node); } -short RRGraph::node_cost_index(const RRNodeId& node) const { +RRIndexedDataId RRGraph::node_cost_index(const RRNodeId& node) const { VTR_ASSERT_SAFE(valid_node_id(node)); - return node_cost_indices_[node]; + return RRIndexedDataId(node_cost_indices_[node]); } Direction RRGraph::node_direction(const RRNodeId& node) const { @@ -990,9 +990,9 @@ void RRGraph::set_node_class_num(const RRNodeId& node, const short& class_id) { set_node_ptc_num(node, class_id); } -void RRGraph::set_node_cost_index(const RRNodeId& node, const short& cost_index) { +void RRGraph::set_node_cost_index(const RRNodeId& node, const RRIndexedDataId& cost_index) { VTR_ASSERT(valid_node_id(node)); - node_cost_indices_[node] = cost_index; + node_cost_indices_[node] = (size_t)cost_index; } void RRGraph::set_node_direction(const RRNodeId& node, const Direction& direction) { diff --git a/vpr/src/device/rr_graph_obj.h b/vpr/src/device/rr_graph_obj.h index 2bff93c8d20..5f7d47b9ba2 100644 --- a/vpr/src/device/rr_graph_obj.h +++ b/vpr/src/device/rr_graph_obj.h @@ -410,7 +410,7 @@ class RRGraph { * when used in evaluate different routing paths * See cross-reference section in this header file for more details */ - short node_cost_index(const RRNodeId& node) const; + RRIndexedDataId node_cost_index(const RRNodeId& node) const; /* Get the directionality of a node * see node coordinate for details @@ -669,7 +669,7 @@ class RRGraph { /* Set the routing cost index for node, see node_cost_index() for details */ /* TODO: the cost index should be changed to a StrongId!!! */ - void set_node_cost_index(const RRNodeId& node, const short& cost_index); + void set_node_cost_index(const RRNodeId& node, const RRIndexedDataId& cost_index); /* Set the directionality for a node, only applicable to CHANX and CHANY */ void set_node_direction(const RRNodeId& node, const Direction& direction); diff --git a/vpr/src/device/rr_graph_view.cpp b/vpr/src/device/rr_graph_view.cpp index 93cbe4394a8..3e87301b129 100644 --- a/vpr/src/device/rr_graph_view.cpp +++ b/vpr/src/device/rr_graph_view.cpp @@ -2,7 +2,7 @@ #include "rr_node.h" #include "physical_types.h" -RRGraphView::RRGraphView(const t_rr_graph_storage& node_storage, const RRSpatialLookup& node_lookup, const std::vector& rr_indexed_data, const std::vector& rr_segments) +RRGraphView::RRGraphView(const t_rr_graph_storage& node_storage, const RRSpatialLookup& node_lookup, const vtr::vector& rr_indexed_data, const std::vector& rr_segments) : node_storage_(node_storage) , node_lookup_(node_lookup) , rr_indexed_data_(rr_indexed_data) diff --git a/vpr/src/device/rr_graph_view.h b/vpr/src/device/rr_graph_view.h index 4c81e069b4d..2c3dc7839f2 100644 --- a/vpr/src/device/rr_graph_view.h +++ b/vpr/src/device/rr_graph_view.h @@ -37,7 +37,7 @@ class RRGraphView { /* See detailed comments about the data structures in the internal data storage section of this file */ RRGraphView(const t_rr_graph_storage& node_storage, const RRSpatialLookup& node_lookup, - const std::vector& rr_indexed_data, + const vtr::vector& rr_indexed_data, const std::vector& rr_segments); /* Disable copy constructors and copy assignment operator @@ -207,7 +207,7 @@ class RRGraphView { arrow = ""; } if (node_type(node) == CHANX || node_type(node) == CHANY) { //for channels, we would like to describe the component with segment specific information - int cost_index = node_cost_index(node); + RRIndexedDataId cost_index = node_cost_index(node); int seg_index = rr_indexed_data_[cost_index].seg_index; coordinate_string += rr_segments_[seg_index].name; //Write the segment name coordinate_string += " length:" + std::to_string(node_length(node)); //add the length of the segment @@ -245,7 +245,7 @@ class RRGraphView { } /** @brief Get the cost index of a routing resource node. This function is inlined for runtime optimization. */ - inline short node_cost_index(RRNodeId node) const { + RRIndexedDataId node_cost_index(RRNodeId node) const { return node_storage_.node_cost_index(node); } @@ -263,7 +263,7 @@ class RRGraphView { const RRSpatialLookup& node_lookup_; /* rr_indexed_data_ and rr_segments_ are needed to lookup the segment information in node_coordinate_to_string() */ - const std::vector& rr_indexed_data_; + const vtr::vector& rr_indexed_data_; /* Segment info for rr nodes */ const std::vector& rr_segments_; diff --git a/vpr/src/power/power.cpp b/vpr/src/power/power.cpp index a20d1cc246e..3fce2e3c391 100644 --- a/vpr/src/power/power.cpp +++ b/vpr/src/power/power.cpp @@ -858,6 +858,7 @@ static void power_usage_routing(t_power_usage* power_usage, for (size_t rr_node_idx = 0; rr_node_idx < device_ctx.rr_nodes.size(); rr_node_idx++) { t_power_usage sub_power_usage; auto node = device_ctx.rr_nodes[rr_node_idx]; + RRNodeId rr_node = RRNodeId(rr_node_idx); t_rr_node_power* node_power = &rr_node_power[rr_node_idx]; float C_wire; float buffer_size; @@ -865,9 +866,9 @@ static void power_usage_routing(t_power_usage* power_usage, int switchbox_fanout; //float C_per_seg_split; int wire_length; - const t_edge_size node_fan_in = rr_graph.node_fan_in(RRNodeId(rr_node_idx)); + const t_edge_size node_fan_in = rr_graph.node_fan_in(rr_node); - switch (rr_graph.node_type(RRNodeId(rr_node_idx))) { + switch (rr_graph.node_type(rr_node)) { case SOURCE: case SINK: case OPIN: @@ -905,12 +906,12 @@ static void power_usage_routing(t_power_usage* power_usage, VTR_ASSERT(node_power->in_prob); wire_length = 0; - if (rr_graph.node_type(RRNodeId(rr_node_idx)) == CHANX) { - wire_length = rr_graph.node_xhigh(node.id()) - rr_graph.node_xlow(node.id()) + 1; - } else if (rr_graph.node_type(RRNodeId(rr_node_idx)) == CHANY) { - wire_length = rr_graph.node_yhigh(node.id()) - rr_graph.node_ylow(node.id()) + 1; + if (rr_graph.node_type(rr_node) == CHANX) { + wire_length = rr_graph.node_xhigh(rr_node) - rr_graph.node_xlow(rr_node) + 1; + } else if (rr_graph.node_type(rr_node) == CHANY) { + wire_length = rr_graph.node_yhigh(rr_node) - rr_graph.node_ylow(rr_node) + 1; } - int seg_index = device_ctx.rr_indexed_data[node.cost_index()].seg_index; + int seg_index = device_ctx.rr_indexed_data[rr_graph.node_cost_index(rr_node)].seg_index; C_wire = wire_length * device_ctx.rr_segments[seg_index].Cmetal; //(double)power_ctx.commonly_used->tile_length); VTR_ASSERT(node_power->selected_input < node_fan_in); diff --git a/vpr/src/route/check_rr_graph.cpp b/vpr/src/route/check_rr_graph.cpp index 6fca0ff0580..f5712434eb1 100644 --- a/vpr/src/route/check_rr_graph.cpp +++ b/vpr/src/route/check_rr_graph.cpp @@ -295,7 +295,8 @@ void check_rr_node(int inode, enum e_route_type route_type, const DeviceContext& int xlow, ylow, xhigh, yhigh, ptc_num, capacity; t_rr_type rr_type; t_physical_tile_type_ptr type; - int nodes_per_chan, tracks_per_node, num_edges, cost_index; + int nodes_per_chan, tracks_per_node, num_edges; + RRIndexedDataId cost_index; float C, R; const auto& rr_graph = device_ctx.rr_graph; RRNodeId rr_node = RRNodeId(inode); @@ -307,7 +308,7 @@ void check_rr_node(int inode, enum e_route_type route_type, const DeviceContext& yhigh = rr_graph.node_yhigh(rr_node); ptc_num = device_ctx.rr_nodes[inode].ptc_num(); capacity = rr_graph.node_capacity(rr_node); - cost_index = device_ctx.rr_nodes[inode].cost_index(); + cost_index = rr_graph.node_cost_index(rr_node); type = nullptr; const auto& grid = device_ctx.grid; @@ -326,7 +327,7 @@ void check_rr_node(int inode, enum e_route_type route_type, const DeviceContext& "in check_rr_node: inode %d (type %d) had a ptc_num of %d.\n", inode, rr_type, ptc_num); } - if (cost_index < 0 || cost_index >= (int)device_ctx.rr_indexed_data.size()) { + if (!cost_index || (size_t)cost_index >= (size_t)device_ctx.rr_indexed_data.size()) { VPR_FATAL_ERROR(VPR_ERROR_ROUTE, "in check_rr_node: node %d cost index (%d) is out of range.\n", inode, cost_index); } diff --git a/vpr/src/route/clock_connection_builders.cpp b/vpr/src/route/clock_connection_builders.cpp index 3ef789e1d41..46a53dc048b 100644 --- a/vpr/src/route/clock_connection_builders.cpp +++ b/vpr/src/route/clock_connection_builders.cpp @@ -109,8 +109,9 @@ RRNodeId RoutingToClockConnection::create_virtual_clock_network_sink_node(int x, rr_graph.set_node_ptc_num(node_index, ptc); rr_graph_builder.set_node_coordinates(node_index, x, y, x, y); rr_graph_builder.set_node_capacity(node_index, 1); - rr_graph.set_node_cost_index(node_index, SINK_COST_INDEX); + rr_graph.set_node_cost_index(node_index, RRIndexedDataId(SINK_COST_INDEX)); rr_graph.set_node_type(node_index, SINK); + float R = 0.; float C = 0.; rr_graph.set_node_rc_index(node_index, find_create_rr_rc_data(R, C)); diff --git a/vpr/src/route/clock_network_builders.cpp b/vpr/src/route/clock_network_builders.cpp index f0befe29a63..bd5037f5f99 100644 --- a/vpr/src/route/clock_network_builders.cpp +++ b/vpr/src/route/clock_network_builders.cpp @@ -342,7 +342,7 @@ int ClockRib::create_chanx_wire(int x_start, VTR_ASSERT_MSG(false, "Unidentified direction type for clock rib"); break; } - node.set_cost_index(CHANX_COST_INDEX_START + seg_index); // Actual value set later + node.set_cost_index(RRIndexedDataId(CHANX_COST_INDEX_START + seg_index)); // Actual value set later /* Add the node to spatial lookup */ auto& rr_graph = (*rr_nodes); @@ -648,7 +648,7 @@ int ClockSpine::create_chany_wire(int y_start, VTR_ASSERT_MSG(false, "Unidentified direction type for clock rib"); break; } - node.set_cost_index(CHANX_COST_INDEX_START + num_segments + seg_index); + node.set_cost_index(RRIndexedDataId(CHANX_COST_INDEX_START + num_segments + seg_index)); /* Add the node to spatial lookup */ auto& rr_graph = (*rr_nodes); diff --git a/vpr/src/route/route_common.h b/vpr/src/route/route_common.h index 7ad4456da45..8d97295aba9 100644 --- a/vpr/src/route/route_common.h +++ b/vpr/src/route/route_common.h @@ -34,7 +34,7 @@ float get_rr_cong_cost(int inode, float pres_fac); /* Returns the base cost of using this rr_node */ inline float get_single_rr_cong_base_cost(int inode) { auto& device_ctx = g_vpr_ctx.device(); - auto cost_index = device_ctx.rr_nodes[inode].cost_index(); + auto cost_index = device_ctx.rr_graph.node_cost_index(RRNodeId(inode)); return device_ctx.rr_indexed_data[cost_index].base_cost; } @@ -78,7 +78,7 @@ inline float get_single_rr_cong_cost(int inode, float pres_fac) { pres_cost = 1.; } - auto cost_index = device_ctx.rr_nodes[inode].cost_index(); + auto cost_index = rr_graph.node_cost_index(RRNodeId(inode)); float cost = device_ctx.rr_indexed_data[cost_index].base_cost * route_ctx.rr_node_route_inf[inode].acc_cost * pres_cost; diff --git a/vpr/src/route/route_timing.cpp b/vpr/src/route/route_timing.cpp index 71ae1fa3a1f..6bff8de5d61 100644 --- a/vpr/src/route/route_timing.cpp +++ b/vpr/src/route/route_timing.cpp @@ -1550,10 +1550,10 @@ void update_rr_base_costs(int fanout) { factor = sqrt(fanout); for (index = CHANX_COST_INDEX_START; index < device_ctx.rr_indexed_data.size(); index++) { - if (device_ctx.rr_indexed_data[index].T_quadratic > 0.) { /* pass transistor */ - device_ctx.rr_indexed_data[index].base_cost = device_ctx.rr_indexed_data[index].saved_base_cost * factor; + if (device_ctx.rr_indexed_data[RRIndexedDataId(index)].T_quadratic > 0.) { /* pass transistor */ + device_ctx.rr_indexed_data[RRIndexedDataId(index)].base_cost = device_ctx.rr_indexed_data[RRIndexedDataId(index)].saved_base_cost * factor; } else { - device_ctx.rr_indexed_data[index].base_cost = device_ctx.rr_indexed_data[index].saved_base_cost; + device_ctx.rr_indexed_data[RRIndexedDataId(index)].base_cost = device_ctx.rr_indexed_data[RRIndexedDataId(index)].saved_base_cost; } } } diff --git a/vpr/src/route/router_lookahead.cpp b/vpr/src/route/router_lookahead.cpp index 3f1fb17c1b7..be65c60c903 100644 --- a/vpr/src/route/router_lookahead.cpp +++ b/vpr/src/route/router_lookahead.cpp @@ -61,13 +61,13 @@ std::pair ClassicLookahead::get_expected_delay_and_cong(RRNodeId n int num_segs_ortho_dir = 0; int num_segs_same_dir = get_expected_segs_to_target(node, target_node, &num_segs_ortho_dir); - int cost_index = device_ctx.rr_nodes.node_cost_index(node); + auto cost_index = rr_graph.node_cost_index(node); int ortho_cost_index = device_ctx.rr_indexed_data[cost_index].ortho_cost_index; const auto& same_data = device_ctx.rr_indexed_data[cost_index]; - const auto& ortho_data = device_ctx.rr_indexed_data[ortho_cost_index]; - const auto& ipin_data = device_ctx.rr_indexed_data[IPIN_COST_INDEX]; - const auto& sink_data = device_ctx.rr_indexed_data[SINK_COST_INDEX]; + const auto& ortho_data = device_ctx.rr_indexed_data[RRIndexedDataId(ortho_cost_index)]; + const auto& ipin_data = device_ctx.rr_indexed_data[RRIndexedDataId(IPIN_COST_INDEX)]; + const auto& sink_data = device_ctx.rr_indexed_data[RRIndexedDataId(SINK_COST_INDEX)]; float cong_cost = num_segs_same_dir * same_data.base_cost + num_segs_ortho_dir * ortho_data.base_cost @@ -83,7 +83,7 @@ std::pair ClassicLookahead::get_expected_delay_and_cong(RRNodeId n return std::make_pair(params.criticality * Tdel, (1 - params.criticality) * cong_cost); } else if (rr_type == IPIN) { /* Change if you're allowing route-throughs */ - return std::make_pair(0., device_ctx.rr_indexed_data[SINK_COST_INDEX].base_cost); + return std::make_pair(0., device_ctx.rr_indexed_data[RRIndexedDataId(SINK_COST_INDEX)].base_cost); } else { /* Change this if you want to investigate route-throughs */ return std::make_pair(0., 0.); @@ -113,17 +113,18 @@ static int get_expected_segs_to_target(RRNodeId inode, RRNodeId target_node, int const auto& rr_graph = device_ctx.rr_graph; t_rr_type rr_type; - int target_x, target_y, num_segs_same_dir, cost_index, ortho_cost_index; + int target_x, target_y, num_segs_same_dir, ortho_cost_index; + RRIndexedDataId cost_index; int no_need_to_pass_by_clb; float inv_length, ortho_inv_length, ylow, yhigh, xlow, xhigh; target_x = rr_graph.node_xlow(target_node); target_y = rr_graph.node_ylow(target_node); - cost_index = device_ctx.rr_nodes.node_cost_index(inode); + cost_index = rr_graph.node_cost_index(inode); inv_length = device_ctx.rr_indexed_data[cost_index].inv_length; ortho_cost_index = device_ctx.rr_indexed_data[cost_index].ortho_cost_index; - ortho_inv_length = device_ctx.rr_indexed_data[ortho_cost_index].inv_length; + ortho_inv_length = device_ctx.rr_indexed_data[RRIndexedDataId(ortho_cost_index)].inv_length; rr_type = rr_graph.node_type(inode); if (rr_type == CHANX) { diff --git a/vpr/src/route/router_lookahead_cost_map.cpp b/vpr/src/route/router_lookahead_cost_map.cpp index b15f605f21c..9e3de711d9d 100644 --- a/vpr/src/route/router_lookahead_cost_map.cpp +++ b/vpr/src/route/router_lookahead_cost_map.cpp @@ -59,10 +59,7 @@ void CostMap::set_counts(size_t seg_count) { */ int CostMap::node_to_segment(int from_node_ind) const { const auto& device_ctx = g_vpr_ctx.device(); - - auto& from_node = device_ctx.rr_nodes[from_node_ind]; - - int from_cost_index = from_node.cost_index(); + auto from_cost_index = device_ctx.rr_graph.node_cost_index(RRNodeId(from_node_ind)); return device_ctx.rr_indexed_data[from_cost_index].seg_index; } diff --git a/vpr/src/route/router_lookahead_extended_map.cpp b/vpr/src/route/router_lookahead_extended_map.cpp index ac37e597646..3411a5bfddd 100644 --- a/vpr/src/route/router_lookahead_extended_map.cpp +++ b/vpr/src/route/router_lookahead_extended_map.cpp @@ -293,8 +293,7 @@ bool ExtendedMapLookahead::add_paths(RRNodeId start_node, auto parent = start_node; for (auto it = path.rbegin(); it != path.rend(); it++) { RRNodeId this_node(*it); - auto& here = device_ctx.rr_nodes[*it]; - int seg_index = device_ctx.rr_indexed_data[here.cost_index()].seg_index; + int seg_index = device_ctx.rr_indexed_data[rr_graph.node_cost_index(this_node)].seg_index; int from_x = rr_graph.node_xlow(this_node); int from_y = rr_graph.node_ylow(this_node); @@ -587,7 +586,7 @@ float ExtendedMapLookahead::get_expected_cost( } else if (rr_type == IPIN) { /* Change if you're allowing route-throughs */ // This is to return only the cost between the IPIN and SINK. No need to // query the cost map, as the routing of this connection is almost done. - return device_ctx.rr_indexed_data[SINK_COST_INDEX].base_cost; + return device_ctx.rr_indexed_data[RRIndexedDataId(SINK_COST_INDEX)].base_cost; } else { /* Change this if you want to investigate route-throughs */ return 0.; } diff --git a/vpr/src/route/router_lookahead_map.cpp b/vpr/src/route/router_lookahead_map.cpp index 94f957280a9..e87c9fb4d19 100644 --- a/vpr/src/route/router_lookahead_map.cpp +++ b/vpr/src/route/router_lookahead_map.cpp @@ -146,11 +146,12 @@ class PQ_Entry { this->rr_node = set_rr_node; auto& device_ctx = g_vpr_ctx.device(); + const auto& rr_graph = device_ctx.rr_graph; this->delay = parent_delay; this->congestion_upstream = parent_congestion_upstream; this->R_upstream = parent_R_upstream; if (!starting_node) { - int cost_index = device_ctx.rr_nodes.node_cost_index(RRNodeId(set_rr_node)); + auto cost_index = rr_graph.node_cost_index(RRNodeId(set_rr_node)); //this->delay += rr_graph.node_C(RRNodeId(set_rr_node)) * (g_rr_switch_inf[switch_ind].R + 0.5*rr_graph.node_R(RRNodeId(set_rr_node))) + // g_rr_switch_inf[switch_ind].Tdel; @@ -243,7 +244,7 @@ float MapLookahead::get_expected_cost(RRNodeId current_node, RRNodeId target_nod std::tie(delay_cost, cong_cost) = get_expected_delay_and_cong(current_node, target_node, params, R_upstream); return delay_cost + cong_cost; } else if (rr_type == IPIN) { /* Change if you're allowing route-throughs */ - return (device_ctx.rr_indexed_data[SINK_COST_INDEX].base_cost); + return (device_ctx.rr_indexed_data[RRIndexedDataId(SINK_COST_INDEX)].base_cost); } else { /* Change this if you want to investigate route-throughs */ return (0.); } @@ -335,7 +336,7 @@ std::pair MapLookahead::get_expected_delay_and_cong(RRNodeId from_ VTR_ASSERT_SAFE(from_type == CHANX || from_type == CHANY); //When estimating costs from a wire, we directly look-up the result in the wire lookahead (f_wire_cost_map) - int from_cost_index = rr_graph.node_cost_index(from_node); + auto from_cost_index = temp_rr_graph.node_cost_index(from_node); int from_seg_index = device_ctx.rr_indexed_data[from_cost_index].seg_index; VTR_ASSERT(from_seg_index >= 0); @@ -355,7 +356,7 @@ std::pair MapLookahead::get_expected_delay_and_cong(RRNodeId from_ describe_rr_node(size_t(from_node)).c_str()) .c_str()); } else if (from_type == IPIN) { /* Change if you're allowing route-throughs */ - return std::make_pair(0., device_ctx.rr_indexed_data[SINK_COST_INDEX].base_cost); + return std::make_pair(0., device_ctx.rr_indexed_data[RRIndexedDataId(SINK_COST_INDEX)].base_cost); } else { /* Change this if you want to investigate route-throughs */ return std::make_pair(0., 0.); } @@ -478,8 +479,8 @@ static void compute_router_wire_lookahead(const std::vector& segm auto rr_type = temp_rr_graph.node_type(rr_node); if (rr_type != chan_type) continue; - int cost_index = rr_graph.node_cost_index(rr_node); - VTR_ASSERT(cost_index != OPEN); + auto cost_index = temp_rr_graph.node_cost_index(rr_node); + VTR_ASSERT(cost_index != RRIndexedDataId(OPEN)); int seg_index = device_ctx.rr_indexed_data[cost_index].seg_index; @@ -544,9 +545,8 @@ static void compute_router_wire_lookahead(const std::vector& segm /* returns index of a node from which to start routing */ static RRNodeId get_start_node(int start_x, int start_y, int target_x, int target_y, t_rr_type rr_type, int seg_index, int track_offset) { auto& device_ctx = g_vpr_ctx.device(); - const auto& temp_rr_graph = device_ctx.rr_graph; //TODO rename to rr_graph once the rr_graph below is unneeded - auto& rr_graph = device_ctx.rr_nodes; - const auto& node_lookup = device_ctx.rr_graph.node_lookup(); + const auto& rr_graph = device_ctx.rr_graph; + const auto& node_lookup = rr_graph.node_lookup(); RRNodeId result = RRNodeId::INVALID(); @@ -565,10 +565,10 @@ static RRNodeId get_start_node(int start_x, int start_y, int target_x, int targe /* find first node in channel that has specified segment index and goes in the desired direction */ for (const RRNodeId& node_id : node_lookup.find_channel_nodes(start_lookup_x, start_lookup_y, rr_type)) { - VTR_ASSERT(temp_rr_graph.node_type(node_id) == rr_type); + VTR_ASSERT(rr_graph.node_type(node_id) == rr_type); Direction node_direction = rr_graph.node_direction(node_id); - int node_cost_ind = rr_graph.node_cost_index(node_id); + auto node_cost_ind = rr_graph.node_cost_index(node_id); int node_seg_ind = device_ctx.rr_indexed_data[node_cost_ind].seg_index; if ((node_direction == direction || node_direction == Direction::BIDIR) && node_seg_ind == seg_index) { diff --git a/vpr/src/route/router_lookahead_map_utils.cpp b/vpr/src/route/router_lookahead_map_utils.cpp index 811c16ca7d0..a535fa129af 100644 --- a/vpr/src/route/router_lookahead_map_utils.cpp +++ b/vpr/src/route/router_lookahead_map_utils.cpp @@ -469,7 +469,7 @@ static void dijkstra_flood_to_wires(int itile, RRNodeId node, util::t_src_opin_d int seg_index; if (curr_rr_type != SINK) { //It's a wire, figure out its type - int cost_index = rr_graph.node_cost_index(curr.node); + auto cost_index = temp_rr_graph.node_cost_index(curr.node); seg_index = device_ctx.rr_indexed_data[cost_index].seg_index; } else { //This is a direct-connect path between an IPIN and OPIN, @@ -493,7 +493,7 @@ static void dijkstra_flood_to_wires(int itile, RRNodeId node, util::t_src_opin_d } else if (curr_rr_type == SOURCE || curr_rr_type == OPIN || curr_rr_type == IPIN) { //We allow expansion through SOURCE/OPIN/IPIN types - int cost_index = rr_graph.node_cost_index(curr.node); + auto cost_index = temp_rr_graph.node_cost_index(curr.node); float incr_cong = device_ctx.rr_indexed_data[cost_index].base_cost; //Current nodes congestion cost for (RREdgeId edge : rr_graph.edge_range(curr.node)) { @@ -588,7 +588,7 @@ static void dijkstra_flood_to_ipins(RRNodeId node, util::t_chan_ipins_delays& ch } //We allow expansion through SOURCE/OPIN/IPIN types - int cost_index = rr_graph.node_cost_index(curr.node); + auto cost_index = temp_rr_graph.node_cost_index(curr.node); float new_cong = device_ctx.rr_indexed_data[cost_index].base_cost; //Current nodes congestion cost for (RREdgeId edge : rr_graph.edge_range(curr.node)) { diff --git a/vpr/src/route/router_lookahead_sampling.cpp b/vpr/src/route/router_lookahead_sampling.cpp index 1cd1d04a27d..a1101b834b3 100644 --- a/vpr/src/route/router_lookahead_sampling.cpp +++ b/vpr/src/route/router_lookahead_sampling.cpp @@ -128,19 +128,20 @@ static uint64_t interleave(uint32_t x) { static std::tuple get_node_info(const t_rr_node& node, int num_segments) { auto& device_ctx = g_vpr_ctx.device(); const auto& rr_graph = device_ctx.rr_graph; + RRNodeId rr_node = node.id(); - if (rr_graph.node_type(node.id()) != CHANX && rr_graph.node_type(node.id()) != CHANY) { + if (rr_graph.node_type(rr_node) != CHANX && rr_graph.node_type(rr_node) != CHANY) { return std::tuple(OPEN, OPEN, OPEN); } - if (rr_graph.node_capacity(node.id()) == 0 || node.num_edges() == 0) { + if (rr_graph.node_capacity(rr_node) == 0 || node.num_edges() == 0) { return std::tuple(OPEN, OPEN, OPEN); } - int x = rr_graph.node_xlow(node.id()); - int y = rr_graph.node_ylow(node.id()); + int x = rr_graph.node_xlow(rr_node); + int y = rr_graph.node_ylow(rr_node); - int seg_index = device_ctx.rr_indexed_data[node.cost_index()].seg_index; + int seg_index = device_ctx.rr_indexed_data[rr_graph.node_cost_index(rr_node)].seg_index; VTR_ASSERT(seg_index != OPEN); VTR_ASSERT(seg_index < num_segments); @@ -205,7 +206,7 @@ std::vector find_sample_regions(int num_segments) { for (auto& node : rr_nodes) { if (rr_graph.node_type(node.id()) != CHANX && rr_graph.node_type(node.id()) != CHANY) continue; if (rr_graph.node_capacity(node.id()) == 0 || node.num_edges() == 0) continue; - int seg_index = device_ctx.rr_indexed_data[node.cost_index()].seg_index; + int seg_index = device_ctx.rr_indexed_data[rr_graph.node_cost_index(node.id())].seg_index; VTR_ASSERT(seg_index != OPEN); VTR_ASSERT(seg_index < num_segments); diff --git a/vpr/src/route/rr_graph.cpp b/vpr/src/route/rr_graph.cpp index 1ed46860637..4dc5c50fae3 100644 --- a/vpr/src/route/rr_graph.cpp +++ b/vpr/src/route/rr_graph.cpp @@ -1405,7 +1405,7 @@ static void build_rr_sinks_sources(RRGraphBuilder& rr_graph_builder, rr_edges_to_create.emplace_back(inode, opin_nodes[iedge], delayless_switch); } - L_rr_node.set_node_cost_index(inode, SOURCE_COST_INDEX); + L_rr_node.set_node_cost_index(inode, RRIndexedDataId(SOURCE_COST_INDEX)); L_rr_node.set_node_type(inode, SOURCE); } else { /* SINK */ VTR_ASSERT(class_inf[iclass].type == RECEIVER); @@ -1423,7 +1423,7 @@ static void build_rr_sinks_sources(RRGraphBuilder& rr_graph_builder, * - set_node_cost_index(RRNodeId, int); * - set_node_type(RRNodeId, t_rr_type); */ - L_rr_node.set_node_cost_index(inode, SINK_COST_INDEX); + L_rr_node.set_node_cost_index(inode, RRIndexedDataId(SINK_COST_INDEX)); L_rr_node.set_node_type(inode, SINK); } @@ -1458,7 +1458,7 @@ static void build_rr_sinks_sources(RRGraphBuilder& rr_graph_builder, //Add info about the edge to be created rr_edges_to_create.emplace_back(inode, to_node, delayless_switch); - L_rr_node.set_node_cost_index(inode, IPIN_COST_INDEX); + L_rr_node.set_node_cost_index(inode, RRIndexedDataId(IPIN_COST_INDEX)); L_rr_node.set_node_type(inode, IPIN); } } else { @@ -1470,7 +1470,7 @@ static void build_rr_sinks_sources(RRGraphBuilder& rr_graph_builder, /* Output pins may not exist on some sides, we may not always find one */ if (inode) { //Initially left unconnected - L_rr_node.set_node_cost_index(inode, OPIN_COST_INDEX); + L_rr_node.set_node_cost_index(inode, RRIndexedDataId(OPIN_COST_INDEX)); L_rr_node.set_node_type(inode, OPIN); } } @@ -1656,7 +1656,7 @@ static void build_rr_chan(RRGraphBuilder& rr_graph_builder, } /* Edge arrays have now been built up. Do everything else. */ - L_rr_node.set_node_cost_index(node, cost_index_offset + seg_details[track].index()); + L_rr_node.set_node_cost_index(node, RRIndexedDataId(cost_index_offset + seg_details[track].index())); rr_graph_builder.set_node_capacity(node, 1); /* GLOBAL routing handled elsewhere */ if (chan_type == CHANX) { @@ -2431,7 +2431,7 @@ std::string describe_rr_node(int inode) { auto rr_node = device_ctx.rr_nodes[inode]; if (rr_graph.node_type(RRNodeId(inode)) == CHANX || rr_graph.node_type(RRNodeId(inode)) == CHANY) { - int cost_index = rr_node.cost_index(); + auto cost_index = rr_graph.node_cost_index(RRNodeId(inode)); int seg_index = device_ctx.rr_indexed_data[cost_index].seg_index; std::string rr_node_direction_string = rr_graph.node_direction_string(RRNodeId(inode)); diff --git a/vpr/src/route/rr_graph_indexed_data.cpp b/vpr/src/route/rr_graph_indexed_data.cpp index 2f87b6dfabb..85c751b3614 100644 --- a/vpr/src/route/rr_graph_indexed_data.cpp +++ b/vpr/src/route/rr_graph_indexed_data.cpp @@ -70,23 +70,23 @@ void alloc_and_load_rr_indexed_data(const std::vector& segment_in constexpr float nan = std::numeric_limits::quiet_NaN(); for (i = SOURCE_COST_INDEX; i <= IPIN_COST_INDEX; i++) { - device_ctx.rr_indexed_data[i].ortho_cost_index = OPEN; - device_ctx.rr_indexed_data[i].seg_index = OPEN; - device_ctx.rr_indexed_data[i].inv_length = nan; - device_ctx.rr_indexed_data[i].T_linear = 0.; - device_ctx.rr_indexed_data[i].T_quadratic = 0.; - device_ctx.rr_indexed_data[i].C_load = 0.; + device_ctx.rr_indexed_data[RRIndexedDataId(i)].ortho_cost_index = OPEN; + device_ctx.rr_indexed_data[RRIndexedDataId(i)].seg_index = OPEN; + device_ctx.rr_indexed_data[RRIndexedDataId(i)].inv_length = nan; + device_ctx.rr_indexed_data[RRIndexedDataId(i)].T_linear = 0.; + device_ctx.rr_indexed_data[RRIndexedDataId(i)].T_quadratic = 0.; + device_ctx.rr_indexed_data[RRIndexedDataId(i)].C_load = 0.; } - device_ctx.rr_indexed_data[IPIN_COST_INDEX].T_linear = device_ctx.rr_switch_inf[wire_to_ipin_switch].Tdel; + device_ctx.rr_indexed_data[RRIndexedDataId(IPIN_COST_INDEX)].T_linear = device_ctx.rr_switch_inf[wire_to_ipin_switch].Tdel; /* X-directed segments. */ for (iseg = 0; iseg < num_segment; iseg++) { index = CHANX_COST_INDEX_START + iseg; if ((index + num_segment) >= (int)device_ctx.rr_indexed_data.size()) { - device_ctx.rr_indexed_data[index].ortho_cost_index = index; + device_ctx.rr_indexed_data[RRIndexedDataId(index)].ortho_cost_index = index; } else { - device_ctx.rr_indexed_data[index].ortho_cost_index = index + num_segment; + device_ctx.rr_indexed_data[RRIndexedDataId(index)].ortho_cost_index = index + num_segment; } if (segment_inf[iseg].longline) @@ -94,8 +94,8 @@ void alloc_and_load_rr_indexed_data(const std::vector& segment_in else length = std::min(segment_inf[iseg].length, device_ctx.grid.width()); - device_ctx.rr_indexed_data[index].inv_length = 1. / length; - device_ctx.rr_indexed_data[index].seg_index = iseg; + device_ctx.rr_indexed_data[RRIndexedDataId(index)].inv_length = 1. / length; + device_ctx.rr_indexed_data[RRIndexedDataId(index)].seg_index = iseg; } /* Y-directed segments. */ @@ -103,9 +103,9 @@ void alloc_and_load_rr_indexed_data(const std::vector& segment_in index = CHANX_COST_INDEX_START + num_segment + iseg; if ((index - num_segment) < CHANX_COST_INDEX_START) { - device_ctx.rr_indexed_data[index].ortho_cost_index = index; + device_ctx.rr_indexed_data[RRIndexedDataId(index)].ortho_cost_index = index; } else { - device_ctx.rr_indexed_data[index].ortho_cost_index = index - num_segment; + device_ctx.rr_indexed_data[RRIndexedDataId(index)].ortho_cost_index = index - num_segment; } if (segment_inf[iseg].longline) @@ -113,8 +113,8 @@ void alloc_and_load_rr_indexed_data(const std::vector& segment_in else length = std::min(segment_inf[iseg].length, device_ctx.grid.height()); - device_ctx.rr_indexed_data[index].inv_length = 1. / length; - device_ctx.rr_indexed_data[index].seg_index = iseg; + device_ctx.rr_indexed_data[RRIndexedDataId(index)].inv_length = 1. / length; + device_ctx.rr_indexed_data[RRIndexedDataId(index)].seg_index = iseg; } load_rr_indexed_data_T_values(); @@ -134,18 +134,18 @@ void load_rr_index_segments(const int num_segment) { int iseg, i, index; for (i = SOURCE_COST_INDEX; i <= IPIN_COST_INDEX; i++) { - device_ctx.rr_indexed_data[i].seg_index = OPEN; + device_ctx.rr_indexed_data[RRIndexedDataId(i)].seg_index = OPEN; } /* X-directed segments. */ for (iseg = 0; iseg < num_segment; iseg++) { index = CHANX_COST_INDEX_START + iseg; - device_ctx.rr_indexed_data[index].seg_index = iseg; + device_ctx.rr_indexed_data[RRIndexedDataId(index)].seg_index = iseg; } /* Y-directed segments. */ for (iseg = 0; iseg < num_segment; iseg++) { index = CHANX_COST_INDEX_START + num_segment + iseg; - device_ctx.rr_indexed_data[index].seg_index = iseg; + device_ctx.rr_indexed_data[RRIndexedDataId(index)].seg_index = iseg; } } @@ -164,10 +164,10 @@ static void load_rr_indexed_data_base_costs(enum e_base_cost_type base_cost_type delay_normalization_fac = get_delay_normalization_fac(); } - device_ctx.rr_indexed_data[SOURCE_COST_INDEX].base_cost = delay_normalization_fac; - device_ctx.rr_indexed_data[SINK_COST_INDEX].base_cost = 0.; - device_ctx.rr_indexed_data[OPIN_COST_INDEX].base_cost = delay_normalization_fac; - device_ctx.rr_indexed_data[IPIN_COST_INDEX].base_cost = 0.95 * delay_normalization_fac; + device_ctx.rr_indexed_data[RRIndexedDataId(SOURCE_COST_INDEX)].base_cost = delay_normalization_fac; + device_ctx.rr_indexed_data[RRIndexedDataId(SINK_COST_INDEX)].base_cost = 0.; + device_ctx.rr_indexed_data[RRIndexedDataId(OPIN_COST_INDEX)].base_cost = delay_normalization_fac; + device_ctx.rr_indexed_data[RRIndexedDataId(IPIN_COST_INDEX)].base_cost = 0.95 * delay_normalization_fac; auto rr_segment_counts = count_rr_segment_types(); size_t total_segments = std::accumulate(rr_segment_counts.begin(), rr_segment_counts.end(), 0u); @@ -177,7 +177,7 @@ static void load_rr_indexed_data_base_costs(enum e_base_cost_type base_cost_type float min_length = 1; if (base_cost_type == DELAY_NORMALIZED_LENGTH_BOUNDED) { for (index = CHANX_COST_INDEX_START; index < device_ctx.rr_indexed_data.size(); index++) { - float length = (1 / device_ctx.rr_indexed_data[index].inv_length); + float length = (1 / device_ctx.rr_indexed_data[RRIndexedDataId(index)].inv_length); max_length = std::max(max_length, length); } } @@ -188,39 +188,39 @@ static void load_rr_indexed_data_base_costs(enum e_base_cost_type base_cost_type for (index = CHANX_COST_INDEX_START; index < device_ctx.rr_indexed_data.size(); index++) { if (base_cost_type == DELAY_NORMALIZED || base_cost_type == DEMAND_ONLY) { - device_ctx.rr_indexed_data[index].base_cost = delay_normalization_fac; + device_ctx.rr_indexed_data[RRIndexedDataId(index)].base_cost = delay_normalization_fac; } else if (base_cost_type == DELAY_NORMALIZED_LENGTH || base_cost_type == DEMAND_ONLY_NORMALIZED_LENGTH) { - device_ctx.rr_indexed_data[index].base_cost = delay_normalization_fac / device_ctx.rr_indexed_data[index].inv_length; + device_ctx.rr_indexed_data[RRIndexedDataId(index)].base_cost = delay_normalization_fac / device_ctx.rr_indexed_data[RRIndexedDataId(index)].inv_length; } else if (base_cost_type == DELAY_NORMALIZED_LENGTH_BOUNDED) { - float length = (1 / device_ctx.rr_indexed_data[index].inv_length); + float length = (1 / device_ctx.rr_indexed_data[RRIndexedDataId(index)].inv_length); if (max_length != min_length) { float length_scale = 1.f + 3.f * (length - min_length) / (max_length - min_length); - device_ctx.rr_indexed_data[index].base_cost = delay_normalization_fac * length_scale; + device_ctx.rr_indexed_data[RRIndexedDataId(index)].base_cost = delay_normalization_fac * length_scale; } else { - device_ctx.rr_indexed_data[index].base_cost = delay_normalization_fac; + device_ctx.rr_indexed_data[RRIndexedDataId(index)].base_cost = delay_normalization_fac; } } else if (base_cost_type == DELAY_NORMALIZED_FREQUENCY) { - int seg_index = device_ctx.rr_indexed_data[index].seg_index; + int seg_index = device_ctx.rr_indexed_data[RRIndexedDataId(index)].seg_index; VTR_ASSERT(total_segments > 0); float freq_fac = float(rr_segment_counts[seg_index]) / total_segments; - device_ctx.rr_indexed_data[index].base_cost = delay_normalization_fac / freq_fac; + device_ctx.rr_indexed_data[RRIndexedDataId(index)].base_cost = delay_normalization_fac / freq_fac; } else if (base_cost_type == DELAY_NORMALIZED_LENGTH_FREQUENCY) { - int seg_index = device_ctx.rr_indexed_data[index].seg_index; + int seg_index = device_ctx.rr_indexed_data[RRIndexedDataId(index)].seg_index; VTR_ASSERT(total_segments > 0); float freq_fac = float(rr_segment_counts[seg_index]) / total_segments; //Base cost = delay_norm / (len * freq) - //device_ctx.rr_indexed_data[index].base_cost = delay_normalization_fac / ((1. / device_ctx.rr_indexed_data[index].inv_length) * freq_fac); + //device_ctx.rr_indexed_data[RRIndexedDataId(index)].base_cost = delay_normalization_fac / ((1. / device_ctx.rr_indexed_data[RRIndexedDataId(index)].inv_length) * freq_fac); //Base cost = (delay_norm * len) * (1 + (1-freq)) - device_ctx.rr_indexed_data[index].base_cost = (delay_normalization_fac / device_ctx.rr_indexed_data[index].inv_length) * (1 + (1 - freq_fac)); + device_ctx.rr_indexed_data[RRIndexedDataId(index)].base_cost = (delay_normalization_fac / device_ctx.rr_indexed_data[RRIndexedDataId(index)].inv_length) * (1 + (1 - freq_fac)); } else { VPR_FATAL_ERROR(VPR_ERROR_ROUTE, "Unrecognized base cost type"); @@ -232,7 +232,7 @@ static void load_rr_indexed_data_base_costs(enum e_base_cost_type base_cost_type * able to restore them from a saved version is useful. */ for (index = 0; index < device_ctx.rr_indexed_data.size(); index++) { - device_ctx.rr_indexed_data[index].saved_base_cost = device_ctx.rr_indexed_data[index].base_cost; + device_ctx.rr_indexed_data[RRIndexedDataId(index)].saved_base_cost = device_ctx.rr_indexed_data[RRIndexedDataId(index)].base_cost; } } @@ -245,7 +245,7 @@ static std::vector count_rr_segment_types() { for (size_t inode = 0; inode < device_ctx.rr_nodes.size(); ++inode) { if (rr_graph.node_type(RRNodeId(inode)) != CHANX && rr_graph.node_type(RRNodeId(inode)) != CHANY) continue; - int cost_index = device_ctx.rr_nodes[inode].cost_index(); + auto cost_index = rr_graph.node_cost_index(RRNodeId(inode)); int seg_index = device_ctx.rr_indexed_data[cost_index].seg_index; @@ -271,8 +271,8 @@ static float get_delay_normalization_fac() { float Tdel_sum = 0.0; int Tdel_num = 0; for (size_t cost_index = CHANX_COST_INDEX_START; cost_index < rr_indexed_data.size(); cost_index++) { - float inv_length = device_ctx.rr_indexed_data[cost_index].inv_length; - float T_value = rr_indexed_data[cost_index].T_linear * inv_length + rr_indexed_data[cost_index].T_quadratic * std::pow(inv_length, 2); + float inv_length = device_ctx.rr_indexed_data[RRIndexedDataId(cost_index)].inv_length; + float T_value = rr_indexed_data[RRIndexedDataId(cost_index)].T_linear * inv_length + rr_indexed_data[RRIndexedDataId(cost_index)].T_quadratic * std::pow(inv_length, 2); if (T_value == 0.0) continue; @@ -320,9 +320,9 @@ static void load_rr_indexed_data_T_values() { auto fan_in_list = get_fan_in_list(); - std::vector num_nodes_of_index(rr_indexed_data.size(), 0); - std::vector> C_total(rr_indexed_data.size()); - std::vector> R_total(rr_indexed_data.size()); + vtr::vector num_nodes_of_index(rr_indexed_data.size(), 0); + vtr::vector> C_total(rr_indexed_data.size()); + vtr::vector> R_total(rr_indexed_data.size()); /* * Not all wire-to-wire switches connecting from some wire segment will necessarily have the same delay. @@ -331,10 +331,10 @@ static void load_rr_indexed_data_T_values() { * them for a single wire segment, and then by averaging this value over all the average values corresponding * to the switches node */ - std::vector> switch_R_total(rr_indexed_data.size()); - std::vector> switch_T_total(rr_indexed_data.size()); - std::vector> switch_Cinternal_total(rr_indexed_data.size()); - std::vector switches_buffered(rr_indexed_data.size(), UNDEFINED); + vtr::vector> switch_R_total(rr_indexed_data.size()); + vtr::vector> switch_T_total(rr_indexed_data.size()); + vtr::vector> switch_Cinternal_total(rr_indexed_data.size()); + vtr::vector switches_buffered(rr_indexed_data.size(), UNDEFINED); /* * Walk through the RR graph and collect all R and C values of all the nodes, @@ -350,7 +350,7 @@ static void load_rr_indexed_data_T_values() { continue; } - int cost_index = rr_nodes[inode].cost_index(); + auto cost_index = rr_graph.node_cost_index(RRNodeId(inode)); /* get average switch parameters */ double avg_switch_R = 0; @@ -396,26 +396,26 @@ static void load_rr_indexed_data_T_values() { for (size_t cost_index = CHANX_COST_INDEX_START; cost_index < rr_indexed_data.size(); cost_index++) { - if (num_nodes_of_index[cost_index] == 0) { /* Segments don't exist. */ + if (num_nodes_of_index[RRIndexedDataId(cost_index)] == 0) { /* Segments don't exist. */ VTR_LOG_WARN("Found no instances of RR node with cost index %d\n", cost_index); - rr_indexed_data[cost_index].T_linear = 0.0; - rr_indexed_data[cost_index].T_quadratic = 0.0; - rr_indexed_data[cost_index].C_load = 0.0; + rr_indexed_data[RRIndexedDataId(cost_index)].T_linear = 0.0; + rr_indexed_data[RRIndexedDataId(cost_index)].T_quadratic = 0.0; + rr_indexed_data[RRIndexedDataId(cost_index)].C_load = 0.0; } else { - auto C_total_histogram = build_histogram(C_total[cost_index], 10); - auto R_total_histogram = build_histogram(R_total[cost_index], 10); - auto switch_R_total_histogram = build_histogram(switch_R_total[cost_index], 10); - auto switch_T_total_histogram = build_histogram(switch_T_total[cost_index], 10); - auto switch_Cinternal_total_histogram = build_histogram(switch_Cinternal_total[cost_index], 10); + auto C_total_histogram = build_histogram(C_total[RRIndexedDataId(cost_index)], 10); + auto R_total_histogram = build_histogram(R_total[RRIndexedDataId(cost_index)], 10); + auto switch_R_total_histogram = build_histogram(switch_R_total[RRIndexedDataId(cost_index)], 10); + auto switch_T_total_histogram = build_histogram(switch_T_total[RRIndexedDataId(cost_index)], 10); + auto switch_Cinternal_total_histogram = build_histogram(switch_Cinternal_total[RRIndexedDataId(cost_index)], 10); // Sort Rnode and Cnode - float Cnode = vtr::median(C_total[cost_index]); - float Rnode = vtr::median(R_total[cost_index]); + float Cnode = vtr::median(C_total[RRIndexedDataId(cost_index)]); + float Rnode = vtr::median(R_total[RRIndexedDataId(cost_index)]); float Rsw = get_histogram_mode(switch_R_total_histogram); float Tsw = get_histogram_mode(switch_T_total_histogram); float Cinternalsw = get_histogram_mode(switch_Cinternal_total_histogram); - if (switches_buffered[cost_index]) { + if (switches_buffered[RRIndexedDataId(cost_index)]) { // Here, we are computing the linear time delay for buffered switches. Tlinear is // the estimated sum of the intrinsic time delay of the switch and the two transient // responses. The key assumption behind the estimate is that one switch will be turned on @@ -424,18 +424,18 @@ static void load_rr_indexed_data_T_values() { // the combined capacitance of the node and internal capacitance of the switch. The // multiplication by the second term by 0.5 is the result of the Rnode being distributed halfway along a // wire segment's length times the total capacitance. - rr_indexed_data[cost_index].T_linear = Tsw + Rsw * (Cinternalsw + Cnode) - + 0.5 * Rnode * (Cnode + Cinternalsw); - rr_indexed_data[cost_index].T_quadratic = 0.; - rr_indexed_data[cost_index].C_load = 0.; + rr_indexed_data[RRIndexedDataId(cost_index)].T_linear = Tsw + Rsw * (Cinternalsw + Cnode) + + 0.5 * Rnode * (Cnode + Cinternalsw); + rr_indexed_data[RRIndexedDataId(cost_index)].T_quadratic = 0.; + rr_indexed_data[RRIndexedDataId(cost_index)].C_load = 0.; } else { /* Pass transistor, does not have an internal capacitance*/ - rr_indexed_data[cost_index].C_load = Cnode; + rr_indexed_data[RRIndexedDataId(cost_index)].C_load = Cnode; /* See Dec. 23, 1997 notes for deriviation of formulae. */ - rr_indexed_data[cost_index].T_linear = Tsw + 0.5 * Rsw * Cnode; - rr_indexed_data[cost_index].T_quadratic = (Rsw + Rnode) * 0.5 - * Cnode; + rr_indexed_data[RRIndexedDataId(cost_index)].T_linear = Tsw + 0.5 * Rsw * Cnode; + rr_indexed_data[RRIndexedDataId(cost_index)].T_quadratic = (Rsw + Rnode) * 0.5 + * Cnode; } } } @@ -514,10 +514,10 @@ static void fixup_rr_indexed_data_T_values(size_t num_segment) { // values in cost functions. for (size_t cost_index = CHANX_COST_INDEX_START; cost_index < CHANX_COST_INDEX_START + 2 * num_segment; cost_index++) { - int ortho_cost_index = device_ctx.rr_indexed_data[cost_index].ortho_cost_index; + int ortho_cost_index = device_ctx.rr_indexed_data[RRIndexedDataId(cost_index)].ortho_cost_index; - auto& indexed_data = device_ctx.rr_indexed_data[cost_index]; - auto& ortho_indexed_data = device_ctx.rr_indexed_data[ortho_cost_index]; + auto& indexed_data = device_ctx.rr_indexed_data[RRIndexedDataId(cost_index)]; + auto& ortho_indexed_data = device_ctx.rr_indexed_data[RRIndexedDataId(ortho_cost_index)]; // Check if this data is uninitialized, but the orthogonal data is // initialized. // Uninitialized data is set to zero by default. @@ -547,7 +547,7 @@ static void print_rr_index_info(const char* fname, const std::vector= std::numeric_limits::max()) { + if ((size_t)new_cost_index >= std::numeric_limits::max()) { VPR_FATAL_ERROR(VPR_ERROR_ROUTE, "Attempted to set cost_index_ %zu above cost_index storage max value.", new_cost_index); } - node.cost_index_ = new_cost_index; + node.cost_index_ = (size_t)new_cost_index; } void t_rr_graph_storage::set_node_rc_index(RRNodeId id, short new_rc_index) { diff --git a/vpr/src/route/rr_graph_storage.h b/vpr/src/route/rr_graph_storage.h index 3df04173789..80eed7d89d9 100644 --- a/vpr/src/route/rr_graph_storage.h +++ b/vpr/src/route/rr_graph_storage.h @@ -185,8 +185,8 @@ class t_rr_graph_storage { short node_capacity(RRNodeId id) const { return node_storage_[id].capacity_; } - short node_cost_index(RRNodeId id) const { - return node_storage_[id].cost_index_; + RRIndexedDataId node_cost_index(RRNodeId id) const { + return RRIndexedDataId(node_storage_[id].cost_index_); } Direction node_direction(RRNodeId id) const { @@ -472,7 +472,7 @@ class t_rr_graph_storage { void set_node_type(RRNodeId id, t_rr_type new_type); void set_node_coordinates(RRNodeId id, short x1, short y1, short x2, short y2); - void set_node_cost_index(RRNodeId, size_t new_cost_index); + void set_node_cost_index(RRNodeId, RRIndexedDataId new_cost_index); void set_node_rc_index(RRNodeId, short new_rc_index); void set_node_capacity(RRNodeId, short new_capacity); void set_node_direction(RRNodeId, Direction new_direction); @@ -752,8 +752,8 @@ class t_rr_graph_view { short node_capacity(RRNodeId id) const { return node_storage_[id].capacity_; } - short node_cost_index(RRNodeId id) const { - return node_storage_[id].cost_index_; + RRIndexedDataId node_cost_index(RRNodeId id) const { + return RRIndexedDataId(node_storage_[id].cost_index_); } Direction node_direction(RRNodeId id) const { diff --git a/vpr/src/route/rr_graph_uxsdcxx_serializer.h b/vpr/src/route/rr_graph_uxsdcxx_serializer.h index 765313d195e..06163dc0415 100644 --- a/vpr/src/route/rr_graph_uxsdcxx_serializer.h +++ b/vpr/src/route/rr_graph_uxsdcxx_serializer.h @@ -262,7 +262,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase { RRGraphBuilder* rr_graph_builder, RRGraphView* rr_graph, std::vector* rr_switch_inf, - std::vector* rr_indexed_data, + vtr::vector* rr_indexed_data, const size_t num_arch_switches, const t_arch_switch_inf* arch_switch_inf, const std::vector& segment_inf, @@ -704,26 +704,26 @@ class RrGraphSerializer final : public uxsd::RrGraphBase { auto node = (*rr_nodes_)[inode]; if (GRAPH_GLOBAL == graph_type_) { - node.set_cost_index(0); + node.set_cost_index(RRIndexedDataId(0)); } else if (rr_graph.node_type(node.id()) == CHANX) { - node.set_cost_index(CHANX_COST_INDEX_START + segment_id); - seg_index_[node.cost_index()] = segment_id; + node.set_cost_index(RRIndexedDataId(CHANX_COST_INDEX_START + segment_id)); + seg_index_[rr_graph.node_cost_index(node.id())] = segment_id; } else if (rr_graph.node_type(node.id()) == CHANY) { - node.set_cost_index(CHANX_COST_INDEX_START + segment_inf_.size() + segment_id); - seg_index_[node.cost_index()] = segment_id; + node.set_cost_index(RRIndexedDataId(CHANX_COST_INDEX_START + segment_inf_.size() + segment_id)); + seg_index_[rr_graph.node_cost_index(node.id())] = segment_id; } return inode; } inline void finish_node_segment(int& /*inode*/) final {} inline int get_node_segment_segment_id(const t_rr_node& node) final { - return (*rr_indexed_data_)[node.cost_index()].seg_index; + return (*rr_indexed_data_)[(*rr_graph_).node_cost_index(node.id())].seg_index; } inline const t_rr_node get_node_segment(const t_rr_node& node) final { return node; } inline bool has_node_segment(const t_rr_node& node) final { - return (*rr_indexed_data_)[node.cost_index()].seg_index != -1; + return (*rr_indexed_data_)[(*rr_graph_).node_cost_index(node.id())].seg_index != -1; } inline MetadataBind init_node_metadata(int& inode) final { @@ -772,16 +772,16 @@ class RrGraphSerializer final : public uxsd::RrGraphBase { case CHANY: break; case SOURCE: - node.set_cost_index(SOURCE_COST_INDEX); + node.set_cost_index(RRIndexedDataId(SOURCE_COST_INDEX)); break; case SINK: - node.set_cost_index(SINK_COST_INDEX); + node.set_cost_index(RRIndexedDataId(SINK_COST_INDEX)); break; case OPIN: - node.set_cost_index(OPIN_COST_INDEX); + node.set_cost_index(RRIndexedDataId(OPIN_COST_INDEX)); break; case IPIN: - node.set_cost_index(IPIN_COST_INDEX); + node.set_cost_index(RRIndexedDataId(IPIN_COST_INDEX)); break; default: report_error( @@ -1552,7 +1552,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase { VTR_ASSERT(rr_indexed_data_->size() == seg_index_.size()); for (size_t i = 0; i < seg_index_.size(); ++i) { - (*rr_indexed_data_)[i].seg_index = seg_index_[i]; + (*rr_indexed_data_)[RRIndexedDataId(i)].seg_index = seg_index_[RRIndexedDataId(i)]; } VTR_ASSERT(read_rr_graph_filename_ != nullptr); @@ -1841,7 +1841,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase { } // Temporary storage - std::vector seg_index_; + vtr::vector seg_index_; std::string temp_string_; // Constant mapping which is frequently used @@ -1854,7 +1854,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase { RRGraphBuilder* rr_graph_builder_; RRGraphView* rr_graph_; std::vector* rr_switch_inf_; - std::vector* rr_indexed_data_; + vtr::vector* rr_indexed_data_; t_rr_node_indices* rr_node_indices_; std::string* read_rr_graph_filename_; diff --git a/vpr/src/route/rr_node.cpp b/vpr/src/route/rr_node.cpp index dfa29dd5310..9af0d809419 100644 --- a/vpr/src/route/rr_node.cpp +++ b/vpr/src/route/rr_node.cpp @@ -71,7 +71,7 @@ void t_rr_node::set_class_num(short new_class_num) { storage_->set_node_class_num(id_, new_class_num); } -void t_rr_node::set_cost_index(size_t new_cost_index) { +void t_rr_node::set_cost_index(RRIndexedDataId new_cost_index) { storage_->set_node_cost_index(id_, new_cost_index); } diff --git a/vpr/src/route/rr_node.h b/vpr/src/route/rr_node.h index 4954612284f..4e24b34625a 100644 --- a/vpr/src/route/rr_node.h +++ b/vpr/src/route/rr_node.h @@ -100,7 +100,7 @@ class t_rr_node { short track_num() const; //Same as ptc_num() but checks that type() is consistent short class_num() const; //Same as ptc_num() but checks that type() is consistent - short cost_index() const; + RRIndexedDataId cost_index() const; short rc_index() const; bool is_node_on_specific_side(e_side side) const; @@ -115,7 +115,7 @@ class t_rr_node { void set_track_num(short); //Same as set_ptc_num() by checks type() is consistent void set_class_num(short); //Same as set_ptc_num() by checks type() is consistent - void set_cost_index(size_t); + void set_cost_index(RRIndexedDataId); void set_rc_index(short); void set_direction(Direction); diff --git a/vpr/src/route/rr_node_impl.h b/vpr/src/route/rr_node_impl.h index 7c8e8824f88..9c2a03c3a3f 100644 --- a/vpr/src/route/rr_node_impl.h +++ b/vpr/src/route/rr_node_impl.h @@ -118,10 +118,6 @@ inline short t_rr_node::class_num() const { return storage_->node_class_num(id_); } -inline short t_rr_node::cost_index() const { - return storage_->node_cost_index(id_); -} - inline bool t_rr_node::is_node_on_specific_side(e_side side) const { return storage_->is_node_on_specific_side(id_, side); } diff --git a/vpr/src/route/segment_stats.cpp b/vpr/src/route/segment_stats.cpp index 425814ba19d..2c54c69d0d9 100644 --- a/vpr/src/route/segment_stats.cpp +++ b/vpr/src/route/segment_stats.cpp @@ -20,7 +20,8 @@ void get_segment_usage_stats(std::vector& segment_inf) { * are counted as full-length segments (e.g. length 4 even if the last 2 * * units of wire were chopped off by the chip edge). */ - int length, max_segment_length, cost_index; + int length, max_segment_length; + RRIndexedDataId cost_index; int *seg_occ_by_length, *seg_cap_by_length; /* [0..max_segment_length] */ int *seg_occ_by_type, *seg_cap_by_type; /* [0..num_segment-1] */ float utilization; @@ -50,7 +51,7 @@ void get_segment_usage_stats(std::vector& segment_inf) { for (size_t inode = 0; inode < device_ctx.rr_nodes.size(); inode++) { if (rr_graph.node_type(RRNodeId(inode)) == CHANX || rr_graph.node_type(RRNodeId(inode)) == CHANY) { - cost_index = device_ctx.rr_nodes[inode].cost_index(); + cost_index = rr_graph.node_cost_index(RRNodeId(inode)); size_t seg_type = device_ctx.rr_indexed_data[cost_index].seg_index; if (!segment_inf[seg_type].longline) diff --git a/vpr/src/util/vpr_utils.cpp b/vpr/src/util/vpr_utils.cpp index 11ab5500763..ca4fc716e66 100644 --- a/vpr/src/util/vpr_utils.cpp +++ b/vpr/src/util/vpr_utils.cpp @@ -216,7 +216,7 @@ std::string rr_node_arch_name(int inode) { } else { VTR_ASSERT(rr_graph.node_type(RRNodeId(inode)) == CHANX || rr_graph.node_type(RRNodeId(inode)) == CHANY); //Wire segment name - auto cost_index = rr_node.cost_index(); + auto cost_index = rr_graph.node_cost_index(RRNodeId(inode)); int seg_index = device_ctx.rr_indexed_data[cost_index].seg_index; rr_node_arch_name += device_ctx.rr_segments[seg_index].name;