libMesh
Loading...
Searching...
No Matches
Functions
libMeshTest::KokkosOracle Namespace Reference

Functions

template<typename T >
inline ::Kokkos::View< T * > upload_objects (const std::vector< T > &values, const char *label)
 
int compare_device_scalars (const ::Kokkos::View< double * > &d_values, const std::vector< Real > &ref_values, const double tol)
 
template<typename ViewType , typename VectorType >
int compare_device_vectors (const ViewType &d_values, const std::vector< VectorType > &ref_values, const double tol)
 
template<typename ViewType , typename TensorType >
int compare_device_tensors (const ViewType &d_values, const std::vector< TensorType > &ref_values, const double tol)
 

Function Documentation

◆ compare_device_scalars()

int libMeshTest::KokkosOracle::compare_device_scalars ( const ::Kokkos::View< double * > &  d_values,
const std::vector< Real > &  ref_values,
const double  tol 
)
inline

Definition at line 53 of file kokkos_numerics_oracle_test_utils.h.

56{
57 auto h_values = ::Kokkos::create_mirror_view(d_values);
58 ::Kokkos::deep_copy(h_values, d_values);
59
60 int fail = 0;
61 for (std::size_t i = 0; i < ref_values.size(); ++i)
62 if (std::fabs(h_values(i) - ref_values[i]) > tol)
63 ++fail;
64
65 return fail;
66}

Referenced by libMeshTest::KokkosTensorOracle::test_dim_ops(), libMeshTest::KokkosTensorOracle::test_mixed_representation_ops(), libMeshTest::KokkosVectorOracle::test_mixed_representation_ops(), libMeshTest::KokkosTensorOracle::test_tensor_ops(), and libMeshTest::KokkosVectorOracle::test_vector_ops_case().

◆ compare_device_tensors()

template<typename ViewType , typename TensorType >
int libMeshTest::KokkosOracle::compare_device_tensors ( const ViewType &  d_values,
const std::vector< TensorType > &  ref_values,
const double  tol 
)
inline

Definition at line 88 of file kokkos_numerics_oracle_test_utils.h.

91{
92 auto h_values = ::Kokkos::create_mirror_view(d_values);
93 ::Kokkos::deep_copy(h_values, d_values);
94
95 int fail = 0;
96 for (std::size_t i = 0; i < ref_values.size(); ++i)
97 for (unsigned int row = 0; row < LIBMESH_DIM; ++row)
98 for (unsigned int col = 0; col < LIBMESH_DIM; ++col)
99 if (std::fabs(h_values(i, row, col) - ref_values[i](row, col)) > tol)
100 ++fail;
101
102 return fail;
103}

Referenced by libMeshTest::KokkosTensorOracle::test_dim_ops(), libMeshTest::KokkosTensorOracle::test_mixed_representation_ops(), and libMeshTest::KokkosTensorOracle::test_tensor_ops().

◆ compare_device_vectors()

template<typename ViewType , typename VectorType >
int libMeshTest::KokkosOracle::compare_device_vectors ( const ViewType &  d_values,
const std::vector< VectorType > &  ref_values,
const double  tol 
)
inline

Definition at line 70 of file kokkos_numerics_oracle_test_utils.h.

73{
74 auto h_values = ::Kokkos::create_mirror_view(d_values);
75 ::Kokkos::deep_copy(h_values, d_values);
76
77 int fail = 0;
78 for (std::size_t i = 0; i < ref_values.size(); ++i)
79 for (unsigned int d = 0; d < LIBMESH_DIM; ++d)
80 if (std::fabs(h_values(i, d) - ref_values[i](d)) > tol)
81 ++fail;
82
83 return fail;
84}

Referenced by libMeshTest::KokkosTensorOracle::test_mixed_representation_ops(), libMeshTest::KokkosVectorOracle::test_mixed_representation_ops(), libMeshTest::KokkosTensorOracle::test_tensor_ops(), and libMeshTest::KokkosVectorOracle::test_vector_ops_case().

◆ upload_objects()

template<typename T >
inline ::Kokkos::View< T * > libMeshTest::KokkosOracle::upload_objects ( const std::vector< T > &  values,
const char *  label 
)

Definition at line 36 of file kokkos_numerics_oracle_test_utils.h.

37{
38 ::Kokkos::View<T *> d(std::string(label), values.size());
39 auto h = ::Kokkos::create_mirror_view(d);
40 for (std::size_t i = 0; i < values.size(); ++i)
41 h(i) = values[i];
42 ::Kokkos::deep_copy(d, h);
43 return d;
44}

Referenced by libMeshTest::KokkosTensorOracle::test_dim_ops().