Concepts and Traits

Concepts

template<typename T>
concept KokkosView

Specifies that a type T is a Kokkos::View object.

template<typename T>
concept KokkosExecutionSpace

Specifies that a type T is a Kokkos::ExecutionSpace.

template<typename T>
concept CommunicationSpace

Specifies that a type T is a KokkosComm communication backend.

Traits

General traits

template<KokkosView View>
struct Traits<View>

A struct that can be specialized to implement custom behavior for a particular Kokkos view.

using non_const_packed_view_type = Kokkos::View<typename View::non_const_data_type, typename View::array_layout, typename View::memory_space>
using packed_view_type = Kokkos::View<typename View::data_type, typename View::array_layout, typename View::memory_space>
template<KokkosView View>
static auto data_handle(const View &v) -> View::pointer_type
Template Parameters:

View – The type of the Kokkos view.

Parameters:

v – The Kokkos view to query.

Returns:

The pointer to the underlying data allocation.

template<KokkosView View>
static auto span(const View &v) -> size_t
Template Parameters:

View – The type of the Kokkos view.

Parameters:

v – The Kokkos view to query.

Returns:

The number of bytes between the beginning of the first byte and the end of the last byte of data in v.

For example, if View was an std::vector<int16_t> of size 3, it would be 6. If the View is non-contiguous, the result includes any “holes” in v.

template<KokkosView View>
static auto is_contiguous(const View &v) -> bool

Checks if a view is contiguous.

Template Parameters:

View – The type of the Kokkos view.

Parameters:

v – The Kokkos view to query.

Returns:

True if, and only if, the data in v is contiguous.

template<KokkosView View>
static constexpr auto rank() -> size_t
Template Parameters:

View – The type of the Kokkos view.

Returns:

The rank (number of dimensions) of the View type.

template<KokkosView View>
static constexpr auto extent(const View &v, const int i) -> size_t
Template Parameters:

View – The type of the Kokkos view.

Parameters:
  • v – The Kokkos view to query.

  • i – The index of the dimension. Must be smaller than the rank of the view.

Returns:

The extent of the specified dimension.

template<KokkosView View>
static constexpr auto stride(const View &v, const int i) -> size_t
Template Parameters:

View – The type of the Kokkos view.

Parameters:
  • v – The Kokkos view to query.

  • i – The index of the dimension. Must be smaller than the rank of the view.

Returns:

The stride of the specified dimension.

template<KokkosView View>
static constexpr auto is_reference_counted() -> bool
Template Parameters:

View – The type of the Kokkos view.

Returns:

True if, and only if, the type is subject to reference counting (e.g., always true for Kokkos::View objects).

This is used to determine if asynchronous MPI operations may need to extend the lifetime of this type when it’s used as an argument.

Packing Traits

Strategies for handling non-contiguous views.

template<typename T>
struct PackTraits<T>

A common packing-related struct that can be specialized to implement custom behavior for a particular Kokkos view.

using packer_type = Impl::Packer::DeepCopy<View>

The packer to use for this View type.