Handling non-contiguous views

MPI

template<KokkosView View>
struct MpiArgs

A wrapper type describing a Kokkos view for the MPI communication backend.

View view

A reference to the Kokkos view to communicate.

MPI_Datatype datatype

The corresponding MPI data type of the Kokkos view.

int count

The number of elements in the Kokkos view.

template<KokkosView View>
struct DeepCopy

Use Kokkos::deep_copy to translate between non-contiguous and contiguous data.

using non_const_packed_view_type = Kokkos::View<typename View::non_const_data_type, Kokkos::LayoutLeft, typename View::memory_space>
using args_type = MpiArgs<non_const_packed_view_type>
template<KokkosExecutionSpace ExecSpace>
static auto allocate_packed_for(const ExecSpace &space, const std::string &label, const View &src) -> args_type

Allocates contiguous Kokkos view large enough to hold all the data in src.

Parameters:
  • space – The execution space to operate in.

  • label – Identification label for the allocation.

  • src – A Kokkos::View produced by allocate_packed_for.

Returns:

Return an MpiArgs object suitable to hold packed data for src.

template<KokkosExecutionSpace ExecSpace>
static auto pack(const ExecSpace &space, const View &src) -> args_type

Uses allocate_packed_for and Kokkos::deep_copy to pack the data in src.

Parameters:
  • space – The execution space to operate in.

  • src – A Kokkos view produced by allocate_packed_for.

Returns:

A packed Kokkos view of the data in src.

template<KokkosExecutionSpace ExecSpace>
static auto unpack_into(const ExecSpace &space, const View &dst, const non_const_packed_view_type &src) -> void

Uses Kokkos::deep_copy to fill dst with an unpacked view of the data in src.

Parameters:
  • space – The execution space to operate in.

  • src – A Kokkos view produced by allocate_packed_for.

  • dst – A corresponding unpacked Kokkos view.

template<KokkosView View>
struct MpiDatatype

Use the MPI data type engine to handle non-contiguous data.

using non_const_packed_view_type = View
using args_type = MpiArgs<non_const_packed_view_type>
template<KokkosExecutionSpace ExecSpace>
static auto allocate_packed_for(const ExecSpace &space, const std::string &label, const View &src) -> args_type

Does not actually allocate. Constructs an MpiArgs describing the view and returns it:

  • the src;

  • an MPI_Datatype describing the possibly-non-contiguous data in that Kokkos::View, and;

  • a count equal to 1.

Parameters:
  • space – The execution space to operate in.

  • label – Identification label for the allocation.

  • src – A Kokkos view produced by allocate_packed_for.

Returns:

Return an MpiArgs suitable to hold packed data for src.

template<KokkosExecutionSpace ExecSpace>
static auto pack(const ExecSpace &space, const View &src) -> args_type

No-op, rely on MPI’s data type engine.

Parameters:
  • space – The execution space to operate in.

  • src – A Kokkos view produced by allocate_packed_for.

Returns:

A packed Kokkos view of the data in src.

template<KokkosExecutionSpace ExecSpace>
static auto unpack_into(const ExecSpace &space, const View &dst, const non_const_packed_view_type &src) -> void

No-op, rely on MPI’s data type engine.

Parameters:
  • space – The execution space to operate in.

  • src – A Kokkos view produced by allocate_packed_for.

  • dst – A corresponding unpacked Kokkos view.