Tpetra parallel linear algebra  Version of the Day
Public Types | Public Member Functions | Static Public Attributes | List of all members
Tpetra::Experimental::LittleBlock< Scalar, LO > Class Template Reference

Nonowning view of a square dense block in a block matrix. More...

#include <Tpetra_Experimental_BlockView.hpp>

Public Types

typedef Kokkos::LayoutRight array_layout
 Data layout (in the same sense as Kokkos::View). More...
 

Public Member Functions

 LittleBlock (Scalar *const A, const LO blockSize, const LO strideX, const LO strideY)
 Constructor. More...
 
template<class T >
 LittleBlock (T *const A, const LO blockSize, const LO strideX, const LO strideY, typename std::enable_if< !std::is_same< Scalar, T >::value &&std::is_convertible< Scalar, T >::value &&sizeof(Scalar)==sizeof(T), int * >::type ignoreMe=NULL)
 Constructor that takes an impl_scalar_type pointer. More...
 
LO getBlockSize () const
 The block size (number of rows, and number of columns). More...
 
LO dimension_0 () const
 Number of rows in the block. More...
 
LO dimension_1 () const
 Number of columns in the block. More...
 
LO size () const
 Number of rows times number of columns. More...
 
Scalar * ptr_on_device () const
 Pointer to the block's entries, as Scalar*. More...
 
Scalar * getRawPtr () const
 Pointer to the block's entries, as Scalar*. More...
 
impl_scalar_type & operator() (const LO i, const LO j) const
 Reference to entry (i,j) of the block. More...
 

Static Public Attributes

static const int rank = 2
 Number of dimensions. More...
 

Detailed Description

template<class Scalar, class LO = int>
class Tpetra::Experimental::LittleBlock< Scalar, LO >

Nonowning view of a square dense block in a block matrix.

Template Parameters
ScalarThe type of entries in the block.
LOThe type of local indices. See the documentation of the first template parameter of Map for requirements.

"Little" means local (not distributed over multiple MPI processes; stored to maximize locality) and small (think 3x3, not 1000x1000).

The Scalar template parameter may be const or nonconst. This is one reason why instance methods below that take a LittleBlock accept it as a template parameter: that lets you add a const LittleBlock (e.g., LittleBlock<const double, int>) to a nonconst LittleBlock (e.g., LittleBlock<double, int>).

Definition at line 1121 of file Tpetra_Experimental_BlockView.hpp.

Member Typedef Documentation

template<class Scalar, class LO = int>
typedef Kokkos::LayoutRight Tpetra::Experimental::LittleBlock< Scalar, LO >::array_layout

Data layout (in the same sense as Kokkos::View).

Definition at line 1134 of file Tpetra_Experimental_BlockView.hpp.

Constructor & Destructor Documentation

template<class Scalar, class LO = int>
Tpetra::Experimental::LittleBlock< Scalar, LO >::LittleBlock ( Scalar *const  A,
const LO  blockSize,
const LO  strideX,
const LO  strideY 
)
inline

Constructor.

Parameters
A[in] Pointer to the block's entries
blockSize[in] Dimension of the block (all blocks are square)
strideX[in] Stride between consecutive entries in a column
strideY[in] Stride between consecutive entries in a row

Definition at line 1141 of file Tpetra_Experimental_BlockView.hpp.

template<class Scalar, class LO = int>
template<class T >
Tpetra::Experimental::LittleBlock< Scalar, LO >::LittleBlock ( T *const  A,
const LO  blockSize,
const LO  strideX,
const LO  strideY,
typename std::enable_if< !std::is_same< Scalar, T >::value &&std::is_convertible< Scalar, T >::value &&sizeof(Scalar)==sizeof(T), int * >::type  ignoreMe = NULL 
)
inline

Constructor that takes an impl_scalar_type pointer.

Parameters
A[in] Pointer to the block's entries, as impl_scalar_type* rather than Scalar*
blockSize[in] Dimension of the block (all blocks are square)
strideX[in] Stride between consecutive entries in a column
strideY[in] Stride between consecutive entries in a row

While this constructor is templated on a type T, the intent is that T == impl_scalar_type. (We must template on T rather than using impl_scalar_type directly, because of how std::enable_if works.) The long, complicated std::enable_if expression ensures that this constructor only exists if Scalar differs from impl_scalar_type, but the two types are mutually compatible and have the same size. (They must be bitwise compatible, so that reinterpret_cast makes sense between them.)

Definition at line 1169 of file Tpetra_Experimental_BlockView.hpp.

Member Function Documentation

template<class Scalar, class LO = int>
LO Tpetra::Experimental::LittleBlock< Scalar, LO >::getBlockSize ( ) const
inline

The block size (number of rows, and number of columns).

Definition at line 1185 of file Tpetra_Experimental_BlockView.hpp.

template<class Scalar, class LO = int>
LO Tpetra::Experimental::LittleBlock< Scalar, LO >::dimension_0 ( ) const
inline

Number of rows in the block.

Definition at line 1190 of file Tpetra_Experimental_BlockView.hpp.

template<class Scalar, class LO = int>
LO Tpetra::Experimental::LittleBlock< Scalar, LO >::dimension_1 ( ) const
inline

Number of columns in the block.

Definition at line 1195 of file Tpetra_Experimental_BlockView.hpp.

template<class Scalar, class LO = int>
LO Tpetra::Experimental::LittleBlock< Scalar, LO >::size ( ) const
inline

Number of rows times number of columns.

Definition at line 1200 of file Tpetra_Experimental_BlockView.hpp.

template<class Scalar, class LO = int>
Scalar* Tpetra::Experimental::LittleBlock< Scalar, LO >::ptr_on_device ( ) const
inline

Pointer to the block's entries, as Scalar*.

Definition at line 1211 of file Tpetra_Experimental_BlockView.hpp.

template<class Scalar, class LO = int>
Scalar* Tpetra::Experimental::LittleBlock< Scalar, LO >::getRawPtr ( ) const
inline

Pointer to the block's entries, as Scalar*.

Definition at line 1216 of file Tpetra_Experimental_BlockView.hpp.

template<class Scalar, class LO = int>
impl_scalar_type& Tpetra::Experimental::LittleBlock< Scalar, LO >::operator() ( const LO  i,
const LO  j 
) const
inline

Reference to entry (i,j) of the block.

Note
To Tpetra developers: This is returned as impl_scalar_type and not as Scalar, in order to avoid a lot of reinterpret_cast calls in the inner loop of the sparse matrix-vector multiply kernel of Tpetra::Experimental::BlockCrsMatrix. Any pair of types impl_scalar_type, Scalar used here should always be convertible in either direction, so the return type should not pose any issues in practice.

Definition at line 1230 of file Tpetra_Experimental_BlockView.hpp.

Member Data Documentation

template<class Scalar, class LO = int>
const int Tpetra::Experimental::LittleBlock< Scalar, LO >::rank = 2
static

Number of dimensions.

Definition at line 1131 of file Tpetra_Experimental_BlockView.hpp.


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