GEOSX
|
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 | 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... | |
constexpr | ArrayView (ArrayView const &source) noexcept |
Copy Constructor. More... | |
template<typename U , typename = std::enable_if_t< !std::is_same< T, U >::value >> | |
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... | |
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_INTEL_CONSTEXPR ArrayView & | operator= (ArrayView &&rhs) |
Move assignment operator, creates a shallow copy and invalidates the source. More... | |
LVARRAY_INTEL_CONSTEXPR ArrayView & | operator= (ArrayView const &rhs) noexcept |
Copy assignment operator, creates a shallow copy. More... | |
ArrayView and ArraySlice creation methods and user defined conversions. | |
constexpr ArrayView | toView () const & |
constexpr ArrayView< T const, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > | toViewConst () const & |
constexpr NestedViewType | toNestedView () const & |
constexpr NestedViewTypeConst | toNestedViewConst () const & |
constexpr ArraySlice< T, NDIM, USD, INDEX_TYPE > | toSlice () const &noexcept |
constexpr ArraySlice< T, NDIM, USD, INDEX_TYPE > | toSlice () const &&noexcept=delete |
Overload for rvalues that is deleted. More... | |
constexpr ArraySlice< T const, NDIM, USD, INDEX_TYPE > | toSliceConst () const &noexcept |
constexpr ArraySlice< T const, NDIM, USD, INDEX_TYPE > | toSliceConst () const &&noexcept=delete |
Overload for rvalues that is deleted. More... | |
template<typename _T = T> | |
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... | |
constexpr | operator ArraySlice< T, NDIM, USD, INDEX_TYPE > () const &noexcept |
constexpr | operator ArraySlice< T, NDIM, USD, INDEX_TYPE > () const &&noexcept=delete |
Overload for rvalues that is deleted. More... | |
template<typename _T = T> | |
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> | |
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 | |
constexpr INDEX_TYPE | size () const noexcept |
constexpr INDEX_TYPE | size (int const dim) const noexcept |
constexpr bool | empty () const |
constexpr INDEX_TYPE | capacity () const |
constexpr int | getSingleParameterResizeIndex () const |
template<typename ... INDICES> | |
constexpr INDEX_TYPE | linearIndex (INDICES const ... indices) const |
constexpr INDEX_TYPE const * | dims () const noexcept |
constexpr typeManipulation::CArray< INDEX_TYPE, NDIM > const & | dimsArray () const |
constexpr INDEX_TYPE const * | strides () const noexcept |
constexpr typeManipulation::CArray< INDEX_TYPE, NDIM > const & | stridesArray () const |
constexpr BUFFER_TYPE< T > const & | dataBuffer () const |
Methods that provide access to the data. | |
template<int _NDIM = NDIM> | |
constexpr 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> | |
constexpr 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> | |
constexpr std::enable_if_t< _NDIM==1, T &> | operator[] (INDEX_TYPE const index) const &noexcept |
template<typename ... INDICES> | |
constexpr T & | operator() (INDICES... indices) const |
constexpr T * | data () const |
constexpr T * | begin () const |
constexpr T * | end () const |
T & | front () const |
T & | back () const |
Methods that set all the values | |
template<typename POLICY > | |
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 | |
constexpr | ArrayView (bool) noexcept |
Protected constructor to be used by the Array class. More... | |
constexpr | ArrayView (BUFFER_TYPE< T > &&buffer) noexcept |
Protected constructor to be used by the Array class. More... | |
Protected Attributes | |
typeManipulation::CArray< INDEX_TYPE, NDIM > | m_dims = { 0 } |
the dimensions of the array. | |
typeManipulation::CArray< INDEX_TYPE, NDIM > | m_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 |
This class serves to provide a "view" of a multidimensional array.
T | type of data that is contained by the array |
NDIM_TPARAM | number of dimensions in array (e.g. NDIM=1->vector, NDIM=2->Matrix, etc. ). |
USD | the dimension with a unit stride, in an Array with a standard layout this is the last dimension. |
INDEX_TYPE | the integer to use for indexing. |
BUFFER_TYPE | A 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.
Definition at line 68 of file ArrayView.hpp.
|
default |
|
inlinenoexcept |
Copy Constructor.
source | The object to copy. |
BUFFER_TYPE. | When using the ChaiBuffer this can move the underlying buffer to a new memory space if the execution context is set. |
Definition at line 127 of file ArrayView.hpp.
|
inlineexplicit |
Construct a new ArrayView from an ArrayView with a different type.
U | The type to convert from. |
source | The 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.
__half
and __half2
. Definition at line 151 of file ArrayView.hpp.
|
default |
Move constructor, creates a shallow copy and invalidates the source.
source | object to move. |
source
is the parent of an Array. Do not do this:
|
inlineexplicit |
Construct a new ArrayView from existing components.
dims | The array of dimensions. |
strides | The array of strides. |
singleParameterResizeIndex | The single parameter resize index. |
buffer | The buffer to copy construct. |
Definition at line 194 of file ArrayView.hpp.
|
inlineexplicitprotectednoexcept |
Protected constructor to be used by the Array class.
Definition at line 723 of file ArrayView.hpp.
|
inlineprotectednoexcept |
Protected constructor to be used by the Array class.
Construct an empty ArrayView from buffer
.
buffer | The buffer use. |
Definition at line 740 of file ArrayView.hpp.
|
inline |
Definition at line 591 of file ArrayView.hpp.
|
inline |
Definition at line 572 of file ArrayView.hpp.
|
inline |
Definition at line 436 of file ArrayView.hpp.
|
inline |
Definition at line 565 of file ArrayView.hpp.
|
inline |
Definition at line 495 of file ArrayView.hpp.
|
inlinenoexcept |
Definition at line 466 of file ArrayView.hpp.
|
inline |
Definition at line 473 of file ArrayView.hpp.
|
inline |
Definition at line 429 of file ArrayView.hpp.
|
inline |
Definition at line 579 of file ArrayView.hpp.
|
inline |
Definition at line 585 of file ArrayView.hpp.
|
inline |
Definition at line 670 of file ArrayView.hpp.
|
inline |
Definition at line 443 of file ArrayView.hpp.
|
inline |
INDICES | A variadic pack of integral types. |
indices | The indices of the value to get the linear index of. |
Definition at line 453 of file ArrayView.hpp.
|
inline |
Move the Array to the given execution space, optionally touching it.
space | the space to move the Array to. |
touch | whether the Array should be touched in the new space or not. |
Definition at line 686 of file ArrayView.hpp.
|
inlinenoexcept |
Definition at line 351 of file ArrayView.hpp.
|
inlinedeletenoexcept |
Overload for rvalues that is deleted.
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.
|
inlinenoexcept |
Definition at line 370 of file ArrayView.hpp.
|
inlinedeletenoexcept |
Overload for rvalues that is deleted.
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.
|
inlinenoexcept |
A user defined conversion operator (UDC) to an ArrayView< T const, ... >.
T
is const
. Definition at line 344 of file ArrayView.hpp.
|
inline |
INDICES | A variadic pack of integral types. |
indices | The indices of the value to access. |
Definition at line 555 of file ArrayView.hpp.
|
inline |
Move assignment operator, creates a shallow copy and invalidates the source.
rhs | The object to copy. |
rhs
is the parent of an Array. Do not do this: Definition at line 227 of file ArrayView.hpp.
|
inlinenoexcept |
Copy assignment operator, creates a shallow copy.
rhs | object to copy. |
Definition at line 246 of file ArrayView.hpp.
|
inlinenoexcept |
index | The index of the slice to create. |
Definition at line 513 of file ArrayView.hpp.
|
inlinedeletenoexcept |
Overload for rvalues that is deleted.
index | Not used. |
ArraySlice
would contain pointers to the object that is about to be destroyed. This overload prevents that from happening.
|
inlinenoexcept |
index | The index of the value to access. |
Definition at line 542 of file ArrayView.hpp.
|
inline |
Touch the memory in space
.
space | The memory space in which a touch will be recorded. |
Definition at line 677 of file ArrayView.hpp.
|
inline |
Set all entries in the array to value
.
POLICY | The RAJA policy to use. |
value | The value to set entries to. |
Definition at line 609 of file ArrayView.hpp.
|
inline |
Set entries to values from another compatible ArrayView.
POLICY | The RAJA policy to use. |
rhs | The source array view, must have the same dimensions and strides as *this. |
Definition at line 644 of file ArrayView.hpp.
|
inlinenoexcept |
Definition at line 396 of file ArrayView.hpp.
|
inlinenoexcept |
dim | The dimension to get the length of. |
Definition at line 416 of file ArrayView.hpp.
|
inlinenoexcept |
Definition at line 480 of file ArrayView.hpp.
|
inline |
Definition at line 487 of file ArrayView.hpp.
|
inline |
Definition at line 289 of file ArrayView.hpp.
|
inline |
Definition at line 296 of file ArrayView.hpp.
|
inlinenoexcept |
Definition at line 304 of file ArrayView.hpp.
|
inlinedeletenoexcept |
Overload for rvalues that is deleted.
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.
|
inlinenoexcept |
Definition at line 323 of file ArrayView.hpp.
|
inlinedeletenoexcept |
Overload for rvalues that is deleted.
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.
|
inline |
Definition at line 270 of file ArrayView.hpp.
|
inline |
T
is const
. Definition at line 277 of file ArrayView.hpp.
|
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.
Definition at line 625 of file ArrayView.hpp.
|
protected |
this data member specifies the dimension that will be resized as a result of a call to the single dimension resize method.
Definition at line 758 of file ArrayView.hpp.