Skip to content

Commit 5ddbbf3

Browse files
litghostkmurray
authored andcommitted
Fix rrgraph reload check when loading rrgraphs from disk.
Signed-off-by: Keith Rothman <[email protected]>
1 parent 0e90c88 commit 5ddbbf3

File tree

4 files changed

+31
-19
lines changed

4 files changed

+31
-19
lines changed

vpr/src/base/vpr_context.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ struct DeviceContext : public Context {
194194
* Clock Network
195195
********************************************************************/
196196
t_clock_arch* clock_arch;
197+
198+
// Name of rrgraph file read (if any).
199+
// Used to determine when reading rrgraph if file is already loaded.
200+
std::string read_rr_graph_filename;
197201
};
198202

199203
//State relating to power analysis

vpr/src/route/rr_graph.cpp

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -327,23 +327,27 @@ void create_rr_graph(const t_graph_type graph_type,
327327
const int num_directs,
328328
int* Warnings) {
329329
const auto& device_ctx = g_vpr_ctx.device();
330-
if (channel_widths_unchanged(device_ctx.chan_width, nodes_per_chan) && !device_ctx.rr_nodes.empty()) {
331-
//No change in channel width, so skip re-building RR graph
332-
VTR_LOG("RR graph channel widths unchanged, skipping RR graph rebuild\n");
333-
return;
334-
}
335-
336-
free_rr_graph();
337330

338331
if (!det_routing_arch->read_rr_graph_filename.empty()) {
339-
load_rr_file(graph_type,
340-
grid,
341-
nodes_per_chan,
342-
segment_inf,
343-
base_cost_type,
344-
&det_routing_arch->wire_to_rr_ipin_switch,
345-
det_routing_arch->read_rr_graph_filename.c_str());
332+
if (device_ctx.read_rr_graph_filename != det_routing_arch->read_rr_graph_filename) {
333+
free_rr_graph();
334+
335+
load_rr_file(graph_type,
336+
grid,
337+
segment_inf,
338+
base_cost_type,
339+
&det_routing_arch->wire_to_rr_ipin_switch,
340+
det_routing_arch->read_rr_graph_filename.c_str());
341+
}
346342
} else {
343+
if (channel_widths_unchanged(device_ctx.chan_width, nodes_per_chan) && !device_ctx.rr_nodes.empty()) {
344+
//No change in channel width, so skip re-building RR graph
345+
VTR_LOG("RR graph channel widths unchanged, skipping RR graph rebuild\n");
346+
return;
347+
}
348+
349+
free_rr_graph();
350+
347351
build_rr_graph(graph_type,
348352
num_block_types,
349353
block_types,
@@ -1370,6 +1374,8 @@ void free_rr_graph() {
13701374
* allocated, as ALL the chunk allocated data is already free! */
13711375
auto& device_ctx = g_vpr_ctx.mutable_device();
13721376

1377+
device_ctx.read_rr_graph_filename.clear();
1378+
13731379
device_ctx.rr_node_indices.clear();
13741380

13751381
device_ctx.rr_nodes.clear();

vpr/src/route/rr_graph_reader.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void process_blocks(pugi::xml_node parent, const pugiutil::loc_data& loc_data);
5757
void verify_grid(pugi::xml_node parent, const pugiutil::loc_data& loc_data, const DeviceGrid& grid);
5858
void process_nodes(pugi::xml_node parent, const pugiutil::loc_data& loc_data);
5959
void process_edges(pugi::xml_node parent, const pugiutil::loc_data& loc_data, int* wire_to_rr_ipin_switch, const int num_rr_switches);
60-
void process_channels(t_chan_width& chan_width, pugi::xml_node parent, const pugiutil::loc_data& loc_data);
60+
void process_channels(t_chan_width& chan_width, const DeviceGrid& grid, pugi::xml_node parent, const pugiutil::loc_data& loc_data);
6161
void process_rr_node_indices(const DeviceGrid& grid);
6262
void process_seg_id(pugi::xml_node parent, const pugiutil::loc_data& loc_data);
6363
void set_cost_indices(pugi::xml_node parent, const pugiutil::loc_data& loc_data, const bool is_global_graph, const int num_seg_types);
@@ -69,7 +69,6 @@ void set_cost_indices(pugi::xml_node parent, const pugiutil::loc_data& loc_data,
6969
* structures as well*/
7070
void load_rr_file(const t_graph_type graph_type,
7171
const DeviceGrid& grid,
72-
t_chan_width nodes_per_chan,
7372
const std::vector<t_segment_inf>& segment_inf,
7473
const enum e_base_cost_type base_cost_type,
7574
int* wire_to_rr_ipin_switch,
@@ -131,7 +130,8 @@ void load_rr_file(const t_graph_type graph_type,
131130
VTR_LOG("Starting build routing resource graph...\n");
132131

133132
next_component = get_first_child(rr_graph, "channels", loc_data);
134-
process_channels(nodes_per_chan, next_component, loc_data);
133+
t_chan_width nodes_per_chan;
134+
process_channels(nodes_per_chan, grid, next_component, loc_data);
135135

136136
/* Decode the graph_type */
137137
bool is_global_graph = (GRAPH_GLOBAL == graph_type ? true : false);
@@ -177,6 +177,7 @@ void load_rr_file(const t_graph_type graph_type,
177177
process_seg_id(next_component, loc_data);
178178

179179
device_ctx.chan_width = nodes_per_chan;
180+
device_ctx.read_rr_graph_filename = std::string(read_rr_graph_name);
180181

181182
check_rr_graph(graph_type, grid, device_ctx.block_types);
182183

@@ -486,7 +487,7 @@ void process_edges(pugi::xml_node parent, const pugiutil::loc_data& loc_data, in
486487
}
487488

488489
/* All channel info is read in and loaded into device_ctx.chan_width*/
489-
void process_channels(t_chan_width& chan_width, pugi::xml_node parent, const pugiutil::loc_data& loc_data) {
490+
void process_channels(t_chan_width& chan_width, const DeviceGrid& grid, pugi::xml_node parent, const pugiutil::loc_data& loc_data) {
490491
pugi::xml_node channel, channelLists;
491492

492493
channel = get_first_child(parent, "channel", loc_data);
@@ -496,6 +497,8 @@ void process_channels(t_chan_width& chan_width, pugi::xml_node parent, const pug
496497
chan_width.y_min = get_attribute(channel, "y_min", loc_data).as_uint();
497498
chan_width.x_max = get_attribute(channel, "x_max", loc_data).as_uint();
498499
chan_width.y_max = get_attribute(channel, "y_max", loc_data).as_uint();
500+
chan_width.x_list.resize(grid.height());
501+
chan_width.y_list.resize(grid.width());
499502

500503
channelLists = get_first_child(parent, "x_list", loc_data);
501504
while (channelLists) {

vpr/src/route/rr_graph_reader.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
void load_rr_file(const t_graph_type graph_type,
88
const DeviceGrid& grid,
9-
t_chan_width nodes_per_chan,
109
const std::vector<t_segment_inf>& segment_inf,
1110
const enum e_base_cost_type base_cost_type,
1211
int* wire_to_rr_ipin_switch,

0 commit comments

Comments
 (0)