24 #if defined(LVARRAY_USE_TOTALVIEW_OUTPUT) && !defined(__CUDA_ARCH__) 66 template<
typename >
class BUFFER_TYPE >
71 static_assert( NDIM_TPARAM > 0,
"Number of dimensions must be greater than zero." );
72 static_assert( USD_TPARAM >= 0,
"USD must be positive." );
73 static_assert( USD_TPARAM < NDIM_TPARAM,
"USD must be less than NDIM." );
79 static constexpr
int NDIM = NDIM_TPARAM;
82 static constexpr
int USD = USD_TPARAM;
161 int const singleParameterResizeIndex,
162 BUFFER_TYPE< T >
const & buffer ):
196 for(
int i = 0; i <
NDIM; ++i )
198 m_dims[ i ] = rhs.m_dims[ i ];
210 inline LVARRAY_INTEL_CONSTEXPR
215 for(
int i = 0; i <
NDIM; ++i )
217 m_dims[ i ] = rhs.m_dims[ i ];
281 toSlice()
const && noexcept =
delete;
306 template<
typename _T=T >
308 operator std::enable_if_t< !std::is_const< _T >::value,
332 template<
typename _T=T >
334 operator std::enable_if_t< !std::is_const< _T >::value,
345 template<
typename _T=T >
347 operator std::enable_if_t< !std::is_const< _T >::value,
361 INDEX_TYPE
size() const noexcept
363 #if defined( __ibmxl__ ) 366 INDEX_TYPE val =
m_dims[ 0 ];
367 for(
int i = 1; i <
NDIM; ++i )
372 return indexing::multiplyAll< NDIM >(
m_dims.
data );
381 INDEX_TYPE
size(
int const dim )
const noexcept
383 #ifdef LVARRAY_BOUNDS_CHECK 395 {
return size() == 0; }
402 {
return LvArray::integerConversion< INDEX_TYPE >(
m_dataBuffer.capacity() ); }
416 template<
typename ... INDICES >
420 static_assert(
sizeof ... (INDICES) == NDIM,
"number of indices does not match NDIM" );
421 #ifdef LVARRAY_BOUNDS_CHECK 424 return indexing::getLinearIndex< USD >(
m_strides.
data, indices ... );
431 INDEX_TYPE
const *
dims() const noexcept
453 template<
int _NDIM=NDIM >
456 operator[]( INDEX_TYPE
const index )
const & noexcept
472 template<
int _NDIM=NDIM >
475 operator[]( INDEX_TYPE
const index )
const && noexcept =
delete;
482 template<
int _NDIM=NDIM >
484 std::enable_if_t< _NDIM == 1, T & >
496 template<
typename ... INDICES >
500 static_assert(
sizeof ... (INDICES) == NDIM,
"number of indices does not match NDIM" );
529 {
return data()[ 0 ]; }
550 template<
typename POLICY >
553 auto const view =
toView();
554 RAJA::forall< POLICY >( RAJA::TypedRangeSegment< INDEX_TYPE >( 0,
size() ), [value, view]
LVARRAY_HOST_DEVICE ( INDEX_TYPE
const i )
556 view.data()[ i ] = value;
565 template<
typename POLICY >
568 for(
int dim = 0; dim <
NDIM; ++dim )
572 "This method only works with Arrays with the same data layout." );
575 auto const view =
toView();
576 RAJA::forall< POLICY >( RAJA::TypedRangeSegment< INDEX_TYPE >( 0,
size() ), [view, rhs]
LVARRAY_HOST_DEVICE ( INDEX_TYPE
const i )
578 view.data()[ i ] = rhs.
data()[ i ];
610 #if defined(LVARRAY_USE_TOTALVIEW_OUTPUT) && !defined(__CUDA_ARCH__) 616 static int TV_ttf_display_type(
ArrayView const * av )
620 int constexpr ndim =
NDIM;
625 TV_ttf_add_row(
"m_dims", totalview::format< INDEX_TYPE, int >( 1, &ndim ).c_str(), (av->
m_dims) );
626 TV_ttf_add_row(
"m_strides", totalview::format< INDEX_TYPE, int >( 1, &ndim ).c_str(), (av->
m_strides) );
647 #if defined(LVARRAY_USE_TOTALVIEW_OUTPUT) && !defined(__CUDA_ARCH__) && defined(LVARRAY_BOUNDS_CHECK) 648 ArrayView::TV_ttf_display_type(
nullptr );
680 template<
typename T,
684 template<
typename >
class BUFFER_TYPE >
685 constexpr
bool isArrayView< ArrayView< T, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > > =
true;
HYPRE_ParVector value_type
The type of the values in the ArrayView, here for stl compatability.
constexpr T & operator()(INDICES... indices) const
INDEX_TYPE size(int const dim) const noexcept
constexpr int getSingleParameterResizeIndex() const
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.
constexpr INDEX_TYPE const * strides() const noexcept
constexpr bool isArrayView
True if the template type is a ArrayView.
INDEX_TYPE size_type
The integer type used for indexing, here for stl compatability.
This class serves to provide a sliced multidimensional interface to the family of LvArray classes...
constexpr ArraySlice< T, NDIM, USD, INDEX_TYPE > toSlice() const &noexcept
INDEX_TYPE size() const noexcept
constexpr T * end() const
#define LVARRAY_ASSERT_GT(lhs, rhs)
Assert that one value compares greater than the other in debug builds.
Contains functions for interacting with ArraySlices of arbitrary dimension.
#define LVARRAY_ERROR_IF_NE_MSG(lhs, rhs, msg)
Raise a hard error if two values are not equal.
void registerTouch(MemorySpace const space) const
Touch the memory in space.
~ArrayView()=default
The default destructor.
void checkIndices(INDEX_TYPE const *const LVARRAY_RESTRICT dims, INDICES const ... indices)
Check that the indices are with dims , if not the program is aborted.
constexpr ArrayView< T const, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > toViewConst() const &
Contains portable access to std::numeric_limits and functions for converting between integral types...
#define ARRAY_SLICE_CHECK_BOUNDS(index)
Point GDB at the scripts/gdb-printers.py.
constexpr T * data() const
This class serves to provide a "view" of a multidimensional array.
#define CONSTEXPR_WITHOUT_BOUNDS_CHECK
Expands to constexpr when array bound checking is disabled.
HYPRE_ParVector ValueType
The type of the values in the ArrayView.
typeManipulation::CArray< INDEX_TYPE, NDIM > m_dims
the dimensions of the array.
Contains the implementation of LvArray::ArraySlice.
constexpr ArrayView toView() const &
#define LVARRAY_ASSERT_GE(lhs, rhs)
Assert that one value compares greater than or equal to the other in debug builds.
Contains functions for manipulating buffers.
constexpr ArrayView(ArrayView const &source) noexcept
Copy Constructor.
constexpr INDEX_TYPE const * dims() const noexcept
constexpr ArraySlice< T const, NDIM, USD, INDEX_TYPE > toSliceConst() const &noexcept
static constexpr auto multiply(A const a, B const b)
BUFFER_TYPE< T > m_dataBuffer
this data member contains the actual data for the array.
static constexpr int USD
The unit stride dimension.
typeManipulation::CArray< INDEX_TYPE, NDIM > m_strides
the strides of the array.
INDEX_TYPE IndexType
The integer type used for indexing.
constexpr INDEX_TYPE linearIndex(INDICES const ... indices) const
constexpr INDEX_TYPE capacity() const
void move(MemorySpace const space, bool const touch=true) const
Move the Array to the given execution space, optionally touching it.
void setValues(ArrayView< T const, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > const &rhs) const
Set entries to values from another compatible ArrayView.
MemorySpace
An enum containing the available memory spaces.
constexpr ArrayView(bool) noexcept
Protected constructor to be used by the Array class.
constexpr T * begin() const
constexpr bool empty() const
void setValues(T const &value) const
Set all entries in the array to value.
Contains a bunch of macro definitions.
constexpr NestedViewTypeConst toNestedViewConst() const &
int m_singleParameterResizeIndex
constexpr std::enable_if_t< _NDIM==1, T &> operator[](INDEX_TYPE const index) const &noexcept
constexpr NestedViewType toNestedView() const &
#define DISABLE_HD_WARNING
Disable host device warnings.
std::string demangle(char const *const name)
static constexpr int NDIM
The number of dimensions.
Contains functions to aid in multidimensional indexing.
#define LVARRAY_ERROR_IF_NE(lhs, rhs)
Raise a hard error if two values are not equal.
LVARRAY_INTEL_CONSTEXPR ArrayView & operator=(ArrayView &&rhs)
Move assignment operator, creates a shallow copy and invalidates the source.
ArrayView()=default
A constructor to create an uninitialized ArrayView.
LVARRAY_INTEL_CONSTEXPR ArrayView & operator=(ArrayView const &rhs) noexcept
Copy assignment operator, creates a shallow copy.
#define LVARRAY_HOST_DEVICE
Mark a function for both host and device usage.