Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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.
49 changes: 20 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,9 @@
void vpr_signal_handler(int signal);
void checkpoint();

std::atomic<int> uncleared_sigint_count(0);
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 +48,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 +78,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 @@ -270,6 +270,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