Kokkos Core Kernels Package  Version of the Day
Kokkos_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 Christian R. Trott (crtrott@sandia.gov)
39 //
40 // ************************************************************************
41 //@HEADER
42 */
43 
44 #ifndef KOKKOS_VIEW_HPP
45 #define KOKKOS_VIEW_HPP
46 
47 #include <type_traits>
48 #include <string>
49 #include <algorithm>
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 #if defined(KOKKOS_ENABLE_PROFILING)
58 #include <impl/Kokkos_Profiling_Interface.hpp>
59 #endif
60 
61 //----------------------------------------------------------------------------
62 //----------------------------------------------------------------------------
63 
64 namespace Kokkos {
65 namespace Impl {
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 
80 
81 template <typename IntType>
82 KOKKOS_INLINE_FUNCTION
83 std::size_t count_valid_integers(const IntType i0,
84  const IntType i1,
85  const IntType i2,
86  const IntType i3,
87  const IntType i4,
88  const IntType i5,
89  const IntType i6,
90  const IntType i7 ){
91  static_assert(std::is_integral<IntType>::value, "count_valid_integers() must have integer arguments.");
92 
93  return ( i0 !=KOKKOS_INVALID_INDEX ) + ( i1 !=KOKKOS_INVALID_INDEX ) + ( i2 !=KOKKOS_INVALID_INDEX ) +
94  ( i3 !=KOKKOS_INVALID_INDEX ) + ( i4 !=KOKKOS_INVALID_INDEX ) + ( i5 !=KOKKOS_INVALID_INDEX ) +
95  ( i6 !=KOKKOS_INVALID_INDEX ) + ( i7 !=KOKKOS_INVALID_INDEX );
96 
97 
98 }
99 
100 KOKKOS_INLINE_FUNCTION
101 void runtime_check_rank_device(const size_t dyn_rank,
102  const bool is_void_spec,
103  const size_t i0,
104  const size_t i1,
105  const size_t i2,
106  const size_t i3,
107  const size_t i4,
108  const size_t i5,
109  const size_t i6,
110  const size_t i7 ){
111 
112 #ifndef KOKKOS_ENABLE_DEPRECATED_CODE
113 
114  if ( is_void_spec ) {
115  const size_t num_passed_args = count_valid_integers(i0, i1, i2, i3,
116  i4, i5, i6, i7);
117 
118  if ( num_passed_args != dyn_rank && is_void_spec ) {
119 
120  Kokkos::abort("Number of arguments passed to Kokkos::View() constructor must match the dynamic rank of the view.") ;
121 
122  }
123  }
124 #endif
125 }
126 
127 #ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST
128 KOKKOS_INLINE_FUNCTION
129 void runtime_check_rank_host(const size_t dyn_rank,
130  const bool is_void_spec,
131  const size_t i0,
132  const size_t i1,
133  const size_t i2,
134  const size_t i3,
135  const size_t i4,
136  const size_t i5,
137  const size_t i6,
138  const size_t i7, const std::string & label ){
139 
140 #ifndef KOKKOS_ENABLE_DEPRECATED_CODE
141 
142  if ( is_void_spec ) {
143  const size_t num_passed_args = count_valid_integers(i0, i1, i2, i3,
144  i4, i5, i6, i7);
145 
146  if ( num_passed_args != dyn_rank ) {
147 
148  const std::string message = "Constructor for Kokkos View '" + label + "' has mismatched number of arguments. Number of arguments = "
149  + std::to_string(num_passed_args) + " but dynamic rank = " + std::to_string(dyn_rank) + " \n";
150  Kokkos::abort(message.c_str()) ;
151  }
152  }
153 #endif
154 }
155 #endif
156 
157 } /* namespace Impl */
158 } /* namespace Kokkos */
159 
160 // Class to provide a uniform type
161 namespace Kokkos {
162 namespace Impl {
163  template< class ViewType , int Traits = 0 >
164  struct ViewUniformType;
165 }
166 }
167 
168 //----------------------------------------------------------------------------
169 //----------------------------------------------------------------------------
170 
171 namespace Kokkos {
172 
190 template< class DataType , class ... Properties >
191 struct ViewTraits ;
192 
193 template<>
194 struct ViewTraits< void >
195 {
196  typedef void execution_space ;
197  typedef void memory_space ;
198  typedef void HostMirrorSpace ;
199  typedef void array_layout ;
200  typedef void memory_traits ;
201 };
202 
203 template< class ... Prop >
204 struct ViewTraits< void , void , Prop ... >
205 {
206  // Ignore an extraneous 'void'
207  typedef typename ViewTraits<void,Prop...>::execution_space execution_space ;
208  typedef typename ViewTraits<void,Prop...>::memory_space memory_space ;
209  typedef typename ViewTraits<void,Prop...>::HostMirrorSpace HostMirrorSpace ;
210  typedef typename ViewTraits<void,Prop...>::array_layout array_layout ;
211  typedef typename ViewTraits<void,Prop...>::memory_traits memory_traits ;
212 };
213 
214 template< class ArrayLayout , class ... Prop >
215 struct ViewTraits< typename std::enable_if< Kokkos::Impl::is_array_layout<ArrayLayout>::value >::type , ArrayLayout , Prop ... >
216 {
217  // Specify layout, keep subsequent space and memory traits arguments
218 
219  typedef typename ViewTraits<void,Prop...>::execution_space execution_space ;
220  typedef typename ViewTraits<void,Prop...>::memory_space memory_space ;
221  typedef typename ViewTraits<void,Prop...>::HostMirrorSpace HostMirrorSpace ;
222  typedef ArrayLayout array_layout ;
223  typedef typename ViewTraits<void,Prop...>::memory_traits memory_traits ;
224 };
225 
226 template< class Space , class ... Prop >
227 struct ViewTraits< typename std::enable_if< Kokkos::Impl::is_space<Space>::value >::type , Space , Prop ... >
228 {
229  // Specify Space, memory traits should be the only subsequent argument.
230 
231  static_assert( std::is_same< typename ViewTraits<void,Prop...>::execution_space , void >::value &&
232  std::is_same< typename ViewTraits<void,Prop...>::memory_space , void >::value &&
233  std::is_same< typename ViewTraits<void,Prop...>::HostMirrorSpace , void >::value &&
234  std::is_same< typename ViewTraits<void,Prop...>::array_layout , void >::value
235  , "Only one View Execution or Memory Space template argument" );
236 
237  typedef typename Space::execution_space execution_space ;
238  typedef typename Space::memory_space memory_space ;
239  typedef typename Kokkos::Impl::HostMirror< Space >::Space HostMirrorSpace ;
240  typedef typename execution_space::array_layout array_layout ;
241  typedef typename ViewTraits<void,Prop...>::memory_traits memory_traits ;
242 };
243 
244 template< class MemoryTraits , class ... Prop >
245 struct ViewTraits< typename std::enable_if< Kokkos::Impl::is_memory_traits<MemoryTraits>::value >::type , MemoryTraits , Prop ... >
246 {
247  // Specify memory trait, should not be any subsequent arguments
248 
249  static_assert( std::is_same< typename ViewTraits<void,Prop...>::execution_space , void >::value &&
250  std::is_same< typename ViewTraits<void,Prop...>::memory_space , void >::value &&
251  std::is_same< typename ViewTraits<void,Prop...>::array_layout , void >::value &&
252  std::is_same< typename ViewTraits<void,Prop...>::memory_traits , void >::value
253  , "MemoryTrait is the final optional template argument for a View" );
254 
255  typedef void execution_space ;
256  typedef void memory_space ;
257  typedef void HostMirrorSpace ;
258  typedef void array_layout ;
259  typedef MemoryTraits memory_traits ;
260 };
261 
262 
263 template< class DataType , class ... Properties >
264 struct ViewTraits {
265 private:
266 
267  // Unpack the properties arguments
268  typedef ViewTraits< void , Properties ... > prop ;
269 
270  typedef typename
271  std::conditional< ! std::is_same< typename prop::execution_space , void >::value
272  , typename prop::execution_space
273  , Kokkos::DefaultExecutionSpace
274  >::type
275  ExecutionSpace ;
276 
277  typedef typename
278  std::conditional< ! std::is_same< typename prop::memory_space , void >::value
279  , typename prop::memory_space
280  , typename ExecutionSpace::memory_space
281  >::type
282  MemorySpace ;
283 
284  typedef typename
285  std::conditional< ! std::is_same< typename prop::array_layout , void >::value
286  , typename prop::array_layout
287  , typename ExecutionSpace::array_layout
288  >::type
289  ArrayLayout ;
290 
291  typedef typename
292  std::conditional
293  < ! std::is_same< typename prop::HostMirrorSpace , void >::value
294  , typename prop::HostMirrorSpace
295  , typename Kokkos::Impl::HostMirror< ExecutionSpace >::Space
296  >::type
297  HostMirrorSpace ;
298 
299  typedef typename
300  std::conditional< ! std::is_same< typename prop::memory_traits , void >::value
301  , typename prop::memory_traits
302  , typename Kokkos::MemoryManaged
303  >::type
304  MemoryTraits ;
305 
306  // Analyze data type's properties,
307  // May be specialized based upon the layout and value type
308  typedef Kokkos::Impl::ViewDataAnalysis< DataType , ArrayLayout > data_analysis ;
309 
310 public:
311 
312  //------------------------------------
313  // Data type traits:
314 
315  typedef typename data_analysis::type data_type ;
316  typedef typename data_analysis::const_type const_data_type ;
317  typedef typename data_analysis::non_const_type non_const_data_type ;
318 
319  //------------------------------------
320  // Compatible array of trivial type traits:
321 
322  typedef typename data_analysis::scalar_array_type scalar_array_type ;
323  typedef typename data_analysis::const_scalar_array_type const_scalar_array_type ;
324  typedef typename data_analysis::non_const_scalar_array_type non_const_scalar_array_type ;
325 
326  //------------------------------------
327  // Value type traits:
328 
329  typedef typename data_analysis::value_type value_type ;
330  typedef typename data_analysis::const_value_type const_value_type ;
331  typedef typename data_analysis::non_const_value_type non_const_value_type ;
332 
333  //------------------------------------
334  // Mapping traits:
335 
336  typedef ArrayLayout array_layout ;
337  typedef typename data_analysis::dimension dimension ;
338  typedef typename data_analysis::specialize specialize /* mapping specialization tag */ ;
339 
340  enum { rank = dimension::rank };
341  enum { rank_dynamic = dimension::rank_dynamic };
342 
343  //------------------------------------
344  // Execution space, memory space, memory access traits, and host mirror space.
345 
346  typedef ExecutionSpace execution_space ;
347  typedef MemorySpace memory_space ;
348  typedef Kokkos::Device<ExecutionSpace,MemorySpace> device_type ;
349  typedef MemoryTraits memory_traits ;
350  typedef HostMirrorSpace host_mirror_space ;
351 
352  typedef typename MemorySpace::size_type size_type ;
353 
354  enum { is_hostspace = std::is_same< MemorySpace , HostSpace >::value };
355  enum { is_managed = MemoryTraits::Unmanaged == 0 };
356  enum { is_random_access = MemoryTraits::RandomAccess == 1 };
357 
358  //------------------------------------
359 };
360 
443 template< class DataType , class ... Properties >
444 class View ;
445 
446 } /* namespace Kokkos */
447 
448 //----------------------------------------------------------------------------
449 //----------------------------------------------------------------------------
450 
451 #include <impl/Kokkos_ViewMapping.hpp>
452 #include <impl/Kokkos_ViewArray.hpp>
453 
454 //----------------------------------------------------------------------------
455 //----------------------------------------------------------------------------
456 
457 namespace Kokkos {
458 
459 namespace {
460 
461 constexpr Kokkos::Impl::ALL_t
462  ALL = Kokkos::Impl::ALL_t();
463 
464 constexpr Kokkos::Impl::WithoutInitializing_t
465  WithoutInitializing = Kokkos::Impl::WithoutInitializing_t();
466 
467 constexpr Kokkos::Impl::AllowPadding_t
468  AllowPadding = Kokkos::Impl::AllowPadding_t();
469 
470 }
471 
481 template< class ... Args >
482 inline
483 Impl::ViewCtorProp< typename Impl::ViewCtorProp< void , Args >::type ... >
484 view_alloc( Args const & ... args )
485 {
486  typedef
487  Impl::ViewCtorProp< typename Impl::ViewCtorProp< void , Args >::type ... >
488  return_type ;
489 
490  static_assert( ! return_type::has_pointer
491  , "Cannot give pointer-to-memory for view allocation" );
492 
493  return return_type( args... );
494 }
495 
496 template< class ... Args >
497 KOKKOS_INLINE_FUNCTION
498 Impl::ViewCtorProp< typename Impl::ViewCtorProp< void , Args >::type ... >
499 view_wrap( Args const & ... args )
500 {
501  typedef
502  Impl::ViewCtorProp< typename Impl::ViewCtorProp< void , Args >::type ... >
503  return_type ;
504 
505  static_assert( ! return_type::has_memory_space &&
506  ! return_type::has_execution_space &&
507  ! return_type::has_label &&
508  return_type::has_pointer
509  , "Must only give pointer-to-memory for view wrapping" );
510 
511  return return_type( args... );
512 }
513 
514 } /* namespace Kokkos */
515 
516 //----------------------------------------------------------------------------
517 //----------------------------------------------------------------------------
518 
519 namespace Kokkos {
520 
521 template< class DataType , class ... Properties >
522 class View ;
523 
524 template< class > struct is_view : public std::false_type {};
525 
526 template< class D, class ... P >
527 struct is_view< View<D,P...> > : public std::true_type {};
528 
529 template< class D, class ... P >
530 struct is_view< const View<D,P...> > : public std::true_type {};
531 
532 template< class DataType , class ... Properties >
533 class View : public ViewTraits< DataType , Properties ... > {
534 private:
535 
536  template< class , class ... > friend class View ;
537  template< class , class ... > friend class Kokkos::Impl::ViewMapping ;
538 
539 public:
540 
541  typedef ViewTraits< DataType , Properties ... > traits ;
542 
543 private:
544 
545  typedef Kokkos::Impl::ViewMapping< traits , void > map_type ;
546  typedef Kokkos::Impl::SharedAllocationTracker track_type ;
547 
548  track_type m_track ;
549  map_type m_map ;
550 
551 public:
552 
553  //----------------------------------------
555  typedef View< typename traits::scalar_array_type ,
556  typename traits::array_layout ,
557  typename traits::device_type ,
558  typename traits::memory_traits >
560 
562  typedef View< typename traits::const_data_type ,
563  typename traits::array_layout ,
564  typename traits::device_type ,
565  typename traits::memory_traits >
567 
569  typedef View< typename traits::non_const_data_type ,
570  typename traits::array_layout ,
571  typename traits::device_type ,
572  typename traits::memory_traits >
574 
576  typedef View< typename traits::non_const_data_type ,
577  typename traits::array_layout ,
578  typename traits::host_mirror_space >
580 
582  typedef View< typename traits::non_const_data_type ,
583  typename traits::array_layout ,
584  typename traits::host_mirror_space >
586 
588  typedef typename Impl::ViewUniformType<View,0>::type uniform_type;
589  typedef typename Impl::ViewUniformType<View,0>::const_type uniform_const_type;
590  typedef typename Impl::ViewUniformType<View,0>::runtime_type uniform_runtime_type;
591  typedef typename Impl::ViewUniformType<View,0>::runtime_const_type uniform_runtime_const_type;
592  typedef typename Impl::ViewUniformType<View,0>::nomemspace_type uniform_nomemspace_type;
593  typedef typename Impl::ViewUniformType<View,0>::const_nomemspace_type uniform_const_nomemspace_type;
594  typedef typename Impl::ViewUniformType<View,0>::runtime_nomemspace_type uniform_runtime_nomemspace_type;
595  typedef typename Impl::ViewUniformType<View,0>::runtime_const_nomemspace_type uniform_runtime_const_nomemspace_type;
596 
597  //----------------------------------------
598  // Domain rank and extents
599 
600  enum { Rank = map_type::Rank };
601 
604  //KOKKOS_INLINE_FUNCTION
605  //static
606  //constexpr unsigned rank() { return map_type::Rank; }
607 
608  template< typename iType >
609  KOKKOS_INLINE_FUNCTION constexpr
610  typename std::enable_if< std::is_integral<iType>::value , size_t >::type
611  extent( const iType & r ) const
612  { return m_map.extent(r); }
613 
614  template< typename iType >
615  KOKKOS_INLINE_FUNCTION constexpr
616  typename std::enable_if< std::is_integral<iType>::value , int >::type
617  extent_int( const iType & r ) const
618  { return static_cast<int>(m_map.extent(r)); }
619 
620  KOKKOS_INLINE_FUNCTION constexpr
621  typename traits::array_layout layout() const
622  { return m_map.layout(); }
623 
624  //----------------------------------------
625  /* Deprecate all 'dimension' functions in favor of
626  * ISO/C++ vocabulary 'extent'.
627  */
628 
629 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE
630 
631  template< typename iType >
632  KOKKOS_INLINE_FUNCTION constexpr
633  typename std::enable_if< std::is_integral<iType>::value , size_t >::type
634  dimension( const iType & r ) const { return extent( r ); }
635 
636  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_0() const { return m_map.dimension_0(); }
637  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_1() const { return m_map.dimension_1(); }
638  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_2() const { return m_map.dimension_2(); }
639  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_3() const { return m_map.dimension_3(); }
640  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_4() const { return m_map.dimension_4(); }
641  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_5() const { return m_map.dimension_5(); }
642  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_6() const { return m_map.dimension_6(); }
643  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_7() const { return m_map.dimension_7(); }
644 
645 #endif
646 
647  //----------------------------------------
648 
649  KOKKOS_INLINE_FUNCTION constexpr size_t size() const { return m_map.dimension_0() *
650  m_map.dimension_1() *
651  m_map.dimension_2() *
652  m_map.dimension_3() *
653  m_map.dimension_4() *
654  m_map.dimension_5() *
655  m_map.dimension_6() *
656  m_map.dimension_7(); }
657 
658  KOKKOS_INLINE_FUNCTION constexpr size_t stride_0() const { return m_map.stride_0(); }
659  KOKKOS_INLINE_FUNCTION constexpr size_t stride_1() const { return m_map.stride_1(); }
660  KOKKOS_INLINE_FUNCTION constexpr size_t stride_2() const { return m_map.stride_2(); }
661  KOKKOS_INLINE_FUNCTION constexpr size_t stride_3() const { return m_map.stride_3(); }
662  KOKKOS_INLINE_FUNCTION constexpr size_t stride_4() const { return m_map.stride_4(); }
663  KOKKOS_INLINE_FUNCTION constexpr size_t stride_5() const { return m_map.stride_5(); }
664  KOKKOS_INLINE_FUNCTION constexpr size_t stride_6() const { return m_map.stride_6(); }
665  KOKKOS_INLINE_FUNCTION constexpr size_t stride_7() const { return m_map.stride_7(); }
666 
667  template< typename iType >
668  KOKKOS_INLINE_FUNCTION constexpr
669  typename std::enable_if< std::is_integral<iType>::value , size_t >::type
670  stride(iType r) const {
671  return (r == 0 ? m_map.stride_0() :
672  (r == 1 ? m_map.stride_1() :
673  (r == 2 ? m_map.stride_2() :
674  (r == 3 ? m_map.stride_3() :
675  (r == 4 ? m_map.stride_4() :
676  (r == 5 ? m_map.stride_5() :
677  (r == 6 ? m_map.stride_6() :
678  m_map.stride_7())))))));
679  }
680 
681  template< typename iType >
682  KOKKOS_INLINE_FUNCTION void stride( iType * const s ) const { m_map.stride(s); }
683 
684  //----------------------------------------
685  // Range span is the span which contains all members.
686 
687  typedef typename map_type::reference_type reference_type ;
688  typedef typename map_type::pointer_type pointer_type ;
689 
690  enum { reference_type_is_lvalue_reference = std::is_lvalue_reference< reference_type >::value };
691 
692  KOKKOS_INLINE_FUNCTION constexpr size_t span() const { return m_map.span(); }
693 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE
694  // Deprecated, use 'span()' instead
695  KOKKOS_INLINE_FUNCTION constexpr size_t capacity() const { return m_map.span(); }
696 #endif
697  KOKKOS_INLINE_FUNCTION bool span_is_contiguous() const { return m_map.span_is_contiguous(); }
698  KOKKOS_INLINE_FUNCTION constexpr pointer_type data() const { return m_map.data(); }
699 
700 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE
701  // Deprecated, use 'span_is_contigous()' instead
702  KOKKOS_INLINE_FUNCTION constexpr bool is_contiguous() const { return m_map.span_is_contiguous(); }
703  // Deprecated, use 'data()' instead
704  KOKKOS_INLINE_FUNCTION constexpr pointer_type ptr_on_device() const { return m_map.data(); }
705 #endif
706 
707  //----------------------------------------
708  // Allow specializations to query their specialized map
709 
710  KOKKOS_INLINE_FUNCTION
711  const Kokkos::Impl::ViewMapping< traits , void > &
712  implementation_map() const { return m_map ; }
713 
714  //----------------------------------------
715 
716 private:
717 
718  enum {
719  is_layout_left = std::is_same< typename traits::array_layout
720  , Kokkos::LayoutLeft >::value ,
721 
722  is_layout_right = std::is_same< typename traits::array_layout
723  , Kokkos::LayoutRight >::value ,
724 
725  is_layout_stride = std::is_same< typename traits::array_layout
726  , Kokkos::LayoutStride >::value ,
727 
728  is_default_map =
729  std::is_same< typename traits::specialize , void >::value &&
730  ( is_layout_left || is_layout_right || is_layout_stride )
731  };
732 
733  template< class Space , bool = Kokkos::Impl::MemorySpaceAccess< Space , typename traits::memory_space >::accessible > struct verify_space
734  { KOKKOS_FORCEINLINE_FUNCTION static void check() {} };
735 
736  template< class Space > struct verify_space<Space,false>
737  { KOKKOS_FORCEINLINE_FUNCTION static void check()
738  { Kokkos::abort("Kokkos::View ERROR: attempt to access inaccessible memory space"); };
739  };
740 
741 #if defined( KOKKOS_ENABLE_DEBUG_BOUNDS_CHECK )
742 
743 #define KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( ARG ) \
744  View::template verify_space< Kokkos::Impl::ActiveExecutionMemorySpace >::check(); \
745  Kokkos::Impl::view_verify_operator_bounds< typename traits::memory_space > ARG ;
746 
747 #else
748 
749 #define KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( ARG ) \
750  View::template verify_space< Kokkos::Impl::ActiveExecutionMemorySpace >::check();
751 
752 #endif
753 
754 public:
755 
756 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE
757  template< class ... Args >
758  KOKKOS_FORCEINLINE_FUNCTION
759  typename std::enable_if<( Kokkos::Impl::are_integral<Args...>::value
760  && ( 0 == Rank )
761  ), reference_type >::type
762  operator()( Args ... args ) const
763  {
764  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,args...) )
765  return m_map.reference();
766  }
767 
768  template< typename I0
769  , class ... Args>
770  KOKKOS_FORCEINLINE_FUNCTION
771  typename std::enable_if<
772  ( Kokkos::Impl::are_integral<I0,Args...>::value
773  && ( 1 == Rank )
774  && ! is_default_map
775  ), reference_type >::type
776  operator()( const I0 & i0,
777  Args ... args) const
778  {
779  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,args...) )
780  return m_map.reference(i0);
781  }
782 
783  template< typename I0
784  , class ... Args >
785  KOKKOS_FORCEINLINE_FUNCTION
786  typename std::enable_if<
787  ( Kokkos::Impl::are_integral<I0,Args...>::value
788  && ( 1 == Rank )
789  && is_default_map
790  && ! is_layout_stride
791  ), reference_type >::type
792  operator()( const I0 & i0
793  , Args ... args ) const
794  {
795  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,args...) )
796  return m_map.m_handle[ i0 ];
797  }
798 
799  template< typename I0
800  , class ... Args >
801  KOKKOS_FORCEINLINE_FUNCTION
802  typename std::enable_if<
803  ( Kokkos::Impl::are_integral<I0,Args...>::value
804  && ( 1 == Rank )
805  && is_default_map
806  && is_layout_stride
807  ), reference_type >::type
808  operator()( const I0 & i0
809  , Args ... args ) const
810  {
811  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,args...) )
812  return m_map.m_handle[ m_map.m_offset.m_stride.S0 * i0 ];
813  }
814 
815  //------------------------------
816  // Rank 1 operator[]
817 
818  template< typename I0 >
819  KOKKOS_FORCEINLINE_FUNCTION
820  typename std::enable_if<
821  ( Kokkos::Impl::are_integral<I0>::value
822  && ( 1 == Rank )
823  && ! is_default_map
824  ), reference_type >::type
825  operator[]( const I0 & i0 ) const
826  {
827  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0) )
828  return m_map.reference(i0);
829  }
830 
831  template< typename I0 >
832  KOKKOS_FORCEINLINE_FUNCTION
833  typename std::enable_if<
834  ( Kokkos::Impl::are_integral<I0>::value
835  && ( 1 == Rank )
836  && is_default_map
837  && ! is_layout_stride
838  ), reference_type >::type
839  operator[]( const I0 & i0 ) const
840  {
841  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0) )
842  return m_map.m_handle[ i0 ];
843  }
844 
845  template< typename I0 >
846  KOKKOS_FORCEINLINE_FUNCTION
847  typename std::enable_if<
848  ( Kokkos::Impl::are_integral<I0>::value
849  && ( 1 == Rank )
850  && is_default_map
851  && is_layout_stride
852  ), reference_type >::type
853  operator[]( const I0 & i0 ) const
854  {
855  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0) )
856  return m_map.m_handle[ m_map.m_offset.m_stride.S0 * i0 ];
857  }
858 
859 
860  template< typename I0 , typename I1
861  , class ... Args >
862  KOKKOS_FORCEINLINE_FUNCTION
863  typename std::enable_if<
864  ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
865  && ( 2 == Rank )
866  && ! is_default_map
867  ), reference_type >::type
868  operator()( const I0 & i0 , const I1 & i1
869  , Args ... args ) const
870  {
871  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
872  return m_map.reference(i0,i1);
873  }
874 
875  template< typename I0 , typename I1
876  , class ... Args >
877  KOKKOS_FORCEINLINE_FUNCTION
878  typename std::enable_if<
879  ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
880  && ( 2 == Rank )
881  && is_default_map
882  && is_layout_left && ( traits::rank_dynamic == 0 )
883  ), reference_type >::type
884  operator()( const I0 & i0 , const I1 & i1
885  , Args ... args ) const
886  {
887  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
888  return m_map.m_handle[ i0 + m_map.m_offset.m_dim.N0 * i1 ];
889  }
890 
891  template< typename I0 , typename I1
892  , class ... Args >
893  KOKKOS_FORCEINLINE_FUNCTION
894  typename std::enable_if<
895  ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
896  && ( 2 == Rank )
897  && is_default_map
898  && is_layout_left && ( traits::rank_dynamic != 0 )
899  ), reference_type >::type
900  operator()( const I0 & i0 , const I1 & i1
901  , Args ... args ) const
902  {
903  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
904  return m_map.m_handle[ i0 + m_map.m_offset.m_stride * i1 ];
905  }
906 
907  template< typename I0 , typename I1
908  , class ... Args >
909  KOKKOS_FORCEINLINE_FUNCTION
910  typename std::enable_if<
911  ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
912  && ( 2 == Rank )
913  && is_default_map
914  && is_layout_right && ( traits::rank_dynamic == 0 )
915  ), reference_type >::type
916  operator()( const I0 & i0 , const I1 & i1
917  , Args ... args ) const
918  {
919  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
920  return m_map.m_handle[ i1 + m_map.m_offset.m_dim.N1 * i0 ];
921  }
922 
923  template< typename I0 , typename I1
924  , class ... Args >
925  KOKKOS_FORCEINLINE_FUNCTION
926  typename std::enable_if<
927  ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
928  && ( 2 == Rank )
929  && is_default_map
930  && is_layout_right && ( traits::rank_dynamic != 0 )
931  ), reference_type >::type
932  operator()( const I0 & i0 , const I1 & i1
933  , Args ... args ) const
934  {
935  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
936  return m_map.m_handle[ i1 + m_map.m_offset.m_stride * i0 ];
937  }
938 
939  template< typename I0 , typename I1
940  , class ... Args >
941  KOKKOS_FORCEINLINE_FUNCTION
942  typename std::enable_if<
943  ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
944  && ( 2 == Rank )
945  && is_default_map
946  && is_layout_stride
947  ), reference_type >::type
948  operator()( const I0 & i0 , const I1 & i1
949  , Args ... args ) const
950  {
951  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
952  return m_map.m_handle[ i0 * m_map.m_offset.m_stride.S0 +
953  i1 * m_map.m_offset.m_stride.S1 ];
954  }
955 
956  //------------------------------
957  // Rank 3
958 
959  template< typename I0 , typename I1 , typename I2
960  , class ... Args >
961  KOKKOS_FORCEINLINE_FUNCTION
962  typename std::enable_if<
963  ( Kokkos::Impl::are_integral<I0,I1,I2,Args...>::value
964  && ( 3 == Rank )
965  && is_default_map
966  ), reference_type >::type
967  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2
968  , Args ... args ) const
969  {
970  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,args...) )
971  return m_map.m_handle[ m_map.m_offset(i0,i1,i2) ];
972  }
973 
974  template< typename I0 , typename I1 , typename I2
975  , class ... Args >
976  KOKKOS_FORCEINLINE_FUNCTION
977  typename std::enable_if<
978  ( Kokkos::Impl::are_integral<I0,I1,I2,Args...>::value
979  && ( 3 == Rank )
980  && ! is_default_map
981  ), reference_type >::type
982  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2
983  , Args ... args ) const
984  {
985  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,args...) )
986  return m_map.reference(i0,i1,i2);
987  }
988 
989  //------------------------------
990  // Rank 4
991 
992  template< typename I0 , typename I1 , typename I2 , typename I3
993  , class ... Args >
994  KOKKOS_FORCEINLINE_FUNCTION
995  typename std::enable_if<
996  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,Args...>::value
997  && ( 4 == Rank )
998  && is_default_map
999  ), reference_type >::type
1000  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1001  , Args ... args ) const
1002  {
1003  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,args...) )
1004  return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3) ];
1005  }
1006 
1007  template< typename I0 , typename I1 , typename I2 , typename I3
1008  , class ... Args >
1009  KOKKOS_FORCEINLINE_FUNCTION
1010  typename std::enable_if<
1011  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,Args...>::value
1012  && ( 4 == Rank )
1013  && ! is_default_map
1014  ), reference_type >::type
1015  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1016  , Args ... args ) const
1017  {
1018  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,args...) )
1019  return m_map.reference(i0,i1,i2,i3);
1020  }
1021 
1022  //------------------------------
1023  // Rank 5
1024 
1025  template< typename I0 , typename I1 , typename I2 , typename I3
1026  , typename I4
1027  , class ... Args >
1028  KOKKOS_FORCEINLINE_FUNCTION
1029  typename std::enable_if<
1030  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,Args...>::value
1031  && ( 5 == Rank )
1032  && is_default_map
1033  ), reference_type >::type
1034  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1035  , const I4 & i4
1036  , Args ... args ) const
1037  {
1038  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,args...) )
1039  return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4) ];
1040  }
1041 
1042  template< typename I0 , typename I1 , typename I2 , typename I3
1043  , typename I4
1044  , class ... Args >
1045  KOKKOS_FORCEINLINE_FUNCTION
1046  typename std::enable_if<
1047  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,Args...>::value
1048  && ( 5 == Rank )
1049  && ! is_default_map
1050  ), reference_type >::type
1051  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1052  , const I4 & i4
1053  , Args ... args ) const
1054  {
1055  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,args...) )
1056  return m_map.reference(i0,i1,i2,i3,i4);
1057  }
1058 
1059  //------------------------------
1060  // Rank 6
1061 
1062  template< typename I0 , typename I1 , typename I2 , typename I3
1063  , typename I4 , typename I5
1064  , class ... Args >
1065  KOKKOS_FORCEINLINE_FUNCTION
1066  typename std::enable_if<
1067  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,Args...>::value
1068  && ( 6 == Rank )
1069  && is_default_map
1070  ), reference_type >::type
1071  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1072  , const I4 & i4 , const I5 & i5
1073  , Args ... args ) const
1074  {
1075  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,args...) )
1076  return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5) ];
1077  }
1078 
1079  template< typename I0 , typename I1 , typename I2 , typename I3
1080  , typename I4 , typename I5
1081  , class ... Args >
1082  KOKKOS_FORCEINLINE_FUNCTION
1083  typename std::enable_if<
1084  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,Args...>::value
1085  && ( 6 == Rank )
1086  && ! is_default_map
1087  ), reference_type >::type
1088  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1089  , const I4 & i4 , const I5 & i5
1090  , Args ... args ) const
1091  {
1092  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,args...) )
1093  return m_map.reference(i0,i1,i2,i3,i4,i5);
1094  }
1095 
1096  //------------------------------
1097  // Rank 7
1098 
1099  template< typename I0 , typename I1 , typename I2 , typename I3
1100  , typename I4 , typename I5 , typename I6
1101  , class ... Args >
1102  KOKKOS_FORCEINLINE_FUNCTION
1103  typename std::enable_if<
1104  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,Args...>::value
1105  && ( 7 == Rank )
1106  && is_default_map
1107  ), reference_type >::type
1108  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1109  , const I4 & i4 , const I5 & i5 , const I6 & i6
1110  , Args ... args ) const
1111  {
1112  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6,args...) )
1113  return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5,i6) ];
1114  }
1115 
1116  template< typename I0 , typename I1 , typename I2 , typename I3
1117  , typename I4 , typename I5 , typename I6
1118  , class ... Args >
1119  KOKKOS_FORCEINLINE_FUNCTION
1120  typename std::enable_if<
1121  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,Args...>::value
1122  && ( 7 == Rank )
1123  && ! is_default_map
1124  ), reference_type >::type
1125  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1126  , const I4 & i4 , const I5 & i5 , const I6 & i6
1127  , Args ... args ) const
1128  {
1129  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6,args...) )
1130  return m_map.reference(i0,i1,i2,i3,i4,i5,i6);
1131  }
1132 
1133  //------------------------------
1134  // Rank 8
1135 
1136  template< typename I0 , typename I1 , typename I2 , typename I3
1137  , typename I4 , typename I5 , typename I6 , typename I7
1138  , class ... Args >
1139  KOKKOS_FORCEINLINE_FUNCTION
1140  typename std::enable_if<
1141  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,I7,Args...>::value
1142  && ( 8 == Rank )
1143  && is_default_map
1144  ), reference_type >::type
1145  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1146  , const I4 & i4 , const I5 & i5 , const I6 & i6 , const I7 & i7
1147  , Args ... args ) const
1148  {
1149  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6,i7,args...) )
1150  return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5,i6,i7) ];
1151  }
1152 
1153  template< typename I0 , typename I1 , typename I2 , typename I3
1154  , typename I4 , typename I5 , typename I6 , typename I7
1155  , class ... Args >
1156  KOKKOS_FORCEINLINE_FUNCTION
1157  typename std::enable_if<
1158  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,I7,Args...>::value
1159  && ( 8 == Rank )
1160  && ! is_default_map
1161  ), reference_type >::type
1162  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1163  , const I4 & i4 , const I5 & i5 , const I6 & i6 , const I7 & i7
1164  , Args ... args ) const
1165  {
1166  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6,i7,args...) )
1167  return m_map.reference(i0,i1,i2,i3,i4,i5,i6,i7);
1168  }
1169 
1170 
1171  #else
1172  //------------------------------
1173  // Rank 0 operator()
1174 
1175  KOKKOS_FORCEINLINE_FUNCTION
1176  reference_type
1177  operator()() const
1178  {
1179  return m_map.reference();
1180  }
1181  //------------------------------
1182  // Rank 1 operator()
1183 
1184 
1185  template< typename I0>
1186  KOKKOS_FORCEINLINE_FUNCTION
1187  typename std::enable_if<
1188  ( Kokkos::Impl::are_integral<I0>::value
1189  && ( 1 == Rank )
1190  && ! is_default_map
1191  ), reference_type >::type
1192  operator()( const I0 & i0) const
1193  {
1194  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0) )
1195  return m_map.reference(i0);
1196  }
1197 
1198  template< typename I0>
1199  KOKKOS_FORCEINLINE_FUNCTION
1200  typename std::enable_if<
1201  ( Kokkos::Impl::are_integral<I0>::value
1202  && ( 1 == Rank )
1203  && is_default_map
1204  && ! is_layout_stride
1205  ), reference_type >::type
1206  operator()( const I0 & i0 ) const
1207  {
1208  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0) )
1209  return m_map.m_handle[ i0 ];
1210  }
1211 
1212  template< typename I0 >
1213  KOKKOS_FORCEINLINE_FUNCTION
1214  typename std::enable_if<
1215  ( Kokkos::Impl::are_integral<I0>::value
1216  && ( 1 == Rank )
1217  && is_default_map
1218  && is_layout_stride
1219  ), reference_type >::type
1220  operator()( const I0 & i0) const
1221  {
1222  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0) )
1223  return m_map.m_handle[ m_map.m_offset.m_stride.S0 * i0 ];
1224  }
1225  //------------------------------
1226  // Rank 1 operator[]
1227 
1228  template< typename I0 >
1229  KOKKOS_FORCEINLINE_FUNCTION
1230  typename std::enable_if<
1231  ( Kokkos::Impl::are_integral<I0>::value
1232  && ( 1 == Rank )
1233  && ! is_default_map
1234  ), reference_type >::type
1235  operator[]( const I0 & i0 ) const
1236  {
1237  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0) )
1238  return m_map.reference(i0);
1239  }
1240 
1241  template< typename I0 >
1242  KOKKOS_FORCEINLINE_FUNCTION
1243  typename std::enable_if<
1244  ( Kokkos::Impl::are_integral<I0>::value
1245  && ( 1 == Rank )
1246  && is_default_map
1247  && ! is_layout_stride
1248  ), reference_type >::type
1249  operator[]( const I0 & i0 ) const
1250  {
1251  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0) )
1252  return m_map.m_handle[ i0 ];
1253  }
1254 
1255  template< typename I0 >
1256  KOKKOS_FORCEINLINE_FUNCTION
1257  typename std::enable_if<
1258  ( Kokkos::Impl::are_integral<I0>::value
1259  && ( 1 == Rank )
1260  && is_default_map
1261  && is_layout_stride
1262  ), reference_type >::type
1263  operator[]( const I0 & i0 ) const
1264  {
1265  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0) )
1266  return m_map.m_handle[ m_map.m_offset.m_stride.S0 * i0 ];
1267  }
1268 
1269 
1270  //------------------------------
1271  // Rank 2
1272 
1273  template< typename I0 , typename I1 >
1274  KOKKOS_FORCEINLINE_FUNCTION
1275  typename std::enable_if<
1276  ( Kokkos::Impl::are_integral<I0,I1>::value
1277  && ( 2 == Rank )
1278  && ! is_default_map
1279  ), reference_type >::type
1280  operator()( const I0 & i0 , const I1 & i1) const
1281  {
1282  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1) )
1283  return m_map.reference(i0,i1);
1284  }
1285 
1286  template< typename I0 , typename I1 >
1287  KOKKOS_FORCEINLINE_FUNCTION
1288  typename std::enable_if<
1289  ( Kokkos::Impl::are_integral<I0,I1>::value
1290  && ( 2 == Rank )
1291  && is_default_map
1292  && is_layout_left && ( traits::rank_dynamic == 0 )
1293  ), reference_type >::type
1294  operator()( const I0 & i0 , const I1 & i1) const
1295  {
1296  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1) )
1297  return m_map.m_handle[ i0 + m_map.m_offset.m_dim.N0 * i1 ];
1298  }
1299 
1300  template< typename I0 , typename I1>
1301  KOKKOS_FORCEINLINE_FUNCTION
1302  typename std::enable_if<
1303  ( Kokkos::Impl::are_integral<I0,I1>::value
1304  && ( 2 == Rank )
1305  && is_default_map
1306  && is_layout_left && ( traits::rank_dynamic != 0 )
1307  ), reference_type >::type
1308  operator()( const I0 & i0 , const I1 & i1) const
1309  {
1310  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1) )
1311  return m_map.m_handle[ i0 + m_map.m_offset.m_stride * i1 ];
1312  }
1313 
1314  template< typename I0 , typename I1 >
1315  KOKKOS_FORCEINLINE_FUNCTION
1316  typename std::enable_if<
1317  ( Kokkos::Impl::are_integral<I0,I1>::value
1318  && ( 2 == Rank )
1319  && is_default_map
1320  && is_layout_right && ( traits::rank_dynamic == 0 )
1321  ), reference_type >::type
1322  operator()( const I0 & i0 , const I1 & i1 ) const
1323  {
1324  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1) )
1325  return m_map.m_handle[ i1 + m_map.m_offset.m_dim.N1 * i0 ];
1326  }
1327 
1328  template< typename I0 , typename I1 >
1329  KOKKOS_FORCEINLINE_FUNCTION
1330  typename std::enable_if<
1331  ( Kokkos::Impl::are_integral<I0,I1>::value
1332  && ( 2 == Rank )
1333  && is_default_map
1334  && is_layout_right && ( traits::rank_dynamic != 0 )
1335  ), reference_type >::type
1336  operator()( const I0 & i0 , const I1 & i1 ) const
1337  {
1338  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1) )
1339  return m_map.m_handle[ i1 + m_map.m_offset.m_stride * i0 ];
1340  }
1341 
1342  template< typename I0 , typename I1>
1343  KOKKOS_FORCEINLINE_FUNCTION
1344  typename std::enable_if<
1345  ( Kokkos::Impl::are_integral<I0,I1>::value
1346  && ( 2 == Rank )
1347  && is_default_map
1348  && is_layout_stride
1349  ), reference_type >::type
1350  operator()( const I0 & i0 , const I1 & i1 ) const
1351  {
1352  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1) )
1353  return m_map.m_handle[ i0 * m_map.m_offset.m_stride.S0 +
1354  i1 * m_map.m_offset.m_stride.S1 ];
1355  }
1356 
1357  //------------------------------
1358  // Rank 3
1359 
1360  template< typename I0 , typename I1 , typename I2 >
1361  KOKKOS_FORCEINLINE_FUNCTION
1362  typename std::enable_if<
1363  ( Kokkos::Impl::are_integral<I0,I1,I2>::value
1364  && ( 3 == Rank )
1365  && is_default_map
1366  ), reference_type >::type
1367  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2) const
1368  {
1369  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2) )
1370  return m_map.m_handle[ m_map.m_offset(i0,i1,i2) ];
1371  }
1372 
1373  template< typename I0 , typename I1 , typename I2>
1374  KOKKOS_FORCEINLINE_FUNCTION
1375  typename std::enable_if<
1376  ( Kokkos::Impl::are_integral<I0,I1,I2>::value
1377  && ( 3 == Rank )
1378  && ! is_default_map
1379  ), reference_type >::type
1380  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2) const
1381  {
1382  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2) )
1383  return m_map.reference(i0,i1,i2);
1384  }
1385 
1386  //------------------------------
1387  // Rank 4
1388 
1389  template< typename I0 , typename I1 , typename I2 , typename I3>
1390  KOKKOS_FORCEINLINE_FUNCTION
1391  typename std::enable_if<
1392  ( Kokkos::Impl::are_integral<I0,I1,I2,I3>::value
1393  && ( 4 == Rank )
1394  && is_default_map
1395  ), reference_type >::type
1396  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3) const
1397  {
1398  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3) )
1399  return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3) ];
1400  }
1401 
1402  template< typename I0 , typename I1 , typename I2 , typename I3 >
1403  KOKKOS_FORCEINLINE_FUNCTION
1404  typename std::enable_if<
1405  ( Kokkos::Impl::are_integral<I0,I1,I2,I3>::value
1406  && ( 4 == Rank )
1407  && ! is_default_map
1408  ), reference_type >::type
1409  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3) const
1410  {
1411  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3) )
1412  return m_map.reference(i0,i1,i2,i3);
1413  }
1414 
1415  //------------------------------
1416  // Rank 5
1417 
1418  template< typename I0 , typename I1 , typename I2 , typename I3
1419  , typename I4>
1420  KOKKOS_FORCEINLINE_FUNCTION
1421  typename std::enable_if<
1422  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4>::value
1423  && ( 5 == Rank )
1424  && is_default_map
1425  ), reference_type >::type
1426  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1427  , const I4 & i4 ) const
1428  {
1429  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4) )
1430  return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4) ];
1431  }
1432 
1433  template< typename I0 , typename I1 , typename I2 , typename I3
1434  , typename I4>
1435  KOKKOS_FORCEINLINE_FUNCTION
1436  typename std::enable_if<
1437  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4>::value
1438  && ( 5 == Rank )
1439  && ! is_default_map
1440  ), reference_type >::type
1441  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1442  , const I4 & i4) const
1443  {
1444  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4) )
1445  return m_map.reference(i0,i1,i2,i3,i4);
1446  }
1447 
1448  //------------------------------
1449  // Rank 6
1450 
1451  template< typename I0 , typename I1 , typename I2 , typename I3
1452  , typename I4 , typename I5 >
1453  KOKKOS_FORCEINLINE_FUNCTION
1454  typename std::enable_if<
1455  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5>::value
1456  && ( 6 == Rank )
1457  && is_default_map
1458  ), reference_type >::type
1459  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1460  , const I4 & i4 , const I5 & i5 ) const
1461  {
1462  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5) )
1463  return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5) ];
1464  }
1465 
1466  template< typename I0 , typename I1 , typename I2 , typename I3
1467  , typename I4 , typename I5>
1468  KOKKOS_FORCEINLINE_FUNCTION
1469  typename std::enable_if<
1470  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5>::value
1471  && ( 6 == Rank )
1472  && ! is_default_map
1473  ), reference_type >::type
1474  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1475  , const I4 & i4 , const I5 & i5) const
1476  {
1477  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5) )
1478  return m_map.reference(i0,i1,i2,i3,i4,i5);
1479  }
1480 
1481  //------------------------------
1482  // Rank 7
1483 
1484  template< typename I0 , typename I1 , typename I2 , typename I3
1485  , typename I4 , typename I5 , typename I6>
1486  KOKKOS_FORCEINLINE_FUNCTION
1487  typename std::enable_if<
1488  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6>::value
1489  && ( 7 == Rank )
1490  && is_default_map
1491  ), reference_type >::type
1492  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1493  , const I4 & i4 , const I5 & i5 , const I6 & i6) const
1494  {
1495  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6) )
1496  return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5,i6) ];
1497  }
1498 
1499  template< typename I0 , typename I1 , typename I2 , typename I3
1500  , typename I4 , typename I5 , typename I6 >
1501  KOKKOS_FORCEINLINE_FUNCTION
1502  typename std::enable_if<
1503  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6>::value
1504  && ( 7 == Rank )
1505  && ! is_default_map
1506  ), reference_type >::type
1507  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1508  , const I4 & i4 , const I5 & i5 , const I6 & i6) const
1509  {
1510  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6) )
1511  return m_map.reference(i0,i1,i2,i3,i4,i5,i6);
1512  }
1513 
1514  //------------------------------
1515  // Rank 8
1516 
1517  template< typename I0 , typename I1 , typename I2 , typename I3
1518  , typename I4 , typename I5 , typename I6 , typename I7 >
1519  KOKKOS_FORCEINLINE_FUNCTION
1520  typename std::enable_if<
1521  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,I7>::value
1522  && ( 8 == Rank )
1523  && is_default_map
1524  ), reference_type >::type
1525  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1526  , const I4 & i4 , const I5 & i5 , const I6 & i6 , const I7 & i7) const
1527  {
1528  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6,i7) )
1529  return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5,i6,i7) ];
1530  }
1531 
1532  template< typename I0 , typename I1 , typename I2 , typename I3
1533  , typename I4 , typename I5 , typename I6 , typename I7>
1534  KOKKOS_FORCEINLINE_FUNCTION
1535  typename std::enable_if<
1536  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,I7>::value
1537  && ( 8 == Rank )
1538  && ! is_default_map
1539  ), reference_type >::type
1540  operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1541  , const I4 & i4 , const I5 & i5 , const I6 & i6 , const I7 & i7 ) const
1542  {
1543  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6,i7) )
1544  return m_map.reference(i0,i1,i2,i3,i4,i5,i6,i7);
1545  }
1546 
1547 #endif
1548 
1549  template< class ... Args >
1550  KOKKOS_FORCEINLINE_FUNCTION
1551  typename std::enable_if<( Kokkos::Impl::are_integral<Args...>::value
1552  && ( 0 == Rank )
1553  ), reference_type >::type
1554  access( Args ... args ) const
1555  {
1556  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,args...) )
1557  return m_map.reference();
1558  }
1559 
1560  template< typename I0
1561  , class ... Args>
1562  KOKKOS_FORCEINLINE_FUNCTION
1563  typename std::enable_if<
1564  ( Kokkos::Impl::are_integral<I0,Args...>::value
1565  && ( 1 == Rank )
1566  && ! is_default_map
1567  ), reference_type >::type
1568  access( const I0 & i0,
1569  Args ... args) const
1570  {
1571  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,args...) )
1572  return m_map.reference(i0);
1573  }
1574 
1575  template< typename I0
1576  , class ... Args >
1577  KOKKOS_FORCEINLINE_FUNCTION
1578  typename std::enable_if<
1579  ( Kokkos::Impl::are_integral<I0,Args...>::value
1580  && ( 1 == Rank )
1581  && is_default_map
1582  && ! is_layout_stride
1583  ), reference_type >::type
1584  access( const I0 & i0
1585  , Args ... args ) const
1586  {
1587  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,args...) )
1588  return m_map.m_handle[ i0 ];
1589  }
1590 
1591  template< typename I0
1592  , class ... Args >
1593  KOKKOS_FORCEINLINE_FUNCTION
1594  typename std::enable_if<
1595  ( Kokkos::Impl::are_integral<I0,Args...>::value
1596  && ( 1 == Rank )
1597  && is_default_map
1598  && is_layout_stride
1599  ), reference_type >::type
1600  access( const I0 & i0
1601  , Args ... args ) const
1602  {
1603  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,args...) )
1604  return m_map.m_handle[ m_map.m_offset.m_stride.S0 * i0 ];
1605  }
1606 
1607  template< typename I0 , typename I1
1608  , class ... Args >
1609  KOKKOS_FORCEINLINE_FUNCTION
1610  typename std::enable_if<
1611  ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
1612  && ( 2 == Rank )
1613  && ! is_default_map
1614  ), reference_type >::type
1615  access( const I0 & i0 , const I1 & i1
1616  , Args ... args ) const
1617  {
1618  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
1619  return m_map.reference(i0,i1);
1620  }
1621 
1622  template< typename I0 , typename I1
1623  , class ... Args >
1624  KOKKOS_FORCEINLINE_FUNCTION
1625  typename std::enable_if<
1626  ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
1627  && ( 2 == Rank )
1628  && is_default_map
1629  && is_layout_left && ( traits::rank_dynamic == 0 )
1630  ), reference_type >::type
1631  access( const I0 & i0 , const I1 & i1
1632  , Args ... args ) const
1633  {
1634  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
1635  return m_map.m_handle[ i0 + m_map.m_offset.m_dim.N0 * i1 ];
1636  }
1637 
1638  template< typename I0 , typename I1
1639  , class ... Args >
1640  KOKKOS_FORCEINLINE_FUNCTION
1641  typename std::enable_if<
1642  ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
1643  && ( 2 == Rank )
1644  && is_default_map
1645  && is_layout_left && ( traits::rank_dynamic != 0 )
1646  ), reference_type >::type
1647  access( const I0 & i0 , const I1 & i1
1648  , Args ... args ) const
1649  {
1650  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
1651  return m_map.m_handle[ i0 + m_map.m_offset.m_stride * i1 ];
1652  }
1653 
1654  template< typename I0 , typename I1
1655  , class ... Args >
1656  KOKKOS_FORCEINLINE_FUNCTION
1657  typename std::enable_if<
1658  ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
1659  && ( 2 == Rank )
1660  && is_default_map
1661  && is_layout_right && ( traits::rank_dynamic == 0 )
1662  ), reference_type >::type
1663  access( const I0 & i0 , const I1 & i1
1664  , Args ... args ) const
1665  {
1666  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
1667  return m_map.m_handle[ i1 + m_map.m_offset.m_dim.N1 * i0 ];
1668  }
1669 
1670  template< typename I0 , typename I1
1671  , class ... Args >
1672  KOKKOS_FORCEINLINE_FUNCTION
1673  typename std::enable_if<
1674  ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
1675  && ( 2 == Rank )
1676  && is_default_map
1677  && is_layout_right && ( traits::rank_dynamic != 0 )
1678  ), reference_type >::type
1679  access( const I0 & i0 , const I1 & i1
1680  , Args ... args ) const
1681  {
1682  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
1683  return m_map.m_handle[ i1 + m_map.m_offset.m_stride * i0 ];
1684  }
1685 
1686  template< typename I0 , typename I1
1687  , class ... Args >
1688  KOKKOS_FORCEINLINE_FUNCTION
1689  typename std::enable_if<
1690  ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
1691  && ( 2 == Rank )
1692  && is_default_map
1693  && is_layout_stride
1694  ), reference_type >::type
1695  access( const I0 & i0 , const I1 & i1
1696  , Args ... args ) const
1697  {
1698  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
1699  return m_map.m_handle[ i0 * m_map.m_offset.m_stride.S0 +
1700  i1 * m_map.m_offset.m_stride.S1 ];
1701  }
1702 
1703  //------------------------------
1704  // Rank 3
1705 
1706  template< typename I0 , typename I1 , typename I2
1707  , class ... Args >
1708  KOKKOS_FORCEINLINE_FUNCTION
1709  typename std::enable_if<
1710  ( Kokkos::Impl::are_integral<I0,I1,I2,Args...>::value
1711  && ( 3 == Rank )
1712  && is_default_map
1713  ), reference_type >::type
1714  access( const I0 & i0 , const I1 & i1 , const I2 & i2
1715  , Args ... args ) const
1716  {
1717  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,args...) )
1718  return m_map.m_handle[ m_map.m_offset(i0,i1,i2) ];
1719  }
1720 
1721  template< typename I0 , typename I1 , typename I2
1722  , class ... Args >
1723  KOKKOS_FORCEINLINE_FUNCTION
1724  typename std::enable_if<
1725  ( Kokkos::Impl::are_integral<I0,I1,I2,Args...>::value
1726  && ( 3 == Rank )
1727  && ! is_default_map
1728  ), reference_type >::type
1729  access( const I0 & i0 , const I1 & i1 , const I2 & i2
1730  , Args ... args ) const
1731  {
1732  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,args...) )
1733  return m_map.reference(i0,i1,i2);
1734  }
1735 
1736  //------------------------------
1737  // Rank 4
1738 
1739  template< typename I0 , typename I1 , typename I2 , typename I3
1740  , class ... Args >
1741  KOKKOS_FORCEINLINE_FUNCTION
1742  typename std::enable_if<
1743  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,Args...>::value
1744  && ( 4 == Rank )
1745  && is_default_map
1746  ), reference_type >::type
1747  access( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1748  , Args ... args ) const
1749  {
1750  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,args...) )
1751  return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3) ];
1752  }
1753 
1754  template< typename I0 , typename I1 , typename I2 , typename I3
1755  , class ... Args >
1756  KOKKOS_FORCEINLINE_FUNCTION
1757  typename std::enable_if<
1758  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,Args...>::value
1759  && ( 4 == Rank )
1760  && ! is_default_map
1761  ), reference_type >::type
1762  access( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1763  , Args ... args ) const
1764  {
1765  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,args...) )
1766  return m_map.reference(i0,i1,i2,i3);
1767  }
1768 
1769  //------------------------------
1770  // Rank 5
1771 
1772  template< typename I0 , typename I1 , typename I2 , typename I3
1773  , typename I4
1774  , class ... Args >
1775  KOKKOS_FORCEINLINE_FUNCTION
1776  typename std::enable_if<
1777  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,Args...>::value
1778  && ( 5 == Rank )
1779  && is_default_map
1780  ), reference_type >::type
1781  access( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1782  , const I4 & i4
1783  , Args ... args ) const
1784  {
1785  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,args...) )
1786  return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4) ];
1787  }
1788 
1789  template< typename I0 , typename I1 , typename I2 , typename I3
1790  , typename I4
1791  , class ... Args >
1792  KOKKOS_FORCEINLINE_FUNCTION
1793  typename std::enable_if<
1794  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,Args...>::value
1795  && ( 5 == Rank )
1796  && ! is_default_map
1797  ), reference_type >::type
1798  access( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1799  , const I4 & i4
1800  , Args ... args ) const
1801  {
1802  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,args...) )
1803  return m_map.reference(i0,i1,i2,i3,i4);
1804  }
1805 
1806  //------------------------------
1807  // Rank 6
1808 
1809  template< typename I0 , typename I1 , typename I2 , typename I3
1810  , typename I4 , typename I5
1811  , class ... Args >
1812  KOKKOS_FORCEINLINE_FUNCTION
1813  typename std::enable_if<
1814  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,Args...>::value
1815  && ( 6 == Rank )
1816  && is_default_map
1817  ), reference_type >::type
1818  access( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1819  , const I4 & i4 , const I5 & i5
1820  , Args ... args ) const
1821  {
1822  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,args...) )
1823  return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5) ];
1824  }
1825 
1826  template< typename I0 , typename I1 , typename I2 , typename I3
1827  , typename I4 , typename I5
1828  , class ... Args >
1829  KOKKOS_FORCEINLINE_FUNCTION
1830  typename std::enable_if<
1831  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,Args...>::value
1832  && ( 6 == Rank )
1833  && ! is_default_map
1834  ), reference_type >::type
1835  access( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1836  , const I4 & i4 , const I5 & i5
1837  , Args ... args ) const
1838  {
1839  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,args...) )
1840  return m_map.reference(i0,i1,i2,i3,i4,i5);
1841  }
1842 
1843  //------------------------------
1844  // Rank 7
1845 
1846  template< typename I0 , typename I1 , typename I2 , typename I3
1847  , typename I4 , typename I5 , typename I6
1848  , class ... Args >
1849  KOKKOS_FORCEINLINE_FUNCTION
1850  typename std::enable_if<
1851  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,Args...>::value
1852  && ( 7 == Rank )
1853  && is_default_map
1854  ), reference_type >::type
1855  access( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1856  , const I4 & i4 , const I5 & i5 , const I6 & i6
1857  , Args ... args ) const
1858  {
1859  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6,args...) )
1860  return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5,i6) ];
1861  }
1862 
1863  template< typename I0 , typename I1 , typename I2 , typename I3
1864  , typename I4 , typename I5 , typename I6
1865  , class ... Args >
1866  KOKKOS_FORCEINLINE_FUNCTION
1867  typename std::enable_if<
1868  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,Args...>::value
1869  && ( 7 == Rank )
1870  && ! is_default_map
1871  ), reference_type >::type
1872  access( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1873  , const I4 & i4 , const I5 & i5 , const I6 & i6
1874  , Args ... args ) const
1875  {
1876  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6,args...) )
1877  return m_map.reference(i0,i1,i2,i3,i4,i5,i6);
1878  }
1879 
1880  //------------------------------
1881  // Rank 8
1882 
1883  template< typename I0 , typename I1 , typename I2 , typename I3
1884  , typename I4 , typename I5 , typename I6 , typename I7
1885  , class ... Args >
1886  KOKKOS_FORCEINLINE_FUNCTION
1887  typename std::enable_if<
1888  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,I7,Args...>::value
1889  && ( 8 == Rank )
1890  && is_default_map
1891  ), reference_type >::type
1892  access( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1893  , const I4 & i4 , const I5 & i5 , const I6 & i6 , const I7 & i7
1894  , Args ... args ) const
1895  {
1896  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6,i7,args...) )
1897  return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5,i6,i7) ];
1898  }
1899 
1900  template< typename I0 , typename I1 , typename I2 , typename I3
1901  , typename I4 , typename I5 , typename I6 , typename I7
1902  , class ... Args >
1903  KOKKOS_FORCEINLINE_FUNCTION
1904  typename std::enable_if<
1905  ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,I7,Args...>::value
1906  && ( 8 == Rank )
1907  && ! is_default_map
1908  ), reference_type >::type
1909  access( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1910  , const I4 & i4 , const I5 & i5 , const I6 & i6 , const I7 & i7
1911  , Args ... args ) const
1912  {
1913  KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6,i7,args...) )
1914  return m_map.reference(i0,i1,i2,i3,i4,i5,i6,i7);
1915  }
1916 
1917 
1918 #undef KOKKOS_IMPL_VIEW_OPERATOR_VERIFY
1919 
1920  //----------------------------------------
1921  // Standard destructor, constructors, and assignment operators
1922 
1923  KOKKOS_INLINE_FUNCTION
1924  ~View() {}
1925 
1926  KOKKOS_INLINE_FUNCTION
1927  View() : m_track(), m_map() {}
1928 
1929  KOKKOS_INLINE_FUNCTION
1930  View( const View & rhs ) : m_track( rhs.m_track, traits::is_managed ), m_map( rhs.m_map ) {}
1931 
1932  KOKKOS_INLINE_FUNCTION
1933  View( View && rhs ) : m_track( std::move(rhs.m_track) ), m_map( std::move(rhs.m_map) ) {}
1934 
1935  KOKKOS_INLINE_FUNCTION
1936  View & operator = ( const View & rhs ) { m_track = rhs.m_track ; m_map = rhs.m_map ; return *this ; }
1937 
1938  KOKKOS_INLINE_FUNCTION
1939  View & operator = ( View && rhs ) { m_track = std::move(rhs.m_track) ; m_map = std::move(rhs.m_map) ; return *this ; }
1940 
1941  //----------------------------------------
1942  // Compatible view copy constructor and assignment
1943  // may assign unmanaged from managed.
1944 
1945  template< class RT , class ... RP >
1946  KOKKOS_INLINE_FUNCTION
1947  View( const View<RT,RP...> & rhs )
1948  : m_track( rhs.m_track , traits::is_managed )
1949  , m_map()
1950  {
1951  typedef typename View<RT,RP...>::traits SrcTraits ;
1952  typedef Kokkos::Impl::ViewMapping< traits , SrcTraits , void > Mapping ;
1953  static_assert( Mapping::is_assignable , "Incompatible View copy construction" );
1954  Mapping::assign( m_map , rhs.m_map , rhs.m_track );
1955  }
1956 
1957  template< class RT , class ... RP >
1958  KOKKOS_INLINE_FUNCTION
1959  View & operator = ( const View<RT,RP...> & rhs )
1960  {
1961  typedef typename View<RT,RP...>::traits SrcTraits ;
1962  typedef Kokkos::Impl::ViewMapping< traits , SrcTraits , void > Mapping ;
1963  static_assert( Mapping::is_assignable , "Incompatible View copy assignment" );
1964  Mapping::assign( m_map , rhs.m_map , rhs.m_track );
1965  m_track.assign( rhs.m_track , traits::is_managed );
1966  return *this ;
1967  }
1968 
1969  //----------------------------------------
1970  // Compatible subview constructor
1971  // may assign unmanaged from managed.
1972 
1973  template< class RT , class ... RP , class Arg0 , class ... Args >
1974  KOKKOS_INLINE_FUNCTION
1975  View( const View< RT , RP... > & src_view
1976  , const Arg0 & arg0 , Args ... args )
1977  : m_track( src_view.m_track , traits::is_managed )
1978  , m_map()
1979  {
1980  typedef View< RT , RP... > SrcType ;
1981 
1982  typedef Kokkos::Impl::ViewMapping
1983  < void /* deduce destination view type from source view traits */
1984  , typename SrcType::traits
1985  , Arg0 , Args... > Mapping ;
1986 
1987  typedef typename Mapping::type DstType ;
1988 
1989  static_assert( Kokkos::Impl::ViewMapping< traits , typename DstType::traits , void >::is_assignable
1990  , "Subview construction requires compatible view and subview arguments" );
1991 
1992  Mapping::assign( m_map, src_view.m_map, arg0 , args... );
1993  }
1994 
1995  //----------------------------------------
1996  // Allocation tracking properties
1997 
1998  KOKKOS_INLINE_FUNCTION
1999  int use_count() const
2000  { return m_track.use_count(); }
2001 
2002  inline
2003  const std::string label() const
2004  { return m_track.template get_label< typename traits::memory_space >(); }
2005 
2006  //----------------------------------------
2007  // Allocation according to allocation properties and array layout
2008 
2009  template< class ... P >
2010  explicit inline
2011  View( const Impl::ViewCtorProp< P ... > & arg_prop
2012  , typename std::enable_if< ! Impl::ViewCtorProp< P... >::has_pointer
2013  , typename traits::array_layout
2014  >::type const & arg_layout
2015  )
2016  : m_track()
2017  , m_map()
2018  {
2019  // Append layout and spaces if not input
2020  typedef Impl::ViewCtorProp< P ... > alloc_prop_input ;
2021 
2022  // use 'std::integral_constant<unsigned,I>' for non-types
2023  // to avoid duplicate class error.
2024  typedef Impl::ViewCtorProp
2025  < P ...
2026  , typename std::conditional
2027  < alloc_prop_input::has_label
2028  , std::integral_constant<unsigned,0>
2029  , typename std::string
2030  >::type
2031  , typename std::conditional
2032  < alloc_prop_input::has_memory_space
2033  , std::integral_constant<unsigned,1>
2034  , typename traits::device_type::memory_space
2035  >::type
2036  , typename std::conditional
2037  < alloc_prop_input::has_execution_space
2038  , std::integral_constant<unsigned,2>
2039  , typename traits::device_type::execution_space
2040  >::type
2041  > alloc_prop ;
2042 
2043  static_assert( traits::is_managed
2044  , "View allocation constructor requires managed memory" );
2045 
2046  if ( alloc_prop::initialize &&
2047 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE
2048  ! alloc_prop::execution_space::is_initialized()
2049 #else
2050  ! alloc_prop::execution_space::impl_is_initialized()
2051 #endif
2052  ) {
2053  // If initializing view data then
2054  // the execution space must be initialized.
2055  Kokkos::Impl::throw_runtime_exception("Constructing View and initializing data with uninitialized execution space");
2056  }
2057 
2058  // Copy the input allocation properties with possibly defaulted properties
2059  alloc_prop prop( arg_prop );
2060 
2061 //------------------------------------------------------------
2062 #if defined( KOKKOS_ENABLE_CUDA )
2063  // If allocating in CudaUVMSpace must fence before and after
2064  // the allocation to protect against possible concurrent access
2065  // on the CPU and the GPU.
2066  // Fence using the trait's executon space (which will be Kokkos::Cuda)
2067  // to avoid incomplete type errors from usng Kokkos::Cuda directly.
2068  if ( std::is_same< Kokkos::CudaUVMSpace , typename traits::device_type::memory_space >::value ) {
2069  traits::device_type::memory_space::execution_space::fence();
2070  }
2071 #endif
2072 //------------------------------------------------------------
2073 
2074  Kokkos::Impl::SharedAllocationRecord<> *
2075  record = m_map.allocate_shared( prop , arg_layout );
2076 
2077 //------------------------------------------------------------
2078 #if defined( KOKKOS_ENABLE_CUDA )
2079  if ( std::is_same< Kokkos::CudaUVMSpace , typename traits::device_type::memory_space >::value ) {
2080  traits::device_type::memory_space::execution_space::fence();
2081  }
2082 #endif
2083 //------------------------------------------------------------
2084 
2085  // Setup and initialization complete, start tracking
2086  m_track.assign_allocated_record_to_uninitialized( record );
2087  }
2088 
2089  KOKKOS_INLINE_FUNCTION
2090  void assign_data( pointer_type arg_data )
2091  {
2092  m_track.clear();
2093  m_map.assign_data( arg_data );
2094  }
2095 
2096  // Wrap memory according to properties and array layout
2097  template< class ... P >
2098  explicit KOKKOS_INLINE_FUNCTION
2099  View( const Impl::ViewCtorProp< P ... > & arg_prop
2100  , typename std::enable_if< Impl::ViewCtorProp< P... >::has_pointer
2101  , typename traits::array_layout
2102  >::type const & arg_layout
2103  )
2104  : m_track() // No memory tracking
2105  , m_map( arg_prop , arg_layout )
2106  {
2107  static_assert(
2108  std::is_same< pointer_type
2109  , typename Impl::ViewCtorProp< P... >::pointer_type
2110  >::value ,
2111  "Constructing View to wrap user memory must supply matching pointer type" );
2112  }
2113 
2114  // Simple dimension-only layout
2115  template< class ... P >
2116  explicit inline
2117  View( const Impl::ViewCtorProp< P ... > & arg_prop
2118  , typename std::enable_if< ! Impl::ViewCtorProp< P... >::has_pointer
2119  , size_t
2120  >::type const arg_N0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2121  , const size_t arg_N1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2122  , const size_t arg_N2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2123  , const size_t arg_N3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2124  , const size_t arg_N4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2125  , const size_t arg_N5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2126  , const size_t arg_N6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2127  , const size_t arg_N7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2128  )
2129  : View( arg_prop
2130  , typename traits::array_layout
2131  ( arg_N0 , arg_N1 , arg_N2 , arg_N3
2132  , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
2133  )
2134  {
2135 #ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST
2136  Impl::runtime_check_rank_host(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2137  arg_N4, arg_N5, arg_N6, arg_N7, label());
2138 #else
2139  Impl::runtime_check_rank_device(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2140  arg_N4, arg_N5, arg_N6, arg_N7);
2141 
2142 #endif
2143 
2144  }
2145 
2146  template< class ... P >
2147  explicit KOKKOS_INLINE_FUNCTION
2148  View( const Impl::ViewCtorProp< P ... > & arg_prop
2149  , typename std::enable_if< Impl::ViewCtorProp< P... >::has_pointer
2150  , size_t
2151  >::type const arg_N0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2152  , const size_t arg_N1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2153  , const size_t arg_N2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2154  , const size_t arg_N3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2155  , const size_t arg_N4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2156  , const size_t arg_N5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2157  , const size_t arg_N6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2158  , const size_t arg_N7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2159  )
2160  : View( arg_prop
2161  , typename traits::array_layout
2162  ( arg_N0 , arg_N1 , arg_N2 , arg_N3
2163  , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
2164  )
2165  {
2166 #ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST
2167  Impl::runtime_check_rank_host(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2168  arg_N4, arg_N5, arg_N6, arg_N7, label());
2169 #else
2170  Impl::runtime_check_rank_device(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2171  arg_N4, arg_N5, arg_N6, arg_N7);
2172 
2173 #endif
2174 
2175  }
2176 
2177  // Allocate with label and layout
2178  template< typename Label >
2179  explicit inline
2180  View( const Label & arg_label
2181  , typename std::enable_if<
2182  Kokkos::Impl::is_view_label<Label>::value ,
2183  typename traits::array_layout >::type const & arg_layout
2184  )
2185  : View( Impl::ViewCtorProp< std::string >( arg_label ) , arg_layout )
2186  {}
2187 
2188  // Allocate label and layout, must disambiguate from subview constructor.
2189  template< typename Label >
2190  explicit inline
2191  View( const Label & arg_label
2192  , typename std::enable_if<
2193  Kokkos::Impl::is_view_label<Label>::value ,
2194  const size_t >::type arg_N0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2195  , const size_t arg_N1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2196  , const size_t arg_N2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2197  , const size_t arg_N3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2198  , const size_t arg_N4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2199  , const size_t arg_N5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2200  , const size_t arg_N6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2201  , const size_t arg_N7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2202  )
2203  : View( Impl::ViewCtorProp< std::string >( arg_label )
2204  , typename traits::array_layout
2205  ( arg_N0 , arg_N1 , arg_N2 , arg_N3
2206  , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
2207  )
2208  {
2209 
2210 #ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST
2211  Impl::runtime_check_rank_host(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2212  arg_N4, arg_N5, arg_N6, arg_N7, label());
2213 #else
2214  Impl::runtime_check_rank_device(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2215  arg_N4, arg_N5, arg_N6, arg_N7);
2216 
2217 #endif
2218 
2219 
2220 
2221  }
2222 
2223  // For backward compatibility
2224  explicit inline
2225  View( const ViewAllocateWithoutInitializing & arg_prop
2226  , const typename traits::array_layout & arg_layout
2227  )
2228  : View( Impl::ViewCtorProp< std::string , Kokkos::Impl::WithoutInitializing_t >( arg_prop.label , Kokkos::WithoutInitializing )
2229  , arg_layout
2230  )
2231  {}
2232 
2233  explicit inline
2234  View( const ViewAllocateWithoutInitializing & arg_prop
2235  , const size_t arg_N0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2236  , const size_t arg_N1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2237  , const size_t arg_N2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2238  , const size_t arg_N3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2239  , const size_t arg_N4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2240  , const size_t arg_N5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2241  , const size_t arg_N6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2242  , const size_t arg_N7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2243  )
2244  : View( Impl::ViewCtorProp< std::string , Kokkos::Impl::WithoutInitializing_t >( arg_prop.label , Kokkos::WithoutInitializing )
2245  , typename traits::array_layout
2246  ( arg_N0 , arg_N1 , arg_N2 , arg_N3
2247  , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
2248  )
2249  {
2250 #ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST
2251  Impl::runtime_check_rank_host(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2252  arg_N4, arg_N5, arg_N6, arg_N7, label());
2253 #else
2254  Impl::runtime_check_rank_device(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2255  arg_N4, arg_N5, arg_N6, arg_N7);
2256 
2257 #endif
2258 
2259  }
2260 
2261  //----------------------------------------
2262  // Memory span required to wrap these dimensions.
2263  static constexpr size_t required_allocation_size(
2264  const size_t arg_N0 = 0
2265  , const size_t arg_N1 = 0
2266  , const size_t arg_N2 = 0
2267  , const size_t arg_N3 = 0
2268  , const size_t arg_N4 = 0
2269  , const size_t arg_N5 = 0
2270  , const size_t arg_N6 = 0
2271  , const size_t arg_N7 = 0
2272  )
2273  {
2274  return map_type::memory_span(
2275  typename traits::array_layout
2276  ( arg_N0 , arg_N1 , arg_N2 , arg_N3
2277  , arg_N4 , arg_N5 , arg_N6 , arg_N7 ) );
2278  }
2279 
2280  explicit KOKKOS_INLINE_FUNCTION
2281  View( pointer_type arg_ptr
2282  , const size_t arg_N0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2283  , const size_t arg_N1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2284  , const size_t arg_N2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2285  , const size_t arg_N3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2286  , const size_t arg_N4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2287  , const size_t arg_N5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2288  , const size_t arg_N6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2289  , const size_t arg_N7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2290  )
2291  : View( Impl::ViewCtorProp<pointer_type>(arg_ptr)
2292  , typename traits::array_layout
2293  ( arg_N0 , arg_N1 , arg_N2 , arg_N3
2294  , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
2295  )
2296  {
2297 #ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST
2298  Impl::runtime_check_rank_host(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2299  arg_N4, arg_N5, arg_N6, arg_N7, label());
2300 #else
2301  Impl::runtime_check_rank_device(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2302  arg_N4, arg_N5, arg_N6, arg_N7);
2303 
2304 #endif
2305  }
2306 
2307  explicit KOKKOS_INLINE_FUNCTION
2308  View( pointer_type arg_ptr
2309  , const typename traits::array_layout & arg_layout
2310  )
2311  : View( Impl::ViewCtorProp<pointer_type>(arg_ptr) , arg_layout )
2312  {
2313 
2314  }
2315 
2316  //----------------------------------------
2317  // Shared scratch memory constructor
2318 
2319  static inline
2320  size_t
2321  shmem_size( const size_t arg_N0 = KOKKOS_INVALID_INDEX,
2322  const size_t arg_N1 = KOKKOS_INVALID_INDEX,
2323  const size_t arg_N2 = KOKKOS_INVALID_INDEX,
2324  const size_t arg_N3 = KOKKOS_INVALID_INDEX,
2325  const size_t arg_N4 = KOKKOS_INVALID_INDEX,
2326  const size_t arg_N5 = KOKKOS_INVALID_INDEX,
2327  const size_t arg_N6 = KOKKOS_INVALID_INDEX,
2328  const size_t arg_N7 = KOKKOS_INVALID_INDEX )
2329  {
2330  if ( is_layout_stride ) {
2331  Kokkos::abort( "Kokkos::View::shmem_size(extents...) doesn't work with LayoutStride. Pass a LayoutStride object instead" );
2332  }
2333  const size_t num_passed_args = Impl::count_valid_integers(arg_N0, arg_N1, arg_N2, arg_N3,
2334  arg_N4, arg_N5, arg_N6, arg_N7);
2335 
2336  if ( std::is_same<typename traits::specialize,void>::value && num_passed_args != traits::rank_dynamic ) {
2337  Kokkos::abort( "Kokkos::View::shmem_size() rank_dynamic != number of arguments.\n" );
2338  }
2339 
2340  return View::shmem_size(
2341  typename traits::array_layout
2342  ( arg_N0 , arg_N1 , arg_N2 , arg_N3
2343  , arg_N4 , arg_N5 , arg_N6 , arg_N7 ) );
2344  }
2345 
2346  static inline
2347  size_t shmem_size( typename traits::array_layout const& arg_layout )
2348  {
2349  return map_type::memory_span( arg_layout );
2350  }
2351 
2352  explicit KOKKOS_INLINE_FUNCTION
2353  View( const typename traits::execution_space::scratch_memory_space & arg_space
2354  , const typename traits::array_layout & arg_layout )
2355  : View( Impl::ViewCtorProp<pointer_type>(
2356  reinterpret_cast<pointer_type>(
2357  arg_space.get_shmem( map_type::memory_span( arg_layout ) ) ) )
2358  , arg_layout )
2359  {}
2360 
2361  explicit KOKKOS_INLINE_FUNCTION
2362  View( const typename traits::execution_space::scratch_memory_space & arg_space
2363  , const size_t arg_N0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2364  , const size_t arg_N1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2365  , const size_t arg_N2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2366  , const size_t arg_N3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2367  , const size_t arg_N4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2368  , const size_t arg_N5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2369  , const size_t arg_N6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2370  , const size_t arg_N7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG )
2371  : View( Impl::ViewCtorProp<pointer_type>(
2372  reinterpret_cast<pointer_type>(
2373  arg_space.get_shmem(
2374  map_type::memory_span(
2375  typename traits::array_layout
2376  ( arg_N0 , arg_N1 , arg_N2 , arg_N3
2377  , arg_N4 , arg_N5 , arg_N6 , arg_N7 ) ) ) ) )
2378  , typename traits::array_layout
2379  ( arg_N0 , arg_N1 , arg_N2 , arg_N3
2380  , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
2381  )
2382  {
2383 
2384 #ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST
2385  Impl::runtime_check_rank_host(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2386  arg_N4, arg_N5, arg_N6, arg_N7, label());
2387 #else
2388  Impl::runtime_check_rank_device(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2389  arg_N4, arg_N5, arg_N6, arg_N7);
2390 
2391 #endif
2392  }
2393 };
2394 
2395 
2400  template < typename D , class ... P >
2401  KOKKOS_INLINE_FUNCTION
2402  constexpr unsigned rank( const View<D , P...> & V ) { return V.Rank; } //Temporary until added to view
2403 
2404 //----------------------------------------------------------------------------
2405 //----------------------------------------------------------------------------
2406 
2407 template< class V , class ... Args >
2408 using Subview =
2409  typename Kokkos::Impl::ViewMapping
2410  < void /* deduce subview type from source view traits */
2411  , typename V::traits
2412  , Args ...
2413  >::type ;
2414 
2415 template< class D, class ... P , class ... Args >
2416 KOKKOS_INLINE_FUNCTION
2417 typename Kokkos::Impl::ViewMapping
2418  < void /* deduce subview type from source view traits */
2419  , ViewTraits< D , P... >
2420  , Args ...
2421  >::type
2422 subview( const View< D, P... > & src , Args ... args )
2423 {
2424  static_assert( View< D , P... >::Rank == sizeof...(Args) ,
2425  "subview requires one argument for each source View rank" );
2426 
2427  return typename
2428  Kokkos::Impl::ViewMapping
2429  < void /* deduce subview type from source view traits */
2430  , ViewTraits< D , P ... >
2431  , Args ... >::type( src , args ... );
2432 }
2433 
2434 template< class MemoryTraits , class D, class ... P , class ... Args >
2435 KOKKOS_INLINE_FUNCTION
2436 typename Kokkos::Impl::ViewMapping
2437  < void /* deduce subview type from source view traits */
2438  , ViewTraits< D , P... >
2439  , Args ...
2440  >::template apply< MemoryTraits >::type
2441 subview( const View< D, P... > & src , Args ... args )
2442 {
2443  static_assert( View< D , P... >::Rank == sizeof...(Args) ,
2444  "subview requires one argument for each source View rank" );
2445 
2446  return typename
2447  Kokkos::Impl::ViewMapping
2448  < void /* deduce subview type from source view traits */
2449  , ViewTraits< D , P ... >
2450  , Args ... >
2451  ::template apply< MemoryTraits >
2452  ::type( src , args ... );
2453 }
2454 
2455 } /* namespace Kokkos */
2456 
2457 //----------------------------------------------------------------------------
2458 //----------------------------------------------------------------------------
2459 
2460 namespace Kokkos {
2461 
2462 template< class LT , class ... LP , class RT , class ... RP >
2463 KOKKOS_INLINE_FUNCTION
2464 bool operator == ( const View<LT,LP...> & lhs ,
2465  const View<RT,RP...> & rhs )
2466 {
2467  // Same data, layout, dimensions
2468  typedef ViewTraits<LT,LP...> lhs_traits ;
2469  typedef ViewTraits<RT,RP...> rhs_traits ;
2470 
2471  return
2472  std::is_same< typename lhs_traits::const_value_type ,
2473  typename rhs_traits::const_value_type >::value &&
2474  std::is_same< typename lhs_traits::array_layout ,
2475  typename rhs_traits::array_layout >::value &&
2476  std::is_same< typename lhs_traits::memory_space ,
2477  typename rhs_traits::memory_space >::value &&
2478  unsigned(lhs_traits::rank) == unsigned(rhs_traits::rank) &&
2479  lhs.data() == rhs.data() &&
2480  lhs.span() == rhs.span() &&
2481  lhs.extent(0) == rhs.extent(0) &&
2482  lhs.extent(1) == rhs.extent(1) &&
2483  lhs.extent(2) == rhs.extent(2) &&
2484  lhs.extent(3) == rhs.extent(3) &&
2485  lhs.extent(4) == rhs.extent(4) &&
2486  lhs.extent(5) == rhs.extent(5) &&
2487  lhs.extent(6) == rhs.extent(6) &&
2488  lhs.extent(7) == rhs.extent(7);
2489 }
2490 
2491 template< class LT , class ... LP , class RT , class ... RP >
2492 KOKKOS_INLINE_FUNCTION
2493 bool operator != ( const View<LT,LP...> & lhs ,
2494  const View<RT,RP...> & rhs )
2495 {
2496  return ! ( operator==(lhs,rhs) );
2497 }
2498 
2499 } /* namespace Kokkos */
2500 
2501 //----------------------------------------------------------------------------
2502 //----------------------------------------------------------------------------
2503 
2504 namespace Kokkos {
2505 namespace Impl {
2506 
2507 inline
2508 void shared_allocation_tracking_disable()
2509 { Kokkos::Impl::SharedAllocationRecord<void,void>::tracking_disable(); }
2510 
2511 inline
2512 void shared_allocation_tracking_enable()
2513 { Kokkos::Impl::SharedAllocationRecord<void,void>::tracking_enable(); }
2514 
2515 } /* namespace Impl */
2516 } /* namespace Kokkos */
2517 
2518 //----------------------------------------------------------------------------
2519 //----------------------------------------------------------------------------
2520 
2521 namespace Kokkos { namespace Impl {
2522 
2523 template < class Specialize, typename A, typename B >
2524 struct CommonViewValueType;
2525 
2526 template < typename A, typename B >
2527 struct CommonViewValueType< void, A, B >
2528 {
2529  using value_type = typename std::common_type< A , B >::type;
2530 };
2531 
2532 
2533 template < class Specialize, class ValueType >
2534 struct CommonViewAllocProp;
2535 
2536 template < class ValueType >
2537 struct CommonViewAllocProp< void, ValueType >
2538 {
2539  using value_type = ValueType;
2540  using scalar_array_type = ValueType;
2541 
2542  template < class ... Views >
2543  KOKKOS_INLINE_FUNCTION
2544  CommonViewAllocProp( const Views & ... ) {}
2545 };
2546 
2547 
2548 template < class ... Views >
2549 struct DeduceCommonViewAllocProp;
2550 
2551 // Base case must provide types for:
2552 // 1. specialize 2. value_type 3. is_view 4. prop_type
2553 template < class FirstView >
2554 struct DeduceCommonViewAllocProp< FirstView >
2555 {
2556  using specialize = typename FirstView::traits::specialize;
2557 
2558  using value_type = typename FirstView::traits::value_type;
2559 
2560  enum : bool { is_view = is_view< FirstView >::value };
2561 
2562  using prop_type = CommonViewAllocProp< specialize, value_type >;
2563 };
2564 
2565 
2566 template < class FirstView, class ... NextViews >
2567 struct DeduceCommonViewAllocProp< FirstView, NextViews... >
2568 {
2569  using NextTraits = DeduceCommonViewAllocProp< NextViews... >;
2570 
2571  using first_specialize = typename FirstView::traits::specialize;
2572  using first_value_type = typename FirstView::traits::value_type;
2573 
2574  enum : bool { first_is_view = is_view< FirstView >::value };
2575 
2576  using next_specialize = typename NextTraits::specialize;
2577  using next_value_type = typename NextTraits::value_type;
2578 
2579  enum : bool { next_is_view = NextTraits::is_view };
2580 
2581  // common types
2582 
2583  // determine specialize type
2584  // if first and next specialize differ, but are not the same specialize, error out
2585  static_assert( !(!std::is_same< first_specialize, next_specialize >::value && !std::is_same< first_specialize, void>::value && !std::is_same< void, next_specialize >::value) , "Kokkos DeduceCommonViewAllocProp ERROR: Only one non-void specialize trait allowed" );
2586 
2587  // otherwise choose non-void specialize if either/both are non-void
2588  using specialize = typename std::conditional< std::is_same< first_specialize, next_specialize >::value
2589  , first_specialize
2590  , typename std::conditional< ( std::is_same< first_specialize, void >::value
2591  && !std::is_same< next_specialize, void >::value)
2592  , next_specialize
2593  , first_specialize
2594  >::type
2595  >::type;
2596 
2597  using value_type = typename CommonViewValueType< specialize, first_value_type, next_value_type >::value_type;
2598 
2599  enum : bool { is_view = (first_is_view && next_is_view) };
2600 
2601  using prop_type = CommonViewAllocProp< specialize, value_type >;
2602 };
2603 
2604 } // end namespace Impl
2605 
2606 template < class ... Views >
2607 using DeducedCommonPropsType = typename Impl::DeduceCommonViewAllocProp<Views...>::prop_type ;
2608 
2609 // User function
2610 template < class ... Views >
2611 KOKKOS_INLINE_FUNCTION
2612 DeducedCommonPropsType<Views...>
2613 common_view_alloc_prop( Views const & ... views )
2614 {
2615  return DeducedCommonPropsType<Views...>( views... );
2616 }
2617 
2618 } // namespace Kokkos
2619 
2620 
2621 namespace Kokkos {
2622 namespace Impl {
2623 
2624 using Kokkos::is_view ;
2625 
2626 } /* namespace Impl */
2627 } /* namespace Kokkos */
2628 
2629 #include <impl/Kokkos_ViewUniformType.hpp>
2630 #include <impl/Kokkos_Atomic_View.hpp>
2631 
2632 //----------------------------------------------------------------------------
2633 //----------------------------------------------------------------------------
2634 
2635 #endif /* #ifndef KOKKOS_VIEW_HPP */
2636 
KOKKOS_INLINE_FUNCTION bool operator==(const complex< RealType1 > &x, const complex< RealType2 > &y)
Equality operator for two complex numbers.
KOKKOS_INLINE_FUNCTION bool operator!=(const complex< RealType1 > &x, const complex< RealType2 > &y)
Inequality operator for two complex numbers.
Memory layout tag indicating left-to-right (Fortran scheme) striding of multi-indices.
View< typename traits::scalar_array_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...
View to an array of data.
Memory layout tag indicating right-to-left (C or lexigraphical scheme) striding of multi-indices...
View
View< typename traits::non_const_data_type, typename traits::array_layout, typename traits::host_mirror_space > host_mirror_type
Compatible HostMirror view.
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.
Impl::ViewUniformType< View, 0 >::type uniform_type
Unified types.
Impl::ViewCtorProp< typename Impl::ViewCtorProp< void, Args >::type ... > view_alloc(Args const &... args)
Create View allocation parameter bundle from argument list.
View< typename traits::non_const_data_type, typename traits::array_layout, typename traits::host_mirror_space > HostMirror
Compatible HostMirror view.
Traits class for accessing attributes of a View.
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< std::is_integral< iType >::value, size_t >::type extent(const iType &r) const
rank() to be implemented
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.