3
3
//
4
4
5
5
#include < sstream>
6
- #include " lookahead_profiler.h"
7
- #include " vtr_error.h"
8
- #include " vtr_log.h"
6
+
9
7
#include " globals.h"
8
+ #include " lookahead_profiler.h"
9
+ #include " re_cluster_util.h"
10
10
#include " router_lookahead_map_utils.h"
11
11
#include " vpr_utils.h"
12
- #include " re_cluster_util.h"
13
-
14
- LookaheadProfiler::LookaheadProfiler ()
15
- : is_empty(true ) {
16
- lookahead_verifier_csv.open (" lookahead_verifier_info.csv" , std::ios::out);
17
-
18
- if (!lookahead_verifier_csv.is_open ()) {
19
- VTR_LOG_WARN (" Could not open lookahead_verifier_info.csv" );
20
- return ;
21
- }
22
- }
12
+ #include " vtr_error.h"
13
+ #include " vtr_log.h"
23
14
24
15
void LookaheadProfiler::record (int iteration,
25
16
int target_net_pin_index,
@@ -32,10 +23,14 @@ void LookaheadProfiler::record(int iteration,
32
23
const auto & rr_graph = device_ctx.rr_graph ;
33
24
auto & route_ctx = g_vpr_ctx.routing ();
34
25
35
- if (!lookahead_verifier_csv.is_open ())
36
- return ;
37
-
26
+ // If csv file hasn't been opened, open it and write out column headers
38
27
if (is_empty) {
28
+ lookahead_verifier_csv.open (" lookahead_verifier_info.csv" , std::ios::out);
29
+
30
+ if (!lookahead_verifier_csv.is_open ()) {
31
+ VTR_LOG_ERROR (" Could not open lookahead_verifier_info.csv" , " error" );
32
+ }
33
+
39
34
lookahead_verifier_csv
40
35
<< " iteration no."
41
36
<< " ,source node"
@@ -63,72 +58,96 @@ void LookaheadProfiler::record(int iteration,
63
58
is_empty = false ;
64
59
}
65
60
61
+ if (!lookahead_verifier_csv.is_open ())
62
+ return ;
63
+
64
+ // The default value in RouteTree::update_from_heap() is -1; only calls which descend from route_net()
65
+ // pass in an iteration value, which is the only context in which we want to profile.
66
66
if (iteration < 1 )
67
67
return ;
68
68
69
- for (size_t i = 2 ; i < branch_inodes.size (); ++i) { /* Distance one node away is always 0.0 (IPIN->SINK) */
70
- RRNodeId source_inode = branch_inodes.back ();
71
- RRNodeId sink_inode = branch_inodes.front ();
72
- RRNodeId curr_inode = branch_inodes[i];
69
+ RRNodeId source_inode = branch_inodes.back ();
70
+ RRNodeId sink_inode = branch_inodes.front ();
73
71
74
- float total_backward_cost = route_ctx.rr_node_route_inf [sink_inode].backward_path_cost ;
75
- float total_backward_delay = route_ctx.rr_node_route_inf [sink_inode].backward_path_delay ;
76
- float total_backward_congestion = route_ctx.rr_node_route_inf [sink_inode].backward_path_congestion ;
72
+ VTR_ASSERT (rr_graph.node_type (source_inode) == SOURCE);
73
+ VTR_ASSERT (rr_graph.node_type (sink_inode) == SINK);
77
74
78
- auto current_node = route_ctx.rr_node_route_inf [curr_inode];
79
- float current_backward_cost = current_node.backward_path_cost ;
80
- float current_backward_delay = current_node.backward_path_delay ;
81
- float current_backward_congestion = current_node.backward_path_congestion ;
75
+ /* Get sink node attributes (atom block name, atom block model, cluster type, tile dimensions) */
82
76
83
- auto [from_x, from_y] = util::get_adjusted_rr_position (curr_inode);
84
- auto [to_x, to_y] = util::get_adjusted_rr_position (sink_inode);
77
+ if (atom_block_names.find (sink_inode) == atom_block_names.end ()) {
78
+ if (net_id != ParentNetId::INVALID () && target_net_pin_index != OPEN) {
79
+ atom_block_names[sink_inode] = net_list.block_name (net_list.net_pin_block (net_id, target_net_pin_index));
85
80
86
- int delta_x = to_x - from_x ;
87
- int delta_y = to_y - from_y ;
81
+ AtomBlockId atom_block_id = g_vpr_ctx. atom (). nlist . find_block (atom_block_names[sink_inode]) ;
82
+ atom_block_models[sink_inode] = g_vpr_ctx. atom (). nlist . block_model (atom_block_id)-> name ;
88
83
89
- float djikstra_cost = total_backward_cost - current_backward_cost;
90
- float djikstra_delay = total_backward_delay - current_backward_delay;
91
- float djikstra_congestion = total_backward_congestion - current_backward_congestion;
84
+ ClusterBlockId cluster_block_id = atom_to_cluster (atom_block_id);
92
85
93
- float lookahead_cost = router_lookahead.get_expected_cost (curr_inode, sink_inode, cost_params, 0.0 );
94
- auto [lookahead_delay, lookahead_congestion] = router_lookahead.get_expected_delay_and_cong (curr_inode, sink_inode, cost_params, 0.0 );
86
+ cluster_block_types[sink_inode] = g_vpr_ctx.clustering ().clb_nlist .block_type (cluster_block_id)->name ;
87
+
88
+ auto tile_type = physical_tile_type (cluster_block_id);
89
+ tile_dimensions[sink_inode] = std::pair (std::to_string (tile_type->width ), std::to_string (tile_type->height ));
90
+ } else {
91
+ atom_block_names[sink_inode] = " --" ;
92
+ atom_block_models[sink_inode] = " --" ;
93
+ cluster_block_types[sink_inode] = " --" ;
94
+ tile_dimensions[sink_inode] = {" --" , " --" };
95
+ }
96
+ }
95
97
96
- if (atom_block_names .find (sink_inode) == atom_block_names .end ()) {
97
- if (net_id != ParentNetId::INVALID () && target_net_pin_index != OPEN) {
98
- atom_block_names[ sink_inode] = net_list. block_name (net_list. net_pin_block (net_id, target_net_pin_index ));
98
+ VTR_ASSERT_SAFE (atom_block_models .find (sink_inode) != atom_block_models .end ());
99
+ VTR_ASSERT_SAFE (cluster_block_types. find (sink_inode) != cluster_block_types. end ());
100
+ VTR_ASSERT_SAFE (tile_dimensions. find ( sink_inode) != tile_dimensions. end ( ));
99
101
100
- AtomBlockId atom_block_id = g_vpr_ctx.atom ().nlist .find_block (atom_block_names[sink_inode]);
101
- atom_block_models[sink_inode] = g_vpr_ctx.atom ().nlist .block_model (atom_block_id)->name ;
102
+ std::string block_name = atom_block_names[sink_inode];
103
+ std::string atom_block_model = atom_block_models[sink_inode];
104
+ std::string cluster_block_type = cluster_block_types[sink_inode];
105
+ auto [tile_width, tile_height] = tile_dimensions[sink_inode];
102
106
103
- ClusterBlockId cluster_block_id = atom_to_cluster (atom_block_id);
107
+ /* Iterate through the given path and record information for each node */
108
+ for (size_t i = 2 ; i < branch_inodes.size (); ++i) { // Distance one node away is always 0. (IPIN->SINK)
109
+ RRNodeId curr_inode = branch_inodes[i];
104
110
105
- cluster_block_types[sink_inode] = g_vpr_ctx.clustering ().clb_nlist .block_type (cluster_block_id)->name ;
111
+ // Get backwards path cost, delay, and congestion from sink node
112
+ t_rr_node_route_inf sink_node_info = route_ctx.rr_node_route_inf [sink_inode];
113
+ float total_backward_cost = sink_node_info.backward_path_cost ;
114
+ float total_backward_delay = sink_node_info.backward_path_delay ;
115
+ float total_backward_congestion = sink_node_info.backward_path_congestion ;
116
+
117
+ // Get backwards path cost, delay, and congestion from current node
118
+ t_rr_node_route_inf curr_node_info = route_ctx.rr_node_route_inf [curr_inode];
119
+ float current_backward_cost = curr_node_info.backward_path_cost ;
120
+ float current_backward_delay = curr_node_info.backward_path_delay ;
121
+ float current_backward_congestion = curr_node_info.backward_path_congestion ;
122
+
123
+ // Get the difference in the coordinates in the current and sink nodes.
124
+ // Note: we are not using util::get_xy_deltas() because this always gives positive values
125
+ // unless the current node is the source node. Using util::get_adjusted_rr_position therefore
126
+ // gives us more information.
127
+ auto [from_x, from_y] = util::get_adjusted_rr_position (curr_inode);
128
+ auto [to_x, to_y] = util::get_adjusted_rr_position (sink_inode);
106
129
107
- auto tile_type = physical_tile_type (cluster_block_id);
108
- tile_dimensions[sink_inode] = std::pair (std::to_string (tile_type->width ), std::to_string (tile_type->height ));
109
- } else {
110
- atom_block_names[sink_inode] = " --" ;
111
- atom_block_models[sink_inode] = " --" ;
112
- cluster_block_types[sink_inode] = " --" ;
113
- tile_dimensions[sink_inode] = {" --" , " --" };
114
- }
115
- }
130
+ int delta_x = to_x - from_x;
131
+ int delta_y = to_y - from_y;
116
132
117
- VTR_ASSERT_SAFE (atom_block_names. find (sink_inode) != atom_block_names. end ());
118
- VTR_ASSERT_SAFE (atom_block_models. find (sink_inode) != atom_block_models. end ()) ;
119
- VTR_ASSERT_SAFE (cluster_block_types. find (sink_inode) != cluster_block_types. end ()) ;
120
- VTR_ASSERT_SAFE (tile_dimensions. find (sink_inode) != tile_dimensions. end ()) ;
133
+ // Calculate the actual cost, delay, and congestion from the current node to the sink.
134
+ float actual_cost = total_backward_cost - current_backward_cost ;
135
+ float actual_delay = total_backward_delay - current_backward_delay ;
136
+ float actual_congestion = total_backward_congestion - current_backward_congestion ;
121
137
122
- std::string block_name = atom_block_names[sink_inode];
123
- std::string atom_block_model = atom_block_models[sink_inode];
124
- std::string cluster_block_type = cluster_block_types[ sink_inode] ;
125
- auto [tile_width, tile_height ] = tile_dimensions[ sink_inode] ;
138
+ // Get the cost, delay, and congestion estimates made by the lookahead.
139
+ // Note: lookahead_cost = lookahead_delay * criticality + lookahead_congestion * (1. - criticality)
140
+ float lookahead_cost = router_lookahead. get_expected_cost (curr_inode, sink_inode, cost_params, 0.0 ) ;
141
+ auto [lookahead_delay, lookahead_congestion ] = router_lookahead. get_expected_delay_and_cong (curr_inode, sink_inode, cost_params, 0.0 ) ;
126
142
143
+ // Get the current node's type and length
127
144
std::string node_type_str = rr_graph.node_type_string (curr_inode);
128
145
std::string node_length = (node_type_str == " CHANX" || node_type_str == " CHANX" )
129
146
? std::to_string (rr_graph.node_length (curr_inode))
130
147
: " --" ;
131
148
149
+ /* Write out all info */
150
+
132
151
lookahead_verifier_csv << iteration << " ," ; // iteration no.
133
152
lookahead_verifier_csv << source_inode << " ," ; // source node
134
153
lookahead_verifier_csv << sink_inode << " ," ; // sink node
@@ -143,9 +162,9 @@ void LookaheadProfiler::record(int iteration,
143
162
lookahead_verifier_csv << i << " ," ; // num. nodes from sink
144
163
lookahead_verifier_csv << delta_x << " ," ; // delta x
145
164
lookahead_verifier_csv << delta_y << " ," ; // delta y
146
- lookahead_verifier_csv << djikstra_cost << " ," ; // actual cost
147
- lookahead_verifier_csv << djikstra_delay << " ," ; // actual delay
148
- lookahead_verifier_csv << djikstra_congestion << " ," ; // actual congestion
165
+ lookahead_verifier_csv << actual_cost << " ," ; // actual cost
166
+ lookahead_verifier_csv << actual_delay << " ," ; // actual delay
167
+ lookahead_verifier_csv << actual_congestion << " ," ; // actual congestion
149
168
lookahead_verifier_csv << lookahead_cost << " ," ; // predicted cost
150
169
lookahead_verifier_csv << lookahead_delay << " ," ; // predicted delay
151
170
lookahead_verifier_csv << lookahead_congestion << " ," ; // predicted congestion
0 commit comments