LvArray
Public Types | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE > Class Template Reference

This class serves to provide a "view" of a multidimensional array. More...

#include <ArrayView.hpp>

Public Types

using ValueType = T
 The type of the values in the ArrayView.
 
using IndexType = INDEX_TYPE
 The integer type used for indexing.
 
using ViewTypeConst = ArrayView< std::remove_const_t< T > const, NDIM, USD, INDEX_TYPE, BUFFER_TYPE >
 The type when the data type is const.
 
using NestedViewType = ArrayView< std::remove_reference_t< typeManipulation::NestedViewType< T > >, NDIM, USD, INDEX_TYPE, BUFFER_TYPE >
 The type when all inner array classes are converted to const views.
 
using NestedViewTypeConst = ArrayView< std::remove_reference_t< typeManipulation::NestedViewTypeConst< T > >, NDIM, USD, INDEX_TYPE, BUFFER_TYPE >
 The type when all inner array classes are converted to const views and the inner most view's values are also const.
 
using SliceType = ArraySlice< T, NDIM, USD, INDEX_TYPE > const
 The type of the ArrayView when converted to an ArraySlice.
 
using SliceTypeConst = ArraySlice< T const, NDIM, USD, INDEX_TYPE > const
 The type of the ArrayView when converted to an immutable ArraySlice.
 
using value_type = T
 The type of the values in the ArrayView, here for stl compatability.
 
using size_type = INDEX_TYPE
 The integer type used for indexing, here for stl compatability.
 

Public Member Functions

Constructors, destructor and assignment operators.
 ArrayView ()=default
 A constructor to create an uninitialized ArrayView. More...
 
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE constexpr ArrayView (ArrayView const &source) noexcept
 Copy Constructor. More...
 
template<typename U , typename = std::enable_if_t< !std::is_same< T, U >::value >>
LVARRAY_HOST_DEVICE constexpr ArrayView (ArrayView< U, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > const &source)
 Construct a new ArrayView from an ArrayView with a different type. More...
 
 ArrayView (ArrayView &&source)=default
 Move constructor, creates a shallow copy and invalidates the source. More...
 
LVARRAY_HOST_DEVICE constexpr ArrayView (typeManipulation::CArray< INDEX_TYPE, NDIM > const &dims, typeManipulation::CArray< INDEX_TYPE, NDIM > const &strides, int const singleParameterResizeIndex, BUFFER_TYPE< T > const &buffer)
 Construct a new ArrayView from existing components. More...
 
 ~ArrayView ()=default
 The default destructor.
 
LVARRAY_HOST_DEVICE LVARRAY_INTEL_CONSTEXPR ArrayViewoperator= (ArrayView &&rhs)
 Move assignment operator, creates a shallow copy and invalidates the source. More...
 
LVARRAY_INTEL_CONSTEXPR ArrayViewoperator= (ArrayView const &rhs) noexcept
 Copy assignment operator, creates a shallow copy. More...
 
ArrayView and ArraySlice creation methods and user defined conversions.
LVARRAY_HOST_DEVICE constexpr ArrayView toView () const &
 
LVARRAY_HOST_DEVICE constexpr ViewTypeConst toViewConst () const &
 
LVARRAY_HOST_DEVICE constexpr NestedViewType toNestedView () const &
 
LVARRAY_HOST_DEVICE constexpr NestedViewTypeConst toNestedViewConst () const &
 
LVARRAY_HOST_DEVICE constexpr ArraySlice< T, NDIM, USD, INDEX_TYPE > toSlice () const &noexcept
 
LVARRAY_HOST_DEVICE constexpr ArraySlice< T, NDIM, USD, INDEX_TYPE > toSlice () const &&noexcept=delete
 Overload for rvalues that is deleted. More...
 
LVARRAY_HOST_DEVICE constexpr ArraySlice< T const, NDIM, USD, INDEX_TYPE > toSliceConst () const &noexcept
 
LVARRAY_HOST_DEVICE constexpr ArraySlice< T const, NDIM, USD, INDEX_TYPE > toSliceConst () const &&noexcept=delete
 Overload for rvalues that is deleted. More...
 
