15 template <
typename FadType1,
typename FadType2>
28 for (
int i=0;
i<x.size(); ++
i)
34 template <
typename FadType1,
typename FadType2>
44 success = success &&
checkFads(x.val(), x2.val(), out,
tol);
47 for (
int i=0;
i<x.size(); ++
i)
53 template <
typename fadfadtype,
typename ordinal>
56 const ordinal num_cols,
57 const ordinal outer_fad_size,
58 const ordinal inner_fad_size,
62 typedef typename fadfadtype::value_type fadtype;
63 typedef typename fadtype::value_type scalar;
64 fadfadtype
x(outer_fad_size, scalar(0.0));
65 fadtype
y(inner_fad_size, scalar(0.0));
67 const scalar x_row = 1000.0 + scalar(num_rows) / scalar(row+1);
68 const scalar x_col = 100.0 + scalar(num_cols) / scalar(col+1);
69 y.val() = x_row + x_col;
70 for (ordinal j=0; j<inner_fad_size; ++j) {
71 const scalar y_fad = 1.0 + scalar(inner_fad_size) / scalar(j+1);
72 y.fastAccessDx(j) = x_row + x_col + y_fad;
75 for (ordinal
i=0;
i<outer_fad_size; ++
i) {
76 const scalar x_fad = 10.0 + scalar(outer_fad_size) / scalar(
i+1);
78 for (ordinal j=0; j<inner_fad_size; ++j) {
79 const scalar y_fad = 1.0 + scalar(inner_fad_size) / scalar(j+1);
80 y.fastAccessDx(j) = x_row + x_col + x_fad + y_fad;
82 x.fastAccessDx(
i) =
y;
93 Kokkos_View_FadFad, DeepCopy, FadFadType, Layout, Device )
95 typedef Kokkos::View<FadFadType**,Layout,Device> ViewType;
96 typedef typename ViewType::size_type size_type;
97 typedef typename ViewType::HostMirror host_view_type;
105 ViewType v1(
"view1", num_rows, num_cols, outer_fad_size+1);
106 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
107 for (size_type
i=0;
i<num_rows; ++
i)
108 for (size_type j=0; j<num_cols; ++j)
109 h_v1(
i,j) = generate_nested_fad<FadFadType>(num_rows,
114 Kokkos::deep_copy(v1, h_v1);
117 ViewType v2(
"view2", num_rows, num_cols, outer_fad_size+1);
118 Kokkos::deep_copy(v2, v1);
121 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
122 Kokkos::deep_copy(h_v2, v2);
126 for (size_type i=0; i<num_rows; ++
i) {
127 for (size_type j=0; j<num_cols; ++j) {
128 FadFadType
f = generate_nested_fad<FadFadType>(num_rows,
138 #ifdef HAVE_SACADO_KOKKOS
141 Kokkos_DynRankView_FadFad, DeepCopy, FadFadType, Layout, Device )
143 typedef Kokkos::DynRankView<FadFadType,Layout,Device> ViewType;
144 typedef typename ViewType::size_type size_type;
145 typedef typename ViewType::HostMirror host_view_type;
153 ViewType v1(
"view1", num_rows, num_cols, outer_fad_size+1);
154 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
155 for (size_type
i=0;
i<num_rows; ++
i)
156 for (size_type j=0; j<num_cols; ++j)
157 h_v1(
i,j) = generate_nested_fad<FadFadType>(num_rows,
162 Kokkos::deep_copy(v1, h_v1);
165 ViewType v2(
"view2", num_rows, num_cols, outer_fad_size+1);
166 Kokkos::deep_copy(v2, v1);
169 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
170 Kokkos::deep_copy(h_v2, v2);
174 for (size_type i=0; i<num_rows; ++
i) {
175 for (size_type j=0; j<num_cols; ++j) {
176 FadFadType
f = generate_nested_fad<FadFadType>(num_rows,
190 Kokkos_DynRankView_FadFad, Interop, FadFadType, Layout, Device )
192 typedef Kokkos::DynRankView<FadFadType,Layout,Device> DRViewType;
193 typedef typename DRViewType::size_type size_type;
194 typedef typename DRViewType::HostMirror host_view_type;
196 typedef Kokkos::View<FadFadType**,Layout,Device> NoDynViewType;
197 typedef typename NoDynViewType::HostMirror host_nondynrankview_type;
205 DRViewType v1(
"drview1", num_rows, num_cols, outer_fad_size+1);
206 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
208 NoDynViewType ndv2(
"nodview2", num_rows, num_cols, outer_fad_size+1);
209 host_nondynrankview_type h_ndv2 = Kokkos::create_mirror_view(ndv2);
211 for (size_type i=0; i<num_rows; ++
i)
212 for (size_type j=0; j<num_cols; ++j)
213 h_v1(i,j) = generate_nested_fad<FadFadType>(num_rows,
218 Kokkos::deep_copy(v1, h_v1);
221 Kokkos::deep_copy(ndv2, h_v1);
223 DRViewType v2(
"drview2", num_rows, num_cols, outer_fad_size+1);
227 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
228 Kokkos::deep_copy(h_v2, v2);
232 for (size_type i=0; i<num_rows; ++
i) {
233 for (size_type j=0; j<num_cols; ++j) {
234 FadFadType
f = generate_nested_fad<FadFadType>(num_rows,
248 Kokkos_DynRankView_FadFad, Interop2, FadFadType, Layout, Device )
250 typedef Kokkos::DynRankView<FadFadType,Layout,Device> DRViewType;
251 typedef typename DRViewType::size_type size_type;
252 typedef typename DRViewType::HostMirror host_view_type;
254 typedef Kokkos::View<FadFadType**,Layout,Device> NoDynViewType;
255 typedef typename NoDynViewType::HostMirror host_nondynrankview_type;
263 DRViewType v1(
"drview1", num_rows, num_cols, outer_fad_size+1);
264 host_view_type h_v1 = Kokkos::create_mirror_view(v1);
266 NoDynViewType ndv2(
"nodview2", num_rows, num_cols, outer_fad_size+1);
267 host_nondynrankview_type h_ndv2 = Kokkos::create_mirror_view(ndv2);
269 for (size_type i=0; i<num_rows; ++
i)
270 for (size_type j=0; j<num_cols; ++j)
271 h_v1(i,j) = generate_nested_fad<FadFadType>(num_rows,
276 Kokkos::deep_copy(v1, h_v1);
279 Kokkos::deep_copy(ndv2, h_v1);
281 DRViewType v2(ndv2) ;
284 host_view_type h_v2 = Kokkos::create_mirror_view(v2);
285 Kokkos::deep_copy(h_v2, v2);
289 for (size_type i=0; i<num_rows; ++
i) {
290 for (size_type j=0; j<num_cols; ++j) {
291 FadFadType
f = generate_nested_fad<FadFadType>(num_rows,
306 Kokkos_DynRankView_FadFad, DeepCopy, FadFadType, Layout, Device ) {}
308 Kokkos_DynRankView_FadFad, Interop, FadFadType, Layout, Device ) {}
310 Kokkos_DynRankView_FadFad, Interop2, FadFadType, Layout, Device ) {}
314 #define VIEW_FAD_TESTS_FLD( F, L, D ) \
315 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_View_FadFad, DeepCopy, F, L, D ) \
316 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_DynRankView_FadFad, DeepCopy, F, L, D ) \
317 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_DynRankView_FadFad, Interop, F, L, D ) \
318 TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( Kokkos_DynRankView_FadFad, Interop2, F, L, D )
320 #define VIEW_FAD_TESTS_FD( F, D ) \
321 using Kokkos::LayoutLeft; \
322 using Kokkos::LayoutRight; \
323 VIEW_FAD_TESTS_FLD( F, LayoutLeft, D) \
324 VIEW_FAD_TESTS_FLD( F, LayoutRight, D)
335 #if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
337 #define VIEW_FAD_TESTS_D( D ) \
338 VIEW_FAD_TESTS_FD( SFadType, D ) \
339 VIEW_FAD_TESTS_FD( SLFadType, D ) \
340 VIEW_FAD_TESTS_FD( DFadType, D )
342 #define VIEW_FAD_TESTS_D( D ) \
343 VIEW_FAD_TESTS_FD( SFadType, D ) \
344 VIEW_FAD_TESTS_FD( SLFadType, D )
347 #define VIEW_FAD_TESTS_D( D )
#define TEUCHOS_TEST_FLOATING_EQUALITY(v1, v2, tol, out, success)
bool checkFads(const FadType1 &x, const FadType2 &x2, Teuchos::FancyOStream &out, double tol=1.0e-15)
const int global_num_rows
Sacado::Fad::SFad< double, fad_dim > SFadType
TEUCHOS_UNIT_TEST_TEMPLATE_3_DECL(Kokkos_View_FadFad, DeepCopy, FadFadType, Layout, Device)
const int global_num_cols
Sacado::Fad::SLFad< double, fad_dim > SLFadType
Sacado::Fad::DFad< double > DFadType
const int global_inner_fad_size
#define TEUCHOS_TEST_EQUALITY(v1, v2, out, success)
Sacado::Fad::SFad< double, global_inner_fad_size > InnerFadType
bool checkNestedFads(const FadType1 &x, const FadType2 &x2, Teuchos::FancyOStream &out, double tol=1.0e-15)
const int global_outer_fad_size
fadfadtype generate_nested_fad(const ordinal num_rows, const ordinal num_cols, const ordinal outer_fad_size, const ordinal inner_fad_size, const ordinal row, const ordinal col)