44 #ifndef KOKKOS_PARALLEL_REDUCE_HPP
45 #define KOKKOS_PARALLEL_REDUCE_HPP
47 #include <Kokkos_NumericTraits.hpp>
51 template<
class T,
class Enable =
void>
52 struct is_reducer_type {
58 struct is_reducer_type<T,typename std::enable_if<
59 std::is_same<typename std::remove_cv<T>::type,
60 typename std::remove_cv<typename T::reducer>::type>::value
65 template<
class Scalar,
class Space>
70 typedef typename std::remove_cv<Scalar>::type value_type;
79 KOKKOS_INLINE_FUNCTION
80 Sum(value_type& value_): value(&value_) {}
82 KOKKOS_INLINE_FUNCTION
83 Sum(
const result_view_type& value_): value(value_.data()) {}
86 KOKKOS_INLINE_FUNCTION
87 void join(value_type& dest,
const value_type& src)
const {
91 KOKKOS_INLINE_FUNCTION
92 void join(
volatile value_type& dest,
const volatile value_type& src)
const {
96 KOKKOS_INLINE_FUNCTION
97 void init( value_type& val)
const {
98 val = reduction_identity<value_type>::sum();
101 KOKKOS_INLINE_FUNCTION
102 value_type& reference()
const {
106 KOKKOS_INLINE_FUNCTION
107 result_view_type view()
const {
108 return result_view_type(value);
112 template<
class Scalar,
class Space>
116 typedef Prod reducer;
117 typedef typename std::remove_cv<Scalar>::type value_type;
126 KOKKOS_INLINE_FUNCTION
127 Prod(value_type& value_): value(&value_) {}
129 KOKKOS_INLINE_FUNCTION
130 Prod(
const result_view_type& value_): value(value_.data()) {}
133 KOKKOS_INLINE_FUNCTION
134 void join(value_type& dest,
const value_type& src)
const {
138 KOKKOS_INLINE_FUNCTION
139 void join(
volatile value_type& dest,
const volatile value_type& src)
const {
143 KOKKOS_INLINE_FUNCTION
144 void init( value_type& val)
const {
145 val = reduction_identity<value_type>::prod();
148 KOKKOS_INLINE_FUNCTION
149 value_type& reference()
const {
153 KOKKOS_INLINE_FUNCTION
154 result_view_type view()
const {
155 return result_view_type(value);
159 template<
class Scalar,
class Space>
164 typedef typename std::remove_cv<Scalar>::type value_type;
173 KOKKOS_INLINE_FUNCTION
174 Min(value_type& value_): value(&value_) {}
176 KOKKOS_INLINE_FUNCTION
177 Min(
const result_view_type& value_): value(value_.data()) {}
180 KOKKOS_INLINE_FUNCTION
181 void join(value_type& dest,
const value_type& src)
const {
186 KOKKOS_INLINE_FUNCTION
187 void join(
volatile value_type& dest,
const volatile value_type& src)
const {
192 KOKKOS_INLINE_FUNCTION
193 void init( value_type& val)
const {
194 val = reduction_identity<value_type>::min();
197 KOKKOS_INLINE_FUNCTION
198 value_type& reference()
const {
202 KOKKOS_INLINE_FUNCTION
203 result_view_type view()
const {
204 return result_view_type(value);
208 template<
class Scalar,
class Space>
213 typedef typename std::remove_cv<Scalar>::type value_type;
222 KOKKOS_INLINE_FUNCTION
223 Max(value_type& value_): value(&value_) {}
225 KOKKOS_INLINE_FUNCTION
226 Max(
const result_view_type& value_): value(value_.data()) {}
229 KOKKOS_INLINE_FUNCTION
230 void join(value_type& dest,
const value_type& src)
const {
235 KOKKOS_INLINE_FUNCTION
236 void join(
volatile value_type& dest,
const volatile value_type& src)
const {
242 KOKKOS_INLINE_FUNCTION
243 void init( value_type& val)
const {
244 val = reduction_identity<value_type>::max();
247 KOKKOS_INLINE_FUNCTION
248 value_type& reference()
const {
252 KOKKOS_INLINE_FUNCTION
253 result_view_type view()
const {
254 return result_view_type(value);
258 template<
class Scalar,
class Space>
262 typedef LAnd reducer;
263 typedef typename std::remove_cv<Scalar>::type value_type;
272 KOKKOS_INLINE_FUNCTION
273 LAnd(value_type& value_): value(&value_) {}
275 KOKKOS_INLINE_FUNCTION
276 LAnd(
const result_view_type& value_): value(value_.data()) {}
278 KOKKOS_INLINE_FUNCTION
279 void join(value_type& dest,
const value_type& src)
const {
283 KOKKOS_INLINE_FUNCTION
284 void join(
volatile value_type& dest,
const volatile value_type& src)
const {
288 KOKKOS_INLINE_FUNCTION
289 void init( value_type& val)
const {
290 val = reduction_identity<value_type>::land();
293 KOKKOS_INLINE_FUNCTION
294 value_type& reference()
const {
298 KOKKOS_INLINE_FUNCTION
299 result_view_type view()
const {
300 return result_view_type(value);
304 template<
class Scalar,
class Space>
309 typedef typename std::remove_cv<Scalar>::type value_type;
318 KOKKOS_INLINE_FUNCTION
319 LOr(value_type& value_): value(&value_) {}
321 KOKKOS_INLINE_FUNCTION
322 LOr(
const result_view_type& value_): value(value_.data()) {}
325 KOKKOS_INLINE_FUNCTION
326 void join(value_type& dest,
const value_type& src)
const {
330 KOKKOS_INLINE_FUNCTION
331 void join(
volatile value_type& dest,
const volatile value_type& src)
const {
335 KOKKOS_INLINE_FUNCTION
336 void init( value_type& val)
const {
337 val = reduction_identity<value_type>::lor();
340 KOKKOS_INLINE_FUNCTION
341 value_type& reference()
const {
345 KOKKOS_INLINE_FUNCTION
346 result_view_type view()
const {
347 return result_view_type(value);
351 template<
class Scalar,
class Space>
355 typedef BAnd reducer;
356 typedef typename std::remove_cv<Scalar>::type value_type;
365 KOKKOS_INLINE_FUNCTION
366 BAnd(value_type& value_): value(&value_) {}
368 KOKKOS_INLINE_FUNCTION
369 BAnd(
const result_view_type& value_): value(value_.data()) {}
372 KOKKOS_INLINE_FUNCTION
373 void join(value_type& dest,
const value_type& src)
const {
377 KOKKOS_INLINE_FUNCTION
378 void join(
volatile value_type& dest,
const volatile value_type& src)
const {
382 KOKKOS_INLINE_FUNCTION
383 void init( value_type& val)
const {
384 val = reduction_identity<value_type>::band();
387 KOKKOS_INLINE_FUNCTION
388 value_type& reference()
const {
392 KOKKOS_INLINE_FUNCTION
393 result_view_type view()
const {
394 return result_view_type(value);
398 template<
class Scalar,
class Space>
403 typedef typename std::remove_cv<Scalar>::type value_type;
412 KOKKOS_INLINE_FUNCTION
413 BOr(value_type& value_): value(&value_) {}
415 KOKKOS_INLINE_FUNCTION
416 BOr(
const result_view_type& value_): value(value_.data()) {}
419 KOKKOS_INLINE_FUNCTION
420 void join(value_type& dest,
const value_type& src)
const {
424 KOKKOS_INLINE_FUNCTION
425 void join(
volatile value_type& dest,
const volatile value_type& src)
const {
429 KOKKOS_INLINE_FUNCTION
430 void init( value_type& val)
const {
431 val = reduction_identity<value_type>::bor();
434 KOKKOS_INLINE_FUNCTION
435 value_type& reference()
const {
439 KOKKOS_INLINE_FUNCTION
440 result_view_type view()
const {
441 return result_view_type(value);
445 template<
class Scalar,
class Index>
446 struct ValLocScalar {
450 KOKKOS_INLINE_FUNCTION
451 void operator = (
const ValLocScalar& rhs) {
456 KOKKOS_INLINE_FUNCTION
457 void operator = (
const volatile ValLocScalar& rhs)
volatile {
463 template<
class Scalar,
class Index,
class Space>
466 typedef typename std::remove_cv<Scalar>::type scalar_type;
467 typedef typename std::remove_cv<Index>::type index_type;
471 typedef MinLoc reducer;
472 typedef ValLocScalar<scalar_type,index_type> value_type;
481 KOKKOS_INLINE_FUNCTION
482 MinLoc(value_type& value_): value(&value_) {}
484 KOKKOS_INLINE_FUNCTION
485 MinLoc(
const result_view_type& value_): value(value_.data()) {}
489 KOKKOS_INLINE_FUNCTION
490 void join(value_type& dest,
const value_type& src)
const {
491 if ( src.val < dest.val )
495 KOKKOS_INLINE_FUNCTION
496 void join(
volatile value_type& dest,
const volatile value_type& src)
const {
497 if ( src.val < dest.val )
501 KOKKOS_INLINE_FUNCTION
502 void init( value_type& val)
const {
503 val.val = reduction_identity<scalar_type>::min();
504 val.loc = reduction_identity<index_type>::min();
507 KOKKOS_INLINE_FUNCTION
508 value_type& reference()
const {
512 KOKKOS_INLINE_FUNCTION
513 result_view_type view()
const {
514 return result_view_type(value);
518 template<
class Scalar,
class Index,
class Space>
521 typedef typename std::remove_cv<Scalar>::type scalar_type;
522 typedef typename std::remove_cv<Index>::type index_type;
526 typedef MaxLoc reducer;
527 typedef ValLocScalar<scalar_type,index_type> value_type;
536 KOKKOS_INLINE_FUNCTION
537 MaxLoc(value_type& value_): value(&value_) {}
539 KOKKOS_INLINE_FUNCTION
540 MaxLoc(
const result_view_type& value_): value(value_.data()) {}
543 KOKKOS_INLINE_FUNCTION
544 void join(value_type& dest,
const value_type& src)
const {
545 if ( src.val > dest.val )
549 KOKKOS_INLINE_FUNCTION
550 void join(
volatile value_type& dest,
const volatile value_type& src)
const {
551 if ( src.val > dest.val )
555 KOKKOS_INLINE_FUNCTION
556 void init( value_type& val)
const {
557 val.val = reduction_identity<scalar_type>::max();;
558 val.loc = reduction_identity<index_type>::min();
561 KOKKOS_INLINE_FUNCTION
562 value_type& reference()
const {
566 KOKKOS_INLINE_FUNCTION
567 result_view_type view()
const {
568 return result_view_type(value);
572 template<
class Scalar>
573 struct MinMaxScalar {
574 Scalar min_val,max_val;
576 KOKKOS_INLINE_FUNCTION
577 void operator = (
const MinMaxScalar& rhs) {
578 min_val = rhs.min_val;
579 max_val = rhs.max_val;
582 KOKKOS_INLINE_FUNCTION
583 void operator = (
const volatile MinMaxScalar& rhs)
volatile {
584 min_val = rhs.min_val;
585 max_val = rhs.max_val;
589 template<
class Scalar,
class Space>
592 typedef typename std::remove_cv<Scalar>::type scalar_type;
596 typedef MinMax reducer;
597 typedef MinMaxScalar<scalar_type> value_type;
606 KOKKOS_INLINE_FUNCTION
607 MinMax(value_type& value_): value(&value_) {}
609 KOKKOS_INLINE_FUNCTION
610 MinMax(
const result_view_type& value_): value(value_.data()) {}
613 KOKKOS_INLINE_FUNCTION
614 void join(value_type& dest,
const value_type& src)
const {
615 if ( src.min_val < dest.min_val ) {
616 dest.min_val = src.min_val;
618 if ( src.max_val > dest.max_val ) {
619 dest.max_val = src.max_val;
623 KOKKOS_INLINE_FUNCTION
624 void join(
volatile value_type& dest,
const volatile value_type& src)
const {
625 if ( src.min_val < dest.min_val ) {
626 dest.min_val = src.min_val;
628 if ( src.max_val > dest.max_val ) {
629 dest.max_val = src.max_val;
633 KOKKOS_INLINE_FUNCTION
634 void init( value_type& val)
const {
635 val.max_val = reduction_identity<scalar_type>::max();;
636 val.min_val = reduction_identity<scalar_type>::min();
639 KOKKOS_INLINE_FUNCTION
640 value_type& reference()
const {
644 KOKKOS_INLINE_FUNCTION
645 result_view_type view()
const {
646 return result_view_type(value);
650 template<
class Scalar,
class Index>
651 struct MinMaxLocScalar {
652 Scalar min_val,max_val;
653 Index min_loc,max_loc;
655 KOKKOS_INLINE_FUNCTION
656 void operator = (
const MinMaxLocScalar& rhs) {
657 min_val = rhs.min_val;
658 min_loc = rhs.min_loc;
659 max_val = rhs.max_val;
660 max_loc = rhs.max_loc;
663 KOKKOS_INLINE_FUNCTION
664 void operator = (
const volatile MinMaxLocScalar& rhs)
volatile {
665 min_val = rhs.min_val;
666 min_loc = rhs.min_loc;
667 max_val = rhs.max_val;
668 max_loc = rhs.max_loc;
672 template<
class Scalar,
class Index,
class Space>
675 typedef typename std::remove_cv<Scalar>::type scalar_type;
676 typedef typename std::remove_cv<Index>::type index_type;
680 typedef MinMaxLoc reducer;
681 typedef MinMaxLocScalar<scalar_type,index_type> value_type;
690 KOKKOS_INLINE_FUNCTION
691 MinMaxLoc(value_type& value_): value(&value_) {}
693 KOKKOS_INLINE_FUNCTION
694 MinMaxLoc(
const result_view_type& value_): value(value_.data()) {}
697 KOKKOS_INLINE_FUNCTION
698 void join(value_type& dest,
const value_type& src)
const {
699 if ( src.min_val < dest.min_val ) {
700 dest.min_val = src.min_val;
701 dest.min_loc = src.min_loc;
703 if ( src.max_val > dest.max_val ) {
704 dest.max_val = src.max_val;
705 dest.max_loc = src.max_loc;
709 KOKKOS_INLINE_FUNCTION
710 void join(
volatile value_type& dest,
const volatile value_type& src)
const {
711 if ( src.min_val < dest.min_val ) {
712 dest.min_val = src.min_val;
713 dest.min_loc = src.min_loc;
715 if ( src.max_val > dest.max_val ) {
716 dest.max_val = src.max_val;
717 dest.max_loc = src.max_loc;
721 KOKKOS_INLINE_FUNCTION
722 void init( value_type& val)
const {
723 val.max_val = reduction_identity<scalar_type>::max();;
724 val.min_val = reduction_identity<scalar_type>::min();
725 val.max_loc = reduction_identity<index_type>::min();
726 val.min_loc = reduction_identity<index_type>::min();
729 KOKKOS_INLINE_FUNCTION
730 value_type& reference()
const {
734 KOKKOS_INLINE_FUNCTION
735 result_view_type view()
const {
736 return result_view_type(value);
743 template<
class T,
class ReturnType ,
class ValueTraits>
744 struct ParallelReduceReturnValue;
746 template<
class ReturnType ,
class FunctorType >
747 struct ParallelReduceReturnValue<typename std::enable_if<Kokkos::is_view<ReturnType>::value>::type,
ReturnType, FunctorType> {
749 typedef InvalidType reducer_type;
751 typedef typename return_type::value_type value_type_scalar;
752 typedef typename return_type::value_type*
const value_type_array;
754 typedef typename if_c<return_type::rank==0,value_type_scalar,value_type_array>::type value_type;
756 static return_type& return_value(
ReturnType& return_val,
const FunctorType&) {
761 template<
class ReturnType ,
class FunctorType>
762 struct ParallelReduceReturnValue<typename std::enable_if<
763 !Kokkos::is_view<ReturnType>::value &&
764 (!std::is_array<ReturnType>::value && !std::is_pointer<ReturnType>::value) &&
765 !Kokkos::is_reducer_type<ReturnType>::value
769 , Kokkos::MemoryUnmanaged
772 typedef InvalidType reducer_type;
774 typedef typename return_type::value_type value_type;
776 static return_type return_value(
ReturnType& return_val,
const FunctorType&) {
777 return return_type(&return_val);
781 template<
class ReturnType ,
class FunctorType>
782 struct ParallelReduceReturnValue<typename std::enable_if<
783 (is_array<ReturnType>::value || std::is_pointer<ReturnType>::value)
787 , Kokkos::MemoryUnmanaged
790 typedef InvalidType reducer_type;
792 typedef typename return_type::value_type value_type[];
794 static return_type return_value(
ReturnType& return_val,
795 const FunctorType& functor) {
796 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE
797 return return_type(return_val,functor.value_count);
799 if ( is_array<ReturnType>::value )
800 return return_type(return_val);
802 return return_type(return_val,functor.value_count);
807 template<
class ReturnType ,
class FunctorType>
808 struct ParallelReduceReturnValue<typename std::enable_if<
809 Kokkos::is_reducer_type<ReturnType>::value
813 typedef typename return_type::value_type value_type;
815 static return_type return_value(
ReturnType& return_val,
816 const FunctorType& functor) {
821 template<
class T,
class ReturnType ,
class FunctorType>
822 struct ParallelReducePolicyType;
824 template<
class PolicyType ,
class FunctorType >
825 struct ParallelReducePolicyType<typename std::enable_if<Kokkos::Impl::is_execution_policy<PolicyType>::value>::type, PolicyType,FunctorType> {
827 typedef PolicyType policy_type;
828 static PolicyType policy(
const PolicyType& policy_) {
833 template<
class PolicyType ,
class FunctorType >
834 struct ParallelReducePolicyType<typename std::enable_if<std::is_integral<PolicyType>::value>::type, PolicyType,FunctorType> {
836 Impl::FunctorPolicyExecutionSpace< FunctorType , void >::execution_space
841 static policy_type policy(
const PolicyType& policy_) {
842 return policy_type(0,policy_);
847 template<
class FunctorType,
class ExecPolicy,
class ValueType,
class ExecutionSpace>
848 struct ParallelReduceFunctorType {
849 typedef FunctorType functor_type;
850 static const functor_type& functor(
const functor_type& functor) {
855 template<
class PolicyType,
class FunctorType,
class ReturnType >
856 struct ParallelReduceAdaptor {
857 typedef Impl::ParallelReduceReturnValue<void,ReturnType,FunctorType> return_value_adapter;
858 #ifdef KOKKOS_IMPL_NEED_FUNCTOR_WRAPPER
859 typedef Impl::ParallelReduceFunctorType<FunctorType,PolicyType,
860 typename return_value_adapter::value_type,
861 typename PolicyType::execution_space> functor_adaptor;
864 void execute(
const std::string& label,
865 const PolicyType& policy,
866 const FunctorType& functor,
868 #if defined(KOKKOS_ENABLE_PROFILING)
870 if(Kokkos::Profiling::profileLibraryLoaded()) {
871 Kokkos::Impl::ParallelConstructName<FunctorType, typename PolicyType::work_tag> name(label);
872 Kokkos::Profiling::beginParallelReduce(name.get(), 0, &kpID);
876 Kokkos::Impl::shared_allocation_tracking_disable();
877 #ifdef KOKKOS_IMPL_NEED_FUNCTOR_WRAPPER
878 Impl::ParallelReduce<typename functor_adaptor::functor_type, PolicyType, typename return_value_adapter::reducer_type >
879 closure(functor_adaptor::functor(functor),
881 return_value_adapter::return_value(return_value,functor));
883 Impl::ParallelReduce<FunctorType, PolicyType, typename return_value_adapter::reducer_type >
886 return_value_adapter::return_value(return_value,functor));
888 Kokkos::Impl::shared_allocation_tracking_enable();
891 #if defined(KOKKOS_ENABLE_PROFILING)
892 if(Kokkos::Profiling::profileLibraryLoaded()) {
893 Kokkos::Profiling::endParallelReduce(kpID);
952 template<
class PolicyType,
class FunctorType,
class ReturnType >
955 const PolicyType& policy,
956 const FunctorType& functor,
958 typename Impl::enable_if<
959 Kokkos::Impl::is_execution_policy<PolicyType>::value
961 Impl::ParallelReduceAdaptor<PolicyType,FunctorType,ReturnType>::execute(label,policy,functor,return_value);
964 template<
class PolicyType,
class FunctorType,
class ReturnType >
967 const FunctorType& functor,
969 typename Impl::enable_if<
970 Kokkos::Impl::is_execution_policy<PolicyType>::value
972 Impl::ParallelReduceAdaptor<PolicyType,FunctorType,ReturnType>::execute(
"",policy,functor,return_value);
975 template<
class FunctorType,
class ReturnType >
978 const FunctorType& functor,
980 typedef typename Impl::ParallelReducePolicyType<void,size_t,FunctorType>::policy_type policy_type;
981 Impl::ParallelReduceAdaptor<policy_type,FunctorType,ReturnType>::execute(
"",policy_type(0,policy),functor,return_value);
984 template<
class FunctorType,
class ReturnType >
987 const size_t& policy,
988 const FunctorType& functor,
990 typedef typename Impl::ParallelReducePolicyType<void,size_t,FunctorType>::policy_type policy_type;
991 Impl::ParallelReduceAdaptor<policy_type,FunctorType,ReturnType>::execute(label,policy_type(0,policy),functor,return_value);
996 template<
class PolicyType,
class FunctorType,
class ReturnType >
999 const PolicyType& policy,
1000 const FunctorType& functor,
1002 typename Impl::enable_if<
1003 Kokkos::Impl::is_execution_policy<PolicyType>::value
1006 Impl::ParallelReduceAdaptor<PolicyType,FunctorType,ReturnType>::execute(label,policy,functor,return_value_impl);
1009 template<
class PolicyType,
class FunctorType,
class ReturnType >
1012 const FunctorType& functor,
1014 typename Impl::enable_if<
1015 Kokkos::Impl::is_execution_policy<PolicyType>::value
1018 Impl::ParallelReduceAdaptor<PolicyType,FunctorType,ReturnType>::execute(
"",policy,functor,return_value_impl);
1021 template<
class FunctorType,
class ReturnType >
1024 const FunctorType& functor,
1026 typedef typename Impl::ParallelReducePolicyType<void,size_t,FunctorType>::policy_type policy_type;
1028 Impl::ParallelReduceAdaptor<policy_type,FunctorType,ReturnType>::execute(
"",policy_type(0,policy),functor,return_value_impl);
1031 template<
class FunctorType,
class ReturnType >
1034 const size_t& policy,
1035 const FunctorType& functor,
1037 typedef typename Impl::ParallelReducePolicyType<void,size_t,FunctorType>::policy_type policy_type;
1039 Impl::ParallelReduceAdaptor<policy_type,FunctorType,ReturnType>::execute(label,policy_type(0,policy),functor,return_value_impl);
1044 template<
class PolicyType,
class FunctorType>
1047 const PolicyType& policy,
1048 const FunctorType& functor,
1049 typename Impl::enable_if<
1050 Kokkos::Impl::is_execution_policy<PolicyType>::value
1052 typedef Kokkos::Impl::FunctorValueTraits< FunctorType , void > ValueTraits ;
1053 typedef typename Kokkos::Impl::if_c< (ValueTraits::StaticValueSize != 0)
1054 ,
typename ValueTraits::value_type
1055 ,
typename ValueTraits::pointer_type
1056 >::type value_type ;
1058 static_assert(Impl::FunctorAnalysis<Impl::FunctorPatternInterface::REDUCE,PolicyType,FunctorType>::
1059 has_final_member_function,
"Calling parallel_reduce without either return value or final function.");
1063 , Kokkos::MemoryUnmanaged
1065 result_view_type result_view ;
1067 Impl::ParallelReduceAdaptor<PolicyType,FunctorType,result_view_type>::execute(label,policy,functor,result_view);
1070 template<
class PolicyType,
class FunctorType >
1073 const FunctorType& functor,
1074 typename Impl::enable_if<
1075 Kokkos::Impl::is_execution_policy<PolicyType>::value
1077 typedef Kokkos::Impl::FunctorValueTraits< FunctorType , void > ValueTraits ;
1078 typedef typename Kokkos::Impl::if_c< (ValueTraits::StaticValueSize != 0)
1079 ,
typename ValueTraits::value_type
1080 ,
typename ValueTraits::pointer_type
1081 >::type value_type ;
1083 static_assert(Impl::FunctorAnalysis<Impl::FunctorPatternInterface::REDUCE,PolicyType,FunctorType>::
1084 has_final_member_function,
"Calling parallel_reduce without either return value or final function.");
1088 , Kokkos::MemoryUnmanaged
1090 result_view_type result_view ;
1092 Impl::ParallelReduceAdaptor<PolicyType,FunctorType,result_view_type>::execute(
"",policy,functor,result_view);
1095 template<
class FunctorType >
1098 const FunctorType& functor) {
1099 typedef typename Impl::ParallelReducePolicyType<void,size_t,FunctorType>::policy_type policy_type;
1100 typedef Kokkos::Impl::FunctorValueTraits< FunctorType , void > ValueTraits ;
1101 typedef typename Kokkos::Impl::if_c< (ValueTraits::StaticValueSize != 0)
1102 ,
typename ValueTraits::value_type
1103 ,
typename ValueTraits::pointer_type
1104 >::type value_type ;
1106 static_assert(Impl::FunctorAnalysis<Impl::FunctorPatternInterface::REDUCE,RangePolicy<>,FunctorType>::
1107 has_final_member_function,
"Calling parallel_reduce without either return value or final function.");
1111 , Kokkos::MemoryUnmanaged
1113 result_view_type result_view ;
1115 Impl::ParallelReduceAdaptor<policy_type,FunctorType,result_view_type>::execute(
"",policy_type(0,policy),functor,result_view);
1118 template<
class FunctorType>
1121 const size_t& policy,
1122 const FunctorType& functor) {
1123 typedef typename Impl::ParallelReducePolicyType<void,size_t,FunctorType>::policy_type policy_type;
1124 typedef Kokkos::Impl::FunctorValueTraits< FunctorType , void > ValueTraits ;
1125 typedef typename Kokkos::Impl::if_c< (ValueTraits::StaticValueSize != 0)
1126 ,
typename ValueTraits::value_type
1127 ,
typename ValueTraits::pointer_type
1128 >::type value_type ;
1130 static_assert(Impl::FunctorAnalysis<Impl::FunctorPatternInterface::REDUCE,RangePolicy<>,FunctorType>::
1131 has_final_member_function,
"Calling parallel_reduce without either return value or final function.");
1135 , Kokkos::MemoryUnmanaged
1137 result_view_type result_view ;
1139 Impl::ParallelReduceAdaptor<policy_type,FunctorType,result_view_type>::execute(label,policy_type(0,policy),functor,result_view);
1144 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE
1146 namespace Kokkos {
namespace Experimental {
1155 using Kokkos::ValLocScalar;
1156 using Kokkos::MinLoc;
1157 using Kokkos::MaxLoc;
1158 using Kokkos::MinMaxScalar;
1159 using Kokkos::MinMax;
1160 using Kokkos::MinMaxLocScalar;
1161 using Kokkos::MinMaxLoc;
1165 #endif // KOKKOS_PARALLEL_REDUCE_HPP
void parallel_reduce(const std::string &label, const PolicyType &policy, const FunctorType &functor, ReturnType &return_value, typename Impl::enable_if< Kokkos::Impl::is_execution_policy< PolicyType >::value >::type *=0)
Parallel reduction.
View to an array of data.
Memory management for host memory.
Execution policy for work over a range of an integral type.