KaMPIng 0.2.1
(Near) zero-overhead MPI wrapper for C++
Loading...
Searching...
No Matches
kamping::types::ScopedCallbackOp< is_commutative > Class Template Reference

RAII handle that creates an MPI_Op from a raw MPI callback function pointer. More...

#include <reduce_ops.hpp>

Public Types

using callback_type = void (*)(void*, void*, int*, MPI_Datatype*)
 The MPI callback signature expected by MPI_Op_create.
 

Public Member Functions

 ScopedCallbackOp () noexcept=default
 Constructs an empty, non-owning handle (MPI_OP_NULL).
 
 ScopedCallbackOp (callback_type ptr)
 Creates an MPI_Op for the given callback.
 
 ScopedCallbackOp (ScopedCallbackOp const &)=delete
 
ScopedCallbackOpoperator= (ScopedCallbackOp const &)=delete
 
 ScopedCallbackOp (ScopedCallbackOp &&) noexcept=default
 Move constructor. The moved-from handle becomes empty.
 
ScopedCallbackOpoperator= (ScopedCallbackOp &&) noexcept=default
 Move assignment. Frees any currently owned op, then takes ownership.
 
MPI_Op get () const noexcept
 

Detailed Description

template<bool is_commutative>
class kamping::types::ScopedCallbackOp< is_commutative >

RAII handle that creates an MPI_Op from a raw MPI callback function pointer.

Calls MPI_Op_create on construction and MPI_Op_free on destruction. A default-constructed ScopedCallbackOp is empty (MPI_OP_NULL, non-owning). Supports move construction and assignment; the moved-from handle becomes empty.

Typically used for lambdas with captures, where the lambda is stored separately and a raw function pointer (via a static trampoline) is passed to MPI_Op_create.

Template Parameters
is_commutativeWhether the operation is commutative.

Constructor & Destructor Documentation

◆ ScopedCallbackOp()

template<bool is_commutative>
kamping::types::ScopedCallbackOp< is_commutative >::ScopedCallbackOp ( callback_type ptr)
inlineexplicit

Creates an MPI_Op for the given callback.

Parameters
ptrNon-null MPI callback function pointer.

Member Function Documentation

◆ get()

template<bool is_commutative>
MPI_Op kamping::types::ScopedCallbackOp< is_commutative >::get ( ) const
inlinenoexcept
Returns
The underlying MPI_Op (MPI_OP_NULL if default-constructed). Do not free manually.

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