Cabana 0.8.0-dev
 
Loading...
Searching...
No Matches
Cabana::Grid::Halo< MemorySpace > Class Template Reference

#include <Cabana_Grid_Halo.hpp>

Public Types

using memory_space = MemorySpace
 Memory space.
 

Public Member Functions

template<class Pattern, class... ArrayTypes>
 Halo (const Pattern &pattern, const int width, const ArrayTypes &... arrays)
 Constructor.
 
template<class ExecutionSpace, class... ArrayTypes>
void gather (const ExecutionSpace &exec_space, const ArrayTypes &... arrays) const
 Gather data into our ghosts from their owners.
 
template<class ExecutionSpace, class ReduceOp, class... ArrayTypes>
void scatter (const ExecutionSpace &exec_space, const ReduceOp &reduce_op, const ArrayTypes &... arrays) const
 Scatter data from our ghosts to their owners using the given type of reduce operation.
 
template<class Array_t>
MPI_Comm getComm (const Array_t &array) const
 Get the communicator.
 
template<class Array_t, class... ArrayTypes>
MPI_Comm getComm (const Array_t &array, const ArrayTypes &... arrays) const
 Get the communicator and check to make sure all are the same.
 
template<class Array_t>
auto getLocalGrid (const Array_t &array)
 
template<class Array_t, class... ArrayTypes>
auto getLocalGrid (const Array_t &array, const ArrayTypes &... arrays)
 
template<class DecompositionTag, std::size_t NumSpaceDim, class... ArrayTypes>
void buildCommData (DecompositionTag decomposition_tag, const int width, const std::array< int, NumSpaceDim > &nid, std::vector< Kokkos::View< char *, memory_space > > &buffers, std::vector< Kokkos::View< int **, memory_space > > &steering, const ArrayTypes &... arrays)
 Build communication data.
 
template<std::size_t NumArray>
void buildSteeringVector (const std::array< IndexSpace< 4 >, NumArray > &spaces, const std::array< std::size_t, NumArray > &value_byte_sizes, const int buffer_bytes, const int buffer_num_element, std::vector< Kokkos::View< int **, memory_space > > &steering)
 Build 3d steering vector.
 
template<std::size_t NumArray>
void buildSteeringVector (const std::array< IndexSpace< 3 >, NumArray > &spaces, const std::array< std::size_t, NumArray > &value_byte_sizes, const int buffer_bytes, const int buffer_num_element, std::vector< Kokkos::View< int **, memory_space > > &steering)
 Build 2d steering vector.
 
template<class ExecutionSpace, class... ArrayViews>
void packBuffer (const ExecutionSpace &exec_space, const Kokkos::View< char *, memory_space > &buffer, const Kokkos::View< int **, memory_space > &steering, ArrayViews... array_views) const
 Pack arrays into a buffer.
 
template<class ExecutionSpace, class ReduceOp, class... ArrayViews>
void unpackBuffer (const ReduceOp &reduce_op, const ExecutionSpace &exec_space, const Kokkos::View< char *, memory_space > &buffer, const Kokkos::View< int **, memory_space > &steering, ArrayViews... array_views) const
 Unpack arrays from a buffer.
 

Static Public Member Functions

template<class ArrayView>
static KOKKOS_INLINE_FUNCTION std::enable_if_t< 4==ArrayView::rank, void > packElement (const Kokkos::View< char *, memory_space > &buffer, const Kokkos::View< int **, memory_space > &steering, const int element_idx, const ArrayView &array_view)
 
template<class ArrayView>
static KOKKOS_INLINE_FUNCTION std::enable_if_t< 3==ArrayView::rank, void > packElement (const Kokkos::View< char *, memory_space > &buffer, const Kokkos::View< int **, memory_space > &steering, const int element_idx, const ArrayView &array_view)
 
template<class... ArrayViews>
static KOKKOS_INLINE_FUNCTION void packArray (const Kokkos::View< char *, memory_space > &buffer, const Kokkos::View< int **, memory_space > &steering, const int element_idx, const std::integral_constant< std::size_t, 0 >, const Cabana::ParameterPack< ArrayViews... > &array_views)
 Pack an array into a buffer.
 
template<std::size_t N, class... ArrayViews>
static KOKKOS_INLINE_FUNCTION void packArray (const Kokkos::View< char *, memory_space > &buffer, const Kokkos::View< int **, memory_space > &steering, const int element_idx, const std::integral_constant< std::size_t, N >, const Cabana::ParameterPack< ArrayViews... > &array_views)
 Pack an array into a buffer.
 
template<class T>
static KOKKOS_INLINE_FUNCTION void unpackOp (ScatterReduce::Sum, const T &buffer_val, T &array_val)
 Reduce an element into the buffer. Sum reduction.
 
template<class T>
static KOKKOS_INLINE_FUNCTION void unpackOp (ScatterReduce::Min, const T &buffer_val, T &array_val)
 Reduce an element into the buffer. Min reduction.
 
template<class T>
static KOKKOS_INLINE_FUNCTION void unpackOp (ScatterReduce::Max, const T &buffer_val, T &array_val)
 Reduce an element into the buffer. Max reduction.
 
template<class T>
static KOKKOS_INLINE_FUNCTION void unpackOp (ScatterReduce::Replace, const T &buffer_val, T &array_val)
 Reduce an element into the buffer. Replace reduction.
 
template<class ReduceOp, class ArrayView>
static KOKKOS_INLINE_FUNCTION std::enable_if_t< 4==ArrayView::rank, void > unpackElement (const ReduceOp &reduce_op, const Kokkos::View< char *, memory_space > &buffer, const Kokkos::View< int **, memory_space > &steering, const int element_idx, const ArrayView &array_view)
 
template<class ReduceOp, class ArrayView>
static KOKKOS_INLINE_FUNCTION std::enable_if_t< 3==ArrayView::rank, void > unpackElement (const ReduceOp &reduce_op, const Kokkos::View< char *, memory_space > &buffer, const Kokkos::View< int **, memory_space > &steering, const int element_idx, const ArrayView &array_view)
 
template<class ReduceOp, class... ArrayViews>
static KOKKOS_INLINE_FUNCTION void unpackArray (const ReduceOp &reduce_op, const Kokkos::View< char *, memory_space > &buffer, const Kokkos::View< int **, memory_space > &steering, const int element_idx, const std::integral_constant< std::size_t, 0 >, const Cabana::ParameterPack< ArrayViews... > &array_views)
 Unpack an array from a buffer.
 
template<class ReduceOp, std::size_t N, class... ArrayViews>
static KOKKOS_INLINE_FUNCTION void unpackArray (const ReduceOp reduce_op, const Kokkos::View< char *, memory_space > &buffer, const Kokkos::View< int **, memory_space > &steering, const int element_idx, const std::integral_constant< std::size_t, N >, const Cabana::ParameterPack< ArrayViews... > &array_views)
 Unpack an array from a buffer.
 

Detailed Description

template<class MemorySpace>
class Cabana::Grid::Halo< MemorySpace >

General multiple array halo communication plan for migrating shared data between blocks. Arrays may be defined on different entity types and have different data types.

The halo operates on an arbitrary set of arrays. Each of these arrays must be defined on the same local grid meaning they that share the same communicator and halo size. The arrays must also reside in the same memory space. These requirements are checked at construction.

Constructor & Destructor Documentation

◆ Halo()

template<class MemorySpace>
template<class Pattern, class... ArrayTypes>
Cabana::Grid::Halo< MemorySpace >::Halo ( const Pattern & pattern,
const int width,
const ArrayTypes &... arrays )
inline

Constructor.

Template Parameters
Thearrays types to construct the halo for.
Parameters
patternThe halo pattern to use for halo communication.
widthHalo cell width. Must be less than or equal to the halo width of the block.
arraysThe arrays to build the halo for. These arrays must be provided in the same order