template<typename _T = T>
LVARRAY_HOST_DEVICE constexpr operator std::enable_if_t< !std::is_const< _T >::value, ArrayView< T const, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > > () const noexcept
 A user defined conversion operator (UDC) to an ArrayView< T const, ... >. More...
 
LVARRAY_HOST_DEVICE constexpr operator ArraySlice< T, NDIM, USD, INDEX_TYPE > () const &noexcept
 
LVARRAY_HOST_DEVICE constexpr operator ArraySlice< T, NDIM, USD, INDEX_TYPE > () const &&noexcept=delete
 Overload for rvalues that is deleted. More...
 
template<typename _T = T>
LVARRAY_HOST_DEVICE constexpr operator std::enable_if_t< !std::is_const< _T >::value, ArraySlice< T const, NDIM, USD, INDEX_TYPE > const > () const &noexcept
 
template<typename _T = T>
LVARRAY_HOST_DEVICE constexpr operator std::enable_if_t< !std::is_const< _T >::value, ArraySlice< T const, NDIM, USD, INDEX_TYPE > const > () const &&noexcept=delete
 Overload for rvalues that is deleted. More...
 
Attribute querying methods
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE size () const noexcept
 
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK INDEX_TYPE size (int const dim) const noexcept
 
LVARRAY_HOST_DEVICE constexpr bool empty () const
 
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE capacity () const
 
LVARRAY_HOST_DEVICE constexpr int getSingleParameterResizeIndex () const
 
template<typename ... INDICES>
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK INDEX_TYPE linearIndex (INDICES const ... indices) const
 
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE const * dims () const noexcept
 
LVARRAY_HOST_DEVICE constexpr typeManipulation::CArray< INDEX_TYPE, NDIM > const & dimsArray () const
 
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE const * strides () const noexcept
 
LVARRAY_HOST_DEVICE constexpr typeManipulation::CArray< INDEX_TYPE, NDIM > const & stridesArray () const
 
LVARRAY_HOST_DEVICE constexpr BUFFER_TYPE< T > const & dataBuffer () const
 
Methods that provide access to the data.
template<int _NDIM = NDIM>
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK std::enable_if_t<(_NDIM > 1), ArraySlice< T, NDIM - 1, USD - 1, INDEX_TYPE > > operator[] (INDEX_TYPE const index) const &noexcept
 
template<int _NDIM = NDIM>
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK std::enable_if_t<(_NDIM > 1), ArraySlice< T, NDIM - 1, USD - 1, INDEX_TYPE > > operator[] (INDEX_TYPE const index) const &&noexcept=delete
 Overload for rvalues that is deleted. More...
 
template<int _NDIM = NDIM>
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK std::enable_if_t< _NDIM==1, T &> operator[] (INDEX_TYPE const index) const &noexcept
 
template<typename ... INDICES>
LVARRAY_HOST_DEVICE constexpr T & operator() (INDICES... indices) const
 
LVARRAY_HOST_DEVICE constexpr T * data () const
 
LVARRAY_HOST_DEVICE constexpr T * begin () const
 
LVARRAY_HOST_DEVICE constexpr T * end () const
 
T & front () const
 
T & back () const
 
Methods that set all the values
template<typename POLICY >
DISABLE_HD_WARNING void setValues (T const &value) const
 Set all entries in the array to value. More...
 
void zero () const
 Use memset to set all the values in the array to 0. More...
 
template<typename POLICY >
void setValues (ArrayView< T const, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > const &rhs) const
 Set entries to values from another compatible ArrayView. More...
 
Methods dealing with memory spaces
MemorySpace getPreviousSpace () const
 
void registerTouch (MemorySpace const space) const
 Touch the memory in space. More...
 
void move (MemorySpace const space, bool const touch=true) const
 Move the Array to the given execution space, optionally touching it. More...
 

Static Public Attributes

static constexpr int NDIM = NDIM_TPARAM
 The number of dimensions.
 
static constexpr int USD = USD_TPARAM
 The unit stride dimension.
 

Protected Member Functions

DISABLE_HD_WARNING LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK ArrayView (bool) noexcept
 Protected constructor to be used by the Array class. More...
 
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE constexpr ArrayView (BUFFER_TYPE< T > &&buffer) noexcept
 Protected constructor to be used by the Array class. More...
 

Protected Attributes

