30 #ifndef KOKKOS_DYN_RANK_VIEW_SACADO_FAD_CONTIGUOUS_HPP
31 #define KOKKOS_DYN_RANK_VIEW_SACADO_FAD_CONTIGUOUS_HPP
38 #if defined(HAVE_SACADO_KOKKOSCONTAINERS)
40 #include "Kokkos_DynRankView.hpp"
42 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
50 struct DynRankDimTraits<Kokkos::Impl::ViewSpecializeSacadoFadContiguous> {
52 enum :
size_t{unspecified = ~size_t(0)};
57 static size_t computeRank(
const size_t N0
67 ( (N7 == unspecified && N6 == unspecified && N5 == unspecified && N4 == unspecified && N3 == unspecified && N2 == unspecified && N1 == unspecified && N0 == unspecified) ? 0
68 : ( (N7 == unspecified && N6 == unspecified && N5 == unspecified && N4 == unspecified && N3 == unspecified && N2 == unspecified && N1 == unspecified) ? 0
69 : ( (N7 == unspecified && N6 == unspecified && N5 == unspecified && N4 == unspecified && N3 == unspecified && N2 == unspecified) ? 1
70 : ( (N7 == unspecified && N6 == unspecified && N5 == unspecified && N4 == unspecified && N3 == unspecified) ? 2
71 : ( (N7 == unspecified && N6 == unspecified && N5 == unspecified && N4 == unspecified) ? 3
72 : ( (N7 == unspecified && N6 == unspecified && N5 == unspecified) ? 4
73 : ( (N7 == unspecified && N6 == unspecified) ? 5
74 : ( (N7 == unspecified) ? 6
79 template <
typename Layout>
81 static size_t computeRank(
const Layout& layout )
83 return computeRank( layout.dimension[0]
90 , layout.dimension[7] );
94 template <
typename Layout,
typename ... P>
96 static size_t computeRank(
const ViewCtorProp<P...>& prop,
const Layout& layout )
98 size_t rank = computeRank( layout.dimension[0]
100 , layout.dimension[2]
101 , layout.dimension[3]
102 , layout.dimension[4]
103 , layout.dimension[5]
104 , layout.dimension[6]
105 , layout.dimension[7] );
108 enum { test_traits_check = Kokkos::Impl::check_has_common_view_alloc_prop< P... >::value };
109 return (test_traits_check ==
true) ? rank+1 : rank;
115 template <
typename Layout>
117 static typename std::enable_if< (std::is_same<Layout , Kokkos::LayoutRight>::value || std::is_same<Layout , Kokkos::LayoutLeft>::value) , Layout >::type createLayout(
const Layout& layout )
119 Layout l( layout.dimension[0] != unspecified ? layout.dimension[0] : 1
120 , layout.dimension[1] != unspecified ? layout.dimension[1] : 1
121 , layout.dimension[2] != unspecified ? layout.dimension[2] : 1
122 , layout.dimension[3] != unspecified ? layout.dimension[3] : 1
123 , layout.dimension[4] != unspecified ? layout.dimension[4] : 1
124 , layout.dimension[5] != unspecified ? layout.dimension[5] : 1
125 , layout.dimension[6] != unspecified ? layout.dimension[6] : 1
126 , layout.dimension[7] != unspecified ? layout.dimension[7] : 1 );
127 const unsigned fad_dim = computeRank(layout);
128 const size_t fad_size = layout.dimension[
fad_dim];
130 l.dimension[7] = fad_size;
136 template <
typename Layout>
138 static typename std::enable_if< (std::is_same<Layout , Kokkos::LayoutStride>::value) , Layout>::type createLayout(
const Layout& layout )
140 Layout l( layout.dimension[0] != unspecified ? layout.dimension[0] : 1
142 , layout.dimension[1] != unspecified ? layout.dimension[1] : 1
144 , layout.dimension[2] != unspecified ? layout.dimension[2] : 1
146 , layout.dimension[3] != unspecified ? layout.dimension[3] : 1
148 , layout.dimension[4] != unspecified ? layout.dimension[4] : 1
150 , layout.dimension[5] != unspecified ? layout.dimension[5] : 1
152 , layout.dimension[6] != unspecified ? layout.dimension[6] : 1
154 , layout.dimension[7] != unspecified ? layout.dimension[7] : 1
157 const unsigned fad_dim = computeRank(layout);
158 const size_t fad_size = layout.dimension[
fad_dim];
160 l.dimension[7] = fad_size;
167 template <
typename Traits,
typename ... P>
169 static typename std::enable_if< (std::is_same<typename Traits::array_layout , Kokkos::LayoutRight>::value || std::is_same<typename Traits::array_layout , Kokkos::LayoutLeft>::value) ,
typename Traits::array_layout >::type createLayout(
const ViewCtorProp<P...> & arg_prop,
const typename Traits::array_layout& layout )
171 using Layout =
typename Traits::array_layout;
173 Layout l( layout.dimension[0] != unspecified ? layout.dimension[0] : 1
174 , layout.dimension[1] != unspecified ? layout.dimension[1] : 1
175 , layout.dimension[2] != unspecified ? layout.dimension[2] : 1
176 , layout.dimension[3] != unspecified ? layout.dimension[3] : 1
177 , layout.dimension[4] != unspecified ? layout.dimension[4] : 1
178 , layout.dimension[5] != unspecified ? layout.dimension[5] : 1
179 , layout.dimension[6] != unspecified ? layout.dimension[6] : 1
180 , layout.dimension[7] != unspecified ? layout.dimension[7] : 1 );
182 enum { test_traits_check = Kokkos::Impl::check_has_common_view_alloc_prop< P... >::value };
183 if (test_traits_check ==
true) {
184 l.dimension[7] = compute_fad_dim_from_alloc_prop<P...>::eval(arg_prop);
187 const unsigned fad_dim = computeRank(layout);
188 const size_t fad_size = layout.dimension[
fad_dim];
190 l.dimension[7] = fad_size;
198 template <
typename Traits,
typename ... P>
200 static typename std::enable_if< (std::is_same<typename Traits::array_layout , Kokkos::LayoutStride>::value) ,
typename Traits::array_layout>::type createLayout(
const ViewCtorProp<P...> & arg_prop,
const typename Traits::array_layout& layout )
202 using Layout =
typename Traits::array_layout;
204 Layout l( layout.dimension[0] != unspecified ? layout.dimension[0] : 1
206 , layout.dimension[1] != unspecified ? layout.dimension[1] : 1
208 , layout.dimension[2] != unspecified ? layout.dimension[2] : 1
210 , layout.dimension[3] != unspecified ? layout.dimension[3] : 1
212 , layout.dimension[4] != unspecified ? layout.dimension[4] : 1
214 , layout.dimension[5] != unspecified ? layout.dimension[5] : 1
216 , layout.dimension[6] != unspecified ? layout.dimension[6] : 1
218 , layout.dimension[7] != unspecified ? layout.dimension[7] : 1
222 enum { test_traits_check = Kokkos::Impl::check_has_common_view_alloc_prop< P... >::value };
223 if (test_traits_check ==
true) {
224 l.dimension[7] = compute_fad_dim_from_alloc_prop<P...>::eval(arg_prop);
227 const unsigned fad_dim = computeRank(layout);
228 const size_t fad_size = layout.dimension[
fad_dim];
230 l.dimension[7] = fad_size;
239 template <
typename ViewType,
typename ViewArg>
240 static ViewType createView(
const ViewArg& arg
250 typename ViewType::array_layout l( N0, N1, N2, N3, N4, N5, N6, N7 );
251 typename ViewType::array_layout l_fad = createLayout(l);
260 , l_fad.dimension[7] );
272 template<
class SrcTraits ,
class ... Args >
274 < typename std::enable_if<(
275 std::is_same< typename SrcTraits::specialize ,
276 Kokkos::Impl::ViewSpecializeSacadoFadContiguous >::value
279 std::is_same< typename SrcTraits::array_layout
280 , Kokkos::LayoutRight >::value ||
281 std::is_same< typename SrcTraits::array_layout
282 , Kokkos::LayoutStride >::value
284 ), Kokkos::Impl::DynRankSubviewTag >::type
292 , R0 = bool(is_integral_extent<0,Args...>::value)
293 , R1 = bool(is_integral_extent<1,Args...>::value)
294 , R2 = bool(is_integral_extent<2,Args...>::value)
295 , R3 = bool(is_integral_extent<3,Args...>::value)
296 , R4 = bool(is_integral_extent<4,Args...>::value)
297 , R5 = bool(is_integral_extent<5,Args...>::value)
298 , R6 = bool(is_integral_extent<6,Args...>::value)
301 enum { rank = unsigned(R0) + unsigned(R1) + unsigned(R2) + unsigned(R3)
302 + unsigned(R4) + unsigned(R5) + unsigned(R6) };
306 typedef typename SrcTraits::value_type value_type ;
308 typedef value_type******* data_type ;
312 typedef Kokkos::ViewTraits
315 ,
typename SrcTraits::device_type
316 ,
typename SrcTraits::memory_traits > traits_type ;
321 ,
typename SrcTraits::device_type
322 ,
typename SrcTraits::memory_traits > type ;
325 template<
class MemoryTraits >
328 static_assert( Kokkos::Impl::is_memory_traits< MemoryTraits >::value ,
"" );
330 typedef Kokkos::ViewTraits
333 ,
typename SrcTraits::device_type
334 , MemoryTraits > traits_type ;
339 ,
typename SrcTraits::device_type
340 , MemoryTraits > type ;
343 template <
class Arg0 =
int,
class Arg1 =
int,
class Arg2 =
int,
class Arg3 =
int,
class Arg4 =
int,
class Arg5 =
int,
class Arg6 =
int >
344 struct ExtentGenerator {
345 template <
typename dimension>
347 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() )
349 return SubviewExtents< 7 , rank >( dim , arg0 , arg1 , arg2 , arg3 ,
350 arg4 , arg5 , arg6 );
354 template <
class Arg0 =
int,
class Arg1 =
int,
class Arg2 =
int,
class Arg3 =
int,
class Arg4 =
int,
class Arg5 =
int,
class Arg6 =
int >
355 struct ArrayExtentGenerator {
356 template <
typename dimension>
358 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() )
360 return SubviewExtents< 8 , rank+1 >( dim , arg0 , arg1 , arg2 , arg3 ,
361 arg4 , arg5 , arg6 , Kokkos::ALL() );
365 typedef DynRankView< value_type , array_layout , typename SrcTraits::device_type , typename SrcTraits::memory_traits > ret_type;
367 template <
typename T ,
class ... P >
369 static ret_type subview(
const unsigned src_rank , Kokkos::DynRankView< T , P...>
const & src , Args ... args )
372 typedef ViewMapping< traits_type, typename traits_type::specialize > DstType ;
373 typedef typename std::conditional< (rank==0) , ViewDimension<>
374 ,
typename std::conditional< (rank==1) , ViewDimension<0>
375 ,
typename std::conditional< (rank==2) , ViewDimension<0,0>
376 ,
typename std::conditional< (rank==3) , ViewDimension<0,0,0>
377 ,
typename std::conditional< (rank==4) , ViewDimension<0,0,0,0>
378 ,
typename std::conditional< (rank==5) , ViewDimension<0,0,0,0,0>
379 ,
typename std::conditional< (rank==6) , ViewDimension<0,0,0,0,0,0>
380 , ViewDimension<0,0,0,0,0,0,0>
381 >::type >::type >::type >::type >::type >::type >::type DstDimType ;
382 typedef typename std::conditional< (rank==0) , ViewDimension<0>
383 ,
typename std::conditional< (rank==1) , ViewDimension<0,0>
384 ,
typename std::conditional< (rank==2) , ViewDimension<0,0,0>
385 ,
typename std::conditional< (rank==3) , ViewDimension<0,0,0,0>
386 ,
typename std::conditional< (rank==4) , ViewDimension<0,0,0,0,0>
387 ,
typename std::conditional< (rank==5) , ViewDimension<0,0,0,0,0,0>
388 ,
typename std::conditional< (rank==6) , ViewDimension<0,0,0,0,0,0,0>
389 , ViewDimension<0,0,0,0,0,0,0,0>
390 >::type >::type >::type >::type >::type >::type >::type DstArrayDimType ;
392 typedef ViewOffset< DstDimType , Kokkos::LayoutStride > dst_offset_type ;
393 typedef ViewOffset< DstArrayDimType , Kokkos::LayoutStride > dst_array_offset_type ;
394 typedef typename DstType::handle_type dst_handle_type ;
398 const SubviewExtents< 7 , rank > extents =
399 ExtentGenerator< Args ... >::generator(
400 src.m_map.m_impl_offset.m_dim , args... ) ;
401 const SubviewExtents< 8 , rank+1 > array_extents =
402 ArrayExtentGenerator< Args ... >::generator(
403 src.m_map.m_array_offset.m_dim , args... ) ;
405 dst_offset_type tempdst( src.m_map.m_impl_offset , extents ) ;
406 dst_array_offset_type temparraydst(
407 src.m_map.m_array_offset , array_extents ) ;
409 dst.m_track = src.m_track ;
411 dst.m_map.m_impl_offset.m_dim.N0 = tempdst.m_dim.N0 ;
412 dst.m_map.m_impl_offset.m_dim.N1 = tempdst.m_dim.N1 ;
413 dst.m_map.m_impl_offset.m_dim.N2 = tempdst.m_dim.N2 ;
414 dst.m_map.m_impl_offset.m_dim.N3 = tempdst.m_dim.N3 ;
415 dst.m_map.m_impl_offset.m_dim.N4 = tempdst.m_dim.N4 ;
416 dst.m_map.m_impl_offset.m_dim.N5 = tempdst.m_dim.N5 ;
417 dst.m_map.m_impl_offset.m_dim.N6 = tempdst.m_dim.N6 ;
419 dst.m_map.m_impl_offset.m_stride.S0 = tempdst.m_stride.S0;
420 dst.m_map.m_impl_offset.m_stride.S1 = tempdst.m_stride.S1;
421 dst.m_map.m_impl_offset.m_stride.S2 = tempdst.m_stride.S2;
422 dst.m_map.m_impl_offset.m_stride.S3 = tempdst.m_stride.S3;
423 dst.m_map.m_impl_offset.m_stride.S4 = tempdst.m_stride.S4;
424 dst.m_map.m_impl_offset.m_stride.S5 = tempdst.m_stride.S5;
425 dst.m_map.m_impl_offset.m_stride.S6 = tempdst.m_stride.S6;
434 AssignFadDimStride<rank,0>::eval( dst.m_map.m_array_offset, temparraydst );
436 dst.m_track = src.m_track ;
438 dst.m_map.m_impl_handle =
440 src.m_map.m_impl_handle +
441 src.m_map.m_array_offset( array_extents.domain_offset(0)
442 , array_extents.domain_offset(1)
443 , array_extents.domain_offset(2)
444 , array_extents.domain_offset(3)
445 , array_extents.domain_offset(4)
446 , array_extents.domain_offset(5)
447 , array_extents.domain_offset(6)
448 , array_extents.domain_offset(7)
451 dst.m_map.m_fad_size = src.m_map.m_fad_size;
452 dst.m_map.m_original_fad_size = src.m_map.m_original_fad_size;
453 dst.m_map.m_fad_stride = src.m_map.m_fad_stride;
454 dst.m_map.m_fad_index = src.m_map.m_fad_index;
456 dst.m_rank = ( src_rank > 0 ? unsigned(R0) : 0 )
457 + ( src_rank > 1 ? unsigned(R1) : 0 )
458 + ( src_rank > 2 ? unsigned(R2) : 0 )
459 + ( src_rank > 3 ? unsigned(R3) : 0 )
460 + ( src_rank > 4 ? unsigned(R4) : 0 )
461 + ( src_rank > 5 ? unsigned(R5) : 0 )
462 + ( src_rank > 6 ? unsigned(R6) : 0 ) ;
468 template<
class SrcTraits ,
class ... Args >
470 < typename std::enable_if<(
471 std::is_same< typename SrcTraits::specialize ,
472 Kokkos::Impl::ViewSpecializeSacadoFadContiguous >::value
474 std::is_same< typename SrcTraits::array_layout
475 , Kokkos::LayoutLeft >::value
476 ), Kokkos::Impl::DynRankSubviewTag >::type
484 , R0 = bool(is_integral_extent<0,Args...>::value)
485 , R1 = bool(is_integral_extent<1,Args...>::value)
486 , R2 = bool(is_integral_extent<2,Args...>::value)
487 , R3 = bool(is_integral_extent<3,Args...>::value)
488 , R4 = bool(is_integral_extent<4,Args...>::value)
489 , R5 = bool(is_integral_extent<5,Args...>::value)
490 , R6 = bool(is_integral_extent<6,Args...>::value)
493 enum { rank = unsigned(R0) + unsigned(R1) + unsigned(R2) + unsigned(R3)
494 + unsigned(R4) + unsigned(R5) + unsigned(R6) };
498 typedef typename SrcTraits::value_type value_type ;
500 typedef value_type******* data_type ;
504 typedef Kokkos::ViewTraits
507 ,
typename SrcTraits::device_type
508 ,
typename SrcTraits::memory_traits > traits_type ;
513 ,
typename SrcTraits::device_type
514 ,
typename SrcTraits::memory_traits > type ;
517 template<
class MemoryTraits >
520 static_assert( Kokkos::Impl::is_memory_traits< MemoryTraits >::value ,
"" );
522 typedef Kokkos::ViewTraits
525 ,
typename SrcTraits::device_type
526 , MemoryTraits > traits_type ;
531 ,
typename SrcTraits::device_type
532 , MemoryTraits > type ;
535 template <
class Arg0 =
int,
class Arg1 =
int,
class Arg2 =
int,
class Arg3 =
int,
class Arg4 =
int,
class Arg5 =
int,
class Arg6 =
int >
536 struct ExtentGenerator {
537 template <
typename dimension>
539 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() )
541 return SubviewExtents< 7 , rank >( dim , arg0 , arg1 , arg2 , arg3 ,
542 arg4 , arg5 , arg6 );
546 template <
class Arg0 =
int,
class Arg1 =
int,
class Arg2 =
int,
class Arg3 =
int,
class Arg4 =
int,
class Arg5 =
int,
class Arg6 =
int >
547 struct ArrayExtentGenerator {
548 template <
typename dimension>
550 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() )
552 return SubviewExtents< 8 , rank+1 >( dim , Kokkos::ALL() , arg0 , arg1 ,
553 arg2 , arg3 , arg4 , arg5 , arg6 );
557 typedef DynRankView< value_type , array_layout , typename SrcTraits::device_type , typename SrcTraits::memory_traits > ret_type;
559 template <
typename T ,
class ... P >
561 static ret_type subview(
const unsigned src_rank , Kokkos::DynRankView< T , P...>
const & src , Args ... args )
564 typedef ViewMapping< traits_type, typename traits_type::specialize > DstType ;
565 typedef typename std::conditional< (rank==0) , ViewDimension<>
566 ,
typename std::conditional< (rank==1) , ViewDimension<0>
567 ,
typename std::conditional< (rank==2) , ViewDimension<0,0>
568 ,
typename std::conditional< (rank==3) , ViewDimension<0,0,0>
569 ,
typename std::conditional< (rank==4) , ViewDimension<0,0,0,0>
570 ,
typename std::conditional< (rank==5) , ViewDimension<0,0,0,0,0>
571 ,
typename std::conditional< (rank==6) , ViewDimension<0,0,0,0,0,0>
572 , ViewDimension<0,0,0,0,0,0,0>
573 >::type >::type >::type >::type >::type >::type >::type DstDimType ;
574 typedef typename std::conditional< (rank==0) , ViewDimension<0>
575 ,
typename std::conditional< (rank==1) , ViewDimension<0,0>
576 ,
typename std::conditional< (rank==2) , ViewDimension<0,0,0>
577 ,
typename std::conditional< (rank==3) , ViewDimension<0,0,0,0>
578 ,
typename std::conditional< (rank==4) , ViewDimension<0,0,0,0,0>
579 ,
typename std::conditional< (rank==5) , ViewDimension<0,0,0,0,0,0>
580 ,
typename std::conditional< (rank==6) , ViewDimension<0,0,0,0,0,0,0>
581 , ViewDimension<0,0,0,0,0,0,0,0>
582 >::type >::type >::type >::type >::type >::type >::type DstArrayDimType ;
584 typedef ViewOffset< DstDimType , Kokkos::LayoutStride > dst_offset_type ;
585 typedef ViewOffset< DstArrayDimType , Kokkos::LayoutStride > dst_array_offset_type ;
586 typedef typename DstType::handle_type dst_handle_type ;
590 const SubviewExtents< 7 , rank > extents =
591 ExtentGenerator< Args ... >::generator(
592 src.m_map.m_impl_offset.m_dim , args... ) ;
593 const SubviewExtents< 8 , rank+1 > array_extents =
594 ArrayExtentGenerator< Args ... >::generator(
595 src.m_map.m_array_offset.m_dim , args... ) ;
597 dst_offset_type tempdst( src.m_map.m_impl_offset , extents ) ;
598 dst_array_offset_type temparraydst(
599 src.m_map.m_array_offset , array_extents ) ;
601 dst.m_track = src.m_track ;
603 dst.m_map.m_impl_offset.m_dim.N0 = tempdst.m_dim.N0 ;
604 dst.m_map.m_impl_offset.m_dim.N1 = tempdst.m_dim.N1 ;
605 dst.m_map.m_impl_offset.m_dim.N2 = tempdst.m_dim.N2 ;
606 dst.m_map.m_impl_offset.m_dim.N3 = tempdst.m_dim.N3 ;
607 dst.m_map.m_impl_offset.m_dim.N4 = tempdst.m_dim.N4 ;
608 dst.m_map.m_impl_offset.m_dim.N5 = tempdst.m_dim.N5 ;
609 dst.m_map.m_impl_offset.m_dim.N6 = tempdst.m_dim.N6 ;
611 dst.m_map.m_impl_offset.m_stride.S0 = tempdst.m_stride.S0;
612 dst.m_map.m_impl_offset.m_stride.S1 = tempdst.m_stride.S1;
613 dst.m_map.m_impl_offset.m_stride.S2 = tempdst.m_stride.S2;
614 dst.m_map.m_impl_offset.m_stride.S3 = tempdst.m_stride.S3;
615 dst.m_map.m_impl_offset.m_stride.S4 = tempdst.m_stride.S4;
616 dst.m_map.m_impl_offset.m_stride.S5 = tempdst.m_stride.S5;
617 dst.m_map.m_impl_offset.m_stride.S6 = tempdst.m_stride.S6;
623 dst.m_map.m_array_offset.m_dim.N0 = temparraydst.m_dim.N1 ;
624 dst.m_map.m_array_offset.m_dim.N1 = temparraydst.m_dim.N2 ;
625 dst.m_map.m_array_offset.m_dim.N2 = temparraydst.m_dim.N3 ;
626 dst.m_map.m_array_offset.m_dim.N3 = temparraydst.m_dim.N4 ;
627 dst.m_map.m_array_offset.m_dim.N4 = temparraydst.m_dim.N5 ;
628 dst.m_map.m_array_offset.m_dim.N5 = temparraydst.m_dim.N6 ;
629 dst.m_map.m_array_offset.m_dim.N6 = temparraydst.m_dim.N7 ;
630 dst.m_map.m_array_offset.m_dim.N7 = temparraydst.m_dim.N0 ;
632 dst.m_map.m_array_offset.m_stride.S0 = temparraydst.m_stride.S1;
633 dst.m_map.m_array_offset.m_stride.S1 = temparraydst.m_stride.S2;
634 dst.m_map.m_array_offset.m_stride.S2 = temparraydst.m_stride.S3;
635 dst.m_map.m_array_offset.m_stride.S3 = temparraydst.m_stride.S4;
636 dst.m_map.m_array_offset.m_stride.S4 = temparraydst.m_stride.S5;
637 dst.m_map.m_array_offset.m_stride.S5 = temparraydst.m_stride.S6;
638 dst.m_map.m_array_offset.m_stride.S6 = temparraydst.m_stride.S7;
639 dst.m_map.m_array_offset.m_stride.S7 = temparraydst.m_stride.S0;
641 dst.m_track = src.m_track ;
643 dst.m_map.m_impl_handle =
645 src.m_map.m_impl_handle +
646 src.m_map.m_array_offset( array_extents.domain_offset(0)
647 , array_extents.domain_offset(1)
648 , array_extents.domain_offset(2)
649 , array_extents.domain_offset(3)
650 , array_extents.domain_offset(4)
651 , array_extents.domain_offset(5)
652 , array_extents.domain_offset(6)
653 , array_extents.domain_offset(7)
656 dst.m_map.m_fad_size = src.m_map.m_fad_size;
657 dst.m_map.m_original_fad_size = src.m_map.m_original_fad_size;
658 dst.m_map.m_fad_stride = src.m_map.m_fad_stride;
659 dst.m_map.m_fad_index = src.m_map.m_fad_index;
661 dst.m_rank = ( src_rank > 0 ? unsigned(R0) : 0 )
662 + ( src_rank > 1 ? unsigned(R1) : 0 )
663 + ( src_rank > 2 ? unsigned(R2) : 0 )
664 + ( src_rank > 3 ? unsigned(R3) : 0 )
665 + ( src_rank > 4 ? unsigned(R4) : 0 )
666 + ( src_rank > 5 ? unsigned(R5) : 0 )
667 + ( src_rank > 6 ? unsigned(R6) : 0 ) ;
677 template<
class DstTraits ,
class SrcTraits >
678 class ViewMapping< DstTraits , SrcTraits ,
679 typename std::enable_if<(
680 Kokkos::Impl::MemorySpaceAccess
681 < typename DstTraits::memory_space
682 , typename SrcTraits::memory_space >::assignable
685 std::is_same< typename DstTraits::specialize
686 , Kokkos::Impl::ViewSpecializeSacadoFadContiguous >::value
689 std::is_same< typename SrcTraits::specialize
690 , Kokkos::Impl::ViewSpecializeSacadoFadContiguous >::value
691 ), Kokkos::Impl::ViewToDynRankViewTag >::type >
695 enum { is_assignable =
true };
696 enum { is_assignable_data_type =
true };
698 typedef Kokkos::Impl::SharedAllocationTracker TrackType ;
699 typedef ViewMapping< DstTraits , typename DstTraits::specialize > DstType ;
700 typedef ViewMapping< SrcTraits , typename SrcTraits::specialize > SrcFadType ;
702 template <
typename DT ,
typename ... DP ,
typename ST ,
typename ... SP >
704 void assign( Kokkos::DynRankView< DT , DP... > & dst
705 ,
const Kokkos::View< ST , SP... >& src )
709 std::is_same<
typename DstTraits::array_layout
710 , Kokkos::LayoutLeft >::value ||
711 std::is_same<
typename DstTraits::array_layout
712 , Kokkos::LayoutRight >::value ||
713 std::is_same<
typename DstTraits::array_layout
714 , Kokkos::LayoutStride >::value
718 std::is_same<
typename SrcTraits::array_layout
719 , Kokkos::LayoutLeft >::value ||
720 std::is_same<
typename SrcTraits::array_layout
721 , Kokkos::LayoutRight >::value ||
722 std::is_same<
typename SrcTraits::array_layout
723 , Kokkos::LayoutStride >::value
725 ,
"View of FAD requires LayoutLeft, LayoutRight, or LayoutStride" );
728 std::is_same<
typename DstTraits::value_type
729 ,
typename SrcTraits::value_type >::value ||
730 std::is_same<
typename DstTraits::value_type
731 ,
typename SrcTraits::const_value_type >::value ,
732 "View assignment must have same value type or const = non-const" );
735 std::is_same<typename DstTraits::array_layout,Kokkos::LayoutLeft>::value;
736 typedef typename DstType::offset_type dst_offset_type;
737 typedef typename DstType::array_offset_type dst_array_offset_type;
739 dst.m_map.m_array_offset =
740 dst_array_offset_type(std::integral_constant<unsigned,0>(),
741 src.m_map.m_array_offset.layout() );
744 dst.m_map.m_array_offset =
745 dst_array_offset_type(std::integral_constant<unsigned,0>(),
746 permute_fad_layout(src.m_map.m_array_offset.layout(),
749 dst.m_map.m_impl_offset =
750 dst_offset_type(std::integral_constant<unsigned,0>(),
751 src.m_map.m_impl_offset.layout() );
753 dst.m_map.m_impl_handle = src.m_map.m_impl_handle ;
754 dst.m_rank = src.Rank ;
756 dst.m_map.m_fad_size = src.m_map.m_fad_size ;
757 dst.m_map.m_original_fad_size = src.m_map.m_original_fad_size;
758 dst.m_map.m_fad_stride = src.m_map.m_fad_stride ;
759 dst.m_map.m_fad_index = src.m_map.m_fad_index;
767 template<
class DstTraits ,
class SrcTraits >
768 class ViewMapping< DstTraits , SrcTraits ,
769 typename std::enable_if<(
770 Kokkos::Impl::MemorySpaceAccess
771 < typename DstTraits::memory_space
772 , typename SrcTraits::memory_space >::assignable
775 std::is_same< typename DstTraits::specialize , void >::value
778 std::is_same< typename SrcTraits::specialize
779 , Kokkos::Impl::ViewSpecializeSacadoFadContiguous >::value
780 ), Kokkos::Impl::ViewToDynRankViewTag >::type >
784 enum { is_assignable =
true };
785 enum { is_assignable_data_type =
true };
787 typedef Kokkos::Impl::SharedAllocationTracker TrackType ;
788 typedef ViewMapping< DstTraits , typename DstTraits::specialize > DstType ;
789 typedef ViewMapping< SrcTraits , typename SrcTraits::specialize > SrcFadType ;
791 template <
typename DT ,
typename ... DP ,
typename ST ,
typename ... SP >
793 void assign( Kokkos::DynRankView< DT , DP... > & dst
794 ,
const Kokkos::View< ST , SP... >& src )
798 std::is_same<
typename DstTraits::array_layout
799 , Kokkos::LayoutLeft >::value ||
800 std::is_same<
typename DstTraits::array_layout
801 , Kokkos::LayoutRight >::value ||
802 std::is_same<
typename DstTraits::array_layout
803 , Kokkos::LayoutStride >::value
807 std::is_same<
typename SrcTraits::array_layout
808 , Kokkos::LayoutLeft >::value ||
809 std::is_same<
typename SrcTraits::array_layout
810 , Kokkos::LayoutRight >::value ||
811 std::is_same<
typename SrcTraits::array_layout
812 , Kokkos::LayoutStride >::value
814 ,
"View of FAD requires LayoutLeft, LayoutRight, or LayoutStride" );
817 std::is_same<
typename DstTraits::value_type
818 ,
typename SrcTraits::value_type >::value ||
819 std::is_same<
typename DstTraits::value_type
820 ,
typename SrcTraits::const_value_type >::value ,
821 "View assignment must have same value type or const = non-const" );
823 dst.m_map.m_impl_offset.m_dim = src.m_map.m_array_offset.m_dim;
824 dst.m_map.m_impl_offset.m_stride = src.m_map.m_array_offset.m_stride ;
826 dst.m_map.m_impl_handle = src.m_map.m_impl_handle ;
827 dst.m_rank = src.Rank ;
833 #endif //defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
835 #endif // defined(HAVE_SACADO_KOKKOSCONTAINERS)
#define KOKKOS_INLINE_FUNCTION