Go to the documentation of this file.
22 #ifndef __VectorSingle_hpp__
23 #define __VectorSingle_hpp__
44 template<
typename T,
typename MemorySpace>
48 template<
typename T,
typename MemorySpace=
void>
94 Kokkos::SpaceAccessibility<execution_space,Kokkos::HostSpace>::accessible;
98 return memory_space::name();
245 if(&rhs ==
this)
return *
this;
266 return makeUnique<VectorSingle>(*
this);
322 auto hView = Kokkos::create_mirror_view(
view_);
330 auto hView = Kokkos::create_mirror_view(
view_);
338 auto hView = Kokkos::create_mirror_view(
deviceVector());
346 auto hView = Kokkos::create_mirror_view(
deviceVector());
355 return view_.label();
453 auto srcSize = src.
size();
537 if(indices.
empty())
return true;
538 auto maxInd = indices.
max();
564 if(indices.
size() == 0)
return true;
565 if(indices.
size() != vals.
size())
return false;
567 auto maxInd = indices.
max();
578 copy(dVecVals, hVecVals);
580 using policy = Kokkos::RangePolicy<
582 Kokkos::IndexType<int32> >;
586 Kokkos::parallel_for(
589 dVec(dIndex(i))= dVecVals(i);
600 if(indices.empty())
return true;
602 auto maxInd =
max(indices);
621 copy(dView, hostView);
632 if(indices.
size() == 0)
return true;
633 if(indices.
size() != vals.
size())
return false;
635 auto maxInd =
max(indices);
661 copy(dVecVals, hVecVals);
662 copy(dVecInd, hVecInd);
675 if(numElems == 0 )
return true;
676 auto oldSize =
size_;
677 auto newSize =
size_ + numElems;
688 auto dSubView = Kokkos::subview(
view_, Kokkos::make_pair(oldSize, newSize));
689 copy(dSubView, dVec);
704 template<
bool Enable = true>
705 typename std::enable_if<
726 template<
bool Enable = true>
728 typename std::enable_if_t<
738 template<
bool Enable = true>
740 typename std::enable_if<
750 template<
bool Enable = true>
752 typename std::enable_if<
761 template<
bool Enable = true>
763 typename std::enable_if<
771 template<
bool Enable = true>
773 typename std::enable_if<
780 template<
bool Enable = true>
782 typename std::enable_if<
795 if( !vecFromFile.
read(is) )
return false;
797 this->
assign(vecFromFile);
808 const auto dVec = Kokkos::subview(
view_, Kokkos::make_pair(0,
int(
size_)));
812 return vecToFile.
write(os);
817 template<
typename T,
typename MemorySpace>
828 template<
typename T,
typename MemorySpace>
832 if( !ovec.
write(os) )
849 #endif //__VectorSingle_hpp__
const INLINE_FUNCTION_H auto hostVector() const
const double vectorGrowthFactor__
INLINE_FUNCTION_H auto hostVector()
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)
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_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
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
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