Skip to content

Commit 17ab565

Browse files
author
Nathan Shreve
committed
#ifdef-ed extra heap data and added CI test
1 parent 2db5325 commit 17ab565

13 files changed

+96
-11
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ jobs:
156156
params: '-DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on -DVPR_USE_EZGL=on -DVPR_USE_SERVER=off',
157157
suite: 'vtr_reg_basic'
158158
},
159+
{
160+
name: 'Basic with PROFILE_LOOKAHEAD',
161+
params: '-DVTR_ASSERT_LEVEL=3 -DVPR_PROFILE_LOOKAHEAD=on',
162+
suite: 'vtr_reg_basic'
163+
},
159164
{
160165
name: 'Basic with CAPNPROTO disabled',
161166
params: '-DCMAKE_COMPILE_WARNING_AS_ERROR=on -DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on -DVTR_ENABLE_CAPNPROTO=off',

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ option(VTR_ENABLE_CAPNPROTO "Enable capnproto binary serialization support in VP
4242
#Allow the user to decide whether to compile the server module
4343
option(VPR_USE_SERVER "Specify whether vpr enables the server mode" ON)
4444

45+
#Allow the user to decide whether to profile the router lookahead
46+
option(VPR_PROFILE_LOOKAHEAD "Specify whether to enable the router LookaheadProfiler" OFF)
47+
4548
#Allow the user to enable/disable VPR analytic placement
4649
#VPR option --enable_analytic_placer is also required for Analytic Placement
4750
option(VPR_ANALYTIC_PLACE "Enable analytic placement in VPR." ON)

vpr/CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ else()
5151
message(STATUS "Server mode is disabled${SERVER_DISABILED_REASON}")
5252
endif()
5353

54+
#Handle router lookahead profiler setup
55+
set(ROUTER_DEFINES "")
56+
57+
if (VPR_PROFILE_LOOKAHEAD)
58+
list(APPEND ROUTER_DEFINES "-DPROFILE_LOOKAHEAD")
59+
message(STATUS "Router lookahead profiler enabled")
60+
else ()
61+
message(STATUS "Router lookahead profiler disabled")
62+
endif ()
63+
5464
#
5565
# Build Configuration
5666
#
@@ -163,7 +173,7 @@ if (VPR_USE_EZGL STREQUAL "on")
163173

164174
endif()
165175

166-
target_compile_definitions(libvpr PUBLIC ${GRAPHICS_DEFINES} ${SERVER_DEFINES})
176+
target_compile_definitions(libvpr PUBLIC ${GRAPHICS_DEFINES} ${SERVER_DEFINES} ${ROUTER_DEFINES})
167177

168178
if(${VTR_ENABLE_CAPNPROTO})
169179
target_link_libraries(libvpr libvtrcapnproto)

vpr/src/base/vpr_types.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,11 +1749,7 @@ constexpr bool is_src_sink(e_rr_type type) { return (type == SOURCE || type == S
17491749
* the expected cost to the target if the timing_driven router
17501750
* is being used.
17511751
* @param backward_path_cost Total cost of the path up to and including
1752-
* this node. Recorded for LookaheadProfiler.
1753-
* @param backward_path_delay Total delay in the path up to and including
1754-
* this node. Recorded for LookaheadProfiler.
1755-
* @param backward_path_congestion Total congestion in the path up to and
1756-
* including this node.
1752+
* this node.
17571753
* @param occ The current occupancy of the associated rr node
17581754
*/
17591755
struct t_rr_node_route_inf {
@@ -1762,8 +1758,12 @@ struct t_rr_node_route_inf {
17621758
float acc_cost;
17631759
float path_cost;
17641760
float backward_path_cost;
1761+
#ifdef PROFILE_LOOKAHEAD
1762+
///@brief Total delay in the path up to and including this node.
17651763
float backward_path_delay;
1764+
///@brief Total congestion in the path up to and including this node.
17661765
float backward_path_congestion;
1766+
#endif
17671767

17681768
public: //Accessors
17691769
short occ() const { return occ_; }

vpr/src/route/connection_router.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,21 @@ t_heap* ConnectionRouter<Heap>::timing_driven_route_connection_from_heap(RRNodeI
239239
// This is then placed into the traceback so that the correct path is returned
240240
// TODO: This can be eliminated by modifying the actual traceback function in route_timing
241241
if (rcv_path_manager.is_enabled()) {
242+
#ifdef PROFILE_LOOKAHEAD
242243
rcv_path_manager.insert_backwards_path_into_traceback(cheapest->path_data,
243244
cheapest->cost,
244245
cheapest->backward_path_cost,
245246
cheapest->backward_path_delay,
246247
cheapest->backward_path_congestion,
247248
route_ctx);
249+
#else
250+
rcv_path_manager.insert_backwards_path_into_traceback(cheapest->path_data,
251+
cheapest->cost,
252+
cheapest->backward_path_cost,
253+
/*backward_path_delay=*/0.f,
254+
/*backward_path_congestion=*/0.f,
255+
route_ctx);
256+
#endif
248257
}
249258
VTR_LOGV_DEBUG(router_debug_, " Found target %8d (%s)\n", inode, describe_rr_node(device_ctx.rr_graph, device_ctx.grid, device_ctx.rr_indexed_data, inode, is_flat_).c_str());
250259
break;
@@ -557,8 +566,10 @@ void ConnectionRouter<Heap>::timing_driven_add_to_heap(const t_conn_cost_params&
557566
// Costs initialized to current
558567
next.cost = std::numeric_limits<float>::infinity(); //Not used directly
559568
next.backward_path_cost = current->backward_path_cost;
569+
#ifdef PROFILE_LOOKAHEAD
560570
next.backward_path_delay = current->backward_path_delay;
561571
next.backward_path_congestion = current->backward_path_congestion;
572+
#endif
562573

563574
// path_data variables are initialized to current values
564575
if (rcv_path_manager.is_enabled() && current->path_data) {
@@ -604,8 +615,10 @@ void ConnectionRouter<Heap>::timing_driven_add_to_heap(const t_conn_cost_params&
604615
next_ptr->cost = next.cost;
605616
next_ptr->R_upstream = next.R_upstream;
606617
next_ptr->backward_path_cost = next.backward_path_cost;
618+
#ifdef PROFILE_LOOKAHEAD
607619
next_ptr->backward_path_delay = next.backward_path_delay;
608620
next_ptr->backward_path_congestion = next.backward_path_congestion;
621+
#endif
609622
next_ptr->index = to_node;
610623
next_ptr->set_prev_edge(from_edge);
611624

@@ -793,8 +806,10 @@ void ConnectionRouter<Heap>::evaluate_timing_driven_node_costs(t_heap* to,
793806
//Update the backward cost (upstream already included)
794807
to->backward_path_cost += (1. - cost_params.criticality) * cong_cost; //Congestion cost
795808
to->backward_path_cost += cost_params.criticality * Tdel; //Delay cost
809+
#ifdef PROFILE_LOOKAHEAD
796810
to->backward_path_delay += Tdel;
797811
to->backward_path_congestion += cong_cost;
812+
#endif
798813

799814
if (cost_params.bend_cost != 0.) {
800815
t_rr_type from_type = rr_graph_->node_type(from_node);
@@ -843,8 +858,10 @@ void ConnectionRouter<Heap>::empty_heap_annotating_node_route_inf() {
843858

844859
rr_node_route_inf_[tmp->index].path_cost = tmp->cost;
845860
rr_node_route_inf_[tmp->index].backward_path_cost = tmp->backward_path_cost;
861+
#ifdef PROFILE_LOOKAHEAD
846862
rr_node_route_inf_[tmp->index].backward_path_delay = tmp->backward_path_delay;
847863
rr_node_route_inf_[tmp->index].backward_path_congestion = tmp->backward_path_congestion;
864+
#endif
848865
modified_rr_node_inf_.push_back(tmp->index);
849866

850867
rcv_path_manager.free_path_struct(tmp->path_data);
@@ -905,8 +922,10 @@ void ConnectionRouter<Heap>::add_route_tree_node_to_heap(
905922
const auto& device_ctx = g_vpr_ctx.device();
906923
const RRNodeId inode = rt_node.inode;
907924
float backward_path_cost = cost_params.criticality * rt_node.Tdel;
925+
#ifdef PROFILE_LOOKAHEAD
908926
float backward_path_delay = rt_node.Tdel;
909927
float backward_path_congestion = 0.0;
928+
#endif
910929
float R_upstream = rt_node.R_upstream;
911930

912931
/* Don't push to heap if not in bounding box: no-op for serial router, important for parallel router */
@@ -928,6 +947,7 @@ void ConnectionRouter<Heap>::add_route_tree_node_to_heap(
928947
tot_cost,
929948
describe_rr_node(device_ctx.rr_graph, device_ctx.grid, device_ctx.rr_indexed_data, inode, is_flat_).c_str());
930949

950+
#ifdef PROFILE_LOOKAHEAD
931951
push_back_node(&heap_,
932952
rr_node_route_inf_,
933953
inode,
@@ -937,6 +957,17 @@ void ConnectionRouter<Heap>::add_route_tree_node_to_heap(
937957
backward_path_delay,
938958
backward_path_congestion,
939959
R_upstream);
960+
#else
961+
push_back_node(&heap_,
962+
rr_node_route_inf_,
963+
inode,
964+
tot_cost,
965+
/*prev_edge=*/RREdgeId::INVALID(),
966+
backward_path_cost,
967+
/*backward_path_delay=*/0.f,
968+
/*backward_path_congestion=*/0.f,
969+
R_upstream);
970+
#endif
940971
} else {
941972
float expected_total_cost = compute_node_cost_using_rcv(cost_params, inode, target_node, rt_node.Tdel, 0, R_upstream);
942973

vpr/src/route/connection_router.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define _CONNECTION_ROUTER_H
33

44
#include "connection_router_interface.h"
5+
#include "lookahead_profiler.h"
56
#include "rr_graph_storage.h"
67
#include "route_common.h"
78
#include "router_lookahead.h"
@@ -153,8 +154,10 @@ class ConnectionRouter : public ConnectionRouterInterface {
153154
route_inf->prev_edge = cheapest->prev_edge();
154155
route_inf->path_cost = cheapest->cost;
155156
route_inf->backward_path_cost = cheapest->backward_path_cost;
157+
#ifdef PROFILE_LOOKAHEAD
156158
route_inf->backward_path_delay = cheapest->backward_path_delay;
157159
route_inf->backward_path_congestion = cheapest->backward_path_congestion;
160+
#endif
158161
}
159162

160163
/** Common logic from timing_driven_route_connection_from_route_tree and

vpr/src/route/heap_type.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ HeapStorage::alloc() {
2727
temp_ptr->set_next_heap_item(nullptr);
2828
temp_ptr->cost = 0.;
2929
temp_ptr->backward_path_cost = 0.;
30+
#ifdef PROFILE_LOOKAHEAD
3031
temp_ptr->backward_path_delay = 0.;
3132
temp_ptr->backward_path_congestion = 0.;
33+
#endif
3234
temp_ptr->R_upstream = 0.;
3335
temp_ptr->index = RRNodeId::INVALID();
3436
temp_ptr->path_data = nullptr;

vpr/src/route/heap_type.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ struct t_heap {
1818
///@brief The "known" cost of the path up to and including this node. Used only by the timing-driven router. In this case, the
1919
///.cost member contains not only the known backward cost but also an expected cost to the target.
2020
float backward_path_cost = 0.;
21+
#ifdef PROFILE_LOOKAHEAD
2122
///@brief The "known" delay in the path up to and including this node. Recorded for LookaheadProfiler during routing.
2223
float backward_path_delay = 0.;
2324
///@brief The "known" congestion in the path up to and including this node. Recorded for LookaheadProfiler during routing.
2425
float backward_path_congestion = 0.;
26+
#endif
2527
///@brief Used only by the timing-driven router. Stores the upstream resistance to ground from this node, including the resistance
2628
/// of the node itself (device_ctx.rr_nodes[index].R).
2729
float R_upstream = 0.;

vpr/src/route/lookahead_profiler.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@ void LookaheadProfiler::set_file_name(const std::string& file_name) {
1313
if (!enabled_)
1414
return;
1515

16+
#ifdef PROFILE_LOOKAHEAD
1617
lookahead_verifier_csv_.open(file_name, std::ios::out);
1718

1819
if (!lookahead_verifier_csv_.is_open()) {
19-
std::string message = "Could not open " + file_name;
20-
VTR_LOG_ERROR(message.c_str());
21-
throw vtr::VtrError(message, "lookahead_profiler.cpp", 21);
20+
throw vtr::VtrError("Could not open " + file_name, "lookahead_profiler.cpp", 21);
2221
}
2322

2423
lookahead_verifier_csv_
@@ -44,6 +43,9 @@ void LookaheadProfiler::set_file_name(const std::string& file_name) {
4443
<< ",predicted congestion"
4544
<< ",criticality"
4645
<< "\n";
46+
#else
47+
throw vtr::VtrError("Profiler enabled, but PROFILE_LOOKAHEAD not defined.", "lookahead_profiler.cpp", 47);
48+
#endif
4749
}
4850

4951
void LookaheadProfiler::record(int iteration,
@@ -60,9 +62,9 @@ void LookaheadProfiler::record(int iteration,
6062
if (!enabled_)
6163
return;
6264

65+
#ifdef PROFILE_LOOKAHEAD
6366
if (!lookahead_verifier_csv_.is_open()) {
64-
VTR_LOG_ERROR("Output file is not open.");
65-
throw vtr::VtrError("Output file is not open.", "lookahead_profiler.cpp", 65);
67+
throw vtr::VtrError("Output file is not open.", "lookahead_profiler.cpp", 67);
6668
}
6769

6870
// The default value in RouteTree::update_from_heap() is -1; only calls which descend from route_net()
@@ -159,6 +161,16 @@ void LookaheadProfiler::record(int iteration,
159161
lookahead_verifier_csv_ << cost_params.criticality; // criticality
160162
lookahead_verifier_csv_ << "\n";
161163
}
164+
#else
165+
throw vtr::VtrError("Profiler enabled, but PROFILE_LOOKAHEAD not defined.", "lookahead_profiler.cpp", 165);
166+
(void)iteration;
167+
(void)target_net_pin_index;
168+
(void)cost_params;
169+
(void)router_lookahead;
170+
(void)net_id;
171+
(void)net_list;
172+
(void)branch_inodes;
173+
#endif
162174
}
163175

164176
void LookaheadProfiler::clear() {

vpr/src/route/lookahead_profiler.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
* @brief A class which records information used to profile the router lookahead: most importantly,
1212
* the actual cost (delay and congestion) from nodes to the sink to which they have been routed, as
1313
* well as the lookahead's estimation of this cost.
14+
*
15+
* @warning
16+
* To use the LookaheadProfiler, you must build VPR with #define PROFILE_LOOKAHEAD.
1417
*/
1518
class LookaheadProfiler {
1619
public:

vpr/src/route/route_common.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,10 @@ void reset_path_costs(const std::vector<RRNodeId>& visited_rr_nodes) {
289289
for (auto node : visited_rr_nodes) {
290290
route_ctx.rr_node_route_inf[node].path_cost = std::numeric_limits<float>::infinity();
291291
route_ctx.rr_node_route_inf[node].backward_path_cost = std::numeric_limits<float>::infinity();
292+
#ifdef PROFILE_LOOKAHEAD
292293
route_ctx.rr_node_route_inf[node].backward_path_delay = std::numeric_limits<float>::infinity();
293294
route_ctx.rr_node_route_inf[node].backward_path_congestion = std::numeric_limits<float>::infinity();
295+
#endif
294296
route_ctx.rr_node_route_inf[node].prev_edge = RREdgeId::INVALID();
295297
}
296298
}
@@ -428,8 +430,10 @@ void reset_rr_node_route_structs() {
428430
node_inf.acc_cost = 1.0;
429431
node_inf.path_cost = std::numeric_limits<float>::infinity();
430432
node_inf.backward_path_cost = std::numeric_limits<float>::infinity();
433+
#ifdef PROFILE_LOOKAHEAD
431434
node_inf.backward_path_delay = std::numeric_limits<float>::infinity();
432435
node_inf.backward_path_congestion = std::numeric_limits<float>::infinity();
436+
#endif
433437
node_inf.set_occ(0);
434438
}
435439
}

vpr/src/route/route_common.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,13 @@ t_heap* prepare_to_add_node_to_heap(
173173
hptr->cost = total_cost;
174174
hptr->set_prev_edge(prev_edge);
175175
hptr->backward_path_cost = backward_path_cost;
176+
#ifdef PROFILE_LOOKAHEAD
176177
hptr->backward_path_delay = backward_path_delay;
177178
hptr->backward_path_congestion = backward_path_congestion;
179+
#else
180+
(void)backward_path_delay;
181+
(void)backward_path_congestion;
182+
#endif
178183
hptr->R_upstream = R_upstream;
179184
return hptr;
180185
}

vpr/src/route/route_path_manager.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,13 @@ void PathManager::insert_backwards_path_into_traceback(t_heap_path* path_data,
5353
route_ctx.rr_node_route_inf[node_2].prev_edge = edge;
5454
route_ctx.rr_node_route_inf[node_2].path_cost = cost;
5555
route_ctx.rr_node_route_inf[node_2].backward_path_cost = backward_path_cost;
56+
#ifdef PROFILE_LOOKAHEAD
5657
route_ctx.rr_node_route_inf[node_2].backward_path_delay = backward_path_delay;
5758
route_ctx.rr_node_route_inf[node_2].backward_path_congestion = backward_path_congestion;
59+
#else
60+
(void)backward_path_delay;
61+
(void)backward_path_congestion;
62+
#endif
5863
}
5964
}
6065

0 commit comments

Comments
 (0)