typeManipulation::CArray< INDEX_TYPE, NDIMm_dims = { 0 }
 the dimensions of the array.
 
typeManipulation::CArray< INDEX_TYPE, NDIMm_strides = { 0 }
 the strides of the array.
 
BUFFER_TYPE< T > m_dataBuffer
 this data member contains the actual data for the array.
 
int m_singleParameterResizeIndex = 0
 

Detailed Description

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
class LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >

This class serves to provide a "view" of a multidimensional array.

Template Parameters
Ttype of data that is contained by the array
NDIM_TPARAMnumber of dimensions in array (e.g. NDIM=1->vector, NDIM=2->Matrix, etc. ).
USDthe dimension with a unit stride, in an Array with a standard layout this is the last dimension.
INDEX_TYPEthe integer to use for indexing.
BUFFER_TYPEA class that defines how to actually allocate memory for the Array. Must take one template argument that describes the type of the data being stored (T).

When using the ChaiBuffer the copy copy constructor of this class calls the copy constructor for the ChaiBuffer which will move the data to the location of the touch (host or device). In general, the ArrayView should be what is passed by value into a lambda that is used to launch kernels as it copy will trigger the desired data motion onto the appropriate memory space.

Key features: 1) When using a ChaiBuffer as the BUFFER_TYPE the ArrayView copy constructor will move the data to the current execution space. 2) Defines a slicing operator[]. 3) Defines operator() array accessor. 3) operator[] and operator() are all const and may be called in non-mutable lambdas. 4) Conversion operators to go from ArrayView<T> to ArrayView<T const>. 5) Since the Array is derived from ArrayView, it may be upcasted: Array<T,NDIM> array; ArrayView<T,NDIM> const & arrView = array;

A good guideline is to upcast to an ArrayView when you don't need allocation capabilities that are only present in Array.

Constructor & Destructor Documentation

◆ ArrayView() [1/7]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::ArrayView ( )
default

A constructor to create an uninitialized ArrayView.

Note
An uninitialized ArrayView should not be used until it is assigned to.

◆ ArrayView() [2/7]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE constexpr LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::ArrayView ( ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE > const &  source)
inlinenoexcept

Copy Constructor.

Parameters
sourceThe object to copy.
Note
Triggers the copy constructor for
Template Parameters
BUFFER_TYPE.When using the ChaiBuffer this can move the underlying buffer to a new memory space if the execution context is set.

◆ ArrayView() [3/7]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
template<typename U , typename = std::enable_if_t< !std::is_same< T, U >::value >>
LVARRAY_HOST_DEVICE constexpr LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::ArrayView ( ArrayView< U, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > const &  source)
inlineexplicit

Construct a new ArrayView from an ArrayView with a different type.

Template Parameters
UThe type to convert from.
Parameters
sourceThe ArrayView to convert.

If the size of T and U are different then either the size of T must be a multiple of the size of U or vice versa. If the types have different size then size of the unit stride dimension is changed accordingly.

Note
This is useful for converting between single values and SIMD types such as CUDA's __half and __half2.
Array< int, 2, RAJA::PERM_IJ, std::ptrdiff_t, MallocBuffer > x( 5, 10 );
ArrayView< int[ 2 ], 2, 1, std::ptrdiff_t, MallocBuffer > y( x.toView() );
assert( y.size( 1 ) == x.size( 1 ) / 2 );
assert( y( 3, 4 )[ 0 ] == x( 3, 8 ) );

◆ ArrayView() [4/7]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::ArrayView ( ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE > &&  source)
default

Move constructor, creates a shallow copy and invalidates the source.

Parameters
sourceobject to move.
Note
Since this invalidates the source this should not be used when source is the parent of an Array. Do not do this:
Array< int, RAJA::PERM_I, std::ptrdiff_t, MallocBuffer > array( 10 );
ArrayView< int, 1, 0, std::ptrdiff_t, MallocBuffer > view = std::move( array.toView() );
However this is ok:
Array< int, RAJA::PERM_I, std::ptrdiff_t, MallocBuffer > array( 10 );
ArrayView< int, 1, 0, std::ptrdiff_t, MallocBuffer > view = array.toView();
ArrayView< int, 1, 0, std::ptrdiff_t, MallocBuffer > anotherView = std::move( view );

