KaMPIng 0.1.0
(Near) zero-overhead C++ MPI bindings.
Loading...
Searching...
No Matches
kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType > Class Template Reference

Data buffer used for named parameters. More...

#include <data_buffer.hpp>

Inheritance diagram for kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >:
kamping::internal::ParameterObjectBase

Public Types

using MemberTypeWithConst
 
using MemberTypeWithConstAndRef
 
using value_type
 Value type of the buffer.
 
using value_type_with_const
 

Public Member Functions

template<bool enabled = ownership == BufferOwnership::referencing, std::enable_if_t< enabled, bool > = true>
 DataBuffer (MemberTypeWithConst &container)
 Constructor for referencing ContainerBasedBuffer.
 
template<bool enabled = ownership == BufferOwnership::owning, std::enable_if_t< enabled, bool > = true>
 DataBuffer (MemberType container)
 Constructor for owning ContainerBasedBuffer.
 
template<bool enabled = allocation == BufferAllocation::lib_allocated, std::enable_if_t< enabled, bool > = true>
 DataBuffer ()
 Constructor for lib allocated ContainerBasedBuffer.
 
size_t size () const
 The size of the underlying container.
 
template<BufferResizePolicy _resize_policy = resize_policy, typename std::enable_if_t< _resize_policy==resize_to_fit, bool > = true>
void resize (size_t size)
 Resizes the underlying container such that it holds exactly size elements of value_type.
 
template<BufferResizePolicy _resize_policy = resize_policy, typename std::enable_if_t< _resize_policy==grow_only, bool > = true>
void resize (size_t size)
 Resizes the underlying container such that it holds at least size elements of value_type.
 
template<BufferResizePolicy _resize_policy = resize_policy, typename std::enable_if_t< _resize_policy==no_resize, bool > = true>
void resize (size_t size)=delete
 
template<typename SizeFunc >
void resize_if_requested (SizeFunc &&compute_required_size)
 Resizes the underlying container if the buffer the buffer's resize policy allows and resizing is necessary.
 
value_type constdata () const
 Get const access to the underlying container.
 
value_type_with_constdata ()
 Get access to the underlying container.
 
Span< value_type constget () const
 Get read-only access to the underlying storage.
 
Span< value_type_with_constget ()
 Get access to the underlying storage.
 
template<bool enabled = is_single_element, std::enable_if_t< enabled, bool > = true>
value_type const get_single_element () const
 Get the single element wrapped by this object.
 
MemberType constunderlying () const
 Provides access to the underlying data.
 
template<bool enabled = modifiability == BufferModifiability::modifiable, std::enable_if_t< enabled, bool > = true>
MemberTypeunderlying ()
 Provides access to the underlying data.
 
template<bool enabled = is_owning, std::enable_if_t< enabled, bool > = true>
MemberTypeWithConst extract ()
 Extract the underlying container. This will leave the DataBuffer in an unspecified state.
 

Static Public Attributes

static constexpr TParameterType parameter_type
 The type of parameter this buffer represents.
 
static constexpr BufferType buffer_type = buffer_type_param
 The type of the buffer, i.e., in, out, or in_out.
 
static constexpr BufferResizePolicy resize_policy
 The policy specifying in which cases the buffer shall be resized.
 
static constexpr bool is_out_buffer
 true if the buffer is an out or in/out buffer that results will be written to and false otherwise.
 
static constexpr bool is_lib_allocated = allocation == BufferAllocation::lib_allocated
 Indicates whether the buffer is allocated by KaMPIng.
 
static constexpr bool is_owning
 Indicates whether the buffer owns its underlying storage.
 
static constexpr bool is_modifiable
 Indicates whether the underlying storage is modifiable.
 
static constexpr bool is_single_element
 

Detailed Description

template<typename MemberType, typename TParameterType, TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
class kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >

Data buffer used for named parameters.

DataBuffer wraps all buffer storages provided by an std-like container like std::vector or single values. A Container type must provide data(), size() and expose the type definition value_type.

Template Parameters
MemberTypeContainer or data type on which this buffer is based.
TParameterTypeType of the parameter_type_param (required for parameter selection within plugins).
parameter_type_paramParameter type represented by this buffer.
modifiabilitymodifiable if a KaMPIng operation is allowed to modify the underlying container. constant otherwise.
ownershipowning if the buffer should hold the actual container. referencing if only a reference to an existing container should be held.
buffer_type_paramType of buffer, i.e., in_buffer, out_buffer, or in_out_buffer.
buffer_resize_policy_paramPolicy specifying whether (and if so, how) the underlying buffer shall be resized.
allocationlib_allocated if the buffer was allocated by the library,
ValueTyperequested value_type for the buffer. If it does not match the containers value type, compilation fails. By default, this is set to default_value_type_tag and the value_type is inferred from the underlying container, without any checking user_allocated if it was allocated by the user.

Member Typedef Documentation

◆ MemberTypeWithConst

template<typename MemberType , typename TParameterType , TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
using kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::MemberTypeWithConst
Initial value:
std::conditional_t<is_modifiable, MemberType, MemberType const>

The ContainerType as const or non-const depending on modifiability.

◆ MemberTypeWithConstAndRef

template<typename MemberType , typename TParameterType , TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
using kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::MemberTypeWithConstAndRef
Initial value:
std::conditional_t<
ownership == BufferOwnership::owning,
std::conditional_t< is_modifiable, MemberType, MemberType const > MemberTypeWithConst
Definition data_buffer.hpp:368

The ContainerType as const or non-const (see ContainerTypeWithConst) and reference or non-reference depending on ownership.

◆ value_type

template<typename MemberType , typename TParameterType , TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
using kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::value_type
Initial value:
T value_type
The value type of T.
Definition data_buffer.hpp:287

Value type of the buffer.

◆ value_type_with_const

template<typename MemberType , typename TParameterType , TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
using kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::value_type_with_const
Initial value:
std::conditional_t<is_modifiable, value_type, value_type const>

Value type as const or non-const depending on modifiability

Constructor & Destructor Documentation

◆ DataBuffer() [1/2]

template<typename MemberType , typename TParameterType , TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
template<bool enabled = ownership == BufferOwnership::referencing, std::enable_if_t< enabled, bool > = true>
kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::DataBuffer ( MemberTypeWithConst & container)
inline

Constructor for referencing ContainerBasedBuffer.

Parameters
containerContainer holding the actual data.

◆ DataBuffer() [2/2]

template<typename MemberType , typename TParameterType , TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
template<bool enabled = ownership == BufferOwnership::owning, std::enable_if_t< enabled, bool > = true>
kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::DataBuffer ( MemberType container)
inline

Constructor for owning ContainerBasedBuffer.

Parameters
containerContainer holding the actual data.

Member Function Documentation

◆ data() [1/2]

template<typename MemberType , typename TParameterType , TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
value_type_with_const * kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::data ( )
inline

Get access to the underlying container.

Returns
Pointer to the underlying container.

◆ data() [2/2]

template<typename MemberType , typename TParameterType , TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
value_type const * kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::data ( ) const
inline

Get const access to the underlying container.

Returns
Pointer to the underlying container.

◆ extract()

template<typename MemberType , typename TParameterType , TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
template<bool enabled = is_owning, std::enable_if_t< enabled, bool > = true>
MemberTypeWithConst kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::extract ( )
inline

Extract the underlying container. This will leave the DataBuffer in an unspecified state.

Returns
Moves the underlying container out of the DataBuffer.

◆ get() [1/2]

template<typename MemberType , typename TParameterType , TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
Span< value_type_with_const > kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::get ( )
inline

Get access to the underlying storage.

Returns
Span referring to the underlying storage.

◆ get() [2/2]

template<typename MemberType , typename TParameterType , TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
Span< value_type const > kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::get ( ) const
inline

Get read-only access to the underlying storage.

Returns
Span referring the underlying storage.

◆ get_single_element()

template<typename MemberType , typename TParameterType , TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
template<bool enabled = is_single_element, std::enable_if_t< enabled, bool > = true>
value_type const kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::get_single_element ( ) const
inline

