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