44 * (ctrl-C from terminal) on POSIX systems. It is only active if
55 * VPR_USE_SIGACTION is defined.
66 *
7- * If a SIGINT occur the handler sets the 'forced_pause' flag of the VPR
8- * context. If 'forced_pause' is still true when another SIGINT occurs an
9- * exception is thrown (typically ending the program).
7+ * Behavior:
8+ * - SIGINT : log, attempt to checkpoint, then exit with INTERRUPTED_EXIT_CODE
9+ * - SIGHUP : log, attempt to checkpoint, continue running
10+ * - SIGTERM : log, attempt to checkpoint, then exit with INTERRUPTED_EXIT_CODE
1011 */
1112#include " vtr_log.h"
1213#include " vtr_time.h"
1718#include " globals.h"
1819
1920#include " read_place.h"
21+ #include " read_route.h"
2022#include " route_export.h"
2123#include < atomic>
2224
2729void vpr_signal_handler (int signal);
2830void checkpoint ();
2931
30- std::atomic<int > uncleared_sigint_count (0 );
31-
3232#ifdef VPR_USE_SIGACTION
3333
3434void vpr_install_signal_handler () {
@@ -44,23 +44,9 @@ void vpr_install_signal_handler() {
4444
4545void vpr_signal_handler (int signal) {
4646 if (signal == SIGINT) {
47- if (g_vpr_ctx.forced_pause ()) {
48- uncleared_sigint_count++; // Previous SIGINT uncleared
49- } else {
50- uncleared_sigint_count.store (1 ); // Only this SIGINT outstanding
51- }
52-
53- if (uncleared_sigint_count == 1 ) {
54- VTR_LOG (" Recieved SIGINT: try again to really exit...\n " );
55- } else if (uncleared_sigint_count == 2 ) {
56- VTR_LOG (" Recieved two uncleared SIGINTs: Attempting to checkpoint and exit...\n " );
57- checkpoint ();
58- std::quick_exit (INTERRUPTED_EXIT_CODE);
59- } else if (uncleared_sigint_count == 3 ) {
60- // Really exit (e.g. SIGINT while checkpointing)
61- VTR_LOG (" Recieved three uncleared SIGINTs: Exiting...\n " );
62- std::quick_exit (INTERRUPTED_EXIT_CODE);
63- }
47+ VTR_LOG (" Recieved SIGINT: Attempting to checkpoint then exit...\n " );
48+ checkpoint ();
49+ std::quick_exit (INTERRUPTED_EXIT_CODE);
6450 } else if (signal == SIGHUP) {
6551 VTR_LOG (" Recieved SIGHUP: Attempting to checkpoint...\n " );
6652 checkpoint ();
@@ -92,7 +78,10 @@ void checkpoint() {
9278 VTR_LOG (" Attempting to checkpoint current placement to file: %s\n " , placer_checkpoint_file.c_str ());
9379 print_place (nullptr , nullptr , placer_checkpoint_file.c_str (), g_vpr_ctx.placement ().block_locs ());
9480
81+ bool is_flat = g_vpr_ctx.routing ().is_flat ;
82+ const Netlist<>& router_net_list = is_flat ? (const Netlist<>&)g_vpr_ctx.atom ().netlist () : (const Netlist<>&)g_vpr_ctx.clustering ().clb_nlist ;
83+
9584 std::string router_checkpoint_file = " router_checkpoint.route" ;
9685 VTR_LOG (" Attempting to checkpoint current routing to file: %s\n " , router_checkpoint_file.c_str ());
97- // print_route(nullptr, router_checkpoint_file.c_str());
98- }
86+ print_route (router_net_list, nullptr , router_checkpoint_file.c_str (), is_flat );
87+ }
0 commit comments