36 static const bool value =
false;
39 template <
typename T,
int N>
46 static const bool value =
false;
54 template <
typename FadType1,
typename FadType2>
55 bool checkFads(
const FadType1& x,
const FadType2& x2,
67 for (
int i=0; i<x.size(); ++i)
73 template <
typename fadtype,
typename ordinal>
76 const ordinal num_cols,
77 const ordinal fad_size,
81 typedef typename fadtype::value_type scalar;
82 fadtype x(fad_size, scalar(0.0));
84 const scalar x_row = 100.0 + scalar(num_rows) / scalar(row+1);
85 const scalar x_col = 10.0 + scalar(num_cols) / scalar(col+1);
86 x.val() = x_row + x_col;
87 for (ordinal i=0; i<fad_size; ++i) {
88 const scalar x_fad = 1.0 + scalar(fad_size) / scalar(i+1);
89 x.fastAccessDx(i) = x_row + x_col + x_fad;
94 #ifndef GLOBAL_FAD_SIZE
95 #define GLOBAL_FAD_SIZE 5
102 template <
typename InputViewType1,
103 typename InputViewType2 = InputViewType1,
104 typename OutputViewType = InputViewType1>
118 const InputViewType2 v2,
119 const OutputViewType v3,
135 const size_type i = team.league_rank()*team.team_size() + team.team_rank();
136 if (i <
m_v1.extent(0))
141 static void apply(
const InputViewType1 v1,
142 const InputViewType2 v2,
143 const OutputViewType v3,
144 const bool update =
false) {
147 #if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
148 const size_type stride = Kokkos::ViewScalarStride<InputViewType1>::stride;
149 const bool use_team =
150 std::is_same<execution_space, Kokkos::Cuda>::value &&
151 ( Kokkos::is_view_fad_contiguous<InputViewType1>::value ||
152 Kokkos::is_dynrankview_fad_contiguous<InputViewType1>::value ) &&
154 #elif defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
156 const bool use_team =
157 std::is_same<execution_space, Kokkos::Cuda>::value &&
158 ( Kokkos::is_view_fad_contiguous<InputViewType1>::value ||
159 Kokkos::is_dynrankview_fad_contiguous<InputViewType1>::value ) &&
163 const bool use_team =
false;
167 const size_type team_size = 256 / stride;
179 template <
typename ViewType>
183 typedef typename ViewType::value_type::value_type
ScalarType;
204 const size_type i = team.league_rank()*team.team_size() + team.team_rank();
205 if (i <
m_v.extent(0))
213 #if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
214 const bool use_team =
215 std::is_same<execution_space, Kokkos::Cuda>::value &&
216 ( Kokkos::is_view_fad_contiguous<ViewType>::value ||
217 Kokkos::is_dynrankview_fad_contiguous<ViewType>::value ) &&
219 #elif defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
220 const bool use_team =
221 std::is_same<execution_space, Kokkos::Cuda>::value &&
222 ( Kokkos::is_view_fad_contiguous<ViewType>::value ||
223 Kokkos::is_dynrankview_fad_contiguous<ViewType>::value ) &&
226 const bool use_team =
false;
242 template <
typename ViewType>
269 const size_type i = team.league_rank()*team.team_size() + team.team_rank();
270 if (i <
m_v.extent(0))
278 #if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
279 const bool use_team =
280 std::is_same<execution_space, Kokkos::Cuda>::value &&
281 ( Kokkos::is_view_fad_contiguous<ViewType>::value ||
282 Kokkos::is_dynrankview_fad_contiguous<ViewType>::value ) &&
284 #elif defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
285 const bool use_team =
286 std::is_same<execution_space, Kokkos::Cuda>::value &&
287 ( Kokkos::is_view_fad_contiguous<ViewType>::value ||
288 Kokkos::is_dynrankview_fad_contiguous<ViewType>::value ) &&
291 const bool use_team =
false;
307 template <
typename InputViewType,
308 typename OutputViewType,
309 typename Enabled =
void>
323 const OutputViewType v2,
326 static_assert(
unsigned(InputViewType::Rank) == 2 ,
327 "Require rank-2 input view" );
328 static_assert(
unsigned(OutputViewType::Rank) == 1 ,
329 "Require rank-1 output view" );
341 const size_type i = team.league_rank()*team.team_size() + team.team_rank();
342 if (i <
m_v1.extent(0))
347 static void apply(
const InputViewType v1,
348 const OutputViewType v2,
352 #if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
353 const bool use_team =
354 std::is_same<execution_space, Kokkos::Cuda>::value &&
355 ( Kokkos::is_view_fad_contiguous<InputViewType>::value ||
356 Kokkos::is_dynrankview_fad_contiguous<InputViewType>::value ) &&
358 #elif defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
359 const bool use_team =
360 std::is_same<execution_space, Kokkos::Cuda>::value &&
361 ( Kokkos::is_view_fad_contiguous<InputViewType>::value ||
362 Kokkos::is_dynrankview_fad_contiguous<InputViewType>::value ) &&
365 const bool use_team =
false;
381 template <
typename ViewType,
typename ScalarViewType>
401 Kokkos::atomic_add(&(
m_s()), x);
407 const size_type i = team.league_rank()*team.team_size() + team.team_rank();
408 if (i <
m_v.extent(0))
413 static void apply(
const ViewType& v,
const ScalarViewType& s) {
416 #if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
417 const bool use_team =
418 std::is_same<execution_space, Kokkos::Cuda>::value &&
419 ( Kokkos::is_view_fad_contiguous<ViewType>::value ||
420 Kokkos::is_dynrankview_fad_contiguous<ViewType>::value ) &&
422 #elif defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
423 const bool use_team =
424 std::is_same<execution_space, Kokkos::Cuda>::value &&
425 ( Kokkos::is_view_fad_contiguous<ViewType>::value ||
426 Kokkos::is_dynrankview_fad_contiguous<ViewType>::value ) &&
429 const bool use_team =
false;
445 Kokkos_View_Fad, Size,
FadType, Layout, Device )
447 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
448 typedef typename ViewType::size_type size_type;
454 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
455 v = ViewType(
"view", num_rows);
458 v = ViewType(
"view", num_rows, fad_size+1);
464 Kokkos_View_Fad, DeepCopy,
FadType, Layout, Device )
466 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
467 typedef typename ViewType::size_type size_type;
468 typedef typename ViewType::HostMirror host_view_type;
476 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
477 v = ViewType (
"view", num_rows, num_cols);
479 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
481 host_view_type h_v = Kokkos::create_mirror_view(v);
482 for (size_type i=0; i<num_rows; ++i)
483 for (size_type j=0; j<num_cols; ++j)
484 h_v(i,j) = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
485 Kokkos::deep_copy(v, h_v);
488 host_view_type h_v2 = Kokkos::create_mirror_view(v);
489 Kokkos::deep_copy(h_v2, v);
493 for (size_type i=0; i<num_rows; ++i) {
494 for (size_type j=0; j<num_cols; ++j) {
495 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
496 success = success &&
checkFads(f, h_v2(i,j), out);
502 Kokkos_View_Fad, DeepCopy_ConstantScalar,
FadType, Layout, Device )
504 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
505 typedef typename ViewType::size_type size_type;
506 typedef typename ViewType::HostMirror host_view_type;
507 typedef typename FadType::value_type value_type;
514 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
515 v = ViewType (
"view", num_rows, num_cols);
518 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
520 typename ViewType::array_type va = v;
521 Kokkos::deep_copy( va, 1.0 );
524 value_type
a = 2.3456;
525 Kokkos::deep_copy( v, a );
528 host_view_type hv = Kokkos::create_mirror_view(v);
529 Kokkos::deep_copy(hv, v);
533 for (size_type i=0; i<num_rows; ++i) {
534 for (size_type j=0; j<num_cols; ++j) {
535 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
540 success = success &&
checkFads(f, hv(i,j), out);
546 Kokkos_View_Fad, DeepCopy_ConstantZero,
FadType, Layout, Device )
548 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
549 typedef typename ViewType::size_type size_type;
550 typedef typename ViewType::HostMirror host_view_type;
551 typedef typename FadType::value_type value_type;
558 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
559 v = ViewType (
"view", num_rows, num_cols);
562 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
564 typename ViewType::array_type va = v;
565 Kokkos::deep_copy( va, 1.0 );
569 Kokkos::deep_copy( v, a );
572 host_view_type hv = Kokkos::create_mirror_view(v);
573 Kokkos::deep_copy(hv, v);
577 for (size_type i=0; i<num_rows; ++i) {
578 for (size_type j=0; j<num_cols; ++j) {
579 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
584 success = success &&
checkFads(f, hv(i,j), out);
590 Kokkos_View_Fad, DeepCopy_ConstantFad,
FadType, Layout, Device )
592 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
593 typedef typename ViewType::size_type size_type;
594 typedef typename ViewType::HostMirror host_view_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_ConstantFadFull,
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;
645 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
646 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 for (size_type i=0; i<fad_size; ++i)
656 a.fastAccessDx(i) = 7.89 + (i+1);
657 Kokkos::deep_copy( v, a );
660 host_view_type hv = Kokkos::create_mirror_view(v);
661 Kokkos::deep_copy(hv, v);
665 for (size_type i=0; i<num_rows; ++i) {
666 for (size_type j=0; j<num_cols; ++j) {
667 success = success &&
checkFads(a, hv(i,j), out);
673 Kokkos_View_Fad, ScalarAssign,
FadType, Layout, Device )
675 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
676 typedef typename ViewType::size_type size_type;
677 typedef typename ViewType::HostMirror host_view_type;
678 typedef typename FadType::value_type value_type;
684 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
685 v = ViewType (
"view", num_rows);
688 v = ViewType (
"view", num_rows, fad_size+1);
690 typename ViewType::array_type va = v;
691 Kokkos::deep_copy( va, 1.0 );
694 value_type
a = 2.3456;
698 host_view_type hv = Kokkos::create_mirror_view(v);
699 Kokkos::deep_copy(hv, v);
703 for (size_type i=0; i<num_rows; ++i) {
704 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
709 success = success &&
checkFads(f, hv(i), out);
714 Kokkos_View_Fad, ValueAssign,
FadType, Layout, Device )
716 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
717 typedef typename ViewType::size_type size_type;
718 typedef typename ViewType::HostMirror host_view_type;
725 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
726 v = ViewType (
"view", num_rows);
728 v = ViewType (
"view", num_rows, fad_size+1);
730 typename ViewType::array_type va = v;
731 Kokkos::deep_copy( va, 1.0 );
735 for (size_type i=0; i<fad_size; ++i)
736 a.fastAccessDx(i) = 7.89+i;
740 host_view_type hv = Kokkos::create_mirror_view(v);
741 Kokkos::deep_copy(hv, v);
745 for (size_type i=0; i<num_rows; ++i) {
746 success = success &&
checkFads(a, hv(i), out);
751 Kokkos_View_Fad, Resize,
FadType, Layout, Device )
753 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
754 typedef typename ViewType::size_type size_type;
755 typedef typename ViewType::HostMirror host_view_type;
763 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
764 v = ViewType (
"view", num_rows, num_cols);
766 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
768 host_view_type h_v = Kokkos::create_mirror_view(v);
769 for (size_type i=0; i<num_rows; ++i)
770 for (size_type j=0; j<num_cols; ++j)
771 h_v(i,j) = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
772 Kokkos::deep_copy(v, h_v);
775 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
776 Kokkos::resize(v, num_rows, num_cols+1);
778 Kokkos::resize(v, num_rows, num_cols+1, fad_size+1);
782 host_view_type h_v2 = Kokkos::create_mirror_view(v);
783 Kokkos::deep_copy(h_v2, v);
787 for (size_type i=0; i<num_rows; ++i) {
788 for (size_type j=0; j<num_cols; ++j) {
789 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
790 success = success &&
checkFads(f, h_v2(i,j), out);
792 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
797 success = success &&
checkFads(f, h_v2(i,num_cols), out);
802 Kokkos_View_Fad, Multiply,
FadType, Layout, Device )
804 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
805 typedef typename ViewType::size_type size_type;
806 typedef typename ViewType::HostMirror host_view_type;
813 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
814 v1 = ViewType (
"view1", num_rows);
815 v2 = ViewType (
"view2", num_rows);
817 v1 = ViewType (
"view1", num_rows, fad_size+1);
818 v2 = ViewType (
"view2", num_rows, fad_size+1);
820 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
821 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
822 for (size_type i=0; i<num_rows; ++i) {
823 h_v1(i) = generate_fad<FadType>(
824 num_rows, size_type(2), fad_size, i, size_type(0));
825 h_v2(i) = generate_fad<FadType>(
826 num_rows, size_type(2), fad_size, i, size_type(1));
828 Kokkos::deep_copy(v1, h_v1);
829 Kokkos::deep_copy(v2, h_v2);
833 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
834 v3 = ViewType (
"view3", num_rows);
836 v3 = ViewType (
"view3", num_rows, fad_size+1);
841 host_view_type h_v3 = Kokkos::create_mirror_view(v3);
842 Kokkos::deep_copy(h_v3, v3);
846 for (size_type i=0; i<num_rows; ++i) {
848 generate_fad<FadType>(num_rows, size_type(2), fad_size, i, size_type(0));
850 generate_fad<FadType>(num_rows, size_type(2), fad_size, i, size_type(1));
852 success = success &&
checkFads(f3, h_v3(i), out);
857 Kokkos_View_Fad, MultiplyUpdate,
FadType, Layout, Device )
859 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
860 typedef typename ViewType::size_type size_type;
861 typedef typename ViewType::HostMirror host_view_type;
868 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
869 v1 = ViewType (
"view1", num_rows);
870 v2 = ViewType (
"view2", num_rows);
872 v1 = ViewType (
"view1", num_rows, fad_size+1);
873 v2 = ViewType (
"view2", num_rows, fad_size+1);
875 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
876 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
877 for (size_type i=0; i<num_rows; ++i) {
878 h_v1(i) = generate_fad<FadType>(
879 num_rows, size_type(2), fad_size, i, size_type(0));
880 h_v2(i) = generate_fad<FadType>(
881 num_rows, size_type(2), fad_size, i, size_type(1));
883 Kokkos::deep_copy(v1, h_v1);
884 Kokkos::deep_copy(v2, h_v2);
888 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
889 v3 = ViewType (
"view3", num_rows);
891 v3 = ViewType (
"view3", num_rows, fad_size+1);
893 Kokkos::deep_copy(v3, 1.0);
897 host_view_type h_v3 = Kokkos::create_mirror_view(v3);
898 Kokkos::deep_copy(h_v3, v3);
902 for (size_type i=0; i<num_rows; ++i) {
904 generate_fad<FadType>(num_rows, size_type(2), fad_size, i, size_type(0));
906 generate_fad<FadType>(num_rows, size_type(2), fad_size, i, size_type(1));
908 success = success &&
checkFads(f3, h_v3(i), out);
913 Kokkos_View_Fad, MultiplyConst,
FadType, Layout, Device )
915 typedef Kokkos::View<const FadType*,Layout,Device,Kokkos::MemoryUnmanaged> ConstViewType;
916 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
917 typedef typename ViewType::size_type size_type;
918 typedef typename ViewType::HostMirror host_view_type;
925 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
926 v1 = ViewType (
"view1", num_rows);
927 v2 = ViewType (
"view2", num_rows);
929 v1 = ViewType (
"view1", num_rows, fad_size+1);
930 v2 = ViewType (
"view2", num_rows, fad_size+1);
932 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
933 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
934 for (size_type i=0; i<num_rows; ++i) {
935 h_v1(i) = generate_fad<FadType>(
936 num_rows, size_type(2), fad_size, i, size_type(0));
937 h_v2(i) = generate_fad<FadType>(
938 num_rows, size_type(2), fad_size, i, size_type(1));
940 Kokkos::deep_copy(v1, h_v1);
941 Kokkos::deep_copy(v2, h_v2);
943 ConstViewType cv1 = v1;
947 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
948 v3 = ViewType (
"view3", num_rows);
950 v3 = ViewType (
"view3", num_rows, fad_size+1);
955 host_view_type h_v3 = Kokkos::create_mirror_view(v3);
956 Kokkos::deep_copy(h_v3, v3);
960 for (size_type i=0; i<num_rows; ++i) {
962 generate_fad<FadType>(num_rows, size_type(2), fad_size, i, size_type(0));
964 generate_fad<FadType>(num_rows, size_type(2), fad_size, i, size_type(1));
966 success = success &&
checkFads(f3, h_v3(i), out);
971 Kokkos_View_Fad, MultiplyMixed,
FadType, Layout, Device )
973 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
974 typedef typename ViewType::size_type size_type;
975 typedef typename ViewType::HostMirror host_view_type;
977 const size_type num_rows = 2;
981 FadType f0 = generate_fad<FadType>(
982 num_rows, size_type(2), fad_size, size_type(0), size_type(0));
983 FadType f1 = generate_fad<FadType>(
984 num_rows, size_type(2), fad_size, size_type(1), size_type(0));
986 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
987 h_v = host_view_type (
"view1", num_rows);
989 h_v = host_view_type (
"view1", num_rows, fad_size+1);
1002 Kokkos_View_Fad, AtomicAdd,
FadType, Layout, Device )
1004 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
1005 typedef Kokkos::View<FadType,Layout,Device> ScalarViewType;
1006 typedef typename ViewType::size_type size_type;
1007 typedef typename ScalarViewType::HostMirror host_scalar_view_type;
1014 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1015 v = ViewType (
"view", num_rows);
1017 v = ViewType (
"view", num_rows, fad_size+1);
1020 for (size_type i=0; i<fad_size; ++i)
1021 a.fastAccessDx(i) = 7.89+i;
1022 Kokkos::deep_copy( v, a );
1026 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1027 s = ScalarViewType (
"scalar view");
1029 s = ScalarViewType (
"scalar view", fad_size+1);
1031 Kokkos::deep_copy( s,
FadType(fad_size,0.0) );
1037 host_scalar_view_type hs = Kokkos::create_mirror_view(s);
1038 Kokkos::deep_copy(hs, s);
1046 Kokkos_View_Fad, Rank8,
FadType, Layout, Device )
1048 typedef Kokkos::View<FadType*******,Layout,Device> ViewType;
1049 typedef typename ViewType::size_type size_type;
1050 typedef typename ViewType::HostMirror host_view_type;
1056 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1057 v = ViewType (
"view", 100, 1, 2, 3, 4, 5, 6);
1059 v = ViewType (
"view", 100, 1, 2, 3, 4, 5, 6, fad_size+1);
1061 host_view_type h_v = Kokkos::create_mirror_view(v);
1062 typename host_view_type::array_type h_a = h_v;
1063 Kokkos::deep_copy(h_a, 1.0);
1066 h_v(99,0,1,2,3,4,5) = f1;
1067 FadType f2 = h_v(99,0,1,2,3,4,5);
1074 Kokkos_View_Fad, Roger,
FadType, Layout, Device )
1076 Kokkos::View<FadType*,Layout,Device>
a;
1077 Kokkos::View<FadType**,Layout,Device> b;
1078 Kokkos::View<FadType***,Layout,Device>
c;
1079 Kokkos::View<FadType****,Layout,Device> d;
1080 Kokkos::View<FadType*****,Layout,Device> e;
1081 Kokkos::View<FadType******,Layout,Device>
f;
1082 Kokkos::View<FadType*******,Layout,Device>
g;
1084 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1085 a = Kokkos::View<FadType*,Layout,Device>(
"a",4);
1086 b = Kokkos::View<FadType**,Layout,Device> (
"b",4,4);
1087 c = Kokkos::View<FadType***,Layout,Device> (
"c",4,4,4);
1088 d = Kokkos::View<FadType****,Layout,Device> (
"d",4,4,4,4);
1089 e = Kokkos::View<FadType*****,Layout,Device> (
"e",4,4,4,4,4);
1090 f = Kokkos::View<FadType******,Layout,Device> (
"f",4,4,4,4,4,4);
1091 g = Kokkos::View<FadType*******,Layout,Device> (
"g",4,4,4,4,4,4,4);
1094 a = Kokkos::View<FadType*,Layout,Device>(
"a",4,fad_size+1);
1095 b = Kokkos::View<FadType**,Layout,Device> (
"b",4,4,fad_size+1);
1096 c = Kokkos::View<FadType***,Layout,Device> (
"c",4,4,4,fad_size+1);
1097 d = Kokkos::View<FadType****,Layout,Device> (
"d",4,4,4,4,fad_size+1);
1098 e = Kokkos::View<FadType*****,Layout,Device> (
"e",4,4,4,4,4,fad_size+1);
1099 f = Kokkos::View<FadType******,Layout,Device> (
"f",4,4,4,4,4,4,fad_size+1);
1100 g = Kokkos::View<FadType*******,Layout,Device> (
"g",4,4,4,4,4,4,4,fad_size+1);
1103 typedef typename Device::memory_space memory_space;
1104 const bool is_accessible =
1105 Kokkos::Impl::MemorySpaceAccess<Kokkos::HostSpace,
1106 memory_space>::accessible;
1107 if (is_accessible) {
1109 f(0,0,0,0,0,0) =
FadType(1.0);
1110 g(0,0,0,0,0,0,0) =
FadType(1.0);
1118 Kokkos_View_Fad, AssignDifferentStrides,
FadType, Layout, Device )
1120 typedef Kokkos::View<FadType**,Layout,Device> ViewType1;
1121 typedef Kokkos::View<FadType*,Layout,Device> ViewType2;
1122 typedef typename ViewType1::size_type size_type;
1123 typedef typename ViewType1::HostMirror host_view_type1;
1124 typedef typename ViewType2::HostMirror host_view_type2;
1132 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1133 v1 = ViewType1 (
"view1", num_rows, num_cols);
1135 v1 = ViewType1 (
"view1", num_rows, num_cols, fad_size+1);
1137 host_view_type1 h_v1 = Kokkos::create_mirror_view(v1);
1138 for (size_type i=0; i<num_rows; ++i) {
1139 for (size_type j=0; j<num_cols; ++j) {
1140 h_v1(i,j) = generate_fad<FadType>(
1141 num_rows, num_cols, fad_size, i, j);
1144 Kokkos::deep_copy(v1, h_v1);
1148 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1149 v2 = ViewType2 (
"view2", num_rows);
1151 v2 = ViewType2 (
"view2", num_rows, fad_size+1);
1156 host_view_type2 h_v2 = Kokkos::create_mirror_view(v2);
1157 Kokkos::deep_copy(h_v2, v2);
1161 for (size_type i=0; i<num_rows; ++i) {
1163 generate_fad<FadType>(num_rows, num_cols, fad_size, i, size_type(1));
1164 success = success &&
checkFads(f, h_v2(i), out);
1168 #if defined(HAVE_SACADO_KOKKOSCONTAINERS) && defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
1171 Kokkos_View_Fad, DynRankDimensionScalar,
FadType, Layout, Device )
1173 typedef Kokkos::DynRankView<double,Layout,Device> DoubleViewType;
1174 typedef Kokkos::DynRankView<FadType,Layout,Device> FadViewType;
1175 typedef typename FadViewType::size_type size_type;
1181 DoubleViewType v1(
"view1", num_rows);
1182 FadViewType v2 (
"view2", num_rows, fad_size+1);
1190 Kokkos_View_Fad, DynRankAssignStatic0,
FadType, Layout, Device )
1192 typedef Kokkos::View<FadType,Layout,Device> StaticViewType;
1193 typedef Kokkos::DynRankView<FadType,Layout,Device> DynamicViewType;
1194 typedef typename StaticViewType::size_type size_type;
1201 StaticViewType v1(
"view", fad_size+1);
1202 auto h_v1 = Kokkos::create_mirror_view(v1);
1203 h_v1() = generate_fad<FadType>(num_rows, num_cols, fad_size, size_type(0), size_type(0));
1204 Kokkos::deep_copy(v1, h_v1);
1207 DynamicViewType v2 = v1;
1210 auto h_v2 = Kokkos::create_mirror_view(v2);
1211 Kokkos::deep_copy(h_v2, v2);
1219 generate_fad<FadType>(num_rows, num_cols, fad_size, size_type(0), size_type(0));
1220 success = success &&
checkFads(f, h_v2(), out);
1224 Kokkos_View_Fad, DynRankAssignStatic1,
FadType, Layout, Device )
1226 typedef Kokkos::View<FadType*,Layout,Device> StaticViewType;
1227 typedef Kokkos::DynRankView<FadType,Layout,Device> DynamicViewType;
1228 typedef typename StaticViewType::size_type size_type;
1235 StaticViewType v1(
"view", num_rows, fad_size+1);
1236 auto h_v1 = Kokkos::create_mirror_view(v1);
1237 for (size_type i=0; i<num_rows; ++i)
1239 generate_fad<FadType>(num_rows, num_cols, fad_size, i, size_type(0));
1240 Kokkos::deep_copy(v1, h_v1);
1243 DynamicViewType v2 = v1;
1246 auto h_v2 = Kokkos::create_mirror_view(v2);
1247 Kokkos::deep_copy(h_v2, v2);
1256 for (size_type i=0; i<num_rows; ++i) {
1258 generate_fad<FadType>(num_rows, num_cols, fad_size, i, size_type(0));
1259 success = success &&
checkFads(f, h_v2(i), out);
1264 Kokkos_View_Fad, DynRankAssignStatic2,
FadType, Layout, Device )
1266 typedef Kokkos::View<FadType**,Layout,Device> StaticViewType;
1267 typedef Kokkos::DynRankView<FadType,Layout,Device> DynamicViewType;
1268 typedef typename StaticViewType::size_type size_type;
1275 StaticViewType v1(
"view", num_rows, num_cols, fad_size+1);
1276 auto h_v1 = Kokkos::create_mirror_view(v1);
1277 for (size_type i=0; i<num_rows; ++i)
1278 for (size_type j=0; j<num_cols; ++j)
1279 h_v1(i,j) = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
1280 Kokkos::deep_copy(v1, h_v1);
1283 DynamicViewType v2 = v1;
1286 auto h_v2 = Kokkos::create_mirror_view(v2);
1287 Kokkos::deep_copy(h_v2, v2);
1298 for (size_type i=0; i<num_rows; ++i) {
1299 for (size_type j=0; j<num_cols; ++j) {
1300 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
1301 success = success &&
checkFads(f, h_v2(i,j), out);
1307 Kokkos_View_Fad, DynRankMultiply,
FadType, Layout, Device )
1309 typedef Kokkos::DynRankView<FadType,Layout,Device> ViewType;
1310 typedef typename ViewType::size_type size_type;
1311 typedef typename ViewType::HostMirror host_view_type;
1317 ViewType v1(
"view1", num_rows, fad_size+1);
1318 ViewType v2(
"view2", num_rows, fad_size+1);
1319 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
1320 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
1321 for (size_type i=0; i<num_rows; ++i) {
1322 h_v1(i) = generate_fad<FadType>(
1323 num_rows, size_type(2), fad_size, i, size_type(0));
1324 h_v2(i) = generate_fad<FadType>(
1325 num_rows, size_type(2), fad_size, i, size_type(1));
1327 Kokkos::deep_copy(v1, h_v1);
1328 Kokkos::deep_copy(v2, h_v2);
1331 ViewType v3(
"view3", num_rows, fad_size+1);
1335 host_view_type h_v3 = Kokkos::create_mirror_view(v3);
1336 Kokkos::deep_copy(h_v3, v3);
1341 for (size_type i=0; i<num_rows; ++i) {
1343 generate_fad<FadType>(num_rows, size_type(2), fad_size, i, size_type(0));
1345 generate_fad<FadType>(num_rows, size_type(2), fad_size, i, size_type(1));
1347 success = success &&
checkFads(f3, h_v3(i), out);
1352 Kokkos_View_Fad, SubdynrankviewCol,
FadType, Layout, Device )
1354 typedef Kokkos::DynRankView<FadType,Layout,Device> ViewType;
1355 typedef typename ViewType::size_type size_type;
1356 typedef typename ViewType::HostMirror host_view_type;
1363 ViewType v(
"view", num_rows, num_cols, fad_size+1);
1364 host_view_type h_v = Kokkos::create_mirror_view(v);
1365 for (size_type i=0; i<num_rows; ++i) {
1366 for (size_type j=0; j<num_cols; ++j) {
1367 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
1371 Kokkos::deep_copy(v, h_v);
1375 auto s = Kokkos::subdynrankview(v, Kokkos::ALL(), col);
1378 typedef decltype(s) SubviewType;
1379 typedef typename SubviewType::HostMirror HostSubviewType;
1385 HostSubviewType h_s = Kokkos::subdynrankview(h_v, Kokkos::ALL(), col);
1389 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(s), fad_size+1, out, success);
1390 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(h_s), fad_size+1, out, success);
1391 TEUCHOS_TEST_EQUALITY(h_s.extent(0), num_rows, out, success);
1392 TEUCHOS_TEST_EQUALITY(h_s.extent(1), 1, out, success);
1393 TEUCHOS_TEST_EQUALITY(h_s.extent(7), 1, out, success);
1395 for (size_type i=0; i<num_rows; ++i) {
1396 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, col);
1397 success = success &&
checkFads(f, h_s(i), out);
1402 Kokkos_View_Fad, SubdynrankviewRow,
FadType, Layout, Device )
1404 typedef Kokkos::DynRankView<FadType,Layout,Device> ViewType;
1405 typedef typename ViewType::size_type size_type;
1406 typedef typename ViewType::HostMirror host_view_type;
1410 const size_type num_planes = 9;
1414 ViewType v(
"view", num_rows, num_cols, num_planes, fad_size+1);
1415 host_view_type h_v = Kokkos::create_mirror_view(v);
1416 for (size_type i=0; i<num_rows; ++i) {
1417 for (size_type j=0; j<num_cols; ++j) {
1418 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
1419 for (size_type k=0; k<num_planes; ++k) {
1420 h_v(i,j,k) = (k+1)*f;
1424 Kokkos::deep_copy(v, h_v);
1428 auto s = Kokkos::subdynrankview(v, row, Kokkos::ALL(), Kokkos::ALL());
1431 typedef decltype(s) SubviewType;
1432 typedef typename SubviewType::HostMirror HostSubviewType;
1438 HostSubviewType h_s =
1439 Kokkos::subdynrankview(h_v, row, Kokkos::ALL(), Kokkos::ALL());
1443 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(s), fad_size+1, out, success);
1444 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(h_s), fad_size+1, out, success);
1445 TEUCHOS_TEST_EQUALITY(h_s.extent(0), num_cols, out, success);
1446 TEUCHOS_TEST_EQUALITY(h_s.extent(1), num_planes, out, success);
1447 TEUCHOS_TEST_EQUALITY(h_s.extent(2), 1, out, success);
1448 TEUCHOS_TEST_EQUALITY(h_s.extent(7), 1, out, success);
1450 for (size_type j=0; j<num_cols; ++j) {
1451 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, row, j);
1452 for (size_type k=0; k<num_planes; ++k) {
1454 success = success &&
checkFads(g, h_s(j,k), out);
1460 Kokkos_View_Fad, SubdynrankviewScalar,
FadType, Layout, Device )
1462 typedef Kokkos::DynRankView<FadType,Layout,Device> ViewType;
1463 typedef typename ViewType::size_type size_type;
1464 typedef typename ViewType::HostMirror host_view_type;
1471 ViewType v(
"view", num_rows, num_cols, fad_size+1);
1472 host_view_type h_v = Kokkos::create_mirror_view(v);
1473 for (size_type i=0; i<num_rows; ++i) {
1474 for (size_type j=0; j<num_cols; ++j) {
1475 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
1479 Kokkos::deep_copy(v, h_v);
1484 auto s = Kokkos::subdynrankview(v, row, col);
1487 typedef decltype(s) SubviewType;
1488 typedef typename SubviewType::HostMirror HostSubviewType;
1494 HostSubviewType h_s = Kokkos::subdynrankview(h_v, row, col);
1498 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(s), fad_size+1, out, success);
1499 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(h_s), fad_size+1, out, success);
1501 success = success &&
checkFads(f, h_s(), out);
1507 Kokkos_View_Fad, DynRankDimensionScalar,
FadType, Layout, Device ) {}
1509 Kokkos_View_Fad, DynRankAssignStatic0,
FadType, Layout, Device ) {}
1511 Kokkos_View_Fad, DynRankAssignStatic1,
FadType, Layout, Device ) {}
1513 Kokkos_View_Fad, DynRankAssignStatic2,
FadType, Layout, Device ) {}
1515 Kokkos_View_Fad, DynRankMultiply,
FadType, Layout, Device ) {}
1517 Kokkos_View_Fad, SubdynrankviewCol,
FadType, Layout, Device ) {}
1519 Kokkos_View_Fad, SubdynrankviewRow,
FadType, Layout, Device ) {}
1521 Kokkos_View_Fad, SubdynrankviewScalar,
FadType, Layout, Device ) {}
1526 Kokkos_View_Fad, Subview,
FadType, Layout, Device )
1528 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
1529 typedef typename ViewType::size_type size_type;
1530 typedef typename ViewType::HostMirror host_view_type;
1538 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1539 v = ViewType (
"view", num_rows, num_cols);
1541 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
1543 host_view_type h_v = Kokkos::create_mirror_view(v);
1544 for (size_type i=0; i<num_rows; ++i) {
1545 for (size_type j=0; j<num_cols; ++j) {
1546 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
1550 Kokkos::deep_copy(v, h_v);
1554 auto s = Kokkos::subview(v, Kokkos::ALL(), col);
1557 typedef decltype(s) SubviewType;
1558 typedef typename SubviewType::HostMirror HostSubviewType;
1564 HostSubviewType h_s = Kokkos::subview(h_v, Kokkos::ALL(), col);
1568 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
1572 for (size_type i=0; i<num_rows; ++i) {
1573 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, col);
1574 success = success &&
checkFads(f, h_s(i), out);
1580 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
1582 Kokkos_View_Fad, ShmemSize,
FadType, Layout, Device )
1584 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
1585 typedef typename FadType::value_type value_type;
1586 typedef typename ViewType::size_type size_type;
1593 const size_type shmem_size =
1594 ViewType::shmem_size(num_rows, num_cols, fad_size+1);
1597 const size_type align = 8;
1598 const size_type mask = align - 1;
1600 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1601 v = ViewType (
"view", num_rows, num_cols);
1603 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
1605 const size_type shmem_size_expected =
1611 Kokkos_View_Fad, Unmanaged,
FadType, Layout, Device )
1616 typedef typename FadType::value_type scalar_type;
1617 typedef Kokkos::View<scalar_type***,TestLayout,Device> ViewType;
1618 typedef Kokkos::View<FadType**,TestLayout,Device,Kokkos::MemoryUnmanaged> FadViewType;
1619 typedef typename ViewType::size_type size_type;
1620 typedef typename ViewType::HostMirror host_view_type;
1621 typedef typename FadViewType::HostMirror fad_host_view_type;
1630 if (Kokkos::is_view_fad_contiguous<FadViewType>::value &&
1631 std::is_same<TestLayout, Kokkos::LayoutLeft >::value) {
1632 v = ViewType (
"view", fad_size+1, num_rows, num_cols);
1633 h_v = Kokkos::create_mirror_view(v);
1634 for (size_type i=0; i<num_rows; ++i) {
1635 for (size_type j=0; j<num_cols; ++j) {
1636 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
1637 for (size_type k=0; k<fad_size; k++)
1638 h_v(k,i,j) = f.dx(k);
1639 h_v(fad_size,i,j) = f.val();
1644 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
1645 h_v = Kokkos::create_mirror_view(v);
1646 for (size_type i=0; i<num_rows; ++i) {
1647 for (size_type j=0; j<num_cols; ++j) {
1648 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
1649 for (size_type k=0; k<fad_size; k++)
1650 h_v(i,j,k) = f.dx(k);
1651 h_v(i,j,fad_size) = f.val();
1655 Kokkos::deep_copy(v, h_v);
1659 fad_host_view_type h_v_fad;
1660 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1661 v_fad = FadViewType ( v.data(), num_rows, num_cols);
1662 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols);
1664 v_fad = FadViewType ( v.data(), num_rows, num_cols, fad_size+1);
1665 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols, fad_size+1);
1669 Kokkos::deep_copy(h_v_fad, v_fad);
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 success = success &&
checkFads(f, h_v_fad(i,j), out);
1682 Kokkos_View_Fad, Unmanaged2,
FadType, Layout, Device )
1687 typedef typename FadType::value_type scalar_type;
1688 typedef Kokkos::View<scalar_type***,TestLayout,Device> ViewType;
1689 typedef Kokkos::View<FadType**,TestLayout,Device> FadViewType;
1690 typedef typename ViewType::size_type size_type;
1691 typedef typename ViewType::HostMirror host_view_type;
1692 typedef typename FadViewType::HostMirror fad_host_view_type;
1701 if (Kokkos::is_view_fad_contiguous<FadViewType>::value &&
1702 std::is_same<TestLayout, Kokkos::LayoutLeft >::value) {
1703 v = ViewType (
"view", fad_size+1, num_rows, num_cols);
1704 h_v = Kokkos::create_mirror_view(v);
1705 for (size_type i=0; i<num_rows; ++i) {
1706 for (size_type j=0; j<num_cols; ++j) {
1707 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
1708 for (size_type k=0; k<fad_size; k++)
1709 h_v(k,i,j) = f.dx(k);
1710 h_v(fad_size,i,j) = f.val();
1715 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
1716 h_v = Kokkos::create_mirror_view(v);
1717 for (size_type i=0; i<num_rows; ++i) {
1718 for (size_type j=0; j<num_cols; ++j) {
1719 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
1720 for (size_type k=0; k<fad_size; k++)
1721 h_v(i,j,k) = f.dx(k);
1722 h_v(i,j,fad_size) = f.val();
1726 Kokkos::deep_copy(v, h_v);
1730 fad_host_view_type h_v_fad;
1731 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1732 v_fad = FadViewType ( v.data(), num_rows, num_cols);
1733 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols);
1735 v_fad = FadViewType ( v.data(), num_rows, num_cols, fad_size+1);
1736 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols, fad_size+1);
1740 Kokkos::deep_copy(h_v_fad, v_fad);
1744 for (size_type i=0; i<num_rows; ++i) {
1745 for (size_type j=0; j<num_cols; ++j) {
1746 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
1747 success = success &&
checkFads(f, h_v_fad(i,j), out);
1753 Kokkos_View_Fad, UnmanagedConst,
FadType, Layout, Device )
1758 typedef typename FadType::value_type scalar_type;
1759 typedef Kokkos::View<scalar_type***,TestLayout,Device> ViewType;
1760 typedef Kokkos::View<const scalar_type***,TestLayout,Device> ConstViewType;
1761 typedef Kokkos::View<FadType**,TestLayout,Device,Kokkos::MemoryUnmanaged> FadViewType;
1762 typedef Kokkos::View<const FadType**,TestLayout,Device,Kokkos::MemoryUnmanaged> ConstFadViewType;
1763 typedef typename ViewType::size_type size_type;
1764 typedef typename ViewType::HostMirror host_view_type;
1765 typedef typename FadViewType::HostMirror fad_host_view_type;
1774 if (Kokkos::is_view_fad_contiguous<FadViewType>::value &&
1775 std::is_same<TestLayout, Kokkos::LayoutLeft >::value) {
1776 v = ViewType (
"view", fad_size+1, num_rows, num_cols);
1777 h_v = Kokkos::create_mirror_view(v);
1778 for (size_type i=0; i<num_rows; ++i) {
1779 for (size_type j=0; j<num_cols; ++j) {
1780 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
1781 for (size_type k=0; k<fad_size; k++)
1782 h_v(k,i,j) = f.dx(k);
1783 h_v(fad_size,i,j) = f.val();
1788 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
1789 h_v = Kokkos::create_mirror_view(v);
1790 for (size_type i=0; i<num_rows; ++i) {
1791 for (size_type j=0; j<num_cols; ++j) {
1792 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
1793 for (size_type k=0; k<fad_size; k++)
1794 h_v(i,j,k) = f.dx(k);
1795 h_v(i,j,fad_size) = f.val();
1799 Kokkos::deep_copy(v, h_v);
1800 ConstViewType v_const = v;
1804 ConstFadViewType v_fad;
1805 fad_host_view_type h_v_fad;
1806 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1807 v_fad = ConstFadViewType ( v_const.data(), num_rows, num_cols);
1808 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols);
1810 v_fad = ConstFadViewType ( v_const.data(), num_rows, num_cols, fad_size+1);
1811 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols, fad_size+1);
1815 Kokkos::deep_copy(h_v_fad, v_fad);
1819 for (size_type i=0; i<num_rows; ++i) {
1820 for (size_type j=0; j<num_cols; ++j) {
1821 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
1822 success = success &&
checkFads(f, h_v_fad(i,j), out);
1828 Kokkos_View_Fad, UnmanagedConst2,
FadType, Layout, Device )
1832 typedef typename FadType::value_type scalar_type;
1833 typedef Kokkos::View<scalar_type***,TestLayout,Device> ViewType;
1834 typedef Kokkos::View<const scalar_type***,TestLayout,Device> ConstViewType;
1835 typedef Kokkos::View<FadType**,TestLayout,Device> FadViewType;
1836 typedef Kokkos::View<const FadType**,TestLayout,Device> ConstFadViewType;
1837 typedef typename ViewType::size_type size_type;
1838 typedef typename ViewType::HostMirror host_view_type;
1839 typedef typename FadViewType::HostMirror fad_host_view_type;
1848 if (Kokkos::is_view_fad_contiguous<FadViewType>::value &&
1849 std::is_same<TestLayout, Kokkos::LayoutLeft >::value) {
1850 v = ViewType (
"view", fad_size+1, num_rows, num_cols);
1851 h_v = Kokkos::create_mirror_view(v);
1852 for (size_type i=0; i<num_rows; ++i) {
1853 for (size_type j=0; j<num_cols; ++j) {
1854 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
1855 for (size_type k=0; k<fad_size; k++)
1856 h_v(k,i,j) = f.dx(k);
1857 h_v(fad_size,i,j) = f.val();
1862 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
1863 h_v = Kokkos::create_mirror_view(v);
1864 for (size_type i=0; i<num_rows; ++i) {
1865 for (size_type j=0; j<num_cols; ++j) {
1866 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
1867 for (size_type k=0; k<fad_size; k++)
1868 h_v(i,j,k) = f.dx(k);
1869 h_v(i,j,fad_size) = f.val();
1873 Kokkos::deep_copy(v, h_v);
1874 ConstViewType v_const = v;
1877 ConstFadViewType v_fad;
1878 fad_host_view_type h_v_fad;
1879 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1880 v_fad = ConstFadViewType (v_const.data(), num_rows, num_cols);
1881 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols);
1883 v_fad = ConstFadViewType (v_const.data(), num_rows, num_cols, fad_size+1);
1884 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols, fad_size+1);
1888 Kokkos::deep_copy(h_v_fad, v_fad);
1892 for (size_type i=0; i<num_rows; ++i) {
1893 for (size_type j=0; j<num_cols; ++j) {
1894 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
1895 success = success &&
checkFads(f, h_v_fad(i,j), out);
1903 Kokkos_View_Fad, SFadNoSizeArg,
FadType, Layout, Device )
1905 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
1906 typedef typename ViewType::size_type size_type;
1907 typedef typename ViewType::HostMirror host_view_type;
1914 ViewType v(
"view", num_rows, num_cols);
1915 host_view_type h_v = Kokkos::create_mirror_view(v);
1916 for (size_type i=0; i<num_rows; ++i) {
1917 for (size_type j=0; j<num_cols; ++j) {
1918 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
1922 Kokkos::deep_copy(v, h_v);
1925 Kokkos::deep_copy(h_v, v);
1931 for (size_type i=0; i<num_rows; ++i) {
1932 for (size_type j=0; j<num_cols; ++j) {
1933 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
1934 success = success &&
checkFads(f, h_v(i,j), out);
1940 Kokkos_View_Fad, Partition,
FadType, Layout, Device )
1942 #if !defined(SACADO_VIEW_CUDA_HIERARCHICAL) && !defined(SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
1943 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
1944 typedef typename ViewType::size_type size_type;
1945 typedef typename ViewType::HostMirror host_view_type;
1953 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1954 v = ViewType (
"view", num_rows, num_cols);
1956 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
1958 host_view_type h_v = Kokkos::create_mirror_view(v);
1960 for (size_type i=0; i<num_rows; ++i) {
1961 for (size_type j=0; j<num_cols; ++j) {
1962 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
1966 Kokkos::deep_copy(v, h_v);
1969 Kokkos::deep_copy(h_v, v);
1973 const size_type stride = 2;
1974 auto h_v1 = Kokkos::partition<2>(h_v, 0, stride);
1975 auto h_v2 = Kokkos::partition<2>(h_v, 1, stride);
1978 const size_type fad_size_1 = (fad_size + stride - 0 - 1) / stride;
1979 const size_type fad_size_2 = (fad_size + stride - 1 - 1) / stride;
1983 for (size_type i=0; i<num_rows; ++i) {
1984 for (size_type j=0; j<num_cols; ++j) {
1985 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
1988 for (
unsigned int k=0; k<fad_size_1; ++k)
1989 if (2*k < fad_size) f1.fastAccessDx(k) = f.dx(2*k);
1990 for (
unsigned int k=0; k<fad_size_2; ++k)
1991 if (2*k+1 < fad_size) f2.fastAccessDx(k) = f.dx(2*k+1);
1992 success = success &&
checkFads(f1, h_v1(i,j), out);
1993 success = success &&
checkFads(f2, h_v2(i,j), out);
2000 Kokkos_View_Fad, AssignLayoutContiguousToLayoutStride,
FadType, Layout, Device )
2002 typedef Kokkos::View<FadType**,Kokkos::LayoutContiguous<Layout>,Device> ContViewType;
2003 typedef Kokkos::View<FadType**,Kokkos::LayoutStride,Device> StrideViewType;
2004 typedef typename ContViewType::size_type size_type;
2005 typedef typename ContViewType::HostMirror cont_host_view_type;
2006 typedef typename StrideViewType::HostMirror stride_host_view_type;
2014 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2015 v = ContViewType (
"view", num_rows, num_cols);
2017 v = ContViewType (
"view", num_rows, num_cols, fad_size+1);
2019 cont_host_view_type h_v = Kokkos::create_mirror_view(v);
2021 for (size_type i=0; i<num_rows; ++i) {
2022 for (size_type j=0; j<num_cols; ++j) {
2023 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
2027 Kokkos::deep_copy(v, h_v);
2030 StrideViewType vs = v;
2037 stride_host_view_type h_vs = h_v;
2044 for (size_type i=0; i<num_rows; ++i) {
2045 for (size_type j=0; j<num_cols; ++j) {
2046 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, i, j);
2047 success = success &&
checkFads(f, h_vs(i,j), out);
2053 Kokkos_View_Fad, CommonViewAllocMixedSpec,
FadType, Layout, Device )
2055 typedef Kokkos::View<FadType**,Kokkos::LayoutContiguous<Layout>,Device> ContViewType;
2056 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
2057 typedef typename ContViewType::size_type size_type;
2065 #if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2066 v1 = ContViewType (
"view", num_rows, num_cols);
2068 v1 = ContViewType (
"view", num_rows, num_cols, fad_size+1);
2072 auto cprop = Kokkos::common_view_alloc_prop(v1);
2073 ViewType v2(Kokkos::view_alloc(
"v2",cprop), num_rows, num_cols);
2085 Kokkos_View_Fad, ShmemSize,
FadType, Layout, Device )
2087 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
2088 typedef typename ViewType::size_type size_type;
2094 const size_type shmem_size =
2095 ViewType::shmem_size(num_rows, num_cols);
2098 static const size_type align = 8;
2099 static const size_type mask = align - 1;
2100 const size_type shmem_size_expected =
2106 Kokkos_View_Fad, Unmanaged,
FadType, Layout, Device ) {}
2109 Kokkos_View_Fad, Unmanaged2,
FadType, Layout, Device ) {}
2112 Kokkos_View_Fad, UnmanagedConst,
FadType, Layout, Device ) {}
2115 Kokkos_View_Fad, UnmanagedConst2,
FadType, Layout, Device ) {}
2118 Kokkos_View_Fad, SFadNoSizeArg,
FadType, Layout, Device ) {}
2121 Kokkos_View_Fad, Partition,
FadType, Layout, Device ) {}
2124 Kokkos_View_Fad, AssignLayoutContiguousToLayoutStride,
FadType, Layout, Device ) {}
2127 Kokkos_View_Fad, CommonViewAllocMixedSpec,
FadType, Layout, Device ) {}
2131 #define VIEW_FAD_TESTS_FLD( F, L, D ) \
2132 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Size, F, L, D ) \
2133 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy, F, L, D ) \
2134 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy_ConstantScalar, F, L, D ) \
2135 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy_ConstantZero, F, L, D ) \
2136 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy_ConstantFad, F, L, D ) \
2137 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy_ConstantFadFull, F, L, D ) \
2138 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, ScalarAssign, F, L, D ) \
2139 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, ValueAssign, F, L, D ) \
2140 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Resize, F, L, D ) \
2141 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Unmanaged, F, L, D ) \
2142 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Unmanaged2, F, L, D ) \
2143 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, UnmanagedConst, F, L, D ) \
2144 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, UnmanagedConst2, F, L, D ) \
2145 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Multiply, F, L, D ) \
2146 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, MultiplyUpdate, F, L, D ) \
2147 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, MultiplyConst, F, L, D ) \
2148 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, MultiplyMixed, F, L, D ) \
2149 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, AtomicAdd, F, L, D ) \
2150 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Rank8, F, L, D ) \
2151 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Roger, F, L, D ) \
2152 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, AssignDifferentStrides, F, L, D ) \
2153 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankDimensionScalar, F, L, D ) \
2154 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankAssignStatic0, F, L, D ) \
2155 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankAssignStatic1, F, L, D ) \
2156 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankAssignStatic2, F, L, D ) \
2157 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankMultiply, F, L, D ) \
2158 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, SubdynrankviewCol, F, L, D ) \
2159 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, SubdynrankviewRow, F, L, D ) \
2160 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, SubdynrankviewScalar, F, L, D ) \
2161 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Subview, F, L, D ) \
2162 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, ShmemSize, F, L, D )
2164 #define VIEW_FAD_TESTS_SFLD( F, L, D ) \
2165 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, SFadNoSizeArg, F, L, D )
2167 #define VIEW_FAD_TESTS_FDI( F, D ) \
2168 using Kokkos::LayoutLeft; \
2169 using Kokkos::LayoutRight; \
2170 VIEW_FAD_TESTS_FLD( F, LayoutLeft, D ) \
2171 VIEW_FAD_TESTS_FLD( F, LayoutRight, D ) \
2172 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, AssignLayoutContiguousToLayoutStride, F, LayoutLeft, D ) \
2173 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, AssignLayoutContiguousToLayoutStride, F, LayoutRight, D ) \
2174 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, CommonViewAllocMixedSpec, F, LayoutLeft, D ) \
2175 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, CommonViewAllocMixedSpec, F, LayoutRight, D )
2177 #define VIEW_FAD_TESTS_SFDI( F, D ) \
2178 using Kokkos::LayoutLeft; \
2179 using Kokkos::LayoutRight; \
2180 VIEW_FAD_TESTS_SFLD( F, LayoutLeft, D ) \
2181 VIEW_FAD_TESTS_SFLD( F, LayoutRight, D )
2183 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
2186 #define VIEW_FAD_TESTS_FDC( F, D ) \
2187 VIEW_FAD_TESTS_FLD( F, LeftContiguous, D ) \
2188 VIEW_FAD_TESTS_FLD( F, RightContiguous, D ) \
2189 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Partition, F, LeftContiguous, D ) \
2190 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Partition, F, RightContiguous, D )
2192 #define VIEW_FAD_TESTS_SFDC( F, D ) \
2193 VIEW_FAD_TESTS_SFLD( F, LeftContiguous, D ) \
2194 VIEW_FAD_TESTS_SFLD( F, RightContiguous, D )
2196 #define VIEW_FAD_TESTS_FDC( F, D )
2197 #define VIEW_FAD_TESTS_SFDC( F, D )
2200 #define VIEW_FAD_TESTS_FD( F, D ) \
2201 VIEW_FAD_TESTS_FDI( F, D ) \
2202 VIEW_FAD_TESTS_FDC( F, D )
2204 #define VIEW_FAD_TESTS_SFD( F, D ) \
2205 VIEW_FAD_TESTS_SFDI( F, D ) \
2206 VIEW_FAD_TESTS_SFDC( F, D )
2229 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC) && SACADO_TEST_DFAD
2230 #define VIEW_FAD_TESTS_D( D ) \
2231 VIEW_FAD_TESTS_FD( SFadType, D ) \
2232 VIEW_FAD_TESTS_FD( SLFadType, D ) \
2233 VIEW_FAD_TESTS_FD( DFadType, D ) \
2234 VIEW_FAD_TESTS_SFD( SFadType, D )
2254 #define VIEW_FAD_TESTS_D( D ) \
2255 VIEW_FAD_TESTS_FD( SFadType, D ) \
2256 VIEW_FAD_TESTS_FD( SLFadType, D ) \
2257 VIEW_FAD_TESTS_SFD( SFadType, D )
InputViewType::size_type size_type
team_policy_type::member_type team_handle
static const size_type stride
ViewType::value_type::value_type ScalarType
ViewType::execution_space execution_space
Kokkos::TeamPolicy< execution_space > team_policy_type
Kokkos::TeamPolicy< execution_space > team_policy_type
static const size_type stride
KOKKOS_INLINE_FUNCTION void operator()(const team_handle &team) const
ViewType::size_type size_type
static const size_type stride
ViewType::size_type size_type
#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
static void apply(const ViewType &v, const ValueType &s)
#define VIEW_FAD_TESTS_SFD(F, D)
KOKKOS_INLINE_FUNCTION void operator()(const size_type i) const
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)
Kokkos::ThreadLocalScalarType< ViewType >::type local_scalar_type
Kokkos::RangePolicy< execution_space > range_policy_type
const InputViewType1 m_v1
static const size_type stride
InputViewType::execution_space execution_space
static void apply(const InputViewType v1, const OutputViewType v2, const size_type col)
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
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
#define KOKKOS_INLINE_FUNCTION
Sacado::Fad::DFad< double > DFadType
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
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
Sacado::Fad::SLFad< double, fad_dim > SLFadType
static void apply(const ViewType &v, const ScalarViewType &s)
KOKKOS_INLINE_FUNCTION void operator()(const team_handle &team) const
ViewType::value_type ValueType
Kokkos::TeamPolicy< execution_space > team_policy_type
ScalarAssignKernel(const ViewType &v, const ScalarType &s)
ValueAssignKernel(const ViewType &v, const ValueType &s)
AtomicAddKernel(const ViewType &v, const ScalarViewType &s)
#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
ViewType::execution_space execution_space
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)
team_policy_type::member_type team_handle
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