Skip to content

Commit 136e97b

Browse files
committed
Merge branch 'disable-graphics'
2 parents 87715a7 + f9a0412 commit 136e97b

20 files changed

+315
-175
lines changed

CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ option(VTR_ENABLE_PROFILING "Enable performance profiler (gprof)" OFF)
2828
option(VTR_ENABLE_COVERAGE "Enable code coverage tracking (gcov)" OFF)
2929
option(VTR_ENABLE_DEBUG_LOGGING "Enable debug logging" OFF)
3030

31+
#Allow the user to decide weather to compile the graphics library
32+
set(VPR_USE_EZGL "auto" CACHE STRING "Specify whether vpr uses the graphics library")
33+
set_property(CACHE VPR_USE_EZGL PROPERTY STRINGS auto off on)
34+
3135
option(WITH_BLIFEXPLORER "Enable build with blifexplorer" OFF)
3236
option(WITH_LIBRTLNUMBER "Enable build with librtlnumber" OFF)
3337

@@ -296,6 +300,26 @@ enable_testing()
296300
# For now just disable readline.
297301
set(READLINE_FOUND FALSE)
298302

303+
304+
# set VPR_USE_EZGL in the root of VTR to decide whether to add
305+
# subdirectory of graphics library, which prevents users
306+
# without gtk/x11 libraries installed to build. VPR_USE_EZGL is
307+
# being used in both the vpr CMakeLists and libs/EXTERNAL CMakeLists.
308+
#
309+
# check if GTK and X11 are installed and turn on/off graphics
310+
if (VPR_USE_EZGL STREQUAL "auto")
311+
find_package(PkgConfig REQUIRED)
312+
pkg_check_modules(GTK3 QUIET gtk+-3.0)
313+
pkg_check_modules(X11 QUIET x11)
314+
315+
if(GTK3_FOUND AND X11_FOUND)
316+
set(VPR_USE_EZGL "on")
317+
else()
318+
set(VPR_USE_EZGL "off")
319+
endif()
320+
endif()
321+
322+
299323
#Add the various sub-projects
300324
add_subdirectory(libs)
301325
add_subdirectory(vpr)

libs/EXTERNAL/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@ add_subdirectory(libargparse)
77
add_subdirectory(libsdcparse)
88
add_subdirectory(libblifparse)
99
add_subdirectory(libtatum)
10-
add_subdirectory(libezgl)
10+
11+
#VPR_USE_EZGL is initialized in the root CMakeLists.
12+
#compile libezgl only if the user asks for or has its dependencies installed.
13+
if(VPR_USE_EZGL STREQUAL "on")
14+
add_subdirectory(libezgl)
15+
endif()

vpr/CMakeLists.txt

