17 static const bool value =
false;
20 template <
typename T,
int N>
27 static const bool value =
false;
35 template <
typename FadType1,
typename FadType2>
48 for (
int i=0;
i<x.size(); ++
i)
54 template <
typename fadtype,
typename ordinal>
57 const ordinal num_cols,
58 const ordinal fad_size,
62 typedef typename fadtype::value_type scalar;
63 fadtype
x(fad_size, scalar(0.0));
65 const scalar x_row = 100.0 + scalar(num_rows) / scalar(row+1);
66 const scalar x_col = 10.0 + scalar(num_cols) / scalar(col+1);
67 x.val() = x_row + x_col;
68 for (ordinal
i=0;
i<fad_size; ++
i) {
69 const scalar x_fad = 1.0 + scalar(fad_size) / scalar(
i+1);
70 x.fastAccessDx(
i) = x_row + x_col + x_fad;
75 #ifndef GLOBAL_FAD_SIZE
76 #define GLOBAL_FAD_SIZE 5
83 template <
typename InputViewType1,
84 typename InputViewType2 = InputViewType1,
85 typename OutputViewType = InputViewType1>
88 typedef typename InputViewType1::size_type
size_type;
99 const InputViewType2 v2,
100 const OutputViewType v3,
105 KOKKOS_INLINE_FUNCTION
113 KOKKOS_INLINE_FUNCTION
116 const size_type i = team.league_rank()*team.team_size() + team.team_rank();
117 if (i <
m_v1.extent(0))
122 static void apply(
const InputViewType1 v1,
123 const InputViewType2 v2,
124 const OutputViewType v3,
125 const bool update =
false) {
128 #if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
129 const size_type stride = Kokkos::ViewScalarStride<InputViewType1>::stride;
130 const bool use_team =
135 #elif defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
136 const size_type stride = team_policy_type::vector_length_max();
137 const bool use_team =
142 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
143 const size_type stride = Kokkos::ViewScalarStride<InputViewType1>::stride;
144 const bool use_team =
149 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
150 const size_type stride = team_policy_type::vector_length_max();
151 const bool use_team =
158 const bool use_team =
false;
162 const size_type team_size = 256 / stride;
174 template <
typename ViewType>
178 typedef typename ViewType::value_type::value_type
ScalarType;
191 KOKKOS_INLINE_FUNCTION
196 KOKKOS_INLINE_FUNCTION
199 const size_type i = team.league_rank()*team.team_size() + team.team_rank();
200 if (i <
m_v.extent(0))
208 #if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
209 const bool use_team =
214 #elif defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
215 const bool use_team =
220 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
221 const bool use_team =
226 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
227 const bool use_team =
233 const bool use_team =
false;
249 template <
typename ViewType,
typename ScalarViewType>
267 KOKKOS_INLINE_FUNCTION
273 KOKKOS_INLINE_FUNCTION
276 const size_type i = team.league_rank()*team.team_size() + team.team_rank();
277 if (i <
m_v.extent(0))
282 static void apply(
const ViewType& v,
const ScalarViewType& s) {
285 #if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
286 const bool use_team =
291 #elif defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
292 const bool use_team =
297 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
298 const bool use_team =
303 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
304 const bool use_team =
310 const bool use_team =
false;
326 template <
typename InputViewType,
327 typename OutputViewType,
328 typename Enabled =
void>
342 const OutputViewType v2,
345 static_assert(
unsigned(InputViewType::rank) == 2 ,
346 "Require rank-2 input view" );
347 static_assert(
unsigned(OutputViewType::rank) == 1 ,
348 "Require rank-1 output view" );
352 KOKKOS_INLINE_FUNCTION
357 KOKKOS_INLINE_FUNCTION
360 const size_type i = team.league_rank()*team.team_size() + team.team_rank();
361 if (i <
m_v1.extent(0))
366 static void apply(
const InputViewType v1,
367 const OutputViewType v2,
371 #if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
372 const bool use_team =
377 #elif defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
378 const bool use_team =
383 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
384 const bool use_team =
389 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
390 const bool use_team =
396 const bool use_team =
false;
412 template <
typename ViewType,
typename ScalarViewType>
429 KOKKOS_INLINE_FUNCTION
432 Kokkos::atomic_add(&(
m_s()), x);
435 KOKKOS_INLINE_FUNCTION
438 const size_type i = team.league_rank()*team.team_size() + team.team_rank();
439 if (i <
m_v.extent(0))
444 static void apply(
const ViewType& v,
const ScalarViewType& s) {
447 #if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
448 const bool use_team =
453 #elif defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
454 const bool use_team =
459 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
460 const bool use_team =
465 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
466 const bool use_team =
472 const bool use_team =
false;
488 Kokkos_View_Fad, Size,
FadType, Layout, Device )
490 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
491 typedef typename ViewType::size_type size_type;
497 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
498 v = ViewType(
"view", num_rows);
501 v = ViewType(
"view", num_rows, fad_size+1);
507 Kokkos_View_Fad, DeepCopy,
FadType, Layout, Device )
509 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
510 typedef typename ViewType::size_type size_type;
511 typedef typename ViewType::host_mirror_type host_view_type;
519 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
520 v = ViewType (
"view", num_rows, num_cols);
522 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
524 host_view_type h_v = Kokkos::create_mirror_view(v);
525 for (size_type
i=0;
i<num_rows; ++
i)
526 for (size_type j=0; j<num_cols; ++j)
527 h_v(
i,j) = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
528 Kokkos::deep_copy(v, h_v);
531 host_view_type h_v2 = Kokkos::create_mirror_view(v);
532 Kokkos::deep_copy(h_v2, v);
536 for (size_type i=0; i<num_rows; ++
i) {
537 for (size_type j=0; j<num_cols; ++j) {
538 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
539 success = success &&
checkFads(f, h_v2(i,j), out);
545 Kokkos_View_Fad, DeepCopy_ConstantScalar,
FadType, Layout, Device )
547 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
548 typedef typename ViewType::size_type size_type;
549 typedef typename ViewType::host_mirror_type host_view_type;
550 typedef typename FadType::value_type value_type;
557 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
558 v = ViewType (
"view", num_rows, num_cols);
561 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
563 #if KOKKOS_VERSION >= 40799
564 typename ViewType::type va = v;
566 typename ViewType::array_type va = v;
568 Kokkos::deep_copy( va, 1.0 );
571 value_type
a = 2.3456;
572 Kokkos::deep_copy( v, a );
575 host_view_type hv = Kokkos::create_mirror_view(v);
576 Kokkos::deep_copy(hv, v);
580 for (size_type
i=0;
i<num_rows; ++
i) {
581 for (size_type j=0; j<num_cols; ++j) {
582 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
587 success = success &&
checkFads(f, hv(
i,j), out);
593 Kokkos_View_Fad, DeepCopy_ConstantZero,
FadType, Layout, Device )
595 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
596 typedef typename ViewType::size_type size_type;
597 typedef typename ViewType::host_mirror_type host_view_type;
598 typedef typename FadType::value_type value_type;
605 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
606 v = ViewType (
"view", num_rows, num_cols);
609 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
611 #if KOKKOS_VERSION >= 40799
612 typename ViewType::type va = v;
614 typename ViewType::array_type va = v;
616 Kokkos::deep_copy( va, 1.0 );
620 Kokkos::deep_copy( v, a );
623 host_view_type hv = Kokkos::create_mirror_view(v);
624 Kokkos::deep_copy(hv, v);
628 for (size_type
i=0;
i<num_rows; ++
i) {
629 for (size_type j=0; j<num_cols; ++j) {
630 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
635 success = success &&
checkFads(f, hv(
i,j), out);
641 Kokkos_View_Fad, DeepCopy_ConstantFad,
FadType, Layout, Device )
643 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
644 typedef typename ViewType::size_type size_type;
645 typedef typename ViewType::host_mirror_type host_view_type;
652 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
653 v = ViewType (
"view", num_rows, num_cols);
656 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
658 #if KOKKOS_VERSION >= 40799
659 typename ViewType::type va = v;
661 typename ViewType::array_type va = v;
663 Kokkos::deep_copy( va, 1.0 );
667 Kokkos::deep_copy( v, a );
670 host_view_type hv = Kokkos::create_mirror_view(v);
671 Kokkos::deep_copy(hv, v);
675 for (size_type
i=0;
i<num_rows; ++
i) {
676 for (size_type j=0; j<num_cols; ++j) {
677 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
682 success = success &&
checkFads(f, hv(
i,j), out);
688 Kokkos_View_Fad, DeepCopy_ConstantFadFull,
FadType, Layout, Device )
690 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
691 typedef typename ViewType::size_type size_type;
692 typedef typename ViewType::host_mirror_type host_view_type;
700 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
701 v = ViewType (
"view", num_rows, num_cols);
703 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
705 #if KOKKOS_VERSION >= 40799
706 typename ViewType::type va = v;
708 typename ViewType::array_type va = v;
710 Kokkos::deep_copy( va, 1.0 );
714 for (size_type
i=0;
i<fad_size; ++
i)
715 a.fastAccessDx(
i) = 7.89 + (
i+1);
718 host_view_type hv = Kokkos::create_mirror_view(v);
719 Kokkos::deep_copy(hv, a);
723 for (size_type
i=0;
i<num_rows; ++
i) {
724 for (size_type j=0; j<num_cols; ++j) {
725 success = success &&
checkFads(a, hv(
i,j), out);
731 Kokkos_View_Fad, LocalDeepCopy,
FadType, Layout, Device )
733 typedef Kokkos::View<FadType***,Layout,Device> ViewType;
734 typedef Kokkos::View<FadType,Layout,Device> ScalarViewType;
735 typedef typename ViewType::size_type size_type;
736 typedef typename ViewType::host_mirror_type host_view_type;
737 typedef typename ScalarViewType::host_mirror_type host_scalar_view_type;
741 const size_type num_slices = 10;
746 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
747 v = ViewType (
"view", num_rows, num_cols, num_slices);
749 v = ViewType (
"view", num_rows, num_cols, num_slices, fad_size+1);
751 #if KOKKOS_VERSION >= 40799
752 typename ViewType::type va = v;
754 typename ViewType::array_type va = v;
756 Kokkos::deep_copy( va, 1.0 );
761 for (size_type
i=0;
i<fad_size; ++
i)
762 a.fastAccessDx(
i) = 7.89 + (
i+1);
763 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
764 ScalarViewType a_view(
"a");
766 ScalarViewType a_view(
"a", fad_size+1);
768 host_scalar_view_type ha_view = Kokkos::create_mirror_view(a_view);
770 Kokkos::deep_copy( a_view, ha_view );
773 Kokkos::parallel_for(Kokkos::RangePolicy<Device>(0,num_rows),
774 KOKKOS_LAMBDA(
const int i)
777 Kokkos::Experimental::local_deep_copy(s,a_view());
781 host_view_type hv = Kokkos::create_mirror_view(v);
782 Kokkos::deep_copy(hv, a);
786 for (size_type i=0; i<num_rows; ++
i) {
787 for (size_type j=0; j<num_cols; ++j) {
788 for (size_type k=0; k<num_slices; ++k) {
789 success = success &&
checkFads(a, hv(i,j,k), out);
796 Kokkos_View_Fad, LocalDeepCopyTeam,
FadType, Layout, Device )
798 typedef Kokkos::View<FadType***,Layout,Device> ViewType;
799 typedef Kokkos::View<FadType,Layout,Device> ScalarViewType;
800 typedef typename ViewType::size_type size_type;
801 typedef typename ViewType::host_mirror_type host_view_type;
802 typedef typename ScalarViewType::host_mirror_type host_scalar_view_type;
806 const size_type num_slices = 10;
811 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
812 v = ViewType (
"view", num_rows, num_cols, num_slices);
814 v = ViewType (
"view", num_rows, num_cols, num_slices, fad_size+1);
816 #if KOKKOS_VERSION >= 40799
817 typename ViewType::type va = v;
819 typename ViewType::array_type va = v;
821 Kokkos::deep_copy( va, 1.0 );
826 for (size_type
i=0;
i<fad_size; ++
i)
827 a.fastAccessDx(
i) = 7.89 + (
i+1);
828 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
829 ScalarViewType a_view(
"a");
831 ScalarViewType a_view(
"a", fad_size+1);
833 host_scalar_view_type ha_view = Kokkos::create_mirror_view(a_view);
835 Kokkos::deep_copy( a_view, ha_view );
838 typedef Kokkos::TeamPolicy<Device> Policy;
839 static const size_type stride = Kokkos::ViewScalarStride<ViewType>::stride;
840 Kokkos::parallel_for(Policy(num_rows,Kokkos::AUTO,stride),
841 KOKKOS_LAMBDA(
const typename Policy::member_type& team)
843 int i = team.league_rank();
845 Kokkos::Experimental::local_deep_copy(team,s,a_view());
849 host_view_type hv = Kokkos::create_mirror_view(v);
850 Kokkos::deep_copy(hv, a);
854 for (size_type
i=0;
i<num_rows; ++
i) {
855 for (size_type j=0; j<num_cols; ++j) {
856 for (size_type k=0; k<num_slices; ++k) {
857 success = success &&
checkFads(a, hv(
i,j,k), out);
864 Kokkos_View_Fad, ScalarAssign,
FadType, Layout, Device )
866 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
867 typedef typename ViewType::size_type size_type;
868 typedef typename ViewType::host_mirror_type host_view_type;
869 typedef typename FadType::value_type value_type;
875 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
876 v = ViewType (
"view", num_rows);
879 v = ViewType (
"view", num_rows, fad_size+1);
881 #if KOKKOS_VERSION >= 40799
882 typename ViewType::type va = v;
884 typename ViewType::array_type va = v;
886 Kokkos::deep_copy( va, 1.0 );
889 value_type
a = 2.3456;
893 host_view_type hv = Kokkos::create_mirror_view(v);
894 Kokkos::deep_copy(hv, v);
898 for (size_type
i=0;
i<num_rows; ++
i) {
899 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
904 success = success &&
checkFads(f, hv(
i), out);
909 Kokkos_View_Fad, ValueAssign,
FadType, Layout, Device )
911 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
912 typedef Kokkos::View<FadType,Layout,Device> ScalarViewType;
913 typedef typename ViewType::size_type size_type;
914 typedef typename ViewType::host_mirror_type host_view_type;
915 typedef typename ScalarViewType::host_mirror_type host_scalar_view_type;
923 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
924 v = ViewType (
"view", num_rows);
925 a = ScalarViewType (
"fad");
927 v = ViewType (
"view", num_rows, fad_size+1);
928 a = ScalarViewType (
"fad", fad_size+1);
930 #if KOKKOS_VERSION >= 40799
931 typename ViewType::type va = v;
933 typename ViewType::array_type va = v;
935 Kokkos::deep_copy( va, 1.0 );
938 Kokkos::deep_copy(a, 2.3456);
940 Kokkos::parallel_for(Kokkos::RangePolicy< Device>(0, fad_size), KOKKOS_LAMBDA(
const int i) {
941 a().fastAccessDx(i) = 7.89 +
i;
949 host_view_type hv = Kokkos::create_mirror_view(v);
950 Kokkos::deep_copy(hv, v);
952 host_scalar_view_type ha = Kokkos::create_mirror_view(a);
953 Kokkos::deep_copy(ha, a);
957 for (size_type i=0; i<num_rows; ++
i) {
958 success = success &&
checkFads(ha(), hv(i), out);
963 Kokkos_View_Fad, Resize,
FadType, Layout, Device )
965 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
966 typedef typename ViewType::size_type size_type;
967 typedef typename ViewType::host_mirror_type host_view_type;
975 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
976 v = ViewType (
"view", num_rows, num_cols);
978 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
980 host_view_type h_v = Kokkos::create_mirror_view(v);
981 for (size_type
i=0;
i<num_rows; ++
i)
982 for (size_type j=0; j<num_cols; ++j)
983 h_v(
i,j) = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
984 Kokkos::deep_copy(v, h_v);
987 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
988 Kokkos::resize(v, num_rows, num_cols+1);
990 Kokkos::resize(v, num_rows, num_cols+1, fad_size+1);
994 host_view_type h_v2 = Kokkos::create_mirror_view(v);
995 Kokkos::deep_copy(h_v2, v);
999 for (size_type i=0; i<num_rows; ++
i) {
1000 for (size_type j=0; j<num_cols; ++j) {
1001 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1002 success = success &&
checkFads(f, h_v2(i,j), out);
1004 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1009 success = success &&
checkFads(f, h_v2(i,num_cols), out);
1014 Kokkos_View_Fad, Multiply,
FadType, Layout, Device )
1016 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
1017 typedef typename ViewType::size_type size_type;
1018 typedef typename ViewType::host_mirror_type host_view_type;
1025 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1026 v1 = ViewType (
"view1", num_rows);
1027 v2 = ViewType (
"view2", num_rows);
1029 v1 = ViewType (
"view1", num_rows, fad_size+1);
1030 v2 = ViewType (
"view2", num_rows, fad_size+1);
1032 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
1033 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
1034 for (size_type
i=0;
i<num_rows; ++
i) {
1035 h_v1(
i) = generate_fad<FadType>(
1036 num_rows, size_type(2), fad_size,
i, size_type(0));
1037 h_v2(i) = generate_fad<FadType>(
1038 num_rows, size_type(2), fad_size,
i, size_type(1));
1040 Kokkos::deep_copy(v1, h_v1);
1041 Kokkos::deep_copy(v2, h_v2);
1045 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1046 v3 = ViewType (
"view3", num_rows);
1048 v3 = ViewType (
"view3", num_rows, fad_size+1);
1053 host_view_type h_v3 = Kokkos::create_mirror_view(v3);
1054 Kokkos::deep_copy(h_v3, v3);
1058 for (size_type
i=0;
i<num_rows; ++
i) {
1060 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(0));
1062 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(1));
1064 success = success &&
checkFads(f3, h_v3(i), out);
1069 Kokkos_View_Fad, MultiplyUpdate,
FadType, Layout, Device )
1071 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
1072 typedef typename ViewType::size_type size_type;
1073 typedef typename ViewType::host_mirror_type host_view_type;
1080 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1081 v1 = ViewType (
"view1", num_rows);
1082 v2 = ViewType (
"view2", num_rows);
1084 v1 = ViewType (
"view1", num_rows, fad_size+1);
1085 v2 = ViewType (
"view2", num_rows, fad_size+1);
1087 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
1088 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
1089 for (size_type
i=0;
i<num_rows; ++
i) {
1090 h_v1(
i) = generate_fad<FadType>(
1091 num_rows, size_type(2), fad_size,
i, size_type(0));
1092 h_v2(i) = generate_fad<FadType>(
1093 num_rows, size_type(2), fad_size,
i, size_type(1));
1095 Kokkos::deep_copy(v1, h_v1);
1096 Kokkos::deep_copy(v2, h_v2);
1100 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1101 v3 = ViewType (
"view3", num_rows);
1103 v3 = ViewType (
"view3", num_rows, fad_size+1);
1105 Kokkos::deep_copy(v3, 1.0);
1109 host_view_type h_v3 = Kokkos::create_mirror_view(v3);
1110 Kokkos::deep_copy(h_v3, v3);
1114 for (size_type
i=0;
i<num_rows; ++
i) {
1116 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(0));
1118 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(1));
1120 success = success &&
checkFads(f3, h_v3(i), out);
1125 Kokkos_View_Fad, MultiplyConst,
FadType, Layout, Device )
1127 typedef Kokkos::View<const FadType*,Layout,Device,Kokkos::MemoryUnmanaged> ConstViewType;
1128 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
1129 typedef typename ViewType::size_type size_type;
1130 typedef typename ViewType::host_mirror_type host_view_type;
1137 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1138 v1 = ViewType (
"view1", num_rows);
1139 v2 = ViewType (
"view2", num_rows);
1141 v1 = ViewType (
"view1", num_rows, fad_size+1);
1142 v2 = ViewType (
"view2", num_rows, fad_size+1);
1144 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
1145 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
1146 for (size_type
i=0;
i<num_rows; ++
i) {
1147 h_v1(
i) = generate_fad<FadType>(
1148 num_rows, size_type(2), fad_size,
i, size_type(0));
1149 h_v2(i) = generate_fad<FadType>(
1150 num_rows, size_type(2), fad_size,
i, size_type(1));
1152 Kokkos::deep_copy(v1, h_v1);
1153 Kokkos::deep_copy(v2, h_v2);
1155 ConstViewType cv1 = v1;
1159 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1160 v3 = ViewType (
"view3", num_rows);
1162 v3 = ViewType (
"view3", num_rows, fad_size+1);
1167 host_view_type h_v3 = Kokkos::create_mirror_view(v3);
1168 Kokkos::deep_copy(h_v3, v3);
1172 for (size_type
i=0;
i<num_rows; ++
i) {
1174 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(0));
1176 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(1));
1178 success = success &&
checkFads(f3, h_v3(i), out);
1183 Kokkos_View_Fad, MultiplyMixed,
FadType, Layout, Device )
1185 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
1186 typedef typename ViewType::size_type size_type;
1187 typedef typename ViewType::host_mirror_type host_view_type;
1189 const size_type num_rows = 2;
1193 FadType f0 = generate_fad<FadType>(
1194 num_rows, size_type(2), fad_size, size_type(0), size_type(0));
1195 FadType f1 = generate_fad<FadType>(
1196 num_rows, size_type(2), fad_size, size_type(1), size_type(0));
1198 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1199 h_v = host_view_type (
"view1", num_rows);
1201 h_v = host_view_type (
"view1", num_rows, fad_size+1);
1214 Kokkos_View_Fad, AtomicAdd,
FadType, Layout, Device )
1216 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
1217 typedef Kokkos::View<FadType,Layout,Device> ScalarViewType;
1218 typedef typename ViewType::size_type size_type;
1219 typedef typename ScalarViewType::host_mirror_type host_scalar_view_type;
1226 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1227 v = ViewType (
"view", num_rows);
1229 v = ViewType (
"view", num_rows, fad_size+1);
1231 Kokkos::deep_copy(v, 2.3456);
1233 Kokkos::parallel_for(Kokkos::RangePolicy<Device>(0, num_rows), KOKKOS_LAMBDA(
const size_type
i) {
1234 for (size_type j = 0; j < fad_size; ++j)
1240 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1241 s = ScalarViewType (
"scalar view");
1243 s = ScalarViewType (
"scalar view", fad_size+1);
1250 host_scalar_view_type hs = Kokkos::create_mirror_view(s);
1251 Kokkos::deep_copy(hs, s);
1254 auto hv = Kokkos::create_mirror_view(v);
1255 Kokkos::deep_copy(hv, v);
1262 Kokkos_View_Fad, Rank8,
FadType, Layout, Device )
1264 typedef Kokkos::View<FadType*******,Layout,Device> ViewType;
1265 typedef typename ViewType::size_type size_type;
1266 typedef typename ViewType::host_mirror_type host_view_type;
1272 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1273 v = ViewType (
"view", 100, 1, 2, 3, 4, 5, 6);
1275 v = ViewType (
"view", 100, 1, 2, 3, 4, 5, 6, fad_size+1);
1277 host_view_type h_v = Kokkos::create_mirror_view(v);
1278 #if KOKKOS_VERSION >= 40799
1279 typename host_view_type::type h_a = h_v;
1281 typename host_view_type::array_type h_a = h_v;
1283 Kokkos::deep_copy(h_a, 1.0);
1286 h_v(99,0,1,2,3,4,5) = f1;
1287 FadType f2 = h_v(99,0,1,2,3,4,5);
1294 Kokkos_View_Fad, Roger,
FadType, Layout, Device )
1296 Kokkos::View<FadType*,Layout,Device>
a;
1297 Kokkos::View<FadType**,Layout,Device> b;
1298 Kokkos::View<FadType***,Layout,Device>
c;
1299 Kokkos::View<FadType****,Layout,Device> d;
1300 Kokkos::View<FadType*****,Layout,Device> e;
1301 Kokkos::View<FadType******,Layout,Device>
f;
1302 Kokkos::View<FadType*******,Layout,Device>
g;
1304 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1305 a = Kokkos::View<FadType*,Layout,Device>(
"a",4);
1306 b = Kokkos::View<FadType**,Layout,Device> (
"b",4,4);
1307 c = Kokkos::View<FadType***,Layout,Device> (
"c",4,4,4);
1308 d = Kokkos::View<FadType****,Layout,Device> (
"d",4,4,4,4);
1309 e = Kokkos::View<FadType*****,Layout,Device> (
"e",4,4,4,4,4);
1310 f = Kokkos::View<FadType******,Layout,Device> (
"f",4,4,4,4,4,4);
1311 g = Kokkos::View<FadType*******,Layout,Device> (
"g",4,4,4,4,4,4,4);
1314 a = Kokkos::View<FadType*,Layout,Device>(
"a",4,fad_size+1);
1315 b = Kokkos::View<FadType**,Layout,Device> (
"b",4,4,fad_size+1);
1316 c = Kokkos::View<FadType***,Layout,Device> (
"c",4,4,4,fad_size+1);
1317 d = Kokkos::View<FadType****,Layout,Device> (
"d",4,4,4,4,fad_size+1);
1318 e = Kokkos::View<FadType*****,Layout,Device> (
"e",4,4,4,4,4,fad_size+1);
1319 f = Kokkos::View<FadType******,Layout,Device> (
"f",4,4,4,4,4,4,fad_size+1);
1320 g = Kokkos::View<FadType*******,Layout,Device> (
"g",4,4,4,4,4,4,4,fad_size+1);
1323 typedef typename Device::memory_space memory_space;
1324 const bool is_accessible =
1325 Kokkos::Impl::MemorySpaceAccess<Kokkos::HostSpace,
1326 memory_space>::accessible;
1327 if (is_accessible) {
1329 f(0,0,0,0,0,0) =
FadType(1.0);
1330 g(0,0,0,0,0,0,0) =
FadType(1.0);
1338 Kokkos_View_Fad, AssignDifferentStrides,
FadType, Layout, Device )
1340 typedef Kokkos::View<FadType**,Layout,Device> ViewType1;
1341 typedef Kokkos::View<FadType*,Layout,Device> ViewType2;
1342 typedef typename ViewType1::size_type size_type;
1343 typedef typename ViewType1::host_mirror_type host_view_type1;
1344 typedef typename ViewType2::host_mirror_type host_view_type2;
1352 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1353 v1 = ViewType1 (
"view1", num_rows, num_cols);
1355 v1 = ViewType1 (
"view1", num_rows, num_cols, fad_size+1);
1357 host_view_type1 h_v1 = Kokkos::create_mirror_view(v1);
1358 for (size_type
i=0;
i<num_rows; ++
i) {
1359 for (size_type j=0; j<num_cols; ++j) {
1360 h_v1(
i,j) = generate_fad<FadType>(
1361 num_rows, num_cols, fad_size,
i, j);
1364 Kokkos::deep_copy(v1, h_v1);
1368 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1369 v2 = ViewType2 (
"view2", num_rows);
1371 v2 = ViewType2 (
"view2", num_rows, fad_size+1);
1376 host_view_type2 h_v2 = Kokkos::create_mirror_view(v2);
1377 Kokkos::deep_copy(h_v2, v2);
1381 for (size_type
i=0;
i<num_rows; ++
i) {
1383 generate_fad<FadType>(num_rows, num_cols, fad_size,
i, size_type(1));
1384 success = success &&
checkFads(f, h_v2(i), out);
1389 Kokkos_View_Fad, ScalarValue,
FadType, Layout, Device )
1392 typedef Kokkos::View<FadType,Layout,Device> ViewType1;
1393 typedef Kokkos::View<ScalarType,Layout,Device> ViewType2;
1394 typedef typename ViewType1::size_type size_type;
1395 typedef typename ViewType1::host_mirror_type host_view_type1;
1396 typedef typename ViewType2::host_mirror_type host_view_type2;
1402 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1403 v1 = ViewType1 (
"view1");
1405 v1 = ViewType1 (
"view1", fad_size+1);
1407 host_view_type1 h_v1 = Kokkos::create_mirror_view(v1);
1408 h_v1() = generate_fad<FadType>(1, 1, fad_size, 0, 0);
1409 Kokkos::deep_copy(v1, h_v1);
1412 ViewType2 v2 = ViewType2 (
"view2");
1413 Kokkos::parallel_for(Kokkos::RangePolicy<Device>(0,1),
1414 KOKKOS_LAMBDA(
const size_type
i)
1420 host_view_type2 h_v2 = Kokkos::create_mirror_view(v2);
1421 Kokkos::deep_copy(h_v2, v2);
1428 #if defined(HAVE_SACADO_KOKKOS) && defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
1431 Kokkos_View_Fad, DynRankDimensionScalar,
FadType, Layout, Device )
1433 typedef Kokkos::DynRankView<double,Layout,Device> DoubleViewType;
1434 typedef Kokkos::DynRankView<FadType,Layout,Device> FadViewType;
1435 typedef typename FadViewType::size_type size_type;
1441 DoubleViewType v1(
"view1", num_rows);
1442 FadViewType v2 (
"view2", num_rows, fad_size+1);
1450 Kokkos_View_Fad, DynRankAssignStatic0,
FadType, Layout, Device )
1452 typedef Kokkos::View<FadType,Layout,Device> StaticViewType;
1453 typedef Kokkos::DynRankView<FadType,Layout,Device> DynamicViewType;
1454 typedef typename StaticViewType::size_type size_type;
1461 StaticViewType v1(
"view", fad_size+1);
1462 auto h_v1 = Kokkos::create_mirror_view(v1);
1463 h_v1() = generate_fad<FadType>(num_rows, num_cols, fad_size, size_type(0), size_type(0));
1464 Kokkos::deep_copy(v1, h_v1);
1467 DynamicViewType v2 = v1;
1470 auto h_v2 = Kokkos::create_mirror_view(v2);
1471 Kokkos::deep_copy(h_v2, v2);
1478 generate_fad<FadType>(num_rows, num_cols, fad_size, size_type(0), size_type(0));
1479 success = success &&
checkFads(f, h_v2(), out);
1483 Kokkos_View_Fad, DynRankAssignStatic1,
FadType, Layout, Device )
1485 typedef Kokkos::View<FadType*,Layout,Device> StaticViewType;
1486 typedef Kokkos::DynRankView<FadType,Layout,Device> DynamicViewType;
1487 typedef typename StaticViewType::size_type size_type;
1494 StaticViewType v1(
"view", num_rows, fad_size+1);
1495 auto h_v1 = Kokkos::create_mirror_view(v1);
1496 for (size_type
i=0;
i<num_rows; ++
i)
1498 generate_fad<FadType>(num_rows, num_cols, fad_size,
i, size_type(0));
1499 Kokkos::deep_copy(v1, h_v1);
1502 DynamicViewType v2 = v1;
1505 auto h_v2 = Kokkos::create_mirror_view(v2);
1506 Kokkos::deep_copy(h_v2, v2);
1514 for (size_type i=0; i<num_rows; ++
i) {
1516 generate_fad<FadType>(num_rows, num_cols, fad_size,
i, size_type(0));
1517 success = success &&
checkFads(f, h_v2(i), out);
1522 Kokkos_View_Fad, DynRankAssignStatic2,
FadType, Layout, Device )
1524 typedef Kokkos::View<FadType**,Layout,Device> StaticViewType;
1525 typedef Kokkos::DynRankView<FadType,Layout,Device> DynamicViewType;
1526 typedef typename StaticViewType::size_type size_type;
1533 StaticViewType v1(
"view", num_rows, num_cols, fad_size+1);
1534 auto h_v1 = Kokkos::create_mirror_view(v1);
1535 for (size_type i=0; i<num_rows; ++
i)
1536 for (size_type j=0; j<num_cols; ++j)
1537 h_v1(i,j) = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1538 Kokkos::deep_copy(v1, h_v1);
1541 DynamicViewType v2 = v1;
1544 auto h_v2 = Kokkos::create_mirror_view(v2);
1545 Kokkos::deep_copy(h_v2, v2);
1555 for (size_type i=0; i<num_rows; ++
i) {
1556 for (size_type j=0; j<num_cols; ++j) {
1557 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1558 success = success &&
checkFads(f, h_v2(i,j), out);
1564 Kokkos_View_Fad, DynRankMultiply,
FadType, Layout, Device )
1566 typedef Kokkos::DynRankView<FadType,Layout,Device> ViewType;
1567 typedef typename ViewType::size_type size_type;
1568 typedef typename ViewType::host_mirror_type host_view_type;
1574 ViewType v1(
"view1", num_rows, fad_size+1);
1575 ViewType v2(
"view2", num_rows, fad_size+1);
1576 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
1577 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
1578 for (size_type i=0; i<num_rows; ++
i) {
1579 h_v1(i) = generate_fad<FadType>(
1580 num_rows, size_type(2), fad_size,
i, size_type(0));
1581 h_v2(i) = generate_fad<FadType>(
1582 num_rows, size_type(2), fad_size,
i, size_type(1));
1584 Kokkos::deep_copy(v1, h_v1);
1585 Kokkos::deep_copy(v2, h_v2);
1588 ViewType v3(
"view3", num_rows, fad_size+1);
1592 host_view_type h_v3 = Kokkos::create_mirror_view(v3);
1593 Kokkos::deep_copy(h_v3, v3);
1598 for (size_type i=0; i<num_rows; ++
i) {
1600 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(0));
1602 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(1));
1604 success = success &&
checkFads(f3, h_v3(i), out);
1609 Kokkos_View_Fad, SubdynrankviewCol,
FadType, Layout, Device )
1611 typedef Kokkos::DynRankView<FadType,Layout,Device> ViewType;
1612 typedef typename ViewType::size_type size_type;
1613 typedef typename ViewType::host_mirror_type host_view_type;
1620 ViewType v(
"view", num_rows, num_cols, fad_size+1);
1621 host_view_type h_v = Kokkos::create_mirror_view(v);
1622 for (size_type i=0; i<num_rows; ++
i) {
1623 for (size_type j=0; j<num_cols; ++j) {
1624 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1628 Kokkos::deep_copy(v, h_v);
1635 typedef decltype(s) SubviewType;
1636 typedef typename SubviewType::host_mirror_type HostSubviewType;
1642 HostSubviewType h_s = Kokkos::
subdynrankview(h_v, Kokkos::ALL(), col);
1646 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(s), fad_size+1, out, success);
1647 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(h_s), fad_size+1, out, success);
1648 TEUCHOS_TEST_EQUALITY(h_s.extent(0), num_rows, out, success);
1649 TEUCHOS_TEST_EQUALITY(h_s.extent(1), 1, out, success);
1650 TEUCHOS_TEST_EQUALITY(h_s.extent(7), 1, out, success);
1652 for (size_type i=0; i<num_rows; ++i) {
1653 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, col);
1654 success = success &&
checkFads(f, h_s(i), out);
1659 Kokkos_View_Fad, SubdynrankviewRow,
FadType, Layout, Device )
1661 typedef Kokkos::DynRankView<FadType,Layout,Device> ViewType;
1662 typedef typename ViewType::size_type size_type;
1663 typedef typename ViewType::host_mirror_type host_view_type;
1667 const size_type num_planes = 9;
1671 ViewType v(
"view", num_rows, num_cols, num_planes, fad_size+1);
1672 host_view_type h_v = Kokkos::create_mirror_view(v);
1673 for (size_type i=0; i<num_rows; ++
i) {
1674 for (size_type j=0; j<num_cols; ++j) {
1675 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1676 for (size_type k=0; k<num_planes; ++k) {
1677 h_v(i,j,k) = (k+1)*f;
1681 Kokkos::deep_copy(v, h_v);
1688 typedef decltype(s) SubviewType;
1689 typedef typename SubviewType::host_mirror_type HostSubviewType;
1695 HostSubviewType h_s =
1700 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(s), fad_size+1, out, success);
1701 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(h_s), fad_size+1, out, success);
1702 TEUCHOS_TEST_EQUALITY(h_s.extent(0), num_cols, out, success);
1703 TEUCHOS_TEST_EQUALITY(h_s.extent(1), num_planes, out, success);
1704 TEUCHOS_TEST_EQUALITY(h_s.extent(2), 1, out, success);
1705 TEUCHOS_TEST_EQUALITY(h_s.extent(7), 1, out, success);
1707 for (size_type j=0; j<num_cols; ++j) {
1708 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, row, j);
1709 for (size_type k=0; k<num_planes; ++k) {
1711 success = success &&
checkFads(g, h_s(j,k), out);
1717 Kokkos_View_Fad, SubdynrankviewScalar,
FadType, Layout, Device )
1719 typedef Kokkos::DynRankView<FadType,Layout,Device> ViewType;
1720 typedef typename ViewType::size_type size_type;
1721 typedef typename ViewType::host_mirror_type host_view_type;
1728 ViewType v(
"view", num_rows, num_cols, fad_size+1);
1729 host_view_type h_v = Kokkos::create_mirror_view(v);
1730 for (size_type i=0; i<num_rows; ++
i) {
1731 for (size_type j=0; j<num_cols; ++j) {
1732 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1736 Kokkos::deep_copy(v, h_v);
1744 typedef decltype(s) SubviewType;
1745 typedef typename SubviewType::host_mirror_type HostSubviewType;
1755 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(s), fad_size+1, out, success);
1756 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(h_s), fad_size+1, out, success);
1758 success = success &&
checkFads(f, h_s(), out);
1764 Kokkos_View_Fad, DynRankDimensionScalar,
FadType, Layout, Device ) {}
1766 Kokkos_View_Fad, DynRankAssignStatic0,
FadType, Layout, Device ) {}
1768 Kokkos_View_Fad, DynRankAssignStatic1,
FadType, Layout, Device ) {}
1770 Kokkos_View_Fad, DynRankAssignStatic2,
FadType, Layout, Device ) {}
1772 Kokkos_View_Fad, DynRankMultiply,
FadType, Layout, Device ) {}
1774 Kokkos_View_Fad, SubdynrankviewCol,
FadType, Layout, Device ) {}
1776 Kokkos_View_Fad, SubdynrankviewRow,
FadType, Layout, Device ) {}
1778 Kokkos_View_Fad, SubdynrankviewScalar,
FadType, Layout, Device ) {}
1783 Kokkos_View_Fad, Subview,
FadType, Layout, Device )
1785 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
1786 typedef typename ViewType::size_type size_type;
1787 typedef typename ViewType::host_mirror_type host_view_type;
1795 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1796 v = ViewType (
"view", num_rows, num_cols);
1798 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
1800 host_view_type h_v = Kokkos::create_mirror_view(v);
1801 for (size_type i=0; i<num_rows; ++
i) {
1802 for (size_type j=0; j<num_cols; ++j) {
1803 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1807 Kokkos::deep_copy(v, h_v);
1814 typedef decltype(s) SubviewType;
1815 typedef typename SubviewType::host_mirror_type HostSubviewType;
1825 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
1829 for (size_type i=0; i<num_rows; ++
i) {
1830 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, col);
1831 success = success &&
checkFads(f, h_s(i), out);
1836 Kokkos_View_Fad, Subview2,
FadType, Layout, Device )
1838 typedef Kokkos::View<FadType***,Layout,Device> ViewType;
1839 typedef typename ViewType::host_mirror_type host_view_type;
1845 const int num_cell = 5;
1846 const int num_qp = 4;
1847 const int num_dim = 3;
1848 const int num_deriv = 2;
1852 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1853 v = host_view_type (
"view", num_cell, num_qp, num_dim);
1855 v = host_view_type (
"view", num_cell, num_qp, num_dim, num_deriv+1);
1857 for (
int cell=0; cell < num_cell; ++cell) {
1858 for (
int qp=0; qp < num_qp; ++qp) {
1859 for (
int dim = 0; dim < num_dim; ++dim) {
1860 v(cell,qp,dim).val() = 100.*cell + 10.*qp + 1.*dim;
1861 for (
int deriv = 0; deriv < num_deriv; ++deriv) {
1862 v(cell,qp,dim).fastAccessDx(deriv) = v(cell,qp,dim).val() + (1.0*deriv)/10.;
1870 out <<
"checking subview(v,ALL,*,*)..." << std::endl;
1871 for (
int qp=0; qp < num_qp; ++qp) {
1872 for (
int dim=0; dim < num_dim; ++dim) {
1873 auto v_tmp =
subview(v,Kokkos::ALL(),qp,dim);
1874 for (
int cell=0; cell < num_cell; ++cell) {
1875 out <<
"\tChecking (" << cell <<
"," << qp <<
"," << dim <<
")" << std::endl;
1876 success = success &&
checkFads(v(cell,qp,dim), v_tmp(cell), out);
1881 out <<
"checking subview(v,*,ALL,*)..." << std::endl;
1882 for (
int cell=0; cell < num_cell; ++cell) {
1883 for (
int dim=0; dim < num_dim; ++dim) {
1884 auto v_tmp =
subview(v,cell,Kokkos::ALL(),dim);
1885 for (
int qp=0; qp < num_qp; ++qp) {
1886 out <<
"\tChecking (" << cell <<
"," << qp <<
"," << dim <<
")" << std::endl;
1887 success = success &&
checkFads(v(cell,qp,dim), v_tmp(qp), out);
1892 out <<
"checking subview(v,*,*,ALL)..." << std::endl;
1893 for (
int cell=0; cell < num_cell; ++cell) {
1894 for (
int qp=0; qp < num_qp; ++qp) {
1895 auto v_tmp =
subview(v,cell,qp,Kokkos::ALL());
1896 for (
int dim=0; dim < num_dim; ++dim) {
1897 out <<
"\tChecking (" << cell <<
"," << qp <<
"," << dim <<
")" << std::endl;
1898 success = success &&
checkFads(v(cell,qp,dim), v_tmp(dim), out);
1903 out <<
"checking subview(v,ALL,ALL,*)..." << std::endl;
1904 for (
int dim=0; dim < num_dim; ++dim) {
1905 auto v_tmp =
subview(v,Kokkos::ALL(),Kokkos::ALL(),dim);
1906 for (
int cell=0; cell < num_cell; ++cell) {
1907 for (
int qp=0; qp < num_qp; ++qp) {
1908 out <<
"\tChecking (" << cell <<
"," << qp <<
"," << dim <<
")" << std::endl;
1909 success = success &&
checkFads(v(cell,qp,dim), v_tmp(cell,qp), out);
1914 out <<
"checking subview(v,*,ALL,ALL)..." << std::endl;
1915 for (
int cell=0; cell < num_cell; ++cell) {
1916 auto v_tmp =
subview(v,cell,Kokkos::ALL(),Kokkos::ALL());
1917 for (
int qp=0; qp < num_qp; ++qp) {
1918 for (
int dim=0; dim < num_dim; ++dim) {
1919 out <<
"\tChecking (" << cell <<
"," << qp <<
"," << dim <<
")" << std::endl;
1920 success = success &&
checkFads(v(cell,qp,dim), v_tmp(qp,dim), out);
1925 out <<
"checking subview(v,ALL,*,ALL)..." << std::endl;
1926 for (
int qp=0; qp < num_qp; ++qp) {
1927 auto v_tmp =
subview(v,Kokkos::ALL(),qp,Kokkos::ALL());
1928 for (
int cell=0; cell < num_cell; ++cell) {
1929 for (
int dim=0; dim < num_dim; ++dim) {
1930 out <<
"\tChecking (" << cell <<
"," << qp <<
"," << dim <<
")" << std::endl;
1931 success = success &&
checkFads(v(cell,qp,dim), v_tmp(cell,dim), out);
1936 out <<
"checking subview(v,range,range,range)..." << std::endl;
1937 auto v_tmp =
subview(v,std::make_pair(1,5),std::make_pair(1,4),std::make_pair(1,3));
1938 for (
int cell=1; cell < num_cell; ++cell) {
1939 for (
int qp=1; qp < num_qp; ++qp) {
1940 for (
int dim=1; dim < num_dim; ++dim) {
1941 out <<
"\tChecking (" << cell <<
"," << qp <<
"," << dim <<
")" << std::endl;
1942 success = success &&
checkFads(v(cell,qp,dim), v_tmp(cell-1,qp-1,dim-1), out);
1948 #ifdef SACADO_NEW_FAD_DESIGN_IS_DEFAULT
1950 Kokkos_View_Fad, ConstViewAssign,
FadType, Layout, Device )
1952 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
1953 typedef Kokkos::View<const FadType,Layout,Device> ConstViewType;
1954 typedef typename ViewType::size_type size_type;
1955 typedef typename ViewType::host_mirror_type host_view_type;
1956 typedef typename ViewType::execution_space exec_space;
1962 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1963 ViewType v1(
"view1", num_rows);
1965 ViewType v1(
"view1", num_rows, fad_size+1);
1967 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
1968 for (size_type i=0; i<num_rows; ++
i) {
1969 FadType f = generate_fad<FadType>(num_rows, size_type(1), fad_size,
i,
1973 Kokkos::deep_copy(v1, h_v1);
1975 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1976 ViewType v2(
"view2", num_rows);
1978 ViewType v2(
"view2", num_rows, fad_size+1);
1981 static const size_type stride = Kokkos::ViewScalarStride<ViewType>::stride;
1982 #if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
1983 const bool use_team =
1988 #elif defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
1989 const bool use_team =
1994 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
1995 const bool use_team =
2000 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
2001 const bool use_team =
2007 const bool use_team =
false;
2011 typedef Kokkos::TeamPolicy<exec_space> team_policy;
2012 Kokkos::parallel_for(team_policy(num_rows, 1, stride),
2013 KOKKOS_LAMBDA(
typename team_policy::member_type team)
2015 const int i = team.league_rank();
2016 typename ConstViewType::reference_type
x = v1(i);
2021 Kokkos::parallel_for(Kokkos::RangePolicy<exec_space>(0,num_rows),
2022 KOKKOS_LAMBDA(
const int i)
2024 typename ConstViewType::reference_type
x = v1(i);
2030 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
2031 Kokkos::deep_copy(h_v2, v2);
2035 for (size_type i=0; i<num_rows; ++
i) {
2036 FadType f = generate_fad<FadType>(num_rows, size_type(1), fad_size,
i,
2038 success = success &&
checkFads(f, h_v2(i), out);
2043 Kokkos_View_Fad, ConstViewAssign,
FadType, Layout, Device ) {}
2048 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
2050 Kokkos_View_Fad, ShmemSize,
FadType, Layout, Device )
2052 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
2053 typedef typename FadType::value_type value_type;
2054 typedef typename ViewType::size_type size_type;
2061 const size_type shmem_size =
2062 ViewType::shmem_size(num_rows, num_cols, fad_size+1);
2066 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2067 v = ViewType (
"view", num_rows, num_cols);
2069 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
2071 #if defined(SACADO_HAS_NEW_KOKKOS_VIEW_IMPL) || (defined(SACADO_DISABLE_FAD_VIEW_SPEC) && !defined(KOKKOS_ENABLE_IMPL_VIEW_LEGACY))
2072 size_t scratch_value_alignment =
2074 alignof(value_type),
2075 static_cast<size_t>(
2076 ViewType::execution_space::scratch_memory_space::ALIGN)});
2077 const size_type shmem_size_expected =
2080 const size_type align = 8;
2081 const size_type mask = align - 1;
2082 const size_type shmem_size_expected =
2089 Kokkos_View_Fad, Unmanaged,
FadType, Layout, Device )
2094 typedef typename FadType::value_type scalar_type;
2095 typedef Kokkos::View<scalar_type***,TestLayout,Device> ViewType;
2096 typedef Kokkos::View<FadType**,TestLayout,Device,Kokkos::MemoryUnmanaged> FadViewType;
2097 typedef typename ViewType::size_type size_type;
2098 typedef typename ViewType::host_mirror_type host_view_type;
2099 typedef typename FadViewType::host_mirror_type fad_host_view_type;
2110 v = ViewType (
"view", fad_size+1, num_rows, num_cols);
2111 h_v = Kokkos::create_mirror_view(v);
2112 for (size_type i=0; i<num_rows; ++
i) {
2113 for (size_type j=0; j<num_cols; ++j) {
2114 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2115 for (size_type k=0; k<fad_size; k++)
2116 h_v(k,i,j) = f.dx(k);
2117 h_v(fad_size,i,j) = f.val();
2122 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
2123 h_v = Kokkos::create_mirror_view(v);
2124 for (size_type i=0; i<num_rows; ++
i) {
2125 for (size_type j=0; j<num_cols; ++j) {
2126 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2127 for (size_type k=0; k<fad_size; k++)
2128 h_v(i,j,k) = f.dx(k);
2129 h_v(i,j,fad_size) = f.val();
2133 Kokkos::deep_copy(v, h_v);
2137 fad_host_view_type h_v_fad;
2138 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2139 v_fad = FadViewType ( v.data(), num_rows, num_cols);
2140 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols);
2142 v_fad = FadViewType ( v.data(), num_rows, num_cols, fad_size+1);
2143 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols, fad_size+1);
2147 Kokkos::deep_copy(h_v_fad, v_fad);
2151 for (size_type i=0; i<num_rows; ++
i) {
2152 for (size_type j=0; j<num_cols; ++j) {
2153 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2154 success = success &&
checkFads(f, h_v_fad(i,j), out);
2160 Kokkos_View_Fad, Unmanaged2,
FadType, Layout, Device )
2165 typedef typename FadType::value_type scalar_type;
2166 typedef Kokkos::View<scalar_type***,TestLayout,Device> ViewType;
2167 typedef Kokkos::View<FadType**,TestLayout,Device> FadViewType;
2168 typedef typename ViewType::size_type size_type;
2169 typedef typename ViewType::host_mirror_type host_view_type;
2170 typedef typename FadViewType::host_mirror_type fad_host_view_type;
2181 v = ViewType (
"view", fad_size+1, num_rows, num_cols);
2182 h_v = Kokkos::create_mirror_view(v);
2183 for (size_type i=0; i<num_rows; ++
i) {
2184 for (size_type j=0; j<num_cols; ++j) {
2185 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2186 for (size_type k=0; k<fad_size; k++)
2187 h_v(k,i,j) = f.dx(k);
2188 h_v(fad_size,i,j) = f.val();
2193 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
2194 h_v = Kokkos::create_mirror_view(v);
2195 for (size_type i=0; i<num_rows; ++
i) {
2196 for (size_type j=0; j<num_cols; ++j) {
2197 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2198 for (size_type k=0; k<fad_size; k++)
2199 h_v(i,j,k) = f.dx(k);
2200 h_v(i,j,fad_size) = f.val();
2204 Kokkos::deep_copy(v, h_v);
2208 fad_host_view_type h_v_fad;
2209 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2210 v_fad = FadViewType ( v.data(), num_rows, num_cols);
2211 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols);
2213 v_fad = FadViewType ( v.data(), num_rows, num_cols, fad_size+1);
2214 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols, fad_size+1);
2218 Kokkos::deep_copy(h_v_fad, v_fad);
2222 for (size_type i=0; i<num_rows; ++
i) {
2223 for (size_type j=0; j<num_cols; ++j) {
2224 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2225 success = success &&
checkFads(f, h_v_fad(i,j), out);
2231 Kokkos_View_Fad, UnmanagedConst,
FadType, Layout, Device )
2236 typedef typename FadType::value_type scalar_type;
2237 typedef Kokkos::View<scalar_type***,TestLayout,Device> ViewType;
2238 typedef Kokkos::View<const scalar_type***,TestLayout,Device> ConstViewType;
2239 typedef Kokkos::View<FadType**,TestLayout,Device,Kokkos::MemoryUnmanaged> FadViewType;
2240 typedef Kokkos::View<const FadType**,TestLayout,Device,Kokkos::MemoryUnmanaged> ConstFadViewType;
2241 typedef typename ViewType::size_type size_type;
2242 typedef typename ViewType::host_mirror_type host_view_type;
2243 typedef typename FadViewType::host_mirror_type fad_host_view_type;
2254 v = ViewType (
"view", fad_size+1, num_rows, num_cols);
2255 h_v = Kokkos::create_mirror_view(v);
2256 for (size_type i=0; i<num_rows; ++
i) {
2257 for (size_type j=0; j<num_cols; ++j) {
2258 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2259 for (size_type k=0; k<fad_size; k++)
2260 h_v(k,i,j) = f.dx(k);
2261 h_v(fad_size,i,j) = f.val();
2266 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
2267 h_v = Kokkos::create_mirror_view(v);
2268 for (size_type i=0; i<num_rows; ++
i) {
2269 for (size_type j=0; j<num_cols; ++j) {
2270 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2271 for (size_type k=0; k<fad_size; k++)
2272 h_v(i,j,k) = f.dx(k);
2273 h_v(i,j,fad_size) = f.val();
2277 Kokkos::deep_copy(v, h_v);
2278 ConstViewType v_const = v;
2282 ConstFadViewType v_fad;
2283 fad_host_view_type h_v_fad;
2284 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2285 v_fad = ConstFadViewType ( v_const.data(), num_rows, num_cols);
2286 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols);
2288 v_fad = ConstFadViewType ( v_const.data(), num_rows, num_cols, fad_size+1);
2289 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols, fad_size+1);
2293 Kokkos::deep_copy(h_v_fad, v_fad);
2297 for (size_type i=0; i<num_rows; ++
i) {
2298 for (size_type j=0; j<num_cols; ++j) {
2299 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2300 success = success &&
checkFads(f, h_v_fad(i,j), out);
2306 Kokkos_View_Fad, UnmanagedConst2,
FadType, Layout, Device )
2310 typedef typename FadType::value_type scalar_type;
2311 typedef Kokkos::View<scalar_type***,TestLayout,Device> ViewType;
2312 typedef Kokkos::View<const scalar_type***,TestLayout,Device> ConstViewType;
2313 typedef Kokkos::View<FadType**,TestLayout,Device> FadViewType;
2314 typedef Kokkos::View<const FadType**,TestLayout,Device> ConstFadViewType;
2315 typedef typename ViewType::size_type size_type;
2316 typedef typename ViewType::host_mirror_type host_view_type;
2317 typedef typename FadViewType::host_mirror_type fad_host_view_type;
2328 v = ViewType (
"view", fad_size+1, num_rows, num_cols);
2329 h_v = Kokkos::create_mirror_view(v);
2330 for (size_type i=0; i<num_rows; ++
i) {
2331 for (size_type j=0; j<num_cols; ++j) {
2332 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2333 for (size_type k=0; k<fad_size; k++)
2334 h_v(k,i,j) = f.dx(k);
2335 h_v(fad_size,i,j) = f.val();
2340 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
2341 h_v = Kokkos::create_mirror_view(v);
2342 for (size_type i=0; i<num_rows; ++
i) {
2343 for (size_type j=0; j<num_cols; ++j) {
2344 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2345 for (size_type k=0; k<fad_size; k++)
2346 h_v(i,j,k) = f.dx(k);
2347 h_v(i,j,fad_size) = f.val();
2351 Kokkos::deep_copy(v, h_v);
2352 ConstViewType v_const = v;
2355 ConstFadViewType v_fad;
2356 fad_host_view_type h_v_fad;
2357 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2358 v_fad = ConstFadViewType (v_const.data(), num_rows, num_cols);
2359 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols);
2361 v_fad = ConstFadViewType (v_const.data(), num_rows, num_cols, fad_size+1);
2362 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols, fad_size+1);
2366 Kokkos::deep_copy(h_v_fad, v_fad);
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);
2373 success = success &&
checkFads(f, h_v_fad(i,j), out);
2381 Kokkos_View_Fad, SFadNoSizeArg,
FadType, Layout, Device )
2383 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
2384 typedef typename ViewType::size_type size_type;
2385 typedef typename ViewType::host_mirror_type host_view_type;
2392 ViewType v(
"view", num_rows, num_cols);
2393 host_view_type h_v = Kokkos::create_mirror_view(v);
2394 for (size_type i=0; i<num_rows; ++
i) {
2395 for (size_type j=0; j<num_cols; ++j) {
2396 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2400 Kokkos::deep_copy(v, h_v);
2403 Kokkos::deep_copy(h_v, v);
2409 for (size_type i=0; i<num_rows; ++
i) {
2410 for (size_type j=0; j<num_cols; ++j) {
2411 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2412 success = success &&
checkFads(f, h_v(i,j), out);
2417 #ifndef SACADO_HAS_NEW_KOKKOS_VIEW_IMPL
2419 Kokkos_View_Fad, Partition,
FadType, Layout, Device )
2421 #if !defined(SACADO_VIEW_CUDA_HIERARCHICAL) && !defined(SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
2422 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
2423 typedef typename ViewType::size_type size_type;
2424 typedef typename ViewType::host_mirror_type host_view_type;
2432 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2433 v = ViewType (
"view", num_rows, num_cols);
2435 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
2437 host_view_type h_v = Kokkos::create_mirror_view(v);
2439 for (size_type i=0; i<num_rows; ++
i) {
2440 for (size_type j=0; j<num_cols; ++j) {
2441 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2445 Kokkos::deep_copy(v, h_v);
2448 Kokkos::deep_copy(h_v, v);
2452 const size_type stride = 2;
2453 auto h_v1 = Kokkos::partition<2>(h_v, 0, stride);
2454 auto h_v2 = Kokkos::partition<2>(h_v, 1, stride);
2457 const size_type fad_size_1 = (fad_size + stride - 0 - 1) / stride;
2458 const size_type fad_size_2 = (fad_size + stride - 1 - 1) / stride;
2462 for (size_type i=0; i<num_rows; ++
i) {
2463 for (size_type j=0; j<num_cols; ++j) {
2464 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2467 for (
unsigned int k=0; k<fad_size_1; ++k)
2468 if (2*k < fad_size) f1.fastAccessDx(k) = f.dx(2*k);
2469 for (
unsigned int k=0; k<fad_size_2; ++k)
2470 if (2*k+1 < fad_size) f2.fastAccessDx(k) = f.dx(2*k+1);
2471 success = success &&
checkFads(f1, h_v1(i,j), out);
2472 success = success &&
checkFads(f2, h_v2(i,j), out);
2477 #endif // SACADO_HAS_NEW_KOKKOS_VIEW_IMPL
2480 Kokkos_View_Fad, AssignLayoutContiguousToLayoutStride,
FadType, Layout, Device )
2482 typedef Kokkos::View<FadType**,Kokkos::LayoutContiguous<Layout>,Device> ContViewType;
2483 typedef Kokkos::View<FadType**,Kokkos::LayoutStride,Device> StrideViewType;
2484 typedef typename ContViewType::size_type size_type;
2485 typedef typename ContViewType::host_mirror_type cont_host_view_type;
2486 typedef typename StrideViewType::host_mirror_type stride_host_view_type;
2494 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2495 v = ContViewType (
"view", num_rows, num_cols);
2497 v = ContViewType (
"view", num_rows, num_cols, fad_size+1);
2499 cont_host_view_type h_v = Kokkos::create_mirror_view(v);
2501 for (size_type i=0; i<num_rows; ++
i) {
2502 for (size_type j=0; j<num_cols; ++j) {
2503 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2507 Kokkos::deep_copy(v, h_v);
2510 StrideViewType vs = v;
2517 stride_host_view_type h_vs = h_v;
2524 for (size_type i=0; i<num_rows; ++
i) {
2525 for (size_type j=0; j<num_cols; ++j) {
2526 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2527 success = success &&
checkFads(f, h_vs(i,j), out);
2533 Kokkos_View_Fad, CommonViewAllocMixedSpec,
FadType, Layout, Device )
2535 typedef Kokkos::View<FadType**,Kokkos::LayoutContiguous<Layout>,Device> ContViewType;
2536 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
2537 typedef typename ContViewType::size_type size_type;
2545 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2546 v1 = ContViewType (
"view", num_rows, num_cols);
2548 v1 = ContViewType (
"view", num_rows, num_cols, fad_size+1);
2552 auto cprop = Kokkos::common_view_alloc_prop(v1);
2553 ViewType v2(Kokkos::view_alloc(
"v2",cprop), num_rows, num_cols);
2565 Kokkos_View_Fad, ShmemSize,
FadType, Layout, Device )
2567 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
2568 typedef typename ViewType::size_type size_type;
2574 const size_type shmem_size =
2575 ViewType::shmem_size(num_rows, num_cols);
2578 #if !defined(KOKKOS_ENABLE_IMPL_VIEW_LEGACY)
2579 size_t scratch_value_alignment =
2582 static_cast<size_t>(
2583 ViewType::execution_space::scratch_memory_space::ALIGN)});
2584 const size_type shmem_size_expected =
2587 static const size_type align = 8;
2588 static const size_type mask = align - 1;
2589 const size_type shmem_size_expected =
2596 Kokkos_View_Fad, Unmanaged,
FadType, Layout, Device ) {}
2599 Kokkos_View_Fad, Unmanaged2,
FadType, Layout, Device ) {}
2602 Kokkos_View_Fad, UnmanagedConst,
FadType, Layout, Device ) {}
2605 Kokkos_View_Fad, UnmanagedConst2,
FadType, Layout, Device ) {}
2608 Kokkos_View_Fad, SFadNoSizeArg,
FadType, Layout, Device ) {}
2611 Kokkos_View_Fad, Partition,
FadType, Layout, Device ) {}
2614 Kokkos_View_Fad, AssignLayoutContiguousToLayoutStride,
FadType, Layout, Device ) {}
2617 Kokkos_View_Fad, CommonViewAllocMixedSpec,
FadType, Layout, Device ) {}
2621 #define VIEW_FAD_TESTS_FLD( F, L, D ) \
2622 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Size, F, L, D ) \
2623 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy, F, L, D ) \
2624 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy_ConstantScalar, F, L, D ) \
2625 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy_ConstantZero, F, L, D ) \
2626 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy_ConstantFad, F, L, D ) \
2627 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy_ConstantFadFull, F, L, D ) \
2628 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, LocalDeepCopy, F, L, D ) \
2629 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, LocalDeepCopyTeam, F, L, D ) \
2630 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, ScalarAssign, F, L, D ) \
2631 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, ValueAssign, F, L, D ) \
2632 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Resize, F, L, D ) \
2633 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Unmanaged, F, L, D ) \
2634 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Unmanaged2, F, L, D ) \
2635 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, UnmanagedConst, F, L, D ) \
2636 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, UnmanagedConst2, F, L, D ) \
2637 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Multiply, F, L, D ) \
2638 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, MultiplyUpdate, F, L, D ) \
2639 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, MultiplyConst, F, L, D ) \
2640 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, MultiplyMixed, F, L, D ) \
2641 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Rank8, F, L, D ) \
2642 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Roger, F, L, D ) \
2643 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, AtomicAdd, F, L, D ) \
2644 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, AssignDifferentStrides, F, L, D ) \
2645 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, ScalarValue, F, L, D ) \
2646 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankDimensionScalar, F, L, D ) \
2647 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankAssignStatic0, F, L, D ) \
2648 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankAssignStatic1, F, L, D ) \
2649 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankAssignStatic2, F, L, D ) \
2650 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankMultiply, F, L, D ) \
2651 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, SubdynrankviewCol, F, L, D ) \
2652 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, SubdynrankviewRow, F, L, D ) \
2653 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, SubdynrankviewScalar, F, L, D ) \
2654 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Subview, F, L, D ) \
2655 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Subview2, F, L, D ) \
2656 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, ShmemSize, F, L, D ) \
2657 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, ConstViewAssign, F, L, D )
2659 #define VIEW_FAD_TESTS_SFLD( F, L, D ) \
2660 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, SFadNoSizeArg, F, L, D )
2662 #define VIEW_FAD_TESTS_FDI( F, D ) \
2663 using Kokkos::LayoutLeft; \
2664 using Kokkos::LayoutRight; \
2665 VIEW_FAD_TESTS_FLD( F, LayoutLeft, D ) \
2666 VIEW_FAD_TESTS_FLD( F, LayoutRight, D ) \
2667 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, AssignLayoutContiguousToLayoutStride, F, LayoutLeft, D ) \
2668 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, AssignLayoutContiguousToLayoutStride, F, LayoutRight, D ) \
2669 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, CommonViewAllocMixedSpec, F, LayoutLeft, D ) \
2670 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, CommonViewAllocMixedSpec, F, LayoutRight, D )
2672 #define VIEW_FAD_TESTS_SFDI( F, D ) \
2673 using Kokkos::LayoutLeft; \
2674 using Kokkos::LayoutRight; \
2675 VIEW_FAD_TESTS_SFLD( F, LayoutLeft, D ) \
2676 VIEW_FAD_TESTS_SFLD( F, LayoutRight, D )
2678 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
2682 #ifndef SACADO_HAS_NEW_KOKKOS_VIEW_IMPL
2683 #define VIEW_FAD_TESTS_FDC( F, D ) \
2684 VIEW_FAD_TESTS_FLD( F, LeftContiguous, D ) \
2685 VIEW_FAD_TESTS_FLD( F, RightContiguous, D ) \
2686 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Partition, F, LeftContiguous, D ) \
2687 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Partition, F, RightContiguous, D )
2689 #define VIEW_FAD_TESTS_FDC( F, D ) \
2690 VIEW_FAD_TESTS_FLD( F, LeftContiguous, D ) \
2691 VIEW_FAD_TESTS_FLD( F, RightContiguous, D )
2694 #define VIEW_FAD_TESTS_SFDC( F, D ) \
2695 VIEW_FAD_TESTS_SFLD( F, LeftContiguous, D ) \
2696 VIEW_FAD_TESTS_SFLD( F, RightContiguous, D )
2698 #define VIEW_FAD_TESTS_FDC( F, D )
2699 #define VIEW_FAD_TESTS_SFDC( F, D )
2702 #define VIEW_FAD_TESTS_FD( F, D ) \
2703 VIEW_FAD_TESTS_FDI( F, D ) \
2704 VIEW_FAD_TESTS_FDC( F, D )
2706 #define VIEW_FAD_TESTS_SFD( F, D ) \
2707 VIEW_FAD_TESTS_SFDI( F, D ) \
2708 VIEW_FAD_TESTS_SFDC( F, D )
2731 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC) && SACADO_TEST_DFAD
2732 #define VIEW_FAD_TESTS_D( D ) \
2733 VIEW_FAD_TESTS_FD( SFadType, D ) \
2734 VIEW_FAD_TESTS_FD( SLFadType, D ) \
2735 VIEW_FAD_TESTS_FD( DFadType, D ) \
2736 VIEW_FAD_TESTS_SFD( SFadType, D )
2756 #define VIEW_FAD_TESTS_D( D ) \
2757 VIEW_FAD_TESTS_FD( SFadType, D ) \
2758 VIEW_FAD_TESTS_FD( SLFadType, D ) \
2759 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
KOKKOS_INLINE_FUNCTION auto subview(const View< D, Kokkos::LayoutContiguous< LayoutSrc, StrideSrc >, P...> &src, Args...args)
#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)
KOKKOS_INLINE_FUNCTION auto subdynrankview(const DynRankView< T, LayoutContiguous< LayoutSrc, StrideSrc >, DRVArgs...> &drv, SubArg0 arg0=SubArg0{}, SubArg1 arg1=SubArg1{}, SubArg2 arg2=SubArg2{}, SubArg3 arg3=SubArg3{}, SubArg4 arg4=SubArg4{}, SubArg5 arg5=SubArg5{}, SubArg6 arg6=SubArg6{})
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
SimpleFad< ValueT > max(const SimpleFad< ValueT > &a, const SimpleFad< ValueT > &b)
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