Go to the documentation of this file.
22 #ifndef __cudaAlgorithms_hpp__
23 #define __cudaAlgorithms_hpp__
28 #include <thrust/fill.h>
29 #include <thrust/count.h>
30 #include <thrust/scan.h>
31 #include <thrust/sort.h>
32 #include <thrust/extrema.h>
33 #include <thrust/execution_policy.h>
40 namespace pFlow::algorithms::CUDA
43 template<
typename Type>
49 first, first+numElems,
54 template<
typename Type>
56 void fill(Type* first,
int32 numElems,
const Type& val)
58 thrust::fill(thrust::device, first, first+numElems, val);
61 template<
typename Type>
70 LAMBDA_HD(Type& ref){ ref = firstVal+(&ref - first);});
73 template<
typename Type,
typename indexType>
75 void fillSelected(Type* first,
const indexType* indices,
const int32 numElems,
const Type val)
88 template<
typename Type>
90 Type
max(
const Type* first,
int32 numElems)
93 auto* resD = thrust::max_element(
99 cudaMemcpy(&resH, resD,
sizeof(Type),cudaMemcpyDeviceToHost);
103 template<
typename Type>
105 Type
min(
const Type* first,
int32 numElems)
108 auto* resD = thrust::min_element(
113 cudaMemcpy(&resH, resD,
sizeof(Type),cudaMemcpyDeviceToHost);
117 template<
typename Type>
130 template<
typename Type,
typename CompareFunc>
132 void sort(Type* first,
int32 numElems, CompareFunc compare)
143 template<
typename Type,
typename PermuteType>
148 fillSequence(pFirst, numElems,
static_cast<PermuteType
>(0));
153 LAMBDA_HD(
const PermuteType& lhs,
const PermuteType& rhs){
154 return first[lhs]<first[rhs]; });
158 template<
typename Type,
typename DestType>
161 thrust::exclusive_scan(
163 first, first+numElems,
167 template<
typename Type,
typename DestType>
170 thrust::inclusive_scan(
172 first, first+numElems,
182 #endif //__cudaAlgorithms_hpp__
void inclusiveScan(const ViewType1D< Type, properties... > &view, uint32 start, uint32 end, ViewType1D< Type, dProperties... > &dView, uint32 dStart)
void fill(Vector< T, Allocator > &vec, const T &val)
INLINE_FUNCTION_HD bool equal(const box &b1, const box &b2, real tol=smallValue)
auto count_if(const Vector< T, Allocator > &vec, UnaryPredicate p)
T max(const internalField< T, MemorySpace > &iField)
bool fillSelected(ViewType1D< Type, properties... > view, ViewType1D< indexType, indexProperties... > indices, uint32 numElems, Type val)
void permuteSort(const ViewType1D< Type, properties... > &view, uint32 start, uint32 end, ViewType1D< permType, permProperties... > &permuteView, uint32 permStart)
void fill(Vector< T, Allocator > &vec, const T &val)
#define INLINE_FUNCTION_H
auto count(const Vector< T, Allocator > &vec, const T &val)
T min(const internalField< T, MemorySpace > &iField)
void sort(Vector< T, Allocator > &vec)
void sort(Vector< T, Allocator > &vec)
void fillSequence(internalField< T, MemorySpace > &iField, const T &startVal)
void exclusiveScan(const ViewType1D< Type, properties... > &view, uint32 start, uint32 end, ViewType1D< Type, dProperties... > &dView, uint32 dStart)