Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KokkosExp_View_MP_Vector_Contiguous.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Stokhos Package
5 // Copyright (2009) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef KOKKOS_EXPERIMENTAL_VIEW_MP_VECTOR_CONTIGUOUS_HPP
43 #define KOKKOS_EXPERIMENTAL_VIEW_MP_VECTOR_CONTIGUOUS_HPP
44 
45 #include "Sacado_Traits.hpp"
46 #include "Sacado_MP_Vector.hpp"
48 
49 // Only include forward declarations so any overloads appear before they
50 // might be used inside Kokkos
51 #include "Kokkos_Core_fwd.hpp"
52 #include "Kokkos_View.hpp"
53 #include "Kokkos_Layout.hpp"
54 #include "Kokkos_View_Utils.hpp"
56 
57 
58 //----------------------------------------------------------------------------
59 
60 namespace Kokkos {
61 
62  namespace Impl {
63  template<class Space, class T, class ... P>
64  struct MirrorType;
65  }
66 
67 }
68 
69 namespace Kokkos {
70 namespace Experimental {
71 namespace Impl {
72 
74 
75 template< class ... Args >
76 struct is_ViewMPVectorContiguous { enum { value = false }; };
77 
78 template< class D , class ... P , class ... Args >
79 struct is_ViewMPVectorContiguous< Kokkos::View<D,P...> , Args... > {
80  enum { value =
81  std::is_same< typename Kokkos::ViewTraits<D,P...>::specialize
83  &&
84  ( ( sizeof...(Args) == 0 ) ||
85  is_ViewMPVectorContiguous< Args... >::value ) };
86 };
87 
88 } // namespace Impl
89 } // namespace Experimental
90 } // namespace Kokkos
91 
92 namespace Kokkos {
93 
94 template <typename T, typename ... P>
95 struct is_view_mp_vector< View<T,P...> > {
96  typedef View<T,P...> view_type;
97  static const bool value =
98  std::is_same< typename view_type::specialize,
100 };
101 
102 template <typename T, typename ... P>
103 KOKKOS_INLINE_FUNCTION
104 constexpr typename
105 std::enable_if< is_view_mp_vector< View<T,P...> >::value, unsigned >::type
106 dimension_scalar(const View<T,P...>& view) {
107  return view.impl_map().dimension_scalar();
108 }
109 
110 // Declare overloads of create_mirror() so they are in scope
111 // Kokkos_Core.hpp is included below
112 
113 template< class T , class ... P >
114 inline
115 typename Kokkos::View<T,P...>::HostMirror
117  const Kokkos::View<T,P...> & src,
118  typename std::enable_if<
119  std::is_same< typename ViewTraits<T,P...>::specialize ,
121  !std::is_same< typename Kokkos::ViewTraits<T,P...>::array_layout,
122  Kokkos::LayoutStride >::value >::type * = 0);
123 
124 template< class T , class ... P >
125 inline
126 typename Kokkos::View<T,P...>::HostMirror
128  const Kokkos::View<T,P...> & src,
129  typename std::enable_if<
130  std::is_same< typename ViewTraits<T,P...>::specialize ,
132  std::is_same< typename Kokkos::ViewTraits<T,P...>::array_layout,
133  Kokkos::LayoutStride >::value >::type * = 0);
134 
135 template<class Space, class T, class ... P>
136 typename Impl::MirrorType<Space,T,P ...>::view_type
138  const Space&,
139  const Kokkos::View<T,P...> & src,
140  typename std::enable_if<
141  std::is_same< typename ViewTraits<T,P...>::specialize ,
143 
144 // Overload of deep_copy for MP::Vector views intializing to a constant scalar
145 template< class DT, class ... DP >
146 void deep_copy(
147  const View<DT,DP...> & view ,
148  const typename View<DT,DP...>::array_type::value_type & value
149  , typename std::enable_if<(
150  std::is_same< typename ViewTraits<DT,DP...>::specialize
152  )>::type * = 0 );
153 
154 // Overload of deep_copy for MP::Vector views intializing to a constant MP::Vector
155 template< class DT, class ... DP >
156 void deep_copy(
157  const View<DT,DP...> & view ,
158  const typename View<DT,DP...>::value_type & value
159  , typename std::enable_if<(
160  std::is_same< typename ViewTraits<DT,DP...>::specialize
162  )>::type * = 0 );
163 
164 // Overload of deep_copy for MP::Vector views intializing to a constant scalar
165 template< class ExecSpace , class DT, class ... DP >
166 void deep_copy(
167  const ExecSpace &,
168  const View<DT,DP...> & view ,
169  const typename View<DT,DP...>::array_type::value_type & value
170  , typename std::enable_if<(
171  Kokkos::Impl::is_execution_space< ExecSpace >::value &&
172  std::is_same< typename ViewTraits<DT,DP...>::specialize
174  )>::type * = 0 );
175 
176 // Overload of deep_copy for MP::Vector views intializing to a constant MP::Vector
177 template< class ExecSpace , class DT, class ... DP >
178 void deep_copy(
179  const ExecSpace &,
180  const View<DT,DP...> & view ,
181  const typename View<DT,DP...>::value_type & value
182  , typename std::enable_if<(
183  Kokkos::Impl::is_execution_space< ExecSpace >::value &&
184  std::is_same< typename ViewTraits<DT,DP...>::specialize
186  )>::type * = 0 );
187 
188 /* Specialize for deep copy of MP::Vector */
189 template< class DT , class ... DP , class ST , class ... SP >
190 inline
191 void deep_copy( const View<DT,DP...> & dst ,
192  const View<ST,SP...> & src
193  , typename std::enable_if<(
194  std::is_same< typename ViewTraits<DT,DP...>::specialize
196  &&
197  std::is_same< typename ViewTraits<ST,SP...>::specialize
199  )>::type * = 0 );
200 
201 } // namespace Kokkos
202 
203 //----------------------------------------------------------------------------
204 
205 #include "Kokkos_Core.hpp"
206 
207 namespace Kokkos {
208 
209 template <typename D, typename ... P>
210 struct FlatArrayType< View<D,P...>,
211  typename std::enable_if< is_view_mp_vector< View<D,P...> >::value >::type > {
212  typedef View<D,P...> view_type;
213  typedef typename view_type::traits::dimension dimension;
215  typedef typename Kokkos::Impl::ViewDataType< flat_value_type , dimension >::type flat_data_type;
216  typedef View<flat_data_type,P...> type;
217 };
218 
219 template< class T , class ... P >
220 inline
221 typename Kokkos::View<T,P...>::HostMirror
222 create_mirror( const Kokkos::View<T,P...> & src
223  , typename std::enable_if<
224  std::is_same< typename ViewTraits<T,P...>::specialize ,
226  &&
227  ! std::is_same< typename Kokkos::ViewTraits<T,P...>::array_layout
228  , Kokkos::LayoutStride >::value
229  >::type *
230  )
231 {
232  typedef View<T,P...> src_type ;
233  typedef typename src_type::HostMirror dst_type ;
234 
235  typename src_type::array_layout layout = src.layout();
236  layout.dimension[src_type::rank] = Kokkos::dimension_scalar(src);
237 
238  return dst_type(std::string(src.label()).append("_mirror"), layout);
239 }
240 
241 template< class T , class ... P >
242 inline
243 typename Kokkos::View<T,P...>::HostMirror
244 create_mirror( const Kokkos::View<T,P...> & src
245  , typename std::enable_if<
246  std::is_same< typename ViewTraits<T,P...>::specialize ,
248  &&
249  std::is_same< typename Kokkos::ViewTraits<T,P...>::array_layout
250  , Kokkos::LayoutStride >::value
251  >::type *
252  )
253 {
254  typedef View<T,P...> src_type ;
255  typedef typename src_type::HostMirror dst_type ;
256 
257  Kokkos::LayoutStride layout ;
258 
259  layout.dimension[0] = src.extent(0);
260  layout.dimension[1] = src.extent(1);
261  layout.dimension[2] = src.extent(2);
262  layout.dimension[3] = src.extent(3);
263  layout.dimension[4] = src.extent(4);
264  layout.dimension[5] = src.extent(5);
265  layout.dimension[6] = src.extent(6);
266  layout.dimension[7] = src.extent(7);
267 
268  layout.stride[0] = src.stride_0();
269  layout.stride[1] = src.stride_1();
270  layout.stride[2] = src.stride_2();
271  layout.stride[3] = src.stride_3();
272  layout.stride[4] = src.stride_4();
273  layout.stride[5] = src.stride_5();
274  layout.stride[6] = src.stride_6();
275  layout.stride[7] = src.stride_7();
276 
277  layout.dimension[src_type::rank] = Kokkos::dimension_scalar(src);
278 
279  return dst_type(std::string(src.label()).append("_mirror"), layout);
280 }
281 
282 template<class Space, class T, class ... P>
283 typename Impl::MirrorType<Space,T,P ...>::view_type
284 create_mirror(const Space& , const Kokkos::View<T,P...> & src
285  , typename std::enable_if<
286  std::is_same< typename ViewTraits<T,P...>::specialize ,
288  >::type *) {
289  typedef View<T,P...> src_type ;
290  typename src_type::array_layout layout = src.layout();
291  layout.dimension[src_type::rank] = Kokkos::dimension_scalar(src);
292  return typename Impl::MirrorType<Space,T,P ...>::view_type(src.label(),layout);
293 }
294 
295 // Overload of deep_copy for MP::Vector views intializing to a constant scalar
296 template< class DT, class ... DP >
298  const View<DT,DP...> & view ,
299  const typename View<DT,DP...>::array_type::value_type & value
300  , typename std::enable_if<(
301  std::is_same< typename ViewTraits<DT,DP...>::specialize
303  )>::type * )
304 {
305  static_assert(
306  std::is_same< typename ViewTraits<DT,DP...>::value_type ,
307  typename ViewTraits<DT,DP...>::non_const_value_type >::value
308  , "Can only deep copy into non-const type" );
309 
310  typedef typename FlatArrayType< View<DT,DP...> >::type flat_array_type;
312 }
313 
314 // Overload of deep_copy for MP::Vector views intializing to a constant MP::Vector
315 template< class DT, class ... DP >
317  const View<DT,DP...> & view ,
318  const typename View<DT,DP...>::value_type & value
319  , typename std::enable_if<(
320  std::is_same< typename ViewTraits<DT,DP...>::specialize
322  )>::type * )
323 {
324  static_assert(
325  std::is_same< typename ViewTraits<DT,DP...>::value_type ,
326  typename ViewTraits<DT,DP...>::non_const_value_type >::value
327  , "Can only deep copy into non-const type" );
328 
329  // static_assert(
330  // Sacado::StaticSize< typename View<DT,DP...>::value_type >::value
331  // ||
332  // std::is_same< Kokkos::Impl::ActiveExecutionMemorySpace
333  // , Kokkos::HostSpace >::value
334  // , "Deep copy from a FAD type must be statically sized or host space" );
335 
336  Kokkos::Impl::StokhosViewFill< View<DT,DP...> >( view , value );
337 }
338 
339 // Overload of deep_copy for MP::Vector views intializing to a constant scalar
340 template< class ExecSpace , class DT, class ... DP >
342  const ExecSpace &,
343  const View<DT,DP...> & view ,
344  const typename View<DT,DP...>::array_type::value_type & value
345  , typename std::enable_if<(
346  Kokkos::Impl::is_execution_space< ExecSpace >::value &&
347  std::is_same< typename ViewTraits<DT,DP...>::specialize
349  )>::type * )
350 {
351  static_assert(
352  std::is_same< typename ViewTraits<DT,DP...>::value_type ,
353  typename ViewTraits<DT,DP...>::non_const_value_type >::value
354  , "Can only deep copy into non-const type" );
355 
356  typedef typename FlatArrayType< View<DT,DP...> >::type flat_array_type;
358 }
359 
360 // Overload of deep_copy for MP::Vector views intializing to a constant MP::Vector
361 template< class ExecSpace , class DT, class ... DP >
363  const ExecSpace &,
364  const View<DT,DP...> & view ,
365  const typename View<DT,DP...>::value_type & value
366  , typename std::enable_if<(
367  Kokkos::Impl::is_execution_space< ExecSpace >::value &&
368  std::is_same< typename ViewTraits<DT,DP...>::specialize
370  )>::type * )
371 {
372  static_assert(
373  std::is_same< typename ViewTraits<DT,DP...>::value_type ,
374  typename ViewTraits<DT,DP...>::non_const_value_type >::value
375  , "Can only deep copy into non-const type" );
376 
377  // static_assert(
378  // Sacado::StaticSize< typename View<DT,DP...>::value_type >::value
379  // ||
380  // std::is_same< Kokkos::Impl::ActiveExecutionMemorySpace
381  // , Kokkos::HostSpace >::value
382  // , "Deep copy from a FAD type must be statically sized or host space" );
383 
384  Kokkos::Impl::StokhosViewFill< View<DT,DP...> >( view , value );
385 }
386 
387 /* Specialize for deep copy of MP::Vector */
388 template< class DT , class ... DP , class ST , class ... SP >
389 inline
390 void deep_copy( const View<DT,DP...> & dst ,
391  const View<ST,SP...> & src
392  , typename std::enable_if<(
393  std::is_same< typename ViewTraits<DT,DP...>::specialize
395  &&
396  std::is_same< typename ViewTraits<ST,SP...>::specialize
398  )>::type * )
399 {
400  static_assert(
401  std::is_same< typename ViewTraits<DT,DP...>::value_type ,
402  typename ViewTraits<DT,DP...>::non_const_value_type >::value
403  , "Deep copy destination must be non-const" );
404 
405  static_assert(
406  ( unsigned(ViewTraits<DT,DP...>::rank) ==
407  unsigned(ViewTraits<ST,SP...>::rank) )
408  , "Deep copy destination and source must have same rank" );
409 
410  // Note ETP 09/29/2016: Use FlatArrayType instead of array_type to work
411  // around issue where dst and src are rank-1, but have differing layouts.
412  // Kokkos' deep_copy() doesn't work in this case because the array_type
413  // will be rank-2. It should be possible to make deep_copy() work there,
414  // but this seems easier.
415 
416  // Kokkos::deep_copy(
417  // typename View<DT,DP...>::array_type( dst ) ,
418  // typename View<ST,SP...>::array_type( src ) );
419 
421  typename FlatArrayType< View<DT,DP...> >::type( dst ) ,
422  typename FlatArrayType< View<ST,SP...> >::type( src ) );
423 }
424 
425 }
426 
427 namespace Kokkos {
428 namespace Impl {
429 
430 template< class DataType , class ArrayLayout , typename StorageType >
431 struct ViewDataAnalysis< DataType /* Original view data type */
432  , ArrayLayout
433  , Sacado::MP::Vector< StorageType > >
434 {
435 private:
436 
438  typedef ViewArrayAnalysis< DataType > array_analysis ;
439  static const int DimVector = StorageType::static_size;
440 
441 public:
442 
443  // Specialized view data mapping:
445 
446  typedef typename array_analysis::dimension dimension ;
448  typedef typename array_analysis::const_value_type const_value_type ;
449  typedef typename array_analysis::non_const_value_type non_const_value_type ;
450 
451  // Generate analogous multidimensional array specification type.
452  typedef typename
453  ViewDataType< value_type , dimension >::type type ;
454  typedef typename
455  ViewDataType< const_value_type , dimension >::type const_type ;
456  typedef typename
457  ViewDataType< non_const_value_type , dimension >::type non_const_type ;
458 
459 private:
460 
461  // A const ?
462  enum { is_const = std::is_same< value_type , const_value_type >::value };
463 
464  // The unwrapped scalar types:
465  typedef typename
466  std::conditional< is_const , const ScalarType , ScalarType >::type
468 
471 
472  // Prepend or append the vector dimension based on ArrayLayout
473  // Note: you can't prepend a static dimension, so use 0 for LayoutLeft
474  typedef typename array_analysis::dimension::
475  template prepend<0>::type
477  typedef typename array_analysis::dimension::
478  template append<DimVector>::type
480  typedef typename std::conditional<
481  std::is_same< ArrayLayout, Kokkos::LayoutLeft>::value,
484 
485 public:
486 
487  // Generate "flattened" multidimensional array specification type.
488  typedef typename
489  ViewDataType< scalar_type , scalar_dimension >::type scalar_array_type ;
490 
491  typedef typename
492  ViewDataType< const_scalar_type , scalar_dimension >::type
494 
495  typedef typename
496  ViewDataType< non_const_scalar_type , scalar_dimension >::type
498 };
499 
500 } // namespace Impl
501 } // namespace Kokkos
502 
503 //----------------------------------------------------------------------------
504 
505 namespace Kokkos {
506 namespace Experimental {
507 namespace Impl {
508 
509  template < class ValueType,
510  bool is_static = Sacado::IsStaticallySized<ValueType>::value >
512 
513 // MP::Vector allocation for statically-sized MP::Vector types.
514 // In this case we can reinterpret cast directly between pointers of types
515 // MP::Vector<Storage> and MP::Vector<Storage>::value_type.
516 template <class ValueType>
517 struct MPVectorAllocation<ValueType, true> {
518  typedef ValueType value_type;
519  typedef typename Sacado::ValueType<value_type>::type scalar_type;
520 
523 
524  KOKKOS_INLINE_FUNCTION
525  static constexpr size_t
526  memory_span(const size_t span, const unsigned vector_size) {
527  return span * vector_size * sizeof(scalar_type);
528  }
529 
530  KOKKOS_INLINE_FUNCTION
531  MPVectorAllocation() : value_ptr(0), scalar_ptr(0) {}
532 
533  template <typename T>
534  KOKKOS_INLINE_FUNCTION
536  value_ptr = a.value_ptr;
537  scalar_ptr = a.scalar_ptr;
538  return *this;
539  }
540 
541  KOKKOS_INLINE_FUNCTION
542  void set(value_type* ptr, const size_t span, const unsigned vector_size) {
543  value_ptr = ptr;
544  scalar_ptr = reinterpret_cast<scalar_type*>(ptr);
545  }
546 
547  template <class ExecSpace>
548  struct ConstructDestructFunctor {
549  typedef Kokkos::Impl::ViewValueFunctor< ExecSpace, scalar_type > FunctorType ;
552 
553  ConstructDestructFunctor() = default;
554  ConstructDestructFunctor(const ConstructDestructFunctor&) = default;
555  ConstructDestructFunctor& operator=(const ConstructDestructFunctor&) = default;
556 
557  ConstructDestructFunctor(const ExecSpace & space,
558  const bool initialize,
559  const size_t span,
560  const unsigned vector_size,
561  scalar_type* scalar_ptr) :
562  m_functor( space , scalar_ptr , span*vector_size ),
563  m_initialize(initialize) {}
564 
566  if (m_initialize)
567  m_functor.construct_shared_allocation();
568  }
569 
571  if (m_initialize)
572  m_functor.destroy_shared_allocation();
573  }
574 
575  };
576 
577  template <class ExecSpace>
578  inline ConstructDestructFunctor<ExecSpace>
579  create_functor(const ExecSpace & space,
580  const bool initialize,
581  const size_t span,
582  const unsigned vector_size) const {
583  return ConstructDestructFunctor<ExecSpace>(space, initialize, span, vector_size, scalar_ptr);
584  }
585 
586  // Assign scalar_type pointer to give ptr
587  template <typename T>
588  KOKKOS_INLINE_FUNCTION
589  void assign(T * ptr) {
590  value_ptr = reinterpret_cast<value_type*>(ptr);
591  scalar_ptr = reinterpret_cast<scalar_type*>(ptr);
592  }
593 
594 };
595 
596 // MP::Vector allocation for dynamically-sized MP::Vector types.
597 // In this case we allocate two chunks of data, the first for the the
598 // MP::Vector<Storage> itself and then for the underlying scalar type
599 // (MP::Vector<Storage>::value_type). The memory is laid out with the
600 // former followed by the latter.
601 template <class ValueType>
602 struct MPVectorAllocation<ValueType, false> {
603  typedef ValueType value_type;
604  typedef typename Sacado::ValueType<value_type>::type scalar_type;
605 
608 
609  KOKKOS_INLINE_FUNCTION
610  static constexpr size_t
611  memory_span(const size_t span, const unsigned vector_size) {
612  return span * ( vector_size * sizeof(scalar_type) + sizeof(value_type) );
613  }
614 
615  KOKKOS_INLINE_FUNCTION
616  MPVectorAllocation() : value_ptr(0), scalar_ptr(0) {}
617 
618  template <typename T>
619  KOKKOS_INLINE_FUNCTION
621  value_ptr = a.value_ptr;
622  scalar_ptr = a.scalar_ptr;
623  return *this;
624  }
625 
626  // We are making an assumption the data is laid out as described above,
627  // which in general may not be true if the view is created from memory
628  // allocated elsewhere. We should check for that.
629  KOKKOS_INLINE_FUNCTION
630  void set(value_type* ptr, const size_t span, const unsigned vector_size) {
631  value_ptr = ptr;
632  scalar_ptr = reinterpret_cast<scalar_type*>(ptr+span);
633  }
634 
635  template <class ExecSpace>
636  struct VectorConstruct {
637  ExecSpace m_space;
640  size_t m_span;
641  unsigned m_vector_size;
642 
643  VectorConstruct() = default;
644  VectorConstruct(const VectorConstruct&) = default;
645  VectorConstruct& operator=(const VectorConstruct&) = default;
646 
647  inline
648  VectorConstruct(const ExecSpace& space,
649  value_type* p,
650  scalar_type* sp,
651  const size_t span,
652  const unsigned vector_size) :
653  m_space(space), m_p(p), m_sp(sp), m_span(span), m_vector_size(vector_size) {}
654 
655  inline void execute() {
656  if ( ! m_space.in_parallel() ) {
657  typedef Kokkos::RangePolicy< ExecSpace > PolicyType ;
658  const Kokkos::Impl::ParallelFor< VectorConstruct , PolicyType >
659  closure( *this , PolicyType( 0 , m_span ) );
660  closure.execute();
661  m_space.fence();
662  }
663  else {
664  for ( size_t i = 0 ; i < m_span ; ++i ) operator()(i);
665  }
666  }
667 
668  KOKKOS_INLINE_FUNCTION
669  void operator() (const size_t i) const {
670  new (m_p+i) value_type(m_vector_size, m_sp+i*m_vector_size, false);
671  }
672  };
673 
674  template <class ExecSpace>
675  struct ConstructDestructFunctor {
676  typedef Kokkos::Impl::ViewValueFunctor< ExecSpace, scalar_type > ScalarFunctorType ;
677  typedef VectorConstruct< ExecSpace > VectorFunctorType ;
681 
682  ConstructDestructFunctor() = default;
683  ConstructDestructFunctor(const ConstructDestructFunctor&) = default;
684  ConstructDestructFunctor& operator=(const ConstructDestructFunctor&) = default;
685 
686  ConstructDestructFunctor(const ExecSpace & space,
687  const bool initialize,
688  const size_t span,
689  const unsigned vector_size,
690  scalar_type* scalar_ptr,
691  value_type* value_ptr) :
692  m_scalar_functor( space , scalar_ptr , span*vector_size ),
693  m_vector_functor( space , value_ptr , scalar_ptr , span , vector_size ),
694  m_initialize(initialize) {}
695 
697  // First initialize the scalar_type array
698  if (m_initialize)
699  m_scalar_functor.construct_shared_allocation();
700 
701  // Construct each MP::Vector using memory in scalar_ptr array,
702  // setting pointer to MP::Vector values from values array
703  // Equivalent to:
704  // value_type* p = value_ptr;
705  // scalar_type* sp = scalar_ptr;
706  // for (size_t i=0; i<span; ++i) {
707  // new (p++) value_type(vector_size, sp, false);
708  // sp += vector_size;
709  // }
710  // (we always need to do this, regardless of initialization)
711  m_vector_functor.execute();
712  }
713 
715  // We only need to (possibly) call the destructor on values in the
716  // scalar_type array, since the value_type array is a view into it
717  if (m_initialize)
718  m_scalar_functor.destroy_shared_allocation();
719  }
720 
721  };
722 
723  template <class ExecSpace>
724  inline ConstructDestructFunctor<ExecSpace>
725  create_functor(const ExecSpace & space,
726  const bool initialize,
727  const size_t span,
728  const unsigned vector_size) const {
729  return ConstructDestructFunctor<ExecSpace>(space, initialize, span, vector_size, scalar_ptr, value_ptr);
730  }
731 
732  // Assign scalar_type pointer to give ptr
733  // This makes BIG assumption on how the data was allocated
734  template <typename T>
735  KOKKOS_INLINE_FUNCTION
736  void assign(T * ptr) {
737  value_ptr = reinterpret_cast<value_type*>(ptr);
738  if (ptr != 0)
739  scalar_ptr = value_ptr->coeff();
740  else
741  scalar_ptr = 0;
742  }
743 };
744 
745 }}} // namespace Kokkos::Experimental::Impl
746 
747 namespace Kokkos {
748 namespace Impl {
749 
750 template< class Traits >
751 class ViewMapping< Traits , /* View internal mapping */
752  typename std::enable_if<
753  ( std::is_same< typename Traits::specialize
754  , Kokkos::Experimental::Impl::ViewMPVectorContiguous >::value
755  &&
756  ( std::is_same< typename Traits::array_layout
757  , Kokkos::LayoutLeft >::value
758  ||
759  std::is_same< typename Traits::array_layout
760  , Kokkos::LayoutRight >::value
761  ||
762  std::is_same< typename Traits::array_layout
763  , Kokkos::LayoutStride >::value
764  )
765  )
766  , typename Traits::specialize
767  >::type >
768 {
769 private:
770 
771  template< class , class ... > friend class ViewMapping ;
772  template< class , class ... > friend class Kokkos::View ;
773 
777  typedef typename
778  std::add_const< intrinsic_scalar_type >::type const_intrinsic_scalar_type ;
779 
780  enum { StokhosStorageStaticDimension = stokhos_storage_type::static_size };
781  typedef Sacado::integral_nonzero< unsigned , StokhosStorageStaticDimension > sacado_size_type;
782 
784 
785  typedef ViewOffset< typename Traits::dimension
786  , typename Traits::array_layout
787  , void
789 
790  // Prepend or append the vector dimension based on array_layout
791  // Note: you can't prepend a static dimension, so use 0 for LayoutLeft
792  typedef ViewArrayAnalysis< typename Traits::data_type > array_analysis ;
793  typedef typename array_analysis::dimension array_dimension;
794  typedef ViewOffset< typename array_dimension::
795  template append<StokhosStorageStaticDimension>::type,
796  typename Traits::array_layout,
797  void
799  typedef ViewOffset< typename array_dimension::
800  template prepend<0>::type,
801  typename Traits::array_layout,
802  void
804  typedef typename std::conditional<
805  std::is_same< typename Traits::array_layout, Kokkos::LayoutLeft>::value,
808 
811  unsigned m_stride ;
812  sacado_size_type m_sacado_size ; // Size of sacado dimension
813 
814  // Note: if the view is partitioned, m_sacado_size is not the stride in
815  // memory between consecutive MP::Vector entries for given vector index:
816  //
817  // original_sacado_size = m_stride * m_sacado_size
818  // m_stride = 1 for original allocation.
819  //
820  // Stride here has a slightly different meaning than in the standard
821  // View implementation. For the moment we are assuming no padding within
822  // the view array itself and stride is to allow for partitioning the view
823  // by dividing up the scalar type.
824  //
825  // I suspect we could combine this with the way the stride is managed in
826  // the default view, in which case, I don't think we even need a
827  // specialization
828  //
829  // For reshaping by folding the sacado dimension into its next adjacent
830  // dimension, padding wouldn't generally work. So unless there becomes
831  // a way to turn padding off in the default view, a specialization
832  // will be necessary.
833 
834 public:
835 
836  //----------------------------------------
837  // Domain dimensions
838 
839  enum { Rank = Traits::dimension::rank };
840 
841  // Rank corresponding to the sacado dimension
842  enum { Sacado_Rank = std::is_same< typename Traits::array_layout, Kokkos::LayoutLeft >::value ? 0 : Rank+1 };
843 
844  // Using the internal offset mapping so limit to public rank:
845  template< typename iType >
846  KOKKOS_INLINE_FUNCTION constexpr size_t extent( const iType & r ) const
847  { return m_impl_offset.m_dim.extent(r); }
848 
849  KOKKOS_INLINE_FUNCTION constexpr
850  typename Traits::array_layout layout() const
851  { return m_impl_offset.layout(); }
852 
853  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_0() const
854  { return m_impl_offset.dimension_0(); }
855  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_1() const
856  { return m_impl_offset.dimension_1(); }
857  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_2() const
858  { return m_impl_offset.dimension_2(); }
859  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_3() const
860  { return m_impl_offset.dimension_3(); }
861  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_4() const
862  { return m_impl_offset.dimension_4(); }
863  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_5() const
864  { return m_impl_offset.dimension_5(); }
865  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_6() const
866  { return m_impl_offset.dimension_6(); }
867  KOKKOS_INLINE_FUNCTION constexpr size_t dimension_7() const
868  { return m_impl_offset.dimension_7(); }
869 
870  // Is a regular layout with uniform striding for each index.
871  // Since we all for striding within the data type, we can't guarantee
872  // regular striding
873  using is_regular = std::false_type ;
874 
875  // FIXME: Adjust these for m_stride
876  KOKKOS_INLINE_FUNCTION constexpr size_t stride_0() const
877  { return m_impl_offset.stride_0(); }
878  KOKKOS_INLINE_FUNCTION constexpr size_t stride_1() const
879  { return m_impl_offset.stride_1(); }
880  KOKKOS_INLINE_FUNCTION constexpr size_t stride_2() const
881  { return m_impl_offset.stride_2(); }
882  KOKKOS_INLINE_FUNCTION constexpr size_t stride_3() const
883  { return m_impl_offset.stride_3(); }
884  KOKKOS_INLINE_FUNCTION constexpr size_t stride_4() const
885  { return m_impl_offset.stride_4(); }
886  KOKKOS_INLINE_FUNCTION constexpr size_t stride_5() const
887  { return m_impl_offset.stride_5(); }
888  KOKKOS_INLINE_FUNCTION constexpr size_t stride_6() const
889  { return m_impl_offset.stride_6(); }
890  KOKKOS_INLINE_FUNCTION constexpr size_t stride_7() const
891  { return m_impl_offset.stride_7(); }
892 
893  template< typename iType >
894  KOKKOS_INLINE_FUNCTION void stride( iType * const s ) const
895  { m_impl_offset.stride(s); }
896 
897  // Size of sacado scalar dimension
898  KOKKOS_FORCEINLINE_FUNCTION constexpr unsigned dimension_scalar() const
899  { return m_sacado_size.value; }
900 
901  // Whether the storage type is statically sized
902  static const bool is_static = stokhos_storage_type::is_static ;
903 
904  // Whether sacado dimension is contiguous
905  static const bool is_contiguous = true;
906 
907  //----------------------------------------
908  // Range of mapping
909 
910  // Return type of reference operators
912 
915 
917  KOKKOS_INLINE_FUNCTION constexpr size_t span() const
918  { return m_impl_offset.span(); }
919 
921  KOKKOS_INLINE_FUNCTION constexpr bool span_is_contiguous() const
922  { return m_impl_offset.span_is_contiguous() && (m_stride == 1); }
923 
925  KOKKOS_INLINE_FUNCTION constexpr pointer_type data() const
926  { return m_impl_handle.value_ptr ; }
927 
928  //----------------------------------------
929 
930  KOKKOS_FORCEINLINE_FUNCTION
932  { return *m_impl_handle.value_ptr; }
933 
934  // FIXME: Check this
935  template< typename I0 >
936  KOKKOS_FORCEINLINE_FUNCTION
937  typename
938  std::enable_if< std::is_integral<I0>::value &&
939  ! std::is_same< typename Traits::array_layout , Kokkos::LayoutStride >::value
940  , reference_type >::type
941  reference( const I0 & i0 ) const
942  { return m_impl_handle.value_ptr[m_stride * i0]; }
943 
944  // FIXME: Check this
945  template< typename I0 >
946  KOKKOS_FORCEINLINE_FUNCTION
947  typename
948  std::enable_if< std::is_integral<I0>::value &&
949  std::is_same< typename Traits::array_layout , Kokkos::LayoutStride >::value
950  , reference_type >::type
951  reference( const I0 & i0 ) const
952  { return m_impl_handle.value_ptr[ m_stride * m_impl_offset(i0) ]; }
953 
954  template< typename I0 , typename I1 >
955  KOKKOS_FORCEINLINE_FUNCTION
956  reference_type reference( const I0 & i0 , const I1 & i1 ) const
957  { return m_impl_handle.value_ptr[ m_stride * m_impl_offset(i0,i1) ]; }
958 
959  template< typename I0 , typename I1 , typename I2 >
960  KOKKOS_FORCEINLINE_FUNCTION
961  reference_type reference( const I0 & i0 , const I1 & i1 , const I2 & i2 ) const
962  { return m_impl_handle.value_ptr[ m_stride * m_impl_offset(i0,i1,i2) ]; }
963 
964  template< typename I0 , typename I1 , typename I2 , typename I3 >
965  KOKKOS_FORCEINLINE_FUNCTION
966  reference_type reference( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3 ) const
967  { return m_impl_handle.value_ptr[ m_stride * m_impl_offset(i0,i1,i2,i3) ]; }
968 
969  template< typename I0 , typename I1 , typename I2 , typename I3
970  , typename I4 >
971  KOKKOS_FORCEINLINE_FUNCTION
972  reference_type reference( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
973  , const I4 & i4 ) const
974  { return m_impl_handle.value_ptr[ m_stride * m_impl_offset(i0,i1,i2,i3,i4) ]; }
975 
976  template< typename I0 , typename I1 , typename I2 , typename I3
977  , typename I4 , typename I5 >
978  KOKKOS_FORCEINLINE_FUNCTION
979  reference_type reference( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
980  , const I4 & i4 , const I5 & i5 ) const
981  { return m_impl_handle.value_ptr[ m_stride * m_impl_offset(i0,i1,i2,i3,i4,i5) ]; }
982 
983  template< typename I0 , typename I1 , typename I2 , typename I3
984  , typename I4 , typename I5 , typename I6 >
985  KOKKOS_FORCEINLINE_FUNCTION
986  reference_type reference( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
987  , const I4 & i4 , const I5 & i5 , const I6 & i6 ) const
988  { return m_impl_handle.value_ptr[ m_stride * m_impl_offset(i0,i1,i2,i3,i4,i5,i6) ]; }
989 
990  template< typename I0 , typename I1 , typename I2 , typename I3
991  , typename I4 , typename I5 , typename I6 , typename I7 >
992  KOKKOS_FORCEINLINE_FUNCTION
993  reference_type reference( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
994  , const I4 & i4 , const I5 & i5 , const I6 & i6 , const I7 & i7 ) const
995  { return m_impl_handle.value_ptr[ m_stride * m_impl_offset(i0,i1,i2,i3,i4,i5,i6,i7) ]; }
996 
997  //----------------------------------------
998 
1000  KOKKOS_INLINE_FUNCTION
1001  static size_t memory_span( typename Traits::array_layout const & layout )
1002  {
1003  // Do not introduce padding...
1004  typedef std::integral_constant< unsigned , 0 > padding ;
1005  offset_type offset( padding(), layout );
1006 
1007  // Always use static dimension if we are static
1008  const unsigned static_dim = StokhosStorageStaticDimension;
1009  if (static_dim > 0)
1010  return handle_type::memory_span( offset.span(), static_dim );
1011 
1012  // Else get size from prescribed layout
1013  const size_t sacado_size =
1015  return handle_type::memory_span( offset.span(), sacado_size );
1016  }
1017 
1018  //----------------------------------------
1019 
1020  KOKKOS_DEFAULTED_FUNCTION ~ViewMapping() = default ;
1021  KOKKOS_INLINE_FUNCTION ViewMapping() :
1022  m_impl_handle(),
1023  m_impl_offset(),
1024  m_stride(1),
1025  m_sacado_size(0)
1026  {}
1027 
1028  KOKKOS_DEFAULTED_FUNCTION ViewMapping( const ViewMapping & ) = default ;
1029  KOKKOS_DEFAULTED_FUNCTION ViewMapping & operator = ( const ViewMapping & ) = default ;
1030 
1031  KOKKOS_DEFAULTED_FUNCTION ViewMapping( ViewMapping && ) = default ;
1032  KOKKOS_DEFAULTED_FUNCTION ViewMapping & operator = ( ViewMapping && ) = default ;
1033 
1034  template< class ... P >
1035  KOKKOS_INLINE_FUNCTION
1036  ViewMapping
1037  ( ViewCtorProp< P ... > const & prop
1038  , typename Traits::array_layout const & layout
1039  )
1040  : m_impl_handle()
1041  , m_impl_offset( std::integral_constant< unsigned , 0 >()
1042  , layout )
1043  , m_stride( 1 )
1044  , m_sacado_size( Kokkos::Impl::GetSacadoSize<unsigned(Rank)>::eval(layout) )
1045  {
1046  m_impl_handle.set( ( (ViewCtorProp<void,pointer_type> const &) prop ).value,
1047  m_impl_offset.span(), m_sacado_size.value );
1048  }
1049 
1051  KOKKOS_INLINE_FUNCTION
1052  void assign_data( pointer_type arg_ptr )
1053  { m_impl_handle.set( arg_ptr, m_impl_offset.span(), m_sacado_size.value ); }
1054 
1055  //----------------------------------------
1056  /* Allocate and construct mapped array.
1057  * Allocate via shared allocation record and
1058  * return that record for allocation tracking.
1059  */
1060  template< class ... P >
1061  SharedAllocationRecord<> *
1062  allocate_shared( ViewCtorProp< P... > const & prop
1063  , typename Traits::array_layout const & layout )
1064  {
1065  typedef ViewCtorProp< P... > ctor_prop ;
1066 
1067  typedef typename ctor_prop::execution_space execution_space ;
1068  typedef typename Traits::memory_space memory_space ;
1069  typedef typename handle_type::template ConstructDestructFunctor<execution_space> functor_type ;
1070  typedef SharedAllocationRecord< memory_space , functor_type > record_type ;
1071 
1072  // Disallow padding
1073  typedef std::integral_constant< unsigned , 0 > padding ;
1074 
1075  m_impl_offset = offset_type( padding(), layout );
1076  m_stride = 1;
1077  m_sacado_size = Kokkos::Impl::GetSacadoSize<unsigned(Rank)>::eval(layout);
1078 
1079  const size_t alloc_size =
1080  handle_type::memory_span( m_impl_offset.span(), m_sacado_size.value );
1081 
1082  // Create shared memory tracking record with allocate memory from the memory space
1083  record_type * const record =
1084  record_type::allocate( ( (ViewCtorProp<void,memory_space> const &) prop ).value
1085  , ( (ViewCtorProp<void,std::string> const &) prop ).value
1086  , alloc_size );
1087 
1088  // Only set the the pointer and initialize if the allocation is non-zero.
1089  // May be zero if one of the dimensions is zero.
1090  if ( alloc_size ) {
1091 
1092  m_impl_handle.set( reinterpret_cast< pointer_type >( record->data() ),
1093  m_impl_offset.span(), m_sacado_size.value );
1094 
1095  // Assume destruction is only required when construction is requested.
1096  // The ViewValueFunctor has both value construction and destruction operators.
1097  record->m_destroy = m_impl_handle.create_functor(
1098  ( (ViewCtorProp<void,execution_space> const &) prop).value
1099  , ctor_prop::initialize
1100  , m_impl_offset.span()
1101  , m_sacado_size.value );
1102 
1103  // Construct values
1104  record->m_destroy.construct_shared_allocation();
1105  }
1106 
1107  return record ;
1108  }
1109 
1110  //----------------------------------------
1111  // If the View is to construct or destroy the elements.
1112 
1113  /*
1114  template< class ExecSpace >
1115  void construct( const ExecSpace & space ) const
1116  {
1117  m_impl_handle.construct( space, m_impl_offset.span(), m_sacado_size.value );
1118  }
1119 
1120  template< class ExecSpace >
1121  void destroy( const ExecSpace & space ) const
1122  {
1123  m_impl_handle.destruct( space, m_impl_offset.span(), m_sacado_size.value );
1124  }
1125  */
1126 };
1127 
1128 } // namespace Impl
1129 } // namespace Kokkos
1130 
1131 //----------------------------------------------------------------------------
1132 
1133 namespace Kokkos {
1134 namespace Impl {
1135 
1140 template< class DstTraits , class SrcTraits >
1141 class ViewMapping< DstTraits , SrcTraits ,
1142  typename std::enable_if<(
1143  Kokkos::Impl::MemorySpaceAccess< typename DstTraits::memory_space
1144  , typename SrcTraits::memory_space >::assignable
1145  &&
1146  // Destination view has MP::Vector
1147  std::is_same< typename DstTraits::specialize
1148  , Kokkos::Experimental::Impl::ViewMPVectorContiguous >::value
1149  &&
1150  // Source view has MP::Vector only
1151  std::is_same< typename SrcTraits::specialize
1152  , Kokkos::Experimental::Impl::ViewMPVectorContiguous >::value
1153  )
1154  , typename DstTraits::specialize
1155  >::type >
1156 {
1157 public:
1158 
1159  enum { is_assignable = true };
1160  enum { is_assignable_data_type = true };
1161 
1162  typedef Kokkos::Impl::SharedAllocationTracker TrackType ;
1163  typedef ViewMapping< DstTraits , typename DstTraits::specialize > DstType ;
1164  typedef ViewMapping< SrcTraits , typename SrcTraits::specialize > SrcType ;
1165 
1166  KOKKOS_INLINE_FUNCTION static
1167  void assign( DstType & dst
1168  , const SrcType & src
1169  , const TrackType & )
1170  {
1171  static_assert(
1172  (
1173  std::is_same< typename DstTraits::array_layout
1174  , Kokkos::LayoutLeft >::value ||
1175  std::is_same< typename DstTraits::array_layout
1176  , Kokkos::LayoutRight >::value ||
1177  std::is_same< typename DstTraits::array_layout
1178  , Kokkos::LayoutStride >::value
1179  )
1180  &&
1181  (
1182  std::is_same< typename SrcTraits::array_layout
1183  , Kokkos::LayoutLeft >::value ||
1184  std::is_same< typename SrcTraits::array_layout
1185  , Kokkos::LayoutRight >::value ||
1186  std::is_same< typename SrcTraits::array_layout
1187  , Kokkos::LayoutStride >::value
1188  )
1189  , "View of MP::Vector requires LayoutLeft, LayoutRight, or LayoutStride" );
1190 
1191  static_assert(
1192  std::is_same< typename DstTraits::array_layout
1193  , typename SrcTraits::array_layout >::value ||
1194  std::is_same< typename DstTraits::array_layout
1195  , Kokkos::LayoutStride >::value ||
1196  ( unsigned(DstTraits::rank) == 0 && unsigned(SrcTraits::rank) == 0 ) ||
1197  ( unsigned(DstTraits::rank) == 1 && unsigned(SrcTraits::rank) == 1 ) ,
1198  "View assignment must have compatible layout" );
1199 
1200  static_assert(
1201  std::is_same< typename DstTraits::value_type
1202  , typename SrcTraits::value_type >::value ||
1203  std::is_same< typename DstTraits::value_type
1204  , typename SrcTraits::const_value_type >::value ,
1205  "View assignment must have same value type or const = non-const" );
1206 
1207  static_assert(
1208  ViewDimensionAssignable
1209  < typename DstType::offset_type::dimension_type
1210  , typename SrcType::offset_type::dimension_type >::value ,
1211  "View assignment must have compatible dimensions" );
1212 
1213  dst.m_impl_handle = src.m_impl_handle ;
1214  dst.m_impl_offset = src.m_impl_offset ;
1215  dst.m_stride = src.m_stride ;
1216  dst.m_sacado_size = src.m_sacado_size ;
1217  }
1218 };
1219 
1225 template< class DstTraits , class SrcTraits >
1226 class ViewMapping< DstTraits , SrcTraits ,
1227  typename std::enable_if<(
1228  Kokkos::Impl::MemorySpaceAccess< typename DstTraits::memory_space
1229  , typename SrcTraits::memory_space >::assignable
1230  &&
1231  // Destination view has ordinary
1232  std::is_same< typename DstTraits::specialize , void >::value
1233  &&
1234  // Source view has MP::Vector only
1235  std::is_same< typename SrcTraits::specialize
1236  , Kokkos::Experimental::Impl::ViewMPVectorContiguous >::value
1237  &&
1238  // Ranks match
1239  unsigned(DstTraits::dimension::rank) == unsigned(SrcTraits::dimension::rank)+1
1240  )
1241  , typename DstTraits::specialize
1242  >::type >
1243 {
1244 public:
1245 
1246  enum { is_assignable = true };
1247  enum { is_assignable_data_type = true };
1248 
1249  typedef Kokkos::Impl::SharedAllocationTracker TrackType ;
1250  typedef ViewMapping< DstTraits , typename DstTraits::specialize > DstType ;
1251  typedef ViewMapping< SrcTraits , typename SrcTraits::specialize > SrcType ;
1252 
1253  KOKKOS_INLINE_FUNCTION static
1254  void assign( DstType & dst
1255  , const SrcType & src
1256  , const TrackType & )
1257  {
1258  static_assert(
1259  (
1260  std::is_same< typename DstTraits::array_layout
1261  , Kokkos::LayoutLeft >::value ||
1262  std::is_same< typename DstTraits::array_layout
1263  , Kokkos::LayoutRight >::value ||
1264  std::is_same< typename DstTraits::array_layout
1265  , Kokkos::LayoutStride >::value
1266  )
1267  &&
1268  (
1269  std::is_same< typename SrcTraits::array_layout
1270  , Kokkos::LayoutLeft >::value ||
1271  std::is_same< typename SrcTraits::array_layout
1272  , Kokkos::LayoutRight >::value ||
1273  std::is_same< typename SrcTraits::array_layout
1274  , Kokkos::LayoutStride >::value
1275  )
1276  , "View of MP::Vector requires LayoutLeft, LayoutRight, or LayoutStride" );
1277 
1278  static_assert(
1279  std::is_same< typename DstTraits::array_layout
1280  , typename SrcTraits::array_layout >::value ||
1281  std::is_same< typename DstTraits::array_layout
1282  , Kokkos::LayoutStride >::value ,
1283  "View assignment must have compatible layout" );
1284 
1285  static_assert(
1286  std::is_same< typename DstTraits::scalar_array_type
1287  , typename SrcTraits::scalar_array_type >::value ||
1288  std::is_same< typename DstTraits::scalar_array_type
1289  , typename SrcTraits::const_scalar_array_type >::value ,
1290  "View assignment must have same value type or const = non-const" );
1291 
1292  static_assert(
1293  ViewDimensionAssignable<
1294  typename DstType::offset_type::dimension_type,
1295  typename SrcType::array_offset_type::dimension_type >::value,
1296  "View assignment must have compatible dimensions" );
1297 
1298  if ( src.m_stride != 1 ) {
1299  Kokkos::abort("\n\n ****** Kokkos::View< Sacado::MP::Vector ... > cannot assign with non-unit stride ******\n\n");
1300  }
1301 
1302  unsigned dims[8];
1303  dims[0] = src.m_impl_offset.dimension_0();
1304  dims[1] = src.m_impl_offset.dimension_1();
1305  dims[2] = src.m_impl_offset.dimension_2();
1306  dims[3] = src.m_impl_offset.dimension_3();
1307  dims[4] = src.m_impl_offset.dimension_4();
1308  dims[5] = src.m_impl_offset.dimension_5();
1309  dims[6] = src.m_impl_offset.dimension_6();
1310  dims[7] = src.m_impl_offset.dimension_7();
1311  unsigned rank = SrcTraits::dimension::rank;
1312  unsigned sacado_size = src.m_sacado_size.value;
1313  if (std::is_same<typename SrcTraits::array_layout, LayoutLeft>::value) {
1314  // Move sacado_size to the first dimension, shift all others up one
1315  for (unsigned i=rank; i>0; --i)
1316  dims[i] = dims[i-1];
1317  dims[0] = sacado_size;
1318  }
1319  else {
1320  dims[rank] = sacado_size;
1321  }
1322  typedef typename DstType::offset_type dst_offset_type;
1323  dst.m_impl_offset = dst_offset_type( std::integral_constant< unsigned , 0 >(),
1324  typename DstTraits::array_layout(
1325  dims[0] , dims[1] , dims[2] , dims[3] ,
1326  dims[4] , dims[5] , dims[6] , dims[7] ) );
1327  dst.m_impl_handle = src.m_impl_handle.scalar_ptr ;
1328  }
1329 };
1330 
1337 template< class DstTraits , class SrcTraits >
1338 class ViewMapping< DstTraits , SrcTraits ,
1339  typename std::enable_if<(
1340  Kokkos::Impl::MemorySpaceAccess< typename DstTraits::memory_space
1341  , typename SrcTraits::memory_space >::assignable
1342  &&
1343  // Destination view has ordinary
1344  std::is_same< typename DstTraits::specialize , void >::value
1345  &&
1346  // Source view has MP::Vector only
1347  std::is_same< typename SrcTraits::specialize
1348  , Kokkos::Experimental::Impl::ViewMPVectorContiguous >::value
1349  &&
1350  // Ranks match
1351  unsigned(DstTraits::dimension::rank) == unsigned(SrcTraits::dimension::rank)
1352  )
1353  , typename DstTraits::specialize
1354  >::type >
1355 {
1356 public:
1357 
1358  enum { is_assignable = true };
1359  enum { is_assignable_data_type = true };
1360 
1361  typedef Kokkos::Impl::SharedAllocationTracker TrackType ;
1362  typedef ViewMapping< DstTraits , typename DstTraits::specialize > DstType ;
1363  typedef ViewMapping< SrcTraits , typename SrcTraits::specialize > SrcType ;
1364 
1365  KOKKOS_INLINE_FUNCTION static
1366  void assign( DstType & dst
1367  , const SrcType & src
1368  , const TrackType & )
1369  {
1370  static_assert(
1371  (
1372  std::is_same< typename DstTraits::array_layout
1373  , Kokkos::LayoutLeft >::value ||
1374  std::is_same< typename DstTraits::array_layout
1375  , Kokkos::LayoutRight >::value ||
1376  std::is_same< typename DstTraits::array_layout
1377  , Kokkos::LayoutStride >::value
1378  )
1379  &&
1380  (
1381  std::is_same< typename SrcTraits::array_layout
1382  , Kokkos::LayoutLeft >::value ||
1383  std::is_same< typename SrcTraits::array_layout
1384  , Kokkos::LayoutRight >::value ||
1385  std::is_same< typename SrcTraits::array_layout
1386  , Kokkos::LayoutStride >::value
1387  )
1388  , "View of MP::Vector requires LayoutLeft, LayoutRight, or LayoutStride" );
1389 
1390  static_assert(
1391  std::is_same< typename DstTraits::array_layout
1392  , typename SrcTraits::array_layout >::value ||
1393  std::is_same< typename DstTraits::array_layout
1394  , Kokkos::LayoutStride >::value ,
1395  "View assignment must have compatible layout" );
1396 
1397  static_assert(
1398  std::is_same< typename DstTraits::value_type
1399  , typename SrcTraits::non_const_value_type::value_type >::value ||
1400  std::is_same< typename DstTraits::value_type
1401  , const typename SrcTraits::non_const_value_type::value_type >::value ,
1402  "View assignment must have same value type or const = non-const" );
1403 
1404  static_assert(
1405  ViewDimensionAssignable<
1406  typename DstType::offset_type::dimension_type,
1407  typename SrcType::offset_type::dimension_type >::value,
1408  "View assignment must have compatible dimensions" );
1409 
1410  if ( src.m_stride != 1 ) {
1411  Kokkos::abort("\n\n ****** Kokkos::View< Sacado::MP::Vector ... > cannot assign with non-unit stride ******\n\n");
1412  }
1413 
1414  unsigned dims[8];
1415  dims[0] = src.m_impl_offset.dimension_0();
1416  dims[1] = src.m_impl_offset.dimension_1();
1417  dims[2] = src.m_impl_offset.dimension_2();
1418  dims[3] = src.m_impl_offset.dimension_3();
1419  dims[4] = src.m_impl_offset.dimension_4();
1420  dims[5] = src.m_impl_offset.dimension_5();
1421  dims[6] = src.m_impl_offset.dimension_6();
1422  dims[7] = src.m_impl_offset.dimension_7();
1423  unsigned rank = SrcTraits::dimension::rank;
1424  unsigned sacado_size = src.m_sacado_size.value;
1425  if (std::is_same<typename DstTraits::array_layout, LayoutLeft>::value) {
1426  dims[0] = dims[0]*sacado_size;
1427  dims[rank] = 0;
1428  }
1429  else {
1430  dims[rank-1] = dims[rank-1]*sacado_size;
1431  dims[rank] = 0;
1432  }
1433  typedef typename DstType::offset_type dst_offset_type;
1434  dst.m_impl_offset = dst_offset_type( std::integral_constant< unsigned , 0 >(),
1435  typename DstTraits::array_layout(
1436  dims[0] , dims[1] , dims[2] , dims[3] ,
1437  dims[4] , dims[5] , dims[6] , dims[7] ) );
1438  dst.m_impl_handle = src.m_impl_handle.scalar_ptr ;
1439  }
1440 };
1441 
1442 } // namespace Impl
1443 } // namespace Kokkos
1444 
1445 //----------------------------------------------------------------------------
1446 
1447 namespace Kokkos {
1448 namespace Impl {
1449 
1450 // Subview mapping
1451 
1452 template< class DataType, class ... P , class Arg0, class ... Args >
1453 struct ViewMapping
1454  < typename std::enable_if<(
1455  // Source view has MP::Vector only
1456  std::is_same< typename Kokkos::ViewTraits<DataType,P...>::specialize
1457  , Kokkos::Experimental::Impl::ViewMPVectorContiguous >::value
1458  &&
1459  (
1460  std::is_same< typename Kokkos::ViewTraits<DataType,P...>::array_layout
1461  , Kokkos::LayoutLeft >::value ||
1462  std::is_same< typename Kokkos::ViewTraits<DataType,P...>::array_layout
1463  , Kokkos::LayoutRight >::value ||
1464  std::is_same< typename Kokkos::ViewTraits<DataType,P...>::array_layout
1465  , Kokkos::LayoutStride >::value
1466  )
1467  && !Sacado::MP::is_vector_partition<Arg0>::value
1468  )>::type
1469  , Kokkos::ViewTraits<DataType,P...>
1470  , Arg0, Args ... >
1471 {
1472 private:
1473 
1474  typedef Kokkos::ViewTraits<DataType,P...> SrcTraits;
1475 
1476  //static_assert( SrcTraits::rank == sizeof...(Args) , "" );
1477 
1478  enum
1479  { RZ = false
1480  , R0 = bool(is_integral_extent<0,Arg0,Args...>::value)
1481  , R1 = bool(is_integral_extent<1,Arg0,Args...>::value)
1482  , R2 = bool(is_integral_extent<2,Arg0,Args...>::value)
1483  , R3 = bool(is_integral_extent<3,Arg0,Args...>::value)
1484  , R4 = bool(is_integral_extent<4,Arg0,Args...>::value)
1485  , R5 = bool(is_integral_extent<5,Arg0,Args...>::value)
1486  , R6 = bool(is_integral_extent<6,Arg0,Args...>::value)
1487  };
1488 
1489  // Public rank
1490  enum { rank = unsigned(R0) + unsigned(R1) + unsigned(R2) + unsigned(R3)
1491  + unsigned(R4) + unsigned(R5) + unsigned(R6) };
1492 
1493  // Whether right-most non-MP::Vector rank is a range.
1494  enum { R0_rev = ( 0 == SrcTraits::rank ? RZ : (
1495  1 == SrcTraits::rank ? R0 : (
1496  2 == SrcTraits::rank ? R1 : (
1497  3 == SrcTraits::rank ? R2 : (
1498  4 == SrcTraits::rank ? R3 : (
1499  5 == SrcTraits::rank ? R4 : (
1500  6 == SrcTraits::rank ? R5 : R6 ))))))) };
1501 
1502  // Subview's layout
1503  typedef typename std::conditional<
1504  ( /* Same array layout IF */
1505  ( rank == 0 ) /* output rank zero */
1506  ||
1507  // OutputRank 1 or 2, InputLayout Left, Interval 0
1508  // because single stride one or second index has a stride.
1509  ( rank <= 2 && R0 && std::is_same< typename SrcTraits::array_layout , Kokkos::LayoutLeft >::value )
1510  ||
1511  // OutputRank 1 or 2, InputLayout Right, Interval [InputRank-1]
1512  // because single stride one or second index has a stride.
1513  ( rank <= 2 && R0_rev && std::is_same< typename SrcTraits::array_layout , Kokkos::LayoutRight >::value )
1514  ), typename SrcTraits::array_layout , Kokkos::LayoutStride
1516 
1518 
1519  typedef typename std::conditional< rank == 0 , sacado_mp_vector_type ,
1520  typename std::conditional< rank == 1 , sacado_mp_vector_type * ,
1521  typename std::conditional< rank == 2 , sacado_mp_vector_type ** ,
1522  typename std::conditional< rank == 3 , sacado_mp_vector_type *** ,
1523  typename std::conditional< rank == 4 , sacado_mp_vector_type **** ,
1524  typename std::conditional< rank == 5 , sacado_mp_vector_type ***** ,
1525  typename std::conditional< rank == 6 , sacado_mp_vector_type ****** ,
1526  sacado_mp_vector_type *******
1529 
1530 public:
1531 
1532  typedef Kokkos::ViewTraits
1533  < data_type
1534  , array_layout
1535  , typename SrcTraits::device_type
1536  , typename SrcTraits::memory_traits > traits_type ;
1537 
1538  typedef Kokkos::View
1539  < data_type
1540  , array_layout
1541  , typename SrcTraits::device_type
1542  , typename SrcTraits::memory_traits > type ;
1543 
1544 
1545  // The presumed type is 'ViewMapping< traits_type , void >'
1546  // However, a compatible ViewMapping is acceptable.
1547  template< class DstTraits >
1548  KOKKOS_INLINE_FUNCTION
1549  static void assign( ViewMapping< DstTraits , typename DstTraits::specialize > & dst
1550  , ViewMapping< SrcTraits , typename SrcTraits::specialize > const & src
1551  , Arg0 arg0, Args ... args )
1552  {
1553  static_assert(
1554  ViewMapping< DstTraits , traits_type , typename DstTraits::specialize >::is_assignable ,
1555  "Subview destination type must be compatible with subview derived type" );
1556 
1557  typedef ViewMapping< DstTraits , typename DstTraits::specialize > DstType ;
1558  typedef typename DstType::offset_type dst_offset_type ;
1559 
1560  const SubviewExtents< SrcTraits::rank , rank >
1561  extents( src.m_impl_offset.m_dim , arg0 , args... );
1562 
1563  const size_t offset = src.m_impl_offset( extents.domain_offset(0)
1564  , extents.domain_offset(1)
1565  , extents.domain_offset(2)
1566  , extents.domain_offset(3)
1567  , extents.domain_offset(4)
1568  , extents.domain_offset(5)
1569  , extents.domain_offset(6)
1570  , extents.domain_offset(7) );
1571 
1572  dst.m_impl_offset = dst_offset_type( src.m_impl_offset , extents );
1573  dst.m_impl_handle.value_ptr = src.m_impl_handle.value_ptr + offset;
1574  dst.m_impl_handle.scalar_ptr =
1575  src.m_impl_handle.scalar_ptr + offset * src.m_stride * src.m_sacado_size.value;
1576  dst.m_stride = src.m_stride;
1577  dst.m_sacado_size = src.m_sacado_size;
1578  }
1579 
1580 };
1581 
1582 } // namespace Impl
1583 } // namespace Kokkos
1584 
1585 //----------------------------------------------------------------------------
1586 //----------------------------------------------------------------------------
1587 //----------------------------------------------------------------------------
1588 
1589 namespace Kokkos {
1590 namespace Impl {
1591 
1592 // Partition mapping
1593 
1594 template< class DataType, class ...P, unsigned Size >
1595 class ViewMapping<
1596  void,
1597  ViewTraits<DataType,P...> ,
1598  Sacado::MP::VectorPartition<Size> >
1599 {
1600 public:
1601 
1602  enum { is_assignable = true };
1603  enum { is_assignable_data_type = true };
1604 
1605  typedef ViewTraits<DataType,P...> src_traits;
1606  typedef ViewMapping< src_traits , typename src_traits::specialize > src_type ;
1607 
1608  typedef typename src_type::offset_type::dimension_type src_dimension;
1611  typedef typename storage_type::template apply_N<Size> storage_apply;
1612  typedef typename storage_apply::type strided_storage_type;
1614  typedef typename
1615  ViewDataType< strided_value_type , src_dimension >::type strided_data_type;
1616  typedef ViewTraits<strided_data_type,P...> dst_traits;
1617  typedef View<strided_data_type,P...> type;
1618  typedef ViewMapping< dst_traits , typename dst_traits::specialize > dst_type ;
1619 
1620  KOKKOS_INLINE_FUNCTION static
1621  void assign( dst_type & dst
1622  , const src_type & src
1623  , const Sacado::MP::VectorPartition<Size> & part )
1624  {
1625  // The pointer assignments below are not sufficient for dynamically sized
1626  // scalar types, so disallow this case for now
1627  static_assert( storage_type::is_static,
1628  "For performance reasons, partitioned assignment is only implemented for statically-sized MP::Vector types" );
1629 
1630  unsigned len = part.end - part.begin;
1631  if ( Size != len || Size == 0 ) {
1632  Kokkos::abort("\n\n ****** Kokkos::View< Sacado::MP::Vector ... > Invalid size in partitioned view assignment ******\n\n");
1633  }
1634 
1635  dst.m_impl_handle.value_ptr =
1636  reinterpret_cast<strided_value_type*>( src.m_impl_handle.value_ptr ) +
1637  part.begin / len ;
1638  dst.m_impl_handle.scalar_ptr = src.m_impl_handle.scalar_ptr +
1639  (part.begin / len) * src.m_stride * src.m_sacado_size.value ;
1640  dst.m_impl_offset = src.m_impl_offset ;
1641  dst.m_stride = src.m_stride * src.m_sacado_size.value / Size ;
1642  dst.m_sacado_size = len ;
1643  }
1644 };
1645 
1646 } // namespace Impl
1647 } // namespace Kokkos
1648 
1649 namespace Kokkos {
1650 
1651 template< unsigned Size, typename D, typename ... P >
1652 KOKKOS_INLINE_FUNCTION
1653 typename Kokkos::Impl::ViewMapping< void, typename Kokkos::ViewTraits<D,P...>, Sacado::MP::VectorPartition<Size> >::type
1654 partition( const Kokkos::View<D,P...> & src ,
1655  const unsigned beg )
1656 {
1657  typedef Kokkos::ViewTraits<D,P...> traits;
1658  typedef typename Kokkos::Impl::ViewMapping< void, traits, Sacado::MP::VectorPartition<Size> >::type DstViewType;
1659  const Sacado::MP::VectorPartition<Size> part( beg , beg+Size );
1660  return DstViewType(src, part);
1661 }
1662 
1663 } // namespace Kokkos
1664 
1665 //----------------------------------------------------------------------------
1666 //----------------------------------------------------------------------------
1667 //----------------------------------------------------------------------------
1668 
1669 namespace Kokkos {
1670 namespace Impl {
1671 
1672 // Specialization for deep_copy( view, view::value_type ) for Cuda
1673 #if defined( KOKKOS_ENABLE_CUDA )
1674 template< class OutputView >
1675 struct StokhosViewFill< OutputView ,
1676  typename std::enable_if< std::is_same< typename OutputView::specialize,
1677  Kokkos::Experimental::Impl::ViewMPVectorContiguous >::value &&
1678  std::is_same< typename OutputView::execution_space,
1679  Cuda >::value >::type >
1680 {
1681  typedef typename OutputView::const_value_type const_value_type ;
1682  typedef typename OutputView::execution_space execution_space ;
1683  typedef typename OutputView::size_type size_type ;
1684 
1685  template <unsigned VectorLength>
1686  struct Kernel {
1687  typedef typename OutputView::execution_space execution_space ;
1688  const OutputView output;
1689  const_value_type input;
1690 
1691  Kernel( const OutputView & arg_out , const_value_type & arg_in ) :
1692  output(arg_out), input(arg_in) {}
1693 
1694  typedef typename Kokkos::TeamPolicy< execution_space >::member_type team_member ;
1695 
1696  KOKKOS_INLINE_FUNCTION
1697  void operator()( const team_member & dev ) const
1698  {
1699  const size_type tidx = dev.team_rank() % VectorLength;
1700  const size_type tidy = dev.team_rank() / VectorLength;
1701  const size_type nrow = dev.team_size() / VectorLength;
1702  const size_type nvec = dimension_scalar(output);
1703 
1704  const size_type i0 = dev.league_rank() * nrow + tidy;
1705  if ( i0 >= output.extent(0) ) return;
1706 
1707  for ( size_type i1 = 0 ; i1 < output.extent(1) ; ++i1 ) {
1708  for ( size_type i2 = 0 ; i2 < output.extent(2) ; ++i2 ) {
1709  for ( size_type i3 = 0 ; i3 < output.extent(3) ; ++i3 ) {
1710  for ( size_type i4 = 0 ; i4 < output.extent(4) ; ++i4 ) {
1711  for ( size_type i5 = 0 ; i5 < output.extent(5) ; ++i5 ) {
1712  for ( size_type i6 = 0 ; i6 < output.extent(6) ; ++i6 ) {
1713  for ( size_type i7 = 0 ; i7 < output.extent(7) ; ++i7 ) {
1714  for ( size_type is = tidx ; is < nvec ; is+=VectorLength ) {
1715  output.access(i0,i1,i2,i3,i4,i5,i6,i7).fastAccessCoeff(is) =
1716  input.fastAccessCoeff(is) ;
1717  }}}}}}}}
1718  }
1719  };
1720 
1721  StokhosViewFill( const OutputView & output , const_value_type & input )
1722  {
1723  if ( Sacado::is_constant(input) ) {
1724  deep_copy( output , input.fastAccessCoeff(0) );
1725  }
1726  else {
1727 
1728  // Coalesced accesses are 128 bytes in size
1730  const unsigned vector_length =
1731  ( 128 + sizeof(scalar_type)-1 ) / sizeof(scalar_type);
1732 
1733  // 8 warps per block should give good occupancy
1734  const size_type block_size = 256;
1735 
1736  const size_type rows_per_block = block_size / vector_length;
1737  const size_type n = output.extent(0);
1738  const size_type league_size = ( n + rows_per_block-1 ) / rows_per_block;
1739  const size_type team_size = rows_per_block * vector_length;
1740  Kokkos::TeamPolicy< execution_space > config( league_size, team_size );
1741 
1742  parallel_for( config, Kernel<vector_length>(output, input) );
1743  execution_space().fence();
1744  }
1745  }
1746 
1747 };
1748 #endif /* #if defined( KOKKOS_ENABLE_CUDA ) */
1749 
1750 } // namespace Impl
1751 } // namespace Kokkos
1752 
1753 //----------------------------------------------------------------------------
1754 //----------------------------------------------------------------------------
1755 //----------------------------------------------------------------------------
1756 
1757 namespace Kokkos {
1758 namespace Impl {
1759 
1760 struct ViewSpecializeSacadoFad;
1761 
1768 template< class DstTraits , class SrcTraits >
1769 class ViewMapping< DstTraits , SrcTraits ,
1770  typename std::enable_if<(
1771  Kokkos::Impl::MemorySpaceAccess< typename DstTraits::memory_space
1772  , typename SrcTraits::memory_space >::assignable
1773  &&
1774  // Destination view has MP::Vector only
1775  std::is_same< typename DstTraits::specialize
1776  , Kokkos::Experimental::Impl::ViewMPVectorContiguous >::value
1777  &&
1778  // Source view has FAD only
1779  std::is_same< typename SrcTraits::specialize
1780  , ViewSpecializeSacadoFad >::value
1781  )
1782  , typename DstTraits::specialize
1783  >::type >
1784 {
1785 public:
1786 
1787  enum { is_assignable = true };
1788  enum { is_assignable_data_type = true };
1789 
1790  typedef Kokkos::Impl::SharedAllocationTracker TrackType ;
1791  typedef ViewMapping< DstTraits , typename DstTraits::specialize > DstType ;
1792  typedef ViewMapping< SrcTraits , typename SrcTraits::specialize > SrcFadType ;
1793 
1794  template< class DstType >
1795  KOKKOS_INLINE_FUNCTION static
1796  void assign( DstType & dst
1797  , const SrcFadType & src
1798  , const TrackType & )
1799  {
1800  static_assert(
1801  (
1802  std::is_same< typename DstTraits::array_layout
1803  , Kokkos::LayoutLeft >::value ||
1804  std::is_same< typename DstTraits::array_layout
1805  , Kokkos::LayoutRight >::value ||
1806  std::is_same< typename DstTraits::array_layout
1807  , Kokkos::LayoutStride >::value
1808  )
1809  &&
1810  (
1811  std::is_same< typename SrcTraits::array_layout
1812  , Kokkos::LayoutLeft >::value ||
1813  std::is_same< typename SrcTraits::array_layout
1814  , Kokkos::LayoutRight >::value ||
1815  std::is_same< typename SrcTraits::array_layout
1816  , Kokkos::LayoutStride >::value
1817  )
1818  , "View of FAD requires LayoutLeft, LayoutRight, or LayoutStride" );
1819 
1820  static_assert(
1821  std::is_same< typename DstTraits::array_layout
1822  , typename SrcTraits::array_layout >::value ||
1823  std::is_same< typename DstTraits::array_layout
1824  , Kokkos::LayoutStride >::value ,
1825  "View assignment must have compatible layout" );
1826 
1827  static_assert(
1828  std::is_same< typename DstTraits::data_type
1829  , typename SrcTraits::scalar_array_type >::value ||
1830  std::is_same< typename DstTraits::data_type
1831  , typename SrcTraits::const_scalar_array_type >::value ,
1832  "View assignment must have same value type or const = non-const" );
1833 
1834  static_assert(
1835  ViewDimensionAssignable
1836  < typename DstType::offset_type::dimension_type
1837  , typename SrcFadType::array_offset_type::dimension_type >::value ,
1838  "View assignment must have compatible dimensions" );
1839 
1840  typedef typename DstType::offset_type dst_offset_type ;
1841 
1842  dst.m_impl_offset = dst_offset_type( src.m_array_offset );
1843  dst.m_impl_handle.assign(src.m_impl_handle) ;
1844  dst.m_stride = 1;
1845 
1846  // Don't need to set dst.m_sacado_size since it is determined statically
1847  static_assert( DstType::is_static,
1848  "Destination view must be statically allocated" );
1849  }
1850 };
1851 
1852 } // namespace Impl
1853 } // namespace Kokkos
1854 
1855 //----------------------------------------------------------------------------
1856 //----------------------------------------------------------------------------
1857 //----------------------------------------------------------------------------
1858 
1859 #include "Kokkos_View_Utils_Def.hpp"
1860 
1861 #endif /* #ifndef KOKKOS_EXPERIMENTAL_VIEW_MP_VECTOR_CONTIGUOUS_HPP */
KOKKOS_INLINE_FUNCTION MPVectorAllocation & operator=(const MPVectorAllocation< T, true > &a)
Stokhos::StandardStorage< int, double > storage_type
static KOKKOS_INLINE_FUNCTION constexpr size_t memory_span(const size_t span, const unsigned vector_size)
KOKKOS_INLINE_FUNCTION MPVectorAllocation & operator=(const MPVectorAllocation< T, false > &a)
Kokkos::DefaultExecutionSpace execution_space
std::conditional< std::is_same< ArrayLayout, Kokkos::LayoutLeft >::value, prepend_scalar_dimension, append_scalar_dimension >::type scalar_dimension
ConstructDestructFunctor< ExecSpace > create_functor(const ExecSpace &space, const bool initialize, const size_t span, const unsigned vector_size) const
KOKKOS_INLINE_FUNCTION void set(value_type *ptr, const size_t span, const unsigned vector_size)
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< View< T, P...> >::value, unsigned >::type dimension_scalar(const View< T, P...> &view)
std::conditional< rank==0, sacado_mp_vector_type, typename std::conditional< rank==1, sacado_mp_vector_type *, typename std::conditional< rank==2, sacado_mp_vector_type **, typename std::conditional< rank==3, sacado_mp_vector_type ***, typename std::conditional< rank==4, sacado_mp_vector_type ****, typename std::conditional< rank==5, sacado_mp_vector_type *****, typename std::conditional< rank==6, sacado_mp_vector_type ******, sacado_mp_vector_type ******* >::type >::type >::type >::type >::type >::type >::type data_type
KOKKOS_INLINE_FUNCTION void set(value_type *ptr, const size_t span, const unsigned vector_size)
VectorConstruct(const ExecSpace &space, value_type *p, scalar_type *sp, const size_t span, const unsigned vector_size)
static KOKKOS_INLINE_FUNCTION constexpr size_t memory_span(const size_t span, const unsigned vector_size)
KOKKOS_INLINE_FUNCTION bool is_constant(const T &x)
void deep_copy(const Stokhos::CrsMatrix< ValueType, DstDevice, Layout > &dst, const Stokhos::CrsMatrix< ValueType, SrcDevice, Layout > &src)
ConstructDestructFunctor(const ExecSpace &space, const bool initialize, const size_t span, const unsigned vector_size, scalar_type *scalar_ptr, value_type *value_ptr)
ConstructDestructFunctor< ExecSpace > create_functor(const ExecSpace &space, const bool initialize, const size_t span, const unsigned vector_size) const
KOKKOS_INLINE_FUNCTION Kokkos::Impl::ViewMapping< void, typename Kokkos::ViewTraits< D, P...>, Sacado::MP::VectorPartition< Size > >::type partition(const Kokkos::View< D, P...> &src, const unsigned beg)
ConstructDestructFunctor(const ExecSpace &space, const bool initialize, const size_t span, const unsigned vector_size, scalar_type *scalar_ptr)
static KOKKOS_INLINE_FUNCTION void assign(dst_type &dst, const src_type &src, const Sacado::MP::VectorPartition< Size > &part)
Stokhos::CrsMatrix< ValueType, Device, Layout >::HostMirror create_mirror(const Stokhos::CrsMatrix< ValueType, Device, Layout > &A)
int n