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