Kokkos Core Kernels Package  Version of the Day
Kokkos_Parallel.hpp
Go to the documentation of this file.
1 /*
2 //@HEADER
3 // ************************************************************************
4 //
5 // Kokkos v. 2.0
6 // Copyright (2014) Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact H. Carter Edwards (hcedwar@sandia.gov)
39 //
40 // ************************************************************************
41 //@HEADER
42 */
43 
46 
47 #ifndef KOKKOS_PARALLEL_HPP
48 #define KOKKOS_PARALLEL_HPP
49 
50 #include <cstddef>
51 #include <Kokkos_Core_fwd.hpp>
52 #include <Kokkos_View.hpp>
53 #include <Kokkos_ExecPolicy.hpp>
54 
55 #ifdef KOKKOSP_ENABLE_PROFILING
56 #include <impl/Kokkos_Profiling_Interface.hpp>
57 #include <typeinfo>
58 #endif
59 
60 #include <impl/Kokkos_AllocationTracker.hpp>
61 #include <impl/Kokkos_Tags.hpp>
62 #include <impl/Kokkos_Traits.hpp>
63 #include <impl/Kokkos_FunctorAdapter.hpp>
64 
65 #ifdef KOKKOS_HAVE_DEBUG
66 #include<iostream>
67 #endif
68 
69 //----------------------------------------------------------------------------
70 //----------------------------------------------------------------------------
71 
72 namespace Kokkos {
73 namespace Impl {
74 
75 //----------------------------------------------------------------------------
83 template< class Functor
84  , class Policy
85  , class EnableFunctor = void
86  , class EnablePolicy = void
87  >
89  typedef Kokkos::DefaultExecutionSpace execution_space ;
90 };
91 
92 template< class Functor , class Policy >
94  < Functor , Policy
95  , typename enable_if_type< typename Functor::device_type >::type
96  , typename enable_if_type< typename Policy ::execution_space >::type
97  >
98 {
99  typedef typename Policy ::execution_space execution_space ;
100 };
101 
102 template< class Functor , class Policy >
104  < Functor , Policy
105  , typename enable_if_type< typename Functor::execution_space >::type
106  , typename enable_if_type< typename Policy ::execution_space >::type
107  >
108 {
109  typedef typename Policy ::execution_space execution_space ;
110 };
111 
112 template< class Functor , class Policy , class EnableFunctor >
114  < Functor , Policy
115  , EnableFunctor
116  , typename enable_if_type< typename Policy::execution_space >::type
117  >
118 {
119  typedef typename Policy ::execution_space execution_space ;
120 };
121 
122 template< class Functor , class Policy , class EnablePolicy >
124  < Functor , Policy
125  , typename enable_if_type< typename Functor::device_type >::type
126  , EnablePolicy
127  >
128 {
129  typedef typename Functor::device_type execution_space ;
130 };
131 
132 template< class Functor , class Policy , class EnablePolicy >
134  < Functor , Policy
135  , typename enable_if_type< typename Functor::execution_space >::type
136  , EnablePolicy
137  >
138 {
139  typedef typename Functor::execution_space execution_space ;
140 };
141 
142 //----------------------------------------------------------------------------
149 template< class FunctorType , class ExecPolicy > class ParallelFor ;
150 
156 template< class FunctorType , class ExecPolicy > class ParallelReduce ;
157 
164 template< class FunctorType , class ExecPolicy > class ParallelScan ;
165 
166 } // namespace Impl
167 } // namespace Kokkos
168 
169 //----------------------------------------------------------------------------
170 //----------------------------------------------------------------------------
171 
172 namespace Kokkos {
173 
195 template< class ExecPolicy , class FunctorType >
196 inline
197 void parallel_for( const ExecPolicy & policy
198  , const FunctorType & functor
199  , const std::string& str = ""
200  , typename Impl::enable_if< ! Impl::is_integral< ExecPolicy >::value >::type * = 0
201  )
202 {
203 #ifdef KOKKOSP_ENABLE_PROFILING
204  uint64_t kpID = 0;
205  if(Kokkos::Experimental::profileLibraryLoaded()) {
206  Kokkos::Experimental::beginParallelFor("" == str ? typeid(FunctorType).name() : str, 0, &kpID);
207  }
208 #endif
209 
210  (void) Impl::ParallelFor< FunctorType , ExecPolicy >( Impl::CopyWithoutTracking::apply(functor) , policy );
211 
212 #ifdef KOKKOSP_ENABLE_PROFILING
213  if(Kokkos::Experimental::profileLibraryLoaded()) {
214  Kokkos::Experimental::endParallelFor(kpID);
215  }
216 #endif
217 }
218 
219 template< class FunctorType >
220 inline
221 void parallel_for( const size_t work_count
222  , const FunctorType & functor
223  , const std::string& str = ""
224  )
225 {
226  typedef typename
227  Impl::FunctorPolicyExecutionSpace< FunctorType , void >::execution_space
228  execution_space ;
229  typedef RangePolicy< execution_space > policy ;
230 
231 #ifdef KOKKOSP_ENABLE_PROFILING
232  uint64_t kpID = 0;
233  if(Kokkos::Experimental::profileLibraryLoaded()) {
234  Kokkos::Experimental::beginParallelFor("" == str ? typeid(FunctorType).name() : str, 0, &kpID);
235  }
236 #endif
237 
238  (void) Impl::ParallelFor< FunctorType , policy >( Impl::CopyWithoutTracking::apply(functor) , policy(0,work_count) );
239 
240 #ifdef KOKKOSP_ENABLE_PROFILING
241  if(Kokkos::Experimental::profileLibraryLoaded()) {
242  Kokkos::Experimental::endParallelFor(kpID);
243  }
244 #endif
245 }
246 
247 template< class ExecPolicy , class FunctorType >
248 inline
249 void parallel_for( const std::string & str
250  , const ExecPolicy & policy
251  , const FunctorType & functor )
252 {
253  #if KOKKOS_ENABLE_DEBUG_PRINT_KERNEL_NAMES
254  Kokkos::fence();
255  std::cout << "KOKKOS_DEBUG Start parallel_for kernel: " << str << std::endl;
256  #endif
257 
258  parallel_for(policy,functor,str);
259 
260  #if KOKKOS_ENABLE_DEBUG_PRINT_KERNEL_NAMES
261  Kokkos::fence();
262  std::cout << "KOKKOS_DEBUG End parallel_for kernel: " << str << std::endl;
263  #endif
264  (void) str;
265 }
266 
267 //----------------------------------------------------------------------------
268 //----------------------------------------------------------------------------
269 
304 template< class ExecPolicy , class FunctorType >
305 inline
306 void parallel_reduce( const ExecPolicy & policy
307  , const FunctorType & functor
308  , const std::string& str = ""
309  , typename Impl::enable_if< ! Impl::is_integral< ExecPolicy >::value >::type * = 0
310  )
311 {
312  // typedef typename
313  // Impl::FunctorPolicyExecutionSpace< FunctorType , ExecPolicy >::execution_space
314  // execution_space ;
315 
316  typedef Kokkos::Impl::FunctorValueTraits< FunctorType , typename ExecPolicy::work_tag > ValueTraits ;
317 
318  typedef typename Kokkos::Impl::if_c< (ValueTraits::StaticValueSize != 0)
319  , typename ValueTraits::value_type
320  , typename ValueTraits::pointer_type
321  >::type value_type ;
322 
323  Kokkos::View< value_type
324  , HostSpace
325  , Kokkos::MemoryUnmanaged
326  >
327  result_view ;
328 
329 #ifdef KOKKOSP_ENABLE_PROFILING
330  uint64_t kpID = 0;
331  if(Kokkos::Experimental::profileLibraryLoaded()) {
332  Kokkos::Experimental::beginParallelReduce("" == str ? typeid(FunctorType).name() : str, 0, &kpID);
333  }
334 #endif
335 
336  (void) Impl::ParallelReduce< FunctorType , ExecPolicy >( Impl::CopyWithoutTracking::apply(functor) , policy , result_view );
337 
338 #ifdef KOKKOSP_ENABLE_PROFILING
339  if(Kokkos::Experimental::profileLibraryLoaded()) {
340  Kokkos::Experimental::endParallelReduce(kpID);
341  }
342 #endif
343 }
344 
345 // integral range policy
346 template< class FunctorType >
347 inline
348 void parallel_reduce( const size_t work_count
349  , const FunctorType & functor
350  , const std::string& str = ""
351  )
352 {
353  typedef typename
354  Impl::FunctorPolicyExecutionSpace< FunctorType , void >::execution_space
355  execution_space ;
356 
357  typedef RangePolicy< execution_space > policy ;
358 
359  typedef Kokkos::Impl::FunctorValueTraits< FunctorType , void > ValueTraits ;
360 
361  typedef typename Kokkos::Impl::if_c< (ValueTraits::StaticValueSize != 0)
362  , typename ValueTraits::value_type
363  , typename ValueTraits::pointer_type
364  >::type value_type ;
365 
366  Kokkos::View< value_type
367  , HostSpace
368  , Kokkos::MemoryUnmanaged
369  >
370  result_view ;
371 
372 #ifdef KOKKOSP_ENABLE_PROFILING
373  uint64_t kpID = 0;
374  if(Kokkos::Experimental::profileLibraryLoaded()) {
375  Kokkos::Experimental::beginParallelReduce("" == str ? typeid(FunctorType).name() : str, 0, &kpID);
376  }
377 #endif
378 
379  (void) Impl::ParallelReduce< FunctorType , policy >( Impl::CopyWithoutTracking::apply(functor) , policy(0,work_count) , result_view );
380 
381 #ifdef KOKKOSP_ENABLE_PROFILING
382  if(Kokkos::Experimental::profileLibraryLoaded()) {
383  Kokkos::Experimental::endParallelReduce(kpID);
384  }
385 #endif
386 
387 }
388 
389 // general policy and view ouput
390 template< class ExecPolicy , class FunctorType , class ViewType >
391 inline
392 void parallel_reduce( const ExecPolicy & policy
393  , const FunctorType & functor
394  , const ViewType & result_view
395  , const std::string& str = ""
396  , typename Impl::enable_if<
397  ( Impl::is_view<ViewType>::value && ! Impl::is_integral< ExecPolicy >::value
398 #ifdef KOKKOS_HAVE_CUDA
399  && ! Impl::is_same<typename ExecPolicy::execution_space,Kokkos::Cuda>::value
400 #endif
401  )>::type * = 0 )
402 {
403 
404 #ifdef KOKKOSP_ENABLE_PROFILING
405  uint64_t kpID = 0;
406  if(Kokkos::Experimental::profileLibraryLoaded()) {
407  Kokkos::Experimental::beginParallelReduce("" == str ? typeid(FunctorType).name() : str, 0, &kpID);
408  }
409 #endif
410 
411  (void) Impl::ParallelReduce< FunctorType, ExecPolicy >( Impl::CopyWithoutTracking::apply(functor) , policy , Impl::CopyWithoutTracking::apply(result_view) );
412 
413 #ifdef KOKKOSP_ENABLE_PROFILING
414  if(Kokkos::Experimental::profileLibraryLoaded()) {
415  Kokkos::Experimental::endParallelReduce(kpID);
416  }
417 #endif
418 
419 }
420 
421 // general policy and pod or array of pod output
422 template< class ExecPolicy , class FunctorType >
423 void parallel_reduce( const ExecPolicy & policy
424  , const FunctorType & functor
425 #ifdef KOKKOS_HAVE_CUDA
426  , typename Impl::enable_if<
427  ( ! Impl::is_integral< ExecPolicy >::value &&
428  ! Impl::is_same<typename ExecPolicy::execution_space,Kokkos::Cuda>::value )
429  , typename Kokkos::Impl::FunctorValueTraits< FunctorType , typename ExecPolicy::work_tag >::reference_type>::type result_ref
430  , const std::string& str = ""
431  , typename Impl::enable_if<! Impl::is_same<typename ExecPolicy::execution_space,Kokkos::Cuda>::value >::type* = 0
432  )
433 #else
434  , typename Impl::enable_if<
435  ( ! Impl::is_integral< ExecPolicy >::value)
436  , typename Kokkos::Impl::FunctorValueTraits< FunctorType , typename ExecPolicy::work_tag >::reference_type
437  >::type result_ref
438  , const std::string& str = ""
439  )
440 #endif
441 {
442  typedef Kokkos::Impl::FunctorValueTraits< FunctorType , typename ExecPolicy::work_tag > ValueTraits ;
443  typedef Kokkos::Impl::FunctorValueOps< FunctorType , typename ExecPolicy::work_tag > ValueOps ;
444 
445  // Wrap the result output request in a view to inform the implementation
446  // of the type and memory space.
447 
448  typedef typename Kokkos::Impl::if_c< (ValueTraits::StaticValueSize != 0)
449  , typename ValueTraits::value_type
450  , typename ValueTraits::pointer_type
451  >::type value_type ;
452 
453  Kokkos::View< value_type
454  , HostSpace
455  , Kokkos::MemoryUnmanaged
456  >
457  result_view( ValueOps::pointer( result_ref )
458  , ValueTraits::value_count( functor )
459  );
460 
461 #ifdef KOKKOSP_ENABLE_PROFILING
462  uint64_t kpID = 0;
463  if(Kokkos::Experimental::profileLibraryLoaded()) {
464  Kokkos::Experimental::beginParallelReduce("" == str ? typeid(FunctorType).name() : str, 0, &kpID);
465  }
466 #endif
467 
468  (void) Impl::ParallelReduce< FunctorType, ExecPolicy >( Impl::CopyWithoutTracking::apply(functor) , policy , Impl::CopyWithoutTracking::apply(result_view) );
469 
470 #ifdef KOKKOSP_ENABLE_PROFILING
471  if(Kokkos::Experimental::profileLibraryLoaded()) {
472  Kokkos::Experimental::endParallelReduce(kpID);
473  }
474 #endif
475 
476 }
477 
478 // integral range policy and view ouput
479 template< class FunctorType , class ViewType >
480 inline
481 void parallel_reduce( const size_t work_count
482  , const FunctorType & functor
483  , const ViewType & result_view
484  , const std::string& str = ""
485  , typename Impl::enable_if<( Impl::is_view<ViewType>::value
486 #ifdef KOKKOS_HAVE_CUDA
487  && ! Impl::is_same<
488  typename Impl::FunctorPolicyExecutionSpace< FunctorType , void >::execution_space,
489  Kokkos::Cuda>::value
490 #endif
491  )>::type * = 0 )
492 {
493  typedef typename
494  Impl::FunctorPolicyExecutionSpace< FunctorType , void >::execution_space
495  execution_space ;
496 
497  typedef RangePolicy< execution_space > ExecPolicy ;
498 
499 #ifdef KOKKOSP_ENABLE_PROFILING
500  uint64_t kpID = 0;
501  if(Kokkos::Experimental::profileLibraryLoaded()) {
502  Kokkos::Experimental::beginParallelReduce("" == str ? typeid(FunctorType).name() : str, 0, &kpID);
503  }
504 #endif
505 
506  (void) Impl::ParallelReduce< FunctorType, ExecPolicy >( Impl::CopyWithoutTracking::apply(functor) , ExecPolicy(0,work_count) , Impl::CopyWithoutTracking::apply(result_view) );
507 
508 #ifdef KOKKOSP_ENABLE_PROFILING
509  if(Kokkos::Experimental::profileLibraryLoaded()) {
510  Kokkos::Experimental::endParallelReduce(kpID);
511  }
512 #endif
513 
514 }
515 
516 // integral range policy and pod or array of pod output
517 template< class FunctorType >
518 inline
519 void parallel_reduce( const size_t work_count
520  , const FunctorType & functor
521  , typename Kokkos::Impl::FunctorValueTraits<
522  typename Impl::if_c<Impl::is_execution_policy<FunctorType>::value ||
523  Impl::is_integral<FunctorType>::value,
524  void,FunctorType>::type
525  , void >::reference_type result
526  , const std::string& str = ""
527  , typename Impl::enable_if< true
528 #ifdef KOKKOS_HAVE_CUDA
529  && ! Impl::is_same<
530  typename Impl::FunctorPolicyExecutionSpace< FunctorType , void >::execution_space,
531  Kokkos::Cuda>::value
532 #endif
533  >::type * = 0 )
534 {
535  typedef Kokkos::Impl::FunctorValueTraits< FunctorType , void > ValueTraits ;
536  typedef Kokkos::Impl::FunctorValueOps< FunctorType , void > ValueOps ;
537 
538  typedef typename
539  Kokkos::Impl::FunctorPolicyExecutionSpace< FunctorType , void >::execution_space
540  execution_space ;
541 
543 
544  // Wrap the result output request in a view to inform the implementation
545  // of the type and memory space.
546 
547  typedef typename Kokkos::Impl::if_c< (ValueTraits::StaticValueSize != 0)
548  , typename ValueTraits::value_type
549  , typename ValueTraits::pointer_type
550  >::type value_type ;
551 
552  Kokkos::View< value_type
553  , HostSpace
554  , Kokkos::MemoryUnmanaged
555  >
556  result_view( ValueOps::pointer( result )
557  , ValueTraits::value_count( functor )
558  );
559 
560 #ifdef KOKKOSP_ENABLE_PROFILING
561  uint64_t kpID = 0;
562  if(Kokkos::Experimental::profileLibraryLoaded()) {
563  Kokkos::Experimental::beginParallelReduce("" == str ? typeid(FunctorType).name() : str, 0, &kpID);
564  }
565 #endif
566 
567  (void) Impl::ParallelReduce< FunctorType , policy >( Impl::CopyWithoutTracking::apply(functor) , policy(0,work_count) , Impl::CopyWithoutTracking::apply(result_view) );
568 
569 #ifdef KOKKOSP_ENABLE_PROFILING
570  if(Kokkos::Experimental::profileLibraryLoaded()) {
571  Kokkos::Experimental::endParallelReduce(kpID);
572  }
573 #endif
574 
575 }
576 #ifndef KOKKOS_HAVE_CUDA
577 template< class ExecPolicy , class FunctorType , class ResultType >
578 inline
579 void parallel_reduce( const std::string & str
580  , const ExecPolicy & policy
581  , const FunctorType & functor
582  , ResultType * result)
583 {
584  #if KOKKOS_ENABLE_DEBUG_PRINT_KERNEL_NAMES
585  Kokkos::fence();
586  std::cout << "KOKKOS_DEBUG Start parallel_reduce kernel: " << str << std::endl;
587  #endif
588 
589  parallel_reduce(policy,functor,result,str);
590 
591  #if KOKKOS_ENABLE_DEBUG_PRINT_KERNEL_NAMES
592  Kokkos::fence();
593  std::cout << "KOKKOS_DEBUG End parallel_reduce kernel: " << str << std::endl;
594  #endif
595  (void) str;
596 }
597 
598 template< class ExecPolicy , class FunctorType , class ResultType >
599 inline
600 void parallel_reduce( const std::string & str
601  , const ExecPolicy & policy
602  , const FunctorType & functor
603  , ResultType & result)
604 {
605  #if KOKKOS_ENABLE_DEBUG_PRINT_KERNEL_NAMES
606  Kokkos::fence();
607  std::cout << "KOKKOS_DEBUG Start parallel_reduce kernel: " << str << std::endl;
608  #endif
609 
610  parallel_reduce(policy,functor,result,str);
611 
612  #if KOKKOS_ENABLE_DEBUG_PRINT_KERNEL_NAMES
613  Kokkos::fence();
614  std::cout << "KOKKOS_DEBUG End parallel_reduce kernel: " << str << std::endl;
615  #endif
616  (void) str;
617 }
618 
619 template< class ExecPolicy , class FunctorType >
620 inline
621 void parallel_reduce( const std::string & str
622  , const ExecPolicy & policy
623  , const FunctorType & functor)
624 {
625  #if KOKKOS_ENABLE_DEBUG_PRINT_KERNEL_NAMES
626  Kokkos::fence();
627  std::cout << "KOKKOS_DEBUG Start parallel_reduce kernel: " << str << std::endl;
628  #endif
629 
630  parallel_reduce(policy,functor,str);
631 
632  #if KOKKOS_ENABLE_DEBUG_PRINT_KERNEL_NAMES
633  Kokkos::fence();
634  std::cout << "KOKKOS_DEBUG End parallel_reduce kernel: " << str << std::endl;
635  #endif
636  (void) str;
637 }
638 #endif
639 
640 } // namespace Kokkos
641 
642 //----------------------------------------------------------------------------
643 //----------------------------------------------------------------------------
644 
645 namespace Kokkos {
646 
801 template< class ExecutionPolicy , class FunctorType >
802 inline
803 void parallel_scan( const ExecutionPolicy & policy
804  , const FunctorType & functor
805  , const std::string& str = ""
806  , typename Impl::enable_if< ! Impl::is_integral< ExecutionPolicy >::value >::type * = 0
807  )
808 {
809 #ifdef KOKKOSP_ENABLE_PROFILING
810  uint64_t kpID = 0;
811  if(Kokkos::Experimental::profileLibraryLoaded()) {
812  Kokkos::Experimental::beginParallelScan("" == str ? typeid(FunctorType).name() : str, 0, &kpID);
813  }
814 #endif
815 
816  Impl::ParallelScan< FunctorType , ExecutionPolicy > scan( Impl::CopyWithoutTracking::apply(functor) , policy );
817 
818 #ifdef KOKKOSP_ENABLE_PROFILING
819  if(Kokkos::Experimental::profileLibraryLoaded()) {
820  Kokkos::Experimental::endParallelScan(kpID);
821  }
822 #endif
823 
824 }
825 
826 template< class FunctorType >
827 inline
828 void parallel_scan( const size_t work_count
829  , const FunctorType & functor
830  , const std::string& str = "" )
831 {
832  typedef typename
833  Kokkos::Impl::FunctorPolicyExecutionSpace< FunctorType , void >::execution_space
834  execution_space ;
835 
837 
838 #ifdef KOKKOSP_ENABLE_PROFILING
839  uint64_t kpID = 0;
840  if(Kokkos::Experimental::profileLibraryLoaded()) {
841  Kokkos::Experimental::beginParallelScan("" == str ? typeid(FunctorType).name() : str, 0, &kpID);
842  }
843 #endif
844 
845  (void) Impl::ParallelScan< FunctorType , policy >( Impl::CopyWithoutTracking::apply(functor) , policy(0,work_count) );
846 
847 #ifdef KOKKOSP_ENABLE_PROFILING
848  if(Kokkos::Experimental::profileLibraryLoaded()) {
849  Kokkos::Experimental::endParallelScan(kpID);
850  }
851 #endif
852 
853 }
854 
855 template< class ExecutionPolicy , class FunctorType >
856 inline
857 void parallel_scan( const std::string& str
858  , const ExecutionPolicy & policy
859  , const FunctorType & functor)
860 {
861  #if KOKKOS_ENABLE_DEBUG_PRINT_KERNEL_NAMES
862  Kokkos::fence();
863  std::cout << "KOKKOS_DEBUG Start parallel_scan kernel: " << str << std::endl;
864  #endif
865 
866  parallel_scan(policy,functor,str);
867 
868  #if KOKKOS_ENABLE_DEBUG_PRINT_KERNEL_NAMES
869  Kokkos::fence();
870  std::cout << "KOKKOS_DEBUG End parallel_scan kernel: " << str << std::endl;
871  #endif
872  (void) str;
873 }
874 
875 } // namespace Kokkos
876 
877 //----------------------------------------------------------------------------
878 //----------------------------------------------------------------------------
879 
880 namespace Kokkos {
881 namespace Impl {
882 
883 template< class FunctorType , class Enable = void >
884 struct FunctorTeamShmemSize
885 {
886  static inline size_t value( const FunctorType & , int ) { return 0 ; }
887 };
888 
889 template< class FunctorType >
890 struct FunctorTeamShmemSize< FunctorType , typename Impl::enable_if< 0 < sizeof( & FunctorType::team_shmem_size ) >::type >
891 {
892  static inline size_t value( const FunctorType & f , int team_size ) { return f.team_shmem_size( team_size ) ; }
893 };
894 
895 template< class FunctorType >
896 struct FunctorTeamShmemSize< FunctorType , typename Impl::enable_if< 0 < sizeof( & FunctorType::shmem_size ) >::type >
897 {
898  static inline size_t value( const FunctorType & f , int team_size ) { return f.shmem_size( team_size ) ; }
899 };
900 
901 } // namespace Impl
902 } // namespace Kokkos
903 
904 //----------------------------------------------------------------------------
905 //----------------------------------------------------------------------------
906 
907 #endif /* KOKKOS_PARALLEL_HPP */
908 
Implementation detail of parallel_scan.
void parallel_reduce(const ExecPolicy &policy, const FunctorType &functor, const std::string &str="", typename Impl::enable_if< !Impl::is_integral< ExecPolicy >::value >::type *=0)
Parallel reduction.
View to an array of data.
Memory management for host memory.
Implementation of the ParallelFor operator that has a partial specialization for the device...
Given a Functor and Execution Policy query an execution space.
Execution policy for work over a range of an integral type.
void parallel_for(const ExecPolicy &policy, const FunctorType &functor, const std::string &str="", typename Impl::enable_if< !Impl::is_integral< ExecPolicy >::value >::type *=0)
Execute functor in parallel according to the execution policy.
Implementation detail of parallel_reduce.