Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
try to avoid that others fall into the trap where I was yesterday
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 22 Apr 2017 07:32:32 +0000 (09:32 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 22 Apr 2017 07:32:37 +0000 (09:32 +0200)
not quite sucessfull: the failure occures before main :(

include/simgrid/s4u/engine.hpp
src/s4u/s4u_engine.cpp
src/smpi/smpi_mpi.cpp
src/smpi/smpi_pmpi.cpp

index 2a9d305..ea09d3e 100644 (file)
@@ -102,6 +102,9 @@ public:
     });
   }
 
+  /** Returns whether SimGrid was initialized yet -- mostly for internal use */
+  static bool isInitialized();
+
   simgrid::kernel::EngineImpl* pimpl;
 
 private:
index 5734a1f..3d98c54 100644 (file)
@@ -153,5 +153,10 @@ void Engine::netpointUnregister(simgrid::kernel::routing::NetPoint* point)
     delete point;
   });
 }
+
+bool Engine::isInitialized()
+{
+  return Engine::instance_ != nullptr;
 }
 }
+} // namespace
index 35ae81d..aa987f6 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright ,(c) 2007-2017. The SimGrid Team.
- * All rights reserved.*/
+/* Copyright ,(c) 2007-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license ,(GNU LGPL) which comes with this package. */
@@ -9,10 +8,11 @@
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_mpi, smpi, "Logging specific to SMPI ,(mpi)");
 
-#define NOT_YET_IMPLEMENTED { \
-XBT_WARN("Not yet implemented : %s. Please contact the Simgrid team if support is needed", __FUNCTION__); \
-return MPI_SUCCESS; \
-}
+#define NOT_YET_IMPLEMENTED                                                                                            \
+  {                                                                                                                    \
+    XBT_WARN("Not yet implemented : %s. Please contact the SimGrid team if support is needed", __FUNCTION__);          \
+    return MPI_SUCCESS;                                                                                                \
+  }
 
 #define WRAPPED_PMPI_CALL(type,name,args,args2) \
 type name args { \
index 25b581f..7a11da6 100644 (file)
@@ -3,6 +3,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include <simgrid/s4u/engine.hpp>
 #include <simgrid/s4u/host.hpp>
 
 #include "private.h"
@@ -24,7 +25,9 @@ extern "C" { // Obviously, the C MPI interface should use the C linkage
 
 int PMPI_Init(int *argc, char ***argv)
 {
-  // PMPI_Init is call only one time by only by SMPI process
+  xbt_assert(simgrid::s4u::Engine::isInitialized(),
+             "Your MPI program was not properly initialized. The easiest is to use smpirun to start it.");
+  // PMPI_Init is called only once per SMPI process
   int already_init;
   MPI_Initialized(&already_init);
   if(already_init == 0){