Loading...
Searching...
No Matches
gpr::linalg::MpiCommunicator Class Reference

#include <gpr/linalg/MpiCommunicator.h>

Public Member Functions

 MpiCommunicator (MpiCommType source)
 ~MpiCommunicator ()
 MpiCommunicator (const MpiCommunicator &)=delete
MpiCommunicator & operator= (const MpiCommunicator &)=delete
MpiContext view () const noexcept

Detailed Description

Owns an independent communication space on the caller's process group. Construction is collective. Components share its lifetime through shared_ptr<const MpiCommunicator> and borrow view() for synchronous work. All participants use the same collective order and destroy their owners before MPI_Finalize. This object neither initializes nor finalizes MPI.

Definition at line 16 of file MpiCommunicator.h.

Constructor & Destructor Documentation

◆ MpiCommunicator() [1/2]

gpr::linalg::MpiCommunicator::MpiCommunicator ( MpiCommType source)
explicit

Definition at line 10 of file MpiCommunicator.cpp.

11{
12#if defined(GPR_HAVE_MPI) || defined(GPR_LINALG_SCALAPACK)
13 if (source == MPI_COMM_NULL)
14 throw std::invalid_argument("cannot own a null MPI communicator");
15 view_ = MpiContext::fromCommunicator(source);
16 if (MPI_Comm_dup(source, &view_.comm) != MPI_SUCCESS)
17 throw std::runtime_error("could not duplicate MPI communicator");
18#else
19 (void)source;
20 throw std::logic_error("MPI communicator requires an MPI build");
21#endif
22}

◆ ~MpiCommunicator()

gpr::linalg::MpiCommunicator::~MpiCommunicator ( )

Definition at line 24 of file MpiCommunicator.cpp.

25{
26#if defined(GPR_HAVE_MPI) || defined(GPR_LINALG_SCALAPACK)
27 int finalized = 0;
28 MPI_Finalized(&finalized);
29 if (!finalized && view_.comm != MPI_COMM_NULL) MPI_Comm_free(&view_.comm);
30#endif
31}

◆ MpiCommunicator() [2/2]

gpr::linalg::MpiCommunicator::MpiCommunicator ( const MpiCommunicator & )
delete

Member Function Documentation

◆ operator=()

MpiCommunicator & gpr::linalg::MpiCommunicator::operator= ( const MpiCommunicator & )
delete

◆ view()

MpiContext gpr::linalg::MpiCommunicator::view ( ) const
inlinenodiscardnoexcept

Definition at line 24 of file MpiCommunicator.h.

25 {
26 return view_;
27 }

The documentation for this class was generated from the following files: