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

#include <Cabana_Grid_HaloBase.hpp>

Inheritance diagram for Cabana::Grid::HaloBase< MemorySpace >:

Public Types

using memory_space = MemorySpace
 Memory space.
 

Public Member Functions

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.
 

Protected Member Functions

template<class Pattern, class... ArrayTypes>
 HaloBase (const Pattern &pattern, const int width, const ArrayTypes &... arrays)
 Constructor.
 

Protected Attributes

std::vector< int > _neighbor_ranks
 The ranks we will send/receive from.
 
std::vector< int > _send_tags
 The tag we use for sending to each neighbor.
 
std::vector< int > _receive_tags
 The tag we use for receiving from each neighbor.
 
std::vector< Kokkos::View< char *, memory_space > > _owned_buffers
 For each neighbor, send/receive buffers for data we own.
 
std::vector< Kokkos::View< char *, memory_space > > _ghosted_buffers
 For each neighbor, send/receive buffers for data we ghost.
 
std::vector< Kokkos::View< int **, memory_space > > _owned_steering
 For each neighbor, steering vector for the owned buffer.
 
std::vector< Kokkos::View< int **, memory_space > > _ghosted_steering
 For each neighbor, steering vector for the ghosted buffer.
 

Detailed Description

template<class MemorySpace>
class Cabana::Grid::HaloBase< 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

◆ HaloBase()

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

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

◆ getLocalGrid() [1/2]

template<class MemorySpace>
template<class Array_t>
auto Cabana::Grid::HaloBase< 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::HaloBase< 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::HaloBase< 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::HaloBase< 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.

◆ 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::HaloBase< 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::HaloBase< 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: