Skip to content

Commit b726e44

Browse files
authored
Remove pres cost (#1438)
* Added overloaded congestion cost calculation functions to provide alternative method of calculations (on the fly). Tested on reserve_locally_used_opins and passed reg tests * removed pathfinder functions' pres cost update and updated route_connection's and breadth first driven routing's calculation of pres_cost * Changed single rr node congestion cost calculation from a file-scope function to a project-scope function * Removed unnecessary passing of the pres_fac parameter. Updated function names and documentations to the more accruate versions * Made cost calculation process atomic. Changed how draw.cpp utilize the congestion cost functions * Refactored draw.cpp so that it uses the up-to-date pres_cost value for visualizing congestions. Also inlined smaller functions related to congestion cost calculations * Moved drawing pres_fac variable into the draw state structure * Manually inlined single rr node cost function * Corrected pres_cost multiplication: use float instead of double. Added debug assertion check for congestion cost calculation * Merged calculation of overuse info into acc_cost update * Fixed issues according to PR comments
1 parent 8cd6d49 commit b726e44

15 files changed

+287
-307
lines changed

vpr/src/base/read_route.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ bool read_route(const char* route_file, const t_router_opts& router_opts, bool v
126126
recompute_occupancy_from_scratch();
127127

128128
/* Note: This pres_fac is not necessarily correct since it isn't the first routing iteration*/
129-
pathfinder_update_cost(router_opts.initial_pres_fac, router_opts.acc_fac);
129+
OveruseInfo overuse_info(device_ctx.rr_nodes.size());
130+
pathfinder_update_acc_cost_and_overuse_info(router_opts.acc_fac, overuse_info);
130131

131132
reserve_locally_used_opins(&small_heap, router_opts.initial_pres_fac,
132133
router_opts.acc_fac, true);

vpr/src/base/vpr_types.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,6 @@ struct t_trace {
13261326
* @param prev_edge Index of the edge (from 0 to num_edges-1 of prev_node)
13271327
* that was used to reach this node from the previous node.
13281328
* If there is no predecessor, prev_edge = NO_PREVIOUS.
1329-
* @param pres_cost Present congestion cost term for this node.
13301329
* @param acc_cost Accumulated cost term from previous Pathfinder iterations.
13311330
* @param path_cost Total cost of the path up to and including this node +
13321331
* the expected cost to the target if the timing_driven router
@@ -1341,7 +1340,6 @@ struct t_rr_node_route_inf {
13411340
int prev_node;
13421341
RREdgeId prev_edge;
13431342

1344-
float pres_cost;
13451343
float acc_cost;
13461344
float path_cost;
13471345
float backward_path_cost;

vpr/src/draw/draw.cpp

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "save_graphics.h"
4646
#include "timing_info.h"
4747
#include "physical_types.h"
48+
#include "route_common.h"
4849

4950
#ifdef WIN32 /* For runtime tracking in WIN32. The clock() function defined in time.h will *
5051
* track CPU runtime. */
@@ -138,20 +139,20 @@ static void draw_router_expansion_costs(ezgl::renderer* g);
138139

139140
static void draw_rr_costs(ezgl::renderer* g, const std::vector<float>& rr_costs, bool lowest_cost_first = true);
140141

141-
void draw_main_canvas(ezgl::renderer* g);
142-
void initial_setup_NO_PICTURE_to_PLACEMENT(ezgl::application* app, bool is_new_window);
143-
void initial_setup_NO_PICTURE_to_PLACEMENT_with_crit_path(ezgl::application* app, bool is_new_window);
144-
void initial_setup_PLACEMENT_to_ROUTING(ezgl::application* app, bool is_new_window);
145-
void initial_setup_ROUTING_to_PLACEMENT(ezgl::application* app, bool is_new_window);
146-
void initial_setup_NO_PICTURE_to_ROUTING(ezgl::application* app, bool is_new_window);
147-
void initial_setup_NO_PICTURE_to_ROUTING_with_crit_path(ezgl::application* app, bool is_new_window);
148-
void toggle_window_mode(GtkWidget* /*widget*/, ezgl::application* /*app*/);
149-
void setup_default_ezgl_callbacks(ezgl::application* app);
150-
void set_force_pause(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data*/);
151-
void set_block_outline(GtkWidget* widget, gint /*response_id*/, gpointer /*data*/);
152-
void set_block_text(GtkWidget* widget, gint /*response_id*/, gpointer /*data*/);
153-
void clip_routing_util(GtkWidget* widget, gint /*response_id*/, gpointer /*data*/);
154-
void run_graphics_commands(std::string commands);
142+
static void draw_main_canvas(ezgl::renderer* g);
143+
static void initial_setup_NO_PICTURE_to_PLACEMENT(ezgl::application* app, bool is_new_window);
144+
static void initial_setup_NO_PICTURE_to_PLACEMENT_with_crit_path(ezgl::application* app, bool is_new_window);
145+
static void initial_setup_PLACEMENT_to_ROUTING(ezgl::application* app, bool is_new_window);
146+
static void initial_setup_ROUTING_to_PLACEMENT(ezgl::application* app, bool is_new_window);
147+
static void initial_setup_NO_PICTURE_to_ROUTING(ezgl::application* app, bool is_new_window);
148+
static void initial_setup_NO_PICTURE_to_ROUTING_with_crit_path(ezgl::application* app, bool is_new_window);
149+
static void toggle_window_mode(GtkWidget* /*widget*/, ezgl::application* /*app*/);
150+
static void setup_default_ezgl_callbacks(ezgl::application* app);
151+
static void set_force_pause(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data*/);
152+
static void set_block_outline(GtkWidget* widget, gint /*response_id*/, gpointer /*data*/);
153+
static void set_block_text(GtkWidget* widget, gint /*response_id*/, gpointer /*data*/);
154+
static void clip_routing_util(GtkWidget* widget, gint /*response_id*/, gpointer /*data*/);
155+
static void run_graphics_commands(std::string commands);
155156

156157
/************************** File Scope Variables ****************************/
157158

@@ -233,7 +234,7 @@ void init_graphics_state(bool show_graphics_val, int gr_automode_val, enum e_rou
233234
}
234235

235236
#ifndef NO_GRAPHICS
236-
void draw_main_canvas(ezgl::renderer* g) {
237+
static void draw_main_canvas(ezgl::renderer* g) {
237238
t_draw_state* draw_state = get_draw_state_vars();
238239

239240
g->set_font_size(14);
@@ -300,7 +301,7 @@ void draw_main_canvas(ezgl::renderer* g) {
300301
/* function below intializes the interface window with a set of buttons and links
301302
* signals to corresponding functions for situation where the window is opened from
302303
* NO_PICTURE_to_PLACEMENT */
303-
void initial_setup_NO_PICTURE_to_PLACEMENT(ezgl::application* app, bool is_new_window) {
304+
static void initial_setup_NO_PICTURE_to_PLACEMENT(ezgl::application* app, bool is_new_window) {
304305
if (!is_new_window) return;
305306

306307
//button to enter window_mode, created in main.ui
@@ -337,15 +338,15 @@ void initial_setup_NO_PICTURE_to_PLACEMENT(ezgl::application* app, bool is_new_w
337338
/* function below intializes the interface window with a set of buttons and links
338339
* signals to corresponding functions for situation where the window is opened from
339340
* NO_PICTURE_to_PLACEMENT_with_crit_path */
340-
void initial_setup_NO_PICTURE_to_PLACEMENT_with_crit_path(ezgl::application* app, bool is_new_window) {
341+
static void initial_setup_NO_PICTURE_to_PLACEMENT_with_crit_path(ezgl::application* app, bool is_new_window) {
341342
initial_setup_NO_PICTURE_to_PLACEMENT(app, is_new_window);
342343
button_for_toggle_crit_path();
343344
}
344345

345346
/* function below intializes the interface window with a set of buttons and links
346347
* signals to corresponding functions for situation where the window is opened from
347348
* PLACEMENT_to_ROUTING */
348-
void initial_setup_PLACEMENT_to_ROUTING(ezgl::application* app, bool is_new_window) {
349+
static void initial_setup_PLACEMENT_to_ROUTING(ezgl::application* app, bool is_new_window) {
349350
initial_setup_NO_PICTURE_to_PLACEMENT_with_crit_path(app, is_new_window);
350351
button_for_toggle_rr();
351352
button_for_toggle_congestion();
@@ -358,7 +359,7 @@ void initial_setup_PLACEMENT_to_ROUTING(ezgl::application* app, bool is_new_wind
358359
/* function below intializes the interface window with a set of buttons and links
359360
* signals to corresponding functions for situation where the window is opened from
360361
* ROUTING_to_PLACEMENT */
361-
void initial_setup_ROUTING_to_PLACEMENT(ezgl::application* app, bool is_new_window) {
362+
static void initial_setup_ROUTING_to_PLACEMENT(ezgl::application* app, bool is_new_window) {
362363
initial_setup_PLACEMENT_to_ROUTING(app, is_new_window);
363364
std::string toggle_rr = "toggle_rr";
364365
std::string toggle_congestion = "toggle_congestion";
@@ -378,7 +379,7 @@ void initial_setup_ROUTING_to_PLACEMENT(ezgl::application* app, bool is_new_wind
378379
/* function below intializes the interface window with a set of buttons and links
379380
* signals to corresponding functions for situation where the window is opened from
380381
* NO_PICTURE_to_ROUTING */
381-
void initial_setup_NO_PICTURE_to_ROUTING(ezgl::application* app, bool is_new_window) {
382+
static void initial_setup_NO_PICTURE_to_ROUTING(ezgl::application* app, bool is_new_window) {
382383
if (!is_new_window) return;
383384

384385
GtkButton* window = (GtkButton*)app->get_object("Window");
@@ -416,7 +417,7 @@ void initial_setup_NO_PICTURE_to_ROUTING(ezgl::application* app, bool is_new_win
416417
/* function below intializes the interface window with a set of buttons and links
417418
* signals to corresponding functions for situation where the window is opened from
418419
* NO_PICTURE_to_ROUTING_with_crit_path */
419-
void initial_setup_NO_PICTURE_to_ROUTING_with_crit_path(ezgl::application* app, bool is_new_window) {
420+
static void initial_setup_NO_PICTURE_to_ROUTING_with_crit_path(ezgl::application* app, bool is_new_window) {
420421
initial_setup_NO_PICTURE_to_ROUTING(app, is_new_window);
421422
button_for_toggle_crit_path();
422423
}
@@ -529,7 +530,7 @@ void update_screen(ScreenUpdatePriority priority, const char* msg, enum pic_type
529530
}
530531

531532
#ifndef NO_GRAPHICS
532-
void toggle_window_mode(GtkWidget* /*widget*/, ezgl::application* /*app*/) {
533+
static void toggle_window_mode(GtkWidget* /*widget*/, ezgl::application* /*app*/) {
533534
window_mode = true;
534535
}
535536

@@ -1194,27 +1195,24 @@ static void draw_routing_costs(ezgl::renderer* g) {
11941195
float min_cost = std::numeric_limits<float>::infinity();
11951196
float max_cost = -min_cost;
11961197
std::vector<float> rr_node_costs(device_ctx.rr_nodes.size(), 0.);
1198+
11971199
for (size_t inode = 0; inode < device_ctx.rr_nodes.size(); inode++) {
11981200
float cost = 0.;
11991201
if (draw_state->show_routing_costs == DRAW_TOTAL_ROUTING_COSTS
12001202
|| draw_state->show_routing_costs == DRAW_LOG_TOTAL_ROUTING_COSTS) {
1201-
int cost_index = device_ctx.rr_nodes[inode].cost_index();
1202-
cost = device_ctx.rr_indexed_data[cost_index].base_cost
1203-
+ route_ctx.rr_node_route_inf[inode].acc_cost
1204-
+ route_ctx.rr_node_route_inf[inode].pres_cost;
1203+
cost = get_single_rr_cong_cost(inode, get_draw_state_vars()->pres_fac);
12051204

12061205
} else if (draw_state->show_routing_costs == DRAW_BASE_ROUTING_COSTS) {
1207-
int cost_index = device_ctx.rr_nodes[inode].cost_index();
1208-
cost = device_ctx.rr_indexed_data[cost_index].base_cost;
1206+
cost = get_single_rr_cong_base_cost(inode);
12091207

12101208
} else if (draw_state->show_routing_costs == DRAW_ACC_ROUTING_COSTS
12111209
|| draw_state->show_routing_costs == DRAW_LOG_ACC_ROUTING_COSTS) {
1212-
cost = route_ctx.rr_node_route_inf[inode].acc_cost;
1210+
cost = get_single_rr_cong_acc_cost(inode);
12131211

12141212
} else {
12151213
VTR_ASSERT(draw_state->show_routing_costs == DRAW_PRES_ROUTING_COSTS
12161214
|| draw_state->show_routing_costs == DRAW_LOG_PRES_ROUTING_COSTS);
1217-
cost = route_ctx.rr_node_route_inf[inode].pres_cost;
1215+
cost = get_single_rr_cong_pres_cost(inode, get_draw_state_vars()->pres_fac);
12181216
}
12191217

12201218
if (draw_state->show_routing_costs == DRAW_LOG_TOTAL_ROUTING_COSTS
@@ -3913,7 +3911,7 @@ float get_net_alpha() {
39133911
return draw_state->net_alpha;
39143912
}
39153913

3916-
void setup_default_ezgl_callbacks(ezgl::application* app) {
3914+
static void setup_default_ezgl_callbacks(ezgl::application* app) {
39173915
// Connect press_proceed function to the Proceed button
39183916
GObject* proceed_button = app->get_object("ProceedButton");
39193917
g_signal_connect(proceed_button, "clicked", G_CALLBACK(ezgl::press_proceed), app);
@@ -3940,7 +3938,7 @@ void setup_default_ezgl_callbacks(ezgl::application* app) {
39403938
}
39413939

39423940
// Callback function for Block Outline checkbox
3943-
void set_block_outline(GtkWidget* widget, gint /*response_id*/, gpointer /*data*/) {
3941+
static void set_block_outline(GtkWidget* widget, gint /*response_id*/, gpointer /*data*/) {
39443942
t_draw_state* draw_state = get_draw_state_vars();
39453943

39463944
// assign corresponding bool value to draw_state->draw_block_outlines
@@ -3954,7 +3952,7 @@ void set_block_outline(GtkWidget* widget, gint /*response_id*/, gpointer /*data*
39543952
}
39553953

39563954
// Callback function for Block Text checkbox
3957-
void set_block_text(GtkWidget* widget, gint /*response_id*/, gpointer /*data*/) {
3955+
static void set_block_text(GtkWidget* widget, gint /*response_id*/, gpointer /*data*/) {
39583956
t_draw_state* draw_state = get_draw_state_vars();
39593957

39603958
// assign corresponding bool value to draw_state->draw_block_text
@@ -3969,7 +3967,7 @@ void set_block_text(GtkWidget* widget, gint /*response_id*/, gpointer /*data*/)
39693967
}
39703968

39713969
// Callback function for Clip Routing Util checkbox
3972-
void clip_routing_util(GtkWidget* widget, gint /*response_id*/, gpointer /*data*/) {
3970+
static void clip_routing_util(GtkWidget* widget, gint /*response_id*/, gpointer /*data*/) {
39733971
t_draw_state* draw_state = get_draw_state_vars();
39743972

39753973
// assign corresponding bool value to draw_state->clip_routing_util
@@ -3999,13 +3997,13 @@ void net_max_fanout(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data
39993997
application.refresh_drawing();
40003998
}
40013999

4002-
void set_force_pause(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data*/) {
4000+
static void set_force_pause(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data*/) {
40034001
t_draw_state* draw_state = get_draw_state_vars();
40044002

40054003
draw_state->forced_pause = true;
40064004
}
40074005

4008-
void run_graphics_commands(std::string commands) {
4006+
static void run_graphics_commands(std::string commands) {
40094007
//A very simmple command interpreter for scripting graphics
40104008
t_draw_state* draw_state = get_draw_state_vars();
40114009

vpr/src/draw/draw_global.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ constexpr float DEFAULT_ARROW_SIZE = 0.3;
2222
# define MIN_VISIBLE_AREA 3.0
2323

2424
t_draw_coords* get_draw_coords_vars();
25+
2526
t_draw_state* get_draw_state_vars();
2627

2728
#endif // NO_GRAPHICS

vpr/src/draw/draw_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ typedef struct {
159159
* save_graphics: Whether to generate an output graphcis file
160160
* force_pause: Should we pause for user interaction (since the user requested it)
161161
* save_graphics_file_base: Base of save graphis file name (i.e. before extension)
162+
* pres_fac: present congestion cost factor
162163
*/
163164
struct t_draw_state {
164165
pic_type pic_on_screen = NO_PICTURE;
@@ -193,6 +194,7 @@ struct t_draw_state {
193194
bool forced_pause = false;
194195
int sequence_number = 0;
195196
float net_alpha = 0.1;
197+
float pres_fac = 1.;
196198

197199
std::string save_graphics_file_base = "vpr";
198200

vpr/src/draw/tuesday.cpp

Whitespace-only changes.

vpr/src/route/connection_router.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ void ConnectionRouter<Heap>::evaluate_timing_driven_node_costs(t_heap* to,
620620

621621
float cong_cost = 0.;
622622
if (reached_configurably) {
623-
cong_cost = get_rr_cong_cost(to_node);
623+
cong_cost = get_rr_cong_cost(to_node, cost_params.pres_fac);
624624
} else {
625625
//Reached by a non-configurable edge.
626626
//Therefore the from_node and to_node are part of the same non-configurable node set.

vpr/src/route/connection_router_interface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ struct t_conn_cost_params {
2222
float criticality = 1.;
2323
float astar_fac = 1.2;
2424
float bend_cost = 1.;
25+
float pres_fac = 1.;
2526
const t_conn_delay_budget* delay_budget = nullptr;
2627

2728
//TODO: Eventually once delay budgets are working, t_conn_delay_budget

0 commit comments

Comments
 (0)