◆ ArrayView() [5/7]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE constexpr LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::ArrayView ( typeManipulation::CArray< INDEX_TYPE, NDIM > const &  dims,
typeManipulation::CArray< INDEX_TYPE, NDIM > const &  strides,
int const  singleParameterResizeIndex,
BUFFER_TYPE< T > const &  buffer 
)
inlineexplicit

Construct a new ArrayView from existing components.

Parameters
dimsThe array of dimensions.
stridesThe array of strides.
singleParameterResizeIndexThe single parameter resize index.
bufferThe buffer to copy construct.

◆ ArrayView() [6/7]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::ArrayView ( bool  )
inlineexplicitprotectednoexcept

Protected constructor to be used by the Array class.

Note
The unused boolean parameter is to distinguish this from the default constructor.

◆ ArrayView() [7/7]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE constexpr LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::ArrayView ( BUFFER_TYPE< T > &&  buffer)
inlineprotectednoexcept

Protected constructor to be used by the Array class.

Construct an empty ArrayView from buffer.

Parameters
bufferThe buffer use.

Member Function Documentation

◆ back()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
T& LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::back ( ) const
inline
Returns
Return a reference to the last value.

◆ begin()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE constexpr T* LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::begin ( ) const
inline
Returns
Return an iterator to the begining of the data.

◆ capacity()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::capacity ( ) const
inline
Returns
Return the maximum number of values the Array can hold without reallocation.

◆ data()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE constexpr T* LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::data ( ) const
inline
Returns
Return a pointer to the values.

◆ dataBuffer()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE constexpr BUFFER_TYPE< T > const& LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::dataBuffer ( ) const
inline
Returns
A reference to the underlying buffer.
Note
Use with caution.

◆ dims()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE const* LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::dims ( ) const
inlinenoexcept
Returns
A pointer to the array containing the size of each dimension.

◆ dimsArray()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE constexpr typeManipulation::CArray< INDEX_TYPE, NDIM > const& LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::dimsArray ( ) const
inline
Returns
The CArray containing the size of each dimension.

◆ empty()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE constexpr bool LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::empty ( ) const
inline
Returns
Return true if the array is empty.

◆ end()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE constexpr T* LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::end ( ) const
inline
Returns
Return an iterator to the end of the data.

◆ front()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
T& LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::front ( ) const
inline
Returns
Return a reference to the first value.

◆ getPreviousSpace()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
MemorySpace LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::getPreviousSpace ( ) const
inline
Returns
The last space the Array was moved to.

◆ getSingleParameterResizeIndex()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE constexpr int LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::getSingleParameterResizeIndex ( ) const
inline
Returns
Return the default resize dimension.

◆ linearIndex()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
template<typename ... INDICES>
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK INDEX_TYPE LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::linearIndex ( INDICES const ...  indices) const
inline
Template Parameters
INDICESA variadic pack of integral types.
Returns
Return the linear index from a multidimensional index.
Parameters
indicesThe indices of the value to get the linear index of.

◆ move()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
void LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::move ( MemorySpace const  space,
bool const  touch = true 
) const
inline

Move the Array to the given execution space, optionally touching it.

Parameters
spacethe space to move the Array to.
touchwhether the Array should be touched in the new space or not.
Note
Not all Buffers support memory movement.

◆ operator ArraySlice< T, NDIM, USD, INDEX_TYPE >() [1/2]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE constexpr LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::operator ArraySlice< T, NDIM, USD, INDEX_TYPE > ( ) const &
inlinenoexcept
Returns
Return an ArraySlice representing this ArrayView.

◆ operator ArraySlice< T, NDIM, USD, INDEX_TYPE >() [2/2]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE constexpr LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::operator ArraySlice< T, NDIM, USD, INDEX_TYPE > ( ) const &&
inlinedeletenoexcept

Overload for rvalues that is deleted.

Returns
A null ArraySlice. This conversion cannot be called on a rvalue since the ArraySlice would contain pointers to the dims and strides of the current ArrayView that is about to be destroyed. This overload prevents that from happening.

