Skip to content

Commit 834f4ab

Browse files
committed
Modified the code a bit to understand how an API may be put into place.
Signed-off-by: Ethan Rogers <[email protected]>
1 parent 54071ae commit 834f4ab

14 files changed

+68109
-22
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# release #Build with compiler optimization
1818
# debug #Build with debug info and no compiler optimization
1919
# strict #Build VPR with warnings treated as errors
20-
BUILD_TYPE ?= release
20+
BUILD_TYPE ?= debug
2121

2222
#Convert to lower case for consistency
2323
BUILD_TYPE := $(shell echo $(BUILD_TYPE) | tr '[:upper:]' '[:lower:]')
@@ -105,7 +105,7 @@ endif #BUILD_TYPE
105105
#Final build
106106
#
107107
@echo "Building target(s): $(MAKECMDGOALS)"
108-
@+$(MAKE) -C $(BUILD_DIR) $(MAKECMDGOALS)
108+
@+$(MAKE) -C $(BUILD_DIR) $(MAKECMDGOALS) CXXFLAGS="-g"
109109
endif #clean
110110
endif #distclean
111111

vpr/src/place/timing_place_lookup.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,13 +351,13 @@ static float route_connection_delay(
351351
VTR_ASSERT(driver_ptc != OPEN);
352352

353353
int source_rr_node = get_rr_node_index(device_ctx.rr_node_indices, source_x, source_y, SOURCE, driver_ptc);
354-
355354
VTR_ASSERT(source_rr_node != OPEN);
356355

357356
for (int sink_ptc : best_sink_ptcs) {
358357
VTR_ASSERT(sink_ptc != OPEN);
359-
358+
360359
int sink_rr_node = get_rr_node_index(device_ctx.rr_node_indices, sink_x, sink_y, SINK, sink_ptc);
360+
//printf("sink:%d", sink_rr_node);
361361

362362
VTR_ASSERT(sink_rr_node != OPEN);
363363

vpr/src/route/gen/rr_graph_uxsdcxx.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vpr/src/route/route_timing.cpp

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ bool try_timing_driven_route_tmpl(const t_router_opts& router_opts,
322322
*/
323323
bool routing_is_successful = false;
324324
WirelengthInfo wirelength_info;
325+
//ESR API Access (get total number of nodes)
325326
OveruseInfo overuse_info(device_ctx.rr_nodes.size());
326327
tatum::TimingPathInfo critical_path;
327328
int itry; //Routing iteration number
@@ -545,6 +546,26 @@ bool try_timing_driven_route_tmpl(const t_router_opts& router_opts,
545546
best_clb_opins_used_locally = router_ctx.clb_opins_used_locally;
546547

547548
routing_is_successful = true;
549+
550+
// ESR print out path for a given net
551+
for (auto net_id : cluster_ctx.clb_nlist.nets()) {
552+
auto current_node = best_routing[net_id].head;
553+
std::cout << "-------\n";
554+
while (current_node != nullptr){
555+
auto current_type = device_ctx.rr_nodes[current_node->index].type_string();
556+
auto xlow = device_ctx.rr_nodes[current_node->index].xlow();
557+
auto xhigh = device_ctx.rr_nodes[current_node->index].xhigh();
558+
auto ylow = device_ctx.rr_nodes[current_node->index].ylow();
559+
auto yhigh = device_ctx.rr_nodes[current_node->index].yhigh();
560+
if ((xlow == xhigh) && (ylow == yhigh)){
561+
printf("Node: %d %s (%d,%d) \n", current_node->index, current_type, xlow, ylow);
562+
}
563+
else{
564+
printf("Node: %d %s (%d,%d) to (%d,%d) \n", current_node->index, current_type, xlow,ylow,xhigh,yhigh);
565+
}
566+
current_node = current_node->next;
567+
}
568+
}
548569

549570
//Update best metrics
550571
if (timing_info) {
@@ -786,7 +807,7 @@ bool try_timing_driven_route_tmpl(const t_router_opts& router_opts,
786807
VTR_LOG("Critical path: %g ns\n", 1e9 * best_routing_metrics.critical_path.delay());
787808
}
788809

789-
VTR_LOG("Successfully routed after %d routing iterations.\n", itry);
810+
VTR_LOG("#ESR timing Successfully routed after %d routing iterations.\n", itry);
790811
} else {
791812
VTR_LOG("Routing failed.\n");
792813

@@ -1158,11 +1179,12 @@ bool timing_driven_route_net(ConnectionRouter& router,
11581179
if (!cluster_ctx.clb_nlist.net_is_ignored(net_id)) {
11591180
for (unsigned ipin = 1; ipin < cluster_ctx.clb_nlist.net_pins(net_id).size(); ++ipin) {
11601181
if (net_delay[ipin] == 0) { // should be SOURCE->OPIN->IPIN->SINK
1182+
//ESR API Access (get type of node)
11611183
VTR_ASSERT(device_ctx.rr_nodes[rt_node_of_sink[ipin]->parent_node->parent_node->inode].type() == OPIN);
11621184
}
11631185
}
11641186
}
1165-
1187+
//ESR API Access (get capacity of node)
11661188
VTR_ASSERT_MSG(route_ctx.rr_node_route_inf[rt_root->inode].occ() <= device_ctx.rr_nodes[rt_root->inode].capacity(), "SOURCE should never be congested");
11671189

11681190
// route tree is not kept persistent since building it from the traceback the next iteration takes almost 0 time
@@ -1519,6 +1541,7 @@ void disable_expansion_and_remove_sink_from_route_tree_nodes(t_rt_node* rt_node)
15191541

15201542
while (linked_rt_edge != nullptr) {
15211543
child_node = linked_rt_edge->child;
1544+
//ESR API Access (get type of node)
15221545
if (device_ctx.rr_nodes[child_node->inode].type() == SINK) {
15231546
VTR_LOGV_DEBUG(f_router_debug,
15241547
"Removing sink %d from route tree\n", child_node->inode);
@@ -1607,6 +1630,7 @@ static bool should_route_net(ClusterNetId net_id, CBRR& connections_inf, bool if
16071630
for (;;) {
16081631
int inode = tptr->index;
16091632
int occ = route_ctx.rr_node_route_inf[inode].occ();
1633+
//ESR API Access (get capacity of node)
16101634
int capacity = device_ctx.rr_nodes[inode].capacity();
16111635

16121636
if (occ > capacity) {
@@ -1663,6 +1687,8 @@ static size_t calculate_wirelength_available() {
16631687
auto& device_ctx = g_vpr_ctx.device();
16641688

16651689
size_t available_wirelength = 0;
1690+
//ESR API Access (Get total number of nodes, type, and width/height of nodes, and available wirelength)
1691+
// But really what's happening is that this for loop iterates over every node and determines the available wirelength
16661692
for (size_t i = 0; i < device_ctx.rr_nodes.size(); ++i) {
16671693
if (device_ctx.rr_nodes[i].type() == CHANX || device_ctx.rr_nodes[i].type() == CHANY) {
16681694
size_t length_x = device_ctx.rr_nodes[i].xhigh() - device_ctx.rr_nodes[i].xlow();
@@ -1940,6 +1966,7 @@ static t_bb calc_current_bb(const t_trace* head) {
19401966
bb.ymax = 0;
19411967

19421968
for (const t_trace* elem = head; elem != nullptr; elem = elem->next) {
1969+
//ESR API Access (Direct access a node)
19431970
const t_rr_node& node = device_ctx.rr_nodes[elem->index];
19441971
//The router interprets RR nodes which cross the boundary as being
19451972
//'within' of the BB. Only those which are *strictly* out side the

vpr/src/route/route_tree_timing.cpp

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ bool alloc_route_tree_timing_structs(bool exists_ok) {
8080
/* Allocates any structures needed to build the routing trees. */
8181

8282
auto& device_ctx = g_vpr_ctx.device();
83-
83+
//ESR API Access (Get total number of nodes)
8484
bool route_tree_structs_are_allocated = (rr_node_to_rt_node.size() == size_t(device_ctx.rr_nodes.size())
8585
|| rt_node_free_list != nullptr);
8686
if (route_tree_structs_are_allocated) {
@@ -196,6 +196,7 @@ t_rt_node* init_route_tree_to_source(ClusterNetId inet) {
196196

197197
rt_root->inode = inode;
198198
rt_root->net_pin_index = OPEN;
199+
//ESR API Access (get Capacitance and Resistance [4 times])
199200
rt_root->C_downstream = device_ctx.rr_nodes[inode].C();
200201
rt_root->R_upstream = device_ctx.rr_nodes[inode].R();
201202
rt_root->Tdel = 0.5 * device_ctx.rr_nodes[inode].R() * device_ctx.rr_nodes[inode].C();
@@ -264,7 +265,8 @@ t_rt_node* update_route_tree(t_heap* hptr, int target_net_pin_index, SpatialRout
264265
void add_route_tree_to_rr_node_lookup(t_rt_node* node) {
265266
if (node) {
266267
auto& device_ctx = g_vpr_ctx.device();
267-
if (device_ctx.rr_nodes[node->inode].type() == SINK) {
268+
//ESR API Access (get type of node)
269+
if (device_ctx.rr_nodes[node->inode].type() == SINK) { //ESR keep iterating until you get to a sink?
268270
VTR_ASSERT(rr_node_to_rt_node[node->inode] == nullptr || rr_node_to_rt_node[node->inode]->inode == node->inode);
269271
} else {
270272
VTR_ASSERT(rr_node_to_rt_node[node->inode] == nullptr || rr_node_to_rt_node[node->inode] == node);
@@ -318,6 +320,7 @@ add_subtree_to_route_tree(t_heap* hptr, int target_net_pin_index, t_rt_node** si
318320
std::unordered_set<int> all_visited; //does not include sink
319321
inode = hptr->prev_node();
320322
RREdgeId edge = hptr->prev_edge();
323+
//ESR API Access (get the switch for the edge)
321324
short iswitch = device_ctx.rr_nodes.edge_switch(edge);
322325

323326
/* For all "new" nodes in the main path */
@@ -348,6 +351,7 @@ add_subtree_to_route_tree(t_heap* hptr, int target_net_pin_index, t_rt_node** si
348351

349352
rr_node_to_rt_node[inode] = rt_node;
350353

354+
//ESR API Access (get type of node)
351355
if (device_ctx.rr_nodes[inode].type() == IPIN) {
352356
rt_node->re_expand = false;
353357
} else {
@@ -357,6 +361,7 @@ add_subtree_to_route_tree(t_heap* hptr, int target_net_pin_index, t_rt_node** si
357361
downstream_rt_node = rt_node;
358362
edge = route_ctx.rr_node_route_inf[inode].prev_edge;
359363
inode = route_ctx.rr_node_route_inf[inode].prev_node;
364+
//ESR API Access (get type of edge)
360365
iswitch = device_ctx.rr_nodes.edge_switch(edge);
361366
}
362367

@@ -405,7 +410,7 @@ static t_rt_node* add_non_configurable_to_route_tree(const int rr_node, const bo
405410
rt_node->u.child_list = nullptr;
406411
rt_node->inode = rr_node;
407412
rt_node->net_pin_index = OPEN;
408-
413+
//ESR API Access (get type of node)
409414
if (device_ctx.rr_nodes[rr_node].type() == IPIN) {
410415
rt_node->re_expand = false;
411416
} else {
@@ -415,7 +420,7 @@ static t_rt_node* add_non_configurable_to_route_tree(const int rr_node, const bo
415420
VTR_ASSERT(rt_node->inode == rr_node);
416421
}
417422
}
418-
423+
//ESR API Access (get non configurable edges, configurable edges, and edge_sink_node)
419424
for (int iedge : device_ctx.rr_nodes[rr_node].non_configurable_edges()) {
420425
//Recursive case: expand children
421426
VTR_ASSERT(!device_ctx.rr_nodes[rr_node].edge_is_configurable(iedge));
@@ -426,7 +431,7 @@ static t_rt_node* add_non_configurable_to_route_tree(const int rr_node, const bo
426431
t_rt_node* child_rt_node = add_non_configurable_to_route_tree(to_rr_node, true, visited);
427432

428433
if (!child_rt_node) continue;
429-
434+
//ESR API Access (get type of switch)
430435
int iswitch = device_ctx.rr_nodes[rr_node].edge_switch(iedge);
431436

432437
//Create the edge
@@ -472,6 +477,7 @@ void load_new_subtree_R_upstream(t_rt_node* rt_node) {
472477
}
473478
R_upstream += device_ctx.rr_switch_inf[iswitch].R; //Parent switch R
474479
}
480+
//ESR API Access (get current node Resistance)
475481
R_upstream += device_ctx.rr_nodes[inode].R(); //Current node R
476482

477483
rt_node->R_upstream = R_upstream;
@@ -487,7 +493,7 @@ float load_new_subtree_C_downstream(t_rt_node* rt_node) {
487493

488494
if (rt_node) {
489495
auto& device_ctx = g_vpr_ctx.device();
490-
496+
//ESR API Access (get node's Capacitance)
491497
C_downstream += device_ctx.rr_nodes[rt_node->inode].C();
492498
for (t_linked_rt_edge* edge = rt_node->u.child_list; edge != nullptr; edge = edge->next) {
493499
/*Similar to net_delay.cpp, this for loop traverses a rc subtree, whose edges represent enabled switches.
@@ -580,7 +586,7 @@ void load_route_tree_Tdel(t_rt_node* subtree_rt_root, float Tarrival) {
580586
/* Assuming the downstream connections are, on average, connected halfway
581587
* along a wire segment's length. See discussion in net_delay.c if you want
582588
* to change this. */
583-
589+
//ESR API Access (get node's Resistance)
584590
Tdel = Tarrival + 0.5 * subtree_rt_root->C_downstream * device_ctx.rr_nodes[inode].R();
585591
subtree_rt_root->Tdel = Tdel;
586592

@@ -688,6 +694,7 @@ void print_route_tree(const t_rt_node* rt_node, int depth) {
688694
}
689695

690696
auto& device_ctx = g_vpr_ctx.device();
697+
//ESR API Access (get node's type string)
691698
VTR_LOG("%srt_node: %d (%s) \t ipin: %d \t R: %g \t C: %g \t delay: %g",
692699
indent.c_str(), rt_node->inode, device_ctx.rr_nodes[rt_node->inode].type_string(), rt_node->net_pin_index, rt_node->R_upstream, rt_node->C_downstream, rt_node->Tdel);
693700

@@ -699,7 +706,7 @@ void print_route_tree(const t_rt_node* rt_node, int depth) {
699706
}
700707

701708
auto& route_ctx = g_vpr_ctx.routing();
702-
709+
//ESR API Access (Get node's capacity)
703710
if (route_ctx.rr_node_route_inf[rt_node->inode].occ() > device_ctx.rr_nodes[rt_node->inode].capacity()) {
704711
VTR_LOG(" x");
705712
}
@@ -801,6 +808,7 @@ static t_trace* traceback_to_route_tree_branch(t_trace* trace,
801808
// In some cases, the same sink node is put into the tree multiple times in a single route.
802809
// So it is possible to hit the same node index multiple times during traceback. Create a
803810
// separate rt_node for each sink with the same node index.
811+
//ESR API Access (Get node's type)
804812
if (itr == rr_node_to_rt.end() || device_ctx.rr_nodes[inode].type() == SINK) {
805813
//Create
806814

@@ -813,7 +821,7 @@ static t_trace* traceback_to_route_tree_branch(t_trace* trace,
813821
node->R_upstream = std::numeric_limits<float>::quiet_NaN();
814822
node->C_downstream = std::numeric_limits<float>::quiet_NaN();
815823
node->Tdel = std::numeric_limits<float>::quiet_NaN();
816-
824+
//ESR API Access (Get node's type)
817825
auto node_type = device_ctx.rr_nodes[inode].type();
818826
if (node_type == IPIN || node_type == SINK)
819827
node->re_expand = false;
@@ -954,6 +962,7 @@ t_trace* traceback_from_route_tree(ClusterNetId inet, const t_rt_node* root, int
954962
nodes.insert(trace->index);
955963

956964
//Sanity check that number of sinks match expected
965+
//ESR API Access (Get node's type)
957966
if (device_ctx.rr_nodes[trace->index].type() == SINK) {
958967
num_trace_sinks += 1;
959968
}
@@ -978,7 +987,7 @@ static t_rt_node* prune_route_tree_recurr(t_rt_node* node, CBRR& connections_inf
978987

979988
auto& device_ctx = g_vpr_ctx.device();
980989
auto& route_ctx = g_vpr_ctx.routing();
981-
990+
//ESR API Access (Get node's capacity)
982991
bool congested = (route_ctx.rr_node_route_inf[node->inode].occ() > device_ctx.rr_nodes[node->inode].capacity());
983992
int node_set = -1;
984993
auto itr = device_ctx.rr_node_to_non_config_node_set.find(node->inode);
@@ -1036,7 +1045,7 @@ static t_rt_node* prune_route_tree_recurr(t_rt_node* node, CBRR& connections_inf
10361045
edge = edge->next;
10371046
}
10381047
}
1039-
1048+
//ESR API Access (Get node's type)
10401049
if (device_ctx.rr_nodes[node->inode].type() == SINK) {
10411050
if (!force_prune) {
10421051
//Valid path to sink
@@ -1172,9 +1181,9 @@ t_rt_node* prune_route_tree(t_rt_node* rt_root, CBRR& connections_inf, std::vect
11721181

11731182
auto& device_ctx = g_vpr_ctx.device();
11741183
auto& route_ctx = g_vpr_ctx.routing();
1175-
1184+
//ESR API Access (Get node's type)
11761185
VTR_ASSERT_MSG(device_ctx.rr_nodes[rt_root->inode].type() == SOURCE, "Root of route tree must be SOURCE");
1177-
1186+
//ESR API Access (Get node's capacity)
11781187
VTR_ASSERT_MSG(route_ctx.rr_node_route_inf[rt_root->inode].occ() <= device_ctx.rr_nodes[rt_root->inode].capacity(),
11791188
"Route tree root/SOURCE should never be congested");
11801189

@@ -1258,6 +1267,7 @@ static void print_node(const t_rt_node* rt_node) {
12581267
auto& device_ctx = g_vpr_ctx.device();
12591268

12601269
int inode = rt_node->inode;
1270+
//ESR API Access (Get node's type)
12611271
t_rr_type node_type = device_ctx.rr_nodes[inode].type();
12621272
VTR_LOG("%5.1e %5.1e %2d%6s|%-6d-> ", rt_node->C_downstream, rt_node->R_upstream,
12631273
rt_node->re_expand, rr_node_typename[node_type], inode);
@@ -1278,6 +1288,7 @@ static void print_node_congestion(const t_rt_node* rt_node) {
12781288

12791289
int inode = rt_node->inode;
12801290
const auto& node_inf = route_ctx.rr_node_route_inf[inode];
1291+
//ESR API Access (Get node)
12811292
const auto& node = device_ctx.rr_nodes[inode];
12821293
VTR_LOG("%2d %2d|%-6d-> ", node_inf.acc_cost, rt_node->Tdel,
12831294
node_inf.occ(), node.capacity(), inode);
@@ -1369,18 +1380,21 @@ bool is_valid_route_tree(const t_rt_node* root) {
13691380
short iswitch = root->parent_switch;
13701381
if (root->parent_node) {
13711382
if (device_ctx.rr_switch_inf[iswitch].buffered()) {
1383+
//ESR API Access (Get node's Resistance)
13721384
float R_upstream_check = device_ctx.rr_nodes[inode].R() + device_ctx.rr_switch_inf[iswitch].R;
13731385
if (!vtr::isclose(root->R_upstream, R_upstream_check, RES_REL_TOL, RES_ABS_TOL)) {
13741386
VTR_LOG("%d mismatch R upstream %e supposed %e\n", inode, root->R_upstream, R_upstream_check);
13751387
return false;
13761388
}
13771389
} else {
1390+
//ESR API Access (Get node's Resistance)
13781391
float R_upstream_check = device_ctx.rr_nodes[inode].R() + root->parent_node->R_upstream + device_ctx.rr_switch_inf[iswitch].R;
13791392
if (!vtr::isclose(root->R_upstream, R_upstream_check, RES_REL_TOL, RES_ABS_TOL)) {
13801393
VTR_LOG("%d mismatch R upstream %e supposed %e\n", inode, root->R_upstream, R_upstream_check);
13811394
return false;
13821395
}
13831396
}
1397+
//ESR API Access (Get node's Resistance [two spots])
13841398
} else if (root->R_upstream != device_ctx.rr_nodes[inode].R()) {
13851399
VTR_LOG("%d mismatch R upstream %e supposed %e\n", inode, root->R_upstream, device_ctx.rr_nodes[inode].R());
13861400
return false;
@@ -1392,6 +1406,7 @@ bool is_valid_route_tree(const t_rt_node* root) {
13921406
// sink, must not be congested
13931407
if (!edge) {
13941408
int occ = route_ctx.rr_node_route_inf[inode].occ();
1409+
//ESR API Access (Get node's capacity)
13951410
int capacity = device_ctx.rr_nodes[inode].capacity();
13961411
if (occ > capacity) {
13971412
VTR_LOG("SINK %d occ %d > cap %d\n", inode, occ, capacity);
@@ -1423,7 +1438,7 @@ bool is_valid_route_tree(const t_rt_node* root) {
14231438
}
14241439
edge = edge->next;
14251440
}
1426-
1441+
//ESR API Access (Get node's Capacitance)
14271442
float C_downstream_check = C_downstream_children + device_ctx.rr_nodes[inode].C();
14281443
if (!vtr::isclose(root->C_downstream, C_downstream_check, CAP_REL_TOL, CAP_ABS_TOL)) {
14291444
VTR_LOG("%d mismatch C downstream %e supposed %e\n", inode, root->C_downstream, C_downstream_check);
@@ -1439,6 +1454,7 @@ bool is_uncongested_route_tree(const t_rt_node* root) {
14391454
auto& device_ctx = g_vpr_ctx.device();
14401455

14411456
int inode = root->inode;
1457+
//ESR API Access (Get node's capacity)
14421458
if (route_ctx.rr_node_route_inf[inode].occ() > device_ctx.rr_nodes[inode].capacity()) {
14431459
//This node is congested
14441460
return false;
@@ -1471,6 +1487,7 @@ init_route_tree_to_source_no_net(int inode) {
14711487
rt_root->re_expand = true;
14721488
rt_root->inode = inode;
14731489
rt_root->net_pin_index = OPEN;
1490+
//ESR API Access (Get node's Capacitance and Resistance [4 times])
14741491
rt_root->C_downstream = device_ctx.rr_nodes[inode].C();
14751492
rt_root->R_upstream = device_ctx.rr_nodes[inode].R();
14761493
rt_root->Tdel = 0.5 * device_ctx.rr_nodes[inode].R() * device_ctx.rr_nodes[inode].C();

vpr/src/route/route_util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ vtr::Matrix<float> calculate_routing_usage(t_rr_type rr_type) {
1616
t_trace* tptr = route_ctx.trace[net].head;
1717
while (tptr != nullptr) {
1818
int inode = tptr->index;
19-
19+
2020
if (device_ctx.rr_nodes[inode].type() == rr_type) {
2121
rr_nodes.insert(inode);
2222
}

vpr/src/route/rr_graph_writer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/* This function is used to write the rr_graph into xml format into a a file with name: file_name */
2727
void write_rr_graph(const char* file_name) {
2828
auto& device_ctx = g_vpr_ctx.mutable_device();
29-
VTR_LOG("Just making sure i can add this...\n");
29+
VTR_LOG("#ESR write_rr_graph\n");
3030
RrGraphSerializer reader(
3131
/*graph_type=*/t_graph_type(),
3232
/*base_cost_type=*/e_base_cost_type(),

0 commit comments

Comments
 (0)