Go to the documentation of this file.
22 #ifndef __VectorSingle_hpp__
23 #define __VectorSingle_hpp__
46 template<
typename T,
typename MemorySpace>
50 template<
typename T,
typename MemorySpace=
void>
96 Kokkos::SpaceAccessibility<execution_space,Kokkos::HostSpace>::accessible;
100 return memory_space::name();
247 if(&rhs ==
this)
return *
this;
268 return makeUnique<VectorSingle>(*
this);
324 auto hView = Kokkos::create_mirror_view(
view_);
332 auto hView = Kokkos::create_mirror_view(
view_);
340 auto hView = Kokkos::create_mirror_view(
deviceVector());
348 auto hView = Kokkos::create_mirror_view(
deviceVector());
357 return view_.label();
455 auto srcSize = src.
size();
539 if(indices.
empty())
return true;
540 auto maxInd = indices.
max();
564 if(indices.
size() == 0)
570 size_t newSize = indices.
size();
571 viewType sortedView(
"sortedView", newSize);
573 using policy = Kokkos::RangePolicy<
575 Kokkos::IndexType<int32> >;
579 Kokkos::parallel_for(
583 sortedView(i) = d_view(d_indices(i));
601 if(indices.
size() == 0)
return true;
602 if(indices.
size() != vals.
size())
return false;
604 auto maxInd = indices.
max();
616 copy(dVecVals, hVecVals);
618 using policy = Kokkos::RangePolicy<
620 Kokkos::IndexType<int32> >;
624 Kokkos::parallel_for(
627 dVec(dIndex(i))= dVecVals(i);
638 if(indices.empty())
return true;
640 auto maxInd =
max(indices);
659 copy(dView, hostView);
670 if(indices.
size() == 0)
return true;
671 if(indices.
size() != vals.
size())
return false;
673 auto maxInd =
max(indices);
699 copy(dVecVals, hVecVals);
700 copy(dVecInd, hVecInd);
713 if(numElems == 0 )
return true;
714 auto oldSize =
size_;
715 auto newSize =
size_ + numElems;
726 auto dSubView = Kokkos::subview(
view_, Kokkos::make_pair(oldSize, newSize));
727 copy(dSubView, dVec);
742 template<
bool Enable = true>
743 typename std::enable_if<
767 template<
bool Enable = true>
769 typename std::enable_if_t<
779 template<
bool Enable = true>
781 typename std::enable_if<
791 template<
bool Enable = true>
793 typename std::enable_if<
802 template<
bool Enable = true>
804 typename std::enable_if<
812 template<
bool Enable = true>
814 typename std::enable_if<
821 template<
bool Enable = true>
823 typename std::enable_if<
838 if( !vecFromFile.
readVector(is,len) )
return false;
840 this->
assign(vecFromFile);
857 const auto dVec = Kokkos::subview(
view_, Kokkos::make_pair(0,
int(
size_)));
861 return vecToFile.
write(os);
866 template<
typename T,
typename MemorySpace>
877 template<
typename T,
typename MemorySpace>
881 if( !ovec.
write(os) )
898 #endif //__VectorSingle_hpp__
const INLINE_FUNCTION_H auto hostVector() const
const double vectorGrowthFactor__
INLINE_FUNCTION_H auto hostVector()
FUNCTION_H bool readVector(iIstream &is, size_t len=0)
const INLINE_FUNCTION_H VectorType & VectorField() const
VectorSingle(const word &name, size_t n, const T &val)
INLINE_FUNCTION_H void fill(const T &val)
bool readVector(iIstream &is, size_t len=0)
VectorSingle & operator=(const VectorSingle &rhs)
VectorSingle(const word &name, const Vector< T > &src)
INLINE_FUNCTION_H void resize(size_t n, const T &val)
void fill(Vector< T, Allocator > &vec, const T &val)
const INLINE_FUNCTION_H auto hostVectorAll() const
INLINE_FUNCTION_H void sortItems(const int32IndexContainer &indices)
INLINE_FUNCTION_HD IndexType max() const
typename viewType::device_type deviceType
INLINE_FUNCTION_HD size_t empty() const
VectorSingle(const word &name, const VectorSingle &src)
INLINE_FUNCTION_H void setSize(size_t n)
INLINE_FUNCTION_H void assign(const Vector< T > &src)
const INLINE_FUNCTION_H word name() const
INLINE_FUNCTION_H void copy(const ViewType1D< dType, dProperties... > &dst, const ViewType1D< sType, sProperties... > &src)
INLINE_FUNCTION_H void clear()
INLINE_FUNCTION_H bool insertSetElement(const int32IndexContainer &indices, const Vector< T > &vals)
INLINE_FUNCTION_H constPointer data() const
FUNCTION_H bool read(iIstream &is)
INLINE_FUNCTION_H void resize(size_t n)
const INLINE_FUNCTION_H viewType & deviceVectorAll() const
INLINE_FUNCTION_H std::enable_if< isHostAccessible_ &&Enable, constIterator >::type begin() const
INLINE_FUNCTION_H VectorSingle * clonePtr() const
INLINE_FUNCTION_HD size_t size() const
const INLINE_FUNCTION_H viewType & deviceVector() const
INLINE_FUNCTION_H void reallocNoInit(ViewType1D< Type, Properties... > &view, int32 len)
INLINE_FUNCTION_H auto hostVectorAll()
INLINE_FUNCTION_H size_t capacity() const
constexpr static const char * memoerySpaceName()
INLINE_FUNCTION_H uniquePtr< VectorSingle > clone() const
INLINE_FUNCTION_H bool empty() const
INLINE_FUNCTION_H bool append(const VectorSingle &Vec)
Kokkos::View< T * > deviceViewType1D
typename viewType::memory_space memory_space
typename viewType::execution_space execution_space
INLINE_FUNCTION_H bool insertSetElement(const Vector< int32 > &indices, const T &val)
VectorSingle(const word &name)
INLINE_FUNCTION_H std::enable_if< isHostAccessible_ &&Enable, constReference >::type operator[](label i) const
INLINE_FUNCTION_H VectorType & VectorField()
VectorSingle(const word &name, size_t n)
INLINE_FUNCTION_H pointer data()
const HostViewType & hostView() const
VectorSingle(const VectorSingle &src)
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
INLINE_FUNCTION_H void reserve(size_t cap)
INLINE_FUNCTION_H bool insertSetElement(const int32IndexContainer &indices, const T &val)
VectorSingle(const word &name, size_t cap, size_t n, RESERVE)
#define INLINE_FUNCTION_H
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
INLINE_FUNCTION_H std::enable_if< isHostAccessible_ &&Enable, iterator >::type end()
INLINE_FUNCTION_H std::enable_if< isHostAccessible_ &&Enable, reference >::type operator[](label i)
std::enable_if< isHostAccessible_ &&Enable, void >::type push_back(const T &val)
virtual const word & name() const
Return the name of the stream.
T max(const Vector< T, Allocator > &v)
INLINE_FUNCTION_H void updateSubView() const
TypeInfoTemplateNV2("VectorSingle", T, memoerySpaceName())
INLINE_FUNCTION_H void reallocate(size_t cap)
Kokkos::View< T *, Kokkos::HostSpace > hostViewType1D
INLINE_FUNCTION_H bool append(const deviceViewType1D< T > &dVec, size_t numElems)
bool write(iOstream &os) const
VectorSingle(size_t n, const T &val)
INLINE_FUNCTION_H void assign(size_t n, const T &val)
static INLINE_FUNCTION_H size_t evalCapacity(size_t n)
INLINE_FUNCTION_H void changeSize(size_t n, bool actualCap=false)
static const real growthFactor_
FUNCTION_H bool write(iOstream &os) const
INLINE_FUNCTION_H bool insertSetElement(const Vector< int32 > &indices, const Vector< T > &vals)
#define ioErrorInFile(fileName, lineNumber)
Kokkos::View< T *, properties... > ViewType1D
int32 lineNumber() const
Const access to the current stream line number.
INLINE_FUNCTION_H std::enable_if< isHostAccessible_ &&Enable, constIterator >::type end() const
INLINE_FUNCTION_H viewType & deviceVector()
INLINE_FUNCTION_H size_t size() const
INLINE_FUNCTION_H std::enable_if_t< isHostAccessible_ &&Enable, iterator > begin()
static constexpr bool isHostAccessible_
INLINE_FUNCTION_H viewType & deviceVectorAll()
VectorSingle(const Vector< T > &src)
VectorSingle(size_t cap, size_t n, RESERVE)
bool fillSelected(ViewType1D< Type, properties... > view, const ViewType1D< indexType, indexProperties... > indices, const int32 numElems, const Type val, typename std::enable_if_t< areAccessible< typename ViewType1D< Type, properties... >::execution_space, typename ViewType1D< indexType, indexProperties... >::memory_space >(), bool >=true)
INLINE_FUNCTION_H void reallocate(size_t cap, size_t size)
const DeviceViewType & deviceView() const
ViewType1D< realx3, void > viewType