29#include "Teuchos_TestingHelpers.hpp"
36 static const bool value =
false;
39template <
typename T,
int N>
46 static const bool value =
false;
54template <
typename FadType1,
typename FadType2>
56 Teuchos::FancyOStream& out,
double tol = 1.0e-15)
61 TEUCHOS_TEST_EQUALITY(
x.size(), x2.size(), out, success);
64 TEUCHOS_TEST_FLOATING_EQUALITY(
x.val(), x2.val(),
tol, out, success);
67 for (
int i=0;
i<
x.size(); ++
i)
68 TEUCHOS_TEST_FLOATING_EQUALITY(
x.dx(
i), x2.dx(
i),
tol, out, success);
73template <
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
102template <
typename InputViewType1,
103 typename InputViewType2 = InputViewType1,
104 typename OutputViewType = InputViewType1>
118 const InputViewType2 v2,
119 const OutputViewType v3,
124 KOKKOS_INLINE_FUNCTION
132 KOKKOS_INLINE_FUNCTION
135 const size_type i = team.league_rank()*team.team_size() + team.team_rank();
136 if (
i <
m_v1.extent(0))
141 static void apply(
const InputViewType1 v1,
142 const InputViewType2 v2,
143 const OutputViewType v3,
144 const bool update =
false) {
147#if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
148 const size_type stride = Kokkos::ViewScalarStride<InputViewType1>::stride;
149 const bool use_team =
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)
155 const size_type stride = team_policy_type::vector_length_max();
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 ) &&
161#elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
162 const size_type stride = Kokkos::ViewScalarStride<InputViewType1>::stride;
163 const bool use_team =
164 std::is_same<execution_space, Kokkos::Experimental::HIP>::value &&
165 ( Kokkos::is_view_fad_contiguous<InputViewType1>::value ||
166 Kokkos::is_dynrankview_fad_contiguous<InputViewType1>::value ) &&
168#elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
169 const size_type stride = team_policy_type::vector_length_max();
170 const bool use_team =
171 std::is_same<execution_space, Kokkos::Experimental::HIP>::value &&
172 ( Kokkos::is_view_fad_contiguous<InputViewType1>::value ||
173 Kokkos::is_dynrankview_fad_contiguous<InputViewType1>::value ) &&
177 const bool use_team =
false;
181 const size_type team_size = 256 / stride;
193template <
typename ViewType>
197 typedef typename ViewType::value_type::value_type
ScalarType;
210 KOKKOS_INLINE_FUNCTION
215 KOKKOS_INLINE_FUNCTION
218 const size_type i = team.league_rank()*team.team_size() + team.team_rank();
219 if (
i <
m_v.extent(0))
227#if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
228 const bool use_team =
229 std::is_same<execution_space, Kokkos::Cuda>::value &&
230 ( Kokkos::is_view_fad_contiguous<ViewType>::value ||
231 Kokkos::is_dynrankview_fad_contiguous<ViewType>::value ) &&
233#elif defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
234 const bool use_team =
235 std::is_same<execution_space, Kokkos::Cuda>::value &&
236 ( Kokkos::is_view_fad_contiguous<ViewType>::value ||
237 Kokkos::is_dynrankview_fad_contiguous<ViewType>::value ) &&
239#elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
240 const bool use_team =
241 std::is_same<execution_space, Kokkos::Experimental::HIP>::value &&
242 ( Kokkos::is_view_fad_contiguous<ViewType>::value ||
243 Kokkos::is_dynrankview_fad_contiguous<ViewType>::value ) &&
245#elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
246 const bool use_team =
247 std::is_same<execution_space, Kokkos::Experimental::HIP>::value &&
248 ( Kokkos::is_view_fad_contiguous<ViewType>::value ||
249 Kokkos::is_dynrankview_fad_contiguous<ViewType>::value ) &&
252 const bool use_team =
false;
268template <
typename ViewType,
typename ScalarViewType>
286 KOKKOS_INLINE_FUNCTION
292 KOKKOS_INLINE_FUNCTION
295 const size_type i = team.league_rank()*team.team_size() + team.team_rank();
296 if (
i <
m_v.extent(0))
301 static void apply(
const ViewType& v,
const ScalarViewType& s) {
304#if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
305 const bool use_team =
306 std::is_same<execution_space, Kokkos::Cuda>::value &&
307 ( Kokkos::is_view_fad_contiguous<ViewType>::value ||
308 Kokkos::is_dynrankview_fad_contiguous<ViewType>::value ) &&
310#elif defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
311 const bool use_team =
312 std::is_same<execution_space, Kokkos::Cuda>::value &&
313 ( Kokkos::is_view_fad_contiguous<ViewType>::value ||
314 Kokkos::is_dynrankview_fad_contiguous<ViewType>::value ) &&
316#elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
317 const bool use_team =
318 std::is_same<execution_space, Kokkos::Experimental::HIP>::value &&
319 ( Kokkos::is_view_fad_contiguous<ViewType>::value ||
320 Kokkos::is_dynrankview_fad_contiguous<ViewType>::value ) &&
322#elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
323 const bool use_team =
324 std::is_same<execution_space, Kokkos::Experimental::HIP>::value &&
325 ( Kokkos::is_view_fad_contiguous<ViewType>::value ||
326 Kokkos::is_dynrankview_fad_contiguous<ViewType>::value ) &&
329 const bool use_team =
false;
345template <
typename InputViewType,
346 typename OutputViewType,
347 typename Enabled =
void>
361 const OutputViewType v2,
364 static_assert( unsigned(InputViewType::Rank) == 2 ,
365 "Require rank-2 input view" );
366 static_assert( unsigned(OutputViewType::Rank) == 1 ,
367 "Require rank-1 output view" );
371 KOKKOS_INLINE_FUNCTION
376 KOKKOS_INLINE_FUNCTION
379 const size_type i = team.league_rank()*team.team_size() + team.team_rank();
380 if (
i <
m_v1.extent(0))
385 static void apply(
const InputViewType v1,
386 const OutputViewType v2,
390#if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
391 const bool use_team =
392 std::is_same<execution_space, Kokkos::Cuda>::value &&
393 ( Kokkos::is_view_fad_contiguous<InputViewType>::value ||
394 Kokkos::is_dynrankview_fad_contiguous<InputViewType>::value ) &&
396#elif defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
397 const bool use_team =
398 std::is_same<execution_space, Kokkos::Cuda>::value &&
399 ( Kokkos::is_view_fad_contiguous<InputViewType>::value ||
400 Kokkos::is_dynrankview_fad_contiguous<InputViewType>::value ) &&
402#elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
403 const bool use_team =
404 std::is_same<execution_space, Kokkos::Experimental::HIP>::value &&
405 ( Kokkos::is_view_fad_contiguous<InputViewType>::value ||
406 Kokkos::is_dynrankview_fad_contiguous<InputViewType>::value ) &&
408#elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
409 const bool use_team =
410 std::is_same<execution_space, Kokkos::Experimental::HIP>::value &&
411 ( Kokkos::is_view_fad_contiguous<InputViewType>::value ||
412 Kokkos::is_dynrankview_fad_contiguous<InputViewType>::value ) &&
415 const bool use_team =
false;
431template <
typename ViewType,
typename ScalarViewType>
448 KOKKOS_INLINE_FUNCTION
451 Kokkos::atomic_add(&(
m_s()),
x);
454 KOKKOS_INLINE_FUNCTION
457 const size_type i = team.league_rank()*team.team_size() + team.team_rank();
458 if (
i <
m_v.extent(0))
463 static void apply(
const ViewType& v,
const ScalarViewType& s) {
466#if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
467 const bool use_team =
468 std::is_same<execution_space, Kokkos::Cuda>::value &&
469 ( Kokkos::is_view_fad_contiguous<ViewType>::value ||
470 Kokkos::is_dynrankview_fad_contiguous<ViewType>::value ) &&
472#elif defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
473 const bool use_team =
474 std::is_same<execution_space, Kokkos::Cuda>::value &&
475 ( Kokkos::is_view_fad_contiguous<ViewType>::value ||
476 Kokkos::is_dynrankview_fad_contiguous<ViewType>::value ) &&
478#elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
479 const bool use_team =
480 std::is_same<execution_space, Kokkos::Experimental::HIP>::value &&
481 ( Kokkos::is_view_fad_contiguous<ViewType>::value ||
482 Kokkos::is_dynrankview_fad_contiguous<ViewType>::value ) &&
484#elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
485 const bool use_team =
486 std::is_same<execution_space, Kokkos::Experimental::HIP>::value &&
487 ( Kokkos::is_view_fad_contiguous<ViewType>::value ||
488 Kokkos::is_dynrankview_fad_contiguous<ViewType>::value ) &&
491 const bool use_team =
false;
507 Kokkos_View_Fad, Size,
FadType, Layout, Device )
509 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
510 typedef typename ViewType::size_type size_type;
516#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
517 v = ViewType(
"view", num_rows);
520 v = ViewType(
"view", num_rows, fad_size+1);
522 TEUCHOS_TEST_EQUALITY(v.size(), num_rows, out, success);
526 Kokkos_View_Fad, DeepCopy,
FadType, Layout, Device )
528 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
529 typedef typename ViewType::size_type size_type;
530 typedef typename ViewType::HostMirror host_view_type;
538#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
539 v = ViewType (
"view", num_rows, num_cols);
541 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
543 host_view_type h_v = Kokkos::create_mirror_view(v);
544 for (size_type
i=0;
i<num_rows; ++
i)
545 for (size_type j=0; j<num_cols; ++j)
546 h_v(
i,j) = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
547 Kokkos::deep_copy(v, h_v);
550 host_view_type h_v2 = Kokkos::create_mirror_view(v);
551 Kokkos::deep_copy(h_v2, v);
555 for (size_type
i=0;
i<num_rows; ++
i) {
556 for (size_type j=0; j<num_cols; ++j) {
557 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
558 success = success &&
checkFads(f, h_v2(
i,j), out);
564 Kokkos_View_Fad, DeepCopy_ConstantScalar,
FadType, Layout, Device )
566 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
567 typedef typename ViewType::size_type size_type;
568 typedef typename ViewType::HostMirror host_view_type;
569 typedef typename FadType::value_type value_type;
576#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
577 v = ViewType (
"view", num_rows, num_cols);
580 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
582 typename ViewType::array_type va = v;
583 Kokkos::deep_copy( va, 1.0 );
586 value_type
a = 2.3456;
587 Kokkos::deep_copy( v,
a );
590 host_view_type hv = Kokkos::create_mirror_view(v);
591 Kokkos::deep_copy(hv, v);
595 for (size_type
i=0;
i<num_rows; ++
i) {
596 for (size_type j=0; j<num_cols; ++j) {
597#if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
602 success = success &&
checkFads(f, hv(
i,j), out);
608 Kokkos_View_Fad, DeepCopy_ConstantZero,
FadType, Layout, Device )
610 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
611 typedef typename ViewType::size_type size_type;
612 typedef typename ViewType::HostMirror host_view_type;
613 typedef typename FadType::value_type value_type;
620#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
621 v = ViewType (
"view", num_rows, num_cols);
624 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
626 typename ViewType::array_type va = v;
627 Kokkos::deep_copy( va, 1.0 );
631 Kokkos::deep_copy( v,
a );
634 host_view_type hv = Kokkos::create_mirror_view(v);
635 Kokkos::deep_copy(hv, v);
639 for (size_type
i=0;
i<num_rows; ++
i) {
640 for (size_type j=0; j<num_cols; ++j) {
641#if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
646 success = success &&
checkFads(f, hv(
i,j), out);
652 Kokkos_View_Fad, DeepCopy_ConstantFad,
FadType, Layout, Device )
654 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
655 typedef typename ViewType::size_type size_type;
656 typedef typename ViewType::HostMirror host_view_type;
663#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
664 v = ViewType (
"view", num_rows, num_cols);
667 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
669 typename ViewType::array_type va = v;
670 Kokkos::deep_copy( va, 1.0 );
674 Kokkos::deep_copy( v,
a );
677 host_view_type hv = Kokkos::create_mirror_view(v);
678 Kokkos::deep_copy(hv, v);
682 for (size_type
i=0;
i<num_rows; ++
i) {
683 for (size_type j=0; j<num_cols; ++j) {
684#if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
689 success = success &&
checkFads(f, hv(
i,j), out);
695 Kokkos_View_Fad, DeepCopy_ConstantFadFull,
FadType, Layout, Device )
697 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
698 typedef typename ViewType::size_type size_type;
699 typedef typename ViewType::HostMirror host_view_type;
707#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
708 v = ViewType (
"view", num_rows, num_cols);
710 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
712 typename ViewType::array_type va = v;
713 Kokkos::deep_copy( va, 1.0 );
717 for (size_type
i=0;
i<fad_size; ++
i)
718 a.fastAccessDx(
i) = 7.89 + (
i+1);
721 host_view_type hv = Kokkos::create_mirror_view(v);
722 Kokkos::deep_copy(hv,
a);
726 for (size_type
i=0;
i<num_rows; ++
i) {
727 for (size_type j=0; j<num_cols; ++j) {
734 Kokkos_View_Fad, ScalarAssign,
FadType, Layout, Device )
736 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
737 typedef typename ViewType::size_type size_type;
738 typedef typename ViewType::HostMirror host_view_type;
739 typedef typename FadType::value_type value_type;
745#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
746 v = ViewType (
"view", num_rows);
749 v = ViewType (
"view", num_rows, fad_size+1);
751 typename ViewType::array_type va = v;
752 Kokkos::deep_copy( va, 1.0 );
755 value_type
a = 2.3456;
759 host_view_type hv = Kokkos::create_mirror_view(v);
760 Kokkos::deep_copy(hv, v);
764 for (size_type
i=0;
i<num_rows; ++
i) {
765#if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
770 success = success &&
checkFads(f, hv(
i), out);
775 Kokkos_View_Fad, ValueAssign,
FadType, Layout, Device )
777 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
778 typedef Kokkos::View<FadType,Layout,Device> ScalarViewType;
779 typedef typename ViewType::size_type size_type;
780 typedef typename ViewType::HostMirror host_view_type;
781 typedef typename ScalarViewType::HostMirror host_scalar_view_type;
789#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
790 v = ViewType (
"view", num_rows);
791 a = ScalarViewType (
"fad");
793 v = ViewType (
"view", num_rows, fad_size+1);
794 a = ScalarViewType (
"fad", fad_size+1);
796 typename ViewType::array_type va = v;
797 Kokkos::deep_copy( va, 1.0 );
800 Kokkos::deep_copy(
a, 2.3456);
802 Kokkos::parallel_for(Kokkos::RangePolicy< Device>(0, fad_size), KOKKOS_LAMBDA(
const int i) {
803 a().fastAccessDx(
i) = 7.89 +
i;
811 host_view_type hv = Kokkos::create_mirror_view(v);
812 Kokkos::deep_copy(hv, v);
814 host_scalar_view_type ha = Kokkos::create_mirror_view(
a);
815 Kokkos::deep_copy(ha,
a);
819 for (size_type
i=0;
i<num_rows; ++
i) {
820 success = success &&
checkFads(ha(), hv(
i), out);
825 Kokkos_View_Fad, Resize,
FadType, Layout, Device )
827 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
828 typedef typename ViewType::size_type size_type;
829 typedef typename ViewType::HostMirror host_view_type;
837#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
838 v = ViewType (
"view", num_rows, num_cols);
840 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
842 host_view_type h_v = Kokkos::create_mirror_view(v);
843 for (size_type
i=0;
i<num_rows; ++
i)
844 for (size_type j=0; j<num_cols; ++j)
845 h_v(
i,j) = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
846 Kokkos::deep_copy(v, h_v);
849#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
850 Kokkos::resize(v, num_rows, num_cols+1);
852 Kokkos::resize(v, num_rows, num_cols+1, fad_size+1);
856 host_view_type h_v2 = Kokkos::create_mirror_view(v);
857 Kokkos::deep_copy(h_v2, v);
861 for (size_type
i=0;
i<num_rows; ++
i) {
862 for (size_type j=0; j<num_cols; ++j) {
863 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
864 success = success &&
checkFads(f, h_v2(
i,j), out);
866#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
871 success = success &&
checkFads(f, h_v2(
i,num_cols), out);
876 Kokkos_View_Fad, Multiply,
FadType, Layout, Device )
878 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
879 typedef typename ViewType::size_type size_type;
880 typedef typename ViewType::HostMirror host_view_type;
887#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
888 v1 = ViewType (
"view1", num_rows);
889 v2 = ViewType (
"view2", num_rows);
891 v1 = ViewType (
"view1", num_rows, fad_size+1);
892 v2 = ViewType (
"view2", num_rows, fad_size+1);
894 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
895 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
896 for (size_type
i=0;
i<num_rows; ++
i) {
897 h_v1(
i) = generate_fad<FadType>(
898 num_rows, size_type(2), fad_size,
i, size_type(0));
899 h_v2(
i) = generate_fad<FadType>(
900 num_rows, size_type(2), fad_size,
i, size_type(1));
902 Kokkos::deep_copy(v1, h_v1);
903 Kokkos::deep_copy(v2, h_v2);
907#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
908 v3 = ViewType (
"view3", num_rows);
910 v3 = ViewType (
"view3", num_rows, fad_size+1);
915 host_view_type h_v3 = Kokkos::create_mirror_view(v3);
916 Kokkos::deep_copy(h_v3, v3);
920 for (size_type
i=0;
i<num_rows; ++
i) {
922 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(0));
924 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(1));
926 success = success &&
checkFads(f3, h_v3(
i), out);
931 Kokkos_View_Fad, MultiplyUpdate,
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;
942#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
943 v1 = ViewType (
"view1", num_rows);
944 v2 = ViewType (
"view2", num_rows);
946 v1 = ViewType (
"view1", num_rows, fad_size+1);
947 v2 = ViewType (
"view2", num_rows, fad_size+1);
949 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
950 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
951 for (size_type
i=0;
i<num_rows; ++
i) {
952 h_v1(
i) = generate_fad<FadType>(
953 num_rows, size_type(2), fad_size,
i, size_type(0));
954 h_v2(
i) = generate_fad<FadType>(
955 num_rows, size_type(2), fad_size,
i, size_type(1));
957 Kokkos::deep_copy(v1, h_v1);
958 Kokkos::deep_copy(v2, h_v2);
962#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
963 v3 = ViewType (
"view3", num_rows);
965 v3 = ViewType (
"view3", num_rows, fad_size+1);
967 Kokkos::deep_copy(v3, 1.0);
971 host_view_type h_v3 = Kokkos::create_mirror_view(v3);
972 Kokkos::deep_copy(h_v3, v3);
976 for (size_type
i=0;
i<num_rows; ++
i) {
978 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(0));
980 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(1));
982 success = success &&
checkFads(f3, h_v3(
i), out);
987 Kokkos_View_Fad, MultiplyConst,
FadType, Layout, Device )
989 typedef Kokkos::View<const FadType*,Layout,Device,Kokkos::MemoryUnmanaged> ConstViewType;
990 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
991 typedef typename ViewType::size_type size_type;
992 typedef typename ViewType::HostMirror host_view_type;
999#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1000 v1 = ViewType (
"view1", num_rows);
1001 v2 = ViewType (
"view2", num_rows);
1003 v1 = ViewType (
"view1", num_rows, fad_size+1);
1004 v2 = ViewType (
"view2", num_rows, fad_size+1);
1006 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
1007 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
1008 for (size_type
i=0;
i<num_rows; ++
i) {
1009 h_v1(
i) = generate_fad<FadType>(
1010 num_rows, size_type(2), fad_size,
i, size_type(0));
1011 h_v2(
i) = generate_fad<FadType>(
1012 num_rows, size_type(2), fad_size,
i, size_type(1));
1014 Kokkos::deep_copy(v1, h_v1);
1015 Kokkos::deep_copy(v2, h_v2);
1017 ConstViewType cv1 = v1;
1021#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1022 v3 = ViewType (
"view3", num_rows);
1024 v3 = ViewType (
"view3", num_rows, fad_size+1);
1029 host_view_type h_v3 = Kokkos::create_mirror_view(v3);
1030 Kokkos::deep_copy(h_v3, v3);
1034 for (size_type
i=0;
i<num_rows; ++
i) {
1036 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(0));
1038 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(1));
1040 success = success &&
checkFads(f3, h_v3(
i), out);
1045 Kokkos_View_Fad, MultiplyMixed,
FadType, Layout, Device )
1047 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
1048 typedef typename ViewType::size_type size_type;
1049 typedef typename ViewType::HostMirror host_view_type;
1051 const size_type num_rows = 2;
1055 FadType f0 = generate_fad<FadType>(
1056 num_rows, size_type(2), fad_size, size_type(0), size_type(0));
1057 FadType f1 = generate_fad<FadType>(
1058 num_rows, size_type(2), fad_size, size_type(1), size_type(0));
1060#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1061 h_v = host_view_type (
"view1", num_rows);
1063 h_v = host_view_type (
"view1", num_rows, fad_size+1);
1076 Kokkos_View_Fad, AtomicAdd,
FadType, Layout, Device )
1078 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
1079 typedef Kokkos::View<FadType,Layout,Device> ScalarViewType;
1080 typedef typename ViewType::size_type size_type;
1081 typedef typename ScalarViewType::HostMirror host_scalar_view_type;
1088#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1089 v = ViewType (
"view", num_rows);
1091 v = ViewType (
"view", num_rows, fad_size+1);
1093 Kokkos::deep_copy(v, 2.3456);
1095 Kokkos::parallel_for(Kokkos::RangePolicy<Device>(0, num_rows), KOKKOS_LAMBDA(
const size_type
i) {
1096 for (size_type j = 0; j < fad_size; ++j)
1102#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1103 s = ScalarViewType (
"scalar view");
1105 s = ScalarViewType (
"scalar view", fad_size+1);
1112 host_scalar_view_type hs = Kokkos::create_mirror_view(s);
1113 Kokkos::deep_copy(hs, s);
1116 auto hv = Kokkos::create_mirror_view(v);
1117 Kokkos::deep_copy(hv, v);
1124 Kokkos_View_Fad, Rank8,
FadType, Layout, Device )
1126 typedef Kokkos::View<FadType*******,Layout,Device> ViewType;
1127 typedef typename ViewType::size_type size_type;
1128 typedef typename ViewType::HostMirror host_view_type;
1134#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1135 v = ViewType (
"view", 100, 1, 2, 3, 4, 5, 6);
1137 v = ViewType (
"view", 100, 1, 2, 3, 4, 5, 6, fad_size+1);
1139 host_view_type h_v = Kokkos::create_mirror_view(v);
1140 typename host_view_type::array_type h_a = h_v;
1141 Kokkos::deep_copy(h_a, 1.0);
1144 h_v(99,0,1,2,3,4,5) = f1;
1145 FadType f2 = h_v(99,0,1,2,3,4,5);
1152 Kokkos_View_Fad, Roger,
FadType, Layout, Device )
1154 Kokkos::View<FadType*,Layout,Device>
a;
1155 Kokkos::View<FadType**,Layout,Device> b;
1156 Kokkos::View<FadType***,Layout,Device>
c;
1157 Kokkos::View<FadType****,Layout,Device> d;
1158 Kokkos::View<FadType*****,Layout,Device> e;
1159 Kokkos::View<FadType******,Layout,Device> f;
1160 Kokkos::View<FadType*******,Layout,Device> g;
1162#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1163 a = Kokkos::View<FadType*,Layout,Device>(
"a",4);
1164 b = Kokkos::View<FadType**,Layout,Device> (
"b",4,4);
1165 c = Kokkos::View<FadType***,Layout,Device> (
"c",4,4,4);
1166 d = Kokkos::View<FadType****,Layout,Device> (
"d",4,4,4,4);
1167 e = Kokkos::View<FadType*****,Layout,Device> (
"e",4,4,4,4,4);
1168 f = Kokkos::View<FadType******,Layout,Device> (
"f",4,4,4,4,4,4);
1169 g = Kokkos::View<FadType*******,Layout,Device> (
"g",4,4,4,4,4,4,4);
1172 a = Kokkos::View<FadType*,Layout,Device>(
"a",4,fad_size+1);
1173 b = Kokkos::View<FadType**,Layout,Device> (
"b",4,4,fad_size+1);
1174 c = Kokkos::View<FadType***,Layout,Device> (
"c",4,4,4,fad_size+1);
1175 d = Kokkos::View<FadType****,Layout,Device> (
"d",4,4,4,4,fad_size+1);
1176 e = Kokkos::View<FadType*****,Layout,Device> (
"e",4,4,4,4,4,fad_size+1);
1177 f = Kokkos::View<FadType******,Layout,Device> (
"f",4,4,4,4,4,4,fad_size+1);
1178 g = Kokkos::View<FadType*******,Layout,Device> (
"g",4,4,4,4,4,4,4,fad_size+1);
1181 typedef typename Device::memory_space memory_space;
1182 const bool is_accessible =
1183 Kokkos::Impl::MemorySpaceAccess<Kokkos::HostSpace,
1184 memory_space>::accessible;
1185 if (is_accessible) {
1187 f(0,0,0,0,0,0) =
FadType(1.0);
1188 g(0,0,0,0,0,0,0) =
FadType(1.0);
1196 Kokkos_View_Fad, AssignDifferentStrides,
FadType, Layout, Device )
1198 typedef Kokkos::View<FadType**,Layout,Device> ViewType1;
1199 typedef Kokkos::View<FadType*,Layout,Device> ViewType2;
1200 typedef typename ViewType1::size_type size_type;
1201 typedef typename ViewType1::HostMirror host_view_type1;
1202 typedef typename ViewType2::HostMirror host_view_type2;
1210#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1211 v1 = ViewType1 (
"view1", num_rows, num_cols);
1213 v1 = ViewType1 (
"view1", num_rows, num_cols, fad_size+1);
1215 host_view_type1 h_v1 = Kokkos::create_mirror_view(v1);
1216 for (size_type
i=0;
i<num_rows; ++
i) {
1217 for (size_type j=0; j<num_cols; ++j) {
1218 h_v1(
i,j) = generate_fad<FadType>(
1219 num_rows, num_cols, fad_size,
i, j);
1222 Kokkos::deep_copy(v1, h_v1);
1226#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1227 v2 = ViewType2 (
"view2", num_rows);
1229 v2 = ViewType2 (
"view2", num_rows, fad_size+1);
1234 host_view_type2 h_v2 = Kokkos::create_mirror_view(v2);
1235 Kokkos::deep_copy(h_v2, v2);
1239 for (size_type
i=0;
i<num_rows; ++
i) {
1241 generate_fad<FadType>(num_rows, num_cols, fad_size,
i, size_type(1));
1242 success = success &&
checkFads(f, h_v2(
i), out);
1247 Kokkos_View_Fad, ScalarValue,
FadType, Layout, Device )
1250 typedef Kokkos::View<FadType,Layout,Device> ViewType1;
1251 typedef Kokkos::View<ScalarType,Layout,Device> ViewType2;
1252 typedef typename ViewType1::size_type size_type;
1253 typedef typename ViewType1::HostMirror host_view_type1;
1254 typedef typename ViewType2::HostMirror host_view_type2;
1260#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1261 v1 = ViewType1 (
"view1");
1263 v1 = ViewType1 (
"view1", fad_size+1);
1265 host_view_type1 h_v1 = Kokkos::create_mirror_view(v1);
1266 h_v1() = generate_fad<FadType>(1, 1, fad_size, 0, 0);
1267 Kokkos::deep_copy(v1, h_v1);
1270 ViewType2 v2 = ViewType2 (
"view2");
1271 Kokkos::parallel_for(Kokkos::RangePolicy<Device>(0,1),
1272 KOKKOS_LAMBDA(
const size_type
i)
1278 host_view_type2 h_v2 = Kokkos::create_mirror_view(v2);
1279 Kokkos::deep_copy(h_v2, v2);
1283 TEUCHOS_TEST_EQUALITY(h_v1().
val(), h_v2(), out, success);
1286#if defined(HAVE_SACADO_KOKKOSCONTAINERS) && defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
1289 Kokkos_View_Fad, DynRankDimensionScalar,
FadType, Layout, Device )
1291 typedef Kokkos::DynRankView<double,Layout,Device> DoubleViewType;
1292 typedef Kokkos::DynRankView<FadType,Layout,Device> FadViewType;
1293 typedef typename FadViewType::size_type size_type;
1299 DoubleViewType v1(
"view1", num_rows);
1300 FadViewType v2 (
"view2", num_rows, fad_size+1);
1303 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(v1), 0, out, success);
1304 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(v2), fad_size+1, out, success);
1308 Kokkos_View_Fad, DynRankAssignStatic0,
FadType, Layout, Device )
1310 typedef Kokkos::View<FadType,Layout,Device> StaticViewType;
1311 typedef Kokkos::DynRankView<FadType,Layout,Device> DynamicViewType;
1312 typedef typename StaticViewType::size_type size_type;
1319 StaticViewType v1(
"view", fad_size+1);
1320 auto h_v1 = Kokkos::create_mirror_view(v1);
1321 h_v1() = generate_fad<FadType>(num_rows, num_cols, fad_size, size_type(0), size_type(0));
1322 Kokkos::deep_copy(v1, h_v1);
1325 DynamicViewType v2 = v1;
1328 auto h_v2 = Kokkos::create_mirror_view(v2);
1329 Kokkos::deep_copy(h_v2, v2);
1332 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(v2), fad_size+1, out, success);
1333 TEUCHOS_TEST_EQUALITY(v2.stride_0(), v1.stride_0(), out, success);
1337 generate_fad<FadType>(num_rows, num_cols, fad_size, size_type(0), size_type(0));
1338 success = success &&
checkFads(f, h_v2(), out);
1342 Kokkos_View_Fad, DynRankAssignStatic1,
FadType, Layout, Device )
1344 typedef Kokkos::View<FadType*,Layout,Device> StaticViewType;
1345 typedef Kokkos::DynRankView<FadType,Layout,Device> DynamicViewType;
1346 typedef typename StaticViewType::size_type size_type;
1353 StaticViewType v1(
"view", num_rows, fad_size+1);
1354 auto h_v1 = Kokkos::create_mirror_view(v1);
1355 for (size_type
i=0;
i<num_rows; ++
i)
1357 generate_fad<FadType>(num_rows, num_cols, fad_size,
i, size_type(0));
1358 Kokkos::deep_copy(v1, h_v1);
1361 DynamicViewType v2 = v1;
1364 auto h_v2 = Kokkos::create_mirror_view(v2);
1365 Kokkos::deep_copy(h_v2, v2);
1368 TEUCHOS_TEST_EQUALITY(v2.extent(0), num_rows, out, success);
1369 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(v2), fad_size+1, out, success);
1370 TEUCHOS_TEST_EQUALITY(v2.stride_0(), v1.stride_0(), out, success);
1371 TEUCHOS_TEST_EQUALITY(v2.stride_1(), v1.stride_1(), out, success);
1374 for (size_type
i=0;
i<num_rows; ++
i) {
1376 generate_fad<FadType>(num_rows, num_cols, fad_size,
i, size_type(0));
1377 success = success &&
checkFads(f, h_v2(
i), out);
1382 Kokkos_View_Fad, DynRankAssignStatic2,
FadType, Layout, Device )
1384 typedef Kokkos::View<FadType**,Layout,Device> StaticViewType;
1385 typedef Kokkos::DynRankView<FadType,Layout,Device> DynamicViewType;
1386 typedef typename StaticViewType::size_type size_type;
1393 StaticViewType v1(
"view", num_rows, num_cols, fad_size+1);
1394 auto h_v1 = Kokkos::create_mirror_view(v1);
1395 for (size_type
i=0;
i<num_rows; ++
i)
1396 for (size_type j=0; j<num_cols; ++j)
1397 h_v1(
i,j) = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1398 Kokkos::deep_copy(v1, h_v1);
1401 DynamicViewType v2 = v1;
1404 auto h_v2 = Kokkos::create_mirror_view(v2);
1405 Kokkos::deep_copy(h_v2, v2);
1408 TEUCHOS_TEST_EQUALITY(v2.extent(0), num_rows, out, success);
1409 TEUCHOS_TEST_EQUALITY(v2.extent(1), num_cols, out, success);
1410 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(v2), fad_size+1, out, success);
1411 TEUCHOS_TEST_EQUALITY(v2.stride_0(), v1.stride_0(), out, success);
1412 TEUCHOS_TEST_EQUALITY(v2.stride_1(), v1.stride_1(), out, success);
1413 TEUCHOS_TEST_EQUALITY(v2.stride_2(), v1.stride_2(), out, success);
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 success = success &&
checkFads(f, h_v2(
i,j), out);
1425 Kokkos_View_Fad, DynRankMultiply,
FadType, Layout, Device )
1427 typedef Kokkos::DynRankView<FadType,Layout,Device> ViewType;
1428 typedef typename ViewType::size_type size_type;
1429 typedef typename ViewType::HostMirror host_view_type;
1435 ViewType v1(
"view1", num_rows, fad_size+1);
1436 ViewType v2(
"view2", num_rows, fad_size+1);
1437 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
1438 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
1439 for (size_type
i=0;
i<num_rows; ++
i) {
1440 h_v1(
i) = generate_fad<FadType>(
1441 num_rows, size_type(2), fad_size,
i, size_type(0));
1442 h_v2(
i) = generate_fad<FadType>(
1443 num_rows, size_type(2), fad_size,
i, size_type(1));
1445 Kokkos::deep_copy(v1, h_v1);
1446 Kokkos::deep_copy(v2, h_v2);
1449 ViewType v3(
"view3", num_rows, fad_size+1);
1453 host_view_type h_v3 = Kokkos::create_mirror_view(v3);
1454 Kokkos::deep_copy(h_v3, v3);
1458 TEUCHOS_TEST_EQUALITY(v3.rank(), 1, out, success);
1459 for (size_type
i=0;
i<num_rows; ++
i) {
1461 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(0));
1463 generate_fad<FadType>(num_rows, size_type(2), fad_size,
i, size_type(1));
1465 success = success &&
checkFads(f3, h_v3(
i), out);
1470 Kokkos_View_Fad, SubdynrankviewCol,
FadType, Layout, Device )
1472 typedef Kokkos::DynRankView<FadType,Layout,Device> ViewType;
1473 typedef typename ViewType::size_type size_type;
1474 typedef typename ViewType::HostMirror host_view_type;
1481 ViewType v(
"view", num_rows, num_cols, fad_size+1);
1482 host_view_type h_v = Kokkos::create_mirror_view(v);
1483 for (size_type
i=0;
i<num_rows; ++
i) {
1484 for (size_type j=0; j<num_cols; ++j) {
1485 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1489 Kokkos::deep_copy(v, h_v);
1493 auto s = Kokkos::subdynrankview(v, Kokkos::ALL(), col);
1496 typedef decltype(s) SubviewType;
1497 typedef typename SubviewType::HostMirror HostSubviewType;
1503 HostSubviewType h_s = Kokkos::subdynrankview(h_v, Kokkos::ALL(), col);
1507 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(s), fad_size+1, out, success);
1508 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(h_s), fad_size+1, out, success);
1509 TEUCHOS_TEST_EQUALITY(h_s.extent(0), num_rows, out, success);
1510 TEUCHOS_TEST_EQUALITY(h_s.extent(1), 1, out, success);
1511 TEUCHOS_TEST_EQUALITY(h_s.extent(7), 1, out, success);
1513 for (size_type
i=0;
i<num_rows; ++
i) {
1514 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, col);
1515 success = success &&
checkFads(f, h_s(
i), out);
1520 Kokkos_View_Fad, SubdynrankviewRow,
FadType, Layout, Device )
1522 typedef Kokkos::DynRankView<FadType,Layout,Device> ViewType;
1523 typedef typename ViewType::size_type size_type;
1524 typedef typename ViewType::HostMirror host_view_type;
1528 const size_type num_planes = 9;
1532 ViewType v(
"view", num_rows, num_cols, num_planes, fad_size+1);
1533 host_view_type h_v = Kokkos::create_mirror_view(v);
1534 for (size_type
i=0;
i<num_rows; ++
i) {
1535 for (size_type j=0; j<num_cols; ++j) {
1536 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1537 for (size_type k=0; k<num_planes; ++k) {
1538 h_v(
i,j,k) = (k+1)*f;
1542 Kokkos::deep_copy(v, h_v);
1546 auto s = Kokkos::subdynrankview(v, row, Kokkos::ALL(), Kokkos::ALL());
1549 typedef decltype(s) SubviewType;
1550 typedef typename SubviewType::HostMirror HostSubviewType;
1556 HostSubviewType h_s =
1557 Kokkos::subdynrankview(h_v, row, Kokkos::ALL(), Kokkos::ALL());
1561 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(s), fad_size+1, out, success);
1562 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(h_s), fad_size+1, out, success);
1563 TEUCHOS_TEST_EQUALITY(h_s.extent(0), num_cols, out, success);
1564 TEUCHOS_TEST_EQUALITY(h_s.extent(1), num_planes, out, success);
1565 TEUCHOS_TEST_EQUALITY(h_s.extent(2), 1, out, success);
1566 TEUCHOS_TEST_EQUALITY(h_s.extent(7), 1, out, success);
1568 for (size_type j=0; j<num_cols; ++j) {
1569 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, row, j);
1570 for (size_type k=0; k<num_planes; ++k) {
1572 success = success &&
checkFads(g, h_s(j,k), out);
1578 Kokkos_View_Fad, SubdynrankviewScalar,
FadType, Layout, Device )
1580 typedef Kokkos::DynRankView<FadType,Layout,Device> ViewType;
1581 typedef typename ViewType::size_type size_type;
1582 typedef typename ViewType::HostMirror host_view_type;
1589 ViewType v(
"view", num_rows, num_cols, fad_size+1);
1590 host_view_type h_v = Kokkos::create_mirror_view(v);
1591 for (size_type
i=0;
i<num_rows; ++
i) {
1592 for (size_type j=0; j<num_cols; ++j) {
1593 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1597 Kokkos::deep_copy(v, h_v);
1602 auto s = Kokkos::subdynrankview(v, row, col);
1605 typedef decltype(s) SubviewType;
1606 typedef typename SubviewType::HostMirror HostSubviewType;
1612 HostSubviewType h_s = Kokkos::subdynrankview(h_v, row, col);
1616 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(s), fad_size+1, out, success);
1617 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(h_s), fad_size+1, out, success);
1618 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size, row, col);
1619 success = success &&
checkFads(f, h_s(), out);
1625 Kokkos_View_Fad, DynRankDimensionScalar,
FadType, Layout, Device ) {}
1627 Kokkos_View_Fad, DynRankAssignStatic0,
FadType, Layout, Device ) {}
1629 Kokkos_View_Fad, DynRankAssignStatic1,
FadType, Layout, Device ) {}
1631 Kokkos_View_Fad, DynRankAssignStatic2,
FadType, Layout, Device ) {}
1633 Kokkos_View_Fad, DynRankMultiply,
FadType, Layout, Device ) {}
1635 Kokkos_View_Fad, SubdynrankviewCol,
FadType, Layout, Device ) {}
1637 Kokkos_View_Fad, SubdynrankviewRow,
FadType, Layout, Device ) {}
1639 Kokkos_View_Fad, SubdynrankviewScalar,
FadType, Layout, Device ) {}
1644 Kokkos_View_Fad, Subview,
FadType, Layout, Device )
1646 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
1647 typedef typename ViewType::size_type size_type;
1648 typedef typename ViewType::HostMirror host_view_type;
1656#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1657 v = ViewType (
"view", num_rows, num_cols);
1659 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
1661 host_view_type h_v = Kokkos::create_mirror_view(v);
1662 for (size_type
i=0;
i<num_rows; ++
i) {
1663 for (size_type j=0; j<num_cols; ++j) {
1664 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1668 Kokkos::deep_copy(v, h_v);
1672 auto s = Kokkos::subview(v, Kokkos::ALL(), col);
1675 typedef decltype(s) SubviewType;
1676 typedef typename SubviewType::HostMirror HostSubviewType;
1682 HostSubviewType h_s = Kokkos::subview(h_v, Kokkos::ALL(), col);
1686#if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
1687 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(s), fad_size+1, out, success);
1688 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(h_s), fad_size+1, out, success);
1690 for (size_type
i=0;
i<num_rows; ++
i) {
1691 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, col);
1692 success = success &&
checkFads(f, h_s(
i), out);
1696#ifdef SACADO_NEW_FAD_DESIGN_IS_DEFAULT
1698 Kokkos_View_Fad, ConstViewAssign,
FadType, Layout, Device )
1700 typedef Kokkos::View<FadType*,Layout,Device> ViewType;
1701 typedef Kokkos::View<const FadType,Layout,Device> ConstViewType;
1702 typedef typename ViewType::size_type size_type;
1703 typedef typename ViewType::HostMirror host_view_type;
1704 typedef typename ViewType::execution_space exec_space;
1710#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1711 ViewType v1(
"view1", num_rows);
1713 ViewType v1(
"view1", num_rows, fad_size+1);
1715 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
1716 for (size_type
i=0;
i<num_rows; ++
i) {
1717 FadType f = generate_fad<FadType>(num_rows, size_type(1), fad_size,
i,
1721 Kokkos::deep_copy(v1, h_v1);
1723#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1724 ViewType v2(
"view2", num_rows);
1726 ViewType v2(
"view2", num_rows, fad_size+1);
1729 static const size_type stride = Kokkos::ViewScalarStride<ViewType>::stride;
1730#if defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
1731 const bool use_team =
1732 std::is_same<exec_space, Kokkos::Cuda>::value &&
1733 ( Kokkos::is_view_fad_contiguous<ViewType>::value ||
1734 Kokkos::is_dynrankview_fad_contiguous<ViewType>::value ) &&
1736#elif defined (KOKKOS_ENABLE_CUDA) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
1737 const bool use_team =
1738 std::is_same<exec_space, Kokkos::Cuda>::value &&
1739 ( Kokkos::is_view_fad_contiguous<ViewType>::value ||
1740 Kokkos::is_dynrankview_fad_contiguous<ViewType>::value ) &&
1742#elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL)
1743 const bool use_team =
1744 std::is_same<exec_space, Kokkos::Experimental::HIP>::value &&
1745 ( Kokkos::is_view_fad_contiguous<ViewType>::value ||
1746 Kokkos::is_dynrankview_fad_contiguous<ViewType>::value ) &&
1748#elif defined (KOKKOS_ENABLE_HIP) && defined (SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
1749 const bool use_team =
1750 std::is_same<exec_space, Kokkos::Experimental::HIP>::value &&
1751 ( Kokkos::is_view_fad_contiguous<ViewType>::value ||
1752 Kokkos::is_dynrankview_fad_contiguous<ViewType>::value ) &&
1755 const bool use_team =
false;
1759 typedef Kokkos::TeamPolicy<exec_space> team_policy;
1760 Kokkos::parallel_for(team_policy(num_rows, 1, stride),
1761 KOKKOS_LAMBDA(
typename team_policy::member_type team)
1763 const int i = team.league_rank();
1764 typename ConstViewType::reference_type
x = v1(
i);
1769 Kokkos::parallel_for(Kokkos::RangePolicy<exec_space>(0,num_rows),
1770 KOKKOS_LAMBDA(
const int i)
1772 typename ConstViewType::reference_type
x = v1(
i);
1778 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
1779 Kokkos::deep_copy(h_v2, v2);
1783 for (size_type
i=0;
i<num_rows; ++
i) {
1784 FadType f = generate_fad<FadType>(num_rows, size_type(1), fad_size,
i,
1786 success = success &&
checkFads(f, h_v2(
i), out);
1791 Kokkos_View_Fad, ConstViewAssign,
FadType, Layout, Device ) {}
1796#if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
1798 Kokkos_View_Fad, ShmemSize,
FadType, Layout, Device )
1800 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
1801 typedef typename FadType::value_type value_type;
1802 typedef typename ViewType::size_type size_type;
1809 const size_type shmem_size =
1810 ViewType::shmem_size(num_rows, num_cols, fad_size+1);
1813 const size_type align = 8;
1814 const size_type mask = align - 1;
1816#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1817 v = ViewType (
"view", num_rows, num_cols);
1819 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
1821 const size_type shmem_size_expected =
1823 TEUCHOS_TEST_EQUALITY(shmem_size, shmem_size_expected, out, success);
1827 Kokkos_View_Fad, Unmanaged,
FadType, Layout, Device )
1832 typedef typename FadType::value_type scalar_type;
1833 typedef Kokkos::View<scalar_type***,TestLayout,Device> ViewType;
1834 typedef Kokkos::View<FadType**,TestLayout,Device,Kokkos::MemoryUnmanaged> FadViewType;
1835 typedef typename ViewType::size_type size_type;
1836 typedef typename ViewType::HostMirror host_view_type;
1837 typedef typename FadViewType::HostMirror fad_host_view_type;
1846 if (Kokkos::is_view_fad_contiguous<FadViewType>::value &&
1847 std::is_same<TestLayout, Kokkos::LayoutLeft >::value) {
1848 v = ViewType (
"view", fad_size+1, num_rows, num_cols);
1849 h_v = Kokkos::create_mirror_view(v);
1850 for (size_type
i=0;
i<num_rows; ++
i) {
1851 for (size_type j=0; j<num_cols; ++j) {
1852 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1853 for (size_type k=0; k<fad_size; k++)
1854 h_v(k,
i,j) = f.dx(k);
1855 h_v(fad_size,
i,j) = f.val();
1860 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
1861 h_v = Kokkos::create_mirror_view(v);
1862 for (size_type
i=0;
i<num_rows; ++
i) {
1863 for (size_type j=0; j<num_cols; ++j) {
1864 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1865 for (size_type k=0; k<fad_size; k++)
1866 h_v(
i,j,k) = f.dx(k);
1867 h_v(
i,j,fad_size) = f.val();
1871 Kokkos::deep_copy(v, h_v);
1875 fad_host_view_type h_v_fad;
1876#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1877 v_fad = FadViewType ( v.data(), num_rows, num_cols);
1878 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols);
1880 v_fad = FadViewType ( v.data(), num_rows, num_cols, fad_size+1);
1881 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols, fad_size+1);
1885 Kokkos::deep_copy(h_v_fad, v_fad);
1889 for (size_type
i=0;
i<num_rows; ++
i) {
1890 for (size_type j=0; j<num_cols; ++j) {
1891 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1892 success = success &&
checkFads(f, h_v_fad(
i,j), out);
1898 Kokkos_View_Fad, Unmanaged2,
FadType, Layout, Device )
1903 typedef typename FadType::value_type scalar_type;
1904 typedef Kokkos::View<scalar_type***,TestLayout,Device> ViewType;
1905 typedef Kokkos::View<FadType**,TestLayout,Device> FadViewType;
1906 typedef typename ViewType::size_type size_type;
1907 typedef typename ViewType::HostMirror host_view_type;
1908 typedef typename FadViewType::HostMirror fad_host_view_type;
1917 if (Kokkos::is_view_fad_contiguous<FadViewType>::value &&
1918 std::is_same<TestLayout, Kokkos::LayoutLeft >::value) {
1919 v = ViewType (
"view", fad_size+1, num_rows, num_cols);
1920 h_v = Kokkos::create_mirror_view(v);
1921 for (size_type
i=0;
i<num_rows; ++
i) {
1922 for (size_type j=0; j<num_cols; ++j) {
1923 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1924 for (size_type k=0; k<fad_size; k++)
1925 h_v(k,
i,j) = f.dx(k);
1926 h_v(fad_size,
i,j) = f.val();
1931 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
1932 h_v = Kokkos::create_mirror_view(v);
1933 for (size_type
i=0;
i<num_rows; ++
i) {
1934 for (size_type j=0; j<num_cols; ++j) {
1935 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1936 for (size_type k=0; k<fad_size; k++)
1937 h_v(
i,j,k) = f.dx(k);
1938 h_v(
i,j,fad_size) = f.val();
1942 Kokkos::deep_copy(v, h_v);
1946 fad_host_view_type h_v_fad;
1947#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
1948 v_fad = FadViewType ( v.data(), num_rows, num_cols);
1949 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols);
1951 v_fad = FadViewType ( v.data(), num_rows, num_cols, fad_size+1);
1952 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols, fad_size+1);
1956 Kokkos::deep_copy(h_v_fad, v_fad);
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);
1963 success = success &&
checkFads(f, h_v_fad(
i,j), out);
1969 Kokkos_View_Fad, UnmanagedConst,
FadType, Layout, Device )
1974 typedef typename FadType::value_type scalar_type;
1975 typedef Kokkos::View<scalar_type***,TestLayout,Device> ViewType;
1976 typedef Kokkos::View<const scalar_type***,TestLayout,Device> ConstViewType;
1977 typedef Kokkos::View<FadType**,TestLayout,Device,Kokkos::MemoryUnmanaged> FadViewType;
1978 typedef Kokkos::View<const FadType**,TestLayout,Device,Kokkos::MemoryUnmanaged> ConstFadViewType;
1979 typedef typename ViewType::size_type size_type;
1980 typedef typename ViewType::HostMirror host_view_type;
1981 typedef typename FadViewType::HostMirror fad_host_view_type;
1990 if (Kokkos::is_view_fad_contiguous<FadViewType>::value &&
1991 std::is_same<TestLayout, Kokkos::LayoutLeft >::value) {
1992 v = ViewType (
"view", fad_size+1, num_rows, num_cols);
1993 h_v = Kokkos::create_mirror_view(v);
1994 for (size_type
i=0;
i<num_rows; ++
i) {
1995 for (size_type j=0; j<num_cols; ++j) {
1996 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
1997 for (size_type k=0; k<fad_size; k++)
1998 h_v(k,
i,j) = f.dx(k);
1999 h_v(fad_size,
i,j) = f.val();
2004 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
2005 h_v = Kokkos::create_mirror_view(v);
2006 for (size_type
i=0;
i<num_rows; ++
i) {
2007 for (size_type j=0; j<num_cols; ++j) {
2008 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2009 for (size_type k=0; k<fad_size; k++)
2010 h_v(
i,j,k) = f.dx(k);
2011 h_v(
i,j,fad_size) = f.val();
2015 Kokkos::deep_copy(v, h_v);
2016 ConstViewType v_const = v;
2020 ConstFadViewType v_fad;
2021 fad_host_view_type h_v_fad;
2022#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2023 v_fad = ConstFadViewType ( v_const.data(), num_rows, num_cols);
2024 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols);
2026 v_fad = ConstFadViewType ( v_const.data(), num_rows, num_cols, fad_size+1);
2027 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols, fad_size+1);
2031 Kokkos::deep_copy(h_v_fad, v_fad);
2035 for (size_type
i=0;
i<num_rows; ++
i) {
2036 for (size_type j=0; j<num_cols; ++j) {
2037 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2038 success = success &&
checkFads(f, h_v_fad(
i,j), out);
2044 Kokkos_View_Fad, UnmanagedConst2,
FadType, Layout, Device )
2048 typedef typename FadType::value_type scalar_type;
2049 typedef Kokkos::View<scalar_type***,TestLayout,Device> ViewType;
2050 typedef Kokkos::View<const scalar_type***,TestLayout,Device> ConstViewType;
2051 typedef Kokkos::View<FadType**,TestLayout,Device> FadViewType;
2052 typedef Kokkos::View<const FadType**,TestLayout,Device> ConstFadViewType;
2053 typedef typename ViewType::size_type size_type;
2054 typedef typename ViewType::HostMirror host_view_type;
2055 typedef typename FadViewType::HostMirror fad_host_view_type;
2064 if (Kokkos::is_view_fad_contiguous<FadViewType>::value &&
2065 std::is_same<TestLayout, Kokkos::LayoutLeft >::value) {
2066 v = ViewType (
"view", fad_size+1, num_rows, num_cols);
2067 h_v = Kokkos::create_mirror_view(v);
2068 for (size_type
i=0;
i<num_rows; ++
i) {
2069 for (size_type j=0; j<num_cols; ++j) {
2070 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2071 for (size_type k=0; k<fad_size; k++)
2072 h_v(k,
i,j) = f.dx(k);
2073 h_v(fad_size,
i,j) = f.val();
2078 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
2079 h_v = Kokkos::create_mirror_view(v);
2080 for (size_type
i=0;
i<num_rows; ++
i) {
2081 for (size_type j=0; j<num_cols; ++j) {
2082 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2083 for (size_type k=0; k<fad_size; k++)
2084 h_v(
i,j,k) = f.dx(k);
2085 h_v(
i,j,fad_size) = f.val();
2089 Kokkos::deep_copy(v, h_v);
2090 ConstViewType v_const = v;
2093 ConstFadViewType v_fad;
2094 fad_host_view_type h_v_fad;
2095#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2096 v_fad = ConstFadViewType (v_const.data(), num_rows, num_cols);
2097 h_v_fad = fad_host_view_type (
"host_view_fad", num_rows, num_cols);
2099 v_fad = ConstFadViewType (v_const.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);
2119 Kokkos_View_Fad, SFadNoSizeArg,
FadType, Layout, Device )
2121 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
2122 typedef typename ViewType::size_type size_type;
2123 typedef typename ViewType::HostMirror host_view_type;
2130 ViewType v(
"view", num_rows, num_cols);
2131 host_view_type h_v = Kokkos::create_mirror_view(v);
2132 for (size_type
i=0;
i<num_rows; ++
i) {
2133 for (size_type j=0; j<num_cols; ++j) {
2134 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2138 Kokkos::deep_copy(v, h_v);
2141 Kokkos::deep_copy(h_v, v);
2145 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(v), fad_size+1, out, success);
2146 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(h_v), fad_size+1, out, success);
2147 for (size_type
i=0;
i<num_rows; ++
i) {
2148 for (size_type j=0; j<num_cols; ++j) {
2149 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2150 success = success &&
checkFads(f, h_v(
i,j), out);
2156 Kokkos_View_Fad, Partition,
FadType, Layout, Device )
2158#if !defined(SACADO_VIEW_CUDA_HIERARCHICAL) && !defined(SACADO_VIEW_CUDA_HIERARCHICAL_DFAD)
2159 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
2160 typedef typename ViewType::size_type size_type;
2161 typedef typename ViewType::HostMirror host_view_type;
2169#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2170 v = ViewType (
"view", num_rows, num_cols);
2172 v = ViewType (
"view", num_rows, num_cols, fad_size+1);
2174 host_view_type h_v = Kokkos::create_mirror_view(v);
2176 for (size_type
i=0;
i<num_rows; ++
i) {
2177 for (size_type j=0; j<num_cols; ++j) {
2178 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2182 Kokkos::deep_copy(v, h_v);
2185 Kokkos::deep_copy(h_v, v);
2189 const size_type stride = 2;
2190 auto h_v1 = Kokkos::partition<2>(h_v, 0, stride);
2191 auto h_v2 = Kokkos::partition<2>(h_v, 1, stride);
2194 const size_type fad_size_1 = (fad_size + stride - 0 - 1) / stride;
2195 const size_type fad_size_2 = (fad_size + stride - 1 - 1) / stride;
2197 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(h_v1), fad_size_1+1, out, success);
2198 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(h_v2), fad_size_2+1, out, success);
2199 for (size_type
i=0;
i<num_rows; ++
i) {
2200 for (size_type j=0; j<num_cols; ++j) {
2201 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2204 for (
unsigned int k=0; k<fad_size_1; ++k)
2205 if (2*k < fad_size) f1.fastAccessDx(k) = f.dx(2*k);
2206 for (
unsigned int k=0; k<fad_size_2; ++k)
2207 if (2*k+1 < fad_size) f2.fastAccessDx(k) = f.dx(2*k+1);
2208 success = success &&
checkFads(f1, h_v1(
i,j), out);
2209 success = success &&
checkFads(f2, h_v2(
i,j), out);
2216 Kokkos_View_Fad, AssignLayoutContiguousToLayoutStride,
FadType, Layout, Device )
2218 typedef Kokkos::View<FadType**,Kokkos::LayoutContiguous<Layout>,Device> ContViewType;
2219 typedef Kokkos::View<FadType**,Kokkos::LayoutStride,Device> StrideViewType;
2220 typedef typename ContViewType::size_type size_type;
2221 typedef typename ContViewType::HostMirror cont_host_view_type;
2222 typedef typename StrideViewType::HostMirror stride_host_view_type;
2230#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2231 v = ContViewType (
"view", num_rows, num_cols);
2233 v = ContViewType (
"view", num_rows, num_cols, fad_size+1);
2235 cont_host_view_type h_v = Kokkos::create_mirror_view(v);
2237 for (size_type
i=0;
i<num_rows; ++
i) {
2238 for (size_type j=0; j<num_cols; ++j) {
2239 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2243 Kokkos::deep_copy(v, h_v);
2246 StrideViewType vs = v;
2253 stride_host_view_type h_vs = h_v;
2257 TEUCHOS_TEST_EQUALITY(h_vs.extent(0), num_rows, out, success);
2258 TEUCHOS_TEST_EQUALITY(h_vs.extent(1), num_cols, out, success);
2259 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(h_vs), fad_size+1, out, success);
2260 for (size_type
i=0;
i<num_rows; ++
i) {
2261 for (size_type j=0; j<num_cols; ++j) {
2262 FadType f = generate_fad<FadType>(num_rows, num_cols, fad_size,
i, j);
2263 success = success &&
checkFads(f, h_vs(
i,j), out);
2269 Kokkos_View_Fad, CommonViewAllocMixedSpec,
FadType, Layout, Device )
2271 typedef Kokkos::View<FadType**,Kokkos::LayoutContiguous<Layout>,Device> ContViewType;
2272 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
2273 typedef typename ContViewType::size_type size_type;
2281#if defined (SACADO_DISABLE_FAD_VIEW_SPEC)
2282 v1 = ContViewType (
"view", num_rows, num_cols);
2284 v1 = ContViewType (
"view", num_rows, num_cols, fad_size+1);
2288 auto cprop = Kokkos::common_view_alloc_prop(v1);
2289 ViewType v2(Kokkos::view_alloc(
"v2",cprop), num_rows, num_cols);
2293 TEUCHOS_TEST_EQUALITY(v2.extent(0), num_rows, out, success);
2294 TEUCHOS_TEST_EQUALITY(v2.extent(1), num_cols, out, success);
2295 TEUCHOS_TEST_EQUALITY(Kokkos::dimension_scalar(v2), fad_size+1, out, success);
2301 Kokkos_View_Fad, ShmemSize,
FadType, Layout, Device )
2303 typedef Kokkos::View<FadType**,Layout,Device> ViewType;
2304 typedef typename ViewType::size_type size_type;
2310 const size_type shmem_size =
2311 ViewType::shmem_size(num_rows, num_cols);
2314 static const size_type align = 8;
2315 static const size_type mask = align - 1;
2316 const size_type shmem_size_expected =
2318 TEUCHOS_TEST_EQUALITY(shmem_size, shmem_size_expected, out, success);
2322 Kokkos_View_Fad, Unmanaged,
FadType, Layout, Device ) {}
2325 Kokkos_View_Fad, Unmanaged2,
FadType, Layout, Device ) {}
2328 Kokkos_View_Fad, UnmanagedConst,
FadType, Layout, Device ) {}
2331 Kokkos_View_Fad, UnmanagedConst2,
FadType, Layout, Device ) {}
2334 Kokkos_View_Fad, SFadNoSizeArg,
FadType, Layout, Device ) {}
2337 Kokkos_View_Fad, Partition,
FadType, Layout, Device ) {}
2340 Kokkos_View_Fad, AssignLayoutContiguousToLayoutStride,
FadType, Layout, Device ) {}
2343 Kokkos_View_Fad, CommonViewAllocMixedSpec,
FadType, Layout, Device ) {}
2347#define VIEW_FAD_TESTS_FLD( F, L, D ) \
2348 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Size, F, L, D ) \
2349 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy, F, L, D ) \
2350 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy_ConstantScalar, F, L, D ) \
2351 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy_ConstantZero, F, L, D ) \
2352 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy_ConstantFad, F, L, D ) \
2353 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DeepCopy_ConstantFadFull, F, L, D ) \
2354 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, ScalarAssign, F, L, D ) \
2355 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, ValueAssign, F, L, D ) \
2356 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Resize, F, L, D ) \
2357 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Unmanaged, F, L, D ) \
2358 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Unmanaged2, F, L, D ) \
2359 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, UnmanagedConst, F, L, D ) \
2360 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, UnmanagedConst2, F, L, D ) \
2361 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Multiply, F, L, D ) \
2362 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, MultiplyUpdate, F, L, D ) \
2363 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, MultiplyConst, F, L, D ) \
2364 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, MultiplyMixed, F, L, D ) \
2365 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Rank8, F, L, D ) \
2366 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Roger, F, L, D ) \
2367 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, AtomicAdd, F, L, D ) \
2368 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, AssignDifferentStrides, F, L, D ) \
2369 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, ScalarValue, F, L, D ) \
2370 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankDimensionScalar, F, L, D ) \
2371 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankAssignStatic0, F, L, D ) \
2372 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankAssignStatic1, F, L, D ) \
2373 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankAssignStatic2, F, L, D ) \
2374 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, DynRankMultiply, F, L, D ) \
2375 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, SubdynrankviewCol, F, L, D ) \
2376 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, SubdynrankviewRow, F, L, D ) \
2377 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, SubdynrankviewScalar, F, L, D ) \
2378 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Subview, F, L, D ) \
2379 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, ShmemSize, F, L, D ) \
2380 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, ConstViewAssign, F, L, D )
2382#define VIEW_FAD_TESTS_SFLD( F, L, D ) \
2383 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, SFadNoSizeArg, F, L, D )
2385#define VIEW_FAD_TESTS_FDI( F, D ) \
2386 using Kokkos::LayoutLeft; \
2387 using Kokkos::LayoutRight; \
2388 VIEW_FAD_TESTS_FLD( F, LayoutLeft, D ) \
2389 VIEW_FAD_TESTS_FLD( F, LayoutRight, D ) \
2390 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, AssignLayoutContiguousToLayoutStride, F, LayoutLeft, D ) \
2391 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, AssignLayoutContiguousToLayoutStride, F, LayoutRight, D ) \
2392 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, CommonViewAllocMixedSpec, F, LayoutLeft, D ) \
2393 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, CommonViewAllocMixedSpec, F, LayoutRight, D )
2395#define VIEW_FAD_TESTS_SFDI( F, D ) \
2396 using Kokkos::LayoutLeft; \
2397 using Kokkos::LayoutRight; \
2398 VIEW_FAD_TESTS_SFLD( F, LayoutLeft, D ) \
2399 VIEW_FAD_TESTS_SFLD( F, LayoutRight, D )
2401#if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
2404#define VIEW_FAD_TESTS_FDC( F, D ) \
2405 VIEW_FAD_TESTS_FLD( F, LeftContiguous, D ) \
2406 VIEW_FAD_TESTS_FLD( F, RightContiguous, D ) \
2407 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Partition, F, LeftContiguous, D ) \
2408 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_Fad, Partition, F, RightContiguous, D )
2410#define VIEW_FAD_TESTS_SFDC( F, D ) \
2411 VIEW_FAD_TESTS_SFLD( F, LeftContiguous, D ) \
2412 VIEW_FAD_TESTS_SFLD( F, RightContiguous, D )
2414#define VIEW_FAD_TESTS_FDC( F, D )
2415#define VIEW_FAD_TESTS_SFDC( F, D )
2418#define VIEW_FAD_TESTS_FD( F, D ) \
2419 VIEW_FAD_TESTS_FDI( F, D ) \
2420 VIEW_FAD_TESTS_FDC( F, D )
2422#define VIEW_FAD_TESTS_SFD( F, D ) \
2423 VIEW_FAD_TESTS_SFDI( F, D ) \
2424 VIEW_FAD_TESTS_SFDC( F, D )
2447#if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC) && SACADO_TEST_DFAD
2448#define VIEW_FAD_TESTS_D( D ) \
2449 VIEW_FAD_TESTS_FD( SFadType, D ) \
2450 VIEW_FAD_TESTS_FD( SLFadType, D ) \
2451 VIEW_FAD_TESTS_FD( DFadType, D ) \
2452 VIEW_FAD_TESTS_SFD( SFadType, D )
2456 VIEW_FAD_TESTS_FD( ELRSLFadType,
D ) \
2457 VIEW_FAD_TESTS_FD( ELRDFadType,
D ) \
2458 VIEW_FAD_TESTS_FD( CacheSFadType,
D ) \
2459 VIEW_FAD_TESTS_FD( CacheSLFadType,
D ) \
2460 VIEW_FAD_TESTS_FD( CacheDFadType,
D ) \
2461 VIEW_FAD_TESTS_FD( ELRCacheSFadType,
D ) \
2462 VIEW_FAD_TESTS_FD( ELRCacheSLFadType,
D ) \
2463 VIEW_FAD_TESTS_FD( ELRCacheDFadType,
D ) \
2465 VIEW_FAD_TESTS_SFD( ELRSFadType,
D ) \
2466 VIEW_FAD_TESTS_SFD( CacheSFadType,
D ) \
2467 VIEW_FAD_TESTS_SFD( ELRCacheSFadType,
D )
2472#define VIEW_FAD_TESTS_D( D ) \
2473 VIEW_FAD_TESTS_FD( SFadType, D ) \
2474 VIEW_FAD_TESTS_FD( SLFadType, D ) \
2475 VIEW_FAD_TESTS_SFD( SFadType, D )
2479 VIEW_FAD_TESTS_FD( ELRSLFadType,
D ) \
2480 VIEW_FAD_TESTS_FD( CacheSFadType,
D ) \
2481 VIEW_FAD_TESTS_FD( CacheSLFadType,
D ) \
2482 VIEW_FAD_TESTS_FD( ELRCacheSFadType,
D ) \
2483 VIEW_FAD_TESTS_FD( ELRCacheSLFadType,
D ) \
2485 VIEW_FAD_TESTS_SFD( ELRSFadType,
D ) \
2486 VIEW_FAD_TESTS_SFD( CacheSFadType,
D ) \
2487 VIEW_FAD_TESTS_SFD( ELRCacheSFadType,
D )
Kokkos::LayoutContiguous< Kokkos::LayoutRight > RightContiguous
Kokkos::LayoutContiguous< Kokkos::LayoutLeft > LeftContiguous
bool checkFads(const FadType1 &x, const FadType2 &x2, Teuchos::FancyOStream &out, double tol=1.0e-15)
const int global_num_rows
fadtype generate_fad(const ordinal num_rows, const ordinal num_cols, const ordinal fad_size, const ordinal row, const ordinal col)
#define VIEW_FAD_TESTS_FD(F, D)
const int global_num_cols
Sacado::Fad::SLFad< double, 2 *global_fad_size > SLFadType
TEUCHOS_UNIT_TEST_TEMPLATE_3_DECL(Kokkos_View_Fad, Size, FadType, Layout, Device)
Sacado::Fad::DFad< double > DFadType
const int global_fad_size
Sacado::Fad::SFad< double, global_fad_size > SFadType
expr expr expr fastAccessDx(i)) FAD_UNARYOP_MACRO(exp
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
Sacado::Fad::DFad< double > FadType
Fad specializations for Teuchos::BLAS wrappers.
SACADO_INLINE_FUNCTION ScalarType< T >::type scalarValue(const T &x)
A simple template function for invoking ScalarValue<>
team_policy_type::member_type team_handle
InputViewType::size_type size_type
KOKKOS_INLINE_FUNCTION void operator()(const size_type i) const
const OutputViewType m_v2
static void apply(const InputViewType v1, const OutputViewType v2, const size_type col)
InputViewType::execution_space execution_space
Kokkos::TeamPolicy< execution_space > team_policy_type
AssignRank2Rank1Kernel(const InputViewType v1, const OutputViewType v2, const size_type col)
Kokkos::RangePolicy< execution_space > range_policy_type
KOKKOS_INLINE_FUNCTION void operator()(const team_handle &team) const
static const size_type stride
KOKKOS_INLINE_FUNCTION void operator()(const size_type i) const
static const size_type stride
ViewType::size_type size_type
ViewType::execution_space execution_space
team_policy_type::member_type team_handle
Kokkos::RangePolicy< execution_space > range_policy_type
AtomicAddKernel(const ViewType &v, const ScalarViewType &s)
Kokkos::ThreadLocalScalarType< ViewType >::type local_scalar_type
KOKKOS_INLINE_FUNCTION void operator()(const team_handle &team) const
static void apply(const ViewType &v, const ScalarViewType &s)
Kokkos::TeamPolicy< execution_space > team_policy_type
team_policy_type::member_type team_handle
static void apply(const InputViewType1 v1, const InputViewType2 v2, const OutputViewType v3, const bool update=false)
InputViewType1::size_type size_type
const InputViewType1 m_v1
const OutputViewType m_v3
KOKKOS_INLINE_FUNCTION void operator()(const size_type i) const
KOKKOS_INLINE_FUNCTION void operator()(const team_handle &team) const
Kokkos::TeamPolicy< execution_space > team_policy_type
InputViewType1::execution_space execution_space
MultiplyKernel(const InputViewType1 v1, const InputViewType2 v2, const OutputViewType v3, const bool update)
const InputViewType2 m_v2
Kokkos::RangePolicy< execution_space > range_policy_type
KOKKOS_INLINE_FUNCTION void operator()(const size_type i) const
Kokkos::RangePolicy< execution_space > range_policy_type
team_policy_type::member_type team_handle
ScalarAssignKernel(const ViewType &v, const ScalarType &s)
static void apply(const ViewType &v, const ScalarType &s)
static const size_type stride
ViewType::size_type size_type
ViewType::execution_space execution_space
Kokkos::TeamPolicy< execution_space > team_policy_type
KOKKOS_INLINE_FUNCTION void operator()(const team_handle &team) const
ViewType::value_type::value_type ScalarType
team_policy_type::member_type team_handle
ViewType::value_type ValueType
KOKKOS_INLINE_FUNCTION void operator()(const team_handle &team) const
static void apply(const ViewType &v, const ScalarViewType &s)
ViewType::execution_space execution_space
ValueAssignKernel(const ViewType &v, const ScalarViewType &s)
Kokkos::RangePolicy< execution_space > range_policy_type
Kokkos::TeamPolicy< execution_space > team_policy_type
Kokkos::ThreadLocalScalarType< ViewType >::type local_scalar_type
ViewType::size_type size_type
KOKKOS_INLINE_FUNCTION void operator()(const size_type i) const
static const size_type stride