Get the single element wrapped by this object.

Returns
The single element wrapped by this object.

◆ resize() [1/2]

template<typename MemberType , typename TParameterType , TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
template<BufferResizePolicy _resize_policy = resize_policy, typename std::enable_if_t< _resize_policy==resize_to_fit, bool > = true>
void kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::resize ( size_t size)
inline

Resizes the underlying container such that it holds exactly size elements of value_type.

This function calls resize on the underlying container.

This takes only part in overload resolution if the resize_policy of the buffer is resize_to_fit.

Parameters
sizeSize the container is resized to.

◆ resize() [2/2]

template<typename MemberType , typename TParameterType , TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
template<BufferResizePolicy _resize_policy = resize_policy, typename std::enable_if_t< _resize_policy==grow_only, bool > = true>
void kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::resize ( size_t size)
inline

Resizes the underlying container such that it holds at least size elements of value_type.

This function calls resize on the underlying container, but only if the requested

Parameters
sizeis larger than the current buffer size. Otherwise, the buffer is left unchanged.

This takes only part in overload resolution if the resize_policy of the buffer is grow_only.

◆ resize_if_requested()

template<typename MemberType , typename TParameterType , TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
template<typename SizeFunc >
void kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::resize_if_requested ( SizeFunc && compute_required_size)
inline

Resizes the underlying container if the buffer the buffer's resize policy allows and resizing is necessary.

Template Parameters
SizeFuncType of the functor which computes the required buffer size.
Parameters
compute_required_sizeFunctor which is used to compute the required buffer size. compute_required_size() is not called if the buffer's resize policy is BufferResizePolicy::no_resize.

◆ underlying() [1/2]

template<typename MemberType , typename TParameterType , TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
template<bool enabled = modifiability == BufferModifiability::modifiable, std::enable_if_t< enabled, bool > = true>
MemberType & kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::underlying ( )
inline

Provides access to the underlying data.

Returns
A reference to the data.

◆ underlying() [2/2]

template<typename MemberType , typename TParameterType , TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
MemberType const & kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::underlying ( ) const
inline

Provides access to the underlying data.

Returns
A reference to the data.

Member Data Documentation

◆ is_modifiable

template<typename MemberType , typename TParameterType , TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
constexpr bool kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::is_modifiable
staticconstexpr
Initial value:
=
modifiability == BufferModifiability::modifiable

Indicates whether the underlying storage is modifiable.

◆ is_out_buffer

template<typename MemberType , typename TParameterType , TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
constexpr bool kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::is_out_buffer
staticconstexpr
Initial value:
=
(buffer_type_param == BufferType::out_buffer || buffer_type_param == BufferType::in_out_buffer)

true if the buffer is an out or in/out buffer that results will be written to and false otherwise.

◆ is_owning

template<typename MemberType , typename TParameterType , TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
constexpr bool kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::is_owning
staticconstexpr
Initial value:
=
ownership == BufferOwnership::owning

Indicates whether the buffer owns its underlying storage.

◆ is_single_element

template<typename MemberType , typename TParameterType , TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
constexpr bool kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::is_single_element
staticconstexpr
Initial value:
=
!has_data_member_v<MemberType>

true if the DataBuffer represents a singe element, false if the DataBuffer represents a container.

◆ parameter_type

template<typename MemberType , typename TParameterType , TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
constexpr TParameterType kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::parameter_type
staticconstexpr
Initial value:
=
parameter_type_param

The type of parameter this buffer represents.

◆ resize_policy

template<typename MemberType , typename TParameterType , TParameterType parameter_type_param, BufferModifiability modifiability, BufferOwnership ownership, BufferType buffer_type_param, BufferResizePolicy buffer_resize_policy_param, BufferAllocation allocation = BufferAllocation::user_allocated, typename ValueType = default_value_type_tag>
constexpr BufferResizePolicy kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::resize_policy
staticconstexpr
Initial value:
=
buffer_resize_policy_param

The policy specifying in which cases the buffer shall be resized.


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