]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
replace mpi_init by mpi_init_thread
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 17 Sep 2013 18:49:23 +0000 (18:49 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 17 Sep 2013 18:49:23 +0000 (18:49 +0000)
git-svn-id: https://svn.dealii.org/trunk@30770 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/source/base/mpi.cc

index 89ca97044374f847db72a46016073621745b2dc9..3120d725567c70ac8e0b4418a99868c324a8c00f 100644 (file)
@@ -85,6 +85,12 @@ inconvenience this causes.
 <h3>Specific improvements</h3>
 
 <ol>
+  <li>
+  Changed: we now call MPI_Init_thread instead of MPI_Init.
+  <br>
+  (Timo Heister, 2013/09/17)
+  </li>
+
   <li>
   Enhancement: It is now possible to use the build directory directly without
   the need to install first. For this, a second copy of all necessary project
index 663d647dad9f4030a1128c2a1a715259ec55886f..8640464889b67c98a36d0c967af12120de16c380 100644 (file)
@@ -342,16 +342,9 @@ namespace Utilities
               ExcMessage ("You can only create a single object of this class "
                           "in a program since it initializes the MPI system."));
 
-#ifdef DEAL_II_WITH_PETSC
-#  ifdef DEAL_II_WITH_SLEPC
-      // Initialise SLEPc (with PETSc):
-      SlepcInitialize(&argc, &argv, PETSC_NULL, PETSC_NULL);
-#  else
-      // or just initialise PETSc alone:
-      PetscInitialize(&argc, &argv, PETSC_NULL, PETSC_NULL);
-#  endif
-#else
-#  ifdef DEAL_II_WITH_MPI
+
+
+#ifdef DEAL_II_WITH_MPI
       // if we have PETSc, we will initialize it and let it handle MPI.
       // Otherwise, we will do it.
       int MPI_has_been_started = 0;
@@ -359,16 +352,31 @@ namespace Utilities
       AssertThrow (MPI_has_been_started == 0,
                    ExcMessage ("MPI error. You can only start MPI once!"));
 
-      int mpi_err;
-      mpi_err = MPI_Init (&argc, &argv);
+      int mpi_err, provided;
+      // this works likempi_err = MPI_Init (&argc, &argv); but tells MPI that
+      // we might use several threads but never call two MPI functions at the
+      // same time. For an explanation see on why we do this see
+      // http://www.open-mpi.org/community/lists/users/2010/03/12244.php
+      mpi_err = MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &provided);
       AssertThrow (mpi_err == 0,
                    ExcMessage ("MPI could not be initialized."));
-#  else
+#else
       // make sure the compiler doesn't warn
       // about these variables
       (void)argc;
       (void)argv;
       (void)owns_mpi;
+#endif
+
+      // we are allowed to call MPI_Init ourselves and PETScInitialize will
+      // detect this. This allows us to use MPI_Init_thread instead.
+#ifdef DEAL_II_WITH_PETSC
+#  ifdef DEAL_II_WITH_SLEPC
+      // Initialise SLEPc (with PETSc):
+      SlepcInitialize(&argc, &argv, PETSC_NULL, PETSC_NULL);
+#  else
+      // or just initialise PETSc alone:
+      PetscInitialize(&argc, &argv, PETSC_NULL, PETSC_NULL);
 #  endif
 #endif
 

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.