1 #ifndef DUNE_FEM_MPIMANAGER_HH 2 #define DUNE_FEM_MPIMANAGER_HH 4 #include <dune/common/parallel/mpicollectivecommunication.hh> 5 #include <dune/common/parallel/mpihelper.hh> 21 typedef Dune::CollectiveCommunication< MPIHelper::MPICommunicator >
48 ~PETSc() { ::Dune::Petsc::finalize(); }
50 static void initialize(
const bool verbose,
int &argc,
char **&argv )
54 ::Dune::Petsc::initialize( verbose, argc, argv );
62 MPIHelper *&helper = instance().helper_;
68 #ifdef USE_SMP_PARALLEL 71 int is_initialized = MPI_Init_thread(&argc, &argv, MPI_THREAD_FUNNELED, &provided );
73 if( is_initialized != MPI_SUCCESS )
74 DUNE_THROW(InvalidStateException,
"MPI_Init_thread failed!");
76 #if not defined NDEBUG && defined DUNE_DEVEL_MODE 80 if( provided != MPI_THREAD_FUNNELED )
82 if( provided == MPI_THREAD_SINGLE )
83 dwarn <<
"MPI thread support = single (instead of funneled)!" << std::endl;
85 dwarn <<
"WARNING: MPI thread support = " << provided <<
" != MPI_THREAD_FUNNELED " << MPI_THREAD_FUNNELED << std::endl;
89 #endif // end USE_SMP_PARALLEL 90 #endif // end HAVE_MPI && MPI_2 92 if( (helper != 0) || (comm != 0) )
93 DUNE_THROW( InvalidStateException,
"MPIManager has already been initialized." );
96 helper = &MPIHelper::instance( argc, argv );
101 PETSc::initialize(
rank() == 0, argc, argv );
112 DUNE_THROW( InvalidStateException,
"MPIManager has not been initialized." );
118 return comm().rank();
123 return comm().size();
135 #endif // #ifndef DUNE_FEM_MPIMANAGER_HH
static int rank()
Definition: mpimanager.hh:116
static int size()
Definition: mpimanager.hh:121
static const CollectiveCommunication & comm()
Definition: mpimanager.hh:108
static void initialize()
initialize static variables
Definition: registry.hh:63
static void initialize(int &argc, char **&argv)
Definition: mpimanager.hh:60
Definition: coordinate.hh:4
Definition: mpimanager.hh:19
Dune::CollectiveCommunication< MPIHelper::MPICommunicator > CollectiveCommunication
Definition: mpimanager.hh:22