18 #ifndef QMCPLUSPLUS_VECTOR_SOA_H 19 #define QMCPLUSPLUS_VECTOR_SOA_H 21 #include <type_traits> 33 template<
typename T,
unsigned D,
typename Alloc = aligned_allocator<T>>
103 template<
typename T1>
117 static_assert(std::is_same<T, typename Alloc::value_type>::value,
118 "VectorSoaContainer and Alloc data types must agree!");
120 throw std::runtime_error(
"Resize not allowed on VectorSoaContainer constructed by initialized memory.");
122 size_type n_padded = getAlignedSize<T, Alloc::alignment>(
n);
187 template<
typename CONTAINER>
236 template<
typename T1>
241 *(
_base +
M * i) = rhs[i];
246 template<
typename T1>
278 template<
typename Allocator = Alloc,
typename = IsDualSpace<Allocator>>
284 template<
typename Allocator = Alloc,
typename = IsDualSpace<Allocator>>
290 template<
typename Allocator = Alloc,
typename = IsDualSpace<Allocator>>
296 template<
typename Allocator = Alloc,
typename = IsDualSpace<Allocator>>
303 template<
typename Allocator = Alloc,
typename = IsDualSpace<Allocator>>
308 template<
typename Allocator = Alloc,
typename = IsDualSpace<Allocator>>
315 template<
typename Allocator = Alloc,
typename = IsDualSpace<Allocator>>
318 auto* host_ptr = this->
data();
319 auto offset_from = this->
data(from) - host_ptr;
320 auto offset_to = this->
data(to) - host_ptr;
321 auto nsize = this->
size();
344 template<
typename OtherT,
unsigned OtherD,
typename OtherAlloc>
VectorSoaContainer & operator=(const Vector< TinyVector< T1, D >> &in)
Accessor & operator=(const TinyVector< T1, D > &rhs)
T * getNonConstData() const
return non_const data
void copyOut(Vector< TinyVector< T, D >> &out) const
SoA to AoS : copy to Vector<TinyVector<>>
size_type capacity() const
return the physical size
helper functions for EinsplineSetBuilder
static void updateTo(Allocator &a, value_type *host_ptr, size_t n, size_t offset=0)
~VectorSoaContainer()
destructor
const T * end() const
return the end
const T *restrict device_data(size_type i) const
return the const pointer of the i-th components, device
T * myData
pointer: what type????
T * device_data()
return the base, device
void copyDeviceDataByIndex(unsigned to, unsigned from)
VectorSoaContainer(size_type n)
constructor with size n without initialization
Accessor & operator=(const T1 rhs)
assign value
SoA adaptor class for Vector<TinyVector<T,D> >
static void deviceSideCopyN(Allocator &a, size_t to, size_t n, size_t from)
Accessor(T *a, size_type ng)
static void attachReference(Allocator &from, Allocator &to, std::ptrdiff_t ptr_offset)
So we can write generic tests that work with all QMCPACK allocators.
VectorSoaContainer(const Vector< TinyVector< T1, D >> &in)
constructor with Vector<T1,D>
Accessor operator()(size_type i)
access operator for assignment of the i-th value
T *restrict data(size_type i)
return the pointer of the i-th components
const T * device_data() const
return the base, device
void attachReference(size_type n, size_type n_padded, const CONTAINER &other, T *ptr)
attach to pre-allocated data
VectorSoaContainer(VectorSoaContainer &&in) noexcept
move constructor
VectorSoaContainer & operator=(const VectorSoaContainer &in)
default copy operator
const T * data() const
return the base
void PosSoA2AoS(int nrows, int ncols, const T *restrict iptr, int lda, T *restrict out, int ldb)
General conversion function from SoA[ncols][ldb] to AoS[nrows][ncols].
size_type nGhosts
number of elements + padded
void copyIn(const Vector< TinyVector< T, D >> &in)
AoS to SoA : copy from Vector<TinyVector<>>
VectorSoaContainer & operator=(const T1 in)
need A=0.0;
T * data()
return the base
static void updateFrom(Allocator &a, value_type *host_ptr, size_t n, size_t offset=0)
VectorSoaContainer(T *ptr, size_type n, size_type n_padded)
constructor for a view, attach to pre-allocated data
helper class for operator ()(size_type i) to assign a value
Declaraton of Vector<T,Alloc> Manage memory through Alloc directly and allow referencing an existing ...
const T *restrict data(size_type i) const
return the const pointer of the i-th components
sycl::event copy_n(sycl::queue &aq, const T1 *restrict VA, size_t array_size, T2 *restrict VC, const std::vector< sycl::event > &events)
Alloc mAllocator
allocator
void PosAoS2SoA(int nrows, int ncols, const T *restrict iptr, int lda, T *restrict out, int ldb)
General conversion function from AoS[nrows][ncols] to SoA[ncols][ldb].
void free()
free allocated memory and clear status variables
TinyVector< T, D > AoSElement_t
VectorSoaContainer(const VectorSoaContainer &in)
default copy constructor
T *restrict device_data(size_type i)
return the pointer of the i-th components, device
bool isRefAttached() const
return true if memory is not owned by the container but from outside.
VectorSoaContainer()
default constructor
void resize(size_type n)
resize myData
size_type size() const
return the physical size
void attachReference(size_type n, size_type n_padded, T *ptr)
attach to pre-allocated data
size_type nAllocated
number of elements allocated by myAlloc
const AoSElement_t operator[](size_type i) const
return TinyVector<T,D>
size_type nLocal
number of elements