Skip to content

Refactor the placer debug code #1522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,22 @@ jobs:
script:
- ./.github/travis/build.sh
- travis_wait 30 ./run_reg_test.pl vtr_reg_basic -show_failures -j2
- stage: Test
name: "Basic Regression Tests with NO_GRAPHICS"
env:
- CMAKE_PARAMS="-DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on -DVPR_USE_EZGL=off"
- MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
script:
- ./.github/travis/build.sh
- travis_wait 30 ./run_reg_test.pl vtr_reg_basic -show_failures -j2
- stage: Test
name: "Basic Regression Tests with VTR_ENABLE_DEBUG_LOGGING"
env:
- CMAKE_PARAMS="-DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on -DVTR_ENABLE_DEBUG_LOGGING=on"
- MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
script:
- ./.github/travis/build.sh
- travis_wait 30 ./run_reg_test.pl vtr_reg_basic -show_failures -j2
- stage: Test
name: "Strong Regression Tests"
env:
Expand Down
2 changes: 2 additions & 0 deletions vpr/src/draw/breakpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <iostream>

#ifndef NO_GRAPHICS
//if the user adds a "proceed move" breakpoint using the entry field in the UI, this function converts it to the equivalent expression and calls the expression evaluator. Returns true if a breakpoint is encountered
//the way the proceed moves breakpoint works is that it proceeds the indicated number of moves from where the placer currently is i.e if at move 3 and proceed 4 ends up at move 7
bool check_for_moves_breakpoints(int moves_to_proceed) {
Expand Down Expand Up @@ -92,3 +93,4 @@ void print_current_info(bool in_placer) {
else
std::cout << "\nrouter_iter: " << get_bp_state_globals()->get_glob_breakpoint_state()->router_iter << "\nnet_id: " << get_bp_state_globals()->get_glob_breakpoint_state()->route_net_id << "\n----------------------------\n";
}
#endif
116 changes: 75 additions & 41 deletions vpr/src/draw/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@
#include "route_common.h"
#include "breakpoint.h"

#ifdef VTR_ENABLE_DEBUG_LOGGING
# include "move_utils.h"
#endif
#include "move_utils.h"

#ifdef WIN32 /* For runtime tracking in WIN32. The clock() function defined in time.h will *
* track CPU runtime. */
Expand Down Expand Up @@ -78,6 +76,8 @@
/****************************** Define Macros *******************************/

# define DEFAULT_RR_NODE_COLOR ezgl::BLACK
# define OLD_BLK_LOC_COLOR blk_GOLD
# define NEW_BLK_LOC_COLOR blk_GREEN
//#define TIME_DRAWSCREEN /* Enable if want to track runtime for drawscreen() */

/********************** Subroutines local to this module ********************/
Expand Down Expand Up @@ -993,56 +993,33 @@ static void drawplace(ezgl::renderer* g) {
/* Fill background for the clb. Do not fill if "show_blk_internal"
* is toggled.
*/
if (bnum == INVALID_BLOCK_ID) continue;
//Determine the block color
if (bnum == INVALID_BLOCK_ID)
continue;

//Determine the block color and logical type
ezgl::color block_color;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put the continue for if (bnum == ...) on a separate, indented line.

t_logical_block_type_ptr logical_block_type = nullptr;
# ifdef VTR_ENABLE_DEBUG_LOGGING
if (f_placer_debug) {
t_pl_loc curr_loc;
curr_loc.x = i;
curr_loc.y = j;
auto it = std::find_if(draw_state->colored_blocks.begin(), draw_state->colored_blocks.end(), [&curr_loc](const std::pair<t_pl_loc, ezgl::color>& a) { return (a.first.x == curr_loc.x && a.first.y == curr_loc.y); });
if (it != draw_state->colored_blocks.end()) {
block_color = it->second;
auto tile_type = device_ctx.grid[i][j].type;
logical_block_type = pick_best_logical_type(tile_type);
} else {
if (bnum != EMPTY_BLOCK_ID) {
block_color = draw_state->block_color(bnum);
logical_block_type = cluster_ctx.clb_nlist.block_type(bnum);
} else {
block_color = get_block_type_color(device_ctx.grid[i][j].type);
block_color = lighten_color(block_color, EMPTY_BLOCK_LIGHTEN_FACTOR);

auto tile_type = device_ctx.grid[i][j].type;
logical_block_type = pick_best_logical_type(tile_type);
}
}
} else {
//flag whether the current location is highlighted with a special color or not
bool current_loc_is_highlighted = false;

if (placer_breakpoint_reached())
current_loc_is_highlighted = highlight_loc_with_specific_color(int(i), int(j), block_color);

// No color specified at this location; use the block color.
if (current_loc_is_highlighted == false) {
if (bnum != EMPTY_BLOCK_ID) {
block_color = draw_state->block_color(bnum);
logical_block_type = cluster_ctx.clb_nlist.block_type(bnum);
} else {
block_color = get_block_type_color(device_ctx.grid[i][j].type);
block_color = lighten_color(block_color, EMPTY_BLOCK_LIGHTEN_FACTOR);

auto tile_type = device_ctx.grid[i][j].type;
logical_block_type = pick_best_logical_type(tile_type);
}
}
# else
if (bnum != EMPTY_BLOCK_ID) {
block_color = draw_state->block_color(bnum);
logical_block_type = cluster_ctx.clb_nlist.block_type(bnum);
} else {
block_color = get_block_type_color(device_ctx.grid[i][j].type);
block_color = lighten_color(block_color, EMPTY_BLOCK_LIGHTEN_FACTOR);

auto tile_type = device_ctx.grid[i][j].type;
logical_block_type = pick_best_logical_type(tile_type);
}
# endif
auto tile_type = device_ctx.grid[i][j].type;
logical_block_type = pick_best_logical_type(tile_type);

g->set_color(block_color);
/* Get coords of current sub_tile */
ezgl::rectangle abs_clb_bbox = draw_coords->get_absolute_clb_bbox(i, j, k, logical_block_type);
Expand Down Expand Up @@ -4157,4 +4134,61 @@ static void run_graphics_commands(std::string commands) {
++draw_state->sequence_number;
}

/* This routine highlights the blocks affected in the latest move *
* It highlights the old and new locations of the moved blocks *
* It also highlights the moved block input and output terminals *
* Currently, it is used in placer debugger when breakpoint is reached */
void highlight_moved_block_and_its_terminals(const t_pl_blocks_to_be_moved& blocks_affected) {
auto& cluster_ctx = g_vpr_ctx.clustering();

//clear all selected blocks
deselect_all();

//highlight the input/output terminals of the moved block
draw_highlight_blocks_color(cluster_ctx.clb_nlist.block_type(blocks_affected.moved_blocks[0].block_num), blocks_affected.moved_blocks[0].block_num);

//highlight the old and new locations of the moved block
clear_colored_locations();
set_draw_loc_color(blocks_affected.moved_blocks[0].old_loc, OLD_BLK_LOC_COLOR);
set_draw_loc_color(blocks_affected.moved_blocks[0].old_loc, NEW_BLK_LOC_COLOR);
}

// pass in an (x,y,subtile) location and the color in which it should be drawn.
// This overrides the color of any block placed in that location, and also applies if the location is empty.
void set_draw_loc_color(t_pl_loc loc, ezgl::color clr) {
t_draw_state* draw_state = get_draw_state_vars();
draw_state->colored_locations.push_back(std::make_pair(loc, clr));
}

// clear the colored_locations vector
void clear_colored_locations() {
t_draw_state* draw_state = get_draw_state_vars();
draw_state->colored_locations.clear();
}

// This routine takes in a (x,y) location.
// If the input loc is marked in colored_locations vector, the function will return true and the correspnding color is sent back in loc_color
// otherwise, the function returns false (the location isn't among the highlighted locations)
bool highlight_loc_with_specific_color(int x, int y, ezgl::color& loc_color) {
t_draw_state* draw_state = get_draw_state_vars();

//define a (x,y) location variable
t_pl_loc curr_loc;
curr_loc.x = x;
curr_loc.y = y;

//search for the current location in the vector of colored locations
auto it = std::find_if(draw_state->colored_locations.begin(), draw_state->colored_locations.end(), [&curr_loc](const std::pair<t_pl_loc, ezgl::color>& vec_element) { return (vec_element.first.x == curr_loc.x && vec_element.first.y == curr_loc.y); });

if (it != draw_state->colored_locations.end()) {
/* found a colored location at the spot I am drawing *
* (currently used for drawing the current move). *
* This overrides any block color. */
loc_color = it->second;
return true;
}

return false;
}

#endif /* NO_GRAPHICS */
18 changes: 18 additions & 0 deletions vpr/src/draw/draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,24 @@ float get_net_alpha();

ezgl::color get_block_type_color(t_physical_tile_type_ptr type);

/* This routine highlights the blocks affected in the latest move *
* It highlights the old and new locations of the moved blocks *
* It also highlights the moved block input and output terminals *
* Currently, it is used in placer debugger when breakpoint is reached */
void highlight_moved_block_and_its_terminals(const t_pl_blocks_to_be_moved&);

// pass in an (x,y,subtile) location and the color in which it should be drawn.
// This overrides the color of any block placed in that location, and also applies if the location is empty.
void set_draw_loc_color(t_pl_loc, ezgl::color);

// clear the colored_locations vector
void clear_colored_locations();

// This routine takes in a (x,y) location.
// If the input loc is marked in colored_locations vector, the function will return true and the correspnding color is sent back in loc_color
// otherwise, the function returns false (the location isn't among the highlighted locations)
bool highlight_loc_with_specific_color(int x, int y, ezgl::color& loc_color);

#endif /* NO_GRAPHICS */

#endif /* DRAW_H */
Loading