Member Function Documentation

◆ gather()

template<class MemorySpace>
template<class ExecutionSpace, class... ArrayTypes>
void Cabana::Grid::Halo< MemorySpace >::gather ( const ExecutionSpace & exec_space,
const ArrayTypes &... arrays ) const
inline

Gather data into our ghosts from their owners.

Parameters
exec_spaceThe execution space to use for pack/unpack.
arraysThe arrays to gather. NOTE: These arrays must be given in the same order as in the constructor. These could technically be different arrays, they just need to have the same layouts and data types as the input arrays.

◆ getLocalGrid() [1/2]

template<class MemorySpace>
template<class Array_t>
auto Cabana::Grid::Halo< MemorySpace >::getLocalGrid ( const Array_t & array)
inline

Get the local grid from the arrays. Check that the grids have the same halo size.

◆ getLocalGrid() [2/2]

template<class MemorySpace>
template<class Array_t, class... ArrayTypes>
auto Cabana::Grid::Halo< MemorySpace >::getLocalGrid ( const Array_t & array,
const ArrayTypes &... arrays )
inline

Get the local grid from the arrays. Check that the grids have the same halo size.

◆ packElement() [1/2]

template<class MemorySpace>
template<class ArrayView>
static KOKKOS_INLINE_FUNCTION std::enable_if_t< 4==ArrayView::rank, void > Cabana::Grid::Halo< MemorySpace >::packElement ( const Kokkos::View< char *, memory_space > & buffer,
const Kokkos::View< int **, memory_space > & steering,
const int element_idx,
const ArrayView & array_view )
inlinestatic

Pack an element into the buffer. Pack by bytes to avoid casting across alignment boundaries.

◆ packElement() [2/2]

template<class MemorySpace>
template<class ArrayView>
static KOKKOS_INLINE_FUNCTION std::enable_if_t< 3==ArrayView::rank, void > Cabana::Grid::Halo< MemorySpace >::packElement ( const Kokkos::View< char *, memory_space > & buffer,
const Kokkos::View< int **, memory_space > & steering,
const int element_idx,
const ArrayView & array_view )
inlinestatic

Pack an element into the buffer. Pack by bytes to avoid casting across alignment boundaries.

◆ scatter()

template<class MemorySpace>
template<class ExecutionSpace, class ReduceOp, class... ArrayTypes>
void Cabana::Grid::Halo< MemorySpace >::scatter ( const ExecutionSpace & exec_space,
const ReduceOp & reduce_op,
const ArrayTypes &... arrays ) const
inline

Scatter data from our ghosts to their owners using the given type of reduce operation.

Parameters
reduce_opThe functor used to reduce the results.
exec_spaceThe execution space to use for pack/unpack.
arraysThe arrays to scatter.

◆ unpackElement() [1/2]

template<class MemorySpace>
template<class ReduceOp, class ArrayView>
static KOKKOS_INLINE_FUNCTION std::enable_if_t< 4==ArrayView::rank, void > Cabana::Grid::Halo< MemorySpace >::unpackElement ( const ReduceOp & reduce_op,
const Kokkos::View< char *, memory_space > & buffer,
const Kokkos::View< int **, memory_space > & steering,
const int element_idx,
const ArrayView & array_view )
inlinestatic

Unpack an element from the buffer. Unpack by bytes to avoid casting across alignment boundaries.

◆ unpackElement() [2/2]

template<class MemorySpace>
template<class ReduceOp, class ArrayView>
static KOKKOS_INLINE_FUNCTION std::enable_if_t< 3==ArrayView::rank, void > Cabana::Grid::Halo< MemorySpace >::unpackElement ( const ReduceOp & reduce_op,
const Kokkos::View< char *, memory_space > & buffer,
const Kokkos::View< int **, memory_space > & steering,
const int element_idx,
const ArrayView & array_view )
inlinestatic

Unpack an element from the buffer. Unpack by bytes to avoid casting across alignment boundaries.


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