Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add option smpi/errors-are-fatal to allow users to bypass MPI errors returned by...
authorAugustin Degomme <adegomme@gmail.com>
Mon, 14 Jun 2021 12:07:41 +0000 (14:07 +0200)
committerAugustin Degomme <adegomme@gmail.com>
Mon, 14 Jun 2021 12:07:41 +0000 (14:07 +0200)
This basically sets the default errhandler to MPI_ERRORS_RETURN if set to false.

ChangeLog
docs/source/Configuring_SimGrid.rst
src/smpi/include/smpi_comm.hpp
src/smpi/include/smpi_config.hpp
src/smpi/include/smpi_win.hpp
src/smpi/internals/smpi_config.cpp
src/smpi/mpi/smpi_comm.cpp
src/smpi/mpi/smpi_file.cpp

index 6c779f0..861f3ed 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,9 +15,12 @@ SMPI:
  - The default SMPI compiler flags are no more taken from the environment.
    They can be explicitly set through cmake parameters SMPI_C_FLAGS,
    SMPI_CXX_FLAGS, or SMPI_Fortran_FLAGS.
- - New option: --cfg=smpi/finalization-barrier, which can be used to add
-   a barrier inside MPI_Finalize. This can help for some codes which cleanup
-   data attached to a process, but still used in other SMPI processes.
+ - New options:
+    --cfg=smpi/finalization-barrier: which can be used to add
+      a barrier inside MPI_Finalize. This can help for some codes which cleanup
+      data attached to a process, but still used in other SMPI processes.
+    --cfg=smpi/errors-are-fatal: True by default, behaves like if MPI_ERRORS_RETURN
+      is active when set to false, to keep going after a small error
 LUA:
  - Lua platform files are deprecated. Their support will be dropped after v3.31.
 
index b59b43e..b2718c0 100644 (file)
@@ -150,6 +150,7 @@ Existing Configuration Items
 - **smpi/cpu-threshold:** :ref:`cfg=smpi/cpu-threshold`
 - **smpi/display-allocs:** :ref:`cfg=smpi/display-allocs`
 - **smpi/display-timing:** :ref:`cfg=smpi/display-timing`
+- **smpi/errors-are-fatal:** :ref:`cfg=smpi/errors-are-fatal`
 - **smpi/finalization-barrier:** :ref:`cfg=smpi/finalization-barrier`
 - **smpi/grow-injected-times:** :ref:`cfg=smpi/grow-injected-times`
 - **smpi/host-speed:** :ref:`cfg=smpi/host-speed`
@@ -1325,6 +1326,15 @@ this option will add an explicit MPI_Barrier(MPI_COMM_WORLD) call inside the
 MPI_Finalize, so that all processes will terminate at almost the same point.
 It might affect the total timing by the cost of a barrier.
 
+.. _cfg=smpi/errors-are-fatal:
+
+**Option** ``smpi/errors-are-fatal`` **default:** on
+
+By default, SMPI processes will crash if a MPI error code is returned. MPI allows
+to explicitely set MPI_ERRORS_RETURN errhandler to avoid this behaviour. This flag
+will turn on this behaviour by default (for all concerned types and errhandlers).
+This can ease debugging by going after the first reported error.
+
 .. _cfg=smpi/iprobe:
 
 Inject constant times for MPI_Iprobe
index f54a743..34881bc 100644 (file)
@@ -13,6 +13,7 @@
 #include "smpi_keyvals.hpp"
 #include "smpi_group.hpp"
 #include "smpi_topo.hpp"
