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

Grid Halo class. Variant that uses vanilla MPI as the communication backend. More...

#include <Cabana_Grid_Halo_Mpi.hpp>

Inheritance diagram for Cabana::Grid::Halo< MemorySpace, Mpi >:
Collaboration diagram for Cabana::Grid::Halo< MemorySpace, Mpi >:

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.
 
- Public Member Functions inherited from Cabana::Grid::HaloBase< MemorySpace >
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.
 

Additional Inherited Members

- Public Types inherited from Cabana::Grid::HaloBase< MemorySpace >
using memory_space = MemorySpace
 Memory space.
 
- Static Public Member Functions inherited from Cabana::Grid::HaloBase< MemorySpace >
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 inherited from Cabana::Grid::HaloBase< MemorySpace >
template<class Pattern, class... ArrayTypes>
 HaloBase (const Pattern &pattern, const int width, const ArrayTypes &... arrays)
 Constructor.
 
- Protected Attributes inherited from Cabana::Grid::HaloBase< MemorySpace >
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::Halo< MemorySpace, Mpi >

Grid Halo class. Variant that uses vanilla MPI as the communication backend.

Constructor & Destructor Documentation

◆ Halo()

template<class MemorySpace>
template<class Pattern, class... ArrayTypes>
Cabana::Grid::Halo< MemorySpace, Mpi >::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, Mpi >::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.

◆ scatter()

template<class MemorySpace>
template<class ExecutionSpace, class ReduceOp, class... ArrayTypes>
void Cabana::Grid::Halo< MemorySpace, Mpi >::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.

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