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::HostMirror 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::HostMirror 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 typename ViewType::array_type va = v;
564 Kokkos::deep_copy( va, 1.0 );
567 value_type
a = 2.3456;
568 Kokkos::deep_copy( v, a );
571 host_view_type hv = Kokkos::create_mirror_view(v);
572 Kokkos::deep_copy(hv, v);
576 for (size_type
i=0;
i<num_rows; ++
i) {
577 for (size_type j=0; j<num_cols; ++j) {
578 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
583 success = success &&
checkFads(f, hv(
i,j), out);
589 Kokkos_View_Fad, DeepCopy_ConstantZero,
FadType, Layout, Device )
591 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
592 typedef typename ViewType::size_type size_type;
593 typedef typename ViewType::HostMirror host_view_type;
594 typedef typename FadType::value_type value_type;
601 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
602 v = ViewType (
"view", num_rows, num_cols);
605 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
607 typename ViewType::array_type va = v;
608 Kokkos::deep_copy( va, 1.0 );
612 Kokkos::deep_copy( v, a );
615 host_view_type hv = Kokkos::create_mirror_view(v);
616 Kokkos::deep_copy(hv, v);
620 for (size_type
i=0;
i<num_rows; ++
i) {
621 for (size_type j=0; j<num_cols; ++j) {
622 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
627 success = success &&
checkFads(f, hv(
i,j), out);
633 Kokkos_View_Fad, DeepCopy_ConstantFad,
FadType, Layout, Device )
635 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
636 typedef typename ViewType::size_type size_type;
637 typedef typename ViewType::HostMirror host_view_type;
644 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
645 v = ViewType (
"view", num_rows, num_cols);
648 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
650 typename ViewType::array_type va = v;
651 Kokkos::deep_copy( va, 1.0 );
655 Kokkos::deep_copy( v, a );
658 host_view_type hv = Kokkos::create_mirror_view(v);
659 Kokkos::deep_copy(hv, v);
663 for (size_type
i=0;
i<num_rows; ++
i) {
664 for (size_type j=0; j<num_cols; ++j) {
665 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
670 success = success &&
checkFads(f, hv(
i,j), out);
676 Kokkos_View_Fad, DeepCopy_ConstantFadFull,
FadType, Layout, Device )
678 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
679 typedef typename ViewType::size_type size_type;
680 typedef typename ViewType::HostMirror host_view_type;
688 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
689 v = ViewType (
"view", num_rows, num_cols);
691 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
693 typename ViewType::array_type va = v;
694 Kokkos::deep_copy( va, 1.0 );
698 for (size_type
i=0;
i<fad_size; ++
i)
699 a.fastAccessDx(
i) = 7.89 + (
i+1);
702 host_view_type hv = Kokkos::create_mirror_view(v);
703 Kokkos::deep_copy(hv, a);
707 for (size_type
i=0;
i<num_rows; ++
i) {
708 for (size_type j=0; j<num_cols; ++j) {
709 success = success &&
checkFads(a, hv(
i,j), out);
715 Kokkos_View_Fad, LocalDeepCopy,
FadType, Layout, Device )
717 typedef Kokkos::View<FadType***,Layout,Device> ViewType;
718 typedef Kokkos::View<FadType,Layout,Device> ScalarViewType;
719 typedef typename ViewType::size_type size_type;
720 typedef typename ViewType::HostMirror host_view_type;
721 typedef typename ScalarViewType::HostMirror host_scalar_view_type;
725 const size_type num_slices = 10;
730 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
731 v = ViewType (
"view", num_rows, num_cols, num_slices);
733 v = ViewType (
"view", num_rows, num_cols, num_slices, fad_size+1);
735 typename ViewType::array_type va = v;
736 Kokkos::deep_copy( va, 1.0 );
741 for (size_type
i=0;
i<fad_size; ++
i)
742 a.fastAccessDx(
i) = 7.89 + (
i+1);
743 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
744 ScalarViewType a_view(
"a");
746 ScalarViewType a_view(
"a", fad_size+1);
748 host_scalar_view_type ha_view = Kokkos::create_mirror_view(a_view);
750 Kokkos::deep_copy( a_view, ha_view );
753 Kokkos::parallel_for(Kokkos::RangePolicy<Device>(0,num_rows),
754 KOKKOS_LAMBDA(
const int i)
756 auto s = Kokkos::subview(v,i,Kokkos::ALL,Kokkos::ALL);
757 Kokkos::Experimental::local_deep_copy(s,a_view());
761 host_view_type hv = Kokkos::create_mirror_view(v);
762 Kokkos::deep_copy(hv, a);
766 for (size_type i=0; i<num_rows; ++
i) {
767 for (size_type j=0; j<num_cols; ++j) {
768 for (size_type k=0; k<num_slices; ++k) {
769 success = success &&
checkFads(a, hv(i,j,k), out);
776 Kokkos_View_Fad, LocalDeepCopyTeam,
FadType, Layout, Device )
778 typedef Kokkos::View<FadType***,Layout,Device> ViewType;
779 typedef Kokkos::View<FadType,Layout,Device> ScalarViewType;
780 typedef typename ViewType::size_type size_type;
781 typedef typename ViewType::HostMirror host_view_type;
782 typedef typename ScalarViewType::HostMirror host_scalar_view_type;
786 const size_type num_slices = 10;
791 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
792 v = ViewType (
"view", num_rows, num_cols, num_slices);
794 v = ViewType (
"view", num_rows, num_cols, num_slices, fad_size+1);
796 typename ViewType::array_type va = v;
797 Kokkos::deep_copy( va, 1.0 );
802 for (size_type
i=0;
i<fad_size; ++
i)
803 a.fastAccessDx(
i) = 7.89 + (
i+1);
804 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
805 ScalarViewType a_view(
"a");
807 ScalarViewType a_view(
"a", fad_size+1);
809 host_scalar_view_type ha_view = Kokkos::create_mirror_view(a_view);
811 Kokkos::deep_copy( a_view, ha_view );
814 typedef Kokkos::TeamPolicy<Device> Policy;
815 static const size_type stride = Kokkos::ViewScalarStride<ViewType>::stride;
816 Kokkos::parallel_for(Policy(num_rows,Kokkos::AUTO,stride),
817 KOKKOS_LAMBDA(
const typename Policy::member_type& team)
819 int i = team.league_rank();
820 auto s = Kokkos::subview(v,i,Kokkos::ALL,Kokkos::ALL);
821 Kokkos::Experimental::local_deep_copy(team,s,a_view());
825 host_view_type hv = Kokkos::create_mirror_view(v);
826 Kokkos::deep_copy(hv, a);
830 for (size_type
i=0;
i<num_rows; ++
i) {
831 for (size_type j=0; j<num_cols; ++j) {
832 for (size_type k=0; k<num_slices; ++k) {
833 success = success &&
checkFads(a, hv(
i,j,k), out);
840 Kokkos_View_Fad, ScalarAssign,
FadType, Layout, Device )
842 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
843 typedef typename ViewType::size_type size_type;
844 typedef typename ViewType::HostMirror host_view_type;
845 typedef typename FadType::value_type value_type;
851 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
852 v = ViewType (
"view", num_rows);
855 v = ViewType (
"view", num_rows, fad_size+1);
857 typename ViewType::array_type va = v;
858 Kokkos::deep_copy( va, 1.0 );
861 value_type
a = 2.3456;
865 host_view_type hv = Kokkos::create_mirror_view(v);
866 Kokkos::deep_copy(hv, v);
870 for (size_type
i=0;
i<num_rows; ++
i) {
871 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
876 success = success &&
checkFads(f, hv(
i), out);
881 Kokkos_View_Fad, ValueAssign,
FadType, Layout, Device )
883 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
884 typedef Kokkos::View<FadType,Layout,Device> ScalarViewType;
885 typedef typename ViewType::size_type size_type;
886 typedef typename ViewType::HostMirror host_view_type;
887 typedef typename ScalarViewType::HostMirror host_scalar_view_type;
895 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
896 v = ViewType (
"view", num_rows);
897 a = ScalarViewType (
"fad");
899 v = ViewType (
"view", num_rows, fad_size+1);
900 a = ScalarViewType (
"fad", fad_size+1);
902 typename ViewType::array_type va = v;
903 Kokkos::deep_copy( va, 1.0 );
906 Kokkos::deep_copy(a, 2.3456);
908 Kokkos::parallel_for(Kokkos::RangePolicy< Device>(0, fad_size), KOKKOS_LAMBDA(
const int i) {
909 a().fastAccessDx(i) = 7.89 +
i;
917 host_view_type hv = Kokkos::create_mirror_view(v);
918 Kokkos::deep_copy(hv, v);
920 host_scalar_view_type ha = Kokkos::create_mirror_view(a);
921 Kokkos::deep_copy(ha, a);
925 for (size_type i=0; i<num_rows; ++
i) {
926 success = success &&
checkFads(ha(), hv(i), out);
931 Kokkos_View_Fad, Resize,
FadType, Layout, Device )
933 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
934 typedef typename ViewType::size_type size_type;
935 typedef typename ViewType::HostMirror host_view_type;
943 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
944 v = ViewType (
"view", num_rows, num_cols);
946 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
948 host_view_type h_v = Kokkos::create_mirror_view(v);
949 for (size_type
i=0;
i<num_rows; ++
i)
950 for (size_type j=0; j<num_cols; ++j)
951 h_v(
i,j) = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
952 Kokkos::deep_copy(v, h_v);
955 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
956 Kokkos::resize(v, num_rows, num_cols+1);
958 Kokkos::resize(v, num_rows, num_cols+1, fad_size+1);
962 host_view_type h_v2 = Kokkos::create_mirror_view(v);
963 Kokkos::deep_copy(h_v2, v);
967 for (size_type i=0; i<num_rows; ++
i) {
968 for (size_type j=0; j<num_cols; ++j) {
969 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
970 success = success &&
checkFads(f, h_v2(i,j), out);
972 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
977 success = success &&
checkFads(f, h_v2(i,num_cols), out);
982 Kokkos_View_Fad, Multiply,
FadType, Layout, Device )
984 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
985 typedef typename ViewType::size_type size_type;
986 typedef typename ViewType::HostMirror host_view_type;
993 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
994 v1 = ViewType (
"view1", num_rows);
995 v2 = ViewType (
"view2", num_rows);
997 v1 = ViewType (
"view1", num_rows, fad_size+1);
998 v2 = ViewType (
"view2", num_rows, fad_size+1);
1000 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
1001 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
1002 for (size_type
i=0;
i<num_rows; ++
i) {
1003 h_v1(
i) = generate_fad<FadType>(
1004 num_rows, size_type(2), fad_size,
i, size_type(0));
1005 h_v2(i) = generate_fad<FadType>(
1006 num_rows, size_type(2), fad_size,
i, size_type(1));
1008 Kokkos::deep_copy(v1, h_v1);
1009 Kokkos::deep_copy(v2, h_v2);
1013 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1014 v3 = ViewType (
"view3", num_rows);
1016 v3 = ViewType (
"view3", num_rows, fad_size+1);
1021 host_view_type h_v3 = Kokkos::create_mirror_view(v3);
1022 Kokkos::deep_copy(h_v3, v3);
1026 for (size_type
i=0;
i<num_rows; ++
i) {
1028 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(0));
1030 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(1));
1032 success = success &&
checkFads(f3, h_v3(i), out);
1037 Kokkos_View_Fad, MultiplyUpdate,
FadType, Layout, Device )
1039 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
1040 typedef typename ViewType::size_type size_type;
1041 typedef typename ViewType::HostMirror host_view_type;
1048 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1049 v1 = ViewType (
"view1", num_rows);
1050 v2 = ViewType (
"view2", num_rows);
1052 v1 = ViewType (
"view1", num_rows, fad_size+1);
1053 v2 = ViewType (
"view2", num_rows, fad_size+1);
1055 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
1056 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
1057 for (size_type
i=0;
i<num_rows; ++
i) {
1058 h_v1(
i) = generate_fad<FadType>(
1059 num_rows, size_type(2), fad_size,
i, size_type(0));
1060 h_v2(i) = generate_fad<FadType>(
1061 num_rows, size_type(2), fad_size,
i, size_type(1));
1063 Kokkos::deep_copy(v1, h_v1);
1064 Kokkos::deep_copy(v2, h_v2);
1068 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1069 v3 = ViewType (
"view3", num_rows);
1071 v3 = ViewType (
"view3", num_rows, fad_size+1);
1073 Kokkos::deep_copy(v3, 1.0);
1077 host_view_type h_v3 = Kokkos::create_mirror_view(v3);
1078 Kokkos::deep_copy(h_v3, v3);
1082 for (size_type
i=0;
i<num_rows; ++
i) {
1084 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(0));
1086 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(1));
1088 success = success &&
checkFads(f3, h_v3(i), out);
1093 Kokkos_View_Fad, MultiplyConst,
FadType, Layout, Device )
1095 typedef Kokkos::View<const FadType*,Layout,Device,Kokkos::MemoryUnmanaged> ConstViewType;
1096 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
1097 typedef typename ViewType::size_type size_type;
1098 typedef typename ViewType::HostMirror host_view_type;
1105 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1106 v1 = ViewType (
"view1", num_rows);
1107 v2 = ViewType (
"view2", num_rows);
1109 v1 = ViewType (
"view1", num_rows, fad_size+1);
1110 v2 = ViewType (
"view2", num_rows, fad_size+1);
1112 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
1113 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
1114 for (size_type
i=0;
i<num_rows; ++
i) {
1115 h_v1(
i) = generate_fad<FadType>(
1116 num_rows, size_type(2), fad_size,
i, size_type(0));
1117 h_v2(i) = generate_fad<FadType>(
1118 num_rows, size_type(2), fad_size,
i, size_type(1));
1120 Kokkos::deep_copy(v1, h_v1);
1121 Kokkos::deep_copy(v2, h_v2);
1123 ConstViewType cv1 = v1;
1127 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1128 v3 = ViewType (
"view3", num_rows);
1130 v3 = ViewType (
"view3", num_rows, fad_size+1);
1135 host_view_type h_v3 = Kokkos::create_mirror_view(v3);
1136 Kokkos::deep_copy(h_v3, v3);
1140 for (size_type
i=0;
i<num_rows; ++
i) {
1142 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(0));
1144 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(1));
1146 success = success &&
checkFads(f3, h_v3(i), out);
1151 Kokkos_View_Fad, MultiplyMixed,
FadType, Layout, Device )
1153 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
1154 typedef typename ViewType::size_type size_type;
1155 typedef typename ViewType::HostMirror host_view_type;
1157 const size_type num_rows = 2;
1161 FadType f0 = generate_fad<FadType>(
1162 num_rows, size_type(2), fad_size, size_type(0), size_type(0));
1163 FadType f1 = generate_fad<FadType>(
1164 num_rows, size_type(2), fad_size, size_type(1), size_type(0));
1166 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1167 h_v = host_view_type (
"view1", num_rows);
1169 h_v = host_view_type (
"view1", num_rows, fad_size+1);
1182 Kokkos_View_Fad, AtomicAdd,
FadType, Layout, Device )
1184 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
1185 typedef Kokkos::View<FadType,Layout,Device> ScalarViewType;
1186 typedef typename ViewType::size_type size_type;
1187 typedef typename ScalarViewType::HostMirror host_scalar_view_type;
1194 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1195 v = ViewType (
"view", num_rows);
1197 v = ViewType (
"view", num_rows, fad_size+1);
1199 Kokkos::deep_copy(v, 2.3456);
1201 Kokkos::parallel_for(Kokkos::RangePolicy<Device>(0, num_rows), KOKKOS_LAMBDA(
const size_type
i) {
1202 for (size_type j = 0; j < fad_size; ++j)
1208 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1209 s = ScalarViewType (
"scalar view");
1211 s = ScalarViewType (
"scalar view", fad_size+1);
1218 host_scalar_view_type hs = Kokkos::create_mirror_view(s);
1219 Kokkos::deep_copy(hs, s);
1222 auto hv = Kokkos::create_mirror_view(v);
1223 Kokkos::deep_copy(hv, v);
1230 Kokkos_View_Fad, Rank8,
FadType, Layout, Device )
1232 typedef Kokkos::View<FadType*******,Layout,Device> ViewType;
1233 typedef typename ViewType::size_type size_type;
1234 typedef typename ViewType::HostMirror host_view_type;
1240 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1241 v = ViewType (
"view", 100, 1, 2, 3, 4, 5, 6);
1243 v = ViewType (
"view", 100, 1, 2, 3, 4, 5, 6, fad_size+1);
1245 host_view_type h_v = Kokkos::create_mirror_view(v);
1246 typename host_view_type::array_type h_a = h_v;
1247 Kokkos::deep_copy(h_a, 1.0);
1250 h_v(99,0,1,2,3,4,5) = f1;
1251 FadType f2 = h_v(99,0,1,2,3,4,5);
1258 Kokkos_View_Fad, Roger,
FadType, Layout, Device )
1260 Kokkos::View<FadType*,Layout,Device>
a;
1261 Kokkos::View<FadType**,Layout,Device> b;
1262 Kokkos::View<FadType***,Layout,Device>
c;
1263 Kokkos::View<FadType****,Layout,Device> d;
1264 Kokkos::View<FadType*****,Layout,Device> e;
1265 Kokkos::View<FadType******,Layout,Device>
f;
1266 Kokkos::View<FadType*******,Layout,Device>
g;
1268 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1269 a = Kokkos::View<FadType*,Layout,Device>(
"a",4);
1270 b = Kokkos::View<FadType**,Layout,Device> (
"b",4,4);
1271 c = Kokkos::View<FadType***,Layout,Device> (
"c",4,4,4);
1272 d = Kokkos::View<FadType****,Layout,Device> (
"d",4,4,4,4);
1273 e = Kokkos::View<FadType*****,Layout,Device> (
"e",4,4,4,4,4);
1274 f = Kokkos::View<FadType******,Layout,Device> (
"f",4,4,4,4,4,4);
1275 g = Kokkos::View<FadType*******,Layout,Device> (
"g",4,4,4,4,4,4,4);
1278 a = Kokkos::View<FadType*,Layout,Device>(
"a",4,fad_size+1);
1279 b = Kokkos::View<FadType**,Layout,Device> (
"b",4,4,fad_size+1);
1280 c = Kokkos::View<FadType***,Layout,Device> (
"c",4,4,4,fad_size+1);
1281 d = Kokkos::View<FadType****,Layout,Device> (
"d",4,4,4,4,fad_size+1);
1282 e = Kokkos::View<FadType*****,Layout,Device> (
"e",4,4,4,4,4,fad_size+1);
1283 f = Kokkos::View<FadType******,Layout,Device> (
"f",4,4,4,4,4,4,fad_size+1);
1284 g = Kokkos::View<FadType*******,Layout,Device> (
"g",4,4,4,4,4,4,4,fad_size+1);
1287 typedef typename Device::memory_space memory_space;
1288 const bool is_accessible =
1289 Kokkos::Impl::MemorySpaceAccess<Kokkos::HostSpace,
1290 memory_space>::accessible;
1291 if (is_accessible) {
1293 f(0,0,0,0,0,0) =
FadType(1.0);
1294 g(0,0,0,0,0,0,0) =
FadType(1.0);
1302 Kokkos_View_Fad, AssignDifferentStrides,
FadType, Layout, Device )
1304 typedef Kokkos::View<FadType**,Layout,Device> ViewType1;
1305 typedef Kokkos::View<FadType*,Layout,Device> ViewType2;
1306 typedef typename ViewType1::size_type size_type;
1307 typedef typename ViewType1::HostMirror host_view_type1;
1308 typedef typename ViewType2::HostMirror host_view_type2;
1316 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1317 v1 = ViewType1 (
"view1", num_rows, num_cols);
1319 v1 = ViewType1 (
"view1", num_rows, num_cols, fad_size+1);
1321 host_view_type1 h_v1 = Kokkos::create_mirror_view(v1);
1322 for (size_type
i=0;
i<num_rows; ++
i) {
1323 for (size_type j=0; j<num_cols; ++j) {
1324 h_v1(
i,j) = generate_fad<FadType>(
1325 num_rows, num_cols, fad_size,
i, j);
1328 Kokkos::deep_copy(v1, h_v1);
1332 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1333 v2 = ViewType2 (
"view2", num_rows);
1335 v2 = ViewType2 (
"view2", num_rows, fad_size+1);
1340 host_view_type2 h_v2 = Kokkos::create_mirror_view(v2);
1341 Kokkos::deep_copy(h_v2, v2);
1345 for (size_type
i=0;
i<num_rows; ++
i) {
1347 generate_fad<FadType>(num_rows, num_cols, fad_size,
i, size_type(1));
1348 success = success &&
checkFads(f, h_v2(i), out);
1353 Kokkos_View_Fad, ScalarValue,
FadType, Layout, Device )
1356 typedef Kokkos::View<FadType,Layout,Device> ViewType1;
1357 typedef Kokkos::View<ScalarType,Layout,Device> ViewType2;
1358 typedef typename ViewType1::size_type size_type;
1359 typedef typename ViewType1::HostMirror host_view_type1;
1360 typedef typename ViewType2::HostMirror host_view_type2;
1366 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1367 v1 = ViewType1 (
"view1");
1369 v1 = ViewType1 (
"view1", fad_size+1);
1371 host_view_type1 h_v1 = Kokkos::create_mirror_view(v1);
1372 h_v1() = generate_fad<FadType>(1, 1, fad_size, 0, 0);
1373 Kokkos::deep_copy(v1, h_v1);
1376 ViewType2 v2 = ViewType2 (
"view2");
1377 Kokkos::parallel_for(Kokkos::RangePolicy<Device>(0,1),
1378 KOKKOS_LAMBDA(
const size_type
i)
1384 host_view_type2 h_v2 = Kokkos::create_mirror_view(v2);
1385 Kokkos::deep_copy(h_v2, v2);
1392 #if defined(HAVE_SACADO_KOKKOS) && defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
1395 Kokkos_View_Fad, DynRankDimensionScalar,
FadType, Layout, Device )
1397 typedef Kokkos::DynRankView<double,Layout,Device> DoubleViewType;
1398 typedef Kokkos::DynRankView<FadType,Layout,Device> FadViewType;
1399 typedef typename FadViewType::size_type size_type;
1405 DoubleViewType v1(
"view1", num_rows);
1406 FadViewType v2 (
"view2", num_rows, fad_size+1);
1414 Kokkos_View_Fad, DynRankAssignStatic0,
FadType, Layout, Device )
1416 typedef Kokkos::View<FadType,Layout,Device> StaticViewType;
1417 typedef Kokkos::DynRankView<FadType,Layout,Device> DynamicViewType;
1418 typedef typename StaticViewType::size_type size_type;
1425 StaticViewType v1(
"view", fad_size+1);
1426 auto h_v1 = Kokkos::create_mirror_view(v1);
1427 h_v1() = generate_fad<FadType>(num_rows, num_cols, fad_size, size_type(0), size_type(0));
1428 Kokkos::deep_copy(v1, h_v1);
1431 DynamicViewType v2 = v1;
1434 auto h_v2 = Kokkos::create_mirror_view(v2);
1435 Kokkos::deep_copy(h_v2, v2);
1443 generate_fad<FadType>(num_rows, num_cols, fad_size, size_type(0), size_type(0));
1444 success = success &&
checkFads(f, h_v2(), out);
1448 Kokkos_View_Fad, DynRankAssignStatic1,
FadType, Layout, Device )
1450 typedef Kokkos::View<FadType*,Layout,Device> StaticViewType;
1451 typedef Kokkos::DynRankView<FadType,Layout,Device> DynamicViewType;
1452 typedef typename StaticViewType::size_type size_type;
1459 StaticViewType v1(
"view", num_rows, fad_size+1);
1460 auto h_v1 = Kokkos::create_mirror_view(v1);
1461 for (size_type
i=0;
i<num_rows; ++
i)
1463 generate_fad<FadType>(num_rows, num_cols, fad_size,
i, 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);
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 success = success &&
checkFads(f, h_v2(i), out);
1488 Kokkos_View_Fad, DynRankAssignStatic2,
FadType, Layout, Device )
1490 typedef Kokkos::View<FadType**,Layout,Device> StaticViewType;
1491 typedef Kokkos::DynRankView<FadType,Layout,Device> DynamicViewType;
1492 typedef typename StaticViewType::size_type size_type;
1499 StaticViewType v1(
"view", num_rows, num_cols, fad_size+1);
1500 auto h_v1 = Kokkos::create_mirror_view(v1);
1501 for (size_type i=0; i<num_rows; ++
i)
1502 for (size_type j=0; j<num_cols; ++j)
1503 h_v1(i,j) = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1504 Kokkos::deep_copy(v1, h_v1);
1507 DynamicViewType v2 = v1;
1510 auto h_v2 = Kokkos::create_mirror_view(v2);
1511 Kokkos::deep_copy(h_v2, v2);
1522 for (size_type i=0; i<num_rows; ++
i) {
1523 for (size_type j=0; j<num_cols; ++j) {
1524 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1525 success = success &&
checkFads(f, h_v2(i,j), out);
1531 Kokkos_View_Fad, DynRankMultiply,
FadType, Layout, Device )
1533 typedef Kokkos::DynRankView<FadType,Layout,Device> ViewType;
1534 typedef typename ViewType::size_type size_type;
1535 typedef typename ViewType::HostMirror host_view_type;
1541 ViewType v1(
"view1", num_rows, fad_size+1);
1542 ViewType v2(
"view2", num_rows, fad_size+1);
1543 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
1544 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
1545 for (size_type i=0; i<num_rows; ++
i) {
1546 h_v1(i) = generate_fad<FadType>(
1547 num_rows, size_type(2), fad_size,
i, size_type(0));
1548 h_v2(i) = generate_fad<FadType>(
1549 num_rows, size_type(2), fad_size,
i, size_type(1));
1551 Kokkos::deep_copy(v1, h_v1);
1552 Kokkos::deep_copy(v2, h_v2);
1555 ViewType v3(
"view3", num_rows, fad_size+1);
1559 host_view_type h_v3 = Kokkos::create_mirror_view(v3);
1560 Kokkos::deep_copy(h_v3, v3);
1565 for (size_type i=0; i<num_rows; ++
i) {
1567 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(0));
1569 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(1));
1571 success = success &&
checkFads(f3, h_v3(i), out);
1576 Kokkos_View_Fad, SubdynrankviewCol,
FadType, Layout, Device )
1578 typedef Kokkos::DynRankView<FadType,Layout,Device> ViewType;
1579 typedef typename ViewType::size_type size_type;
1580 typedef typename ViewType::HostMirror host_view_type;
1587 ViewType v(
"view", num_rows, num_cols, fad_size+1);
1588 host_view_type h_v = Kokkos::create_mirror_view(v);
1589 for (size_type i=0; i<num_rows; ++
i) {
1590 for (size_type j=0; j<num_cols; ++j) {
1591 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1595 Kokkos::deep_copy(v, h_v);
1599 auto s = Kokkos::subdynrankview(v, Kokkos::ALL(), col);
1602 typedef decltype(s) SubviewType;
1603 typedef typename SubviewType::HostMirror HostSubviewType;
1609 HostSubviewType h_s = Kokkos::subdynrankview(h_v, Kokkos::ALL(), col);
1613 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(s), fad_size+1, out, success);
1614 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(h_s), fad_size+1, out, success);
1615 TEUCHOS_TEST_EQUALITY(h_s.extent(0), num_rows, out, success);
1616 TEUCHOS_TEST_EQUALITY(h_s.extent(1), 1, out, success);
1617 TEUCHOS_TEST_EQUALITY(h_s.extent(7), 1, out, success);
1619 for (size_type i=0; i<num_rows; ++i) {
1620 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, col);
1621 success = success &&
checkFads(f, h_s(i), out);
1626 Kokkos_View_Fad, SubdynrankviewRow,
FadType, Layout, Device )
1628 typedef Kokkos::DynRankView<FadType,Layout,Device> ViewType;
1629 typedef typename ViewType::size_type size_type;
1630 typedef typename ViewType::HostMirror host_view_type;
1634 const size_type num_planes = 9;
1638 ViewType v(
"view", num_rows, num_cols, num_planes, fad_size+1);
1639 host_view_type h_v = Kokkos::create_mirror_view(v);
1640 for (size_type i=0; i<num_rows; ++
i) {
1641 for (size_type j=0; j<num_cols; ++j) {
1642 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1643 for (size_type k=0; k<num_planes; ++k) {
1644 h_v(i,j,k) = (k+1)*f;
1648 Kokkos::deep_copy(v, h_v);
1652 auto s = Kokkos::subdynrankview(v, row, Kokkos::ALL(), Kokkos::ALL());
1655 typedef decltype(s) SubviewType;
1656 typedef typename SubviewType::HostMirror HostSubviewType;
1662 HostSubviewType h_s =
1663 Kokkos::subdynrankview(h_v, row, Kokkos::ALL(), Kokkos::ALL());
1667 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(s), fad_size+1, out, success);
1668 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(h_s), fad_size+1, out, success);
1669 TEUCHOS_TEST_EQUALITY(h_s.extent(0), num_cols, out, success);
1670 TEUCHOS_TEST_EQUALITY(h_s.extent(1), num_planes, out, success);
1671 TEUCHOS_TEST_EQUALITY(h_s.extent(2), 1, out, success);
1672 TEUCHOS_TEST_EQUALITY(h_s.extent(7), 1, out, success);
1674 for (size_type j=0; j<num_cols; ++j) {
1675 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, row, j);
1676 for (size_type k=0; k<num_planes; ++k) {
1678 success = success &&
checkFads(g, h_s(j,k), out);
1684 Kokkos_View_Fad, SubdynrankviewScalar,
FadType, Layout, Device )
1686 typedef Kokkos::DynRankView<FadType,Layout,Device> ViewType;
1687 typedef typename ViewType::size_type size_type;
1688 typedef typename ViewType::HostMirror host_view_type;
1695 ViewType v(
"view", num_rows, num_cols, fad_size+1);
1696 host_view_type h_v = Kokkos::create_mirror_view(v);
1697 for (size_type i=0; i<num_rows; ++
i) {
1698 for (size_type j=0; j<num_cols; ++j) {
1699 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1703 Kokkos::deep_copy(v, h_v);
1708 auto s = Kokkos::subdynrankview(v, row, col);
1711 typedef decltype(s) SubviewType;
1712 typedef typename SubviewType::HostMirror HostSubviewType;
1718 HostSubviewType h_s = Kokkos::subdynrankview(h_v, row, col);
1722 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(s), fad_size+1, out, success);
1723 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(h_s), fad_size+1, out, success);
1725 success = success &&
checkFads(f, h_s(), out);
1731 Kokkos_View_Fad, DynRankDimensionScalar,
FadType, Layout, Device ) {}
1733 Kokkos_View_Fad, DynRankAssignStatic0,
FadType, Layout, Device ) {}
1735 Kokkos_View_Fad, DynRankAssignStatic1,
FadType, Layout, Device ) {}
1737 Kokkos_View_Fad, DynRankAssignStatic2,
FadType, Layout, Device ) {}
1739 Kokkos_View_Fad, DynRankMultiply,
FadType, Layout, Device ) {}
1741 Kokkos_View_Fad, SubdynrankviewCol,
FadType, Layout, Device ) {}
1743 Kokkos_View_Fad, SubdynrankviewRow,
FadType, Layout, Device ) {}
1745 Kokkos_View_Fad, SubdynrankviewScalar,
FadType, Layout, Device ) {}
1750 Kokkos_View_Fad, Subview,
FadType, Layout, Device )
1752 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
1753 typedef typename ViewType::size_type size_type;
1754 typedef typename ViewType::HostMirror host_view_type;
1762 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1763 v = ViewType (
"view", num_rows, num_cols);
1765 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
1767 host_view_type h_v = Kokkos::create_mirror_view(v);
1768 for (size_type i=0; i<num_rows; ++
i) {
1769 for (size_type j=0; j<num_cols; ++j) {
1770 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1774 Kokkos::deep_copy(v, h_v);
1778 auto s = Kokkos::subview(v, Kokkos::ALL(), col);
1781 typedef decltype(s) SubviewType;
1782 typedef typename SubviewType::HostMirror HostSubviewType;
1788 HostSubviewType h_s = Kokkos::subview(h_v, Kokkos::ALL(), col);
1792 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
1796 for (size_type i=0; i<num_rows; ++
i) {
1797 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, col);
1798 success = success &&
checkFads(f, h_s(i), out);
1803 Kokkos_View_Fad, Subview2,
FadType, Layout, Device )
1805 typedef Kokkos::View<FadType***,Layout,Device> ViewType;
1806 typedef typename ViewType::HostMirror host_view_type;
1812 const int num_cell = 5;
1813 const int num_qp = 4;
1814 const int num_dim = 3;
1815 const int num_deriv = 2;
1819 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1820 v = host_view_type (
"view", num_cell, num_qp, num_dim);
1822 v = host_view_type (
"view", num_cell, num_qp, num_dim, num_deriv+1);
1824 for (
int cell=0; cell < num_cell; ++cell) {
1825 for (
int qp=0; qp < num_qp; ++qp) {
1826 for (
int dim = 0; dim < num_dim; ++dim) {
1827 v(cell,qp,dim).val() = 100.*cell + 10.*qp + 1.*dim;
1828 for (
int deriv = 0; deriv < num_deriv; ++deriv) {
1829 v(cell,qp,dim).fastAccessDx(deriv) = v(cell,qp,dim).val() + (1.0*deriv)/10.;
1837 out <<
"checking subview(v,ALL,*,*)..." << std::endl;
1838 for (
int qp=0; qp < num_qp; ++qp) {
1839 for (
int dim=0; dim < num_dim; ++dim) {
1840 auto v_tmp = subview(v,Kokkos::ALL(),qp,dim);
1841 for (
int cell=0; cell < num_cell; ++cell) {
1842 out <<
"\tChecking (" << cell <<
"," << qp <<
"," << dim <<
")" << std::endl;
1843 success = success &&
checkFads(v(cell,qp,dim), v_tmp(cell), out);
1848 out <<
"checking subview(v,*,ALL,*)..." << std::endl;
1849 for (
int cell=0; cell < num_cell; ++cell) {
1850 for (
int dim=0; dim < num_dim; ++dim) {
1851 auto v_tmp = subview(v,cell,Kokkos::ALL(),dim);
1852 for (
int qp=0; qp < num_qp; ++qp) {
1853 out <<
"\tChecking (" << cell <<
"," << qp <<
"," << dim <<
")" << std::endl;
1854 success = success &&
checkFads(v(cell,qp,dim), v_tmp(qp), out);
1859 out <<
"checking subview(v,*,*,ALL)..." << std::endl;
1860 for (
int cell=0; cell < num_cell; ++cell) {
1861 for (
int qp=0; qp < num_qp; ++qp) {
1862 auto v_tmp = subview(v,cell,qp,Kokkos::ALL());
1863 for (
int dim=0; dim < num_dim; ++dim) {
1864 out <<
"\tChecking (" << cell <<
"," << qp <<
"," << dim <<
")" << std::endl;
1865 success = success &&
checkFads(v(cell,qp,dim), v_tmp(dim), out);
1870 out <<
"checking subview(v,ALL,ALL,*)..." << std::endl;
1871 for (
int dim=0; dim < num_dim; ++dim) {
1872 auto v_tmp = subview(v,Kokkos::ALL(),Kokkos::ALL(),dim);
1873 for (
int cell=0; cell < num_cell; ++cell) {
1874 for (
int qp=0; qp < num_qp; ++qp) {
1875 out <<
"\tChecking (" << cell <<
"," << qp <<
"," << dim <<
")" << std::endl;
1876 success = success &&
checkFads(v(cell,qp,dim), v_tmp(cell,qp), out);
1881 out <<
"checking subview(v,*,ALL,ALL)..." << std::endl;
1882 for (
int cell=0; cell < num_cell; ++cell) {
1883 auto v_tmp = subview(v,cell,Kokkos::ALL(),Kokkos::ALL());
1884 for (
int qp=0; qp < num_qp; ++qp) {
1885 for (
int dim=0; dim < num_dim; ++dim) {
1886 out <<
"\tChecking (" << cell <<
"," << qp <<
"," << dim <<
")" << std::endl;
1887 success = success &&
checkFads(v(cell,qp,dim), v_tmp(qp,dim), out);
1892 out <<
"checking subview(v,ALL,*,ALL)..." << std::endl;
1893 for (
int qp=0; qp < num_qp; ++qp) {
1894 auto v_tmp = subview(v,Kokkos::ALL(),qp,Kokkos::ALL());
1895 for (
int cell=0; cell < num_cell; ++cell) {
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(cell,dim), out);
1903 out <<
"checking subview(v,range,range,range)..." << std::endl;
1904 auto v_tmp = subview(v,std::make_pair(1,5),std::make_pair(1,4),std::make_pair(1,3));
1905 for (
int cell=1; cell < num_cell; ++cell) {
1906 for (
int qp=1; qp < num_qp; ++qp) {
1907 for (
int dim=1; dim < num_dim; ++dim) {
1908 out <<
"\tChecking (" << cell <<
"," << qp <<
"," << dim <<
")" << std::endl;
1909 success = success &&
checkFads(v(cell,qp,dim), v_tmp(cell-1,qp-1,dim-1), out);
1915 #ifdef SACADO_NEW_FAD_DESIGN_IS_DEFAULT
1917 Kokkos_View_Fad, ConstViewAssign,
FadType, Layout, Device )
1919 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
1920 typedef Kokkos::View<const FadType,Layout,Device> ConstViewType;
1921 typedef typename ViewType::size_type size_type;
1922 typedef typename ViewType::HostMirror host_view_type;
1923 typedef typename ViewType::execution_space exec_space;
1929 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1930 ViewType v1(
"view1", num_rows);
1932 ViewType v1(
"view1", num_rows, fad_size+1);
1934 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
1935 for (size_type i=0; i<num_rows; ++
i) {
1936 FadType f = generate_fad<FadType>(num_rows, size_type(1), fad_size,
i,
1940 Kokkos::deep_copy(v1, h_v1);
1942 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1943 ViewType v2(
"view2", num_rows);
1945 ViewType v2(
"view2", num_rows, fad_size+1);
1948 static const size_type stride = Kokkos::ViewScalarStride<ViewType>::stride;
1949 #if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
1950 const bool use_team =
1955 #elif defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
1956 const bool use_team =
1961 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
1962 const bool use_team =
1967 #elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
1968 const bool use_team =
1974 const bool use_team =
false;
1978 typedef Kokkos::TeamPolicy<exec_space> team_policy;
1979 Kokkos::parallel_for(team_policy(num_rows, 1, stride),
1980 KOKKOS_LAMBDA(
typename team_policy::member_type team)
1982 const int i = team.league_rank();
1983 typename ConstViewType::reference_type
x = v1(i);
1988 Kokkos::parallel_for(Kokkos::RangePolicy<exec_space>(0,num_rows),
1989 KOKKOS_LAMBDA(
const int i)
1991 typename ConstViewType::reference_type
x = v1(i);
1997 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
1998 Kokkos::deep_copy(h_v2, v2);
2002 for (size_type i=0; i<num_rows; ++
i) {
2003 FadType f = generate_fad<FadType>(num_rows, size_type(1), fad_size,
i,
2005 success = success &&
checkFads(f, h_v2(i), out);
2010 Kokkos_View_Fad, ConstViewAssign,
FadType, Layout, Device ) {}
2015 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
2017 Kokkos_View_Fad, ShmemSize,
FadType, Layout, Device )
2019 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
2020 typedef typename FadType::value_type value_type;
2021 typedef typename ViewType::size_type size_type;
2028 const size_type shmem_size =
2029 ViewType::shmem_size(num_rows, num_cols, fad_size+1);
2032 const size_type align = 8;
2033 const size_type mask = align - 1;
2035 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2036 v = ViewType (
"view", num_rows, num_cols);
2038 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
2040 const size_type shmem_size_expected =
2046 Kokkos_View_Fad, Unmanaged,
FadType, Layout, Device )
2051 typedef typename FadType::value_type scalar_type;
2052 typedef Kokkos::View<scalar_type***,TestLayout,Device> ViewType;
2053 typedef Kokkos::View<FadType**,TestLayout,Device,Kokkos::MemoryUnmanaged> FadViewType;
2054 typedef typename ViewType::size_type size_type;
2055 typedef typename ViewType::HostMirror host_view_type;
2056 typedef typename FadViewType::HostMirror fad_host_view_type;
2067 v = ViewType (
"view", fad_size+1, num_rows, num_cols);
2068 h_v = Kokkos::create_mirror_view(v);
2069 for (size_type i=0; i<num_rows; ++
i) {
2070 for (size_type j=0; j<num_cols; ++j) {
2071 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2072 for (size_type k=0; k<fad_size; k++)
2073 h_v(k,i,j) = f.dx(k);
2074 h_v(fad_size,i,j) = f.val();
2079 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
2080 h_v = Kokkos::create_mirror_view(v);
2081 for (size_type i=0; i<num_rows; ++
i) {
2082 for (size_type j=0; j<num_cols; ++j) {
2083 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2084 for (size_type k=0; k<fad_size; k++)
2085 h_v(i,j,k) = f.dx(k);
2086 h_v(i,j,fad_size) = f.val();
2090 Kokkos::deep_copy(v, h_v);
2094 fad_host_view_type h_v_fad;
2095 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2096 v_fad = FadViewType ( v.data(), num_rows, num_cols);
2097 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols);
2099 v_fad = FadViewType ( v.data(), num_rows, num_cols, fad_size+1);
2100 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols, fad_size+1);
2104 Kokkos::deep_copy(h_v_fad, v_fad);
2108 for (size_type i=0; i<num_rows; ++
i) {
2109 for (size_type j=0; j<num_cols; ++j) {
2110 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2111 success = success &&
checkFads(f, h_v_fad(i,j), out);
2117 Kokkos_View_Fad, Unmanaged2,
FadType, Layout, Device )
2122 typedef typename FadType::value_type scalar_type;
2123 typedef Kokkos::View<scalar_type***,TestLayout,Device> ViewType;
2124 typedef Kokkos::View<FadType**,TestLayout,Device> FadViewType;
2125 typedef typename ViewType::size_type size_type;
2126 typedef typename ViewType::HostMirror host_view_type;
2127 typedef typename FadViewType::HostMirror fad_host_view_type;
2138 v = ViewType (
"view", fad_size+1, num_rows, num_cols);
2139 h_v = Kokkos::create_mirror_view(v);
2140 for (size_type i=0; i<num_rows; ++
i) {
2141 for (size_type j=0; j<num_cols; ++j) {
2142 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2143 for (size_type k=0; k<fad_size; k++)
2144 h_v(k,i,j) = f.dx(k);
2145 h_v(fad_size,i,j) = f.val();
2150 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
2151 h_v = Kokkos::create_mirror_view(v);
2152 for (size_type i=0; i<num_rows; ++
i) {
2153 for (size_type j=0; j<num_cols; ++j) {
2154 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2155 for (size_type k=0; k<fad_size; k++)
2156 h_v(i,j,k) = f.dx(k);
2157 h_v(i,j,fad_size) = f.val();
2161 Kokkos::deep_copy(v, h_v);
2165 fad_host_view_type h_v_fad;
2166 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2167 v_fad = FadViewType ( v.data(), num_rows, num_cols);
2168 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols);
2170 v_fad = FadViewType ( v.data(), num_rows, num_cols, fad_size+1);
2171 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols, fad_size+1);
2175 Kokkos::deep_copy(h_v_fad, v_fad);
2179 for (size_type i=0; i<num_rows; ++
i) {
2180 for (size_type j=0; j<num_cols; ++j) {
2181 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2182 success = success &&
checkFads(f, h_v_fad(i,j), out);
2188 Kokkos_View_Fad, UnmanagedConst,
FadType, Layout, Device )
2193 typedef typename FadType::value_type scalar_type;
2194 typedef Kokkos::View<scalar_type***,TestLayout,Device> ViewType;
2195 typedef Kokkos::View<const scalar_type***,TestLayout,Device> ConstViewType;
2196 typedef Kokkos::View<FadType**,TestLayout,Device,Kokkos::MemoryUnmanaged> FadViewType;
2197 typedef Kokkos::View<const FadType**,TestLayout,Device,Kokkos::MemoryUnmanaged> ConstFadViewType;
2198 typedef typename ViewType::size_type size_type;
2199 typedef typename ViewType::HostMirror host_view_type;
2200 typedef typename FadViewType::HostMirror fad_host_view_type;
2211 v = ViewType (
"view", fad_size+1, num_rows, num_cols);
2212 h_v = Kokkos::create_mirror_view(v);
2213 for (size_type i=0; i<num_rows; ++
i) {
2214 for (size_type j=0; j<num_cols; ++j) {
2215 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2216 for (size_type k=0; k<fad_size; k++)
2217 h_v(k,i,j) = f.dx(k);
2218 h_v(fad_size,i,j) = f.val();
2223 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
2224 h_v = Kokkos::create_mirror_view(v);
2225 for (size_type i=0; i<num_rows; ++
i) {
2226 for (size_type j=0; j<num_cols; ++j) {
2227 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2228 for (size_type k=0; k<fad_size; k++)
2229 h_v(i,j,k) = f.dx(k);
2230 h_v(i,j,fad_size) = f.val();
2234 Kokkos::deep_copy(v, h_v);
2235 ConstViewType v_const = v;
2239 ConstFadViewType v_fad;
2240 fad_host_view_type h_v_fad;
2241 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2242 v_fad = ConstFadViewType ( v_const.data(), num_rows, num_cols);
2243 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols);
2245 v_fad = ConstFadViewType ( v_const.data(), num_rows, num_cols, fad_size+1);
2246 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols, fad_size+1);
2250 Kokkos::deep_copy(h_v_fad, v_fad);
2254 for (size_type i=0; i<num_rows; ++
i) {
2255 for (size_type j=0; j<num_cols; ++j) {
2256 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2257 success = success &&
checkFads(f, h_v_fad(i,j), out);
2263 Kokkos_View_Fad, UnmanagedConst2,
FadType, Layout, Device )
2267 typedef typename FadType::value_type scalar_type;
2268 typedef Kokkos::View<scalar_type***,TestLayout,Device> ViewType;
2269 typedef Kokkos::View<const scalar_type***,TestLayout,Device> ConstViewType;
2270 typedef Kokkos::View<FadType**,TestLayout,Device> FadViewType;
2271 typedef Kokkos::View<const FadType**,TestLayout,Device> ConstFadViewType;
2272 typedef typename ViewType::size_type size_type;
2273 typedef typename ViewType::HostMirror host_view_type;
2274 typedef typename FadViewType::HostMirror fad_host_view_type;
2285 v = ViewType (
"view", fad_size+1, num_rows, num_cols);
2286 h_v = Kokkos::create_mirror_view(v);
2287 for (size_type i=0; i<num_rows; ++
i) {
2288 for (size_type j=0; j<num_cols; ++j) {
2289 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2290 for (size_type k=0; k<fad_size; k++)
2291 h_v(k,i,j) = f.dx(k);
2292 h_v(fad_size,i,j) = f.val();
2297 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
2298 h_v = Kokkos::create_mirror_view(v);
2299 for (size_type i=0; i<num_rows; ++
i) {
2300 for (size_type j=0; j<num_cols; ++j) {
2301 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2302 for (size_type k=0; k<fad_size; k++)
2303 h_v(i,j,k) = f.dx(k);
2304 h_v(i,j,fad_size) = f.val();
2308 Kokkos::deep_copy(v, h_v);
2309 ConstViewType v_const = v;
2312 ConstFadViewType v_fad;
2313 fad_host_view_type h_v_fad;
2314 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2315 v_fad = ConstFadViewType (v_const.data(), num_rows, num_cols);
2316 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols);
2318 v_fad = ConstFadViewType (v_const.data(), num_rows, num_cols, fad_size+1);
2319 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols, fad_size+1);
2323 Kokkos::deep_copy(h_v_fad, v_fad);
2327 for (size_type i=0; i<num_rows; ++
i) {
2328 for (size_type j=0; j<num_cols; ++j) {
2329 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2330 success = success &&
checkFads(f, h_v_fad(i,j), out);
2338 Kokkos_View_Fad, SFadNoSizeArg,
FadType, Layout, Device )
2340 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
2341 typedef typename ViewType::size_type size_type;
2342 typedef typename ViewType::HostMirror host_view_type;
2349 ViewType v(
"view", num_rows, num_cols);
2350 host_view_type h_v = Kokkos::create_mirror_view(v);
2351 for (size_type i=0; i<num_rows; ++
i) {
2352 for (size_type j=0; j<num_cols; ++j) {
2353 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2357 Kokkos::deep_copy(v, h_v);
2360 Kokkos::deep_copy(h_v, v);
2366 for (size_type i=0; i<num_rows; ++
i) {
2367 for (size_type j=0; j<num_cols; ++j) {
2368 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2369 success = success &&
checkFads(f, h_v(i,j), out);
2375 Kokkos_View_Fad, Partition,
FadType, Layout, Device )
2377 #if !defined(SACADO_VIEW_CUDA_HIERARCHICAL) && !defined(SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
2378 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
2379 typedef typename ViewType::size_type size_type;
2380 typedef typename ViewType::HostMirror host_view_type;
2388 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2389 v = ViewType (
"view", num_rows, num_cols);
2391 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
2393 host_view_type h_v = Kokkos::create_mirror_view(v);
2395 for (size_type i=0; i<num_rows; ++
i) {
2396 for (size_type j=0; j<num_cols; ++j) {
2397 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2401 Kokkos::deep_copy(v, h_v);
2404 Kokkos::deep_copy(h_v, v);
2408 const size_type stride = 2;
2409 auto h_v1 = Kokkos::partition<2>(h_v, 0, stride);
2410 auto h_v2 = Kokkos::partition<2>(h_v, 1, stride);
2413 const size_type fad_size_1 = (fad_size + stride - 0 - 1) / stride;
2414 const size_type fad_size_2 = (fad_size + stride - 1 - 1) / stride;
2418 for (size_type i=0; i<num_rows; ++
i) {
2419 for (size_type j=0; j<num_cols; ++j) {
2420 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2423 for (
unsigned int k=0; k<fad_size_1; ++k)
2424 if (2*k < fad_size) f1.fastAccessDx(k) = f.dx(2*k);
2425 for (
unsigned int k=0; k<fad_size_2; ++k)
2426 if (2*k+1 < fad_size) f2.fastAccessDx(k) = f.dx(2*k+1);
2427 success = success &&
checkFads(f1, h_v1(i,j), out);
2428 success = success &&
checkFads(f2, h_v2(i,j), out);
2435 Kokkos_View_Fad, AssignLayoutContiguousToLayoutStride,
FadType, Layout, Device )
2437 typedef Kokkos::View<FadType**,Kokkos::LayoutContiguous<Layout>,Device> ContViewType;
2438 typedef Kokkos::View<FadType**,Kokkos::LayoutStride,Device> StrideViewType;
2439 typedef typename ContViewType::size_type size_type;
2440 typedef typename ContViewType::HostMirror cont_host_view_type;
2441 typedef typename StrideViewType::HostMirror stride_host_view_type;
2449 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2450 v = ContViewType (
"view", num_rows, num_cols);
2452 v = ContViewType (
"view", num_rows, num_cols, fad_size+1);
2454 cont_host_view_type h_v = Kokkos::create_mirror_view(v);
2456 for (size_type i=0; i<num_rows; ++
i) {
2457 for (size_type j=0; j<num_cols; ++j) {
2458 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2462 Kokkos::deep_copy(v, h_v);
2465 StrideViewType vs = v;
2472 stride_host_view_type h_vs = h_v;
2479 for (size_type i=0; i<num_rows; ++
i) {
2480 for (size_type j=0; j<num_cols; ++j) {
2481 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2482 success = success &&
checkFads(f, h_vs(i,j), out);
2488 Kokkos_View_Fad, CommonViewAllocMixedSpec,
FadType, Layout, Device )
2490 typedef Kokkos::View<FadType**,Kokkos::LayoutContiguous<Layout>,Device> ContViewType;
2491 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
2492 typedef typename ContViewType::size_type size_type;
2500 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2501 v1 = ContViewType (
"view", num_rows, num_cols);
2503 v1 = ContViewType (
"view", num_rows, num_cols, fad_size+1);
2507 auto cprop = Kokkos::common_view_alloc_prop(v1);
2508 ViewType v2(Kokkos::view_alloc(
"v2",cprop), num_rows, num_cols);
2520 Kokkos_View_Fad, ShmemSize,
FadType, Layout, Device )
2522 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
2523 typedef typename ViewType::size_type size_type;
2529 const size_type shmem_size =
2530 ViewType::shmem_size(num_rows, num_cols);
2533 static const size_type align = 8;
2534 static const size_type mask = align - 1;
2535 const size_type shmem_size_expected =
2541 Kokkos_View_Fad, Unmanaged,
FadType, Layout, Device ) {}
2544 Kokkos_View_Fad, Unmanaged2,
FadType, Layout, Device ) {}
2547 Kokkos_View_Fad, UnmanagedConst,
FadType, Layout, Device ) {}
2550 Kokkos_View_Fad, UnmanagedConst2,
FadType, Layout, Device ) {}
2553 Kokkos_View_Fad, SFadNoSizeArg,
FadType, Layout, Device ) {}
2556 Kokkos_View_Fad, Partition,
FadType, Layout, Device ) {}
2559 Kokkos_View_Fad, AssignLayoutContiguousToLayoutStride,
FadType, Layout, Device ) {}
2562 Kokkos_View_Fad, CommonViewAllocMixedSpec,
FadType, Layout, Device ) {}
2566 #define VIEW_FAD_TESTS_FLD( F, L, D ) \
2567 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Size, F, L, D ) \
2568 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy, F, L, D ) \
2569 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy_ConstantScalar, F, L, D ) \
2570 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy_ConstantZero, F, L, D ) \
2571 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy_ConstantFad, F, L, D ) \
2572 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy_ConstantFadFull, F, L, D ) \
2573 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, LocalDeepCopy, F, L, D ) \
2574 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, LocalDeepCopyTeam, F, L, D ) \
2575 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, ScalarAssign, F, L, D ) \
2576 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, ValueAssign, F, L, D ) \
2577 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Resize, F, L, D ) \
2578 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Unmanaged, F, L, D ) \
2579 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Unmanaged2, F, L, D ) \
2580 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, UnmanagedConst, F, L, D ) \
2581 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, UnmanagedConst2, F, L, D ) \
2582 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Multiply, F, L, D ) \
2583 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, MultiplyUpdate, F, L, D ) \
2584 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, MultiplyConst, F, L, D ) \
2585 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, MultiplyMixed, F, L, D ) \
2586 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Rank8, F, L, D ) \
2587 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Roger, F, L, D ) \
2588 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, AtomicAdd, F, L, D ) \
2589 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, AssignDifferentStrides, F, L, D ) \
2590 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, ScalarValue, F, L, D ) \
2591 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankDimensionScalar, F, L, D ) \
2592 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankAssignStatic0, F, L, D ) \
2593 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankAssignStatic1, F, L, D ) \
2594 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankAssignStatic2, F, L, D ) \
2595 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankMultiply, F, L, D ) \
2596 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, SubdynrankviewCol, F, L, D ) \
2597 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, SubdynrankviewRow, F, L, D ) \
2598 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, SubdynrankviewScalar, F, L, D ) \
2599 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Subview, F, L, D ) \
2600 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Subview2, F, L, D ) \
2601 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, ShmemSize, F, L, D ) \
2602 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, ConstViewAssign, F, L, D )
2604 #define VIEW_FAD_TESTS_SFLD( F, L, D ) \
2605 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, SFadNoSizeArg, F, L, D )
2607 #define VIEW_FAD_TESTS_FDI( F, D ) \
2608 using Kokkos::LayoutLeft; \
2609 using Kokkos::LayoutRight; \
2610 VIEW_FAD_TESTS_FLD( F, LayoutLeft, D ) \
2611 VIEW_FAD_TESTS_FLD( F, LayoutRight, D ) \
2612 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, AssignLayoutContiguousToLayoutStride, F, LayoutLeft, D ) \
2613 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, AssignLayoutContiguousToLayoutStride, F, LayoutRight, D ) \
2614 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, CommonViewAllocMixedSpec, F, LayoutLeft, D ) \
2615 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, CommonViewAllocMixedSpec, F, LayoutRight, D )
2617 #define VIEW_FAD_TESTS_SFDI( F, D ) \
2618 using Kokkos::LayoutLeft; \
2619 using Kokkos::LayoutRight; \
2620 VIEW_FAD_TESTS_SFLD( F, LayoutLeft, D ) \
2621 VIEW_FAD_TESTS_SFLD( F, LayoutRight, D )
2623 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
2626 #define VIEW_FAD_TESTS_FDC( F, D ) \
2627 VIEW_FAD_TESTS_FLD( F, LeftContiguous, D ) \
2628 VIEW_FAD_TESTS_FLD( F, RightContiguous, D ) \
2629 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Partition, F, LeftContiguous, D ) \
2630 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Partition, F, RightContiguous, D )
2632 #define VIEW_FAD_TESTS_SFDC( F, D ) \
2633 VIEW_FAD_TESTS_SFLD( F, LeftContiguous, D ) \
2634 VIEW_FAD_TESTS_SFLD( F, RightContiguous, D )
2636 #define VIEW_FAD_TESTS_FDC( F, D )
2637 #define VIEW_FAD_TESTS_SFDC( F, D )
2640 #define VIEW_FAD_TESTS_FD( F, D ) \
2641 VIEW_FAD_TESTS_FDI( F, D ) \
2642 VIEW_FAD_TESTS_FDC( F, D )
2644 #define VIEW_FAD_TESTS_SFD( F, D ) \
2645 VIEW_FAD_TESTS_SFDI( F, D ) \
2646 VIEW_FAD_TESTS_SFDC( F, D )
2669 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC) && SACADO_TEST_DFAD
2670 #define VIEW_FAD_TESTS_D( D ) \
2671 VIEW_FAD_TESTS_FD( SFadType, D ) \
2672 VIEW_FAD_TESTS_FD( SLFadType, D ) \
2673 VIEW_FAD_TESTS_FD( DFadType, D ) \
2674 VIEW_FAD_TESTS_SFD( SFadType, D )
2694 #define VIEW_FAD_TESTS_D( D ) \
2695 VIEW_FAD_TESTS_FD( SFadType, D ) \
2696 VIEW_FAD_TESTS_FD( SLFadType, D ) \
2697 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