◆ operator std::enable_if_t< !std::is_const< _T >::value, ArraySlice< T const, NDIM, USD, INDEX_TYPE > const >() [1/2]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
template<typename _T = T>
LVARRAY_HOST_DEVICE constexpr LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::operator std::enable_if_t< !std::is_const< _T >::value, ArraySlice< T const, NDIM, USD, INDEX_TYPE > const > ( ) const &
inlinenoexcept
Returns
Return an immutable ArraySlice representing this ArrayView.

◆ operator std::enable_if_t< !std::is_const< _T >::value, ArraySlice< T const, NDIM, USD, INDEX_TYPE > const >() [2/2]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
template<typename _T = T>
LVARRAY_HOST_DEVICE constexpr LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::operator std::enable_if_t< !std::is_const< _T >::value, ArraySlice< T const, NDIM, USD, INDEX_TYPE > const > ( ) const &&
inlinedeletenoexcept

Overload for rvalues that is deleted.

Returns
A null ArraySlice. This conversion cannot be called on a rvalue since the ArraySlice would contain pointers to the dims and strides of the current ArrayView that is about to be destroyed. This overload prevents that from happening.

◆ operator std::enable_if_t< !std::is_const< _T >::value, ArrayView< T const, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > >()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
template<typename _T = T>
LVARRAY_HOST_DEVICE constexpr LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::operator std::enable_if_t< !std::is_const< _T >::value, ArrayView< T const, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > > ( ) const
inlinenoexcept

A user defined conversion operator (UDC) to an ArrayView< T const, ... >.

Returns
A new ArrayView where T is const.

◆ operator()()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
template<typename ... INDICES>
LVARRAY_HOST_DEVICE constexpr T& LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::operator() ( INDICES...  indices) const
inline
Template Parameters
INDICESA variadic pack of integral types.
Returns
Return a reference to the value at the given multidimensional index.
Parameters
indicesThe indices of the value to access.

◆ operator=() [1/2]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE LVARRAY_INTEL_CONSTEXPR ArrayView& LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::operator= ( ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE > &&  rhs)
inline

Move assignment operator, creates a shallow copy and invalidates the source.

Parameters
rhsThe object to copy.
Returns
*this.
Note
Since this invalidates the source this should not be used when rhs is the parent of an Array. Do not do this:
Array< int, RAJA::PERM_I, std::ptrdiff_t, MallocBuffer > array( 10 );
ArrayView< int, 1, 0, std::ptrdiff_t, MallocBuffer > view;
view = std::move( array.toView() );
However this is ok:
Array< int, RAJA::PERM_I, std::ptrdiff_t, MallocBuffer > array( 10 );
ArrayView< int, 1, 0, std::ptrdiff_t, MallocBuffer > view = array.toView();
ArrayView< int, 1, 0, std::ptrdiff_t, MallocBuffer > anotherView;
anotherView = std::move( view );

◆ operator=() [2/2]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_INTEL_CONSTEXPR ArrayView& LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::operator= ( ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE > const &  rhs)
inlinenoexcept

Copy assignment operator, creates a shallow copy.

Parameters
rhsobject to copy.
Returns
*this

◆ operator[]() [1/3]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
template<int _NDIM = NDIM>
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK std::enable_if_t< (_NDIM > 1), ArraySlice< T, NDIM - 1, USD - 1, INDEX_TYPE > > LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::operator[] ( INDEX_TYPE const  index) const &
inlinenoexcept
Returns
Return a lower dimensional slice of this ArrayView.
Parameters
indexThe index of the slice to create.
Note
This method is only active when NDIM > 1.

◆ operator[]() [2/3]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
template<int _NDIM = NDIM>
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK std::enable_if_t< (_NDIM > 1), ArraySlice< T, NDIM - 1, USD - 1, INDEX_TYPE > > LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::operator[] ( INDEX_TYPE const  index) const &&
inlinedeletenoexcept

Overload for rvalues that is deleted.

Parameters
indexNot used.
Returns
A null ArraySlice. The multidimensional operator[] cannot be called on a rvalue since the ArraySlice would contain pointers to the object that is about to be destroyed. This overload prevents that from happening.

◆ operator[]() [3/3]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
template<int _NDIM = NDIM>
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK std::enable_if_t< _NDIM == 1, T & > LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::operator[] ( INDEX_TYPE const  index) const &
inlinenoexcept
Returns
Return a reference to the value at the given index.
Parameters
indexThe index of the value to access.
Note
This method is only active when NDIM == 1.

◆ registerTouch()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
void LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::registerTouch ( MemorySpace const  space) const
inline

Touch the memory in space.

Parameters
spaceThe memory space in which a touch will be recorded.

◆ setValues() [1/2]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
template<typename POLICY >
DISABLE_HD_WARNING void LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::setValues ( T const &  value) const
inline

Set all entries in the array to value.

Template Parameters
POLICYThe RAJA policy to use.
Parameters
valueThe value to set entries to.
Note
The view is moved to and touched in the appropriate space.

◆ setValues() [2/2]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
template<typename POLICY >
void LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::setValues ( ArrayView< T const, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > const &  rhs) const
inline

Set entries to values from another compatible ArrayView.

Template Parameters
POLICYThe RAJA policy to use.
Parameters
rhsThe source array view, must have the same dimensions and strides as *this.

◆ size() [1/2]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::size ( ) const
inlinenoexcept
Returns
Return the allocated size.

◆ size() [2/2]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK INDEX_TYPE LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::size ( int const  dim) const
inlinenoexcept
Returns
Return the length of the given dimension.
Parameters
dimThe dimension to get the length of.

◆ strides()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE const* LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::strides ( ) const
inlinenoexcept
Returns
A pointer to the array containing the stride of each dimension.

◆ stridesArray()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE constexpr typeManipulation::CArray< INDEX_TYPE, NDIM > const& LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::stridesArray ( ) const
inline
Returns
The CArray containing the stride of each dimension.

◆ toNestedView()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE constexpr NestedViewType LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::toNestedView ( ) const &
inline
Returns
Return *this after converting any nested arrays to const views.

◆ toNestedViewConst()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE constexpr NestedViewTypeConst LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::toNestedViewConst ( ) const &
inline
Returns
Return *this after converting any nested arrays to const views to const values.

◆ toSlice() [1/2]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE constexpr ArraySlice< T, NDIM, USD, INDEX_TYPE > LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::toSlice ( ) const &
inlinenoexcept
Returns
Return an ArraySlice representing this ArrayView.

◆ toSlice() [2/2]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE constexpr ArraySlice< T, NDIM, USD, INDEX_TYPE > LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::toSlice ( ) const &&
inlinedeletenoexcept

Overload for rvalues that is deleted.

Returns
A null ArraySlice.
Note
This cannot be called on a rvalue since the ArraySlice would contain pointers to the dims and strides of the current ArrayView that is about to be destroyed. This overload prevents that from happening.

◆ toSliceConst() [1/2]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE constexpr ArraySlice< T const, NDIM, USD, INDEX_TYPE > LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::toSliceConst ( ) const &
inlinenoexcept
Returns
Return an immutable ArraySlice representing this ArrayView.

◆ toSliceConst() [2/2]

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE constexpr ArraySlice< T const, NDIM, USD, INDEX_TYPE > LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::toSliceConst ( ) const &&
inlinedeletenoexcept

Overload for rvalues that is deleted.

Returns
A null ArraySlice. This cannot be called on a rvalue since the ArraySlice would contain pointers to the dims and strides of the current ArrayView that is about to be destroyed. This overload prevents that from happening.

◆ toView()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE constexpr ArrayView LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::toView ( ) const &
inline
Returns
Return a new ArrayView.

◆ toViewConst()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LVARRAY_HOST_DEVICE constexpr ViewTypeConst LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::toViewConst ( ) const &
inline
Returns
Return a new ArrayView where T is const.

◆ zero()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
void LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::zero ( ) const
inline

Use memset to set all the values in the array to 0.

This is preferred over setValues< POLICY >( 0 ) for numeric types since it is much faster in most cases. If the buffer is allocated using Umpire then the Umpire ResouceManager is used, otherwise std::memset is used.

Note
The memset occurs in the last space the array was used in and the view is moved and touched in that space.

Member Data Documentation

◆ m_singleParameterResizeIndex

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
int LvArray::ArrayView< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE, BUFFER_TYPE >::m_singleParameterResizeIndex = 0
protected

this data member specifies the dimension that will be resized as a result of a call to the single dimension resize method.


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