141 [[maybe_unused]]
char** argv)
155 int rank ()
const {
return 0; }
159 int size ()
const {
return 1; }
163 FakeMPIHelper(
const FakeMPIHelper&);
164 FakeMPIHelper& operator=(
const FakeMPIHelper);
198 return MPI_COMM_WORLD;
209 return MPI_COMM_SELF;
244 static std::mutex mutex;
245 std::lock_guard<std::mutex> guard(mutex);
247 instance_.reset(
new MPIHelper(argc,argv));
262 int rank ()
const {
return rank_; }
266 int size ()
const {
return size_; }
271 int wasFinalized = -1;
272 MPI_Finalized( &wasFinalized );
273 if(!wasFinalized && initializedHere_)
276 dverb <<
"Called MPI_Finalize on p=" << rank_ <<
"!" <<std::endl;
284 bool initializedHere_;
285 void prevent_warning(
int){}
286 static inline std::unique_ptr<MPIHelper> instance_ = {};
289 MPIHelper(
int& argc,
char**& argv)
290 : initializedHere_(false)
292 int wasInitialized = -1;
293 MPI_Initialized( &wasInitialized );
298 static int is_initialized = MPI_Init(&argc, &argv);
299 prevent_warning(is_initialized);
300 initializedHere_ =
true;
303 MPI_Comm_rank(MPI_COMM_WORLD,&rank_);
304 MPI_Comm_size(MPI_COMM_WORLD,&size_);
306 assert( rank_ >= 0 );
307 assert( size_ >= 1 );
309 dverb <<
"Called MPI_Init on p=" << rank_ <<
"!" << std::endl;
312 MPIHelper(
const MPIHelper&);
313 MPIHelper& operator=(
const MPIHelper);
322 typedef FakeMPIHelper MPIHelper;
Implements an utility class that provides collective communication methods for sequential programs.
Implements an utility class that provides MPI's collective communication methods.
Standard Dune debug streams.
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:18
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
DVerbType dverb(std::cout)
Singleton of verbose debug stream.
Definition: stdstreams.hh:114
Dune namespace.
Definition: alignedallocator.hh:11
Default exception if a function was called while the object is not in a valid state for that function...
Definition: exceptions.hh:279
Definition: communication.hh:44
Collective communication interface and sequential default implementation.
Definition: communication.hh:98
A fake mpi helper.
Definition: mpihelper.hh:72
static DUNE_EXPORT MPICommunicator getCommunicator()
get the default communicator
Definition: mpihelper.hh:93
static DUNE_EXPORT FakeMPIHelper & instance([[maybe_unused]] int argc, [[maybe_unused]] char **argv)
Get the singleton instance of the helper.
Definition: mpihelper.hh:140
static Communication< MPICommunicator > getCollectiveCommunication()
Definition: mpihelper.hh:114
int size() const
return rank of process, i.e. one
Definition: mpihelper.hh:159
static Communication< MPICommunicator > getCommunication()
Definition: mpihelper.hh:120
@ isFake
Are we fake (i.e. pretend to have MPI support but are compiled without.)
Definition: mpihelper.hh:79
static MPICommunicator getLocalCommunicator()
get a local communicator
Definition: mpihelper.hh:105
No_Comm MPICommunicator
The type of the mpi communicator.
Definition: mpihelper.hh:85
static DUNE_EXPORT FakeMPIHelper & instance()
Definition: mpihelper.hh:146
int rank() const
return rank of process, i.e. zero
Definition: mpihelper.hh:155
A real mpi helper.
Definition: mpihelper.hh:175
int size() const
return number of processes
Definition: mpihelper.hh:266
static Communication< MPICommunicator > getCollectiveCommunication()
Definition: mpihelper.hh:215
~MPIHelper()
calls MPI_Finalize
Definition: mpihelper.hh:269
int rank() const
return rank of process
Definition: mpihelper.hh:262
@ isFake
Are we fake (i. e. pretend to have MPI support but are compiled without.
Definition: mpihelper.hh:182
MPI_Comm MPICommunicator
The type of the mpi communicator.
Definition: mpihelper.hh:188
static MPICommunicator getCommunicator()
get the default communicator
Definition: mpihelper.hh:196
static MPICommunicator getLocalCommunicator()
get a local communicator
Definition: mpihelper.hh:207
static Communication< MPICommunicator > getCommunication()
Definition: mpihelper.hh:221
static DUNE_EXPORT MPIHelper & instance(int &argc, char **&argv)
Get the singleton instance of the helper.
Definition: mpihelper.hh:240
static DUNE_EXPORT MPIHelper & instance()
Definition: mpihelper.hh:252