+#include "smpi_config.hpp"
 
 namespace simgrid{
 namespace smpi{
@@ -36,7 +37,7 @@ class Comm : public F2C, public Keyval{
   std::string name_;
   MPI_Info info_ = MPI_INFO_NULL;
   int id_;
-  MPI_Errhandler errhandler_ = MPI_ERRORS_ARE_FATAL;
+  MPI_Errhandler errhandler_ =  _smpi_cfg_default_errhandler_is_error ? MPI_ERRORS_ARE_FATAL : MPI_ERRORS_RETURN;;
   MPI_Errhandler* errhandlers_ = nullptr; //for MPI_COMM_WORLD only
 
 public:
index 903ebdb..60d81ed 100644 (file)
@@ -23,6 +23,7 @@ extern XBT_PRIVATE simgrid::config::Flag<double> _smpi_cfg_iprobe_cpu_usage;
 extern XBT_PRIVATE simgrid::config::Flag<bool> _smpi_cfg_trace_call_use_absolute_path;
 extern XBT_PRIVATE simgrid::config::Flag<bool> _smpi_cfg_trace_call_location;
 extern XBT_PRIVATE simgrid::config::Flag<std::string> _smpi_cfg_comp_adjustment_file;
+extern XBT_PRIVATE simgrid::config::Flag<bool> _smpi_cfg_default_errhandler_is_error;
 #if HAVE_PAPI
 extern XBT_PRIVATE simgrid::config::Flag<std::string> _smpi_cfg_papi_events_file;
 #endif
index d7d1880..b3994e4 100644 (file)
@@ -11,6 +11,7 @@
 #include "smpi_errhandler.hpp"
 #include "smpi_f2c.hpp"
 #include "smpi_keyvals.hpp"
+#include "smpi_config.hpp"
 
 #include <vector>
 #include <list>
@@ -41,7 +42,7 @@ class Win : public F2C, public Keyval {
   int mode_ = 0; // exclusive or shared lock
   bool allocated_;
   bool dynamic_;
-  MPI_Errhandler errhandler_ = MPI_ERRORS_ARE_FATAL;
+  MPI_Errhandler errhandler_ = _smpi_cfg_default_errhandler_is_error ? MPI_ERRORS_ARE_FATAL : MPI_ERRORS_RETURN;
 
 public:
   static std::unordered_map<int, smpi_key_elem> keyvals_;
index 41f771e..b7cd540 100644 (file)
@@ -108,7 +108,9 @@ simgrid::config::Flag<std::string> _smpi_cfg_comp_adjustment_file{"smpi/comp-adj
         }
       }
     }};
-    
+
+simgrid::config::Flag<bool> _smpi_cfg_default_errhandler_is_error{
+  "smpi/errors-are-fatal", "Whether MPI errors are fatal or just return. Default is true", true };
 #if HAVE_PAPI
   simgrid::config::Flag<std::string> _smpi_cfg_papi_events_file{"smpi/papi-events",
                                                                 "This switch enables tracking the specified counters with PAPI", ""};
index 017d010..5c23877 100644 (file)
@@ -583,9 +583,12 @@ MPI_Errhandler Comm::errhandler()
       errhandler_->ref();
     return errhandler_;
   } else {
-    if(errhandlers_==nullptr)
-      return MPI_ERRORS_ARE_FATAL;
-    else {
+    if(errhandlers_==nullptr){
+      if (_smpi_cfg_default_errhandler_is_error)
+        return MPI_ERRORS_ARE_FATAL;
+      else
+        return MPI_ERRORS_RETURN;
+    } else {
       if(errhandlers_[this->rank()] != MPI_ERRHANDLER_NULL)
         errhandlers_[this->rank()]->ref();
       return errhandlers_[this->rank()];
index 4ad8f8f..82c5e2f 100644 (file)
@@ -21,7 +21,7 @@
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_io, smpi, "Logging specific to SMPI (RMA operations)");
 
-MPI_Errhandler SMPI_default_File_Errhandler = MPI_ERRORS_RETURN;
+MPI_Errhandler SMPI_default_File_Errhandler =  _smpi_cfg_default_errhandler_is_error ? MPI_ERRORS_ARE_FATAL : MPI_ERRORS_RETURN;;
 
 namespace simgrid{
 namespace smpi{