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)
556 size_t newSize = indices.
size();
563 Kokkos::parallel_for(
567 sortedView[i] = dVec[d_indices[i]];
581 if(indices.
size() == 0)
return true;
583 auto maxInd = indices.
max();
594 Kokkos::parallel_for(
598 dVals[dIndices[i]]= val;
607 template<
typename s
ide=HostS
ide>
615 if(indices.
size() == 0)
return true;
616 if(indices.
size() != vals.
size())
return false;
618 auto maxInd = indices.
max();
619 auto minInd = indices.
min();
626 if constexpr (std::is_same<side,HostSide>::value )
632 pFlow::algorithms::KOKKOS::fillSelected<T, int32, DefaultHostExecutionSpace>(
648 Kokkos::deep_copy(dVecVals, hVecVals);
652 pFlow::algorithms::KOKKOS::fillSelected<T, int32, execution_space>(
669 template<
typename s
ide=HostS
ide>
673 if(indices.
size() == 0)
return true;
675 auto maxInd =
max(indices);
676 auto minInd =
min(indices);
683 if constexpr (std::is_same<side,HostSide>::value )
698 Kokkos::deep_copy(dVecInd, hVecInd);
713 template<
typename s
ide=HostS
ide>
721 if(indices.
size() == 0)
return true;
722 if(indices.
size() != vals.
size())
return false;
724 auto maxInd =
max(indices);
725 auto minInd =
min(indices);
732 if constexpr (std::is_same<side,HostSide>::value )
752 Kokkos::deep_copy(dVecVals, hVecVals);
753 Kokkos::deep_copy(dVecInd, hVecInd);
842 return dualView_.template need_sync<hostType>();
847 return dualView_.template need_sync<deviceType>();
852 return std::is_same<hostType,deviceType>::value;
940 if( !vecFromFile.readVector(is,len) )
return false;
942 this->
assign(vecFromFile);
970 Kokkos::deep_copy(mirror,
hostView());
972 return vecToFile.
write(os);
976 template<
typename T,
typename memory_space>
987 template<
typename T,
typename memory_space>
991 if( !ovec.
write(os) )
1006 #endif //__VectorDual_hpp__
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
INLINE_FUNCTION_H void syncViews()
INLINE_FUNCTION_H iterator begin()
#define fatalExit
Fatal exit.
INLINE_FUNCTION_H deviceViewType deviceView(int32 start, int32 end) const
typename viewType::memory_space memory_space
VectorDual(size_t cap, size_t n, RESERVE)
INLINE_FUNCTION_H VectorDual * clonePtr() const
INLINE_FUNCTION_HD IndexType max() const
Max value of indices.
INLINE_FUNCTION_H void fill(const T &val)
INLINE_FUNCTION_H void syncToDevice()
INLINE_FUNCTION_H void copy(const ViewType1D< dType, dProperties... > &dst, const ViewType1D< sType, sProperties... > &src)
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)
T max(const internalField< T, MemorySpace > &iField)
FUNCTION_H void assign(const Vector< T > &src)
FUNCTION_H void assign(size_t n, const T &val)
auto size() const
Size of the vector.
const INLINE_FUNCTION_H deviceViewType & deviceViewAll() const
const INLINE_FUNCTION_H word name() const
INLINE_FUNCTION_H size_t capacity() const
const INLINE_FUNCTION_H deviceViewType & deviceView() 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
1D array (vector) with default device (memory space and execution space)
INLINE_FUNCTION_H void syncToHost()
VectorDual & operator=(const VectorDual &rhs)
INLINE_FUNCTION_H void modifyOnDevice()
VectorDual(const word &name, size_t n, const T &val)
Kokkos::DualView< multiRotatingAxis *, void > dualViewType
deviceViewType deviceSubView_
INLINE_FUNCTION_HD IndexType min() const
Min value of indices.
INLINE_FUNCTION_H constReference operator[](label i) const
VectorDual(const word &name, size_t n)
bool fillSelected(ViewType1D< Type, properties... > view, ViewType1D< indexType, indexProperties... > indices, uint32 numElems, Type val)
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)
Defines an axis of rotation that rotates around itself and rotates around another axis.
Interface class for any input stream
INLINE_FUNCTION_H void sortItems(const int32IndexContainer &indices)
const HostViewType & hostView() const
Return Host veiw.
INLINE_FUNCTION_H deviceViewType & deviceViewAll()
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 void syncViews(int32 start, int32 end)
INLINE_FUNCTION_H void copyDeviceToHost()
const INLINE_FUNCTION_H hostViewType & hostViewAll() const
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
const double vectorGrowthFactor__
#define INLINE_FUNCTION_H
INLINE_FUNCTION_H hostViewType hostView(int32 start, int32 end) const
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
static INLINE_FUNCTION_H size_t evalCapacity(size_t n)
VectorDual(const word &name)
T min(const internalField< T, MemorySpace > &iField)
INLINE_FUNCTION_H void reallocate(size_t cap)
virtual const word & name() const
Return the name of the stream.
INLINE_FUNCTION_H bool deviceRequiresSync() const
INLINE_FUNCTION_H bool areViewsSimilar() const
INLINE_FUNCTION_H void resizeSync(size_t n)
Kokkos::View< T *, Kokkos::HostSpace > hostViewType1D
1D array (vector with host memeory space)
INLINE_FUNCTION_H deviceViewType & deviceView()
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 constPointer data() const
static const real growthFactor_
#define ioErrorInFile(fileName, lineNumber)
Report an error in file operation with supplied fileName and 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
int32 lineNumber() const
Const access to the current stream line number.
bool deleteElement(const Vector< label > &indices)
INLINE_FUNCTION_H bool hostRequiresSync() const
INLINE_FUNCTION_HD auto size() const
Size.
typename dualViewType::t_host hostViewType
typename dualViewType::host_mirror_space hostMirrorSpace
const INLINE_FUNCTION_H hostViewType & hostView() const
Interface class for any output stream.
INLINE_FUNCTION_H size_t size() const
static constexpr bool isHostAccessible_
hostViewType hostSubView_
It holds two vectors of indecis on Host and Device.
INLINE_FUNCTION_H hostViewType & hostViewAll()
INLINE_FUNCTION_H constIterator begin() const
const DeviceViewType & deviceView() const
Return Device view.
FUNCTION_H bool readVector(iIstream &is, size_t len=0)
INLINE_FUNCTION_H hostViewType & hostView()
TypeInfoTemplateNV2("VectorDual", T, memoerySpaceName())
INLINE_FUNCTION_H void fillDevice(const T &val)