Skip to content

Commit 5217e10

Browse files
author
Nathan Shreve
committed
Revert "set_sink_locs() now keeps track of tile types to avoid repeated calculations" as it resulted in a significant increase in runtime
This reverts commit 7bc80ac.
1 parent 7bc80ac commit 5217e10

File tree

3 files changed

+6
-36
lines changed

3 files changed

+6
-36
lines changed

libs/librrgraph/src/base/rr_graph_utils.cpp

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,9 @@ vtr::vector<RRNodeId, std::vector<RREdgeId>> get_fan_in_list(const RRGraphView&
9797
return node_fan_in_list;
9898
}
9999

100-
void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder, const DeviceGrid& grid) {
100+
void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder) {
101101
auto node_fanins = get_fan_in_list(rr_graph);
102102

103-
// Keep track of offsets for SINKs for each tile type, to avoid repeated
104-
// calculations
105-
std::unordered_map<std::string, std::unordered_map<size_t, vtr::Point<int>>> physical_type_offsets;
106-
107103
// Iterate over all SINK nodes
108104
for (size_t node = 0; node < rr_graph.num_nodes(); ++node) {
109105
auto node_id = RRNodeId(node);
@@ -117,24 +113,6 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
117113
if (tile_width == 0 && tile_height == 0)
118114
continue;
119115

120-
// See if we have encountered this tile before
121-
size_t tile_layer = rr_graph.node_layer(node_id);
122-
size_t node_x = rr_graph.node_xhigh(node_id);
123-
size_t node_y = rr_graph.node_yhigh(node_id);
124-
std::string tile_name = grid.get_physical_type({(int)node_x, (int)node_y, (int)tile_layer})->name;
125-
126-
size_t sink_ptc = rr_graph.node_ptc_num(node_id);
127-
128-
if ((physical_type_offsets.find(tile_name) != physical_type_offsets.end()) && (physical_type_offsets[tile_name].find(sink_ptc) != physical_type_offsets[tile_name].end())) { /* We have seen this tile before */
129-
auto new_x = (short)((int)node_x + physical_type_offsets[tile_name].at(sink_ptc).x());
130-
auto new_y = (short)((int)node_y + physical_type_offsets[tile_name].at(sink_ptc).y());
131-
132-
// Set new coordinates
133-
rr_graph_builder.set_node_coordinates(node_id, new_x, new_y, new_x, new_y);
134-
135-
continue;
136-
}
137-
138116
// The IPINs of the current SINK node
139117
std::unordered_set<RRNodeId> sink_ipins = {};
140118

@@ -148,7 +126,7 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
148126
// Make sure IPIN in the same cluster as origin
149127
int curr_x = rr_graph.node_xlow(pin);
150128
int curr_y = rr_graph.node_ylow(pin);
151-
if ((curr_x < rr_graph.node_xlow(pin)) || (curr_x > rr_graph.node_xhigh(pin)) || (curr_y < rr_graph.node_ylow(pin)) || (curr_y > rr_graph.node_yhigh(pin)))
129+
if ((curr_x < rr_graph.node_xlow(node_id)) || (curr_x > rr_graph.node_xhigh(node_id)) || (curr_y < rr_graph.node_ylow(node_id)) || (curr_y > rr_graph.node_yhigh(node_id)))
152130
continue;
153131

154132
sink_ipins.insert(pin);
@@ -168,8 +146,8 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
168146
int pin_x = rr_graph.node_xlow(pin);
169147
int pin_y = rr_graph.node_ylow(pin);
170148

171-
VTR_ASSERT_SAFE(pin_x = rr_graph.node_xhigh(pin));
172-
VTR_ASSERT_SAFE(pin_y = rr_graph.node_yhigh(pin));
149+
VTR_ASSERT_SAFE(pin_x == rr_graph.node_xhigh(pin));
150+
VTR_ASSERT_SAFE(pin_y == rr_graph.node_yhigh(pin));
173151

174152
x_coords.push_back((float)pin_x);
175153
y_coords.push_back((float)pin_y);
@@ -178,13 +156,6 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
178156
auto x_avg = (short)round(std::accumulate(x_coords.begin(), x_coords.end(), 0.f) / (double)x_coords.size());
179157
auto y_avg = (short)round(std::accumulate(y_coords.begin(), y_coords.end(), 0.f) / (double)y_coords.size());
180158

181-
// Save offset for this tile type
182-
if (physical_type_offsets.find(tile_name) == physical_type_offsets.end())
183-
physical_type_offsets[tile_name] = {};
184-
185-
physical_type_offsets[tile_name].insert({sink_ptc, {x_avg - (int)node_x, y_avg - (int)node_y}});
186-
187-
// Set new coordinates
188159
rr_graph_builder.set_node_coordinates(node_id, x_avg, y_avg, x_avg, y_avg);
189160
}
190161
}

libs/librrgraph/src/base/rr_graph_utils.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "rr_graph_fwd.h"
1515
#include "rr_node_types.h"
1616
#include "rr_graph_view.h"
17-
#include "device_grid.h"
1817

1918
struct t_pin_chain_node {
2019
int pin_physical_num = OPEN;
@@ -74,7 +73,7 @@ vtr::vector<RRNodeId, std::vector<RREdgeId>> get_fan_in_list(const RRGraphView&
7473
* determined. However, this is quite a big issue, as choosing to write out the RR graph now significantly increases
7574
* runtime!
7675
*/
77-
void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder, const DeviceGrid& grid);
76+
void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder);
7877

7978
/**
8079
* @brief Returns the segment number (distance along the channel) of the connection box from from_rr_type (CHANX or

vpr/src/route/rr_graph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,7 @@ static void build_rr_graph(const t_graph_type graph_type,
14381438
}
14391439

14401440
// Get better locations for SINK nodes
1441-
set_sink_locs(rr_graph, device_ctx.rr_graph_builder, device_ctx.grid);
1441+
set_sink_locs(rr_graph, device_ctx.rr_graph_builder);
14421442

14431443
// We are done with building the RR Graph. Thus, we can clear the storages only used
14441444
// to build the RR Graph

0 commit comments

Comments
 (0)