[PPL-devel] [GIT] ppl/ppl(MPI): Init: call MPI_Init and MPI_Finalize directly, instead of using an mpi::environment, avoiding crashes on some systems.

Marco Poletti poletti.marco at gmail.com
Fri Sep 10 12:02:47 CEST 2010


Module: ppl/ppl
Branch: MPI
Commit: 4b615df4b01f520c6a3f67ccd2af4dfe7db19670
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=4b615df4b01f520c6a3f67ccd2af4dfe7db19670

Author: Marco Poletti <poletti.marco at gmail.com>
Date:   Fri Sep 10 12:01:54 2010 +0200

Init: call MPI_Init and MPI_Finalize directly, instead of using an mpi::environment, avoiding crashes on some systems.

---

 src/Init.cc      |   11 +++++------
 src/Init.defs.hh |    1 -
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/Init.cc b/src/Init.cc
index c5eaf18..1c4a9d6 100644
--- a/src/Init.cc
+++ b/src/Init.cc
@@ -52,8 +52,7 @@ unsigned int PPL::Init::count = 0;
 PPL::fpu_rounding_direction_type PPL::Init::old_rounding_direction;
 
 #if USE_PPL_DISTRIBUTED_SPARSE_MATRIX
-boost::mpi::communicator* PPL::Init::mpi_communicator;
-boost::mpi::environment* PPL::Init::mpi_environment;
+boost::mpi::communicator* PPL::Init::mpi_communicator = NULL;
 #endif // USE_PPL_DISTRIBUTED_SPARSE_MATRIX
 
 extern "C" void
@@ -189,11 +188,11 @@ PPL::Init::Init() {
 
 #if USE_PPL_DISTRIBUTED_SPARSE_MATRIX
     // Initialize MPI
-    int fake_argc = 0;
+    int fake_argc = 1;
     char c = '\0';
     char *fake_argv0 = &c;
     char **fake_argv = &fake_argv0;
-    mpi_environment = new boost::mpi::environment(fake_argc, fake_argv);
+    MPI_Init(&fake_argc, &fake_argv);
     mpi_communicator = new boost::mpi::communicator();
     if (mpi_communicator->rank() == 0) {
       Distributed_Sparse_Matrix::init_root(*mpi_communicator);
@@ -201,7 +200,7 @@ PPL::Init::Init() {
       // WARNING: worker nodes will block here until process termination
       Distributed_Sparse_Matrix::worker_main_loop(*mpi_communicator);
       delete mpi_communicator;
-      delete mpi_environment;
+      MPI_Finalize();
       exit(0);
     }
 #endif // USE_PPL_DISTRIBUTED_SPARSE_MATRIX
@@ -215,7 +214,7 @@ PPL::Init::~Init() {
     // Release MPI resources.
     Distributed_Sparse_Matrix::quit_workers();
     delete mpi_communicator;
-    delete mpi_environment;
+    MPI_Finalize();
 #endif // USE_PPL_DISTRIBUTED_SPARSE_MATRIX
 
 #if PPL_CAN_CONTROL_FPU
diff --git a/src/Init.defs.hh b/src/Init.defs.hh
index 7df6a7e..f9f2ed3 100644
--- a/src/Init.defs.hh
+++ b/src/Init.defs.hh
@@ -86,7 +86,6 @@ private:
   static fpu_rounding_direction_type old_rounding_direction;
 #if USE_PPL_DISTRIBUTED_SPARSE_MATRIX
   static boost::mpi::communicator* mpi_communicator;
-  static boost::mpi::environment* mpi_environment;
 #endif
 
   friend void set_rounding_for_PPL();




More information about the PPL-devel mailing list