Kokkos Core Kernels Package  Version of the Day
KokkosExp_View.hpp
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 
44 #ifndef KOKKOS_EXPERIMENTAL_VIEW_HPP
45 #define KOKKOS_EXPERIMENTAL_VIEW_HPP
46 
47 #include <string>
48 #include <algorithm>
49 #include <type_traits>
50 #include <initializer_list>
51 
52 #include <Kokkos_Core_fwd.hpp>
53 #include <Kokkos_HostSpace.hpp>
54 #include <Kokkos_MemoryTraits.hpp>
55 #include <Kokkos_ExecPolicy.hpp>
56 
57 //----------------------------------------------------------------------------
58 //----------------------------------------------------------------------------
59 
60 namespace Kokkos {
61 namespace Experimental {
62 namespace Impl {
63 
64 template< class DstMemorySpace , class SrcMemorySpace >
65 struct DeepCopy ;
66 
67 template< class DataType >
68 struct ViewArrayAnalysis ;
69 
70 template< class DataType , class ArrayLayout
71  , typename ValueType =
72  typename ViewArrayAnalysis< DataType >::non_const_value_type
73  >
74 struct ViewDataAnalysis ;
75 
76 template< class , class ... >
77 class ViewMapping { public: enum { is_assignable = false }; };
78 
79 template< class MemorySpace >
80 struct ViewOperatorBoundsErrorAbort ;
81 
82 template<>
83 struct ViewOperatorBoundsErrorAbort< Kokkos::HostSpace > {
84  static void apply( const size_t rank
85  , const size_t n0 , const size_t n1
86  , const size_t n2 , const size_t n3
87  , const size_t n4 , const size_t n5
88  , const size_t n6 , const size_t n7
89  , const size_t i0 , const size_t i1
90  , const size_t i2 , const size_t i3
91  , const size_t i4 , const size_t i5
92  , const size_t i6 , const size_t i7 );
93 };
94 
95 } /* namespace Impl */
96 } /* namespace Experimental */
97 } /* namespace Kokkos */
98 
99 //----------------------------------------------------------------------------
100 //----------------------------------------------------------------------------
101 
102 namespace Kokkos {
103 namespace Experimental {
104 
122 template< class DataType , class ... Properties >
123 struct ViewTraits ;
124 
125 template<>
126 struct ViewTraits< void >
127 {
128  typedef void execution_space ;
129  typedef void memory_space ;
130  typedef void array_layout ;
131  typedef void memory_traits ;
132 };
133 
134 template< class ... Prop >
135 struct ViewTraits< void , void , Prop ... >
136 {
137  // Ignore an extraneous 'void'
138  typedef typename ViewTraits<void,Prop...>::execution_space execution_space ;
139  typedef typename ViewTraits<void,Prop...>::memory_space memory_space ;
140  typedef typename ViewTraits<void,Prop...>::array_layout array_layout ;
141  typedef typename ViewTraits<void,Prop...>::memory_traits memory_traits ;
142 };
143 
144 template< class ArrayLayout , class ... Prop >
145 struct ViewTraits< typename std::enable_if< Kokkos::Impl::is_array_layout<ArrayLayout>::value >::type , ArrayLayout , Prop ... >
146 {
147  // Specify layout, keep subsequent space and memory traits arguments
148 
149  typedef typename ViewTraits<void,Prop...>::execution_space execution_space ;
150  typedef typename ViewTraits<void,Prop...>::memory_space memory_space ;
151  typedef ArrayLayout array_layout ;
152  typedef typename ViewTraits<void,Prop...>::memory_traits memory_traits ;
153 };
154 
155 template< class Space , class ... Prop >
156 struct ViewTraits< typename std::enable_if< Kokkos::Impl::is_space<Space>::value >::type , Space , Prop ... >
157 {
158  // Specify Space, memory traits should be the only subsequent argument
159 
160  static_assert( std::is_same< typename ViewTraits<void,Prop...>::execution_space , void >::value ||
161  std::is_same< typename ViewTraits<void,Prop...>::memory_space , void >::value ||
162  std::is_same< typename ViewTraits<void,Prop...>::array_layout , void >::value
163  , "Only one View Execution or Memory Space template argument" );
164 
165  typedef typename Space::execution_space execution_space ;
166  typedef typename Space::memory_space memory_space ;
167  typedef typename execution_space::array_layout array_layout ;
168  typedef typename ViewTraits<void,Prop...>::memory_traits memory_traits ;
169 };
170 
171 template< class MemoryTraits , class ... Prop >
172 struct ViewTraits< typename std::enable_if< Kokkos::Impl::is_memory_traits<MemoryTraits>::value >::type , MemoryTraits , Prop ... >
173 {
174  // Specify memory trait, should not be any subsequent arguments
175 
176  static_assert( std::is_same< typename ViewTraits<void,Prop...>::execution_space , void >::value ||
177  std::is_same< typename ViewTraits<void,Prop...>::memory_space , void >::value ||
178  std::is_same< typename ViewTraits<void,Prop...>::array_layout , void >::value ||
179  std::is_same< typename ViewTraits<void,Prop...>::memory_traits , void >::value
180  , "MemoryTrait is the final optional template argument for a View" );
181 
182  typedef void execution_space ;
183  typedef void memory_space ;
184  typedef void array_layout ;
185  typedef MemoryTraits memory_traits ;
186 };
187 
188 
189 template< class DataType , class ... Properties >
190 struct ViewTraits {
191 private:
192 
193  // Unpack the properties arguments
194  typedef ViewTraits< void , Properties ... > prop ;
195 
196  typedef typename
197  std::conditional< ! std::is_same< typename prop::execution_space , void >::value
198  , typename prop::execution_space
199  , Kokkos::DefaultExecutionSpace
200  >::type
201  ExecutionSpace ;
202 
203  typedef typename
204  std::conditional< ! std::is_same< typename prop::memory_space , void >::value
205  , typename prop::memory_space
206  , typename ExecutionSpace::memory_space
207  >::type
208  MemorySpace ;
209 
210  typedef typename
211  std::conditional< ! std::is_same< typename prop::array_layout , void >::value
212  , typename prop::array_layout
213  , typename ExecutionSpace::array_layout
214  >::type
215  ArrayLayout ;
216 
217  typedef typename Kokkos::Impl::is_space< ExecutionSpace >::host_mirror_space
218  HostMirrorSpace ;
219 
220  typedef typename
221  std::conditional< ! std::is_same< typename prop::memory_traits , void >::value
222  , typename prop::memory_traits
223  , typename Kokkos::MemoryManaged
224  >::type
225  MemoryTraits ;
226 
227  // Analyze data type's properties,
228  // May be specialized based upon the layout and value type
229  typedef Kokkos::Experimental::Impl::ViewDataAnalysis< DataType , ArrayLayout > data_analysis ;
230 
231 public:
232 
233  //------------------------------------
234  // Data type traits:
235 
236  typedef typename data_analysis::type data_type ;
237  typedef typename data_analysis::const_type const_data_type ;
238  typedef typename data_analysis::non_const_type non_const_data_type ;
239 
240  //------------------------------------
241  // Compatible array of trivial type traits:
242 
243  typedef typename data_analysis::array_scalar_type array_scalar_type ;
244  typedef typename data_analysis::const_array_scalar_type const_array_scalar_type ;
245  typedef typename data_analysis::non_const_array_scalar_type non_const_array_scalar_type ;
246 
247  //------------------------------------
248  // Value type traits:
249 
250  typedef typename data_analysis::value_type value_type ;
251  typedef typename data_analysis::const_value_type const_value_type ;
252  typedef typename data_analysis::non_const_value_type non_const_value_type ;
253 
254  //------------------------------------
255  // Mapping traits:
256 
257  typedef ArrayLayout array_layout ;
258  typedef typename data_analysis::dimension dimension ;
259  typedef typename data_analysis::specialize specialize /* mapping specialization tag */ ;
260 
261  enum { rank = dimension::rank };
262  enum { rank_dynamic = dimension::rank_dynamic };
263 
264  //------------------------------------
265  // Execution space, memory space, memory access traits, and host mirror space.
266 
267  typedef ExecutionSpace execution_space ;
268  typedef MemorySpace memory_space ;
270  typedef MemoryTraits memory_traits ;
271  typedef HostMirrorSpace host_mirror_space ;
272 
273  typedef typename MemorySpace::size_type size_type ;
274 
275  enum { is_hostspace = std::is_same< MemorySpace , HostSpace >::value };
276  enum { is_managed = MemoryTraits::Unmanaged == 0 };
277  enum { is_random_access = MemoryTraits::RandomAccess == 1 };
278 
279  //------------------------------------
280 };
281 
364 template< class DataType , class ... Properties >
365 class View ;
366 
367 } /* namespace Experimental */
368 } /* namespace Kokkos */
369 
370 //----------------------------------------------------------------------------
371 //----------------------------------------------------------------------------
372 
373 #include <impl/KokkosExp_ViewMapping.hpp>
374 #include <impl/KokkosExp_ViewAllocProp.hpp>
375 #include <impl/KokkosExp_ViewArray.hpp>
376 
377 //----------------------------------------------------------------------------
378 //----------------------------------------------------------------------------
379 
380 namespace Kokkos {
381 namespace Experimental {
382 
383 namespace {
384 
385 constexpr Kokkos::Experimental::Impl::ALL_t
386  ALL = Kokkos::Experimental::Impl::ALL_t();
387 
388 constexpr Kokkos::Experimental::Impl::WithoutInitializing_t
389  WithoutInitializing = Kokkos::Experimental::Impl::WithoutInitializing_t();
390 
391 constexpr Kokkos::Experimental::Impl::AllowPadding_t
392  AllowPadding = Kokkos::Experimental::Impl::AllowPadding_t();
393 
394 }
395 
405 template< class ... Args >
406 inline
407 Kokkos::Experimental::Impl::ViewAllocProp< Args ... >
408 view_alloc( Args ... args )
409 {
410  return Kokkos::Experimental::Impl::ViewAllocProp< Args ... >( args ... );
411 }
412 
413 } /* namespace Experimental */
414 } /* namespace Kokkos */
415 
416 //----------------------------------------------------------------------------
417 //----------------------------------------------------------------------------
418 
419 namespace Kokkos {
420 namespace Experimental {
421 
422 template< class DataType , class ... Properties >
423 class View ;
424 
425 template< class > struct is_view : public std::false_type {};
426 
427 template< class D, class ... P >
428 struct is_view< View<D,P...> > : public std::true_type {};
429 
430 template< class DataType , class ... Properties >
431 class View : public ViewTraits< DataType , Properties ... > {
432 private:
433 
434  template< class , class ... > friend class View ;
435  template< class , class ... > friend class Impl::ViewMapping ;
436 
437  typedef ViewTraits< DataType , Properties ... > traits ;
438  typedef Kokkos::Experimental::Impl::ViewMapping< traits , void > map_type ;
439  typedef Kokkos::Experimental::Impl::SharedAllocationTracker track_type ;
440 
441  track_type m_track ;
442  map_type m_map ;
443 
444 public:
445 
446  //----------------------------------------
448  typedef View< typename traits::array_scalar_type ,
449  typename traits::array_layout ,
450  typename traits::device_type ,
451  typename traits::memory_traits >
453 
455  typedef View< typename traits::const_data_type ,
456  typename traits::array_layout ,
457  typename traits::device_type ,
458  typename traits::memory_traits >
460 
462  typedef View< typename traits::non_const_data_type ,
463  typename traits::array_layout ,
464  typename traits::device_type ,
465  typename traits::memory_traits >
467 
469  typedef View< typename traits::non_const_data_type ,
470  typename traits::array_layout ,
471  typename traits::host_mirror_space >
473 
474  //----------------------------------------
475  // Domain dimensions
476 
477  enum { Rank = map_type::Rank };
478 
479  template< typename iType >
480  KOKKOS_INLINE_FUNCTION constexpr
481  typename std::enable_if< std::is_integral<iType>::value , size_t >::type
482  extent( const iType & r ) const
483  { return m_map.extent(r); }
484 
485  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_0() const { return m_map.dimension_0(); }
486  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_1() const { return m_map.dimension_1(); }
487  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_2() const { return m_map.dimension_2(); }
488  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_3() const { return m_map.dimension_3(); }
489  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_4() const { return m_map.dimension_4(); }
490  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_5() const { return m_map.dimension_5(); }
491  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_6() const { return m_map.dimension_6(); }
492  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_7() const { return m_map.dimension_7(); }
493 
494  KOKKOS_INLINE_FUNCTION constexpr size_t size() const { return m_map.dimension_0() *
495  m_map.dimension_1() *
496  m_map.dimension_2() *
497  m_map.dimension_3() *
498  m_map.dimension_4() *
499  m_map.dimension_5() *
500  m_map.dimension_6() *
501  m_map.dimension_7(); }
502 
503  KOKKOS_INLINE_FUNCTION constexpr size_t stride_0() const { return m_map.stride_0(); }
504  KOKKOS_INLINE_FUNCTION constexpr size_t stride_1() const { return m_map.stride_1(); }
505  KOKKOS_INLINE_FUNCTION constexpr size_t stride_2() const { return m_map.stride_2(); }
506  KOKKOS_INLINE_FUNCTION constexpr size_t stride_3() const { return m_map.stride_3(); }
507  KOKKOS_INLINE_FUNCTION constexpr size_t stride_4() const { return m_map.stride_4(); }
508  KOKKOS_INLINE_FUNCTION constexpr size_t stride_5() const { return m_map.stride_5(); }
509  KOKKOS_INLINE_FUNCTION constexpr size_t stride_6() const { return m_map.stride_6(); }
510  KOKKOS_INLINE_FUNCTION constexpr size_t stride_7() const { return m_map.stride_7(); }
511 
512  template< typename iType >
513  KOKKOS_INLINE_FUNCTION void stride( iType * const s ) const { m_map.stride(s); }
514 
515  //----------------------------------------
516  // Range span is the span which contains all members.
517 
518  typedef typename map_type::reference_type reference_type ;
519  typedef typename map_type::pointer_type pointer_type ;
520 
521  enum { reference_type_is_lvalue_reference = std::is_lvalue_reference< reference_type >::value };
522 
523  KOKKOS_INLINE_FUNCTION constexpr size_t span() const { return m_map.span(); }
524  // Deprecated, use 'span()' instead
525  KOKKOS_INLINE_FUNCTION constexpr size_t capacity() const { return m_map.span(); }
526  KOKKOS_INLINE_FUNCTION constexpr bool span_is_contiguous() const { return m_map.span_is_contiguous(); }
527  KOKKOS_INLINE_FUNCTION constexpr pointer_type data() const { return m_map.data(); }
528 
529  // Deprecated, use 'span_is_contigous()' instead
530  KOKKOS_INLINE_FUNCTION constexpr bool is_contiguous() const { return m_map.span_is_contiguous(); }
531  // Deprecated, use 'data()' instead
532  KOKKOS_INLINE_FUNCTION constexpr pointer_type ptr_on_device() const { return m_map.data(); }
533 
534  //----------------------------------------
535  // Allow specializations to query their specialized map
536 
537  KOKKOS_INLINE_FUNCTION
538  const map_type & implementation_map() const { return m_map ; }
539 
540  //----------------------------------------
541 
542 private:
543 
544  enum {
545  is_layout_left = std::is_same< typename traits::array_layout
546  , Kokkos::LayoutLeft >::value ,
547 
548  is_layout_right = std::is_same< typename traits::array_layout
549  , Kokkos::LayoutRight >::value ,
550 
551  is_layout_stride = std::is_same< typename traits::array_layout
552  , Kokkos::LayoutStride >::value ,
553 
554  is_default_map =
555  std::is_same< typename traits::specialize , void >::value &&
556  ( is_layout_left || is_layout_right || is_layout_stride )
557  };
558 
559 #if defined( KOKKOS_ENABLE_DEBUG_BOUNDS_CHECK )
560 
561 #define KOKKOS_VIEW_OPERATOR_VERIFY( ARG ) \
562  Kokkos::Impl::VerifyExecutionCanAccessMemorySpace \
563  < Kokkos::Impl::ActiveExecutionMemorySpace , typename traits::memory_space >::verify(); \
564  Kokkos::Experimental::Impl::view_verify_operator_bounds ARG ;
565 
566 #else
567 
568 #define KOKKOS_VIEW_OPERATOR_VERIFY( ARG ) \
569  Kokkos::Impl::VerifyExecutionCanAccessMemorySpace \
570  < Kokkos::Impl::ActiveExecutionMemorySpace , typename traits::memory_space >::verify();
571 
572 #endif
573 
574 public:
575 
576  //------------------------------
577  // Rank 0 operator()
578 
579  template< class ... Args >
580  KOKKOS_FORCEINLINE_FUNCTION
581  typename std::enable_if<( Kokkos::Impl::are_integral<Args...>::value
582  && ( 0 == Rank )
583  ), reference_type >::type
584  operator()( Args ... args ) const
585  {
586  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,args...) )
587 
588  return m_map.reference();
589  }
590 
591  //------------------------------
592  // Rank 1 operator()
593 
594  template< typename I0
595  , class ... Args >
596  KOKKOS_FORCEINLINE_FUNCTION
597  typename std::enable_if<
598  ( Kokkos::Impl::are_integral<I0,Args...>::value
599  && ( 1 == Rank )
600  && ! is_default_map
601  ), reference_type >::type
602  operator()( const I0 & i0
603  , Args ... args ) const
604  {
605  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,args...) )
606 
607  return m_map.reference(i0);
608  }
609 
610  template< typename I0
611  , class ... Args >
612  KOKKOS_FORCEINLINE_FUNCTION
613  typename std::enable_if<
614  ( Kokkos::Impl::are_integral<I0,Args...>::value
615  && ( 1 == Rank )
616  && is_default_map
617  && ! is_layout_stride
618  ), reference_type >::type
619  operator()( const I0 & i0
620  , Args ... args ) const
621  {
622  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,args...) )
623 
624  return m_map.m_handle[ i0 ];
625  }
626 
627  template< typename I0
628  , class ... Args >
629  KOKKOS_FORCEINLINE_FUNCTION
630  typename std::enable_if<
631  ( Kokkos::Impl::are_integral<I0,Args...>::value
632  && ( 1 == Rank )
633  && is_default_map
634  && is_layout_stride
635  ), reference_type >::type
636  operator()( const I0 & i0
637  , Args ... args ) const
638  {
639  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,args...) )
640 
641  return m_map.m_handle[ m_map.m_offset.m_stride.S0 * i0 ];
642  }
643 
644  //------------------------------
645  // Rank 1 operator[]
646 
647  template< typename I0 >
648  KOKKOS_FORCEINLINE_FUNCTION
649  typename std::enable_if<
650  ( Kokkos::Impl::are_integral<I0>::value
651  && ( 1 == Rank )
652  && ! is_default_map
653  ), reference_type >::type
654  operator[]( const I0 & i0 ) const
655  {
656  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0) )
657 
658  return m_map.reference(i0);
659  }
660 
661  template< typename I0 >
662  KOKKOS_FORCEINLINE_FUNCTION
663  typename std::enable_if<
664  ( Kokkos::Impl::are_integral<I0>::value
665  && ( 1 == Rank )
666  && is_default_map
667  && ! is_layout_stride
668  ), reference_type >::type
669  operator[]( const I0 & i0 ) const
670  {
671  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0) )
672 
673  return m_map.m_handle[ i0 ];
674  }
675 
676  template< typename I0 >
677  KOKKOS_FORCEINLINE_FUNCTION
678  typename std::enable_if<
679  ( Kokkos::Impl::are_integral<I0>::value
680  && ( 1 == Rank )
681  && is_default_map
682  && is_layout_stride
683  ), reference_type >::type
684  operator[]( const I0 & i0 ) const
685  {
686  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0) )
687 
688  return m_map.m_handle[ m_map.m_offset.m_stride.S0 * i0 ];
689  }
690 
691  //------------------------------
692  // Rank 2
693 
694  template< typename I0 , typename I1
695  , class ... Args >
696  KOKKOS_FORCEINLINE_FUNCTION
697  typename std::enable_if<
698  ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
699  && ( 2 == Rank )
700  && ! is_default_map
701  ), reference_type >::type
702  operator()( const I0 & i0 , const I1 & i1
703  , Args ... args ) const
704  {
705  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,args...) )
706 
707  return m_map.reference(i0,i1);
708  }
709 
710  template< typename I0 , typename I1
711  , class ... Args >
712  KOKKOS_FORCEINLINE_FUNCTION
713  typename std::enable_if<
714  ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
715  && ( 2 == Rank )
716  && is_default_map
717  && is_layout_left && ( traits::rank_dynamic == 0 )
718  ), reference_type >::type
719  operator()( const I0 & i0 , const I1 & i1
720  , Args ... args ) const
721  {
722  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,args...) )
723 
724  return m_map.m_handle[ i0 + m_map.m_offset.m_dim.N0 * i1 ];
725  }
726 
727  template< typename I0 , typename I1
728  , class ... Args >
729  KOKKOS_FORCEINLINE_FUNCTION
730  typename std::enable_if<
731  ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
732  && ( 2 == Rank )
733  && is_default_map
734  && is_layout_left && ( traits::rank_dynamic != 0 )
735  ), reference_type >::type
736  operator()( const I0 & i0 , const I1 & i1
737  , Args ... args ) const
738  {
739  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,args...) )
740 
741  return m_map.m_handle[ i0 + m_map.m_offset.m_stride * i1 ];
742  }
743 
744  template< typename I0 , typename I1
745  , class ... Args >
746  KOKKOS_FORCEINLINE_FUNCTION
747  typename std::enable_if<
748  ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
749  && ( 2 == Rank )
750  && is_default_map
751  && is_layout_right && ( traits::rank_dynamic == 0 )
752  ), reference_type >::type
753  operator()( const I0 & i0 , const I1 & i1
754  , Args ... args ) const
755  {
756  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,args...) )
757 
758  return m_map.m_handle[ i1 + m_map.m_offset.m_dim.N1 * i0 ];
759  }
760 
761  template< typename I0 , typename I1
762  , class ... Args >
763  KOKKOS_FORCEINLINE_FUNCTION
764  typename std::enable_if<
765  ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
766  && ( 2 == Rank )
767  && is_default_map
768  && is_layout_right && ( traits::rank_dynamic != 0 )
769  ), reference_type >::type
770  operator()( const I0 & i0 , const I1 & i1
771  , Args ... args ) const
772  {
773  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,args...) )
774 
775  return m_map.m_handle[ i1 + m_map.m_offset.m_stride * i0 ];
776  }
777 
778  template< typename I0 , typename I1
779  , class ... Args >
780  KOKKOS_FORCEINLINE_FUNCTION
781  typename std::enable_if<
782  ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
783  && ( 2 == Rank )
784  && is_default_map
785  && is_layout_stride
786  ), reference_type >::type
787  operator()( const I0 & i0 , const I1 & i1
788  , Args ... args ) const
789  {
790  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,args...) )
791 
792  return m_map.m_handle[ i0 * m_map.m_offset.m_stride.S0 +
793  i1 * m_map.m_offset.m_stride.S1 ];
794  }
795 
796  //------------------------------
797  // Rank 3
798 
799  template< typename I0 , typename I1 , typename I2
800  , class ... Args >
801  KOKKOS_FORCEINLINE_FUNCTION
802  typename std::enable_if<
803  ( Kokkos::Impl::are_integral<I0,I1,I2,Args...>::value
804  && ( 3 == Rank )
805  && is_default_map
806  ), reference_type >::type
807  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2
808  , Args ... args ) const
809  {
810  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,args...) )
811 
812  return m_map.m_handle[ m_map.m_offset(i0,i1,i2) ];
813  }
814 
815  template< typename I0 , typename I1 , typename I2
816  , class ... Args >
817  KOKKOS_FORCEINLINE_FUNCTION
818  typename std::enable_if<
819  ( Kokkos::Impl::are_integral<I0,I1,I2,Args...>::value
820  && ( 3 == Rank )
821  && ! is_default_map
822  ), reference_type >::type
823  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2
824  , Args ... args ) const
825  {
826  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,args...) )
827 
828  return m_map.reference(i0,i1,i2);
829  }
830 
831  //------------------------------
832  // Rank 4
833 
834  template< typename I0 , typename I1 , typename I2 , typename I3
835  , class ... Args >
836  KOKKOS_FORCEINLINE_FUNCTION
837  typename std::enable_if<
838  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,Args...>::value
839  && ( 4 == Rank )
840  && is_default_map
841  ), reference_type >::type
842  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
843  , Args ... args ) const
844  {
845  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,i3,args...) )
846 
847  return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3) ];
848  }
849 
850  template< typename I0 , typename I1 , typename I2 , typename I3
851  , class ... Args >
852  KOKKOS_FORCEINLINE_FUNCTION
853  typename std::enable_if<
854  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,Args...>::value
855  && ( 4 == Rank )
856  && ! is_default_map
857  ), reference_type >::type
858  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
859  , Args ... args ) const
860  {
861  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,i3,args...) )
862 
863  return m_map.reference(i0,i1,i2,i3);
864  }
865 
866  //------------------------------
867  // Rank 5
868 
869  template< typename I0 , typename I1 , typename I2 , typename I3
870  , typename I4
871  , class ... Args >
872  KOKKOS_FORCEINLINE_FUNCTION
873  typename std::enable_if<
874  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,Args...>::value
875  && ( 5 == Rank )
876  && is_default_map
877  ), reference_type >::type
878  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
879  , const I4 & i4
880  , Args ... args ) const
881  {
882  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,i3,i4,args...) )
883 
884  return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4) ];
885  }
886 
887  template< typename I0 , typename I1 , typename I2 , typename I3
888  , typename I4
889  , class ... Args >
890  KOKKOS_FORCEINLINE_FUNCTION
891  typename std::enable_if<
892  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,Args...>::value
893  && ( 5 == Rank )
894  && ! is_default_map
895  ), reference_type >::type
896  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
897  , const I4 & i4
898  , Args ... args ) const
899  {
900  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,i3,i4,args...) )
901 
902  return m_map.reference(i0,i1,i2,i3,i4);
903  }
904 
905  //------------------------------
906  // Rank 6
907 
908  template< typename I0 , typename I1 , typename I2 , typename I3
909  , typename I4 , typename I5
910  , class ... Args >
911  KOKKOS_FORCEINLINE_FUNCTION
912  typename std::enable_if<
913  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,Args...>::value
914  && ( 6 == Rank )
915  && is_default_map
916  ), reference_type >::type
917  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
918  , const I4 & i4 , const I5 & i5
919  , Args ... args ) const
920  {
921  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,i3,i4,i5,args...) )
922 
923  return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5) ];
924  }
925 
926  template< typename I0 , typename I1 , typename I2 , typename I3
927  , typename I4 , typename I5
928  , class ... Args >
929  KOKKOS_FORCEINLINE_FUNCTION
930  typename std::enable_if<
931  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,Args...>::value
932  && ( 6 == Rank )
933  && ! is_default_map
934  ), reference_type >::type
935  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
936  , const I4 & i4 , const I5 & i5
937  , Args ... args ) const
938  {
939  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,i3,i4,i5,args...) )
940 
941  return m_map.reference(i0,i1,i2,i3,i4,i5);
942  }
943 
944  //------------------------------
945  // Rank 7
946 
947  template< typename I0 , typename I1 , typename I2 , typename I3
948  , typename I4 , typename I5 , typename I6
949  , class ... Args >
950  KOKKOS_FORCEINLINE_FUNCTION
951  typename std::enable_if<
952  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,Args...>::value
953  && ( 7 == Rank )
954  && is_default_map
955  ), reference_type >::type
956  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
957  , const I4 & i4 , const I5 & i5 , const I6 & i6
958  , Args ... args ) const
959  {
960  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,i3,i4,i5,i6,args...) )
961 
962  return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5,i6) ];
963  }
964 
965  template< typename I0 , typename I1 , typename I2 , typename I3
966  , typename I4 , typename I5 , typename I6
967  , class ... Args >
968  KOKKOS_FORCEINLINE_FUNCTION
969  typename std::enable_if<
970  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,Args...>::value
971  && ( 7 == Rank )
972  && ! is_default_map
973  ), reference_type >::type
974  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
975  , const I4 & i4 , const I5 & i5 , const I6 & i6
976  , Args ... args ) const
977  {
978  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,i3,i4,i5,i6,args...) )
979 
980  return m_map.reference(i0,i1,i2,i3,i4,i5,i6);
981  }
982 
983  //------------------------------
984  // Rank 8
985 
986  template< typename I0 , typename I1 , typename I2 , typename I3
987  , typename I4 , typename I5 , typename I6 , typename I7
988  , class ... Args >
989  KOKKOS_FORCEINLINE_FUNCTION
990  typename std::enable_if<
991  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,I7,Args...>::value
992  && ( 8 == Rank )
993  && is_default_map
994  ), reference_type >::type
995  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
996  , const I4 & i4 , const I5 & i5 , const I6 & i6 , const I7 & i7
997  , Args ... args ) const
998  {
999  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,i3,i4,i5,i6,i7,args...) )
1000 
1001  return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5,i6,i7) ];
1002  }
1003 
1004  template< typename I0 , typename I1 , typename I2 , typename I3
1005  , typename I4 , typename I5 , typename I6 , typename I7
1006  , class ... Args >
1007  KOKKOS_FORCEINLINE_FUNCTION
1008  typename std::enable_if<
1009  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,I7,Args...>::value
1010  && ( 8 == Rank )
1011  && ! is_default_map
1012  ), reference_type >::type
1013  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1014  , const I4 & i4 , const I5 & i5 , const I6 & i6 , const I7 & i7
1015  , Args ... args ) const
1016  {
1017  KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,i3,i4,i5,i6,i7,args...) )
1018 
1019  return m_map.reference(i0,i1,i2,i3,i4,i5,i6,i7);
1020  }
1021 
1022 #undef KOKKOS_VIEW_OPERATOR_VERIFY
1023 
1024  //----------------------------------------
1025  // Standard destructor, constructors, and assignment operators
1026 
1027  KOKKOS_INLINE_FUNCTION
1028  ~View() {}
1029 
1030  KOKKOS_INLINE_FUNCTION
1031  View() : m_track(), m_map() {}
1032 
1033  KOKKOS_INLINE_FUNCTION
1034  View( const View & rhs ) : m_track( rhs.m_track ), m_map( rhs.m_map ) {}
1035 
1036  KOKKOS_INLINE_FUNCTION
1037  View( View && rhs ) : m_track( rhs.m_track ), m_map( rhs.m_map ) {}
1038 
1039  KOKKOS_INLINE_FUNCTION
1040  View & operator = ( const View & rhs ) { m_track = rhs.m_track ; m_map = rhs.m_map ; return *this ; }
1041 
1042  KOKKOS_INLINE_FUNCTION
1043  View & operator = ( View && rhs ) { m_track = rhs.m_track ; m_map = rhs.m_map ; return *this ; }
1044 
1045  //----------------------------------------
1046  // Compatible view copy constructor and assignment
1047  // may assign unmanaged from managed.
1048 
1049  template< class RT , class ... RP >
1050  KOKKOS_INLINE_FUNCTION
1051  View( const View<RT,RP...> & rhs )
1052  : m_track( rhs.m_track , traits::is_managed )
1053  , m_map()
1054  {
1055  typedef typename View<RT,RP...>::traits SrcTraits ;
1056  typedef Kokkos::Experimental::Impl::ViewMapping< traits , SrcTraits , void > Mapping ;
1057  static_assert( Mapping::is_assignable , "Incompatible View copy construction" );
1058  Mapping::assign( m_map , rhs.m_map , rhs.m_track );
1059  }
1060 
1061  template< class RT , class ... RP >
1062  KOKKOS_INLINE_FUNCTION
1063  View & operator = ( const View<RT,RP...> & rhs )
1064  {
1065  typedef typename View<RT,RP...>::traits SrcTraits ;
1066  typedef Kokkos::Experimental::Impl::ViewMapping< traits , SrcTraits , void > Mapping ;
1067  static_assert( Mapping::is_assignable , "Incompatible View copy assignment" );
1068  Mapping::assign( m_map , rhs.m_map , rhs.m_track );
1069  m_track.assign( rhs.m_track , traits::is_managed );
1070  return *this ;
1071  }
1072 
1073  //----------------------------------------
1074  // Compatible subview constructor
1075  // may assign unmanaged from managed.
1076 
1077  template< class RT , class ... RP , class Arg0 , class ... Args >
1078  KOKKOS_INLINE_FUNCTION
1079  View( const View< RT , RP... > & src_view
1080  , const Arg0 & arg0 , Args ... args )
1081  : m_track( src_view.m_track , traits::is_managed )
1082  , m_map()
1083  {
1084  typedef View< RT , RP... > SrcType ;
1085 
1086  typedef Kokkos::Experimental::Impl::ViewMapping
1087  < void /* deduce destination view type from source view traits */
1088  , typename SrcType::traits
1089  , Arg0 , Args... > Mapping ;
1090 
1091  typedef typename Mapping::type DstType ;
1092 
1093  static_assert( Kokkos::Experimental::Impl::ViewMapping< View , DstType , void >::is_assignable
1094  , "Subview construction requires compatible view and subview arguments" );
1095 
1096  Mapping::assign( m_map, src_view.m_map, arg0 , args... );
1097  }
1098 
1099  //----------------------------------------
1100  // Allocation according to allocation properties
1101 
1102 private:
1103 
1104  // Must call destructor for non-trivial types
1105  template< class ExecSpace >
1106  struct DestroyFunctor {
1107  map_type m_map ;
1108  ExecSpace m_space ;
1109 
1110  void destroy_shared_allocation() { m_map.destroy( m_space ); }
1111  };
1112 
1113 public:
1114 
1115  KOKKOS_INLINE_FUNCTION
1116  int use_count() const { return m_track.use_count(); }
1117 
1118  inline
1119  const std::string label() const { return m_track.template get_label< typename traits::memory_space >(); }
1120 
1121  // Disambiguate from subview constructor.
1122  template< class Prop >
1123  explicit inline
1124  View( const Prop & arg_prop
1125  , typename std::enable_if< ! is_view<Prop>::value ,
1126  const size_t >::type arg_N0 = 0
1127  , const size_t arg_N1 = 0
1128  , const size_t arg_N2 = 0
1129  , const size_t arg_N3 = 0
1130  , const size_t arg_N4 = 0
1131  , const size_t arg_N5 = 0
1132  , const size_t arg_N6 = 0
1133  , const size_t arg_N7 = 0
1134  )
1135  : m_track()
1136  , m_map()
1137  {
1138  // Merge the < execution_space , memory_space > into the properties.
1139  typedef Kokkos::Experimental::Impl::ViewAllocProp< typename traits::device_type , Prop > alloc_prop ;
1140 
1141  typedef typename alloc_prop::execution_space execution_space ;
1142  typedef typename traits::memory_space memory_space ;
1143  typedef DestroyFunctor< execution_space > destroy_functor ;
1144  typedef Kokkos::Experimental::Impl::SharedAllocationRecord< memory_space , destroy_functor > record_type ;
1145 
1146  static_assert( traits::is_managed , "View allocation constructor requires managed memory" );
1147 
1148  const alloc_prop prop( arg_prop );
1149 
1150  // If initializing view data then the execution space must be initialized.
1151  if ( prop.initialize.value && ! prop.execution.is_initialized() ) {
1152  Kokkos::Impl::throw_runtime_exception("Constructing View and initializing data with uninitialized execution space");
1153  }
1154 
1155  // Query the mapping for byte-size of allocation.
1156  const size_t alloc_size = map_type::memory_span( prop.allow_padding
1157  , arg_N0 , arg_N1 , arg_N2 , arg_N3
1158  , arg_N4 , arg_N5 , arg_N6 , arg_N7 );
1159 
1160  // Allocate memory from the memory space.
1161  record_type * const record = record_type::allocate( prop.memory , prop.label , alloc_size );
1162 
1163  // Construct the mapping object prior to start of tracking
1164  // to assign destroy functor and possibly initialize.
1165  m_map = map_type( reinterpret_cast< pointer_type >( record->data() )
1166  , prop.allow_padding
1167  , arg_N0 , arg_N1 , arg_N2 , arg_N3
1168  , arg_N4 , arg_N5 , arg_N6 , arg_N7 );
1169 
1170  // If constructing the plan for destructing as well
1171  // Copy the destroy functor into the allocation record
1172  // before initiating tracking.
1173  if ( prop.initialize.value ) {
1174  m_map.construct( prop.execution );
1175 
1176  record->m_destroy.m_map = m_map ;
1177  record->m_destroy.m_space = prop.execution ;
1178  }
1179 
1180  // Setup and initialization complete, start tracking
1181  m_track.assign_allocated_record_to_uninitialized( record );
1182  }
1183 
1184  template< class Prop >
1185  explicit inline
1186  View( const Prop & arg_prop
1187  , const typename traits::array_layout & arg_layout
1188  )
1189  : m_track()
1190  , m_map()
1191  {
1192  // Merge the < execution_space , memory_space > into the properties.
1193  typedef Kokkos::Experimental::Impl::ViewAllocProp< typename traits::device_type , Prop > alloc_prop ;
1194 
1195  typedef typename alloc_prop::execution_space execution_space ;
1196  typedef typename traits::memory_space memory_space ;
1197  typedef DestroyFunctor< execution_space > destroy_functor ;
1198  typedef Kokkos::Experimental::Impl::SharedAllocationRecord< memory_space , destroy_functor > record_type ;
1199 
1200  static_assert( traits::is_managed , "View allocation constructor requires managed memory" );
1201 
1202  const alloc_prop prop( arg_prop );
1203 
1204  // If initializing view data then the execution space must be initialized.
1205  if ( prop.initialize.value && ! prop.execution.is_initialized() ) {
1206  Kokkos::Impl::throw_runtime_exception("Constructing View and initializing data with uninitialized execution space");
1207  }
1208 
1209  // Query the mapping for byte-size of allocation.
1210  const size_t alloc_size = map_type::memory_span( prop.allow_padding , arg_layout );
1211 
1212  // Allocate memory from the memory space.
1213  record_type * const record = record_type::allocate( prop.memory , prop.label , alloc_size );
1214 
1215  // Construct the mapping object prior to start of tracking
1216  // to assign destroy functor and possibly initialize.
1217  m_map = map_type( reinterpret_cast< pointer_type >( record->data() ) , prop.allow_padding , arg_layout );
1218 
1219  // Copy the destroy functor into the allocation record before initiating tracking.
1220 
1221  if ( prop.initialize.value ) {
1222  m_map.construct( prop.execution );
1223 
1224  record->m_destroy.m_map = m_map ;
1225  record->m_destroy.m_space = prop.execution ;
1226  }
1227 
1228  // Setup and initialization complete, start tracking
1229  m_track.assign_allocated_record_to_uninitialized( record );
1230  }
1231 
1232  //----------------------------------------
1233  // Memory span required to wrap these dimensions.
1234  static constexpr size_t memory_span( const size_t arg_N0 = 0
1235  , const size_t arg_N1 = 0
1236  , const size_t arg_N2 = 0
1237  , const size_t arg_N3 = 0
1238  , const size_t arg_N4 = 0
1239  , const size_t arg_N5 = 0
1240  , const size_t arg_N6 = 0
1241  , const size_t arg_N7 = 0
1242  )
1243  {
1244  return map_type::memory_span( std::integral_constant<bool,false>()
1245  , arg_N0 , arg_N1 , arg_N2 , arg_N3
1246  , arg_N4 , arg_N5 , arg_N6 , arg_N7 );
1247  }
1248 
1249  explicit inline
1250  View( pointer_type arg_ptr
1251  , const size_t arg_N0 = 0
1252  , const size_t arg_N1 = 0
1253  , const size_t arg_N2 = 0
1254  , const size_t arg_N3 = 0
1255  , const size_t arg_N4 = 0
1256  , const size_t arg_N5 = 0
1257  , const size_t arg_N6 = 0
1258  , const size_t arg_N7 = 0
1259  )
1260  : m_track() // No memory tracking
1261  , m_map( arg_ptr , std::integral_constant<bool,false>()
1262  , arg_N0 , arg_N1 , arg_N2 , arg_N3
1263  , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
1264  {}
1265 
1266  explicit inline
1267  View( pointer_type arg_ptr
1268  , typename traits::array_layout & arg_layout
1269  )
1270  : m_track() // No memory tracking
1271  , m_map( arg_ptr , std::integral_constant<bool,false>(), arg_layout )
1272  {}
1273 
1274  //----------------------------------------
1275  // Shared scratch memory constructor
1276 
1277  static inline
1278  size_t shmem_size( const size_t arg_N0 = 0 ,
1279  const size_t arg_N1 = 0 ,
1280  const size_t arg_N2 = 0 ,
1281  const size_t arg_N3 = 0 ,
1282  const size_t arg_N4 = 0 ,
1283  const size_t arg_N5 = 0 ,
1284  const size_t arg_N6 = 0 ,
1285  const size_t arg_N7 = 0 )
1286  {
1287  return map_type::memory_span( std::integral_constant<bool,false>()
1288  , arg_N0 , arg_N1 , arg_N2 , arg_N3
1289  , arg_N4 , arg_N5 , arg_N6 , arg_N7 );
1290  }
1291 
1292  explicit KOKKOS_INLINE_FUNCTION
1293  View( const typename traits::execution_space::scratch_memory_space & arg_space
1294  , const size_t arg_N0 = 0
1295  , const size_t arg_N1 = 0
1296  , const size_t arg_N2 = 0
1297  , const size_t arg_N3 = 0
1298  , const size_t arg_N4 = 0
1299  , const size_t arg_N5 = 0
1300  , const size_t arg_N6 = 0
1301  , const size_t arg_N7 = 0 )
1302  : m_track() // No memory tracking
1303  , m_map( reinterpret_cast<pointer_type>(
1304  arg_space.get_shmem(
1305  map_type::memory_span( std::integral_constant<bool,false>()
1306  , arg_N0 , arg_N1 , arg_N2 , arg_N3
1307  , arg_N4 , arg_N5 , arg_N6 , arg_N7 ) ) )
1308  , std::integral_constant<bool,false>()
1309  , arg_N0 , arg_N1 , arg_N2 , arg_N3
1310  , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
1311  {}
1312 };
1313 
1314 //----------------------------------------------------------------------------
1315 //----------------------------------------------------------------------------
1316 
1317 template< class V , class ... Args >
1318 using Subview =
1319  typename Kokkos::Experimental::Impl::ViewMapping
1320  < void /* deduce subview type from source view traits */
1321  , V
1322  , Args ...
1323  >::type ;
1324 
1325 template< class D, class ... P , class ... Args >
1326 KOKKOS_INLINE_FUNCTION
1327 typename Kokkos::Experimental::Impl::ViewMapping
1328  < void /* deduce subview type from source view traits */
1329  , ViewTraits< D , P... >
1330  , Args ...
1331  >::type
1332 subview( const View< D, P... > & src , Args ... args )
1333 {
1334  static_assert( View< D , P... >::Rank == sizeof...(Args) ,
1335  "subview requires one argument for each source View rank" );
1336 
1337  return typename
1338  Kokkos::Experimental::Impl::ViewMapping
1339  < void /* deduce subview type from source view traits */
1340  , ViewTraits< D , P ... >
1341  , Args ... >::type( src , args ... );
1342 }
1343 
1344 template< class MemoryTraits , class D, class ... P , class ... Args >
1345 KOKKOS_INLINE_FUNCTION
1346 typename Kokkos::Experimental::Impl::ViewMapping
1347  < void /* deduce subview type from source view traits */
1348  , ViewTraits< D , P... >
1349  , Args ...
1350  >::template apply< MemoryTraits >::type
1351 subview( const View< D, P... > & src , Args ... args )
1352 {
1353  static_assert( View< D , P... >::Rank == sizeof...(Args) ,
1354  "subview requires one argument for each source View rank" );
1355 
1356  return typename
1357  Kokkos::Experimental::Impl::ViewMapping
1358  < void /* deduce subview type from source view traits */
1359  , ViewTraits< D , P ... >
1360  , Args ... >
1361  ::template apply< MemoryTraits >
1362  ::type( src , args ... );
1363 }
1364 
1365 
1366 
1367 } /* namespace Experimental */
1368 } /* namespace Kokkos */
1369 
1370 //----------------------------------------------------------------------------
1371 //----------------------------------------------------------------------------
1372 
1373 namespace Kokkos {
1374 namespace Experimental {
1375 
1376 template< class LT , class ... LP , class RT , class ... RP >
1377 KOKKOS_INLINE_FUNCTION
1378 bool operator == ( const View<LT,LP...> & lhs ,
1379  const View<RT,RP...> & rhs )
1380 {
1381  // Same data, layout, dimensions
1382  typedef ViewTraits<LT,LP...> lhs_traits ;
1383  typedef ViewTraits<RT,RP...> rhs_traits ;
1384 
1385  return
1386  std::is_same< typename lhs_traits::const_value_type ,
1387  typename rhs_traits::const_value_type >::value &&
1388  std::is_same< typename lhs_traits::array_layout ,
1389  typename rhs_traits::array_layout >::value &&
1390  std::is_same< typename lhs_traits::memory_space ,
1391  typename rhs_traits::memory_space >::value &&
1392  lhs_traits::rank == rhs_traits::rank &&
1393  lhs.data() == rhs.data() &&
1394  lhs.span() == rhs.span() &&
1395  lhs.dimension_0() == rhs.dimension_0() &&
1396  lhs.dimension_1() == rhs.dimension_1() &&
1397  lhs.dimension_2() == rhs.dimension_2() &&
1398  lhs.dimension_3() == rhs.dimension_3() &&
1399  lhs.dimension_4() == rhs.dimension_4() &&
1400  lhs.dimension_5() == rhs.dimension_5() &&
1401  lhs.dimension_6() == rhs.dimension_6() &&
1402  lhs.dimension_7() == rhs.dimension_7();
1403 }
1404 
1405 template< class LT , class ... LP , class RT , class ... RP >
1406 KOKKOS_INLINE_FUNCTION
1407 bool operator != ( const View<LT,LP...> & lhs ,
1408  const View<RT,RP...> & rhs )
1409 {
1410  return ! ( operator==(lhs,rhs) );
1411 }
1412 
1413 } /* namespace Experimental */
1414 } /* namespace Kokkos */
1415 
1416 //----------------------------------------------------------------------------
1417 //----------------------------------------------------------------------------
1418 
1419 namespace Kokkos {
1420 namespace Impl {
1421 
1422 #if defined( KOKKOS_USING_EXPERIMENTAL_VIEW )
1423 
1424 inline
1425 void shared_allocation_tracking_claim_and_disable()
1426 { Kokkos::Experimental::Impl::SharedAllocationRecord<void,void>::tracking_claim_and_disable(); }
1427 
1428 inline
1429 void shared_allocation_tracking_release_and_enable()
1430 { Kokkos::Experimental::Impl::SharedAllocationRecord<void,void>::tracking_release_and_enable(); }
1431 
1432 #else
1433 
1434 inline
1435 void shared_allocation_tracking_claim_and_disable()
1436 { Kokkos::Impl::AllocationTracker::disable_tracking(); }
1437 
1438 inline
1439 void shared_allocation_tracking_release_and_enable()
1440 { Kokkos::Impl::AllocationTracker::enable_tracking(); }
1441 
1442 #endif
1443 
1444 } /* namespace Impl */
1445 } /* namespace Kokkos */
1446 
1447 //----------------------------------------------------------------------------
1448 //----------------------------------------------------------------------------
1449 
1450 namespace Kokkos {
1451 namespace Experimental {
1452 namespace Impl {
1453 
1454 template< class OutputView , typename Enable = void >
1455 struct ViewFill {
1456 
1457  typedef typename OutputView::const_value_type const_value_type ;
1458 
1459  const OutputView output ;
1460  const_value_type input ;
1461 
1462  KOKKOS_INLINE_FUNCTION
1463  void operator()( const size_t i0 ) const
1464  {
1465  const size_t n1 = output.dimension_1();
1466  const size_t n2 = output.dimension_2();
1467  const size_t n3 = output.dimension_3();
1468  const size_t n4 = output.dimension_4();
1469  const size_t n5 = output.dimension_5();
1470  const size_t n6 = output.dimension_6();
1471  const size_t n7 = output.dimension_7();
1472 
1473  for ( size_t i1 = 0 ; i1 < n1 ; ++i1 ) {
1474  for ( size_t i2 = 0 ; i2 < n2 ; ++i2 ) {
1475  for ( size_t i3 = 0 ; i3 < n3 ; ++i3 ) {
1476  for ( size_t i4 = 0 ; i4 < n4 ; ++i4 ) {
1477  for ( size_t i5 = 0 ; i5 < n5 ; ++i5 ) {
1478  for ( size_t i6 = 0 ; i6 < n6 ; ++i6 ) {
1479  for ( size_t i7 = 0 ; i7 < n7 ; ++i7 ) {
1480  output(i0,i1,i2,i3,i4,i5,i6,i7) = input ;
1481  }}}}}}}
1482  }
1483 
1484  ViewFill( const OutputView & arg_out , const_value_type & arg_in )
1485  : output( arg_out ), input( arg_in )
1486  {
1487  typedef typename OutputView::execution_space execution_space ;
1489 
1490  const Kokkos::Impl::ParallelFor< ViewFill , Policy > closure( *this , Policy( 0 , output.dimension_0() ) );
1491 
1492  closure.execute();
1493 
1494  execution_space::fence();
1495  }
1496 };
1497 
1498 template< class OutputView >
1499 struct ViewFill< OutputView , typename std::enable_if< OutputView::Rank == 0 >::type > {
1500  ViewFill( const OutputView & dst , const typename OutputView::const_value_type & src )
1501  {
1502  Kokkos::Impl::DeepCopy< typename OutputView::memory_space , Kokkos::HostSpace >
1503  ( dst.data() , & src , sizeof(typename OutputView::const_value_type) );
1504  }
1505 };
1506 
1507 template< class OutputView , class InputView >
1508 struct ViewRemap {
1509 
1510  const OutputView output ;
1511  const InputView input ;
1512  const size_t n0 ;
1513  const size_t n1 ;
1514  const size_t n2 ;
1515  const size_t n3 ;
1516  const size_t n4 ;
1517  const size_t n5 ;
1518  const size_t n6 ;
1519  const size_t n7 ;
1520 
1521  ViewRemap( const OutputView & arg_out , const InputView & arg_in )
1522  : output( arg_out ), input( arg_in )
1523  , n0( std::min( (size_t)arg_out.dimension_0() , (size_t)arg_in.dimension_0() ) )
1524  , n1( std::min( (size_t)arg_out.dimension_1() , (size_t)arg_in.dimension_1() ) )
1525  , n2( std::min( (size_t)arg_out.dimension_2() , (size_t)arg_in.dimension_2() ) )
1526  , n3( std::min( (size_t)arg_out.dimension_3() , (size_t)arg_in.dimension_3() ) )
1527  , n4( std::min( (size_t)arg_out.dimension_4() , (size_t)arg_in.dimension_4() ) )
1528  , n5( std::min( (size_t)arg_out.dimension_5() , (size_t)arg_in.dimension_5() ) )
1529  , n6( std::min( (size_t)arg_out.dimension_6() , (size_t)arg_in.dimension_6() ) )
1530  , n7( std::min( (size_t)arg_out.dimension_7() , (size_t)arg_in.dimension_7() ) )
1531  {
1532  typedef typename OutputView::execution_space execution_space ;
1534  const Kokkos::Impl::ParallelFor< ViewRemap , Policy > closure( *this , Policy( 0 , n0 ) );
1535  closure.execute();
1536  }
1537 
1538  KOKKOS_INLINE_FUNCTION
1539  void operator()( const size_t i0 ) const
1540  {
1541  for ( size_t i1 = 0 ; i1 < n1 ; ++i1 ) {
1542  for ( size_t i2 = 0 ; i2 < n2 ; ++i2 ) {
1543  for ( size_t i3 = 0 ; i3 < n3 ; ++i3 ) {
1544  for ( size_t i4 = 0 ; i4 < n4 ; ++i4 ) {
1545  for ( size_t i5 = 0 ; i5 < n5 ; ++i5 ) {
1546  for ( size_t i6 = 0 ; i6 < n6 ; ++i6 ) {
1547  for ( size_t i7 = 0 ; i7 < n7 ; ++i7 ) {
1548  output(i0,i1,i2,i3,i4,i5,i6,i7) = input(i0,i1,i2,i3,i4,i5,i6,i7);
1549  }}}}}}}
1550  }
1551 };
1552 
1553 } /* namespace Impl */
1554 } /* namespace Experimental */
1555 } /* namespace Kokkos */
1556 
1557 //----------------------------------------------------------------------------
1558 //----------------------------------------------------------------------------
1559 
1560 namespace Kokkos {
1561 namespace Experimental {
1562 
1564 template< class DT , class ... DP >
1565 inline
1566 void deep_copy
1567  ( const View<DT,DP...> & dst
1568  , typename ViewTraits<DT,DP...>::const_value_type & value
1569  , typename std::enable_if<
1570  std::is_same< typename ViewTraits<DT,DP...>::specialize , void >::value
1571  >::type * = 0 )
1572 {
1573  static_assert(
1574  std::is_same< typename ViewTraits<DT,DP...>::non_const_value_type ,
1575  typename ViewTraits<DT,DP...>::value_type >::value
1576  , "deep_copy requires non-const type" );
1577 
1578  Kokkos::Experimental::Impl::ViewFill< View<DT,DP...> >( dst , value );
1579 }
1580 
1582 template< class ST , class ... SP >
1583 inline
1584 void deep_copy
1585  ( ST & dst
1586  , const View<ST,SP...> & src
1587  , typename std::enable_if<
1588  std::is_same< typename ViewTraits<ST,SP...>::specialize , void >::value
1589  >::type * = 0 )
1590 {
1591  static_assert( ViewTraits<ST,SP...>::rank == 0
1592  , "ERROR: Non-rank-zero view in deep_copy( value , View )" );
1593 
1594  typedef ViewTraits<ST,SP...> src_traits ;
1595  typedef typename src_traits::memory_space src_memory_space ;
1596  Kokkos::Impl::DeepCopy< HostSpace , src_memory_space >( & dst , src.data() , sizeof(ST) );
1597 }
1598 
1599 //----------------------------------------------------------------------------
1601 template< class DT , class ... DP , class ST , class ... SP >
1602 inline
1603 void deep_copy
1604  ( const View<DT,DP...> & dst
1605  , const View<ST,SP...> & src
1606  , typename std::enable_if<(
1607  std::is_same< typename ViewTraits<DT,DP...>::specialize , void >::value &&
1608  std::is_same< typename ViewTraits<ST,SP...>::specialize , void >::value &&
1609  ( unsigned(ViewTraits<DT,DP...>::rank) == unsigned(0) &&
1610  unsigned(ViewTraits<ST,SP...>::rank) == unsigned(0) )
1611  )>::type * = 0 )
1612 {
1613  static_assert(
1614  std::is_same< typename ViewTraits<DT,DP...>::value_type ,
1615  typename ViewTraits<ST,SP...>::non_const_value_type >::value
1616  , "deep_copy requires matching non-const destination type" );
1617 
1618  typedef View<DT,DP...> dst_type ;
1619  typedef View<ST,SP...> src_type ;
1620 
1621  typedef typename dst_type::value_type value_type ;
1622  typedef typename dst_type::memory_space dst_memory_space ;
1623  typedef typename src_type::memory_space src_memory_space ;
1624 
1625  if ( dst.data() != src.data() ) {
1626  Kokkos::Impl::DeepCopy< dst_memory_space , src_memory_space >( dst.data() , src.data() , sizeof(value_type) );
1627  }
1628 }
1629 
1630 //----------------------------------------------------------------------------
1634 template< class DT , class ... DP , class ST , class ... SP >
1635 inline
1636 void deep_copy
1637  ( const View<DT,DP...> & dst
1638  , const View<ST,SP...> & src
1639  , typename std::enable_if<(
1640  std::is_same< typename ViewTraits<DT,DP...>::specialize , void >::value &&
1641  std::is_same< typename ViewTraits<ST,SP...>::specialize , void >::value &&
1642  ( unsigned(ViewTraits<DT,DP...>::rank) != 0 ||
1643  unsigned(ViewTraits<ST,SP...>::rank) != 0 )
1644  )>::type * = 0 )
1645 {
1646  static_assert(
1647  std::is_same< typename ViewTraits<DT,DP...>::value_type ,
1648  typename ViewTraits<DT,DP...>::non_const_value_type >::value
1649  , "deep_copy requires non-const destination type" );
1650 
1651  static_assert(
1652  ( unsigned(ViewTraits<DT,DP...>::rank) ==
1653  unsigned(ViewTraits<ST,SP...>::rank) )
1654  , "deep_copy requires Views of equal rank" );
1655 
1656  typedef View<DT,DP...> dst_type ;
1657  typedef View<ST,SP...> src_type ;
1658 
1659  typedef typename dst_type::execution_space dst_execution_space ;
1660  typedef typename dst_type::memory_space dst_memory_space ;
1661  typedef typename src_type::memory_space src_memory_space ;
1662 
1663  enum { DstExecCanAccessSrc =
1664  Kokkos::Impl::VerifyExecutionCanAccessMemorySpace< typename dst_execution_space::memory_space , src_memory_space >::value };
1665 
1666  if ( (void *) dst.data() != (void*) src.data() ) {
1667 
1668  // Concern: If overlapping views then a parallel copy will be erroneous.
1669  // ...
1670 
1671  // If same type, equal layout, equal dimensions, equal span, and contiguous memory then can byte-wise copy
1672 
1673  if ( std::is_same< typename ViewTraits<DT,DP...>::value_type ,
1674  typename ViewTraits<ST,SP...>::non_const_value_type >::value &&
1675  std::is_same< typename ViewTraits<DT,DP...>::array_layout ,
1676  typename ViewTraits<ST,SP...>::array_layout >::value &&
1677  dst.span_is_contiguous() &&
1678  src.span_is_contiguous() &&
1679  dst.span() == src.span() &&
1680  dst.dimension_0() == src.dimension_0() &&
1681  dst.dimension_1() == src.dimension_1() &&
1682  dst.dimension_2() == src.dimension_2() &&
1683  dst.dimension_3() == src.dimension_3() &&
1684  dst.dimension_4() == src.dimension_4() &&
1685  dst.dimension_5() == src.dimension_5() &&
1686  dst.dimension_6() == src.dimension_6() &&
1687  dst.dimension_7() == src.dimension_7() ) {
1688 
1689  const size_t nbytes = sizeof(typename dst_type::value_type) * dst.span();
1690 
1691  Kokkos::Impl::DeepCopy< dst_memory_space , src_memory_space >( dst.data() , src.data() , nbytes );
1692  }
1693  else if ( DstExecCanAccessSrc ) {
1694  // Copying data between views in accessible memory spaces and either non-contiguous or incompatible shape.
1695  Kokkos::Experimental::Impl::ViewRemap< dst_type , src_type >( dst , src );
1696  }
1697  else {
1698  Kokkos::Impl::throw_runtime_exception("deep_copy given views that would require a temporary allocation");
1699  }
1700  }
1701 }
1702 
1703 } /* namespace Experimental */
1704 } /* namespace Kokkos */
1705 
1706 //----------------------------------------------------------------------------
1707 //----------------------------------------------------------------------------
1708 
1709 namespace Kokkos {
1710 namespace Experimental {
1711 
1712 template< class T , class ... P >
1713 inline
1715 create_mirror( const Kokkos::Experimental::View<T,P...> & src
1716  , typename std::enable_if<
1717  ! std::is_same< typename Kokkos::Experimental::ViewTraits<T,P...>::array_layout
1718  , Kokkos::LayoutStride >::value
1719  >::type * = 0
1720  )
1721 {
1722  typedef View<T,P...> src_type ;
1723  typedef typename src_type::HostMirror dst_type ;
1724 
1725  return dst_type( std::string( src.label() ).append("_mirror")
1726  , src.dimension_0()
1727  , src.dimension_1()
1728  , src.dimension_2()
1729  , src.dimension_3()
1730  , src.dimension_4()
1731  , src.dimension_5()
1732  , src.dimension_6()
1733  , src.dimension_7() );
1734 }
1735 
1736 template< class T , class ... P >
1737 inline
1739 create_mirror( const Kokkos::Experimental::View<T,P...> & src
1740  , typename std::enable_if<
1741  std::is_same< typename Kokkos::Experimental::ViewTraits<T,P...>::array_layout
1742  , Kokkos::LayoutStride >::value
1743  >::type * = 0
1744  )
1745 {
1746  typedef View<T,P...> src_type ;
1747  typedef typename src_type::HostMirror dst_type ;
1748 
1749  Kokkos::LayoutStride layout ;
1750 
1751  layout.dimension[0] = src.dimension_0();
1752  layout.dimension[1] = src.dimension_1();
1753  layout.dimension[2] = src.dimension_2();
1754  layout.dimension[3] = src.dimension_3();
1755  layout.dimension[4] = src.dimension_4();
1756  layout.dimension[5] = src.dimension_5();
1757  layout.dimension[6] = src.dimension_6();
1758  layout.dimension[7] = src.dimension_7();
1759 
1760  layout.stride[0] = src.stride_0();
1761  layout.stride[1] = src.stride_1();
1762  layout.stride[2] = src.stride_2();
1763  layout.stride[3] = src.stride_3();
1764  layout.stride[4] = src.stride_4();
1765  layout.stride[5] = src.stride_5();
1766  layout.stride[6] = src.stride_6();
1767  layout.stride[7] = src.stride_7();
1768 
1769  return dst_type( std::string( src.label() ).append("_mirror") , layout );
1770 }
1771 
1772 template< class T , class ... P >
1773 inline
1775 create_mirror_view( const Kokkos::Experimental::View<T,P...> & src
1776  , typename std::enable_if<(
1777  std::is_same< typename Kokkos::Experimental::View<T,P...>::memory_space
1778  , typename Kokkos::Experimental::View<T,P...>::HostMirror::memory_space
1779  >::value
1780  &&
1781  std::is_same< typename Kokkos::Experimental::View<T,P...>::data_type
1782  , typename Kokkos::Experimental::View<T,P...>::HostMirror::data_type
1783  >::value
1784  )>::type * = 0
1785  )
1786 {
1787  return src ;
1788 }
1789 
1790 template< class T , class ... P >
1791 inline
1793 create_mirror_view( const Kokkos::Experimental::View<T,P...> & src
1794  , typename std::enable_if< ! (
1795  std::is_same< typename Kokkos::Experimental::View<T,P...>::memory_space
1796  , typename Kokkos::Experimental::View<T,P...>::HostMirror::memory_space
1797  >::value
1798  &&
1799  std::is_same< typename Kokkos::Experimental::View<T,P...>::data_type
1800  , typename Kokkos::Experimental::View<T,P...>::HostMirror::data_type
1801  >::value
1802  )>::type * = 0
1803  )
1804 {
1805  return Kokkos::Experimental::create_mirror( src );
1806 }
1807 
1808 } /* namespace Experimental */
1809 } /* namespace Kokkos */
1810 
1811 //----------------------------------------------------------------------------
1812 //----------------------------------------------------------------------------
1813 
1814 namespace Kokkos {
1815 namespace Experimental {
1816 
1818 template< class T , class ... P >
1819 inline
1821  const size_t n0 = 0 ,
1822  const size_t n1 = 0 ,
1823  const size_t n2 = 0 ,
1824  const size_t n3 = 0 ,
1825  const size_t n4 = 0 ,
1826  const size_t n5 = 0 ,
1827  const size_t n6 = 0 ,
1828  const size_t n7 = 0 )
1829 {
1830  typedef Kokkos::Experimental::View<T,P...> view_type ;
1831 
1832  static_assert( Kokkos::Experimental::ViewTraits<T,P...>::is_managed , "Can only resize managed views" );
1833 
1834  view_type v_resized( v.label(), n0, n1, n2, n3, n4, n5, n6, n7 );
1835 
1836  Kokkos::Experimental::Impl::ViewRemap< view_type , view_type >( v_resized , v );
1837 
1838  v = v_resized ;
1839 }
1840 
1842 template< class T , class ... P >
1843 inline
1845  const size_t n0 = 0 ,
1846  const size_t n1 = 0 ,
1847  const size_t n2 = 0 ,
1848  const size_t n3 = 0 ,
1849  const size_t n4 = 0 ,
1850  const size_t n5 = 0 ,
1851  const size_t n6 = 0 ,
1852  const size_t n7 = 0 )
1853 {
1854  typedef Kokkos::Experimental::View<T,P...> view_type ;
1855 
1856  static_assert( Kokkos::Experimental::ViewTraits<T,P...>::is_managed , "Can only realloc managed views" );
1857 
1858  const std::string label = v.label();
1859 
1860  v = view_type(); // Deallocate first, if the only view to allocation
1861  v = view_type( label, n0, n1, n2, n3, n4, n5, n6, n7 );
1862 }
1863 
1864 } /* namespace Experimental */
1865 } /* namespace Kokkos */
1866 
1867 //----------------------------------------------------------------------------
1868 //----------------------------------------------------------------------------
1869 
1870 #if defined( KOKKOS_USING_EXPERIMENTAL_VIEW )
1871 
1872 namespace Kokkos {
1873 
1874 template< class D , class ... P >
1876 
1877 template< class D , class ... P >
1878 using View = Kokkos::Experimental::View<D,P...> ;
1879 
1880 using Kokkos::Experimental::ALL ;
1881 using Kokkos::Experimental::deep_copy ;
1882 using Kokkos::Experimental::create_mirror ;
1883 using Kokkos::Experimental::create_mirror_view ;
1884 using Kokkos::Experimental::subview ;
1885 using Kokkos::Experimental::resize ;
1886 using Kokkos::Experimental::realloc ;
1887 using Kokkos::Experimental::is_view ;
1888 
1889 namespace Impl {
1890 
1891 using Kokkos::Experimental::is_view ;
1892 
1893 class ViewDefault {};
1894 
1895 template< class SrcViewType
1896  , class Arg0Type
1897  , class Arg1Type
1898  , class Arg2Type
1899  , class Arg3Type
1900  , class Arg4Type
1901  , class Arg5Type
1902  , class Arg6Type
1903  , class Arg7Type
1904  >
1905 struct ViewSubview /* { typedef ... type ; } */ ;
1906 
1907 }
1908 
1909 } /* namespace Kokkos */
1910 
1911 #include <impl/Kokkos_Atomic_View.hpp>
1912 
1913 #endif /* #if defined( KOKKOS_USING_EXPERIMENTAL_VIEW ) */
1914 
1915 //----------------------------------------------------------------------------
1916 //----------------------------------------------------------------------------
1917 
1918 #endif
1919 
Tag denoting that a subview should capture all of a dimension.
void deep_copy(const View< DT, DL, DD, DM, DS > &dst, typename Impl::enable_if<(Impl::is_same< typename ViewTraits< DT, DL, DD, DM >::non_const_value_type, typename ViewTraits< DT, DL, DD, DM >::value_type >::value), typename ViewTraits< DT, DL, DD, DM >::const_value_type >::type &value)
Deep copy a value into a view.
Memory layout tag indicating left-to-right (Fortran scheme) striding of multi-indices.
View< typename traits::non_const_data_type, typename traits::array_layout, typename traits::host_mirror_space > HostMirror
Compatible HostMirror view.
KOKKOS_INLINE_FUNCTION bool operator!=(const complex< RealType > &x, const complex< RealType > &y)
Inequality operator for two complex numbers.
View< typename traits::array_scalar_type, typename traits::array_layout, typename traits::device_type, typename traits::memory_traits > array_type
Compatible view of array of scalar types.
Memory layout tag indicated arbitrarily strided multi-index mapping into contiguous memory...
Memory space for main process and CPU execution spaces.
View< typename traits::non_const_data_type, typename traits::array_layout, typename traits::device_type, typename traits::memory_traits > non_const_type
Compatible view of non-const data type.
Memory layout tag indicating right-to-left (C or lexigraphical scheme) striding of multi-indices...
Implementation of the ParallelFor operator that has a partial specialization for the device...
View< typename traits::const_data_type, typename traits::array_layout, typename traits::device_type, typename traits::memory_traits > const_type
Compatible view of const data type.
KOKKOS_INLINE_FUNCTION bool operator==(const complex< RealType > &x, const complex< RealType > &y)
Equality operator for two complex numbers.
Execution policy for work over a range of an integral type.
void resize(View< T, L, D, M, S > &v, const typename Impl::enable_if< ViewTraits< T, L, D, M >::is_managed, size_t >::type n0, const size_t n1=0, const size_t n2=0, const size_t n3=0, const size_t n4=0, const size_t n5=0, const size_t n6=0, const size_t n7=0)
Resize a view with copying old data to new data at the corresponding indices.
Traits class for accessing attributes of a View.
void realloc(View< T, L, D, M, S > &v, const typename Impl::enable_if< ViewTraits< T, L, D, M >::is_managed, size_t >::type n0, const size_t n1=0, const size_t n2=0, const size_t n3=0, const size_t n4=0, const size_t n5=0, const size_t n6=0, const size_t n7=0)
Reallocate a view without copying old data to new data.
View to an array of data.