25 #if defined(LVARRAY_USE_TOTALVIEW_OUTPUT) && !defined(__CUDA_ARCH__) 67 template<
typename >
class BUFFER_TYPE >
72 static_assert( NDIM_TPARAM > 0,
"Number of dimensions must be greater than zero." );
73 static_assert( USD_TPARAM >= 0,
"USD must be positive." );
74 static_assert( USD_TPARAM < NDIM_TPARAM,
"USD must be less than NDIM." );
80 static constexpr
int NDIM = NDIM_TPARAM;
83 static constexpr
int USD = USD_TPARAM;
153 template< typename U, typename=std::enable_if_t< !std::is_same< T, U >::value > >
163 for(
int i = 0; i <
NDIM; ++i )
200 int const singleParameterResizeIndex,
201 BUFFER_TYPE< T >
const & buffer ):
235 for(
int i = 0; i <
NDIM; ++i )
237 m_dims[ i ] = rhs.m_dims[ i ];
249 inline LVARRAY_INTEL_CONSTEXPR
254 for(
int i = 0; i <
NDIM; ++i )
256 m_dims[ i ] = rhs.m_dims[ i ];
320 toSlice()
const && noexcept =
delete;
345 template<
typename _T=T >
347 operator std::enable_if_t< !std::is_const< _T >::value,
371 template<
typename _T=T >
373 operator std::enable_if_t< !std::is_const< _T >::value,
384 template<
typename _T=T >
386 operator std::enable_if_t< !std::is_const< _T >::value,
400 INDEX_TYPE
size() const noexcept
402 #if defined( __ibmxl__ ) 405 INDEX_TYPE val =
m_dims[ 0 ];
406 for(
int i = 1; i <
NDIM; ++i )
411 return indexing::multiplyAll< NDIM >(
m_dims.
data );
420 INDEX_TYPE
size(
int const dim )
const noexcept
422 #ifdef LVARRAY_BOUNDS_CHECK 434 {
return size() == 0; }
441 {
return LvArray::integerConversion< INDEX_TYPE >(
m_dataBuffer.capacity() ); }
455 template<
typename ... INDICES >
459 static_assert(
sizeof ... (INDICES) == NDIM,
"number of indices does not match NDIM" );
460 #ifdef LVARRAY_BOUNDS_CHECK 463 return indexing::getLinearIndex< USD >(
m_strides.
data, indices ... );
470 INDEX_TYPE
const *
dims() const noexcept
514 template<
int _NDIM=NDIM >
517 operator[]( INDEX_TYPE
const index )
const & noexcept
533 template<
int _NDIM=NDIM >
536 operator[]( INDEX_TYPE
const index )
const && noexcept =
delete;
543 template<
int _NDIM=NDIM >
545 std::enable_if_t< _NDIM == 1, T & >
557 template<
typename ... INDICES >
561 static_assert(
sizeof ... (INDICES) == NDIM,
"number of indices does not match NDIM" );
590 {
return data()[ 0 ]; }
612 template<
typename POLICY >
615 auto const view =
toView();
616 RAJA::forall< POLICY >( RAJA::TypedRangeSegment< INDEX_TYPE >( 0,
size() ),
619 view.data()[ i ] = value;
631 #if !defined( LVARRAY_USE_UMPIRE ) 638 umpireInterface::memset(
data(), 0,
size() *
sizeof( T ) );
647 template<
typename POLICY >
650 for(
int dim = 0; dim <
NDIM; ++dim )
654 "This method only works with Arrays with the same data layout." );
657 auto const view =
toView();
658 RAJA::forall< POLICY >( RAJA::TypedRangeSegment< INDEX_TYPE >( 0,
size() ), [view, rhs]
LVARRAY_HOST_DEVICE ( INDEX_TYPE
const i )
660 view.data()[ i ] = rhs.
data()[ i ];
695 #if defined(LVARRAY_USE_TOTALVIEW_OUTPUT) && !defined(__CUDA_ARCH__) 701 static int TV_ttf_display_type(
ArrayView const * av )
705 int constexpr ndim =
NDIM;
710 TV_ttf_add_row(
"m_dims", totalview::format< INDEX_TYPE, int >( 1, &ndim ).c_str(), (av->
m_dims) );
711 TV_ttf_add_row(
"m_strides", totalview::format< INDEX_TYPE, int >( 1, &ndim ).c_str(), (av->
m_strides) );
732 #if defined(LVARRAY_USE_TOTALVIEW_OUTPUT) && !defined(__CUDA_ARCH__) && defined(LVARRAY_BOUNDS_CHECK) 733 ArrayView::TV_ttf_display_type(
nullptr );
779 template<
typename T,
783 template<
typename >
class BUFFER_TYPE >
784 constexpr
bool isArrayView< ArrayView< T, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > > =
true;
T value_type
The type of the values in the ArrayView, here for stl compatability.
Definition: ArrayView.hpp:107
LVARRAY_HOST_DEVICE constexpr ArraySlice< T const, NDIM, USD, INDEX_TYPE > toSliceConst() const &noexcept
Definition: ArrayView.hpp:327
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE capacity() const
Definition: ArrayView.hpp:440
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.
Definition: ArrayView.hpp:198
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK INDEX_TYPE linearIndex(INDICES const ... indices) const
Definition: ArrayView.hpp:457
constexpr bool isArrayView
True if the template type is a ArrayView.
Definition: ArrayView.hpp:769
INDEX_TYPE size_type
The integer type used for indexing, here for stl compatability.
Definition: ArrayView.hpp:110
This class serves to provide a sliced multidimensional interface to the family of LvArray classes...
Definition: ArraySlice.hpp:89
LVARRAY_HOST_DEVICE constexpr T * data() const
Definition: ArrayView.hpp:569
T & front() const
Definition: ArrayView.hpp:589
#define LVARRAY_ASSERT_GT(lhs, rhs)
Assert that one value compares greater than the other in debug builds.
Definition: Macros.hpp:515
LVARRAY_HOST_DEVICE constexpr ArraySlice< T, NDIM, USD, INDEX_TYPE > toSlice() const &noexcept
Definition: ArrayView.hpp:308
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.
Definition: Macros.hpp:305
void registerTouch(MemorySpace const space) const
Touch the memory in space.
Definition: ArrayView.hpp:681
~ArrayView()=default
The default destructor.
LVARRAY_HOST_DEVICE constexpr ViewTypeConst toViewConst() const &
Definition: ArrayView.hpp:281
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.
Definition: ArraySlice.hpp:66
LVARRAY_HOST_DEVICE constexpr T * end() const
Definition: ArrayView.hpp:583
Contains the LvArray umpire interface. This is only used to keep umpire/ResourceManager.hpp out of the includes for most headers.
LVARRAY_HOST_DEVICE constexpr NestedViewTypeConst toNestedViewConst() const &
Definition: ArrayView.hpp:300
This class serves to provide a "view" of a multidimensional array.
Definition: ArrayView.hpp:68
#define CONSTEXPR_WITHOUT_BOUNDS_CHECK
Expands to constexpr when array bound checking is disabled.
Definition: Macros.hpp:609
LVARRAY_HOST_DEVICE LVARRAY_INTEL_CONSTEXPR ArrayView & operator=(ArrayView &&rhs)
Move assignment operator, creates a shallow copy and invalidates the source.
Definition: ArrayView.hpp:231
void zero() const
Use memset to set all the values in the array to 0.
Definition: ArrayView.hpp:629
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE size() const noexcept
Definition: ArrayView.hpp:400
T ValueType
The type of the values in the ArrayView.
Definition: ArrayView.hpp:77
typeManipulation::CArray< INDEX_TYPE, NDIM > m_dims
the dimensions of the array.
Definition: ArrayView.hpp:752
Contains the implementation of LvArray::ArraySlice.
LVARRAY_HOST_DEVICE constexpr ArrayView toView() const &
Definition: ArrayView.hpp:274
LVARRAY_HOST_DEVICE constexpr BUFFER_TYPE< T > const & dataBuffer() const
Definition: ArrayView.hpp:499
ArrayView< std::remove_const_t< T > const, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > ViewTypeConst
The type when the data type is const.
Definition: ArrayView.hpp:89
#define LVARRAY_ASSERT_GE(lhs, rhs)
Assert that one value compares greater than or equal to the other in debug builds.
Definition: Macros.hpp:530
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.
Definition: ArrayView.hpp:155
Contains functions for manipulating buffers.
BUFFER_TYPE< T > m_dataBuffer
this data member contains the actual data for the array.
Definition: ArrayView.hpp:758
static constexpr int USD
The unit stride dimension.
Definition: ArrayView.hpp:83
T & back() const
Definition: ArrayView.hpp:595
typeManipulation::CArray< INDEX_TYPE, NDIM > m_strides
the strides of the array.
Definition: ArrayView.hpp:755
camp::resources::Platform MemorySpace
an alias for camp::resources::Platform.
Definition: bufferManipulation.hpp:31
DISABLE_HD_WARNING void setValues(T const &value) const
Set all entries in the array to value.
Definition: ArrayView.hpp:613
INDEX_TYPE IndexType
The integer type used for indexing.
Definition: ArrayView.hpp:86
static LVARRAY_HOST_DEVICE constexpr auto multiply(A const a, B const b)
Definition: indexing.hpp:47
LVARRAY_HOST_DEVICE 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.
Definition: indexing.hpp:208
void move(MemorySpace const space, bool const touch=true) const
Move the Array to the given execution space, optionally touching it.
Definition: ArrayView.hpp:690
void setValues(ArrayView< T const, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > const &rhs) const
Set entries to values from another compatible ArrayView.
Definition: ArrayView.hpp:648
LVARRAY_HOST_DEVICE constexpr T & operator()(INDICES... indices) const
Definition: ArrayView.hpp:559
The top level namespace.
Definition: Array.hpp:24
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK INDEX_TYPE size(int const dim) const noexcept
Definition: ArrayView.hpp:420
MemorySpace getPreviousSpace() const
Definition: ArrayView.hpp:674
LVARRAY_HOST_DEVICE constexpr T * begin() const
Definition: ArrayView.hpp:576
LVARRAY_HOST_DEVICE constexpr typeManipulation::CArray< INDEX_TYPE, NDIM > const & dimsArray() const
Definition: ArrayView.hpp:477
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK ArrayView(bool) noexcept
Protected constructor to be used by the Array class.
Definition: ArrayView.hpp:727
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE constexpr ArrayView(ArrayView const &source) noexcept
Copy Constructor.
Definition: ArrayView.hpp:131
Contains a bunch of macro definitions.
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE const * strides() const noexcept
Definition: ArrayView.hpp:484
LVARRAY_HOST_DEVICE constexpr typeManipulation::CArray< INDEX_TYPE, NDIM > const & stridesArray() const
Definition: ArrayView.hpp:491
int m_singleParameterResizeIndex
Definition: ArrayView.hpp:762
T data[N]
The backing c array, public so that aggregate initialization works.
Definition: typeManipulation.hpp:540
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE const * dims() const noexcept
Definition: ArrayView.hpp:470
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE constexpr ArrayView(BUFFER_TYPE< T > &&buffer) noexcept
Protected constructor to be used by the Array class.
Definition: ArrayView.hpp:744
#define DISABLE_HD_WARNING
Disable host device warnings.
Definition: Macros.hpp:561
std::string demangle(char const *const name)
Definition: system.cpp:388
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK std::enable_if_t< _NDIM==1, T &> operator[](INDEX_TYPE const index) const &noexcept
Definition: ArrayView.hpp:546
LVARRAY_HOST_DEVICE constexpr NestedViewType toNestedView() const &
Definition: ArrayView.hpp:293
LVARRAY_HOST_DEVICE constexpr bool empty() const
Definition: ArrayView.hpp:433
static constexpr int NDIM
The number of dimensions.
Definition: ArrayView.hpp:80
Contains functions to aid in multidimensional indexing.
#define LVARRAY_ERROR_IF_NE(lhs, rhs)
Raise a hard error if two values are not equal.
Definition: Macros.hpp:321
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.
Definition: ArrayView.hpp:250
LVARRAY_HOST_DEVICE constexpr int getSingleParameterResizeIndex() const
Definition: ArrayView.hpp:447
#define LVARRAY_HOST_DEVICE
Mark a function for both host and device usage.
Definition: Macros.hpp:549