GEOSX
Array.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors.
3  * All rights reserved.
4  * See the LICENSE file for details.
5  * SPDX-License-Identifier: (BSD-3-Clause)
6  */
7 
13 #pragma once
14 
15 // Source includes
16 #include "indexing.hpp"
17 #include "ArrayView.hpp"
18 #include "bufferManipulation.hpp"
19 #include "StackBuffer.hpp"
20 
24 namespace LvArray
25 {
26 
50 template< typename T,
51  int NDIM,
52  typename PERMUTATION,
53  typename INDEX_TYPE,
54  template< typename > class BUFFER_TYPE >
55 class Array : public ArrayView< T,
56  NDIM,
57  typeManipulation::getStrideOneDimension( PERMUTATION {} ),
58  INDEX_TYPE,
59  BUFFER_TYPE >
60 {
61 public:
62 
63  // Check that the template arguments are valid.
64  static_assert( NDIM >= 0, "The dimension of the Array must be positive." );
65  static_assert( typeManipulation::isValidPermutation( PERMUTATION {} ), "The permutation must be valid." );
66  static_assert( typeManipulation::getDimension( PERMUTATION {} ) == NDIM,
67  "The dimension of the permutation must match the dimension of the Array." );
68  static_assert( std::is_integral< INDEX_TYPE >::value, "INDEX_TYPE must be integral." );
69 
71  using Permutation = PERMUTATION;
72 
74  using ParentClass = ArrayView< T, NDIM, typeManipulation::getStrideOneDimension( Permutation {} ), INDEX_TYPE, BUFFER_TYPE >;
75 
76  using ParentClass::USD;
77  using typename ParentClass::NestedViewType;
78  using typename ParentClass::NestedViewTypeConst;
79 
83 
89  inline Array():
90  ParentClass( true )
91  {
92  CalculateStrides();
93 #if !defined(__CUDA_ARCH__)
94  setName( "" );
95 #endif
96 #if defined(LVARRAY_USE_TOTALVIEW_OUTPUT) && !defined(__CUDA_ARCH__)
97  Array::TV_ttf_display_type( nullptr );
98 #endif
99  }
100 
105  template< typename ... DIMS,
106  typename=std::enable_if_t< sizeof ... ( DIMS ) == NDIM &&
107  typeManipulation::all_of_t< std::is_integral< DIMS > ... >::value > >
109  inline explicit Array( DIMS const ... dims ):
110  Array()
111  { resize( dims ... ); }
112 
119  Array( Array const & source ):
120  Array()
121  { *this = source; }
122 
131  Array( Array && source ):
132  ParentClass( std::move( source ) )
133  {
134  for( int i = 0; i < NDIM; ++i )
135  {
136  source.m_dims[ i ] = 0;
137  source.m_strides[ i ] = 0;
138  }
139  }
140 
146  { bufferManipulation::free( this->m_dataBuffer, this->size() ); }
147 
154  Array & operator=( Array const & rhs )
155  {
156  bufferManipulation::copyInto( this->m_dataBuffer, this->size(), rhs.m_dataBuffer, rhs.size() );
157 
158  for( int i = 0; i < NDIM; ++i )
159  {
160  this->m_dims[ i ] = rhs.m_dims[ i ];
161  this->m_strides[ i ] = rhs.m_strides[ i ];
162  }
163 
165  return *this;
166  }
167 
174  Array & operator=( Array && rhs )
175  {
176  ParentClass::operator=( std::move( rhs ) );
177 
178  for( int i = 0; i < NDIM; ++i )
179  {
180  rhs.m_dims[ i ] = 0;
181  rhs.m_strides[ i ] = 0;
182  }
183 
184  return *this;
185  }
186 
188 
192 
194  using ParentClass::toView;
195 
203  inline LVARRAY_HOST_DEVICE constexpr
205 
207 
215  inline LVARRAY_HOST_DEVICE constexpr
217 
219 
227  inline LVARRAY_HOST_DEVICE constexpr
228  NestedViewType toNestedView() const && = delete;
229 
231 
239  inline LVARRAY_HOST_DEVICE constexpr
240  NestedViewTypeConst toNestedViewConst() const && = delete;
241 
246  inline LVARRAY_HOST_DEVICE constexpr
248  { return toViewConst(); }
249 
257  template< typename _T=T >
258  inline LVARRAY_HOST_DEVICE constexpr
259  operator std::enable_if_t< !std::is_const< _T >::value,
260  ArrayView< T const, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > >() const && noexcept = delete;
261 
263 
267 
275  template< typename DIMS_TYPE >
277  void resize( int const numDims, DIMS_TYPE const * const dims )
278  {
279  LVARRAY_ERROR_IF_NE( numDims, NDIM );
280 
281  INDEX_TYPE const oldSize = this->size();
282  for( int i = 0; i < NDIM; ++i )
283  {
284  this->m_dims[ i ] = LvArray::integerConversion< INDEX_TYPE >( dims[ i ] );
285  LVARRAY_ERROR_IF_LT( this->m_dims[ i ], 0 );
286  }
287 
288  CalculateStrides();
289 
290  bufferManipulation::resize( this->m_dataBuffer, oldSize, this->size() );
291  }
292 
300  template< typename ... DIMS >
302  std::enable_if_t< sizeof ... ( DIMS ) == NDIM && typeManipulation::all_of_t< std::is_integral< DIMS > ... >::value >
303  resize( DIMS const ... newDims )
304  {
305  static_assert( sizeof ... ( DIMS ) == NDIM, "The number of arguments provided does not equal NDIM!" );
306  INDEX_TYPE const oldSize = this->size();
307 
308  int curDim = 0;
309  typeManipulation::forEachArg( [&]( auto const newDim )
310  {
311  this->m_dims[ curDim ] = LvArray::integerConversion< INDEX_TYPE >( newDim );
312  LVARRAY_ERROR_IF_LT( this->m_dims[ curDim ], 0 );
313  ++curDim;
314  }, newDims ... );
315 
316  CalculateStrides();
317 
318  bufferManipulation::resize( this->m_dataBuffer, oldSize, this->size() );
319  }
320 
328  template< typename ... DIMS >
330  void resizeWithoutInitializationOrDestruction( DIMS const ... newDims )
331  {
332  static_assert( sizeof ... ( DIMS ) == NDIM, "The number of arguments provided does not equal NDIM!" );
333  static_assert( std::is_trivially_destructible< T >::value,
334  "This function is only safe if T is trivially destructable." );
335 
336  INDEX_TYPE const oldSize = this->size();
337 
338  int i = 0;
339  typeManipulation::forEachArg( [&]( auto const newDim )
340  {
341  this->m_dims[ i ] = LvArray::integerConversion< INDEX_TYPE >( newDim );
342  LVARRAY_ERROR_IF_LT( this->m_dims[ i ], 0 );
343  ++i;
344  }, newDims ... );
345 
346  CalculateStrides();
347 
348  bufferManipulation::reserve( this->m_dataBuffer, oldSize, this->size() );
349  }
350 
359  template< INDEX_TYPE... INDICES, typename ... DIMS >
361  void resizeDimension( DIMS const ... newDims )
362  {
363  static_assert( sizeof ... (INDICES) <= NDIM, "Too many arguments provided." );
364  static_assert( sizeof ... (INDICES) == sizeof ... (DIMS),
365  "The number of indices must match the number of dimensions." );
366  static_assert( typeManipulation::all_of< ( 0 <= INDICES ) ... >::value, "INDICES must all be positive." );
367  static_assert( typeManipulation::all_of< ( INDICES < NDIM ) ... >::value, "INDICES must all be less than NDIM." );
368 
369  INDEX_TYPE const oldSize = this->size();
370 
371  typeManipulation::forEachArg( [&]( auto const & pair )
372  {
373  this->m_dims[ camp::get< 0 >( pair ) ] = LvArray::integerConversion< INDEX_TYPE >( camp::get< 1 >( pair ) );
374  LVARRAY_ERROR_IF_LT( this->m_dims[ camp::get< 0 >( pair ) ], 0 );
375  }, camp::make_tuple( INDICES, newDims )... );
376 
377  CalculateStrides();
378 
379  bufferManipulation::resize( this->m_dataBuffer, oldSize, this->size() );
380  }
381 
389  void resize( INDEX_TYPE const newdim )
390  { resizeDefaultDimension( newdim ); }
391 
400  void resizeDefault( INDEX_TYPE const newdim, T const & defaultValue )
401  { resizeDefaultDimension( newdim, defaultValue ); }
402 
408  void clear()
409  {
410  bufferManipulation::resize( this->m_dataBuffer, this->size(), 0 );
411 
412  this->m_dims[ this->getSingleParameterResizeIndex() ] = 0;
413 
414  CalculateStrides();
415  }
416 
422  inline void setSingleParameterResizeIndex( int const index )
423  {
424  LVARRAY_ERROR_IF_LT( index, 0 );
425  LVARRAY_ERROR_IF_GE( index, NDIM );
426  this->m_singleParameterResizeIndex = index;
427  }
428 
430 
434 
441  void reserve( INDEX_TYPE const newCapacity )
442  { bufferManipulation::reserve( this->m_dataBuffer, this->size(), newCapacity ); }
443 
445 
450 
459  template< typename ... ARGS, int _NDIM=NDIM >
460  std::enable_if_t< _NDIM == 1 >
461  emplace_back( ARGS && ... args )
462  {
463  bufferManipulation::emplaceBack( this->m_dataBuffer, this->size(), std::forward< ARGS >( args ) ... );
464  ++this->m_dims[ 0 ];
465  }
466 
475  template< typename ... ARGS, int _NDIM=NDIM >
476  std::enable_if_t< _NDIM == 1 >
477  emplace( INDEX_TYPE const pos, ARGS && ... args )
478  {
479  bufferManipulation::emplace( this->m_dataBuffer, this->size(), pos, std::forward< ARGS >( args ) ... );
480  ++this->m_dims[ 0 ];
481  }
482 
492  template< typename ITER, int _NDIM=NDIM >
493  std::enable_if_t< _NDIM == 1 >
494  insert( INDEX_TYPE const pos, ITER const first, ITER const last )
495  { this->m_dims[ 0 ] += bufferManipulation::insert( this->m_dataBuffer, this->size(), pos, first, last ); }
496 
502  template< int _NDIM=NDIM >
503  std::enable_if_t< _NDIM == 1 >
505  {
507  --this->m_dims[ 0 ];
508  }
509 
516  template< int _NDIM=NDIM >
517  std::enable_if_t< _NDIM == 1 >
518  erase( INDEX_TYPE const pos )
519  {
520  bufferManipulation::erase( this->m_dataBuffer, this->size(), pos );
521  --this->m_dims[ 0 ];
522  }
523 
525 
530  void setName( std::string const & name )
531  { this->m_dataBuffer.template setName< decltype(*this) >( name ); }
532 
533 #if defined(LVARRAY_USE_TOTALVIEW_OUTPUT) && !defined(__CUDA_ARCH__)
534 
539  static int TV_ttf_display_type( Array const * av )
540  {
541  return ParentClass::TV_ttf_display_type( av );
542  }
543 #endif
544 
545 private:
546 
552  void CalculateStrides()
553  {
555  INDEX_TYPE foldedStrides[ NDIM ];
556 
557  for( int i = 0; i < NDIM; ++i )
558  {
559  foldedStrides[ i ] = 1;
560  for( int j = i + 1; j < NDIM; ++j )
561  {
562  foldedStrides[ i ] *= this->m_dims[ perm[ j ] ];
563  }
564  }
565 
566  for( int i = 0; i < NDIM; ++i )
567  {
568  this->m_strides[ perm[ i ] ] = foldedStrides[ i ];
569  }
570  }
571 
581  template< typename ... ARGS >
583  void resizeDefaultDimension( INDEX_TYPE const newDimLength, ARGS && ... args )
584  {
585  LVARRAY_ERROR_IF_LT( newDimLength, 0 );
586 
587  // If m_singleParameterResizeIndex is the first dimension in memory than a simple 1D resizing is sufficient. The
588  // check if NDIM == 1 is to give the compiler compile time knowledge that this path is always taken for 1D arrays.
589  if( NDIM == 1 || typeManipulation::asArray( PERMUTATION {} )[ 0 ] == this->m_singleParameterResizeIndex )
590  {
591  INDEX_TYPE const oldSize = this->size();
592  this->m_dims[ this->m_singleParameterResizeIndex ] = newDimLength;
593  CalculateStrides();
594  bufferManipulation::resize( this->m_dataBuffer, oldSize, this->size(), std::forward< ARGS >( args )... );
595  return;
596  }
597 
598  // Get the current length and stride of the dimension as well as the size of the whole Array.
599  INDEX_TYPE const curDimLength = this->m_dims[ this->m_singleParameterResizeIndex ];
600  INDEX_TYPE const curDimStride = this->m_strides[ this->m_singleParameterResizeIndex ];
601  INDEX_TYPE const curSize = this->size();
602 
603  // Set the size of the dimension, recalculate the strides and get the new total size.
604  this->m_dims[ this->m_singleParameterResizeIndex ] = newDimLength;
605  CalculateStrides();
606  INDEX_TYPE const newSize = this->size();
607 
608  // If we aren't changing the total size then we can return early.
609  if( newSize == curSize ) return;
610 
611  // If the size is increasing do one thing, if it's decreasing do another.
612  if( newDimLength > curDimLength )
613  {
614  // Reserve space in the buffer but don't initialize the values.
615  bufferManipulation::reserve( this->m_dataBuffer, curSize, newSize );
616  T * const ptr = this->data();
617 
618  // The resizing consists of iterations where each iteration consists of the addition of a
619  // contiguous segment of new values.
620  INDEX_TYPE const valuesToAddPerIteration = curDimStride * ( newDimLength - curDimLength );
621  INDEX_TYPE const valuesToShiftPerIteration = curDimStride * curDimLength;
622  INDEX_TYPE const numIterations = ( newSize - curSize ) / valuesToAddPerIteration;
623 
624  // Iterate backwards over the iterations.
625  for( INDEX_TYPE i = numIterations - 1; i >= 0; --i )
626  {
627  // First shift the values up to make remove for the values of subsequent iterations.
628  // This step is a no-op on the last iteration (i=0).
629  INDEX_TYPE const valuesLeftToInsert = valuesToAddPerIteration * i;
630  T * const startOfShift = ptr + valuesToShiftPerIteration * i;
631  arrayManipulation::shiftUp( startOfShift, valuesToShiftPerIteration, INDEX_TYPE( 0 ), valuesLeftToInsert );
632 
633  // Initialize the new values.
634  T * const startOfNewValues = startOfShift + valuesToShiftPerIteration + valuesLeftToInsert;
635  for( INDEX_TYPE j = 0; j < valuesToAddPerIteration; ++j )
636  {
637  new ( startOfNewValues + j ) T( args ... );
638  }
639  }
640  }
641  else
642  {
643  T * const ptr = this->data();
644 
645  // The resizing consists of iterations where each iteration consists of the removal of a
646  // contiguous segment of new values.
647  INDEX_TYPE const valuesToRemovePerIteration = curDimStride * ( curDimLength - newDimLength );
648  INDEX_TYPE const valuesToShiftPerIteration = curDimStride * newDimLength;
649  INDEX_TYPE const numIterations = ( curSize - newSize ) / valuesToRemovePerIteration;
650 
651  // Iterate over the iterations, skipping the first.
652  for( INDEX_TYPE i = 1; i < numIterations; ++i )
653  {
654  INDEX_TYPE const amountToShift = valuesToRemovePerIteration * i;
655  T * const startOfShift = ptr + valuesToShiftPerIteration * i;
656  arrayManipulation::shiftDown( startOfShift,
657  valuesToShiftPerIteration + amountToShift,
658  amountToShift, amountToShift );
659  }
660 
661  // After the iterations are complete all the values to remove have been moved to the end of the array.
662  // We destroy them here.
663  INDEX_TYPE const totalValuesToRemove = valuesToRemovePerIteration * numIterations;
664  for( INDEX_TYPE i = 0; i < totalValuesToRemove; ++i )
665  {
666  ptr[ newSize + i ].~T();
667  }
668  }
669  }
670 };
671 
675 template< typename >
676 constexpr bool isArray = false;
677 
686 template< typename T,
687  int NDIM,
688  typename PERMUTATION,
689  typename INDEX_TYPE,
690  template< typename > class BUFFER_TYPE >
691 constexpr bool isArray< Array< T, NDIM, PERMUTATION, INDEX_TYPE, BUFFER_TYPE > > = true;
692 
693 namespace internal
694 {
695 
696 // Since Array expects the BUFFER to only except a single template parameter we need to
697 // create an alias for a StackBuffer with a given length.
706 template< typename T,
707  int NDIM,
708  typename PERMUTATION,
709  typename INDEX_TYPE,
710  int LENGTH >
711 struct StackArrayHelper
712 {
717  template< typename U >
718  using BufferType = StackBuffer< U, LENGTH >;
719 
722 };
723 
724 } // namespace internal
725 
734 template< typename T,
735  int NDIM,
736  typename PERMUTATION,
737  typename INDEX_TYPE,
738  int LENGTH >
740 
741 } /* namespace LvArray */
void emplace(BUFFER &buf, std::ptrdiff_t const size, std::ptrdiff_t const pos, ARGS &&... args)
Construct a new value at position pos.
std::enable_if_t< _NDIM==1 > erase(INDEX_TYPE const pos)
Remove the value at the given position.
Definition: Array.hpp:518
void clear()
Sets the size of the Array to zero and destroys all the values.
Definition: Array.hpp:408
void setName(std::string const &name)
Set the name to be displayed whenever the underlying Buffer&#39;s user call back is called.
Definition: Array.hpp:530
std::ptrdiff_t insert(BUFFER &buf, std::ptrdiff_t const size, std::ptrdiff_t const pos, ITER const first, ITER const last)
Insert multiple values into the buffer.
void resize(INDEX_TYPE const newdim)
Resize the default dimension of the Array.
Definition: Array.hpp:389
void reserve(BUFFER &buf, std::ptrdiff_t const size, std::ptrdiff_t const newCapacity)
Reserve space in the buffer for at least the given capacity.
void emplaceBack(BUFFER &buf, std::ptrdiff_t const size, ARGS &&... args)
Construct a new value at the end of the buffer.
Array(Array const &source)
Copy constructor.
Definition: Array.hpp:119
constexpr int getSingleParameterResizeIndex() const
Definition: ArrayView.hpp:408
constexpr bool isValidPermutation(PERMUTATION)
#define LVARRAY_ERROR_IF_LT(lhs, rhs)
Raise a hard error if one value compares less than the other.
Definition: Macros.hpp:282
constexpr NestedViewType toNestedView() const &&=delete
Overload for rvalues that is deleted.
Contains the implementation of LvArray:StackBuffer.
Array(DIMS const ... dims)
Constructor that takes in the dimensions as a variadic parameter list.
Definition: Array.hpp:109
PERMUTATION Permutation
The permutation of the array.
Definition: Array.hpp:71
constexpr bool isArray
True if the template type is an Array.
Definition: Array.hpp:676
void shiftUp(T *const LVARRAY_RESTRICT ptr, std::ptrdiff_t const size, std::ptrdiff_t const index, std::ptrdiff_t const n)
Shift the values in the array at or above the given position up by the given amount. New uninitialized values take their place.
void copyInto(DST_BUFFER &dst, std::ptrdiff_t const dstSize, SRC_BUFFER const &src, std::ptrdiff_t const srcSize)
Copy values from the source buffer into the destination buffer.
Array & operator=(Array &&rhs)
Move assignment operator, performs a shallow copy of rhs.
Definition: Array.hpp:174
constexpr ArrayView< T const, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > toViewConst() const &
Definition: ArrayView.hpp:242
ArrayView< std::remove_reference_t< typeManipulation::NestedViewTypeConst< T > >, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > NestedViewTypeConst
The type when all inner array classes are converted to const views and the inner most view&#39;s values a...
Definition: ArrayView.hpp:93
constexpr ArrayView< T const, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > toViewConst() const &&=delete
Overload for rvalues that is deleted.
void popBack(BUFFER &buf, std::ptrdiff_t const size)
Remove a value from the end of the buffer.
This class serves to provide a "view" of a multidimensional array.
Definition: ArrayView.hpp:67
std::enable_if_t< sizeof ...(DIMS)==NDIM &&typeManipulation::all_of_t< std::is_integral< DIMS > ... >::value > resize(DIMS const ... newDims)
function to resize the array.
Definition: Array.hpp:303
std::enable_if_t< _NDIM==1 > emplace(INDEX_TYPE const pos, ARGS &&... args)
Insert a value into the array constructing it in place.
Definition: Array.hpp:477
std::enable_if_t< _NDIM==1 > emplace_back(ARGS &&... args)
Construct a value in place at the end of the array.
Definition: Array.hpp:461
typeManipulation::CArray< INDEX_TYPE, NDIM > m_dims
the dimensions of the array.
Definition: ArrayView.hpp:653
Array & operator=(Array const &rhs)
Copy assignment operator, performs a deep copy of rhs.
Definition: Array.hpp:154
void reserve(INDEX_TYPE const newCapacity)
Reserve space in the Array to hold at least the given number of values.
Definition: Array.hpp:441
void resizeDefault(INDEX_TYPE const newdim, T const &defaultValue)
Resize the default dimension of the Array.
Definition: Array.hpp:400
void free(BUFFER &buf, std::ptrdiff_t const size)
Destroy the values in the buffer and free it&#39;s memory.
constexpr ArrayView toView() const &
Definition: ArrayView.hpp:235
Contains functions for manipulating buffers.
void setSingleParameterResizeIndex(int const index)
Set the default resize dimension.
Definition: Array.hpp:422
void resizeWithoutInitializationOrDestruction(DIMS const ... newDims)
Resize the array without initializing any new values or destroying any old values. Only safe on POD data, however it is much faster for large allocations.
Definition: Array.hpp:330
std::enable_if_t< _NDIM==1 > insert(INDEX_TYPE const pos, ITER const first, ITER const last)
Insert values into the array at the given position.
Definition: Array.hpp:494
BUFFER_TYPE< T > m_dataBuffer
this data member contains the actual data for the array.
Definition: ArrayView.hpp:659
static constexpr int USD
The unit stride dimension.
Definition: ArrayView.hpp:82
camp::concepts::metalib::all_of< BOOLS ... > all_of
A struct that contains a static constexpr bool value that is true if all of BOOLS are true...
constexpr camp::idx_t getStrideOneDimension(camp::idx_seq< INDICES... >)
void resizeDimension(DIMS const ... newDims)
Resize specific dimensions of the array.
Definition: Array.hpp:361
void move(MemorySpace const space, bool const touch=true) const
Move the Array to the given execution space, optionally touching it.
Definition: ArrayView.hpp:605
The top level namespace.
Definition: Array.hpp:24
ArrayView< std::remove_reference_t< typeManipulation::NestedViewType< T > >, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > NestedViewType
The type when all inner array classes are converted to const views.
Definition: ArrayView.hpp:89
~Array()
Destructor, free&#39;s the data.
Definition: Array.hpp:145
typename internal::StackArrayHelper< T, NDIM, PERMUTATION, INDEX_TYPE, LENGTH >::type StackArray
An alias for a Array backed by a StackBuffer.
Definition: Array.hpp:739
std::enable_if_t< _NDIM==1 > pop_back()
Remove the last value in the array.
Definition: Array.hpp:504
void resize(int const numDims, DIMS_TYPE const *const dims)
Resize the dimensions of the Array to match the given dimensions.
Definition: Array.hpp:277
#define LVARRAY_ERROR_IF_GE(lhs, rhs)
Raise a hard error if one value compares greater than or equal to the other.
Definition: Macros.hpp:267
constexpr camp::idx_t getDimension(camp::idx_seq< INDICES... >)
constexpr ArrayView< T, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > toView() const &&=delete
Overload for rvalues that is deleted.
constexpr NestedViewTypeConst toNestedViewConst() const &&=delete
Overload for rvalues that is deleted.
A wrapper around a compile time c array.
constexpr NestedViewTypeConst toNestedViewConst() const &
Definition: ArrayView.hpp:261
std::string string
String type.
Definition: DataTypes.hpp:131
void shiftDown(T *const LVARRAY_RESTRICT ptr, std::ptrdiff_t const size, std::ptrdiff_t const index, std::ptrdiff_t const n)
Shift the values in the array at or above the given position down by the given amount overwriting the...
constexpr NestedViewType toNestedView() const &
Definition: ArrayView.hpp:254
constexpr CArray< camp::idx_t, sizeof...(INDICES) > asArray(camp::idx_seq< INDICES... >)
#define DISABLE_HD_WARNING
Disable host device warnings.
Definition: Macros.hpp:401
camp::concepts::metalib::all_of_t< TYPES ... > all_of_t
A struct that contains a static constexpr bool value that is true if all of TYPES::value are true...
This class implements the Buffer interface using a c-array.
Definition: StackBuffer.hpp:40
This class provides a fixed dimensional resizeable array interface in addition to an interface simila...
Definition: Array.hpp:55
Array()
default constructor
Definition: Array.hpp:89
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:237
Array(Array &&source)
Move constructor.
Definition: Array.hpp:131
void erase(BUFFER &buf, std::ptrdiff_t const size, std::ptrdiff_t const pos)
Erase a value from the buffer.
LVARRAY_INTEL_CONSTEXPR ArrayView & operator=(ArrayView &&rhs)
Move assignment operator, creates a shallow copy and invalidates the source.
Definition: ArrayView.hpp:192
constexpr void forEachArg(F &&f)
The recursive base case where no argument is provided.
void resize(BUFFER &buf, std::ptrdiff_t const size, std::ptrdiff_t const newSize, ARGS &&... args)
Resize the buffer to the given size.
Contains the implementation of LvArray::ArrayView.
#define LVARRAY_HOST_DEVICE
Mark a function for both host and device usage.
Definition: Macros.hpp:389