42 #include "Teuchos_TestingHelpers.hpp" 43 #include "Teuchos_UnitTestHelpers.hpp" 46 #include "Kokkos_View_Fad_Fwd.hpp" 48 #include "Stokhos_Ensemble_Sizes.hpp" 53 #include "Kokkos_Core.hpp" 62 template <
typename scalar,
typename ordinal>
66 const ordinal iColFEM,
67 const ordinal iStoch )
69 const scalar X_fem = 100.0 + scalar(iColFEM) / scalar(nFEM);
70 const scalar X_stoch = 1.0 + scalar(iStoch) / scalar(nStoch);
71 return X_fem + X_stoch;
75 template <
typename ViewType>
78 Teuchos::FancyOStream& out) {
79 typedef ViewType view_type;
80 typedef typename view_type::size_type size_type;
81 typedef typename view_type::HostMirror host_view_type;
82 typedef typename host_view_type::array_type host_array_type;
88 host_array_type h_a = h_v;
90 size_type num_rows, num_cols;
94 bool is_right = std::is_same<
typename ViewType::array_layout,
96 if (is_right || !view_type::is_contiguous) {
97 num_rows = h_a.extent(0);
98 num_cols = h_a.extent(1);
101 num_rows = h_a.extent(1);
102 num_cols = h_a.extent(0);
105 if (is_right || !view_type::is_contiguous) {
106 for (size_type i=0; i<num_rows; ++i) {
107 for (size_type
j=0;
j<num_cols; ++
j) {
110 generate_vector_coefficient<scalar_type>(
111 num_rows, num_cols, i,
j);
112 TEUCHOS_TEST_EQUALITY(
val, val_expected, out, success);
117 for (size_type i=0; i<num_rows; ++i) {
118 for (size_type
j=0;
j<num_cols; ++
j) {
121 generate_vector_coefficient<scalar_type>(
122 num_rows, num_cols, i,
j);
123 TEUCHOS_TEST_EQUALITY(
val, val_expected, out, success);
131 template <
typename ViewType>
135 Teuchos::FancyOStream& out) {
136 typedef ViewType view_type;
140 typedef typename view_type::size_type size_type;
141 typedef typename view_type::HostMirror host_view_type;
147 const size_type num_rows = h_view.extent(0);
149 const size_type num_ensemble = storage_type::static_size;
151 for (size_type i=0; i<num_rows; ++i) {
152 for (size_type k=0; k<num_ensemble; ++k) {
153 TEUCHOS_TEST_EQUALITY(h_view(i).
val().coeff(k), v.val().coeff(k), out, success);
154 for (size_type
j=0;
j<num_fad; ++
j) {
155 TEUCHOS_TEST_EQUALITY(h_view(i).
dx(
j).coeff(k), v.dx(
j).coeff(k), out, success);
163 template <
typename ViewType>
167 Teuchos::FancyOStream& out) {
168 typedef ViewType view_type;
172 typedef typename view_type::size_type size_type;
173 typedef typename view_type::HostMirror host_view_type;
181 const size_type num_ensemble = storage_type::static_size;
182 for (size_type i0=0; i0<h_view.extent(0); ++i0) {
183 for (size_type i1=0; i1<h_view.extent(1); ++i1) {
184 for (size_type i2=0; i2<h_view.extent(2); ++i2) {
185 for (size_type i3=0; i3<h_view.extent(3); ++i3) {
186 for (size_type i4=0; i4<h_view.extent(4); ++i4) {
187 for (size_type i5=0; i5<h_view.extent(5); ++i5) {
188 for (size_type i6=0; i6<h_view.extent(6); ++i6) {
189 for (size_type k=0; k<num_ensemble; ++k)
190 TEUCHOS_TEST_EQUALITY(h_view.access(i0,i1,i2,i3,i4,i5,i6,0).val().coeff(k),
191 v.val().coeff(k), out, success);
192 for (size_type
j=0;
j<num_fad; ++
j) {
193 for (size_type k=0; k<num_ensemble; ++k)
194 TEUCHOS_TEST_EQUALITY(h_view.access(i0,i1,i2,i3,i4,i5,i6,0).dx(
j).coeff(k),
195 v.dx(
j).coeff(k), out, success);
202 template <
typename DataType,
typename LayoutType,
typename ExecutionSpace>
204 typedef Kokkos::View<DataType,LayoutType,ExecutionSpace>
type;
208 template <
typename DataType,
typename ExecutionSpace>
210 typedef Kokkos::View<DataType,ExecutionSpace>
type;
226 typedef typename ViewType::size_type size_type;
230 ViewType v(
"view", num_rows, num_cols);
231 TEUCHOS_TEST_EQUALITY(v.size(), num_rows, out, success);
240 typedef typename ViewType::size_type size_type;
244 ViewType v(
"view", num_rows, num_cols);
245 BaseScalar
val = 1.2345;
261 BaseScalar
val = 1.2345;
268 #define VIEW_FAD_MP_VECTOR_TESTS_SCALAR_LAYOUT( SCALAR, LAYOUT ) \ 269 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \ 270 Kokkos_View_Fad_MP, Size, SCALAR, LAYOUT ) \ 271 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \ 272 Kokkos_View_Fad_MP, DeepCopy_ConstantScalar, SCALAR, LAYOUT ) \ 273 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \ 274 Kokkos_View_Fad_MP, Rank6, SCALAR, LAYOUT ) 276 #define VIEW_FAD_MP_VECTOR_TESTS_SCALAR( SCALAR ) \ 277 using Kokkos::LayoutLeft; \ 278 using Kokkos::LayoutRight; \ 279 VIEW_FAD_MP_VECTOR_TESTS_SCALAR_LAYOUT(SCALAR, NoLayout) \ 280 VIEW_FAD_MP_VECTOR_TESTS_SCALAR_LAYOUT(SCALAR, LayoutLeft) \ 281 VIEW_FAD_MP_VECTOR_TESTS_SCALAR_LAYOUT(SCALAR, LayoutRight) 283 #define VIEW_FAD_MP_VECTOR_TESTS_DEVICE( DEVICE ) \ 284 typedef Stokhos::StaticFixedStorage<int,double,global_ensemble_size,DEVICE> SFS; \ 285 typedef Sacado::MP::Vector< SFS > MP_SFS; \ 286 typedef Sacado::Fad::DFad< MP_SFS > Fad_MP_SFS; \ 287 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)