14 #include "Kokkos_View_Fad_Fwd.hpp"
16 #include "Stokhos_Ensemble_Sizes.hpp"
21 #include "Kokkos_Core.hpp"
30 template <
typename scalar,
typename ordinal>
34 const ordinal iColFEM,
35 const ordinal iStoch )
37 const scalar X_fem = 100.0 + scalar(iColFEM) / scalar(nFEM);
38 const scalar X_stoch = 1.0 + scalar(iStoch) / scalar(nStoch);
39 return X_fem + X_stoch;
43 template <
typename ViewType>
47 typedef ViewType view_type;
48 typedef typename view_type::size_type size_type;
49 typedef typename view_type::HostMirror host_view_type;
50 typedef typename host_view_type::array_type host_array_type;
56 host_array_type h_a = h_v;
58 size_type num_rows, num_cols;
62 bool is_right = std::is_same<
typename ViewType::array_layout,
64 if (is_right || !view_type::is_contiguous) {
65 num_rows = h_a.extent(0);
66 num_cols = h_a.extent(1);
69 num_rows = h_a.extent(1);
70 num_cols = h_a.extent(0);
73 if (is_right || !view_type::is_contiguous) {
74 for (size_type i=0; i<num_rows; ++i) {
75 for (size_type
j=0;
j<num_cols; ++
j) {
76 scalar_type
val = h_a(i,
j);
77 scalar_type val_expected =
78 generate_vector_coefficient<scalar_type>(
79 num_rows, num_cols, i,
j);
85 for (size_type i=0; i<num_rows; ++i) {
86 for (size_type
j=0;
j<num_cols; ++
j) {
87 scalar_type
val = h_a(
j,i);
88 scalar_type val_expected =
89 generate_vector_coefficient<scalar_type>(
90 num_rows, num_cols, i,
j);
99 template <
typename ViewType>
104 typedef ViewType view_type;
108 typedef typename view_type::size_type size_type;
109 typedef typename view_type::HostMirror host_view_type;
115 const size_type num_rows = h_view.extent(0);
117 const size_type num_ensemble = storage_type::static_size;
119 for (size_type i=0; i<num_rows; ++i) {
120 for (size_type k=0; k<num_ensemble; ++k) {
122 for (size_type
j=0;
j<num_fad; ++
j) {
131 template <
typename ViewType>
136 typedef ViewType view_type;
140 typedef typename view_type::size_type size_type;
141 typedef typename view_type::HostMirror host_view_type;
149 const size_type num_ensemble = storage_type::static_size;
150 for (size_type i0=0; i0<h_view.extent(0); ++i0) {
151 for (size_type i1=0; i1<h_view.extent(1); ++i1) {
152 for (size_type i2=0; i2<h_view.extent(2); ++i2) {
153 for (size_type i3=0; i3<h_view.extent(3); ++i3) {
154 for (size_type i4=0; i4<h_view.extent(4); ++i4) {
155 for (size_type i5=0; i5<h_view.extent(5); ++i5) {
156 for (size_type i6=0; i6<h_view.extent(6); ++i6) {
157 for (size_type k=0; k<num_ensemble; ++k)
159 v.val().coeff(k), out, success);
160 for (size_type
j=0;
j<num_fad; ++
j) {
161 for (size_type k=0; k<num_ensemble; ++k)
163 v.dx(
j).coeff(k), out, success);
170 template <
typename DataType,
typename LayoutType,
typename ExecutionSpace>
172 typedef Kokkos::View<DataType,LayoutType,ExecutionSpace>
type;
176 template <
typename DataType,
typename ExecutionSpace>
178 typedef Kokkos::View<DataType,ExecutionSpace>
type;
194 typedef typename ViewType::size_type size_type;
198 ViewType v(
"view", num_rows, num_cols);
208 typedef typename ViewType::size_type size_type;
212 ViewType v(
"view", num_rows, num_cols);
213 BaseScalar
val = 1.2345;
229 BaseScalar
val = 1.2345;
236 #define VIEW_FAD_MP_VECTOR_TESTS_SCALAR_LAYOUT( SCALAR, LAYOUT ) \
237 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \
238 Kokkos_View_Fad_MP, Size, SCALAR, LAYOUT ) \
239 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \
240 Kokkos_View_Fad_MP, DeepCopy_ConstantScalar, SCALAR, LAYOUT ) \
241 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \
242 Kokkos_View_Fad_MP, Rank6, SCALAR, LAYOUT )
244 #define VIEW_FAD_MP_VECTOR_TESTS_SCALAR( SCALAR ) \
245 using Kokkos::LayoutLeft; \
246 using Kokkos::LayoutRight; \
247 VIEW_FAD_MP_VECTOR_TESTS_SCALAR_LAYOUT(SCALAR, NoLayout) \
248 VIEW_FAD_MP_VECTOR_TESTS_SCALAR_LAYOUT(SCALAR, LayoutLeft) \
249 VIEW_FAD_MP_VECTOR_TESTS_SCALAR_LAYOUT(SCALAR, LayoutRight)
251 #define VIEW_FAD_MP_VECTOR_TESTS_DEVICE( DEVICE ) \
252 typedef Stokhos::StaticFixedStorage<int,double,global_ensemble_size,DEVICE> SFS; \
253 typedef Sacado::MP::Vector< SFS > MP_SFS; \
254 typedef Sacado::Fad::DFad< MP_SFS > Fad_MP_SFS; \
255 VIEW_FAD_MP_VECTOR_TESTS_SCALAR( Fad_MP_SFS )
const int global_ensemble_size
Stokhos::StandardStorage< int, double > storage_type
Kokkos::DefaultExecutionSpace execution_space
scalar generate_vector_coefficient(const ordinal nFEM, const ordinal nStoch, const ordinal iColFEM, const ordinal iStoch)
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< View< T, P...> >::value, unsigned >::type dimension_scalar(const View< T, P...> &view)
bool checkConstantFadVectorView2(const ViewType &view, const typename ViewType::value_type &v, Teuchos::FancyOStream &out)
bool checkVectorView(const ViewType &v, Teuchos::FancyOStream &out)
TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL(Kokkos_SG_SpMv, CrsProductTensorCijk, Scalar, Device)
const int global_fad_size
Kokkos::View< DataType, ExecutionSpace > type
void deep_copy(const Stokhos::CrsMatrix< ValueType, DstDevice, Layout > &dst, const Stokhos::CrsMatrix< ValueType, SrcDevice, Layout > &src)
const int global_num_rows
#define TEUCHOS_TEST_EQUALITY(v1, v2, out, success)
SparseArrayIterator< index_iterator, value_iterator >::value_reference value(const SparseArrayIterator< index_iterator, value_iterator > &it)
bool checkConstantFadVectorView(const ViewType &view, const typename ViewType::value_type &v, Teuchos::FancyOStream &out)
Kokkos::View< DataType, LayoutType, ExecutionSpace > type
Stokhos::CrsMatrix< ValueType, Device, Layout >::HostMirror create_mirror_view(const Stokhos::CrsMatrix< ValueType, Device, Layout > &A)