Skip to content

Commit 19e5196

Browse files
committed
Changes made based on suggestions from pull request
1 parent 8a5a5a8 commit 19e5196

12 files changed

+101
-114
lines changed

vpr/src/base/read_route.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ static void process_nodes(std::ifstream& fp, ClusterNetId inet, const char* file
216216

217217
/*remember the position of the last line in order to go back*/
218218
std::streampos oldpos = fp.tellg();
219-
int inode, x, y, x2, y2, ptc, switch_id, net_pin_id, offset;
219+
int inode, x, y, x2, y2, ptc, switch_id, net_pin_index, offset;
220220
std::string prev_type;
221221
int node_count = 0;
222222
std::string input;
@@ -348,23 +348,26 @@ static void process_nodes(std::ifstream& fp, ClusterNetId inet, const char* file
348348
switch_id = atoi(tokens[7 + offset].c_str());
349349
}
350350

351-
/*Process net pin index for sinks*/
351+
/* Process net pin index for sinks *
352+
* If you have an old .route file, it may not have this information *
353+
* Please check your .route file to see if it contains Net_pin_index *
354+
* information for sinks. If not, plrase re-generate the routing. */
352355
if (tokens[2] == "SINK") {
353356
if (tokens[8 + offset] == "Net_pin_index:") {
354-
net_pin_id = atoi(tokens[9 + offset].c_str());
357+
net_pin_index = atoi(tokens[9 + offset].c_str());
355358
} else {
356359
vpr_throw(VPR_ERROR_ROUTE, filename, lineno,
357-
"%d (sink) node does not have net pin index", inode);
360+
"%d (sink) node does not have net pin index. If you are using an old .route file without this information, please re-generate the routing.", inode);
358361
}
359362
} else {
360-
net_pin_id = OPEN;
363+
net_pin_index = OPEN; //net pin index is invalid for non-SINKs
361364
}
362365

