21 #ifndef __ViewAlgorithms_hpp__
22 #define __ViewAlgorithms_hpp__
37 template<
typename T,
typename... properties>
45 using ExecutionSpace =
typename ViewType1D<T, properties...>::execution_space;
47 int32 numElems = end-start;
49 if constexpr( isHostAccessible<ExecutionSpace>())
53 return pFlow::algorithms::STD::count<T,false>(
60 return pFlow::algorithms::KOKKOS::count<T, ExecutionSpace>(
66 template<
typename T,
typename... properties>
75 using ExecutionSpace =
typename ViewType1D<T, properties...>::execution_space;
78 if constexpr( isHostAccessible<ExecutionSpace>())
83 pFlow::algorithms::STD::fill<T,false>(
84 view.data()+
span.first,
91 auto subV = Kokkos::subview(view,
span);
92 Kokkos::deep_copy(subV, val);
95 template<
typename T,
typename... properties>
109 typename... properties>
118 using ExecutionSpace =
typename ViewType1D<Type, properties...>::execution_space;
119 int32 numElems = end-start;
121 if constexpr( isHostAccessible<ExecutionSpace>())
125 pFlow::algorithms::STD::fillSequence<Type,false>(
133 pFlow::algorithms::KOKKOS::fillSequence<Type, ExecutionSpace>(
144 typename... properties,
146 typename... indexProperties>
150 const int32 numElems,
152 typename std::enable_if_t<
159 using ExecutionSpace =
typename ViewType1D<Type, properties...>::execution_space;
161 if constexpr( isHostAccessible<ExecutionSpace>())
165 pFlow::algorithms::STD::fillSelected<Type,indexType,false>(
174 pFlow::algorithms::KOKKOS::fillSelected<Type, indexType, ExecutionSpace>(
185 typename... properties,
187 typename... indexProperties>
194 const int32 numElems ,
195 typename std::enable_if_t<
202 using ExecutionSpace =
typename ViewType1D<Type, properties...>::execution_space;
206 if constexpr( isHostAccessible<ExecutionSpace>())
210 pFlow::algorithms::STD::fillSelected<Type,indexType,false>(
221 pFlow::algorithms::KOKKOS::fillSelected<Type, indexType, ExecutionSpace>(
232 template<
typename T,
typename... properties>
240 using ExecutionSpace =
typename ViewType1D<T, properties...>::execution_space;
242 int32 numElems = end-start;
244 if constexpr( isHostAccessible<ExecutionSpace>())
249 pFlow::algorithms::STD::min<T,false>(
256 pFlow::algorithms::KOKKOS::min<T, ExecutionSpace>(
261 template<
typename T,
typename... properties>
269 using ExecutionSpace =
typename ViewType1D<T, properties...>::execution_space;
271 int32 numElems = end-start;
273 if constexpr( isHostAccessible<ExecutionSpace>())
278 pFlow::algorithms::STD::max<T,false>(
285 pFlow::algorithms::KOKKOS::max<T, ExecutionSpace>(
292 typename... dProperties,
294 typename... sProperties>
301 Kokkos::deep_copy(dst,src);
306 typename... dProperties,
308 typename... sProperties>
319 range sSpan(sStart,sEnd);
320 range dSpan(dStart,dStart+(sEnd-sStart));
322 auto srcSub = Kokkos::subview(src, sSpan);
323 auto dstSub = Kokkos::subview(dst, dSpan);
325 Kokkos::deep_copy(dstSub,srcSub);
331 typename... sProperties>
340 auto subV = Kokkos::subview(src,
span);
342 Kokkos::deep_copy(dstView,subV);
343 dst = *dstView.data();
347 template<
typename T,
typename... properties>
355 using ExecutionSpace =
typename ViewType1D<T, properties...>::execution_space;
357 int32 numElems = end-start;
359 if constexpr( isHostAccessible<ExecutionSpace>())
363 pFlow::algorithms::STD::sort<T,false>(
370 pFlow::algorithms::STD::sort<T,true>(
379 pFlow::algorithms::CUDA::sort<T>(
383 static_assert(
"sort on device is not defined!");
390 template<
typename T,
typename... properties,
typename CompareFunc>
399 using ExecutionSpace =
typename ViewType1D<T, properties...>::execution_space;
401 int32 numElems = end-start;
403 if constexpr( isHostAccessible<ExecutionSpace>())
407 pFlow::algorithms::STD::sort<T,CompareFunc,false>(
415 pFlow::algorithms::STD::sort<T,CompareFunc,true>(
425 pFlow::algorithms::CUDA::sort<T, CompareFunc>(
430 static_assert(
"sort on device is not defined!");
439 typename... properties,
441 typename... permProperties>
448 typename std::enable_if_t<
454 using ExecutionSpace =
typename ViewType1D<Type, properties...>::execution_space;
456 int32 numElems = end-start;
458 if constexpr( isHostAccessible<ExecutionSpace>())
462 pFlow::algorithms::STD::permuteSort<Type,permType,false>(
464 permuteView.data()+permStart,
470 pFlow::algorithms::STD::permuteSort<Type,permType,true>(
472 permuteView.data()+permStart,
482 permuteView.data()+permStart,
485 static_assert(
"sort on device is not defined!");
493 typename... properties>
502 if(end<=start)
return -1;
515 typename... properties,
517 typename... dProperties>
524 typename std::enable_if_t<
530 using ExecutionSpace =
typename ViewType1D<Type, properties...>::execution_space;
532 int32 numElems = end-start;
533 if constexpr( isHostAccessible<ExecutionSpace>())
537 pFlow::algorithms::STD::exclusiveScan<Type,dType,false>(
545 pFlow::algorithms::KOKKOS::exclusiveScan<Type,dType,ExecutionSpace>(
554 typename... properties,
556 typename... dProperties>
563 typename std::enable_if_t<
569 using ExecutionSpace =
typename ViewType1D<Type, properties...>::execution_space;
571 int32 numElems = end-start;
572 if constexpr( isHostAccessible<ExecutionSpace>())
576 pFlow::algorithms::STD::inclusiveScan<Type,dType,false>(
584 pFlow::algorithms::KOKKOS::inclusiveScan<Type,dType,ExecutionSpace>(
593 #endif // Viewalgorithms