KaMPIng 0.1.0
(Near) zero-overhead C++ MPI bindings.
|
Data buffer used for named parameters. More...
#include <data_buffer.hpp>
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 const * | data () const |
Get const access to the underlying container. | |
value_type_with_const * | data () |
Get access to the underlying container. | |
Span< value_type const > | get () const |
Get read-only access to the underlying storage. | |
Span< value_type_with_const > | get () |
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 const & | underlying () const |
Provides access to the underlying data. | |
template<bool enabled = modifiability == BufferModifiability::modifiable, std::enable_if_t< enabled, bool > = true> | |
MemberType & | underlying () |
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 |
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
.
MemberType | Container or data type on which this buffer is based. |
TParameterType | Type of the parameter_type_param (required for parameter selection within plugins). |
parameter_type_param | Parameter type represented by this buffer. |
modifiability | modifiable if a KaMPIng operation is allowed to modify the underlying container. constant otherwise. |
ownership | owning if the buffer should hold the actual container. referencing if only a reference to an existing container should be held. |
buffer_type_param | Type of buffer, i.e., in_buffer , out_buffer , or in_out_buffer . |
buffer_resize_policy_param | Policy specifying whether (and if so, how) the underlying buffer shall be resized. |
allocation | lib_allocated if the buffer was allocated by the library, |
ValueType | requested 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. |
using kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::MemberTypeWithConst |
The ContainerType as const or non-const depending on modifiability.
using kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::MemberTypeWithConstAndRef |
The ContainerType as const or non-const (see ContainerTypeWithConst) and reference or non-reference depending on ownership.
using kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::value_type |
Value type of the buffer.
using kamping::internal::DataBuffer< MemberType, TParameterType, parameter_type_param, modifiability, ownership, buffer_type_param, buffer_resize_policy_param, allocation, ValueType >::value_type_with_const |
Value type as const or non-const depending on modifiability
|
inline |
Constructor for referencing ContainerBasedBuffer.
container | Container holding the actual data. |
|
inline |
Constructor for owning ContainerBasedBuffer.
container | Container holding the actual data. |
Get access to the underlying container.
|
inline |
Get const access to the underlying container.
|
inline |
Extract the underlying container. This will leave the DataBuffer in an unspecified state.
|
inline |
Get access to the underlying storage.
|
inline |
Get read-only access to the underlying storage.
|
inline |
Get the single element wrapped by this object.
|
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
.
size | Size the container is resized to. |
|
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
size | is 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
.
|
inline |
Resizes the underlying container if the buffer the buffer's resize policy allows and resizing is necessary.
SizeFunc | Type of the functor which computes the required buffer size. |
compute_required_size | Functor 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. |
|
inline |
Provides access to the underlying data.
|
inline |
Provides access to the underlying data.
|
staticconstexpr |
Indicates whether the underlying storage is modifiable.
|
staticconstexpr |
true
if the buffer is an out or in/out buffer that results will be written to and false
otherwise.
|
staticconstexpr |
Indicates whether the buffer owns its underlying storage.
|
staticconstexpr |
true
if the DataBuffer represents a singe element, false
if the DataBuffer represents a container.
|
staticconstexpr |
The type of parameter this buffer represents.
|
staticconstexpr |
The policy specifying in which cases the buffer shall be resized.