alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
alpaka::concepts::impl::IDataSource Concept Reference

Interface concept for objects describing a multidimensional data source. More...

#include <IDataSource.hpp>

Concept definition

template<typename T>
concept IDataSource = requires(T t, alpaka::Vec<typename T::index_type, T::dim()> vec) {
typename T::value_type;
typename T::index_type;
/* Non const data sources must be assignable.
* You can NOT assign const data sources to non const data sources because this will remove the const-ness.
*/
requires concepts::AssignableFrom<std::decay_t<T>, std::decay_t<T>>;
// only the non-const type is moveable
requires std::movable<std::remove_const_t<T>>;
Check whether the specified data type T_To can be assigned to T_From.
Interface concept for objects describing a multidimensional data source.

The bool operator returns true if the access operator returns valid values.

For example, memory access may be invalid after moving the DataSource.

static_cast<bool>(t);
{ T::dim() } -> std::same_as<uint32_t>;
/* check multi-dimensional access operator
if T has no reference type, the access operator needs to return a copy
`|| requires { typename T::reference; }` is only required, that the statement becomes true in any case
*/
requires (!requires { typename T::reference; } &&
requires { { t[vec] } -> std::same_as<typename T::value_type>;})
|| requires { typename T::reference; };
/* check 1-dimensional access operator
checking for (T::dim() != 1u) disables the access operator requirement for multidimensional
IDataSources */
requires
(T::dim() != 1u) ||
(T::dim() == 1u && !requires { typename T::reference; } &&
requires {{ t[0] } -> std::same_as<typename T::value_type>; })
|| requires { typename T::reference; };
// typically the alignment of the value_type.
{ t.getAlignment() } -> alpaka::concepts::Alignment;
Todo
implement concept alpaka::concepts::Extents and use it as return value
t.getExtents();
Todo
implement concept alpaka::concepts::Pitches and use it as return value
t.getPitches();
}

Detailed Description

Interface concept for objects describing a multidimensional data source.

An object that implements the interface returns a value for a multidimensional index. Therefore, it behaves like multidimensional memory that can only be read. It is not permitted to write a new value to an index position. An IDataSource object has an immutable, fixed multidimensional size. The IDataSource object is not required to reference the storage. It may create or calculate the data instead of reading it from memory.

The immutable extent is required for algorithms such as alpaka::onHost::transform.

Parameters
tObject that implements the IDataSource interface. May or may not have a const modifier.
vecVector with the same number of elements as the dimension of the IDataSource like object. Used to call the access operator.

Member types

  • T::value_type: The element type. May or may not be const.
  • T::index_type: The index type of the pitch.
Note
The access operator [] with an integral as an argument is only available if the dimension is one.

Definition at line 43 of file IDataSource.hpp.