Skip to content
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
Binary file modified doc/src/Images/Overall_view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions doc/src/vpr/graphics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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%
Expand Down Expand Up @@ -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.
56 changes: 27 additions & 29 deletions vpr/src/base/vpr_signal_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -17,6 +18,7 @@
#include "globals.h"

#include "read_place.h"
#include "read_route.h"
#include "route_export.h"
#include <atomic>

Expand All @@ -27,7 +29,16 @@
void vpr_signal_handler(int signal);
void checkpoint();

std::atomic<int> 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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Need a doxygen comment; what is this for?

(void)!write(STDERR_FILENO, msg, strlen(msg));
}

#ifdef VPR_USE_SIGACTION

Expand All @@ -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);
}
Expand All @@ -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);
}
2 changes: 2 additions & 0 deletions vpr/src/draw/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions vpr/src/place/annealer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down