117 [[deprecated(
"getCollectionCommunication is deprecated. Use getCommunication instead.")]]
145 [[maybe_unused]]
char** argv)
159 int rank ()
const {
return 0; }
163 int size ()
const {
return 1; }
167 FakeMPIHelper(
const FakeMPIHelper&);
168 FakeMPIHelper& operator=(
const FakeMPIHelper);
200 return MPI_COMM_WORLD;
211 return MPI_COMM_SELF;
219 [[deprecated(
"getCollectionCommunication is deprecated. Use getCommunication instead.")]]
250 static std::mutex mutex;
251 std::lock_guard<std::mutex> guard(mutex);
253 instance_.reset(
new MPIHelper(argc,argv));
268 int rank ()
const {
return rank_; }
272 int size ()
const {
return size_; }
277 int wasFinalized = -1;
278 MPI_Finalized( &wasFinalized );
279 if(!wasFinalized && initializedHere_)
282 dverb <<
"Called MPI_Finalize on p=" << rank_ <<
"!" <<std::endl;
290 bool initializedHere_;
291 void prevent_warning(
int){}
292 static inline std::unique_ptr<MPIHelper> instance_ = {};
295 MPIHelper(
int& argc,
char**& argv)
296 : initializedHere_(false)
298 int wasInitialized = -1;
299 MPI_Initialized( &wasInitialized );
304 static int is_initialized = MPI_Init(&argc, &argv);
305 prevent_warning(is_initialized);
306 initializedHere_ =
true;
309 MPI_Comm_rank(MPI_COMM_WORLD,&rank_);
310 MPI_Comm_size(MPI_COMM_WORLD,&size_);
312 assert( rank_ >= 0 );
313 assert( size_ >= 1 );
315 dverb <<
"Called MPI_Init on p=" << rank_ <<
"!" << std::endl;
318 MPIHelper(
const MPIHelper&);
319 MPIHelper& operator=(
const MPIHelper);
328 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
Standard Dune debug streams.
Implements an utility class that provides collective communication methods for sequential programs.
Implements an utility class that provides MPI's collective communication methods.
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
DVerbType dverb(std::cout)
Singleton of verbose debug stream.
Definition stdstreams.hh:116
Dune namespace.
Definition alignedallocator.hh:13
Default exception if a function was called while the object is not in a valid state for that function...
Definition exceptions.hh:281
Definition communication.hh:46
Collective communication interface and sequential default implementation.
Definition communication.hh:100
A fake mpi helper.
Definition mpihelper.hh:74
static DUNE_EXPORT MPICommunicator getCommunicator()
get the default communicator
Definition mpihelper.hh:93
int size() const
return rank of process, i.e. one
Definition mpihelper.hh:163
static Communication< MPICommunicator > getCollectiveCommunication()
Definition mpihelper.hh:118
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(int argc, char **argv)
Get the singleton instance of the helper.
Definition mpihelper.hh:144
static DUNE_EXPORT FakeMPIHelper & instance()
Definition mpihelper.hh:150
static Communication< MPICommunicator > getCommunication()
Definition mpihelper.hh:124
static constexpr bool isFake
Are we fake (i.e. pretend to have MPI support but are compiled without.)
Definition mpihelper.hh:80
int rank() const
return rank of process, i.e. zero
Definition mpihelper.hh:159
A real mpi helper.
Definition mpihelper.hh:179
int size() const
return number of processes
Definition mpihelper.hh:272
static DUNE_EXPORT MPIHelper & instance()
Definition mpihelper.hh:258
static constexpr bool isFake
Are we fake (i. e. pretend to have MPI support but are compiled without.
Definition mpihelper.hh:185
static DUNE_EXPORT MPIHelper & instance(int &argc, char **&argv)
Get the singleton instance of the helper.
Definition mpihelper.hh:246
static Communication< MPICommunicator > getCommunication()
Definition mpihelper.hh:227
~MPIHelper()
calls MPI_Finalize
Definition mpihelper.hh:275
int rank() const
return rank of process
Definition mpihelper.hh:268
MPI_Comm MPICommunicator
The type of the mpi communicator.
Definition mpihelper.hh:190
static MPICommunicator getCommunicator()
get the default communicator
Definition mpihelper.hh:198
static MPICommunicator getLocalCommunicator()
get a local communicator
Definition mpihelper.hh:209
static Communication< MPICommunicator > getCollectiveCommunication()
Definition mpihelper.hh:221