diff --git a/doc/src/Images/Overall_view.png b/doc/src/Images/Overall_view.png index c76e212c6b..c50e551e67 100644 Binary files a/doc/src/Images/Overall_view.png and b/doc/src/Images/Overall_view.png differ diff --git a/doc/src/vpr/graphics.rst b/doc/src/vpr/graphics.rst index 801055cee8..db1dd31502 100644 --- a/doc/src/vpr/graphics.rst +++ b/doc/src/vpr/graphics.rst @@ -308,6 +308,7 @@ Manual Moves The manual moves feature allows the user to specify the next move in placement. If the move is legal, blocks are swapped and the new move is shown on the architecture. +.. _fig-misc-tab: .. figure:: ../Images/manual_move.png :align: center :width: 25% @@ -335,3 +336,15 @@ If the manual move is legal, the cost summary window will display the delta cost The user can Accept or Reject the manual move based on the values provided. If accepted the block's new location is shown. +Pause Button +------------ + +The pause button allows the user to temporarily stop the program during placement or routing. +When clicked during the placement stage, the program will pause at the next temperature update. +When clicked during the routing stage, it will pause at the next router iteration. + +The button can be pressed at any time while the program is running. To enable the feature, click the **Pause** button under the **Misc.** tab (see :ref:`fig-misc-tab`). +Once the program reaches the next temperature update or router iteration after the button is pressed, it will automatically pause. + +After the program has paused, clicking **Next Step** allows the user to resume execution from the point where the program was paused. +This can be continuing from the current temperature in placement or from the current router iteration in routing. diff --git a/vpr/src/base/vpr_signal_handler.cpp b/vpr/src/base/vpr_signal_handler.cpp index 9be73206bd..e528df66ec 100644 --- a/vpr/src/base/vpr_signal_handler.cpp +++ b/vpr/src/base/vpr_signal_handler.cpp @@ -4,9 +4,10 @@ * (ctrl-C from terminal) on POSIX systems. It is only active if * VPR_USE_SIGACTION is defined. * - * If a SIGINT occur the handler sets the 'forced_pause' flag of the VPR - * context. If 'forced_pause' is still true when another SIGINT occurs an - * exception is thrown (typically ending the program). + * Behavior: + * - SIGINT : log, attempt to checkpoint, then exit with INTERRUPTED_EXIT_CODE + * - SIGHUP : log, attempt to checkpoint, continue running + * - SIGTERM : log, attempt to checkpoint, then exit with INTERRUPTED_EXIT_CODE */ #include "vtr_log.h" #include "vtr_time.h" @@ -17,6 +18,7 @@ #include "globals.h" #include "read_place.h" +#include "read_route.h" #include "route_export.h" #include @@ -27,7 +29,16 @@ void vpr_signal_handler(int signal); void checkpoint(); -std::atomic uncleared_sigint_count(0); +/** + * @brief Writes a message directly to stderr with async-signal-safe write() function. + * + * Uses write() to avoid signal unsafe std::cerr in the signal handler. + * + * @param msg Message string to write. + */ +static inline void safe_write(const char* msg) { + (void)!write(STDERR_FILENO, msg, strlen(msg)); +} #ifdef VPR_USE_SIGACTION @@ -44,28 +55,14 @@ void vpr_install_signal_handler() { void vpr_signal_handler(int signal) { if (signal == SIGINT) { - if (g_vpr_ctx.forced_pause()) { - uncleared_sigint_count++; //Previous SIGINT uncleared - } else { - uncleared_sigint_count.store(1); //Only this SIGINT outstanding - } - - if (uncleared_sigint_count == 1) { - VTR_LOG("Recieved SIGINT: try again to really exit...\n"); - } else if (uncleared_sigint_count == 2) { - VTR_LOG("Recieved two uncleared SIGINTs: Attempting to checkpoint and exit...\n"); - checkpoint(); - std::quick_exit(INTERRUPTED_EXIT_CODE); - } else if (uncleared_sigint_count == 3) { - //Really exit (e.g. SIGINT while checkpointing) - VTR_LOG("Recieved three uncleared SIGINTs: Exiting...\n"); - std::quick_exit(INTERRUPTED_EXIT_CODE); - } + safe_write("Received SIGINT: Attempting to checkpoint then exit...\n"); + checkpoint(); + std::quick_exit(INTERRUPTED_EXIT_CODE); } else if (signal == SIGHUP) { - VTR_LOG("Recieved SIGHUP: Attempting to checkpoint...\n"); + safe_write("Received SIGHUP: Attempting to checkpoint...\n"); checkpoint(); } else if (signal == SIGTERM) { - VTR_LOG("Recieved SIGTERM: Attempting to checkpoint then exit...\n"); + safe_write("Received SIGTERM: Attempting to checkpoint then exit...\n"); checkpoint(); std::quick_exit(INTERRUPTED_EXIT_CODE); } @@ -88,11 +85,12 @@ void checkpoint() { //Dump the current placement and routing state vtr::ScopedStartFinishTimer timer("Checkpointing"); - std::string placer_checkpoint_file = "placer_checkpoint.place"; - VTR_LOG("Attempting to checkpoint current placement to file: %s\n", placer_checkpoint_file.c_str()); - print_place(nullptr, nullptr, placer_checkpoint_file.c_str(), g_vpr_ctx.placement().block_locs()); + safe_write("Attempting to checkpoint current placement to file: placer_checkpoint.place\n"); + print_place(nullptr, nullptr, "placer_checkpoint.place", g_vpr_ctx.placement().block_locs()); + + bool is_flat = g_vpr_ctx.routing().is_flat; + const Netlist<>& router_net_list = is_flat ? (const Netlist<>&)g_vpr_ctx.atom().netlist() : (const Netlist<>&)g_vpr_ctx.clustering().clb_nlist; - std::string router_checkpoint_file = "router_checkpoint.route"; - VTR_LOG("Attempting to checkpoint current routing to file: %s\n", router_checkpoint_file.c_str()); - //print_route(nullptr, router_checkpoint_file.c_str()); + safe_write("Attempting to checkpoint current routing to file: router_checkpoint.route\n"); + print_route(router_net_list, nullptr, "router_checkpoint.route", is_flat); } diff --git a/vpr/src/draw/draw.cpp b/vpr/src/draw/draw.cpp index 99ff4e6796..510c1ce61d 100644 --- a/vpr/src/draw/draw.cpp +++ b/vpr/src/draw/draw.cpp @@ -274,6 +274,8 @@ static void on_stage_change_setup(ezgl::application* app, bool is_new_window) { hide_crit_path_routing(app); hide_draw_routing(app); + + app->update_message(draw_state->default_message); } #endif //NO_GRAPHICS diff --git a/vpr/src/place/annealer.cpp b/vpr/src/place/annealer.cpp index 0ce20f4b99..46e7f062bf 100644 --- a/vpr/src/place/annealer.cpp +++ b/vpr/src/place/annealer.cpp @@ -898,6 +898,11 @@ void PlacementAnnealer::placement_inner_loop() { } } +#ifdef VPR_USE_SIGACTION + // Save the block locations after each inner loop for checkpointing. + g_vpr_ctx.mutable_placement().mutable_block_locs() = placer_state_.block_locs(); +#endif + // Calculate the success_rate and std_dev of the costs. placer_stats_.calc_iteration_stats(costs_, annealing_state_.move_lim);