47 #include "Stokhos_Ensemble_Sizes.hpp"
52 #include "Kokkos_Core.hpp"
61 template <
typename scalar,
typename ordinal>
65 const ordinal iColFEM,
66 const ordinal iStoch )
68 const scalar X_fem = 100.0 + scalar(iColFEM) / scalar(nFEM);
69 const scalar X_stoch = 1.0 + scalar(iStoch) / scalar(nStoch);
70 return X_fem + X_stoch;
74 template <
typename ViewType>
78 typedef ViewType view_type;
79 typedef typename view_type::size_type size_type;
80 typedef typename view_type::HostMirror host_view_type;
81 typedef typename host_view_type::array_type host_array_type;
87 host_array_type h_a = h_v;
89 size_type num_rows, num_cols;
93 bool is_right = std::is_same<
typename ViewType::array_layout,
95 if (is_right || !view_type::is_contiguous) {
96 num_rows = h_a.extent(0);
97 num_cols = h_a.extent(1);
100 num_rows = h_a.extent(1);
101 num_cols = h_a.extent(0);
104 if (is_right || !view_type::is_contiguous) {
105 for (size_type i=0; i<num_rows; ++i) {
106 for (size_type
j=0;
j<num_cols; ++
j) {
107 scalar_type
val = h_a(i,
j);
108 scalar_type val_expected =
109 generate_vector_coefficient<scalar_type>(
110 num_rows, num_cols, i,
j);
116 for (size_type i=0; i<num_rows; ++i) {
117 for (size_type
j=0;
j<num_cols; ++
j) {
118 scalar_type
val = h_a(
j,i);
119 scalar_type val_expected =
120 generate_vector_coefficient<scalar_type>(
121 num_rows, num_cols, i,
j);
130 template <
typename ViewType>
135 typedef ViewType view_type;
139 typedef typename view_type::size_type size_type;
140 typedef typename view_type::HostMirror host_view_type;
146 const size_type num_rows = h_view.extent(0);
148 const size_type num_ensemble = storage_type::static_size;
150 for (size_type i=0; i<num_rows; ++i) {
151 for (size_type k=0; k<num_ensemble; ++k) {
153 for (size_type
j=0;
j<num_fad; ++
j) {
162 template <
typename ViewType>
167 typedef ViewType view_type;
171 typedef typename view_type::size_type size_type;
172 typedef typename view_type::HostMirror host_view_type;
180 const size_type num_ensemble = storage_type::static_size;
181 for (size_type i0=0; i0<h_view.extent(0); ++i0) {
182 for (size_type i1=0; i1<h_view.extent(1); ++i1) {
183 for (size_type i2=0; i2<h_view.extent(2); ++i2) {
184 for (size_type i3=0; i3<h_view.extent(3); ++i3) {
185 for (size_type i4=0; i4<h_view.extent(4); ++i4) {
186 for (size_type i5=0; i5<h_view.extent(5); ++i5) {
187 for (size_type i6=0; i6<h_view.extent(6); ++i6) {
188 for (size_type k=0; k<num_ensemble; ++k)
190 v.val().coeff(k), out, success);
191 for (size_type
j=0;
j<num_fad; ++
j) {
192 for (size_type k=0; k<num_ensemble; ++k)
194 v.dx(
j).coeff(k), out, success);
201 template <
typename DataType,
typename LayoutType,
typename ExecutionSpace>
203 typedef Kokkos::View<DataType,LayoutType,ExecutionSpace>
type;
207 template <
typename DataType,
typename ExecutionSpace>
209 typedef Kokkos::View<DataType,ExecutionSpace>
type;
225 typedef typename ViewType::size_type size_type;
229 ViewType v(
"view", num_rows, num_cols);
239 typedef typename ViewType::size_type size_type;
243 ViewType v(
"view", num_rows, num_cols);
244 BaseScalar
val = 1.2345;
260 BaseScalar
val = 1.2345;
267 #define VIEW_FAD_MP_VECTOR_TESTS_SCALAR_LAYOUT( SCALAR, LAYOUT ) \
268 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \
269 Kokkos_View_Fad_MP, Size, SCALAR, LAYOUT ) \
270 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \
271 Kokkos_View_Fad_MP, DeepCopy_ConstantScalar, SCALAR, LAYOUT ) \
272 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \
273 Kokkos_View_Fad_MP, Rank6, SCALAR, LAYOUT )
275 #define VIEW_FAD_MP_VECTOR_TESTS_SCALAR( SCALAR ) \
276 using Kokkos::LayoutLeft; \
277 using Kokkos::LayoutRight; \
278 VIEW_FAD_MP_VECTOR_TESTS_SCALAR_LAYOUT(SCALAR, NoLayout) \
279 VIEW_FAD_MP_VECTOR_TESTS_SCALAR_LAYOUT(SCALAR, LayoutLeft) \
280 VIEW_FAD_MP_VECTOR_TESTS_SCALAR_LAYOUT(SCALAR, LayoutRight)
282 #define VIEW_FAD_MP_VECTOR_TESTS_DEVICE( DEVICE ) \
283 typedef Stokhos::StaticFixedStorage<int,double,global_ensemble_size,DEVICE> SFS; \
284 typedef Sacado::MP::Vector< SFS > MP_SFS; \
285 typedef Sacado::Fad::DFad< MP_SFS > Fad_MP_SFS; \
286 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)