36 static const bool value =
false;
39 template <
typename T,
int N>
46 static const bool value =
false;
54 template <
typename FadType1,
typename FadType2>
67 for (
int i=0;
i<x.size(); ++
i)
73 template <
typename fadtype,
typename ordinal>
76 const ordinal num_cols,
77 const ordinal fad_size,
81 typedef typename fadtype::value_type scalar;
82 fadtype
x(fad_size, scalar(0.0));
84 const scalar x_row = 100.0 + scalar(num_rows) / scalar(row+1);
85 const scalar x_col = 10.0 + scalar(num_cols) / scalar(col+1);
86 x.val() = x_row + x_col;
87 for (ordinal
i=0;
i<fad_size; ++
i) {
88 const scalar x_fad = 1.0 + scalar(fad_size) / scalar(
i+1);
89 x.fastAccessDx(
i) = x_row + x_col + x_fad;
94 #ifndef GLOBAL_FAD_SIZE
95 #define GLOBAL_FAD_SIZE 5
102 template <
typename InputViewType1,
103 typename InputViewType2 = InputViewType1,
104 typename OutputViewType = InputViewType1>
118 const InputViewType2 v2,
119 const OutputViewType v3,
124 KOKKOS_INLINE_FUNCTION
132 KOKKOS_INLINE_FUNCTION
135 const size_type i = team.league_rank()*team.team_size() + team.team_rank();
136 if (i <
m_v1.extent(0))
141 static void apply(
const InputViewType1 v1,
142 const InputViewType2 v2,
143 const OutputViewType v3,
144 const bool update =
false) {
147 #if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
148 const size_type stride = Kokkos::ViewScalarStride<InputViewType1>::stride;
149 const bool use_team =
154 #elif defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
155 const size_type stride = team_policy_type::vector_length_max();
156 const bool use_team =
161 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
162 const size_type stride = Kokkos::ViewScalarStride<InputViewType1>::stride;
163 const bool use_team =
168 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
169 const size_type stride = team_policy_type::vector_length_max();
170 const bool use_team =
177 const bool use_team =
false;
181 const size_type team_size = 256 / stride;
193 template <
typename ViewType>
197 typedef typename ViewType::value_type::value_type
ScalarType;
210 KOKKOS_INLINE_FUNCTION
215 KOKKOS_INLINE_FUNCTION
218 const size_type i = team.league_rank()*team.team_size() + team.team_rank();
219 if (i <
m_v.extent(0))
227 #if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
228 const bool use_team =
233 #elif defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
234 const bool use_team =
239 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
240 const bool use_team =
245 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
246 const bool use_team =
252 const bool use_team =
false;
268 template <
typename ViewType,
typename ScalarViewType>
286 KOKKOS_INLINE_FUNCTION
292 KOKKOS_INLINE_FUNCTION
295 const size_type i = team.league_rank()*team.team_size() + team.team_rank();
296 if (i <
m_v.extent(0))
301 static void apply(
const ViewType& v,
const ScalarViewType& s) {
304 #if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
305 const bool use_team =
310 #elif defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
311 const bool use_team =
316 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
317 const bool use_team =
322 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
323 const bool use_team =
329 const bool use_team =
false;
345 template <
typename InputViewType,
346 typename OutputViewType,
347 typename Enabled =
void>
361 const OutputViewType v2,
364 static_assert(
unsigned(InputViewType::rank) == 2 ,
365 "Require rank-2 input view" );
366 static_assert(
unsigned(OutputViewType::rank) == 1 ,
367 "Require rank-1 output view" );
371 KOKKOS_INLINE_FUNCTION
376 KOKKOS_INLINE_FUNCTION
379 const size_type i = team.league_rank()*team.team_size() + team.team_rank();
380 if (i <
m_v1.extent(0))
385 static void apply(
const InputViewType v1,
386 const OutputViewType v2,
390 #if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
391 const bool use_team =
396 #elif defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
397 const bool use_team =
402 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
403 const bool use_team =
408 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
409 const bool use_team =
415 const bool use_team =
false;
431 template <
typename ViewType,
typename ScalarViewType>
448 KOKKOS_INLINE_FUNCTION
451 Kokkos::atomic_add(&(
m_s()), x);
454 KOKKOS_INLINE_FUNCTION
457 const size_type i = team.league_rank()*team.team_size() + team.team_rank();
458 if (i <
m_v.extent(0))
463 static void apply(
const ViewType& v,
const ScalarViewType& s) {
466 #if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
467 const bool use_team =
472 #elif defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
473 const bool use_team =
478 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
479 const bool use_team =
484 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
485 const bool use_team =
491 const bool use_team =
false;
507 Kokkos_View_Fad, Size,
FadType, Layout, Device )
509 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
510 typedef typename ViewType::size_type size_type;
516 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
517 v = ViewType(
"view", num_rows);
520 v = ViewType(
"view", num_rows, fad_size+1);
526 Kokkos_View_Fad, DeepCopy,
FadType, Layout, Device )
528 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
529 typedef typename ViewType::size_type size_type;
530 typedef typename ViewType::HostMirror host_view_type;
538 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
539 v = ViewType (
"view", num_rows, num_cols);
541 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
543 host_view_type h_v = Kokkos::create_mirror_view(v);
544 for (size_type
i=0;
i<num_rows; ++
i)
545 for (size_type j=0; j<num_cols; ++j)
546 h_v(
i,j) = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
547 Kokkos::deep_copy(v, h_v);
550 host_view_type h_v2 = Kokkos::create_mirror_view(v);
551 Kokkos::deep_copy(h_v2, v);
555 for (size_type i=0; i<num_rows; ++
i) {
556 for (size_type j=0; j<num_cols; ++j) {
557 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
558 success = success &&
checkFads(f, h_v2(i,j), out);
564 Kokkos_View_Fad, DeepCopy_ConstantScalar,
FadType, Layout, Device )
566 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
567 typedef typename ViewType::size_type size_type;
568 typedef typename ViewType::HostMirror host_view_type;
569 typedef typename FadType::value_type value_type;
576 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
577 v = ViewType (
"view", num_rows, num_cols);
580 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
582 typename ViewType::array_type va = v;
583 Kokkos::deep_copy( va, 1.0 );
586 value_type
a = 2.3456;
587 Kokkos::deep_copy( v, a );
590 host_view_type hv = Kokkos::create_mirror_view(v);
591 Kokkos::deep_copy(hv, v);
595 for (size_type
i=0;
i<num_rows; ++
i) {
596 for (size_type j=0; j<num_cols; ++j) {
597 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
602 success = success &&
checkFads(f, hv(
i,j), out);
608 Kokkos_View_Fad, DeepCopy_ConstantZero,
FadType, Layout, Device )
610 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
611 typedef typename ViewType::size_type size_type;
612 typedef typename ViewType::HostMirror host_view_type;
613 typedef typename FadType::value_type value_type;
620 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
621 v = ViewType (
"view", num_rows, num_cols);
624 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
626 typename ViewType::array_type va = v;
627 Kokkos::deep_copy( va, 1.0 );
631 Kokkos::deep_copy( v, a );
634 host_view_type hv = Kokkos::create_mirror_view(v);
635 Kokkos::deep_copy(hv, v);
639 for (size_type
i=0;
i<num_rows; ++
i) {
640 for (size_type j=0; j<num_cols; ++j) {
641 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
646 success = success &&
checkFads(f, hv(
i,j), out);
652 Kokkos_View_Fad, DeepCopy_ConstantFad,
FadType, Layout, Device )
654 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
655 typedef typename ViewType::size_type size_type;
656 typedef typename ViewType::HostMirror host_view_type;
663 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
664 v = ViewType (
"view", num_rows, num_cols);
667 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
669 typename ViewType::array_type va = v;
670 Kokkos::deep_copy( va, 1.0 );
674 Kokkos::deep_copy( v, a );
677 host_view_type hv = Kokkos::create_mirror_view(v);
678 Kokkos::deep_copy(hv, v);
682 for (size_type
i=0;
i<num_rows; ++
i) {
683 for (size_type j=0; j<num_cols; ++j) {
684 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
689 success = success &&
checkFads(f, hv(
i,j), out);
695 Kokkos_View_Fad, DeepCopy_ConstantFadFull,
FadType, Layout, Device )
697 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
698 typedef typename ViewType::size_type size_type;
699 typedef typename ViewType::HostMirror host_view_type;
707 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
708 v = ViewType (
"view", num_rows, num_cols);
710 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
712 typename ViewType::array_type va = v;
713 Kokkos::deep_copy( va, 1.0 );
717 for (size_type
i=0;
i<fad_size; ++
i)
718 a.fastAccessDx(
i) = 7.89 + (
i+1);
721 host_view_type hv = Kokkos::create_mirror_view(v);
722 Kokkos::deep_copy(hv, a);
726 for (size_type
i=0;
i<num_rows; ++
i) {
727 for (size_type j=0; j<num_cols; ++j) {
728 success = success &&
checkFads(a, hv(
i,j), out);
734 Kokkos_View_Fad, LocalDeepCopy,
FadType, Layout, Device )
736 typedef Kokkos::View<FadType***,Layout,Device> ViewType;
737 typedef Kokkos::View<FadType,Layout,Device> ScalarViewType;
738 typedef typename ViewType::size_type size_type;
739 typedef typename ViewType::HostMirror host_view_type;
740 typedef typename ScalarViewType::HostMirror host_scalar_view_type;
744 const size_type num_slices = 10;
749 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
750 v = ViewType (
"view", num_rows, num_cols, num_slices);
752 v = ViewType (
"view", num_rows, num_cols, num_slices, fad_size+1);
754 typename ViewType::array_type va = v;
755 Kokkos::deep_copy( va, 1.0 );
760 for (size_type
i=0;
i<fad_size; ++
i)
761 a.fastAccessDx(
i) = 7.89 + (
i+1);
762 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
763 ScalarViewType a_view(
"a");
765 ScalarViewType a_view(
"a", fad_size+1);
767 host_scalar_view_type ha_view = Kokkos::create_mirror_view(a_view);
769 Kokkos::deep_copy( a_view, ha_view );
772 Kokkos::parallel_for(Kokkos::RangePolicy<Device>(0,num_rows),
773 KOKKOS_LAMBDA(
const int i)
775 auto s = Kokkos::subview(v,i,Kokkos::ALL,Kokkos::ALL);
776 Kokkos::Experimental::local_deep_copy(s,a_view());
780 host_view_type hv = Kokkos::create_mirror_view(v);
781 Kokkos::deep_copy(hv, a);
785 for (size_type i=0; i<num_rows; ++
i) {
786 for (size_type j=0; j<num_cols; ++j) {
787 for (size_type k=0; k<num_slices; ++k) {
788 success = success &&
checkFads(a, hv(i,j,k), out);
795 Kokkos_View_Fad, LocalDeepCopyTeam,
FadType, Layout, Device )
797 typedef Kokkos::View<FadType***,Layout,Device> ViewType;
798 typedef Kokkos::View<FadType,Layout,Device> ScalarViewType;
799 typedef typename ViewType::size_type size_type;
800 typedef typename ViewType::HostMirror host_view_type;
801 typedef typename ScalarViewType::HostMirror host_scalar_view_type;
805 const size_type num_slices = 10;
810 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
811 v = ViewType (
"view", num_rows, num_cols, num_slices);
813 v = ViewType (
"view", num_rows, num_cols, num_slices, fad_size+1);
815 typename ViewType::array_type va = v;
816 Kokkos::deep_copy( va, 1.0 );
821 for (size_type
i=0;
i<fad_size; ++
i)
822 a.fastAccessDx(
i) = 7.89 + (
i+1);
823 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
824 ScalarViewType a_view(
"a");
826 ScalarViewType a_view(
"a", fad_size+1);
828 host_scalar_view_type ha_view = Kokkos::create_mirror_view(a_view);
830 Kokkos::deep_copy( a_view, ha_view );
833 typedef Kokkos::TeamPolicy<Device> Policy;
834 static const size_type stride = Kokkos::ViewScalarStride<ViewType>::stride;
835 Kokkos::parallel_for(Policy(num_rows,Kokkos::AUTO,stride),
836 KOKKOS_LAMBDA(
const typename Policy::member_type& team)
838 int i = team.league_rank();
839 auto s = Kokkos::subview(v,i,Kokkos::ALL,Kokkos::ALL);
840 Kokkos::Experimental::local_deep_copy(team,s,a_view());
844 host_view_type hv = Kokkos::create_mirror_view(v);
845 Kokkos::deep_copy(hv, a);
849 for (size_type
i=0;
i<num_rows; ++
i) {
850 for (size_type j=0; j<num_cols; ++j) {
851 for (size_type k=0; k<num_slices; ++k) {
852 success = success &&
checkFads(a, hv(
i,j,k), out);
859 Kokkos_View_Fad, ScalarAssign,
FadType, Layout, Device )
861 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
862 typedef typename ViewType::size_type size_type;
863 typedef typename ViewType::HostMirror host_view_type;
864 typedef typename FadType::value_type value_type;
870 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
871 v = ViewType (
"view", num_rows);
874 v = ViewType (
"view", num_rows, fad_size+1);
876 typename ViewType::array_type va = v;
877 Kokkos::deep_copy( va, 1.0 );
880 value_type
a = 2.3456;
884 host_view_type hv = Kokkos::create_mirror_view(v);
885 Kokkos::deep_copy(hv, v);
889 for (size_type
i=0;
i<num_rows; ++
i) {
890 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
895 success = success &&
checkFads(f, hv(
i), out);
900 Kokkos_View_Fad, ValueAssign,
FadType, Layout, Device )
902 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
903 typedef Kokkos::View<FadType,Layout,Device> ScalarViewType;
904 typedef typename ViewType::size_type size_type;
905 typedef typename ViewType::HostMirror host_view_type;
906 typedef typename ScalarViewType::HostMirror host_scalar_view_type;
914 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
915 v = ViewType (
"view", num_rows);
916 a = ScalarViewType (
"fad");
918 v = ViewType (
"view", num_rows, fad_size+1);
919 a = ScalarViewType (
"fad", fad_size+1);
921 typename ViewType::array_type va = v;
922 Kokkos::deep_copy( va, 1.0 );
925 Kokkos::deep_copy(a, 2.3456);
927 Kokkos::parallel_for(Kokkos::RangePolicy< Device>(0, fad_size), KOKKOS_LAMBDA(
const int i) {
928 a().fastAccessDx(i) = 7.89 +
i;
936 host_view_type hv = Kokkos::create_mirror_view(v);
937 Kokkos::deep_copy(hv, v);
939 host_scalar_view_type ha = Kokkos::create_mirror_view(a);
940 Kokkos::deep_copy(ha, a);
944 for (size_type i=0; i<num_rows; ++
i) {
945 success = success &&
checkFads(ha(), hv(i), out);
950 Kokkos_View_Fad, Resize,
FadType, Layout, Device )
952 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
953 typedef typename ViewType::size_type size_type;
954 typedef typename ViewType::HostMirror host_view_type;
962 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
963 v = ViewType (
"view", num_rows, num_cols);
965 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
967 host_view_type h_v = Kokkos::create_mirror_view(v);
968 for (size_type
i=0;
i<num_rows; ++
i)
969 for (size_type j=0; j<num_cols; ++j)
970 h_v(
i,j) = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
971 Kokkos::deep_copy(v, h_v);
974 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
975 Kokkos::resize(v, num_rows, num_cols+1);
977 Kokkos::resize(v, num_rows, num_cols+1, fad_size+1);
981 host_view_type h_v2 = Kokkos::create_mirror_view(v);
982 Kokkos::deep_copy(h_v2, v);
986 for (size_type i=0; i<num_rows; ++
i) {
987 for (size_type j=0; j<num_cols; ++j) {
988 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
989 success = success &&
checkFads(f, h_v2(i,j), out);
991 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
996 success = success &&
checkFads(f, h_v2(i,num_cols), out);
1001 Kokkos_View_Fad, Multiply,
FadType, Layout, Device )
1003 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
1004 typedef typename ViewType::size_type size_type;
1005 typedef typename ViewType::HostMirror host_view_type;
1012 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1013 v1 = ViewType (
"view1", num_rows);
1014 v2 = ViewType (
"view2", num_rows);
1016 v1 = ViewType (
"view1", num_rows, fad_size+1);
1017 v2 = ViewType (
"view2", num_rows, fad_size+1);
1019 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
1020 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
1021 for (size_type
i=0;
i<num_rows; ++
i) {
1022 h_v1(
i) = generate_fad<FadType>(
1023 num_rows, size_type(2), fad_size,
i, size_type(0));
1024 h_v2(i) = generate_fad<FadType>(
1025 num_rows, size_type(2), fad_size,
i, size_type(1));
1027 Kokkos::deep_copy(v1, h_v1);
1028 Kokkos::deep_copy(v2, h_v2);
1032 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1033 v3 = ViewType (
"view3", num_rows);
1035 v3 = ViewType (
"view3", num_rows, fad_size+1);
1040 host_view_type h_v3 = Kokkos::create_mirror_view(v3);
1041 Kokkos::deep_copy(h_v3, v3);
1045 for (size_type
i=0;
i<num_rows; ++
i) {
1047 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(0));
1049 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(1));
1051 success = success &&
checkFads(f3, h_v3(i), out);
1056 Kokkos_View_Fad, MultiplyUpdate,
FadType, Layout, Device )
1058 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
1059 typedef typename ViewType::size_type size_type;
1060 typedef typename ViewType::HostMirror host_view_type;
1067 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1068 v1 = ViewType (
"view1", num_rows);
1069 v2 = ViewType (
"view2", num_rows);
1071 v1 = ViewType (
"view1", num_rows, fad_size+1);
1072 v2 = ViewType (
"view2", num_rows, fad_size+1);
1074 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
1075 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
1076 for (size_type
i=0;
i<num_rows; ++
i) {
1077 h_v1(
i) = generate_fad<FadType>(
1078 num_rows, size_type(2), fad_size,
i, size_type(0));
1079 h_v2(i) = generate_fad<FadType>(
1080 num_rows, size_type(2), fad_size,
i, size_type(1));
1082 Kokkos::deep_copy(v1, h_v1);
1083 Kokkos::deep_copy(v2, h_v2);
1087 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1088 v3 = ViewType (
"view3", num_rows);
1090 v3 = ViewType (
"view3", num_rows, fad_size+1);
1092 Kokkos::deep_copy(v3, 1.0);
1096 host_view_type h_v3 = Kokkos::create_mirror_view(v3);
1097 Kokkos::deep_copy(h_v3, v3);
1101 for (size_type
i=0;
i<num_rows; ++
i) {
1103 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(0));
1105 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(1));
1107 success = success &&
checkFads(f3, h_v3(i), out);
1112 Kokkos_View_Fad, MultiplyConst,
FadType, Layout, Device )
1114 typedef Kokkos::View<const FadType*,Layout,Device,Kokkos::MemoryUnmanaged> ConstViewType;
1115 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
1116 typedef typename ViewType::size_type size_type;
1117 typedef typename ViewType::HostMirror host_view_type;
1124 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1125 v1 = ViewType (
"view1", num_rows);
1126 v2 = ViewType (
"view2", num_rows);
1128 v1 = ViewType (
"view1", num_rows, fad_size+1);
1129 v2 = ViewType (
"view2", num_rows, fad_size+1);
1131 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
1132 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
1133 for (size_type
i=0;
i<num_rows; ++
i) {
1134 h_v1(
i) = generate_fad<FadType>(
1135 num_rows, size_type(2), fad_size,
i, size_type(0));
1136 h_v2(i) = generate_fad<FadType>(
1137 num_rows, size_type(2), fad_size,
i, size_type(1));
1139 Kokkos::deep_copy(v1, h_v1);
1140 Kokkos::deep_copy(v2, h_v2);
1142 ConstViewType cv1 = v1;
1146 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1147 v3 = ViewType (
"view3", num_rows);
1149 v3 = ViewType (
"view3", num_rows, fad_size+1);
1154 host_view_type h_v3 = Kokkos::create_mirror_view(v3);
1155 Kokkos::deep_copy(h_v3, v3);
1159 for (size_type
i=0;
i<num_rows; ++
i) {
1161 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(0));
1163 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(1));
1165 success = success &&
checkFads(f3, h_v3(i), out);
1170 Kokkos_View_Fad, MultiplyMixed,
FadType, Layout, Device )
1172 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
1173 typedef typename ViewType::size_type size_type;
1174 typedef typename ViewType::HostMirror host_view_type;
1176 const size_type num_rows = 2;
1180 FadType f0 = generate_fad<FadType>(
1181 num_rows, size_type(2), fad_size, size_type(0), size_type(0));
1182 FadType f1 = generate_fad<FadType>(
1183 num_rows, size_type(2), fad_size, size_type(1), size_type(0));
1185 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1186 h_v = host_view_type (
"view1", num_rows);
1188 h_v = host_view_type (
"view1", num_rows, fad_size+1);
1201 Kokkos_View_Fad, AtomicAdd,
FadType, Layout, Device )
1203 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
1204 typedef Kokkos::View<FadType,Layout,Device> ScalarViewType;
1205 typedef typename ViewType::size_type size_type;
1206 typedef typename ScalarViewType::HostMirror host_scalar_view_type;
1213 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1214 v = ViewType (
"view", num_rows);
1216 v = ViewType (
"view", num_rows, fad_size+1);
1218 Kokkos::deep_copy(v, 2.3456);
1220 Kokkos::parallel_for(Kokkos::RangePolicy<Device>(0, num_rows), KOKKOS_LAMBDA(
const size_type
i) {
1221 for (size_type j = 0; j < fad_size; ++j)
1227 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1228 s = ScalarViewType (
"scalar view");
1230 s = ScalarViewType (
"scalar view", fad_size+1);
1237 host_scalar_view_type hs = Kokkos::create_mirror_view(s);
1238 Kokkos::deep_copy(hs, s);
1241 auto hv = Kokkos::create_mirror_view(v);
1242 Kokkos::deep_copy(hv, v);
1249 Kokkos_View_Fad, Rank8,
FadType, Layout, Device )
1251 typedef Kokkos::View<FadType*******,Layout,Device> ViewType;
1252 typedef typename ViewType::size_type size_type;
1253 typedef typename ViewType::HostMirror host_view_type;
1259 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1260 v = ViewType (
"view", 100, 1, 2, 3, 4, 5, 6);
1262 v = ViewType (
"view", 100, 1, 2, 3, 4, 5, 6, fad_size+1);
1264 host_view_type h_v = Kokkos::create_mirror_view(v);
1265 typename host_view_type::array_type h_a = h_v;
1266 Kokkos::deep_copy(h_a, 1.0);
1269 h_v(99,0,1,2,3,4,5) = f1;
1270 FadType f2 = h_v(99,0,1,2,3,4,5);
1277 Kokkos_View_Fad, Roger,
FadType, Layout, Device )
1279 Kokkos::View<FadType*,Layout,Device>
a;
1280 Kokkos::View<FadType**,Layout,Device> b;
1281 Kokkos::View<FadType***,Layout,Device>
c;
1282 Kokkos::View<FadType****,Layout,Device> d;
1283 Kokkos::View<FadType*****,Layout,Device> e;
1284 Kokkos::View<FadType******,Layout,Device>
f;
1285 Kokkos::View<FadType*******,Layout,Device>
g;
1287 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1288 a = Kokkos::View<FadType*,Layout,Device>(
"a",4);
1289 b = Kokkos::View<FadType**,Layout,Device> (
"b",4,4);
1290 c = Kokkos::View<FadType***,Layout,Device> (
"c",4,4,4);
1291 d = Kokkos::View<FadType****,Layout,Device> (
"d",4,4,4,4);
1292 e = Kokkos::View<FadType*****,Layout,Device> (
"e",4,4,4,4,4);
1293 f = Kokkos::View<FadType******,Layout,Device> (
"f",4,4,4,4,4,4);
1294 g = Kokkos::View<FadType*******,Layout,Device> (
"g",4,4,4,4,4,4,4);
1297 a = Kokkos::View<FadType*,Layout,Device>(
"a",4,fad_size+1);
1298 b = Kokkos::View<FadType**,Layout,Device> (
"b",4,4,fad_size+1);
1299 c = Kokkos::View<FadType***,Layout,Device> (
"c",4,4,4,fad_size+1);
1300 d = Kokkos::View<FadType****,Layout,Device> (
"d",4,4,4,4,fad_size+1);
1301 e = Kokkos::View<FadType*****,Layout,Device> (
"e",4,4,4,4,4,fad_size+1);
1302 f = Kokkos::View<FadType******,Layout,Device> (
"f",4,4,4,4,4,4,fad_size+1);
1303 g = Kokkos::View<FadType*******,Layout,Device> (
"g",4,4,4,4,4,4,4,fad_size+1);
1306 typedef typename Device::memory_space memory_space;
1307 const bool is_accessible =
1308 Kokkos::Impl::MemorySpaceAccess<Kokkos::HostSpace,
1309 memory_space>::accessible;
1310 if (is_accessible) {
1312 f(0,0,0,0,0,0) =
FadType(1.0);
1313 g(0,0,0,0,0,0,0) =
FadType(1.0);
1321 Kokkos_View_Fad, AssignDifferentStrides,
FadType, Layout, Device )
1323 typedef Kokkos::View<FadType**,Layout,Device> ViewType1;
1324 typedef Kokkos::View<FadType*,Layout,Device> ViewType2;
1325 typedef typename ViewType1::size_type size_type;
1326 typedef typename ViewType1::HostMirror host_view_type1;
1327 typedef typename ViewType2::HostMirror host_view_type2;
1335 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1336 v1 = ViewType1 (
"view1", num_rows, num_cols);
1338 v1 = ViewType1 (
"view1", num_rows, num_cols, fad_size+1);
1340 host_view_type1 h_v1 = Kokkos::create_mirror_view(v1);
1341 for (size_type
i=0;
i<num_rows; ++
i) {
1342 for (size_type j=0; j<num_cols; ++j) {
1343 h_v1(
i,j) = generate_fad<FadType>(
1344 num_rows, num_cols, fad_size,
i, j);
1347 Kokkos::deep_copy(v1, h_v1);
1351 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1352 v2 = ViewType2 (
"view2", num_rows);
1354 v2 = ViewType2 (
"view2", num_rows, fad_size+1);
1359 host_view_type2 h_v2 = Kokkos::create_mirror_view(v2);
1360 Kokkos::deep_copy(h_v2, v2);
1364 for (size_type
i=0;
i<num_rows; ++
i) {
1366 generate_fad<FadType>(num_rows, num_cols, fad_size,
i, size_type(1));
1367 success = success &&
checkFads(f, h_v2(i), out);
1372 Kokkos_View_Fad, ScalarValue,
FadType, Layout, Device )
1375 typedef Kokkos::View<FadType,Layout,Device> ViewType1;
1376 typedef Kokkos::View<ScalarType,Layout,Device> ViewType2;
1377 typedef typename ViewType1::size_type size_type;
1378 typedef typename ViewType1::HostMirror host_view_type1;
1379 typedef typename ViewType2::HostMirror host_view_type2;
1385 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1386 v1 = ViewType1 (
"view1");
1388 v1 = ViewType1 (
"view1", fad_size+1);
1390 host_view_type1 h_v1 = Kokkos::create_mirror_view(v1);
1391 h_v1() = generate_fad<FadType>(1, 1, fad_size, 0, 0);
1392 Kokkos::deep_copy(v1, h_v1);
1395 ViewType2 v2 = ViewType2 (
"view2");
1396 Kokkos::parallel_for(Kokkos::RangePolicy<Device>(0,1),
1397 KOKKOS_LAMBDA(
const size_type
i)
1403 host_view_type2 h_v2 = Kokkos::create_mirror_view(v2);
1404 Kokkos::deep_copy(h_v2, v2);
1411 #if defined(HAVE_SACADO_KOKKOS) && defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
1414 Kokkos_View_Fad, DynRankDimensionScalar,
FadType, Layout, Device )
1416 typedef Kokkos::DynRankView<double,Layout,Device> DoubleViewType;
1417 typedef Kokkos::DynRankView<FadType,Layout,Device> FadViewType;
1418 typedef typename FadViewType::size_type size_type;
1424 DoubleViewType v1(
"view1", num_rows);
1425 FadViewType v2 (
"view2", num_rows, fad_size+1);
1433 Kokkos_View_Fad, DynRankAssignStatic0,
FadType, Layout, Device )
1435 typedef Kokkos::View<FadType,Layout,Device> StaticViewType;
1436 typedef Kokkos::DynRankView<FadType,Layout,Device> DynamicViewType;
1437 typedef typename StaticViewType::size_type size_type;
1444 StaticViewType v1(
"view", fad_size+1);
1445 auto h_v1 = Kokkos::create_mirror_view(v1);
1446 h_v1() = generate_fad<FadType>(num_rows, num_cols, fad_size, size_type(0), size_type(0));
1447 Kokkos::deep_copy(v1, h_v1);
1450 DynamicViewType v2 = v1;
1453 auto h_v2 = Kokkos::create_mirror_view(v2);
1454 Kokkos::deep_copy(h_v2, v2);
1462 generate_fad<FadType>(num_rows, num_cols, fad_size, size_type(0), size_type(0));
1463 success = success &&
checkFads(f, h_v2(), out);
1467 Kokkos_View_Fad, DynRankAssignStatic1,
FadType, Layout, Device )
1469 typedef Kokkos::View<FadType*,Layout,Device> StaticViewType;
1470 typedef Kokkos::DynRankView<FadType,Layout,Device> DynamicViewType;
1471 typedef typename StaticViewType::size_type size_type;
1478 StaticViewType v1(
"view", num_rows, fad_size+1);
1479 auto h_v1 = Kokkos::create_mirror_view(v1);
1480 for (size_type
i=0;
i<num_rows; ++
i)
1482 generate_fad<FadType>(num_rows, num_cols, fad_size,
i, size_type(0));
1483 Kokkos::deep_copy(v1, h_v1);
1486 DynamicViewType v2 = v1;
1489 auto h_v2 = Kokkos::create_mirror_view(v2);
1490 Kokkos::deep_copy(h_v2, v2);
1499 for (size_type i=0; i<num_rows; ++
i) {
1501 generate_fad<FadType>(num_rows, num_cols, fad_size,
i, size_type(0));
1502 success = success &&
checkFads(f, h_v2(i), out);
1507 Kokkos_View_Fad, DynRankAssignStatic2,
FadType, Layout, Device )
1509 typedef Kokkos::View<FadType**,Layout,Device> StaticViewType;
1510 typedef Kokkos::DynRankView<FadType,Layout,Device> DynamicViewType;
1511 typedef typename StaticViewType::size_type size_type;
1518 StaticViewType v1(
"view", num_rows, num_cols, fad_size+1);
1519 auto h_v1 = Kokkos::create_mirror_view(v1);
1520 for (size_type i=0; i<num_rows; ++
i)
1521 for (size_type j=0; j<num_cols; ++j)
1522 h_v1(i,j) = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1523 Kokkos::deep_copy(v1, h_v1);
1526 DynamicViewType v2 = v1;
1529 auto h_v2 = Kokkos::create_mirror_view(v2);
1530 Kokkos::deep_copy(h_v2, v2);
1541 for (size_type i=0; i<num_rows; ++
i) {
1542 for (size_type j=0; j<num_cols; ++j) {
1543 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1544 success = success &&
checkFads(f, h_v2(i,j), out);
1550 Kokkos_View_Fad, DynRankMultiply,
FadType, Layout, Device )
1552 typedef Kokkos::DynRankView<FadType,Layout,Device> ViewType;
1553 typedef typename ViewType::size_type size_type;
1554 typedef typename ViewType::HostMirror host_view_type;
1560 ViewType v1(
"view1", num_rows, fad_size+1);
1561 ViewType v2(
"view2", num_rows, fad_size+1);
1562 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
1563 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
1564 for (size_type i=0; i<num_rows; ++
i) {
1565 h_v1(i) = generate_fad<FadType>(
1566 num_rows, size_type(2), fad_size,
i, size_type(0));
1567 h_v2(i) = generate_fad<FadType>(
1568 num_rows, size_type(2), fad_size,
i, size_type(1));
1570 Kokkos::deep_copy(v1, h_v1);
1571 Kokkos::deep_copy(v2, h_v2);
1574 ViewType v3(
"view3", num_rows, fad_size+1);
1578 host_view_type h_v3 = Kokkos::create_mirror_view(v3);
1579 Kokkos::deep_copy(h_v3, v3);
1584 for (size_type i=0; i<num_rows; ++
i) {
1586 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(0));
1588 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(1));
1590 success = success &&
checkFads(f3, h_v3(i), out);
1595 Kokkos_View_Fad, SubdynrankviewCol,
FadType, Layout, Device )
1597 typedef Kokkos::DynRankView<FadType,Layout,Device> ViewType;
1598 typedef typename ViewType::size_type size_type;
1599 typedef typename ViewType::HostMirror host_view_type;
1606 ViewType v(
"view", num_rows, num_cols, fad_size+1);
1607 host_view_type h_v = Kokkos::create_mirror_view(v);
1608 for (size_type i=0; i<num_rows; ++
i) {
1609 for (size_type j=0; j<num_cols; ++j) {
1610 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1614 Kokkos::deep_copy(v, h_v);
1618 auto s = Kokkos::subdynrankview(v, Kokkos::ALL(), col);
1621 typedef decltype(s) SubviewType;
1622 typedef typename SubviewType::HostMirror HostSubviewType;
1628 HostSubviewType h_s = Kokkos::subdynrankview(h_v, Kokkos::ALL(), col);
1632 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(s), fad_size+1, out, success);
1633 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(h_s), fad_size+1, out, success);
1634 TEUCHOS_TEST_EQUALITY(h_s.extent(0), num_rows, out, success);
1635 TEUCHOS_TEST_EQUALITY(h_s.extent(1), 1, out, success);
1636 TEUCHOS_TEST_EQUALITY(h_s.extent(7), 1, out, success);
1638 for (size_type i=0; i<num_rows; ++i) {
1639 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, col);
1640 success = success &&
checkFads(f, h_s(i), out);
1645 Kokkos_View_Fad, SubdynrankviewRow,
FadType, Layout, Device )
1647 typedef Kokkos::DynRankView<FadType,Layout,Device> ViewType;
1648 typedef typename ViewType::size_type size_type;
1649 typedef typename ViewType::HostMirror host_view_type;
1653 const size_type num_planes = 9;
1657 ViewType v(
"view", num_rows, num_cols, num_planes, fad_size+1);
1658 host_view_type h_v = Kokkos::create_mirror_view(v);
1659 for (size_type i=0; i<num_rows; ++
i) {
1660 for (size_type j=0; j<num_cols; ++j) {
1661 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1662 for (size_type k=0; k<num_planes; ++k) {
1663 h_v(i,j,k) = (k+1)*f;
1667 Kokkos::deep_copy(v, h_v);
1671 auto s = Kokkos::subdynrankview(v, row, Kokkos::ALL(), Kokkos::ALL());
1674 typedef decltype(s) SubviewType;
1675 typedef typename SubviewType::HostMirror HostSubviewType;
1681 HostSubviewType h_s =
1682 Kokkos::subdynrankview(h_v, row, Kokkos::ALL(), Kokkos::ALL());
1686 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(s), fad_size+1, out, success);
1687 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(h_s), fad_size+1, out, success);
1688 TEUCHOS_TEST_EQUALITY(h_s.extent(0), num_cols, out, success);
1689 TEUCHOS_TEST_EQUALITY(h_s.extent(1), num_planes, out, success);
1690 TEUCHOS_TEST_EQUALITY(h_s.extent(2), 1, out, success);
1691 TEUCHOS_TEST_EQUALITY(h_s.extent(7), 1, out, success);
1693 for (size_type j=0; j<num_cols; ++j) {
1694 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, row, j);
1695 for (size_type k=0; k<num_planes; ++k) {
1697 success = success &&
checkFads(g, h_s(j,k), out);
1703 Kokkos_View_Fad, SubdynrankviewScalar,
FadType, Layout, Device )
1705 typedef Kokkos::DynRankView<FadType,Layout,Device> ViewType;
1706 typedef typename ViewType::size_type size_type;
1707 typedef typename ViewType::HostMirror host_view_type;
1714 ViewType v(
"view", num_rows, num_cols, fad_size+1);
1715 host_view_type h_v = Kokkos::create_mirror_view(v);
1716 for (size_type i=0; i<num_rows; ++
i) {
1717 for (size_type j=0; j<num_cols; ++j) {
1718 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1722 Kokkos::deep_copy(v, h_v);
1727 auto s = Kokkos::subdynrankview(v, row, col);
1730 typedef decltype(s) SubviewType;
1731 typedef typename SubviewType::HostMirror HostSubviewType;
1737 HostSubviewType h_s = Kokkos::subdynrankview(h_v, row, col);
1741 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(s), fad_size+1, out, success);
1742 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(h_s), fad_size+1, out, success);
1744 success = success &&
checkFads(f, h_s(), out);
1750 Kokkos_View_Fad, DynRankDimensionScalar,
FadType, Layout, Device ) {}
1752 Kokkos_View_Fad, DynRankAssignStatic0,
FadType, Layout, Device ) {}
1754 Kokkos_View_Fad, DynRankAssignStatic1,
FadType, Layout, Device ) {}
1756 Kokkos_View_Fad, DynRankAssignStatic2,
FadType, Layout, Device ) {}
1758 Kokkos_View_Fad, DynRankMultiply,
FadType, Layout, Device ) {}
1760 Kokkos_View_Fad, SubdynrankviewCol,
FadType, Layout, Device ) {}
1762 Kokkos_View_Fad, SubdynrankviewRow,
FadType, Layout, Device ) {}
1764 Kokkos_View_Fad, SubdynrankviewScalar,
FadType, Layout, Device ) {}
1769 Kokkos_View_Fad, Subview,
FadType, Layout, Device )
1771 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
1772 typedef typename ViewType::size_type size_type;
1773 typedef typename ViewType::HostMirror host_view_type;
1781 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1782 v = ViewType (
"view", num_rows, num_cols);
1784 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
1786 host_view_type h_v = Kokkos::create_mirror_view(v);
1787 for (size_type i=0; i<num_rows; ++
i) {
1788 for (size_type j=0; j<num_cols; ++j) {
1789 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1793 Kokkos::deep_copy(v, h_v);
1797 auto s = Kokkos::subview(v, Kokkos::ALL(), col);
1800 typedef decltype(s) SubviewType;
1801 typedef typename SubviewType::HostMirror HostSubviewType;
1807 HostSubviewType h_s = Kokkos::subview(h_v, Kokkos::ALL(), col);
1811 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
1815 for (size_type i=0; i<num_rows; ++
i) {
1816 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, col);
1817 success = success &&
checkFads(f, h_s(i), out);
1822 Kokkos_View_Fad, Subview2,
FadType, Layout, Device )
1824 typedef Kokkos::View<FadType***,Layout,Device> ViewType;
1825 typedef typename ViewType::HostMirror host_view_type;
1831 const int num_cell = 5;
1832 const int num_qp = 4;
1833 const int num_dim = 3;
1834 const int num_deriv = 2;
1838 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1839 v = host_view_type (
"view", num_cell, num_qp, num_dim);
1841 v = host_view_type (
"view", num_cell, num_qp, num_dim, num_deriv+1);
1843 for (
int cell=0; cell < num_cell; ++cell) {
1844 for (
int qp=0; qp < num_qp; ++qp) {
1845 for (
int dim = 0; dim < num_dim; ++dim) {
1846 v(cell,qp,dim).val() = 100.*cell + 10.*qp + 1.*dim;
1847 for (
int deriv = 0; deriv < num_deriv; ++deriv) {
1848 v(cell,qp,dim).fastAccessDx(deriv) = v(cell,qp,dim).val() + (1.0*deriv)/10.;
1856 out <<
"checking subview(v,ALL,*,*)..." << std::endl;
1857 for (
int qp=0; qp < num_qp; ++qp) {
1858 for (
int dim=0; dim < num_dim; ++dim) {
1859 auto v_tmp = subview(v,Kokkos::ALL(),qp,dim);
1860 for (
int cell=0; cell < num_cell; ++cell) {
1861 out <<
"\tChecking (" << cell <<
"," << qp <<
"," << dim <<
")" << std::endl;
1862 success = success &&
checkFads(v(cell,qp,dim), v_tmp(cell), out);
1867 out <<
"checking subview(v,*,ALL,*)..." << std::endl;
1868 for (
int cell=0; cell < num_cell; ++cell) {
1869 for (
int dim=0; dim < num_dim; ++dim) {
1870 auto v_tmp = subview(v,cell,Kokkos::ALL(),dim);
1871 for (
int qp=0; qp < num_qp; ++qp) {
1872 out <<
"\tChecking (" << cell <<
"," << qp <<
"," << dim <<
")" << std::endl;
1873 success = success &&
checkFads(v(cell,qp,dim), v_tmp(qp), out);
1878 out <<
"checking subview(v,*,*,ALL)..." << std::endl;
1879 for (
int cell=0; cell < num_cell; ++cell) {
1880 for (
int qp=0; qp < num_qp; ++qp) {
1881 auto v_tmp = subview(v,cell,qp,Kokkos::ALL());
1882 for (
int dim=0; dim < num_dim; ++dim) {
1883 out <<
"\tChecking (" << cell <<
"," << qp <<
"," << dim <<
")" << std::endl;
1884 success = success &&
checkFads(v(cell,qp,dim), v_tmp(dim), out);
1889 out <<
"checking subview(v,ALL,ALL,*)..." << std::endl;
1890 for (
int dim=0; dim < num_dim; ++dim) {
1891 auto v_tmp = subview(v,Kokkos::ALL(),Kokkos::ALL(),dim);
1892 for (
int cell=0; cell < num_cell; ++cell) {
1893 for (
int qp=0; qp < num_qp; ++qp) {
1894 out <<
"\tChecking (" << cell <<
"," << qp <<
"," << dim <<
")" << std::endl;
1895 success = success &&
checkFads(v(cell,qp,dim), v_tmp(cell,qp), out);
1900 out <<
"checking subview(v,*,ALL,ALL)..." << std::endl;
1901 for (
int cell=0; cell < num_cell; ++cell) {
1902 auto v_tmp = subview(v,cell,Kokkos::ALL(),Kokkos::ALL());
1903 for (
int qp=0; qp < num_qp; ++qp) {
1904 for (
int dim=0; dim < num_dim; ++dim) {
1905 out <<
"\tChecking (" << cell <<
"," << qp <<
"," << dim <<
")" << std::endl;
1906 success = success &&
checkFads(v(cell,qp,dim), v_tmp(qp,dim), out);
1911 out <<
"checking subview(v,ALL,*,ALL)..." << std::endl;
1912 for (
int qp=0; qp < num_qp; ++qp) {
1913 auto v_tmp = subview(v,Kokkos::ALL(),qp,Kokkos::ALL());
1914 for (
int cell=0; cell < num_cell; ++cell) {
1915 for (
int dim=0; dim < num_dim; ++dim) {
1916 out <<
"\tChecking (" << cell <<
"," << qp <<
"," << dim <<
")" << std::endl;
1917 success = success &&
checkFads(v(cell,qp,dim), v_tmp(cell,dim), out);
1922 out <<
"checking subview(v,range,range,range)..." << std::endl;
1923 auto v_tmp = subview(v,std::make_pair(1,5),std::make_pair(1,4),std::make_pair(1,3));
1924 for (
int cell=1; cell < num_cell; ++cell) {
1925 for (
int qp=1; qp < num_qp; ++qp) {
1926 for (
int dim=1; dim < num_dim; ++dim) {
1927 out <<
"\tChecking (" << cell <<
"," << qp <<
"," << dim <<
")" << std::endl;
1928 success = success &&
checkFads(v(cell,qp,dim), v_tmp(cell-1,qp-1,dim-1), out);
1934 #ifdef SACADO_NEW_FAD_DESIGN_IS_DEFAULT
1936 Kokkos_View_Fad, ConstViewAssign,
FadType, Layout, Device )
1938 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
1939 typedef Kokkos::View<const FadType,Layout,Device> ConstViewType;
1940 typedef typename ViewType::size_type size_type;
1941 typedef typename ViewType::HostMirror host_view_type;
1942 typedef typename ViewType::execution_space exec_space;
1948 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1949 ViewType v1(
"view1", num_rows);
1951 ViewType v1(
"view1", num_rows, fad_size+1);
1953 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
1954 for (size_type i=0; i<num_rows; ++
i) {
1955 FadType f = generate_fad<FadType>(num_rows, size_type(1), fad_size,
i,
1959 Kokkos::deep_copy(v1, h_v1);
1961 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1962 ViewType v2(
"view2", num_rows);
1964 ViewType v2(
"view2", num_rows, fad_size+1);
1967 static const size_type stride = Kokkos::ViewScalarStride<ViewType>::stride;
1968 #if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
1969 const bool use_team =
1974 #elif defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
1975 const bool use_team =
1980 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
1981 const bool use_team =
1986 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
1987 const bool use_team =
1993 const bool use_team =
false;
1997 typedef Kokkos::TeamPolicy<exec_space> team_policy;
1998 Kokkos::parallel_for(team_policy(num_rows, 1, stride),
1999 KOKKOS_LAMBDA(
typename team_policy::member_type team)
2001 const int i = team.league_rank();
2002 typename ConstViewType::reference_type
x = v1(i);
2007 Kokkos::parallel_for(Kokkos::RangePolicy<exec_space>(0,num_rows),
2008 KOKKOS_LAMBDA(
const int i)
2010 typename ConstViewType::reference_type
x = v1(i);
2016 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
2017 Kokkos::deep_copy(h_v2, v2);
2021 for (size_type i=0; i<num_rows; ++
i) {
2022 FadType f = generate_fad<FadType>(num_rows, size_type(1), fad_size,
i,
2024 success = success &&
checkFads(f, h_v2(i), out);
2029 Kokkos_View_Fad, ConstViewAssign,
FadType, Layout, Device ) {}
2034 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
2036 Kokkos_View_Fad, ShmemSize,
FadType, Layout, Device )
2038 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
2039 typedef typename FadType::value_type value_type;
2040 typedef typename ViewType::size_type size_type;
2047 const size_type shmem_size =
2048 ViewType::shmem_size(num_rows, num_cols, fad_size+1);
2051 const size_type align = 8;
2052 const size_type mask = align - 1;
2054 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2055 v = ViewType (
"view", num_rows, num_cols);
2057 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
2059 const size_type shmem_size_expected =
2065 Kokkos_View_Fad, Unmanaged,
FadType, Layout, Device )
2070 typedef typename FadType::value_type scalar_type;
2071 typedef Kokkos::View<scalar_type***,TestLayout,Device> ViewType;
2072 typedef Kokkos::View<FadType**,TestLayout,Device,Kokkos::MemoryUnmanaged> FadViewType;
2073 typedef typename ViewType::size_type size_type;
2074 typedef typename ViewType::HostMirror host_view_type;
2075 typedef typename FadViewType::HostMirror fad_host_view_type;
2086 v = ViewType (
"view", fad_size+1, num_rows, num_cols);
2087 h_v = Kokkos::create_mirror_view(v);
2088 for (size_type i=0; i<num_rows; ++
i) {
2089 for (size_type j=0; j<num_cols; ++j) {
2090 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2091 for (size_type k=0; k<fad_size; k++)
2092 h_v(k,i,j) = f.dx(k);
2093 h_v(fad_size,i,j) = f.val();
2098 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
2099 h_v = Kokkos::create_mirror_view(v);
2100 for (size_type i=0; i<num_rows; ++
i) {
2101 for (size_type j=0; j<num_cols; ++j) {
2102 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2103 for (size_type k=0; k<fad_size; k++)
2104 h_v(i,j,k) = f.dx(k);
2105 h_v(i,j,fad_size) = f.val();
2109 Kokkos::deep_copy(v, h_v);
2113 fad_host_view_type h_v_fad;
2114 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2115 v_fad = FadViewType ( v.data(), num_rows, num_cols);
2116 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols);
2118 v_fad = FadViewType ( v.data(), num_rows, num_cols, fad_size+1);
2119 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols, fad_size+1);
2123 Kokkos::deep_copy(h_v_fad, v_fad);
2127 for (size_type i=0; i<num_rows; ++
i) {
2128 for (size_type j=0; j<num_cols; ++j) {
2129 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2130 success = success &&
checkFads(f, h_v_fad(i,j), out);
2136 Kokkos_View_Fad, Unmanaged2,
FadType, Layout, Device )
2141 typedef typename FadType::value_type scalar_type;
2142 typedef Kokkos::View<scalar_type***,TestLayout,Device> ViewType;
2143 typedef Kokkos::View<FadType**,TestLayout,Device> FadViewType;
2144 typedef typename ViewType::size_type size_type;
2145 typedef typename ViewType::HostMirror host_view_type;
2146 typedef typename FadViewType::HostMirror fad_host_view_type;
2157 v = ViewType (
"view", fad_size+1, num_rows, num_cols);
2158 h_v = Kokkos::create_mirror_view(v);
2159 for (size_type i=0; i<num_rows; ++
i) {
2160 for (size_type j=0; j<num_cols; ++j) {
2161 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2162 for (size_type k=0; k<fad_size; k++)
2163 h_v(k,i,j) = f.dx(k);
2164 h_v(fad_size,i,j) = f.val();
2169 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
2170 h_v = Kokkos::create_mirror_view(v);
2171 for (size_type i=0; i<num_rows; ++
i) {
2172 for (size_type j=0; j<num_cols; ++j) {
2173 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2174 for (size_type k=0; k<fad_size; k++)
2175 h_v(i,j,k) = f.dx(k);
2176 h_v(i,j,fad_size) = f.val();
2180 Kokkos::deep_copy(v, h_v);
2184 fad_host_view_type h_v_fad;
2185 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2186 v_fad = FadViewType ( v.data(), num_rows, num_cols);
2187 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols);
2189 v_fad = FadViewType ( v.data(), num_rows, num_cols, fad_size+1);
2190 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols, fad_size+1);
2194 Kokkos::deep_copy(h_v_fad, v_fad);
2198 for (size_type i=0; i<num_rows; ++
i) {
2199 for (size_type j=0; j<num_cols; ++j) {
2200 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2201 success = success &&
checkFads(f, h_v_fad(i,j), out);
2207 Kokkos_View_Fad, UnmanagedConst,
FadType, Layout, Device )
2212 typedef typename FadType::value_type scalar_type;
2213 typedef Kokkos::View<scalar_type***,TestLayout,Device> ViewType;
2214 typedef Kokkos::View<const scalar_type***,TestLayout,Device> ConstViewType;
2215 typedef Kokkos::View<FadType**,TestLayout,Device,Kokkos::MemoryUnmanaged> FadViewType;
2216 typedef Kokkos::View<const FadType**,TestLayout,Device,Kokkos::MemoryUnmanaged> ConstFadViewType;
2217 typedef typename ViewType::size_type size_type;
2218 typedef typename ViewType::HostMirror host_view_type;
2219 typedef typename FadViewType::HostMirror fad_host_view_type;
2230 v = ViewType (
"view", fad_size+1, num_rows, num_cols);
2231 h_v = Kokkos::create_mirror_view(v);
2232 for (size_type i=0; i<num_rows; ++
i) {
2233 for (size_type j=0; j<num_cols; ++j) {
2234 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2235 for (size_type k=0; k<fad_size; k++)
2236 h_v(k,i,j) = f.dx(k);
2237 h_v(fad_size,i,j) = f.val();
2242 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
2243 h_v = Kokkos::create_mirror_view(v);
2244 for (size_type i=0; i<num_rows; ++
i) {
2245 for (size_type j=0; j<num_cols; ++j) {
2246 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2247 for (size_type k=0; k<fad_size; k++)
2248 h_v(i,j,k) = f.dx(k);
2249 h_v(i,j,fad_size) = f.val();
2253 Kokkos::deep_copy(v, h_v);
2254 ConstViewType v_const = v;
2258 ConstFadViewType v_fad;
2259 fad_host_view_type h_v_fad;
2260 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2261 v_fad = ConstFadViewType ( v_const.data(), num_rows, num_cols);
2262 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols);
2264 v_fad = ConstFadViewType ( v_const.data(), num_rows, num_cols, fad_size+1);
2265 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols, fad_size+1);
2269 Kokkos::deep_copy(h_v_fad, v_fad);
2273 for (size_type i=0; i<num_rows; ++
i) {
2274 for (size_type j=0; j<num_cols; ++j) {
2275 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2276 success = success &&
checkFads(f, h_v_fad(i,j), out);
2282 Kokkos_View_Fad, UnmanagedConst2,
FadType, Layout, Device )
2286 typedef typename FadType::value_type scalar_type;
2287 typedef Kokkos::View<scalar_type***,TestLayout,Device> ViewType;
2288 typedef Kokkos::View<const scalar_type***,TestLayout,Device> ConstViewType;
2289 typedef Kokkos::View<FadType**,TestLayout,Device> FadViewType;
2290 typedef Kokkos::View<const FadType**,TestLayout,Device> ConstFadViewType;
2291 typedef typename ViewType::size_type size_type;
2292 typedef typename ViewType::HostMirror host_view_type;
2293 typedef typename FadViewType::HostMirror fad_host_view_type;
2304 v = ViewType (
"view", fad_size+1, num_rows, num_cols);
2305 h_v = Kokkos::create_mirror_view(v);
2306 for (size_type i=0; i<num_rows; ++
i) {
2307 for (size_type j=0; j<num_cols; ++j) {
2308 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2309 for (size_type k=0; k<fad_size; k++)
2310 h_v(k,i,j) = f.dx(k);
2311 h_v(fad_size,i,j) = f.val();
2316 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
2317 h_v = Kokkos::create_mirror_view(v);
2318 for (size_type i=0; i<num_rows; ++
i) {
2319 for (size_type j=0; j<num_cols; ++j) {
2320 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2321 for (size_type k=0; k<fad_size; k++)
2322 h_v(i,j,k) = f.dx(k);
2323 h_v(i,j,fad_size) = f.val();
2327 Kokkos::deep_copy(v, h_v);
2328 ConstViewType v_const = v;
2331 ConstFadViewType v_fad;
2332 fad_host_view_type h_v_fad;
2333 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2334 v_fad = ConstFadViewType (v_const.data(), num_rows, num_cols);
2335 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols);
2337 v_fad = ConstFadViewType (v_const.data(), num_rows, num_cols, fad_size+1);
2338 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols, fad_size+1);
2342 Kokkos::deep_copy(h_v_fad, v_fad);
2346 for (size_type i=0; i<num_rows; ++
i) {
2347 for (size_type j=0; j<num_cols; ++j) {
2348 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2349 success = success &&
checkFads(f, h_v_fad(i,j), out);
2357 Kokkos_View_Fad, SFadNoSizeArg,
FadType, Layout, Device )
2359 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
2360 typedef typename ViewType::size_type size_type;
2361 typedef typename ViewType::HostMirror host_view_type;
2368 ViewType v(
"view", num_rows, num_cols);
2369 host_view_type h_v = Kokkos::create_mirror_view(v);
2370 for (size_type i=0; i<num_rows; ++
i) {
2371 for (size_type j=0; j<num_cols; ++j) {
2372 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2376 Kokkos::deep_copy(v, h_v);
2379 Kokkos::deep_copy(h_v, v);
2385 for (size_type i=0; i<num_rows; ++
i) {
2386 for (size_type j=0; j<num_cols; ++j) {
2387 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2388 success = success &&
checkFads(f, h_v(i,j), out);
2394 Kokkos_View_Fad, Partition,
FadType, Layout, Device )
2396 #if !defined(SACADO_VIEW_CUDA_HIERARCHICAL) && !defined(SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
2397 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
2398 typedef typename ViewType::size_type size_type;
2399 typedef typename ViewType::HostMirror host_view_type;
2407 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2408 v = ViewType (
"view", num_rows, num_cols);
2410 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
2412 host_view_type h_v = Kokkos::create_mirror_view(v);
2414 for (size_type i=0; i<num_rows; ++
i) {
2415 for (size_type j=0; j<num_cols; ++j) {
2416 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2420 Kokkos::deep_copy(v, h_v);
2423 Kokkos::deep_copy(h_v, v);
2427 const size_type stride = 2;
2428 auto h_v1 = Kokkos::partition<2>(h_v, 0, stride);
2429 auto h_v2 = Kokkos::partition<2>(h_v, 1, stride);
2432 const size_type fad_size_1 = (fad_size + stride - 0 - 1) / stride;
2433 const size_type fad_size_2 = (fad_size + stride - 1 - 1) / stride;
2437 for (size_type i=0; i<num_rows; ++
i) {
2438 for (size_type j=0; j<num_cols; ++j) {
2439 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2442 for (
unsigned int k=0; k<fad_size_1; ++k)
2443 if (2*k < fad_size) f1.fastAccessDx(k) = f.dx(2*k);
2444 for (
unsigned int k=0; k<fad_size_2; ++k)
2445 if (2*k+1 < fad_size) f2.fastAccessDx(k) = f.dx(2*k+1);
2446 success = success &&
checkFads(f1, h_v1(i,j), out);
2447 success = success &&
checkFads(f2, h_v2(i,j), out);
2454 Kokkos_View_Fad, AssignLayoutContiguousToLayoutStride,
FadType, Layout, Device )
2456 typedef Kokkos::View<FadType**,Kokkos::LayoutContiguous<Layout>,Device> ContViewType;
2457 typedef Kokkos::View<FadType**,Kokkos::LayoutStride,Device> StrideViewType;
2458 typedef typename ContViewType::size_type size_type;
2459 typedef typename ContViewType::HostMirror cont_host_view_type;
2460 typedef typename StrideViewType::HostMirror stride_host_view_type;
2468 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2469 v = ContViewType (
"view", num_rows, num_cols);
2471 v = ContViewType (
"view", num_rows, num_cols, fad_size+1);
2473 cont_host_view_type h_v = Kokkos::create_mirror_view(v);
2475 for (size_type i=0; i<num_rows; ++
i) {
2476 for (size_type j=0; j<num_cols; ++j) {
2477 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2481 Kokkos::deep_copy(v, h_v);
2484 StrideViewType vs = v;
2491 stride_host_view_type h_vs = h_v;
2498 for (size_type i=0; i<num_rows; ++
i) {
2499 for (size_type j=0; j<num_cols; ++j) {
2500 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2501 success = success &&
checkFads(f, h_vs(i,j), out);
2507 Kokkos_View_Fad, CommonViewAllocMixedSpec,
FadType, Layout, Device )
2509 typedef Kokkos::View<FadType**,Kokkos::LayoutContiguous<Layout>,Device> ContViewType;
2510 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
2511 typedef typename ContViewType::size_type size_type;
2519 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2520 v1 = ContViewType (
"view", num_rows, num_cols);
2522 v1 = ContViewType (
"view", num_rows, num_cols, fad_size+1);
2526 auto cprop = Kokkos::common_view_alloc_prop(v1);
2527 ViewType v2(Kokkos::view_alloc(
"v2",cprop), num_rows, num_cols);
2539 Kokkos_View_Fad, ShmemSize,
FadType, Layout, Device )
2541 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
2542 typedef typename ViewType::size_type size_type;
2548 const size_type shmem_size =
2549 ViewType::shmem_size(num_rows, num_cols);
2552 static const size_type align = 8;
2553 static const size_type mask = align - 1;
2554 const size_type shmem_size_expected =
2560 Kokkos_View_Fad, Unmanaged,
FadType, Layout, Device ) {}
2563 Kokkos_View_Fad, Unmanaged2,
FadType, Layout, Device ) {}
2566 Kokkos_View_Fad, UnmanagedConst,
FadType, Layout, Device ) {}
2569 Kokkos_View_Fad, UnmanagedConst2,
FadType, Layout, Device ) {}
2572 Kokkos_View_Fad, SFadNoSizeArg,
FadType, Layout, Device ) {}
2575 Kokkos_View_Fad, Partition,
FadType, Layout, Device ) {}
2578 Kokkos_View_Fad, AssignLayoutContiguousToLayoutStride,
FadType, Layout, Device ) {}
2581 Kokkos_View_Fad, CommonViewAllocMixedSpec,
FadType, Layout, Device ) {}
2585 #define VIEW_FAD_TESTS_FLD( F, L, D ) \
2586 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Size, F, L, D ) \
2587 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy, F, L, D ) \
2588 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy_ConstantScalar, F, L, D ) \
2589 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy_ConstantZero, F, L, D ) \
2590 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy_ConstantFad, F, L, D ) \
2591 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy_ConstantFadFull, F, L, D ) \
2592 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, LocalDeepCopy, F, L, D ) \
2593 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, LocalDeepCopyTeam, F, L, D ) \
2594 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, ScalarAssign, F, L, D ) \
2595 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, ValueAssign, F, L, D ) \
2596 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Resize, F, L, D ) \
2597 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Unmanaged, F, L, D ) \
2598 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Unmanaged2, F, L, D ) \
2599 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, UnmanagedConst, F, L, D ) \
2600 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, UnmanagedConst2, F, L, D ) \
2601 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Multiply, F, L, D ) \
2602 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, MultiplyUpdate, F, L, D ) \
2603 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, MultiplyConst, F, L, D ) \
2604 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, MultiplyMixed, F, L, D ) \
2605 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Rank8, F, L, D ) \
2606 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Roger, F, L, D ) \
2607 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, AtomicAdd, F, L, D ) \
2608 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, AssignDifferentStrides, F, L, D ) \
2609 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, ScalarValue, F, L, D ) \
2610 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankDimensionScalar, F, L, D ) \
2611 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankAssignStatic0, F, L, D ) \
2612 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankAssignStatic1, F, L, D ) \
2613 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankAssignStatic2, F, L, D ) \
2614 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankMultiply, F, L, D ) \
2615 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, SubdynrankviewCol, F, L, D ) \
2616 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, SubdynrankviewRow, F, L, D ) \
2617 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, SubdynrankviewScalar, F, L, D ) \
2618 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Subview, F, L, D ) \
2619 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Subview2, F, L, D ) \
2620 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, ShmemSize, F, L, D ) \
2621 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, ConstViewAssign, F, L, D )
2623 #define VIEW_FAD_TESTS_SFLD( F, L, D ) \
2624 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, SFadNoSizeArg, F, L, D )
2626 #define VIEW_FAD_TESTS_FDI( F, D ) \
2627 using Kokkos::LayoutLeft; \
2628 using Kokkos::LayoutRight; \
2629 VIEW_FAD_TESTS_FLD( F, LayoutLeft, D ) \
2630 VIEW_FAD_TESTS_FLD( F, LayoutRight, D ) \
2631 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, AssignLayoutContiguousToLayoutStride, F, LayoutLeft, D ) \
2632 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, AssignLayoutContiguousToLayoutStride, F, LayoutRight, D ) \
2633 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, CommonViewAllocMixedSpec, F, LayoutLeft, D ) \
2634 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, CommonViewAllocMixedSpec, F, LayoutRight, D )
2636 #define VIEW_FAD_TESTS_SFDI( F, D ) \
2637 using Kokkos::LayoutLeft; \
2638 using Kokkos::LayoutRight; \
2639 VIEW_FAD_TESTS_SFLD( F, LayoutLeft, D ) \
2640 VIEW_FAD_TESTS_SFLD( F, LayoutRight, D )
2642 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
2645 #define VIEW_FAD_TESTS_FDC( F, D ) \
2646 VIEW_FAD_TESTS_FLD( F, LeftContiguous, D ) \
2647 VIEW_FAD_TESTS_FLD( F, RightContiguous, D ) \
2648 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Partition, F, LeftContiguous, D ) \
2649 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Partition, F, RightContiguous, D )
2651 #define VIEW_FAD_TESTS_SFDC( F, D ) \
2652 VIEW_FAD_TESTS_SFLD( F, LeftContiguous, D ) \
2653 VIEW_FAD_TESTS_SFLD( F, RightContiguous, D )
2655 #define VIEW_FAD_TESTS_FDC( F, D )
2656 #define VIEW_FAD_TESTS_SFDC( F, D )
2659 #define VIEW_FAD_TESTS_FD( F, D ) \
2660 VIEW_FAD_TESTS_FDI( F, D ) \
2661 VIEW_FAD_TESTS_FDC( F, D )
2663 #define VIEW_FAD_TESTS_SFD( F, D ) \
2664 VIEW_FAD_TESTS_SFDI( F, D ) \
2665 VIEW_FAD_TESTS_SFDC( F, D )
2688 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC) && SACADO_TEST_DFAD
2689 #define VIEW_FAD_TESTS_D( D ) \
2690 VIEW_FAD_TESTS_FD( SFadType, D ) \
2691 VIEW_FAD_TESTS_FD( SLFadType, D ) \
2692 VIEW_FAD_TESTS_FD( DFadType, D ) \
2693 VIEW_FAD_TESTS_SFD( SFadType, D )
2713 #define VIEW_FAD_TESTS_D( D ) \
2714 VIEW_FAD_TESTS_FD( SFadType, D ) \
2715 VIEW_FAD_TESTS_FD( SLFadType, D ) \
2716 VIEW_FAD_TESTS_SFD( SFadType, D )
SACADO_INLINE_FUNCTION ScalarType< T >::type scalarValue(const T &x)
A simple template function for invoking ScalarValue<>
InputViewType::size_type size_type
team_policy_type::member_type team_handle
Kokkos::TeamPolicy< execution_space > team_policy_type
static const size_type stride
ViewType::value_type::value_type ScalarType
ViewType::execution_space execution_space
Kokkos::TeamPolicy< execution_space > team_policy_type
static const size_type stride
ViewType::execution_space execution_space
KOKKOS_INLINE_FUNCTION void operator()(const team_handle &team) const
ViewType::size_type size_type
Kokkos::LayoutContiguous< Kokkos::LayoutRight > RightContiguous
Kokkos::RangePolicy< execution_space > range_policy_type
ViewType::value_type ValueType
Kokkos::LayoutContiguous< Kokkos::LayoutLeft > LeftContiguous
static const size_type stride
#define TEUCHOS_TEST_FLOATING_EQUALITY(v1, v2, tol, out, success)
KOKKOS_INLINE_FUNCTION void operator()(const team_handle &team) const
const int global_fad_size
KOKKOS_INLINE_FUNCTION void operator()(const size_type i) const
#define VIEW_FAD_TESTS_SFD(F, D)
KOKKOS_INLINE_FUNCTION void operator()(const size_type i) const
Sacado::Fad::DFad< double > FadType
KOKKOS_INLINE_FUNCTION void operator()(const size_type i) const
#define VIEW_FAD_TESTS_FD(F, D)
const InputViewType1 m_v1
static const size_type stride
ViewType::size_type size_type
InputViewType::execution_space execution_space
static void apply(const InputViewType v1, const OutputViewType v2, const size_type col)
team_policy_type::member_type team_handle
bool checkFads(const FadType1 &x, const FadType2 &x2, Teuchos::FancyOStream &out, double tol=1.0e-15)
const int global_num_rows
Kokkos::RangePolicy< execution_space > range_policy_type
KOKKOS_INLINE_FUNCTION void operator()(const size_type i) const
ViewType::execution_space execution_space
scalar generate_fad(const size_t n0, const size_t n1, const size_t n2, const size_t n3, const int fad_size, const size_t i0, const size_t i1, const size_t i2, const size_t i3, const int i_fad)
Sacado::Fad::SFad< double, fad_dim > SFadType
const OutputViewType m_v2
TEUCHOS_UNIT_TEST_TEMPLATE_3_DECL(Kokkos_View_FadFad, DeepCopy, FadFadType, Layout, Device)
AssignRank2Rank1Kernel(const InputViewType v1, const OutputViewType v2, const size_type col)
expr expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c *expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr2 expr1 expr2 expr1 expr1 expr1 c
team_policy_type::member_type team_handle
const int global_num_cols
KOKKOS_INLINE_FUNCTION void operator()(const team_handle &team) const
ValueAssignKernel(const ViewType &v, const ScalarViewType &s)
ViewType::size_type size_type
GeneralFad< DynamicStorage< T > > DFad
team_policy_type::member_type team_handle
static void apply(const InputViewType1 v1, const InputViewType2 v2, const OutputViewType v3, const bool update=false)
InputViewType1::execution_space execution_space
Kokkos::TeamPolicy< execution_space > team_policy_type
static void apply(const ViewType &v, const ScalarViewType &s)
Sacado::Fad::SLFad< double, fad_dim > SLFadType
Sacado::Fad::DFad< double > DFadType
static void apply(const ViewType &v, const ScalarViewType &s)
Kokkos::TeamPolicy< execution_space > team_policy_type
ScalarAssignKernel(const ViewType &v, const ScalarType &s)
KOKKOS_INLINE_FUNCTION void operator()(const team_handle &team) const
AtomicAddKernel(const ViewType &v, const ScalarViewType &s)
expr expr expr fastAccessDx(i)) FAD_UNARYOP_MACRO(exp
#define TEUCHOS_TEST_EQUALITY(v1, v2, out, success)
KOKKOS_INLINE_FUNCTION void operator()(const team_handle &team) const
team_policy_type::member_type team_handle
Kokkos::ThreadLocalScalarType< ViewType >::type local_scalar_type
static void apply(const ViewType &v, const ScalarType &s)
Kokkos::ThreadLocalScalarType< ViewType >::type local_scalar_type
MultiplyKernel(const InputViewType1 v1, const InputViewType2 v2, const OutputViewType v3, const bool update)
InputViewType1::size_type size_type
Kokkos::RangePolicy< execution_space > range_policy_type
Kokkos::RangePolicy< execution_space > range_policy_type
KOKKOS_INLINE_FUNCTION void operator()(const size_type i) const
GeneralFad< StaticFixedStorage< T, Num > > SFad
const InputViewType2 m_v2
Kokkos::RangePolicy< execution_space > range_policy_type
Kokkos::TeamPolicy< execution_space > team_policy_type
const OutputViewType m_v3