Skip to content

Commit 70e11a4

Browse files
committed
interchange: rr graph: adapt to use new RR graph library
Signed-off-by: Alessandro Comodi <[email protected]>
1 parent c4ad279 commit 70e11a4

File tree

1 file changed

+38
-19
lines changed

1 file changed

+38
-19
lines changed

vpr/src/route/rr_graph_fpga_interchange.cpp

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,13 @@ struct RR_Graph_Builder {
8787
RR_Graph_Builder(Device::Reader& arch_reader,
8888
const DeviceGrid& grid,
8989
DeviceContext& device_ctx,
90-
const std::vector<t_physical_tile_type>& physical_tile_types,
90+
t_rr_graph_storage& rr_nodes,
9191
const vtr::vector<RRSegmentId, t_segment_inf>& segment_inf,
92+
const std::vector<t_physical_tile_type>& physical_tile_types,
9293
const enum e_base_cost_type base_cost_type)
9394
: ar_(arch_reader)
9495
, device_ctx_(device_ctx)
96+
, rr_nodes_(rr_nodes)
9597
, segment_inf_(segment_inf)
9698
, grid_(grid)
9799
, base_cost_type_(base_cost_type) {
@@ -137,6 +139,7 @@ struct RR_Graph_Builder {
137139
private:
138140
Device::Reader& ar_;
139141
DeviceContext& device_ctx_;
142+
t_rr_graph_storage& rr_nodes_;
140143
const vtr::vector<RRSegmentId, t_segment_inf>& segment_inf_;
141144
const DeviceGrid& grid_;
142145
const enum e_base_cost_type base_cost_type_;
@@ -288,7 +291,7 @@ struct RR_Graph_Builder {
288291

289292
int it = 0;
290293

291-
for (auto const& switch_id : device_ctx_.rr_switch_inf) {
294+
for (auto const& switch_id : device_ctx_.rr_graph.rr_switch()) {
292295
VTR_LOG("Switch: %d Name:%s\n", it++, switch_id.name);
293296
}
294297

@@ -361,13 +364,20 @@ struct RR_Graph_Builder {
361364
std::set<std::tuple<int /*timing*/, bool /*buffered*/>> seen;
362365
pip_types(seen, ar_);
363366

364-
device_ctx_.rr_switch_inf.resize(seen.size() + 2);
367+
std::vector<t_rr_switch_inf> switches;
368+
switches.resize(seen.size() + 2);
365369

366370
std::vector<std::tuple<std::tuple<int, bool>, int>> temp_;
367-
process_switches_array<t_rr_switch_inf*, int>(ar_, seen, device_ctx_.rr_switch_inf.data(), temp_);
368-
for (auto i : temp_) {
371+
process_switches_array<std::vector<t_rr_switch_inf>&, int>(ar_, seen, switches, temp_);
372+
373+
auto& rr_switches = device_ctx_.rr_graph_builder.rr_switch();
374+
rr_switches.resize(seen.size() + 2);
375+
376+
for (int i = 0; i < (int)switches.size(); i++)
377+
rr_switches[RRSwitchId(i)] = switches[i];
378+
379+
for (auto i : temp_)
369380
pips_models_[std::get<0>(i)] = std::get<1>(i);
370-
}
371381
}
372382

373383
/*
@@ -1327,9 +1337,9 @@ struct RR_Graph_Builder {
13271337
chan_loc_map_[std::make_tuple(track_loc, track_type)][track_idx] = std::make_tuple(track_seg, track_R, track_C, end);
13281338
}
13291339

1330-
device_ctx_.rr_nodes.make_room_for_node(RRNodeId(rr_idx));
1340+
rr_nodes_.make_room_for_node(RRNodeId(rr_idx));
13311341
loc_type_idx_to_rr_idx_[std::make_tuple(loc, pin, j)] = rr_idx;
1332-
auto node = device_ctx_.rr_nodes[rr_idx];
1342+
auto node = rr_nodes_[rr_idx];
13331343
RRNodeId node_id = node.id();
13341344
device_ctx_.rr_graph_builder.set_node_type(node_id, pin);
13351345
device_ctx_.rr_graph_builder.set_node_capacity(node_id, 1);
@@ -1351,9 +1361,9 @@ struct RR_Graph_Builder {
13511361
continue;
13521362
e_rr_type pin = input ? e_rr_type::IPIN : e_rr_type::OPIN;
13531363

1354-
device_ctx_.rr_nodes.make_room_for_node(RRNodeId(rr_idx));
1364+
rr_nodes_.make_room_for_node(RRNodeId(rr_idx));
13551365
loc_type_idx_to_rr_idx_[std::make_tuple(loc, pin, j)] = rr_idx;
1356-
auto node = device_ctx_.rr_nodes[rr_idx];
1366+
auto node = rr_nodes_[rr_idx];
13571367
RRNodeId node_id = node.id();
13581368
device_ctx_.rr_graph_builder.set_node_type(node_id, pin);
13591369
device_ctx_.rr_graph_builder.set_node_capacity(node_id, 1);
@@ -1387,9 +1397,9 @@ struct RR_Graph_Builder {
13871397
std::tie(seg, R, C, end) = track.second;
13881398
std::tie(x1, y1) = end;
13891399

1390-
device_ctx_.rr_nodes.make_room_for_node(RRNodeId(rr_idx));
1400+
rr_nodes_.make_room_for_node(RRNodeId(rr_idx));
13911401
loc_type_idx_to_rr_idx_[std::make_tuple(loc, type, track.first)] = rr_idx;
1392-
auto node = device_ctx_.rr_nodes[rr_idx];
1402+
auto node = rr_nodes_[rr_idx];
13931403
RRNodeId node_id = node.id();
13941404

13951405
device_ctx_.rr_graph_builder.set_node_type(node_id, type);
@@ -1413,11 +1423,11 @@ struct RR_Graph_Builder {
14131423
}
14141424

14151425
void pack_rr_nodes() {
1416-
device_ctx_.rr_nodes.clear();
1426+
rr_nodes_.clear();
14171427
seg_index_.resize(CHANX_COST_INDEX_START + 2 * segment_inf_.size(), -1);
14181428
pack_tiles();
14191429
pack_chans();
1420-
device_ctx_.rr_nodes.shrink_to_fit();
1430+
rr_nodes_.shrink_to_fit();
14211431
}
14221432

14231433
void pack_tiles_edges() {
@@ -1553,8 +1563,8 @@ struct RR_Graph_Builder {
15531563
device_ctx_.rr_graph_builder.node_lookup().resize_nodes(grid_.width(), grid_.height(), rr_type, NUM_SIDES);
15541564
}
15551565
}
1556-
for (size_t node = 0; node < device_ctx_.rr_nodes.size(); node++) {
1557-
auto rr_node = device_ctx_.rr_nodes[node];
1566+
for (size_t node = 0; node < rr_nodes_.size(); node++) {
1567+
auto rr_node = rr_nodes_[node];
15581568
device_ctx_.rr_graph_builder.add_node_to_all_locs(rr_node.id());
15591569
}
15601570

@@ -1595,9 +1605,11 @@ void build_rr_graph_fpga_interchange(const t_graph_type graph_type,
15951605

15961606
auto& device_ctx = g_vpr_ctx.mutable_device();
15971607
size_t num_segments = segment_inf.size();
1598-
device_ctx.rr_segments.reserve(num_segments);
1608+
1609+
auto& rr_segments = device_ctx.rr_graph_builder.rr_segments();
1610+
rr_segments.reserve(num_segments);
15991611
for (long unsigned int iseg = 0; iseg < num_segments; ++iseg) {
1600-
device_ctx.rr_segments.push_back(segment_inf[(iseg)]);
1612+
rr_segments.push_back(segment_inf[(iseg)]);
16011613
}
16021614

16031615
// Decompress GZipped capnproto device file
@@ -1636,7 +1648,14 @@ void build_rr_graph_fpga_interchange(const t_graph_type graph_type,
16361648

16371649
auto device_reader = message_reader.getRoot<DeviceResources::Device>();
16381650

1639-
RR_Graph_Builder builder(device_reader, grid, device_ctx, device_ctx.physical_tile_types, device_ctx.rr_segments, base_cost_type);
1651+
RR_Graph_Builder builder(
1652+
device_reader,
1653+
grid,
1654+
device_ctx,
1655+
device_ctx.rr_graph_builder.rr_nodes(),
1656+
device_ctx.rr_graph.rr_segments(),
1657+
device_ctx.physical_tile_types,
1658+
base_cost_type);
16401659
builder.build_rr_graph();
16411660
*wire_to_rr_ipin_switch = 0;
16421661
device_ctx.read_rr_graph_filename.assign(get_arch_file_name());

0 commit comments

Comments
 (0)