]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use MPI_Abort instead of std::abort. 4413/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 23 May 2017 21:35:49 +0000 (15:35 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 23 May 2017 22:33:02 +0000 (16:33 -0600)
source/base/exceptions.cc

index 456962a9d01ca8af61b3cccf5224642cc2ae8283..6f7c217dd08fbbf113fa7f2672f7c45bebfff31d 100644 (file)
@@ -410,9 +410,28 @@ namespace deal_II_exceptions
     {
       if (dealii::deal_II_exceptions::abort_on_exception)
         {
-          // Print the error message and bail out:
+          // first print the error
           std::cerr << exc.what() << std::endl;
+
+          // then bail out. if in MPI mode, bring down the entire
+          // house by asking the MPI system to do a best-effort
+          // operation at also terminating all of the other MPI
+          // processes. this is useful because if only one process
+          // runs into an assertion, then that may lead to deadlocks
+          // if the others don't recognize this, or at the very least
+          // delay their termination until they realize that their
+          // communication with the job that died times out.
+#ifdef DEAL_II_WITH_MPI
+          int is_initialized;
+          MPI_Initialized(&is_initialized);
+          if (is_initialized)
+            MPI_Abort (MPI_COMM_WORLD,
+                       /* return code = */ 255);
+          else
+            std::abort ();
+#else
           std::abort();
+#endif
         }
       else if (nothrow)
         {

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.