Lines changed: 52 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,24 @@ option(VPR_USE_SIGNAL_HANDLER "Should VPR use a signal handler to intercept sign
1616
set(VPR_PGO_CONFIG "none" CACHE STRING "Configure VPR Profile-Guided Optimization (PGO). prof_gen: built executable will produce profiling info, prof_use: built executable will be optimized based on generated profiling info, none: disable pgo")
1717
set_property(CACHE VPR_PGO_CONFIG PROPERTY STRINGS prof_gen prof_use none)
1818

19-
set(
20-
RESOURCE_LIST
21-
# Strip all the whitespace characters from ui file
22-
STRIPBLANKS main.ui
23-
)
2419

25-
list(APPEND CMAKE_MODULE_PATH
26-
${CMAKE_CURRENT_SOURCE_DIR}/../libs/EXTERNAL/libezgl/gcr-cmake/macros)
20+
if (VPR_USE_EZGL STREQUAL "on")
21+
set(
22+
RESOURCE_LIST
23+
# Strip all the whitespace characters from ui file
24+
STRIPBLANKS main.ui
25+
)
26+
27+
list(APPEND CMAKE_MODULE_PATH
28+
${CMAKE_CURRENT_SOURCE_DIR}/../libs/EXTERNAL/libezgl/gcr-cmake/macros)
29+
30+
include(GlibCompileResourcesSupport)
31+
endif()
2732

2833
#
2934
# Build Configuration
3035
#
3136
include(CheckCXXSymbolExists)
32-
include(GlibCompileResourcesSupport)
3337

3438
#Collect the source files
3539
file(GLOB_RECURSE EXEC_SOURCES src/main.cpp)
@@ -52,48 +56,59 @@ target_link_libraries(libvpr
5256
libarchfpga
5357
libsdcparse
5458
libblifparse
55-
ezgl
5659
libeasygl
5760
libtatum
5861
libargparse
5962
libpugixml)
6063

61-
#Create the executable
62-
add_executable(vpr ${EXEC_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/resources.C)
63-
target_link_libraries(vpr
64-
libvpr)
64+
#link graphics library only when graphics set to on
65+
if (VPR_USE_EZGL STREQUAL "on")
66+
target_link_libraries(libvpr
67+
ezgl)
68+
69+
compile_gresources(
70+
# input: the name of our resources
71+
RESOURCE_FILE
72+
# output: the filename of the generated XML file
73+
XML_OUT
74+
# generate C code to be compiled with our program
75+
TYPE
76+
EMBED_C
77+
# specify the name of the C file that is generated
78+
TARGET
79+
resources.C
80+
# specify the resource prefix (used in the code)
81+
PREFIX
82+
/ezgl
83+
# input: specify the list of files to compile into resources
84+
RESOURCES
85+
${RESOURCE_LIST}
86+
)
87+
88+
89+
add_custom_target(
90+
resource ALL
91+
DEPENDS
92+
${RESOURCE_FILE}
93+
)
94+
95+
#Create the executable with resources
96+
list(APPEND EXEC_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/resources.C)
97+
98+
endif()
99+
100+
add_executable(vpr ${EXEC_SOURCES})
101+
102+
target_link_libraries(vpr libvpr)
103+
65104

66105
#Supress IPO link warnings if IPO is enabled
67106
get_target_property(VPR_USES_IPO vpr INTERPROCEDURAL_OPTIMIZATION)
68107
if (VPR_USES_IPO)
69108
set_target_properties(vpr PROPERTIES LINK_FLAGS ${IPO_LINK_WARN_SUPRESS_FLAGS})
70109
endif()
71110

72-
compile_gresources(
73-
# input: the name of our resources
74-
RESOURCE_FILE
75-
# output: the filename of the generated XML file
76-
XML_OUT
77-
# generate C code to be compiled with our program
78-
TYPE
79-
EMBED_C
80-
# specify the name of the C file that is generated
81-
TARGET
82-
resources.C
83-
# specify the resource prefix (used in the code)
84-
PREFIX
85-
/ezgl
86-
# input: specify the list of files to compile into resources
87-
RESOURCES
88-
${RESOURCE_LIST}
89-
)
90-
91111

92-
add_custom_target(
93-
resource ALL
94-
DEPENDS
95-
${RESOURCE_FILE}
96-
)
97112

98113
#
99114
# VPR compiler options

vpr/src/base/place_and_route.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,6 @@ int binary_search_place_and_route(t_placer_opts placer_opts,
356356
&warnings);
357357

358358
init_draw_coords(final);
359-
360359
restore_routing(best_routing, route_ctx.clb_opins_used_locally, saved_clb_opins_used_locally);
361360

362361
if (Fc_clipped) {

vpr/src/base/vpr_api.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,6 @@ RouteStatus vpr_route_flow(t_vpr_setup& vpr_setup, const t_arch& arch) {
707707

708708
//Update interactive graphics
709709
update_screen(ScreenUpdatePriority::MAJOR, graphics_msg.c_str(), ROUTING, timing_info);
710-
711710
free_net_delay(net_delay, &net_delay_ch);
712711
}
713712

@@ -788,7 +787,6 @@ RouteStatus vpr_load_routing(t_vpr_setup& vpr_setup,
788787

789788
timing_info->update();
790789
}
791-
792790
init_draw_coords(fixed_channel_width);
793791

794792
return RouteStatus(is_legal, fixed_channel_width);
@@ -829,14 +827,12 @@ void vpr_create_rr_graph(t_vpr_setup& vpr_setup, const t_arch& arch, int chan_wi
829827
router_opts.lookahead_type,
830828
arch.Directs, arch.num_directs,
831829
&warnings);
832-
833830
//Initialize drawing, now that we have an RR graph
834831
init_draw_coords(chan_width_fac);
835832
}
836833

837834
void vpr_init_graphics(const t_vpr_setup& vpr_setup, const t_arch& arch) {
838835
/* Startup X graphics */
839-
840836
init_graphics_state(vpr_setup.ShowGraphics, vpr_setup.GraphPause,
841837
vpr_setup.RouterOpts.route_type);
842838
if (vpr_setup.ShowGraphics) {

vpr/src/draw/draw.cpp

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ using namespace std;
4242
#include "hsl.h"
4343
#include "route_export.h"
4444
#include "search_bar.h"
45+
#include "timing_info.h"
46+
#include "physical_types.h"
4547

4648
#ifdef WIN32 /* For runtime tracking in WIN32. The clock() function defined in time.h will *
4749
* track CPU runtime. */
@@ -53,19 +55,21 @@ using namespace std;
5355
# include <sys/time.h>
5456
#endif
5557

58+
#ifndef NO_GRAPHICS
59+
5660
//To process key presses we need the X11 keysym definitions,
5761
//which are unavailable when building with MINGW
58-
#if defined(X11) && !defined(__MINGW32__)
59-
# include <X11/keysym.h>
60-
#endif
62+
# if defined(X11) && !defined(__MINGW32__)
63+
# include <X11/keysym.h>
64+
# endif
6165

62-
#include "rr_graph.h"
63-
#include "route_util.h"
64-
#include "place_macro.h"
66+
# include "rr_graph.h"
67+
# include "route_util.h"
68+
# include "place_macro.h"
6569

6670
/****************************** Define Macros *******************************/
6771

68-
#define DEFAULT_RR_NODE_COLOR ezgl::BLACK
72+
# define DEFAULT_RR_NODE_COLOR ezgl::BLACK
6973
//#define TIME_DRAWSCREEN /* Enable if want to track runtime for drawscreen() */
7074

7175
//The arrow head position for turning/straight-thru connections in a switch box
@@ -200,9 +204,12 @@ void initial_setup_NO_PICTURE_to_ROUTING(ezgl::application* app);
200204
void initial_setup_NO_PICTURE_to_ROUTING_with_crit_path(ezgl::application* app);
201205
void toggle_window_mode(GtkWidget* /*widget*/, ezgl::application* /*app*/);
202206

207+
#endif // NO_GRAPHICS
208+
203209
/********************** Subroutine definitions ******************************/
204210

205211
void init_graphics_state(bool show_graphics_val, int gr_automode_val, enum e_route_type route_type) {
212+
#ifndef NO_GRAPHICS
206213
/* Call accessor functions to retrieve global variables. */
207214
t_draw_state* draw_state = get_draw_state_vars();
208215

@@ -213,8 +220,14 @@ void init_graphics_state(bool show_graphics_val, int gr_automode_val, enum e_rou
213220
draw_state->show_graphics = show_graphics_val;
214221
draw_state->gr_automode = gr_automode_val;
215222
draw_state->draw_route_type = route_type;
223+
#else
224+
(void)show_graphics_val;
225+
(void)gr_automode_val;
226+
(void)route_type;
227+
#endif // NO_GRAPHICS
216228
}
217229

230+
#ifndef NO_GRAPHICS
218231
void draw_main_canvas(ezgl::renderer& g) {
219232
t_draw_state* draw_state = get_draw_state_vars();
220233

@@ -368,8 +381,11 @@ void initial_setup_NO_PICTURE_to_ROUTING_with_crit_path(ezgl::application* app)
368381
initial_setup_NO_PICTURE_to_ROUTING(app);
369382
app->create_button("Crit. Path", 6, toggle_crit_path);
370383
}
384+
#endif //NO_GRAPHICS
371385

372386
void update_screen(ScreenUpdatePriority priority, const char* msg, enum pic_type pic_on_screen_val, std::shared_ptr<SetupTimingInfo> setup_timing_info) {
387+
#ifndef NO_GRAPHICS
388+
373389
/* Updates the screen if the user has requested graphics. The priority *
374390
* value controls whether or not the Proceed button must be clicked to *
375391
* continue. Saves the pic_on_screen_val to allow pan and zoom redraws. */
@@ -438,8 +454,15 @@ void update_screen(ScreenUpdatePriority priority, const char* msg, enum pic_type
438454
} else {
439455
application.refresh_drawing();
440456
}
457+
#else
458+
(void)setup_timing_info;
459+
(void)priority;
460+
(void)msg;
461+
(void)pic_on_screen_val;
462+
#endif //NO_GRAPHICS
441463
}
442464

465+
#ifndef NO_GRAPHICS
443466
void toggle_window_mode(GtkWidget* /*widget*/, ezgl::application* /*app*/) {
444467
window_mode = true;
445468
}
@@ -645,7 +668,10 @@ void toggle_router_rr_costs(GtkWidget* /*widget*/, ezgl::application* app) {
645668
app->refresh_drawing();
646669
}
647670

671+
#endif // NO_GRAPHICS
672+
648673
void alloc_draw_structs(const t_arch* arch) {
674+
#ifndef NO_GRAPHICS
649675
/* Call accessor functions to retrieve global variables. */
650676
t_draw_coords* draw_coords = get_draw_coords_vars();
651677
t_draw_state* draw_state = get_draw_state_vars();
@@ -672,9 +698,13 @@ void alloc_draw_structs(const t_arch* arch) {
672698
draw_state->arch_info = arch;
673699

674700
deselect_all(); /* Set initial colors */
701+
#else
702+
(void)arch;
703+
#endif // NO_GRAPHICS
675704
}
676705

677706
void free_draw_structs() {
707+
#ifndef NO_GRAPHICS
678708
/* Free everything allocated by alloc_draw_structs. Called after close_graphics() *
679709
* in vpr_api.c.
680710
*
@@ -694,9 +724,13 @@ void free_draw_structs() {
694724
free(draw_state->draw_rr_node);
695725
draw_state->draw_rr_node = nullptr;
696726
}
727+
#else
728+
;
729+
#endif /* NO_GRAPHICS */
697730
}
698731

699732
void init_draw_coords(float width_val) {
733+
#ifndef NO_GRAPHICS
700734
/* Load the arrays containing the left and bottom coordinates of the clbs *
701735
* forming the FPGA. tile_width_val sets the width and height of a drawn *
702736
* clb. */
@@ -751,8 +785,13 @@ void init_draw_coords(float width_val) {
751785
float draw_height = draw_coords->tile_y[device_ctx.grid.height() - 1] + draw_coords->get_tile_width();
752786

753787
initial_world = ezgl::rectangle({-VISIBLE_MARGIN * draw_width, -VISIBLE_MARGIN * draw_height}, {(1. + VISIBLE_MARGIN) * draw_width, (1. + VISIBLE_MARGIN) * draw_height});
788+
#else
789+
(void)width_val;
790+
#endif /* NO_GRAPHICS */
754791
}
755792

793+
#ifndef NO_GRAPHICS
794+
756795
/* Draws the blocks placed on the proper clbs. Occupied blocks are darker colours *
757796
* while empty ones are lighter colours and have a dashed border. */
758797
static void drawplace(ezgl::renderer& g) {
@@ -2354,7 +2393,7 @@ static bool highlight_rr_nodes(float x, float y) {
23542393
return highlight_rr_nodes(hit_node);
23552394
}
23562395

2357-
#if defined(X11) && !defined(__MINGW32__)
2396+
# if defined(X11) && !defined(__MINGW32__)
23582397
void act_on_key_press(ezgl::application* app, GdkEventKey* event, char* key_name) {
23592398
//VTR_LOG("Key press %c (%d)\n", key_pressed, keysym);
23602399
std::string key(key_name);
@@ -2366,11 +2405,11 @@ void act_on_key_press(ezgl::application* app, GdkEventKey* event, char* key_name
23662405

23672406
event = event; // just for hiding warning message
23682407
}
2369-
#else
2408+
# else
23702409
void act_on_key_press(ezgl::application* app, GdkEventKey* event, char* key_name) {
23712410
//Nothing to do
23722411
}
2373-
#endif
2412+
# endif
23742413

23752414
void act_on_mouse_press(ezgl::application* app, GdkEventButton* event, double x, double y) {
23762415
app->update_message("Mouse Clicked");
@@ -3553,3 +3592,5 @@ static void highlight_blocks(double x, double y) {
35533592

35543593
application.refresh_drawing();
35553594
}
3595+
3596+
#endif /* NO_GRAPHICS */

0 commit comments

Comments
 (0)