Go to the documentation of this file.
21 #ifndef __VectorDual_hpp__
22 #define __VectorDual_hpp__
42 template<
typename T,
typename MemorySpace>
46 template<
typename T,
typename MemorySpace=
void>
81 using hostType =
typename hostViewType::device_type;
110 Kokkos::SpaceAccessibility<execution_space,Kokkos::HostSpace>::accessible;
114 word(hostType::memory_space::name())+
115 word(deviceType::memory_space::name());
290 if(&rhs ==
this)
return *
this;
309 return makeUnique<VectorDual>(*
this);
377 return Kokkos::subview(
dualView_.h_view, Kokkos::make_pair(start,
end));
383 return Kokkos::subview(
dualView_.d_view, Kokkos::make_pair(start,
end));
498 auto srcSize = src.
size();
506 for(
auto& elem:src )
519 if( indices.
size() == 0 )
return true;
521 if( *(indices.end()-1) >=
size() )
return false;
523 auto oldSize = this->
size();
524 auto nextInd = indices.begin();
525 label j = indices[0];
526 for(
label i=indices[0]; i < oldSize; ++i)
528 if( nextInd != indices.end() && i == *nextInd )
551 if(indices.
size() == 0)
return true;
553 auto maxInd = indices.
max();
564 Kokkos::parallel_for(
568 dVals[dIndices[i]]= val;
577 template<
typename s
ide=HostS
ide>
585 if(indices.
size() == 0)
return true;
586 if(indices.
size() != vals.
size())
return false;
588 auto maxInd = indices.
max();
589 auto minInd = indices.
min();
596 if constexpr (std::is_same<side,HostSide>::value )
602 pFlow::algorithms::KOKKOS::fillSelected<T, int32, DefaultHostExecutionSpace>(
618 Kokkos::deep_copy(dVecVals, hVecVals);
622 pFlow::algorithms::KOKKOS::fillSelected<T, int32, execution_space>(
639 template<
typename s
ide=HostS
ide>
643 if(indices.
size() == 0)
return true;
645 auto maxInd =
max(indices);
646 auto minInd =
min(indices);
653 if constexpr (std::is_same<side,HostSide>::value )
668 Kokkos::deep_copy(dVecInd, hVecInd);
683 template<
typename s
ide=HostS
ide>
691 if(indices.
size() == 0)
return true;
692 if(indices.
size() != vals.
size())
return false;
694 auto maxInd =
max(indices);
695 auto minInd =
min(indices);
702 if constexpr (std::is_same<side,HostSide>::value )
722 Kokkos::deep_copy(dVecVals, hVecVals);
723 Kokkos::deep_copy(dVecInd, hVecInd);
808 return dualView_.template need_sync<hostType>();
813 return dualView_.template need_sync<deviceType>();
818 return std::is_same<hostType,deviceType>::value;
904 if( !vecFromFile.
read(is) )
return false;
906 this->
assign(vecFromFile);
930 return vecToFile.
write(os);
934 template<
typename T,
typename memory_space>
945 template<
typename T,
typename memory_space>
949 if( !ovec.
write(os) )
964 #endif //__VectorDual_hpp__
const double vectorGrowthFactor__
INLINE_FUNCTION_H bool empty() const
INLINE_FUNCTION_H void resizeSync(size_t n, const T &val)
typename hostViewType::device_type hostType
typename dualViewType::t_dev deviceViewType
const INLINE_FUNCTION_H hostViewType & hostVector() const
INLINE_FUNCTION_H void syncViews()
INLINE_FUNCTION_H iterator begin()
INLINE_FUNCTION_H hostViewType & hostVectorAll()
typename viewType::memory_space memory_space
VectorDual(size_t cap, size_t n, RESERVE)
INLINE_FUNCTION_H VectorDual * clonePtr() const
INLINE_FUNCTION_H hostViewType hostVector(int32 start, int32 end) const
INLINE_FUNCTION_HD IndexType max() const
INLINE_FUNCTION_H void fill(const T &val)
INLINE_FUNCTION_H void syncToDevice()
INLINE_FUNCTION_H deviceViewType deviceVector(int32 start, int32 end) const
INLINE_FUNCTION_H void resize(size_t n)
VectorDual(const VectorDual &src)
void push_back(const T &val)
VectorDual(const word &name, const Vector< T > &src)
INLINE_FUNCTION_H uniquePtr< VectorDual > clone() const
static const word hdName__
INLINE_FUNCTION_H pointer data()
INLINE_FUNCTION_H reference operator[](label i)
INLINE_FUNCTION_H void copyDeviceToHost(int32 start, int32 end, bool setUpdated=true)
FUNCTION_H void assign(const Vector< T > &src)
FUNCTION_H void assign(size_t n, const T &val)
INLINE_FUNCTION_HD size_t size() const
const INLINE_FUNCTION_H word name() const
INLINE_FUNCTION_H size_t capacity() const
INLINE_FUNCTION_H bool insertSetElement(const Vector< int32 > &indices, const T &val)
INLINE_FUNCTION_H void reserve(size_t cap)
typename deviceViewType::device_type deviceType
INLINE_FUNCTION_H void modifyOnHost()
FUNCTION_H bool read(iIstream &is)
Kokkos::View< T * > deviceViewType1D
INLINE_FUNCTION_H void syncToHost()
const INLINE_FUNCTION_H deviceViewType & deviceVectorAll() const
VectorDual & operator=(const VectorDual &rhs)
const INLINE_FUNCTION_H hostViewType & hostVectorAll() const
INLINE_FUNCTION_H void modifyOnDevice()
VectorDual(const word &name, size_t n, const T &val)
Kokkos::DualView< int8 *, void > dualViewType
deviceViewType deviceSubView_
INLINE_FUNCTION_HD IndexType min() const
INLINE_FUNCTION_H deviceViewType & deviceVectorAll()
INLINE_FUNCTION_H constReference operator[](label i) const
VectorDual(const word &name, size_t n)
VectorDual(const word &name, const VectorDual &src)
INLINE_FUNCTION_H iterator end()
INLINE_FUNCTION_H void resize(size_t n, const T &val)
INLINE_FUNCTION_H void setSize(size_t n)
const HostViewType & hostView() const
typename deviceType::execution_space execution_space
INLINE_FUNCTION_H void clear()
INLINE_FUNCTION_H void updateSubViews() const
INLINE_FUNCTION_H void copyHostToDevice()
INLINE_FUNCTION_H hostViewType & hostVector()
INLINE_FUNCTION_H void syncViews(int32 start, int32 end)
const INLINE_FUNCTION_H deviceViewType & deviceVector() const
INLINE_FUNCTION_H void copyDeviceToHost()
INLINE_FUNCTION_H void changeSize(size_t n, bool actualCap=false)
INLINE_FUNCTION_H VectorType & VectorField()
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
const INLINE_FUNCTION_H VectorType & VectorField() const
#define INLINE_FUNCTION_H
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
static INLINE_FUNCTION_H size_t evalCapacity(size_t n)
VectorDual(const word &name)
INLINE_FUNCTION_H void reallocate(size_t cap)
virtual const word & name() const
INLINE_FUNCTION_H bool deviceRequiresSync() const
T max(const Vector< T, Allocator > &v)
const int8 * constIterator
const int8 & constReference
INLINE_FUNCTION_H bool areViewsSimilar() const
INLINE_FUNCTION_H void resizeSync(size_t n)
Kokkos::View< T *, Kokkos::HostSpace > hostViewType1D
bool write(iOstream &os) const
VectorDual(const Vector< T > &src)
VectorDual(const word &name, size_t cap, size_t n, RESERVE)
constexpr static const char * memoerySpaceName()
INLINE_FUNCTION_H void copyHostToDevice(int32 start, int32 end, bool setUpdated=true)
INLINE_FUNCTION_H deviceViewType & deviceVector()
INLINE_FUNCTION_H constPointer data() const
static const real growthFactor_
#define ioErrorInFile(fileName, lineNumber)
INLINE_FUNCTION_H constIterator end() const
INLINE_FUNCTION_H bool insertSetElement(const int32IndexContainer &indices, const T &val)
INLINE_FUNCTION_H void fillHost(const T &val)
VectorDual(size_t n, const T &val)
FUNCTION_H bool write(iOstream &os) const
const int8 * constPointer
bool deleteElement(const Vector< label > &indices)
INLINE_FUNCTION_H bool hostRequiresSync() const
typename dualViewType::t_host hostViewType
typename dualViewType::host_mirror_space hostMirrorSpace
INLINE_FUNCTION_H size_t size() const
T min(const Vector< T, Allocator > &v)
static constexpr bool isHostAccessible_
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)
hostViewType hostSubView_
INLINE_FUNCTION_H constIterator begin() const
const DeviceViewType & deviceView() const
TypeInfoTemplateNV2("VectorDual", T, memoerySpaceName())
INLINE_FUNCTION_H void fillDevice(const T &val)