5#ifndef DUNE_COMMON_PARALLEL_MPIHELPER_HH
6#define DUNE_COMMON_PARALLEL_MPIHELPER_HH
119 [[deprecated(
"getCollectionCommunication is deprecated. Use getCommunication instead.")]]
147 [[maybe_unused]]
char** argv)
161 int rank ()
const {
return 0; }
165 int size ()
const {
return 1; }
169 FakeMPIHelper(
const FakeMPIHelper&);
170 FakeMPIHelper& operator=(
const FakeMPIHelper);
202 return MPI_COMM_WORLD;
213 return MPI_COMM_SELF;
221 [[deprecated(
"getCollectionCommunication is deprecated. Use getCommunication instead.")]]
286 assert((argc ==
nullptr) == (argv ==
nullptr));
294 int rank ()
const {
return rank_; }
298 int size ()
const {
return size_; }
303 int wasFinalized = -1;
304 MPI_Finalized( &wasFinalized );
305 if(!wasFinalized && initializedHere_)
308 dverb <<
"Called MPI_Finalize on p=" << rank_ <<
"!" <<std::endl;
316 bool initializedHere_;
317 void prevent_warning(
int){}
320 MPIHelper(
int* argc,
char*** argv)
321 : initializedHere_(false)
323 int wasInitialized = -1;
324 MPI_Initialized( &wasInitialized );
329 static int is_initialized = MPI_Init(argc, argv);
330 prevent_warning(is_initialized);
331 initializedHere_ =
true;
334 MPI_Comm_rank(MPI_COMM_WORLD,&rank_);
335 MPI_Comm_size(MPI_COMM_WORLD,&size_);
337 assert( rank_ >= 0 );
338 assert( size_ >= 1 );
340 dverb <<
"Called MPI_Init on p=" << rank_ <<
"!" << std::endl;
343 MPIHelper(
const MPIHelper&);
344 MPIHelper& operator=(
const MPIHelper);
353 typedef FakeMPIHelper MPIHelper;
Definition of macros controlling symbol visibility at the ABI level.
#define DUNE_EXPORT
Export a symbol as part of the public ABI.
Definition visibility.hh:20
Implements an utility class that provides MPI's collective communication methods.
Implements an utility class that provides collective communication methods for sequential programs.
A few common exception classes.
Standard Dune debug streams.
DVerbType dverb(std::cout)
Singleton of verbose debug stream.
Definition stdstreams.hh:117
Dune namespace.
Definition alignedallocator.hh:13
Definition communication.hh:46
Collective communication interface and sequential default implementation.
Definition communication.hh:100
A fake mpi helper.
Definition mpihelper.hh:76
static DUNE_EXPORT MPICommunicator getCommunicator()
get the default communicator
Definition mpihelper.hh:95
No_Comm MPICommunicator
The type of the mpi communicator.
Definition mpihelper.hh:87
int size() const
return rank of process, i.e. one
Definition mpihelper.hh:165
static Communication< MPICommunicator > getCollectiveCommunication()
Definition mpihelper.hh:120
static MPICommunicator getLocalCommunicator()
get a local communicator
Definition mpihelper.hh:107
static DUNE_EXPORT FakeMPIHelper & instance(int argc, char **argv)
Get the singleton instance of the helper.
Definition mpihelper.hh:146
static DUNE_EXPORT FakeMPIHelper & instance()
Definition mpihelper.hh:152
static Communication< MPICommunicator > getCommunication()
Definition mpihelper.hh:126
static constexpr bool isFake
Are we fake (i.e. pretend to have MPI support but are compiled without.)
Definition mpihelper.hh:82
int rank() const
return rank of process, i.e. zero
Definition mpihelper.hh:161
A real mpi helper.
Definition mpihelper.hh:181
int size() const
return number of processes
Definition mpihelper.hh:298
static constexpr bool isFake
Are we fake (i. e. pretend to have MPI support but are compiled without.
Definition mpihelper.hh:187
static DUNE_EXPORT MPIHelper & instance(int *argc=nullptr, char ***argv=nullptr)
Get the singleton instance of the helper.
Definition mpihelper.hh:284
static DUNE_EXPORT MPIHelper & instance(int &argc, char **&argv)
Get the singleton instance of the helper.
Definition mpihelper.hh:252
static Communication< MPICommunicator > getCommunication()
Definition mpihelper.hh:229
~MPIHelper()
calls MPI_Finalize
Definition mpihelper.hh:301
int rank() const
return rank of process
Definition mpihelper.hh:294
static MPICommunicator getCommunicator()
get the default communicator
Definition mpihelper.hh:200
static MPICommunicator getLocalCommunicator()
get a local communicator
Definition mpihelper.hh:211
static Communication< MPICommunicator > getCollectiveCommunication()
Definition mpihelper.hh:223
MPI_Comm MPICommunicator
The type of the mpi communicator.
Definition mpihelper.hh:192