From: heister Date: Tue, 17 Sep 2013 18:49:23 +0000 (+0000) Subject: replace mpi_init by mpi_init_thread X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fcf7b8b1a4715f0e6207ba04063f525a21f3c9a9;p=dealii-svn.git replace mpi_init by mpi_init_thread git-svn-id: https://svn.dealii.org/trunk@30770 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 89ca970443..3120d72556 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -85,6 +85,12 @@ inconvenience this causes.

Specific improvements

    +
  1. + Changed: we now call MPI_Init_thread instead of MPI_Init. +
    + (Timo Heister, 2013/09/17) +
  2. +
  3. 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 diff --git a/deal.II/source/base/mpi.cc b/deal.II/source/base/mpi.cc index 663d647dad..8640464889 100644 --- a/deal.II/source/base/mpi.cc +++ b/deal.II/source/base/mpi.cc @@ -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