10 #ifndef KOKKOS_DYN_RANK_VIEW_SACADO_FAD_CONTIGUOUS_HPP
11 #define KOKKOS_DYN_RANK_VIEW_SACADO_FAD_CONTIGUOUS_HPP
18 #if defined(HAVE_SACADO_KOKKOS)
20 #include "Kokkos_DynRankView.hpp"
22 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
30 struct DynRankDimTraits<Kokkos::Impl::ViewSpecializeSacadoFadContiguous> {
32 enum :
size_t{unspecified = ~size_t(0)};
36 KOKKOS_INLINE_FUNCTION
37 static size_t computeRank(
const size_t N0
47 ( (N7 == unspecified && N6 == unspecified && N5 == unspecified && N4 == unspecified && N3 == unspecified && N2 == unspecified && N1 == unspecified && N0 == unspecified) ? 0
48 : ( (N7 == unspecified && N6 == unspecified && N5 == unspecified && N4 == unspecified && N3 == unspecified && N2 == unspecified && N1 == unspecified) ? 0
49 : ( (N7 == unspecified && N6 == unspecified && N5 == unspecified && N4 == unspecified && N3 == unspecified && N2 == unspecified) ? 1
50 : ( (N7 == unspecified && N6 == unspecified && N5 == unspecified && N4 == unspecified && N3 == unspecified) ? 2
51 : ( (N7 == unspecified && N6 == unspecified && N5 == unspecified && N4 == unspecified) ? 3
52 : ( (N7 == unspecified && N6 == unspecified && N5 == unspecified) ? 4
53 : ( (N7 == unspecified && N6 == unspecified) ? 5
54 : ( (N7 == unspecified) ? 6
59 template <
typename Layout>
60 KOKKOS_INLINE_FUNCTION
61 static size_t computeRank(
const Layout& layout )
63 return computeRank( layout.dimension[0]
70 , layout.dimension[7] );
74 template <
typename Layout,
typename ... P>
75 KOKKOS_INLINE_FUNCTION
76 static size_t computeRank(
const ViewCtorProp<P...>& prop,
const Layout& layout )
78 size_t rank = computeRank( layout.dimension[0]
85 , layout.dimension[7] );
88 enum { test_traits_check = Kokkos::Impl::check_has_common_view_alloc_prop< P... >
::value };
89 return (test_traits_check ==
true) ? rank+1 : rank;
95 template <
typename Layout>
96 KOKKOS_INLINE_FUNCTION
99 Layout l( layout.dimension[0] != unspecified ? layout.dimension[0] : 1
100 , layout.dimension[1] != unspecified ? layout.dimension[1] : 1
101 , layout.dimension[2] != unspecified ? layout.dimension[2] : 1
102 , layout.dimension[3] != unspecified ? layout.dimension[3] : 1
103 , layout.dimension[4] != unspecified ? layout.dimension[4] : 1
104 , layout.dimension[5] != unspecified ? layout.dimension[5] : 1
105 , layout.dimension[6] != unspecified ? layout.dimension[6] : 1
106 , layout.dimension[7] != unspecified ? layout.dimension[7] : 1 );
107 const unsigned fad_dim = computeRank(layout);
108 const size_t fad_size = layout.dimension[
fad_dim];
110 l.dimension[7] = fad_size;
116 template <
typename Layout>
117 KOKKOS_INLINE_FUNCTION
120 Layout l( layout.dimension[0] != unspecified ? layout.dimension[0] : 1
122 , layout.dimension[1] != unspecified ? layout.dimension[1] : 1
124 , layout.dimension[2] != unspecified ? layout.dimension[2] : 1
126 , layout.dimension[3] != unspecified ? layout.dimension[3] : 1
128 , layout.dimension[4] != unspecified ? layout.dimension[4] : 1
130 , layout.dimension[5] != unspecified ? layout.dimension[5] : 1
132 , layout.dimension[6] != unspecified ? layout.dimension[6] : 1
134 , layout.dimension[7] != unspecified ? layout.dimension[7] : 1
137 const unsigned fad_dim = computeRank(layout);
138 const size_t fad_size = layout.dimension[
fad_dim];
140 l.dimension[7] = fad_size;
147 template <
typename Traits,
typename ... P>
148 KOKKOS_INLINE_FUNCTION
151 using Layout =
typename Traits::array_layout;
153 Layout l( layout.dimension[0] != unspecified ? layout.dimension[0] : 1
154 , layout.dimension[1] != unspecified ? layout.dimension[1] : 1
155 , layout.dimension[2] != unspecified ? layout.dimension[2] : 1
156 , layout.dimension[3] != unspecified ? layout.dimension[3] : 1
157 , layout.dimension[4] != unspecified ? layout.dimension[4] : 1
158 , layout.dimension[5] != unspecified ? layout.dimension[5] : 1
159 , layout.dimension[6] != unspecified ? layout.dimension[6] : 1
160 , layout.dimension[7] != unspecified ? layout.dimension[7] : 1 );
162 enum { test_traits_check = Kokkos::Impl::check_has_common_view_alloc_prop< P... >
::value };
163 if (test_traits_check ==
true) {
164 l.dimension[7] = compute_fad_dim_from_alloc_prop<P...>::eval(arg_prop);
167 const unsigned fad_dim = computeRank(layout);
168 const size_t fad_size = layout.dimension[
fad_dim];
170 l.dimension[7] = fad_size;
178 template <
typename Traits,
typename ... P>
179 KOKKOS_INLINE_FUNCTION
182 using Layout =
typename Traits::array_layout;
184 Layout l( layout.dimension[0] != unspecified ? layout.dimension[0] : 1
186 , layout.dimension[1] != unspecified ? layout.dimension[1] : 1
188 , layout.dimension[2] != unspecified ? layout.dimension[2] : 1
190 , layout.dimension[3] != unspecified ? layout.dimension[3] : 1
192 , layout.dimension[4] != unspecified ? layout.dimension[4] : 1
194 , layout.dimension[5] != unspecified ? layout.dimension[5] : 1
196 , layout.dimension[6] != unspecified ? layout.dimension[6] : 1
198 , layout.dimension[7] != unspecified ? layout.dimension[7] : 1
202 enum { test_traits_check = Kokkos::Impl::check_has_common_view_alloc_prop< P... >
::value };
203 if (test_traits_check ==
true) {
204 l.dimension[7] = compute_fad_dim_from_alloc_prop<P...>::eval(arg_prop);
207 const unsigned fad_dim = computeRank(layout);
208 const size_t fad_size = layout.dimension[
fad_dim];
210 l.dimension[7] = fad_size;
219 template <
typename ViewType,
typename ViewArg>
220 static ViewType createView(
const ViewArg& arg
230 typename ViewType::array_layout l( N0, N1, N2, N3, N4, N5, N6, N7 );
231 typename ViewType::array_layout l_fad = createLayout(l);
240 , l_fad.dimension[7] );
252 template<
class SrcTraits ,
class ... Args >
254 < typename std::enable_if<(
255 std::is_same< typename SrcTraits::specialize ,
256 Kokkos::Impl::ViewSpecializeSacadoFadContiguous >::value
259 std::is_same< typename SrcTraits::array_layout
260 , Kokkos::LayoutRight >::value ||
261 std::is_same< typename SrcTraits::array_layout
262 , Kokkos::LayoutStride >::value
264 ), Kokkos::Impl::DynRankSubviewTag >::type
281 enum { rank = unsigned(R0) + unsigned(R1) + unsigned(R2) + unsigned(R3)
282 + unsigned(R4) + unsigned(R5) + unsigned(R6) };
286 typedef typename SrcTraits::value_type value_type ;
288 typedef value_type******* data_type ;
292 typedef Kokkos::ViewTraits
295 ,
typename SrcTraits::device_type
296 ,
typename SrcTraits::memory_traits > traits_type ;
301 ,
typename SrcTraits::device_type
302 ,
typename SrcTraits::memory_traits > type ;
305 template<
class MemoryTraits >
310 typedef Kokkos::ViewTraits
313 ,
typename SrcTraits::device_type
314 , MemoryTraits > traits_type ;
319 ,
typename SrcTraits::device_type
320 , MemoryTraits > type ;
323 template <
class Arg0 =
int,
class Arg1 =
int,
class Arg2 =
int,
class Arg3 =
int,
class Arg4 =
int,
class Arg5 =
int,
class Arg6 =
int >
324 struct ExtentGenerator {
325 template <
typename dimension>
326 KOKKOS_INLINE_FUNCTION
327 static SubviewExtents< 7 , rank > generator (
const dimension & dim , Arg0 arg0 = Arg0(), Arg1 arg1 = Arg1(), Arg2 arg2 = Arg2(), Arg3 arg3 = Arg3(), Arg4 arg4 = Arg4(), Arg5 arg5 = Arg5(), Arg6 arg6 = Arg6() )
329 return SubviewExtents< 7 , rank >( dim , arg0 , arg1 , arg2 , arg3 ,
330 arg4 , arg5 , arg6 );
334 template <
class Arg0 =
int,
class Arg1 =
int,
class Arg2 =
int,
class Arg3 =
int,
class Arg4 =
int,
class Arg5 =
int,
class Arg6 =
int >
335 struct ArrayExtentGenerator {
336 template <
typename dimension>
337 KOKKOS_INLINE_FUNCTION
338 static SubviewExtents< 8 , rank+1 > generator (
const dimension & dim , Arg0 arg0 = Arg0(), Arg1 arg1 = Arg1(), Arg2 arg2 = Arg2(), Arg3 arg3 = Arg3(), Arg4 arg4 = Arg4(), Arg5 arg5 = Arg5(), Arg6 arg6 = Arg6() )
340 return SubviewExtents< 8 , rank+1 >( dim , arg0 , arg1 , arg2 , arg3 ,
341 arg4 , arg5 , arg6 , Kokkos::ALL() );
345 typedef DynRankView< value_type , array_layout , typename SrcTraits::device_type , typename SrcTraits::memory_traits > ret_type;
347 template <
typename T ,
class ... P >
348 KOKKOS_INLINE_FUNCTION
349 static ret_type subview(
const unsigned src_rank , Kokkos::DynRankView< T , P...>
const & src , Args ... args )
352 typedef ViewMapping< traits_type, typename traits_type::specialize > DstType ;
353 typedef typename std::conditional< (rank==0) , ViewDimension<>
354 ,
typename std::conditional< (rank==1) , ViewDimension<0>
355 ,
typename std::conditional< (rank==2) , ViewDimension<0,0>
356 ,
typename std::conditional< (rank==3) , ViewDimension<0,0,0>
357 ,
typename std::conditional< (rank==4) , ViewDimension<0,0,0,0>
358 ,
typename std::conditional< (rank==5) , ViewDimension<0,0,0,0,0>
359 ,
typename std::conditional< (rank==6) , ViewDimension<0,0,0,0,0,0>
360 , ViewDimension<0,0,0,0,0,0,0>
361 >::type >::type >::type >::type >::type >::type >::type DstDimType ;
362 typedef typename std::conditional< (rank==0) , ViewDimension<0>
363 ,
typename std::conditional< (rank==1) , ViewDimension<0,0>
364 ,
typename std::conditional< (rank==2) , ViewDimension<0,0,0>
365 ,
typename std::conditional< (rank==3) , ViewDimension<0,0,0,0>
366 ,
typename std::conditional< (rank==4) , ViewDimension<0,0,0,0,0>
367 ,
typename std::conditional< (rank==5) , ViewDimension<0,0,0,0,0,0>
368 ,
typename std::conditional< (rank==6) , ViewDimension<0,0,0,0,0,0,0>
369 , ViewDimension<0,0,0,0,0,0,0,0>
370 >::type >::type >::type >::type >::type >::type >::type DstArrayDimType ;
372 typedef ViewOffset< DstDimType , Kokkos::LayoutStride > dst_offset_type ;
373 typedef ViewOffset< DstArrayDimType , Kokkos::LayoutStride > dst_array_offset_type ;
374 typedef typename DstType::handle_type dst_handle_type ;
378 const SubviewExtents< 7 , rank > extents =
379 ExtentGenerator< Args ... >::generator(
380 src.m_map.m_impl_offset.m_dim , args... ) ;
381 const SubviewExtents< 8 , rank+1 > array_extents =
382 ArrayExtentGenerator< Args ... >::generator(
383 src.m_map.m_array_offset.m_dim , args... ) ;
385 dst_offset_type tempdst( src.m_map.m_impl_offset , extents ) ;
386 dst_array_offset_type temparraydst(
387 src.m_map.m_array_offset , array_extents ) ;
389 dst.m_track = src.m_track ;
391 dst.m_map.m_impl_offset.m_dim.N0 = tempdst.m_dim.N0 ;
392 dst.m_map.m_impl_offset.m_dim.N1 = tempdst.m_dim.N1 ;
393 dst.m_map.m_impl_offset.m_dim.N2 = tempdst.m_dim.N2 ;
394 dst.m_map.m_impl_offset.m_dim.N3 = tempdst.m_dim.N3 ;
395 dst.m_map.m_impl_offset.m_dim.N4 = tempdst.m_dim.N4 ;
396 dst.m_map.m_impl_offset.m_dim.N5 = tempdst.m_dim.N5 ;
397 dst.m_map.m_impl_offset.m_dim.N6 = tempdst.m_dim.N6 ;
399 dst.m_map.m_impl_offset.m_stride.S0 = tempdst.m_stride.S0;
400 dst.m_map.m_impl_offset.m_stride.S1 = tempdst.m_stride.S1;
401 dst.m_map.m_impl_offset.m_stride.S2 = tempdst.m_stride.S2;
402 dst.m_map.m_impl_offset.m_stride.S3 = tempdst.m_stride.S3;
403 dst.m_map.m_impl_offset.m_stride.S4 = tempdst.m_stride.S4;
404 dst.m_map.m_impl_offset.m_stride.S5 = tempdst.m_stride.S5;
405 dst.m_map.m_impl_offset.m_stride.S6 = tempdst.m_stride.S6;
414 AssignFadDimStride<rank,0>::eval( dst.m_map.m_array_offset, temparraydst );
416 dst.m_track = src.m_track ;
418 dst.m_map.m_impl_handle =
420 src.m_map.m_impl_handle +
421 src.m_map.m_array_offset( array_extents.domain_offset(0)
422 , array_extents.domain_offset(1)
423 , array_extents.domain_offset(2)
424 , array_extents.domain_offset(3)
425 , array_extents.domain_offset(4)
426 , array_extents.domain_offset(5)
427 , array_extents.domain_offset(6)
428 , array_extents.domain_offset(7)
431 dst.m_map.m_fad_size = src.m_map.m_fad_size;
432 dst.m_map.m_original_fad_size = src.m_map.m_original_fad_size;
433 dst.m_map.m_fad_stride = src.m_map.m_fad_stride;
434 dst.m_map.m_fad_index = src.m_map.m_fad_index;
436 dst.m_rank = ( src_rank > 0 ? unsigned(R0) : 0 )
437 + ( src_rank > 1 ? unsigned(R1) : 0 )
438 + ( src_rank > 2 ? unsigned(R2) : 0 )
439 + ( src_rank > 3 ? unsigned(R3) : 0 )
440 + ( src_rank > 4 ? unsigned(R4) : 0 )
441 + ( src_rank > 5 ? unsigned(R5) : 0 )
442 + ( src_rank > 6 ? unsigned(R6) : 0 ) ;
448 template<
class SrcTraits ,
class ... Args >
450 < typename std::enable_if<(
451 std::is_same< typename SrcTraits::specialize ,
452 Kokkos::Impl::ViewSpecializeSacadoFadContiguous >::value
454 std::is_same< typename SrcTraits::array_layout
455 , Kokkos::LayoutLeft >::value
456 ), Kokkos::Impl::DynRankSubviewTag >::type
473 enum { rank = unsigned(R0) + unsigned(R1) + unsigned(R2) + unsigned(R3)
474 + unsigned(R4) + unsigned(R5) + unsigned(R6) };
478 typedef typename SrcTraits::value_type value_type ;
480 typedef value_type******* data_type ;
484 typedef Kokkos::ViewTraits
487 ,
typename SrcTraits::device_type
488 ,
typename SrcTraits::memory_traits > traits_type ;
493 ,
typename SrcTraits::device_type
494 ,
typename SrcTraits::memory_traits > type ;
497 template<
class MemoryTraits >
502 typedef Kokkos::ViewTraits
505 ,
typename SrcTraits::device_type
506 , MemoryTraits > traits_type ;
511 ,
typename SrcTraits::device_type
512 , MemoryTraits > type ;
515 template <
class Arg0 =
int,
class Arg1 =
int,
class Arg2 =
int,
class Arg3 =
int,
class Arg4 =
int,
class Arg5 =
int,
class Arg6 =
int >
516 struct ExtentGenerator {
517 template <
typename dimension>
518 KOKKOS_INLINE_FUNCTION
519 static SubviewExtents< 7 , rank > generator (
const dimension & dim , Arg0 arg0 = Arg0(), Arg1 arg1 = Arg1(), Arg2 arg2 = Arg2(), Arg3 arg3 = Arg3(), Arg4 arg4 = Arg4(), Arg5 arg5 = Arg5(), Arg6 arg6 = Arg6() )
521 return SubviewExtents< 7 , rank >( dim , arg0 , arg1 , arg2 , arg3 ,
522 arg4 , arg5 , arg6 );
526 template <
class Arg0 =
int,
class Arg1 =
int,
class Arg2 =
int,
class Arg3 =
int,
class Arg4 =
int,
class Arg5 =
int,
class Arg6 =
int >
527 struct ArrayExtentGenerator {
528 template <
typename dimension>
529 KOKKOS_INLINE_FUNCTION
530 static SubviewExtents< 8 , rank+1 > generator (
const dimension & dim , Arg0 arg0 = Arg0(), Arg1 arg1 = Arg1(), Arg2 arg2 = Arg2(), Arg3 arg3 = Arg3(), Arg4 arg4 = Arg4(), Arg5 arg5 = Arg5(), Arg6 arg6 = Arg6() )
532 return SubviewExtents< 8 , rank+1 >( dim , Kokkos::ALL() , arg0 , arg1 ,
533 arg2 , arg3 , arg4 , arg5 , arg6 );
537 typedef DynRankView< value_type , array_layout , typename SrcTraits::device_type , typename SrcTraits::memory_traits > ret_type;
539 template <
typename T ,
class ... P >
540 KOKKOS_INLINE_FUNCTION
541 static ret_type subview(
const unsigned src_rank , Kokkos::DynRankView< T , P...>
const & src , Args ... args )
544 typedef ViewMapping< traits_type, typename traits_type::specialize > DstType ;
545 typedef typename std::conditional< (rank==0) , ViewDimension<>
546 ,
typename std::conditional< (rank==1) , ViewDimension<0>
547 ,
typename std::conditional< (rank==2) , ViewDimension<0,0>
548 ,
typename std::conditional< (rank==3) , ViewDimension<0,0,0>
549 ,
typename std::conditional< (rank==4) , ViewDimension<0,0,0,0>
550 ,
typename std::conditional< (rank==5) , ViewDimension<0,0,0,0,0>
551 ,
typename std::conditional< (rank==6) , ViewDimension<0,0,0,0,0,0>
552 , ViewDimension<0,0,0,0,0,0,0>
553 >::type >::type >::type >::type >::type >::type >::type DstDimType ;
554 typedef typename std::conditional< (rank==0) , ViewDimension<0>
555 ,
typename std::conditional< (rank==1) , ViewDimension<0,0>
556 ,
typename std::conditional< (rank==2) , ViewDimension<0,0,0>
557 ,
typename std::conditional< (rank==3) , ViewDimension<0,0,0,0>
558 ,
typename std::conditional< (rank==4) , ViewDimension<0,0,0,0,0>
559 ,
typename std::conditional< (rank==5) , ViewDimension<0,0,0,0,0,0>
560 ,
typename std::conditional< (rank==6) , ViewDimension<0,0,0,0,0,0,0>
561 , ViewDimension<0,0,0,0,0,0,0,0>
562 >::type >::type >::type >::type >::type >::type >::type DstArrayDimType ;
564 typedef ViewOffset< DstDimType , Kokkos::LayoutStride > dst_offset_type ;
565 typedef ViewOffset< DstArrayDimType , Kokkos::LayoutStride > dst_array_offset_type ;
566 typedef typename DstType::handle_type dst_handle_type ;
570 const SubviewExtents< 7 , rank > extents =
571 ExtentGenerator< Args ... >::generator(
572 src.m_map.m_impl_offset.m_dim , args... ) ;
573 const SubviewExtents< 8 , rank+1 > array_extents =
574 ArrayExtentGenerator< Args ... >::generator(
575 src.m_map.m_array_offset.m_dim , args... ) ;
577 dst_offset_type tempdst( src.m_map.m_impl_offset , extents ) ;
578 dst_array_offset_type temparraydst(
579 src.m_map.m_array_offset , array_extents ) ;
581 dst.m_track = src.m_track ;
583 dst.m_map.m_impl_offset.m_dim.N0 = tempdst.m_dim.N0 ;
584 dst.m_map.m_impl_offset.m_dim.N1 = tempdst.m_dim.N1 ;
585 dst.m_map.m_impl_offset.m_dim.N2 = tempdst.m_dim.N2 ;
586 dst.m_map.m_impl_offset.m_dim.N3 = tempdst.m_dim.N3 ;
587 dst.m_map.m_impl_offset.m_dim.N4 = tempdst.m_dim.N4 ;
588 dst.m_map.m_impl_offset.m_dim.N5 = tempdst.m_dim.N5 ;
589 dst.m_map.m_impl_offset.m_dim.N6 = tempdst.m_dim.N6 ;
591 dst.m_map.m_impl_offset.m_stride.S0 = tempdst.m_stride.S0;
592 dst.m_map.m_impl_offset.m_stride.S1 = tempdst.m_stride.S1;
593 dst.m_map.m_impl_offset.m_stride.S2 = tempdst.m_stride.S2;
594 dst.m_map.m_impl_offset.m_stride.S3 = tempdst.m_stride.S3;
595 dst.m_map.m_impl_offset.m_stride.S4 = tempdst.m_stride.S4;
596 dst.m_map.m_impl_offset.m_stride.S5 = tempdst.m_stride.S5;
597 dst.m_map.m_impl_offset.m_stride.S6 = tempdst.m_stride.S6;
603 dst.m_map.m_array_offset.m_dim.N0 = temparraydst.m_dim.N1 ;
604 dst.m_map.m_array_offset.m_dim.N1 = temparraydst.m_dim.N2 ;
605 dst.m_map.m_array_offset.m_dim.N2 = temparraydst.m_dim.N3 ;
606 dst.m_map.m_array_offset.m_dim.N3 = temparraydst.m_dim.N4 ;
607 dst.m_map.m_array_offset.m_dim.N4 = temparraydst.m_dim.N5 ;
608 dst.m_map.m_array_offset.m_dim.N5 = temparraydst.m_dim.N6 ;
609 dst.m_map.m_array_offset.m_dim.N6 = temparraydst.m_dim.N7 ;
610 dst.m_map.m_array_offset.m_dim.N7 = temparraydst.m_dim.N0 ;
612 dst.m_map.m_array_offset.m_stride.S0 = temparraydst.m_stride.S1;
613 dst.m_map.m_array_offset.m_stride.S1 = temparraydst.m_stride.S2;
614 dst.m_map.m_array_offset.m_stride.S2 = temparraydst.m_stride.S3;
615 dst.m_map.m_array_offset.m_stride.S3 = temparraydst.m_stride.S4;
616 dst.m_map.m_array_offset.m_stride.S4 = temparraydst.m_stride.S5;
617 dst.m_map.m_array_offset.m_stride.S5 = temparraydst.m_stride.S6;
618 dst.m_map.m_array_offset.m_stride.S6 = temparraydst.m_stride.S7;
619 dst.m_map.m_array_offset.m_stride.S7 = temparraydst.m_stride.S0;
621 dst.m_track = src.m_track ;
623 dst.m_map.m_impl_handle =
625 src.m_map.m_impl_handle +
626 src.m_map.m_array_offset( array_extents.domain_offset(0)
627 , array_extents.domain_offset(1)
628 , array_extents.domain_offset(2)
629 , array_extents.domain_offset(3)
630 , array_extents.domain_offset(4)
631 , array_extents.domain_offset(5)
632 , array_extents.domain_offset(6)
633 , array_extents.domain_offset(7)
636 dst.m_map.m_fad_size = src.m_map.m_fad_size;
637 dst.m_map.m_original_fad_size = src.m_map.m_original_fad_size;
638 dst.m_map.m_fad_stride = src.m_map.m_fad_stride;
639 dst.m_map.m_fad_index = src.m_map.m_fad_index;
641 dst.m_rank = ( src_rank > 0 ? unsigned(R0) : 0 )
642 + ( src_rank > 1 ? unsigned(R1) : 0 )
643 + ( src_rank > 2 ? unsigned(R2) : 0 )
644 + ( src_rank > 3 ? unsigned(R3) : 0 )
645 + ( src_rank > 4 ? unsigned(R4) : 0 )
646 + ( src_rank > 5 ? unsigned(R5) : 0 )
647 + ( src_rank > 6 ? unsigned(R6) : 0 ) ;
657 template<
class DstTraits ,
class SrcTraits >
658 class ViewMapping< DstTraits , SrcTraits ,
659 typename std::enable_if<(
660 Kokkos::Impl::MemorySpaceAccess
661 < typename DstTraits::memory_space
662 , typename SrcTraits::memory_space >::assignable
665 std::is_same< typename DstTraits::specialize
666 , Kokkos::Impl::ViewSpecializeSacadoFadContiguous >::value
669 std::is_same< typename SrcTraits::specialize
670 , Kokkos::Impl::ViewSpecializeSacadoFadContiguous >::value
671 ), Kokkos::Impl::ViewToDynRankViewTag >::type >
675 enum { is_assignable =
true };
676 enum { is_assignable_data_type =
true };
678 typedef Kokkos::Impl::SharedAllocationTracker TrackType ;
679 typedef ViewMapping< DstTraits , typename DstTraits::specialize > DstType ;
680 typedef ViewMapping< SrcTraits , typename SrcTraits::specialize > SrcFadType ;
682 template <
typename DT ,
typename ... DP ,
typename ST ,
typename ... SP >
683 KOKKOS_INLINE_FUNCTION
static
684 void assign( Kokkos::DynRankView< DT , DP... > & dst
685 ,
const Kokkos::View< ST , SP... >& src )
689 std::is_same<
typename DstTraits::array_layout
690 , Kokkos::LayoutLeft >::
value ||
691 std::is_same<
typename DstTraits::array_layout
692 , Kokkos::LayoutRight >::
value ||
693 std::is_same<
typename DstTraits::array_layout
694 , Kokkos::LayoutStride >::
value
698 std::is_same<
typename SrcTraits::array_layout
699 , Kokkos::LayoutLeft >::
value ||
700 std::is_same<
typename SrcTraits::array_layout
701 , Kokkos::LayoutRight >::
value ||
702 std::is_same<
typename SrcTraits::array_layout
703 , Kokkos::LayoutStride >::
value
705 ,
"View of FAD requires LayoutLeft, LayoutRight, or LayoutStride" );
708 std::is_same<
typename DstTraits::value_type
709 ,
typename SrcTraits::value_type >::
value ||
710 std::is_same<
typename DstTraits::value_type
711 ,
typename SrcTraits::const_value_type >::
value ,
712 "View assignment must have same value type or const = non-const" );
716 typedef typename DstType::offset_type dst_offset_type;
717 typedef typename DstType::array_offset_type dst_array_offset_type;
719 dst.m_map.m_array_offset =
720 dst_array_offset_type(std::integral_constant<unsigned,0>(),
721 src.m_map.m_array_offset.layout() );
724 dst.m_map.m_array_offset =
725 dst_array_offset_type(std::integral_constant<unsigned,0>(),
726 permute_fad_layout(src.m_map.m_array_offset.layout(),
729 dst.m_map.m_impl_offset =
730 dst_offset_type(std::integral_constant<unsigned,0>(),
731 src.m_map.m_impl_offset.layout() );
733 dst.m_map.m_impl_handle = src.m_map.m_impl_handle ;
734 dst.m_rank = src.rank ;
736 dst.m_map.m_fad_size = src.m_map.m_fad_size ;
737 dst.m_map.m_original_fad_size = src.m_map.m_original_fad_size;
738 dst.m_map.m_fad_stride = src.m_map.m_fad_stride ;
739 dst.m_map.m_fad_index = src.m_map.m_fad_index;
747 template<
class DstTraits ,
class SrcTraits >
748 class ViewMapping< DstTraits , SrcTraits ,
749 typename std::enable_if<(
750 Kokkos::Impl::MemorySpaceAccess
751 < typename DstTraits::memory_space
752 , typename SrcTraits::memory_space >::assignable
755 std::is_same< typename DstTraits::specialize , void >::value
758 std::is_same< typename SrcTraits::specialize
759 , Kokkos::Impl::ViewSpecializeSacadoFadContiguous >::value
760 ), Kokkos::Impl::ViewToDynRankViewTag >::type >
764 enum { is_assignable =
true };
765 enum { is_assignable_data_type =
true };
767 typedef Kokkos::Impl::SharedAllocationTracker TrackType ;
768 typedef ViewMapping< DstTraits , typename DstTraits::specialize > DstType ;
769 typedef ViewMapping< SrcTraits , typename SrcTraits::specialize > SrcFadType ;
771 template <
typename DT ,
typename ... DP ,
typename ST ,
typename ... SP >
772 KOKKOS_INLINE_FUNCTION
static
773 void assign( Kokkos::DynRankView< DT , DP... > & dst
774 ,
const Kokkos::View< ST , SP... >& src )
778 std::is_same<
typename DstTraits::array_layout
779 , Kokkos::LayoutLeft >::
value ||
780 std::is_same<
typename DstTraits::array_layout
781 , Kokkos::LayoutRight >::
value ||
782 std::is_same<
typename DstTraits::array_layout
783 , Kokkos::LayoutStride >::
value
787 std::is_same<
typename SrcTraits::array_layout
788 , Kokkos::LayoutLeft >::
value ||
789 std::is_same<
typename SrcTraits::array_layout
790 , Kokkos::LayoutRight >::
value ||
791 std::is_same<
typename SrcTraits::array_layout
792 , Kokkos::LayoutStride >::
value
794 ,
"View of FAD requires LayoutLeft, LayoutRight, or LayoutStride" );
797 std::is_same<
typename DstTraits::value_type
798 ,
typename SrcTraits::value_type >::
value ||
799 std::is_same<
typename DstTraits::value_type
800 ,
typename SrcTraits::const_value_type >::
value ,
801 "View assignment must have same value type or const = non-const" );
803 dst.m_map.m_impl_offset.m_dim = src.m_map.m_array_offset.m_dim;
804 dst.m_map.m_impl_offset.m_stride = src.m_map.m_array_offset.m_stride ;
806 dst.m_map.m_impl_handle = src.m_map.m_impl_handle ;
807 dst.m_rank = src.rank ;
813 #endif //defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
815 #endif // defined(HAVE_SACADO_KOKKOS)