Skip to content

Commit

Permalink
[mpi] add documentation on copy/move
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelKoch committed Dec 17, 2024
1 parent 8e2a12a commit 3c88302
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions include/ginkgo/core/base/mpi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,16 @@ class communicator {
this->comm_.reset(new MPI_Comm(comm_out), comm_deleter{});
}

/**
* Creates a new communicator and takes ownership of the MPI_Comm.
*
* The ownership is shared with all communicators that are created as a
* copy from the new communicator.
* The underlying MPI_Comm will be freed when the last communicator with
* ownership is destroyed.
*
* @see communicator(const MPI_Comm&, bool)
*/
static communicator create_owning(const MPI_Comm& comm,
bool force_host_buffer = false)
{
Expand All @@ -462,12 +472,29 @@ class communicator {
return comm_out;
}

/**
* Create a copy of a communicator.
*
* Potential ownership of the underlying MPI_Comm will be shared.
*/
communicator(const communicator& other) = default;

/**
* Move constructor.
*
* The other communicator will relinquish any potential ownership and use
* MPI_COMM_NULL as underlying MPI_Comm after the move operation.
*/
communicator(communicator&& other) { *this = std::move(other); }

/**
* @see communicator(const communicator&)
*/
communicator& operator=(const communicator& other) = default;

/**
* @see communicator(communicator&&)
*/
communicator& operator=(communicator&& other)
{
if (this != &other) {
Expand Down

0 comments on commit 3c88302

Please sign in to comment.