363366
/* Allocate and load correct values to trace.head*/
364367
if (node_count == 0) {
365368
route_ctx.trace[inet].head = alloc_trace_data();
366369
route_ctx.trace[inet].head->index = inode;
367-
route_ctx.trace[inet].head->ipin = net_pin_id;
370+
route_ctx.trace[inet].head->net_pin_index = net_pin_index;
368371
route_ctx.trace[inet].head->iswitch = switch_id;
369372
route_ctx.trace[inet].head->next = nullptr;
370373
tptr = route_ctx.trace[inet].head;
@@ -373,7 +376,7 @@ static void process_nodes(std::ifstream& fp, ClusterNetId inet, const char* file
373376
tptr->next = alloc_trace_data();
374377
tptr = tptr->next;
375378
tptr->index = inode;
376-
tptr->ipin = net_pin_id;
379+
tptr->net_pin_index = net_pin_index;
377380
tptr->iswitch = switch_id;
378381
tptr->next = nullptr;
379382
node_count++;

vpr/src/base/vpr_types.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,15 +1315,16 @@ typedef std::array<vtr::NdMatrix<std::vector<int>, 3>, NUM_RR_TYPES> t_rr_node_i
13151315
* @brief Basic element used to store the traceback (routing) of each net.
13161316
*
13171317
* @param index Array index (ID) of this routing resource node.
1318-
* @param ipin: Net pin index associated with the node. This value *
1319-
* ranges from 1 to fanout [1..num_pins-1]. For cases when *
1320-
* different speed paths are taken to the same sink for *
1321-
* different pins, node index cannot uniquely identify *
1322-
* each sink, so the net pin index guarentees an unique *
1323-
* identification for each sink-type node. For non-sink- *
1324-
* type nodes and for sink-type nodes with no associated *
1325-
* net pin index, the value for this member should be set *
1326-
* to OPEN (-1). *
1318+
* @param net_pin_index: Net pin index associated with the node. This value
1319+
* ranges from 1 to fanout [1..num_pins-1]. For cases when
1320+
* different speed paths are taken to the same SINK for
1321+
* different pins, node index cannot uniquely identify
1322+
* each SINK, so the net pin index guarantees an unique
1323+
* identification for each SINK node. For non-SINK nodes
1324+
* and for SINK nodes with no associated net pin index
1325+
* (i.e. special SINKs like the source of a clock tree
1326+
* which do not correspond to an actual netlist connection),
1327+
* the value for this member should be set to OPEN (-1).
13271328
* @param iswitch Index of the switch type used to go from this rr_node to
13281329
* the next one in the routing. OPEN if there is no next node
13291330
* (i.e. this node is the last one (a SINK) in a branch of the
@@ -1333,7 +1334,7 @@ typedef std::array<vtr::NdMatrix<std::vector<int>, 3>, NUM_RR_TYPES> t_rr_node_i
13331334
struct t_trace {
13341335
t_trace* next;
13351336
int index;
1336-
int ipin = OPEN;
1337+
int net_pin_index = OPEN;
13371338
short iswitch;
13381339
};
13391340

vpr/src/route/connection_based_routing.cpp

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ Connection_based_routing_resources::Connection_based_routing_resources()
1212
, connection_criticality_tolerance{0.9f}
1313
, connection_delay_optimality_tolerance{1.1f} {
1414
/* Initialize the persistent data structures for incremental rerouting
15-
* this includes rr_sink_node_to_pin, which provides pin lookup given a
16-
* sink node for a specific net.
1715
*
1816
* remaining_targets will reserve enough space to ensure it won't need
1917
* to grow while storing the sinks that still need routing after pruning
@@ -31,50 +29,26 @@ Connection_based_routing_resources::Connection_based_routing_resources()
3129
reached_rt_sinks.reserve(max_sink_pins_per_net);
3230

3331
size_t routing_num_nets = cluster_ctx.clb_nlist.nets().size();
34-
rr_sink_node_to_pin.resize(routing_num_nets);
3532
lower_bound_connection_delay.resize(routing_num_nets);
3633
forcible_reroute_connection_flag.resize(routing_num_nets);
3734

3835
for (auto net_id : cluster_ctx.clb_nlist.nets()) {
39-
// unordered_map<int,int> net_node_to_pin;
40-
auto& net_node_to_pin = rr_sink_node_to_pin[net_id];
4136
auto& net_lower_bound_connection_delay = lower_bound_connection_delay[net_id];
4237
auto& net_forcible_reroute_connection_flag = forcible_reroute_connection_flag[net_id];
4338

44-
unsigned int num_pins = cluster_ctx.clb_nlist.net_pins(net_id).size();
45-
net_node_to_pin.reserve(num_pins); // not looking up on the SOURCE pin
39+
unsigned int num_pins = cluster_ctx.clb_nlist.net_pins(net_id).size(); // not looking up on the SOURCE pin
4640
net_lower_bound_connection_delay.resize(num_pins, std::numeric_limits<float>::infinity()); // will be filled in after the 1st iteration's
4741
net_forcible_reroute_connection_flag.reserve(num_pins); // all false to begin with
4842

4943
for (unsigned int ipin = 1; ipin < num_pins; ++ipin) {
5044
// rr sink node index corresponding to this connection terminal
5145
auto rr_sink_node = route_ctx.net_rr_terminals[net_id][ipin];
5246

53-
net_node_to_pin.insert({rr_sink_node, ipin});
5447
net_forcible_reroute_connection_flag.insert({rr_sink_node, false});
5548
}
5649
}
5750
}
5851

59-
bool Connection_based_routing_resources::sanity_check_lookup() const {
60-
auto& cluster_ctx = g_vpr_ctx.clustering();
61-
auto& route_ctx = g_vpr_ctx.routing();
62-
63-
for (auto net_id : cluster_ctx.clb_nlist.nets()) {
64-
const auto& net_node_to_pin = rr_sink_node_to_pin[net_id];
65-
66-
for (auto mapping : net_node_to_pin) {
67-
auto sanity = net_node_to_pin.find(mapping.first);
68-
if (sanity == net_node_to_pin.end()) {
69-
VTR_LOG("%d cannot find itself (net %lu)\n", mapping.first, size_t(net_id));
70-
return false;
71-
}
72-
VTR_ASSERT(route_ctx.net_rr_terminals[net_id][mapping.second] == mapping.first);
73-
}
74-
}
75-
return true;
76-
}
77-
7852
void Connection_based_routing_resources::set_lower_bound_connection_delays(ClbNetPinsMatrix<float>& net_delay) {
7953
/* Set the lower bound connection delays after first iteration, which only optimizes for timing delay.
8054
* This will be used later to judge the optimality of a connection, with suboptimal ones being candidates

vpr/src/route/connection_based_routing.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,6 @@
1515
// reroute only the connections to the ones that did not have a legal connection the previous time
1616
class Connection_based_routing_resources {
1717
// Incremental reroute resources --------------
18-
// conceptually works like rr_sink_node_to_pin[inet][sink_rr_node_index] to get the pin index for that net
19-
// each net maps SINK node index -> PIN index for net
20-
// only need to be built once at the start since the SINK nodes never change
21-
// the reverse lookup of route_ctx.net_rr_terminals
22-
// be careful: it is possible for multiple sinks to share the same node index in some cases.
23-
// rt_nodes already have pin index stored as a member, so in most cases, you do not
24-
// need this lookup. Only use this if necessary and if you are sure that a node index
25-
// can uniquely identify the node.
26-
vtr::vector<ClusterNetId, std::unordered_map<int, int>> rr_sink_node_to_pin;
2718

2819
// a property of each net, but only valid after pruning the previous route tree
2920
// the "targets" in question can be either rr_node indices or pin indices, the
@@ -46,7 +37,6 @@ class Connection_based_routing_resources {
4637
// get a handle on the resources
4738
std::vector<int>& get_remaining_targets() { return remaining_targets; }
4839
std::vector<t_rt_node*>& get_reached_rt_sinks() { return reached_rt_sinks; }
49-
vtr::vector<ClusterNetId, std::unordered_map<int, int>>& get_rr_sink_node_to_pin() { return rr_sink_node_to_pin; };
5040

5141
bool sanity_check_lookup() const;
5242

vpr/src/route/route_common.cpp

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static int num_linked_f_pointer_allocated = 0;
8686
* */
8787

8888
/******************** Subroutines local to route_common.c *******************/
89-
static t_trace_branch traceback_branch(int node, int target_pin, std::unordered_set<int>& main_branch_visited);
89+
static t_trace_branch traceback_branch(int node, int target_net_pin_index, std::unordered_set<int>& main_branch_visited);
9090
static std::pair<t_trace*, t_trace*> add_trace_non_configurable(t_trace* head, t_trace* tail, int node, std::unordered_set<int>& visited);
9191
static std::pair<t_trace*, t_trace*> add_trace_non_configurable_recurr(int node, std::unordered_set<int>& visited, int depth = 0);
9292

@@ -494,26 +494,28 @@ void init_route_structs(int bb_factor) {
494494
route_ctx.net_status.resize(cluster_ctx.clb_nlist.nets().size());
495495
}
496496

497-
t_trace* update_traceback(t_heap* hptr, int target_pin, ClusterNetId net_id) {
498-
/* This routine adds the most recently finished wire segment to the *
499-
* traceback linked list. The first connection starts with the net SOURCE *
500-
* and begins at the structure pointed to by route_ctx.trace[net_id].head. *
501-
* Each connection ends with a SINK. After each SINK, the next connection *
502-
* begins (if the net has more than 2 pins). The first element after the *
503-
* SINK gives the routing node on a previous piece of the routing, which is *
504-
* the link from the existing net to this new piece of the net. *
505-
* In each traceback I start at the end of a path and trace back through *
506-
* its predecessors to the beginning. I have stored information on the *
507-
* predecesser of each node to make traceback easy -- this sacrificies some *
508-
* memory for easier code maintenance. This routine returns a pointer to *
509-
* the first "new" node in the traceback (node not previously in trace). */
497+
/* This routine adds the most recently finished wire segment to the *
498+
* traceback linked list. The first connection starts with the net SOURCE *
499+
* and begins at the structure pointed to by route_ctx.trace[net_id].head. *
500+
* Each connection ends with a SINK. After each SINK, the next connection *
501+
* begins (if the net has more than 2 pins). The first element after the *
502+
* SINK gives the routing node on a previous piece of the routing, which is *
503+
* the link from the existing net to this new piece of the net. *
504+
* In each traceback I start at the end of a path, which is a SINK with *
505+
* target_net_pin_index (net pin index corresponding to the SINK, ranging *
506+
* from 1 to fanout), and trace back through its predecessors to the *
507+
* beginning. I have stored information on the predecesser of each node to *
508+
* make traceback easy -- this sacrificies some memory for easier code *
509+
* maintenance. This routine returns a pointer to the first "new" node in *
510+
* the traceback (node not previously in trace). */
511+
t_trace* update_traceback(t_heap* hptr, int target_net_pin_index, ClusterNetId net_id) {
510512
auto& route_ctx = g_vpr_ctx.mutable_routing();
511513

512514
auto& trace_nodes = route_ctx.trace_nodes[net_id];
513515

514516
VTR_ASSERT_SAFE(validate_trace_nodes(route_ctx.trace[net_id].head, trace_nodes));
515517

516-
t_trace_branch branch = traceback_branch(hptr->index, target_pin, trace_nodes);
518+
t_trace_branch branch = traceback_branch(hptr->index, target_net_pin_index, trace_nodes);
517519

518520
VTR_ASSERT_SAFE(validate_trace_nodes(branch.head, trace_nodes));
519521

@@ -530,9 +532,10 @@ t_trace* update_traceback(t_heap* hptr, int target_pin, ClusterNetId net_id) {
530532
return (ret_ptr);
531533
}
532534

533-
//Traces back a new routing branch starting from the specified 'node' and working backwards to any existing routing.
535+
//Traces back a new routing branch starting from the specified SINK 'node' with target_net_pin_index, which is the
536+
//net pin index corresponding to the SINK (ranging from 1 to fanout), and working backwards to any existing routing.
534537
//Returns the new branch, and also updates trace_nodes for any new nodes which are included in the branches traceback.
535-
static t_trace_branch traceback_branch(int node, int target_pin, std::unordered_set<int>& trace_nodes) {
538+
static t_trace_branch traceback_branch(int node, int target_net_pin_index, std::unordered_set<int>& trace_nodes) {
536539
auto& device_ctx = g_vpr_ctx.device();
537540
auto& route_ctx = g_vpr_ctx.routing();
538541

@@ -547,7 +550,7 @@ static t_trace_branch traceback_branch(int node, int target_pin, std::unordered_
547550
t_trace* branch_head = alloc_trace_data();
548551
t_trace* branch_tail = branch_head;
549552
branch_head->index = node;
550-
branch_head->ipin = target_pin;
553+
branch_head->net_pin_index = target_net_pin_index; //The first node is the SINK node, so store its net pin index
551554
branch_head->iswitch = OPEN;
552555
branch_head->next = nullptr;
553556

@@ -562,7 +565,7 @@ static t_trace_branch traceback_branch(int node, int target_pin, std::unordered_
562565
//Add the current node to the head of traceback
563566
t_trace* prev_ptr = alloc_trace_data();
564567
prev_ptr->index = inode;
565-
prev_ptr->ipin = OPEN;
568+
prev_ptr->net_pin_index = OPEN; //Net pin index is invalid for Non-SINK nodes
566569
prev_ptr->iswitch = device_ctx.rr_nodes.edge_switch(iedge);
567570
prev_ptr->next = branch_head;
568571
branch_head = prev_ptr;
@@ -1199,7 +1202,7 @@ alloc_trace_data() {
11991202
trace_free_head->next = nullptr;
12001203
}
12011204
temp_ptr = trace_free_head;
1202-
temp_ptr->ipin = OPEN; //default
1205+
temp_ptr->net_pin_index = OPEN; //default
12031206
trace_free_head = trace_free_head->next;
12041207
num_trace_allocated++;
12051208
return (temp_ptr);
@@ -1296,7 +1299,7 @@ void print_route(FILE* fp, const vtr::vector<ClusterNetId, t_traceback>& traceba
12961299

12971300
//Save net pin index for sinks
12981301
if (rr_type == SINK) {
1299-
fprintf(fp, " Net_pin_index: %d", tptr->ipin);
1302+
fprintf(fp, " Net_pin_index: %d", tptr->net_pin_index);
13001303
}
13011304

13021305
fprintf(fp, "\n");

vpr/src/route/route_common.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ void pathfinder_update_acc_cost_and_overuse_info(float acc_fac, OveruseInfo& ove
2222

2323
float update_pres_fac(float new_pres_fac);
2424

25-
t_trace* update_traceback(t_heap* hptr, int target_pin, ClusterNetId net_id);
25+
/* Pass in the hptr starting at a SINK with target_net_pin_index, which is the net pin index corresonding *
26+
* to the sink (ranging from 1 to fanout). Returns a pointer to the first "new" node in the traceback *
27+
* (node not previously in trace). */
28+
t_trace* update_traceback(t_heap* hptr, int target_net_pin_index, ClusterNetId net_id);
2629

2730
void reset_path_costs(const std::vector<int>& visited_rr_nodes);
2831

vpr/src/route/route_timing.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ bool try_timing_driven_route_tmpl(const t_router_opts& router_opts,
273273
}
274274

275275
CBRR connections_inf{};
276-
VTR_ASSERT_SAFE(connections_inf.sanity_check_lookup());
277276

278277
route_budgets budgeting_inf;
279278

@@ -1386,7 +1385,7 @@ static t_rt_node* setup_routing_resources(int itry,
13861385

13871386
// give lookup on the reached sinks
13881387
for (t_rt_node* sink_node : reached_rt_sinks) {
1389-
rt_node_of_sink[sink_node->ipin] = sink_node;
1388+
rt_node_of_sink[sink_node->net_pin_index] = sink_node;
13901389
}
13911390

13921391
profiling::net_rebuild_end(num_sinks, remaining_targets.size());

vpr/src/route/route_traceback.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ t_traceback::t_traceback(const t_traceback& other) {
88
//Deep-copy of traceback
99
t_trace* prev = nullptr;
1010
for (t_trace* other_curr = other.head; other_curr; other_curr = other_curr->next) {
11-
//VTR_LOG("Copying trace %p node: %d switch: %d pin(for sink): %d\n", other_curr, other_curr->index, other_curr->iswitch. other_curr->ipin);
11+
//VTR_LOG("Copying trace %p node: %d switch: %d pin(for sink): %d\n", other_curr, other_curr->index, other_curr->iswitch. other_curr->net_pin_index);
1212
t_trace* curr = alloc_trace_data();
1313

1414
curr->index = other_curr->index;
15-
curr->ipin = other_curr->ipin;
15+
curr->net_pin_index = other_curr->net_pin_index;
1616
curr->iswitch = other_curr->iswitch;
1717

1818
if (prev) {

0 commit comments

Comments
 (0)