42 #include "Teuchos_TestingHelpers.hpp" 43 #include "Teuchos_UnitTestHelpers.hpp" 51 #include "Kokkos_Core.hpp" 60 template <
typename scalar,
typename ordinal>
64 const ordinal iColFEM,
65 const ordinal iStoch )
67 const scalar X_fem = 100.0 + scalar(iColFEM) / scalar(nFEM);
68 const scalar X_stoch = 1.0 + scalar(iStoch) / scalar(nStoch);
69 return X_fem + X_stoch;
73 template <
typename ViewType>
76 Teuchos::FancyOStream& out) {
77 typedef ViewType view_type;
78 typedef typename view_type::size_type size_type;
79 typedef typename view_type::HostMirror host_view_type;
80 typedef typename host_view_type::array_type host_array_type;
86 host_array_type h_a = h_v;
88 size_type num_rows, num_cols;
92 bool is_right = Kokkos::Impl::is_same<
typename ViewType::array_layout,
94 if (is_right || !view_type::is_contiguous) {
95 num_rows = h_a.extent(0);
96 num_cols = h_a.extent(1);
99 num_rows = h_a.extent(1);
100 num_cols = h_a.extent(0);
103 if (is_right || !view_type::is_contiguous) {
104 for (size_type i=0; i<num_rows; ++i) {
105 for (size_type
j=0;
j<num_cols; ++
j) {
108 generate_vector_coefficient<scalar_type>(
109 num_rows, num_cols, i,
j);
110 TEUCHOS_TEST_EQUALITY(
val, val_expected, out, success);
115 for (size_type i=0; i<num_rows; ++i) {
116 for (size_type
j=0;
j<num_cols; ++
j) {
119 generate_vector_coefficient<scalar_type>(
120 num_rows, num_cols, i,
j);
121 TEUCHOS_TEST_EQUALITY(
val, val_expected, out, success);
129 template <
typename ViewType>
133 Teuchos::FancyOStream& out) {
134 typedef ViewType view_type;
138 typedef typename view_type::size_type size_type;
139 typedef typename view_type::HostMirror host_view_type;
145 const size_type num_rows = h_view.extent(0);
147 const size_type num_ensemble = storage_type::static_size;
149 for (size_type i=0; i<num_rows; ++i) {
150 for (size_type k=0; k<num_ensemble; ++k) {
151 TEUCHOS_TEST_EQUALITY(h_view(i).
val().coeff(k), v.val().coeff(k), out, success);
152 for (size_type
j=0;
j<num_fad; ++
j) {
153 TEUCHOS_TEST_EQUALITY(h_view(i).
dx(
j).coeff(k), v.dx(
j).coeff(k), out, success);
161 template <
typename ViewType>
165 Teuchos::FancyOStream& out) {
166 typedef ViewType view_type;
170 typedef typename view_type::size_type size_type;
171 typedef typename view_type::HostMirror host_view_type;
179 const size_type num_ensemble = storage_type::static_size;
180 for (size_type i0=0; i0<h_view.extent(0); ++i0) {
181 for (size_type i1=0; i1<h_view.extent(1); ++i1) {
182 for (size_type i2=0; i2<h_view.extent(2); ++i2) {
183 for (size_type i3=0; i3<h_view.extent(3); ++i3) {
184 for (size_type i4=0; i4<h_view.extent(4); ++i4) {
185 for (size_type i5=0; i5<h_view.extent(5); ++i5) {
186 for (size_type i6=0; i6<h_view.extent(6); ++i6) {
187 for (size_type k=0; k<num_ensemble; ++k)
188 TEUCHOS_TEST_EQUALITY(h_view.access(i0,i1,i2,i3,i4,i5,i6,0).val().coeff(k),
189 v.val().coeff(k), out, success);
190 for (size_type
j=0;
j<num_fad; ++
j) {
191 for (size_type k=0; k<num_ensemble; ++k)
192 TEUCHOS_TEST_EQUALITY(h_view.access(i0,i1,i2,i3,i4,i5,i6,0).dx(
j).coeff(k),
193 v.dx(
j).coeff(k), out, success);
200 template <
typename DataType,
typename LayoutType,
typename ExecutionSpace>
202 typedef Kokkos::View<DataType,LayoutType,ExecutionSpace>
type;
206 template <
typename DataType,
typename ExecutionSpace>
208 typedef Kokkos::View<DataType,ExecutionSpace>
type;
224 typedef typename ViewType::size_type size_type;
228 ViewType v(
"view", num_rows, num_cols);
229 TEUCHOS_TEST_EQUALITY(v.size(), num_rows, out, success);
238 typedef typename ViewType::size_type size_type;
242 ViewType v(
"view", num_rows, num_cols);
243 BaseScalar
val = 1.2345;
259 BaseScalar
val = 1.2345;
266 #define VIEW_FAD_MP_VECTOR_TESTS_SCALAR_LAYOUT( SCALAR, LAYOUT ) \ 267 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \ 268 Kokkos_View_Fad_MP, Size, SCALAR, LAYOUT ) \ 269 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \ 270 Kokkos_View_Fad_MP, DeepCopy_ConstantScalar, SCALAR, LAYOUT ) \ 271 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \ 272 Kokkos_View_Fad_MP, Rank6, SCALAR, LAYOUT ) 274 #define VIEW_FAD_MP_VECTOR_TESTS_SCALAR( SCALAR ) \ 275 using Kokkos::LayoutLeft; \ 276 using Kokkos::LayoutRight; \ 277 VIEW_FAD_MP_VECTOR_TESTS_SCALAR_LAYOUT(SCALAR, NoLayout) \ 278 VIEW_FAD_MP_VECTOR_TESTS_SCALAR_LAYOUT(SCALAR, LayoutLeft) \ 279 VIEW_FAD_MP_VECTOR_TESTS_SCALAR_LAYOUT(SCALAR, LayoutRight) 281 #define VIEW_FAD_MP_VECTOR_TESTS_DEVICE( DEVICE ) \ 282 typedef Stokhos::StaticFixedStorage<int,double,global_ensemble_size,DEVICE> SFS; \ 283 typedef Sacado::MP::Vector< SFS > MP_SFS; \ 284 typedef Sacado::Fad::DFad< MP_SFS > Fad_MP_SFS; \ 285 VIEW_FAD_MP_VECTOR_TESTS_SCALAR( Fad_MP_SFS )
const int global_ensemble_size
Stokhos::StandardStorage< int, double > storage_type
Kokkos::DefaultExecutionSpace execution_space
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_View_Fad_MP, Size, Scalar, Layout)
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< View< T, P... > >::value, unsigned >::type dimension_scalar(const View< T, P... > &view)
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
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
scalar generate_vector_coefficient(const ordinal nFEM, const ordinal nStoch, const ordinal iColFEM, const ordinal iStoch)
Stokhos::CrsMatrix< ValueType, Device, Layout >::HostMirror create_mirror_view(const Stokhos::CrsMatrix< ValueType, Device, Layout > &A)