KaMPIng 0.2.1
(Near) zero-overhead MPI wrapper for C++
Loading...
Searching...
No Matches
kamping::types::ScopedOp Class Reference

RAII wrapper for an MPI_Op. More...

#include <reduce_ops.hpp>

Public Member Functions

 ScopedOp () noexcept
 Constructs an empty, non-owning handle (MPI_OP_NULL).
 
 ScopedOp (MPI_Op op, bool owns) noexcept
 Wrap an existing MPI_Op.
 
 ScopedOp (ScopedOp const &)=delete
 
ScopedOpoperator= (ScopedOp const &)=delete
 
 ScopedOp (ScopedOp &&other) noexcept
 Move constructor. Transfers ownership; the moved-from handle no longer frees the op.
 
ScopedOpoperator= (ScopedOp &&other) noexcept
 Move assignment. Frees any currently owned op, then transfers ownership.
 
MPI_Op get () const noexcept
 

Detailed Description

RAII wrapper for an MPI_Op.

Calls MPI_Op_free on destruction only when owns is true (i.e. the op was created via MPI_Op_create for a user-defined functor). Predefined MPI constants (MPI_SUM, MPI_MAX, …) are never freed.

Analogous to ScopedDatatype for MPI_Datatype.

Constructor & Destructor Documentation

◆ ScopedOp()

kamping::types::ScopedOp::ScopedOp ( MPI_Op op,
bool owns )
inlinenoexcept

Wrap an existing MPI_Op.

Parameters
opThe op to wrap.
ownsIf true, MPI_Op_free is called on destruction.

Member Function Documentation

◆ get()

MPI_Op kamping::types::ScopedOp::get ( ) const
inlinenoexcept
Returns
The underlying MPI_Op.

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