37 const auto a = make_vector<Vec>(info.ax, info.ay, info.az);
38 const auto b = make_vector<Vec>(info.bx, info.by, info.bz);
39 const auto c = make_vector<Vec>(info.cx, info.cy, info.cz);
43 auto d_a = libMesh::Kokkos::upload_vector_storage<StoragePolicy>(std::vector<Vec>{a},
"vector_ops_a");
44 auto d_b = libMesh::Kokkos::upload_vector_storage<StoragePolicy>(std::vector<Vec>{
b},
"vector_ops_b");
45 auto d_c = libMesh::Kokkos::upload_vector_storage<StoragePolicy>(std::vector<Vec>{c},
"vector_ops_c");
46 auto d_vectors = libMesh::Kokkos::make_vector_storage<StoragePolicy>(
"vector_ops_vectors",
vector_results);
47 ::Kokkos::View<double *> d_scalars(
"vector_ops_scalars",
scalar_results);
49 ::Kokkos::parallel_for(
56 const Vec copied = libMesh::Kokkos::copy_vector<Vec>(a_ref);
57 const Vec mix = a_ref + b_ref - c_ref;
58 const Vec scaled = Real(1.25) * a_ref + Real(-0.5) * b_ref + Real(0.25) * c_ref;
59 const Vec plus_assign = a_ref + b_ref;
60 const Vec minus_assign = a_ref - b_ref;
61 const Vec accum = Real(1.25) * a_ref + Real(-0.5) * b_ref + Real(0.25) * c_ref;
62 const Vec divided = a_ref / Real(5.0);
63 const Vec outer_right = Real(5.0) * a_ref;
64 const Vec outer_left = a_ref * Real(5.0);
65 const Vec mult_assign = a_ref * Real(5.0);
66 const Vec div_assign = a_ref / Real(5.0);
69 const Real contract = a_ref.contract(b_ref);
70 const Real norm = mix.norm();
71 const Real norm_sq = mix.norm_sq();
73 const Vec assign_zero = zero;
75 unsigned int vector_offset = 0;
88 unsigned int scalar_offset = 0;
89 d_scalars(scalar_offset++) = a_ref * b_ref;
90 d_scalars(scalar_offset++) = dot;
91 d_scalars(scalar_offset++) = contract;
92 d_scalars(scalar_offset++) = norm;
93 d_scalars(scalar_offset++) = norm_sq;
94 d_scalars(scalar_offset++) = zero.is_zero() ? 1.0 : 0.0;
95 d_scalars(scalar_offset++) = mix.is_zero() ? 1.0 : 0.0;
96 d_scalars(scalar_offset++) = (a_ref == a_ref) ? 1.0 : 0.0;
97 d_scalars(scalar_offset++) = (a_ref == b_ref) ? 1.0 : 0.0;
98 d_scalars(scalar_offset++) = (a_ref != a_ref) ? 1.0 : 0.0;
99 d_scalars(scalar_offset++) = (a_ref != b_ref) ? 1.0 : 0.0;
100 d_scalars(scalar_offset++) = assign_zero.is_zero() ? 1.0 : 0.0;
102 const Vec xvec = make_vector<Vec>(1.3);
106 const Vec yvec = make_vector<Vec>(0.0, 2.7);
107 const Vec xydiag = make_vector<Vec>(3.1, 3.1);
113 const Vec xypdiag = make_vector<Vec>(0.8, -0.8);
114 const Vec zvec = make_vector<Vec>(0.0, 0.0, 1.1);
115 const Vec xzdiag = make_vector<Vec>(0.0, 0.7, 0.7);
116 const Vec icosa1 = make_vector<Vec>(1.0,
golden_ratio, 0.0);
117 const Vec icosa2 = make_vector<Vec>(-1.0,
golden_ratio, 0.0);
118 const Vec icosa3 = make_vector<Vec>(0.0, 1.0,
golden_ratio);
126 const Vec cross = a_ref.cross(b_ref);
127 Vec unit_cross = cross;
129 unit_cross = libMesh::Kokkos::vector_unit<Vec>(cross);
211 const auto a = make_vector<Vec>(2.0, 3.0, 4.0);
212 const auto b = make_vector<Vec>(5.0, -6.0, 7.0);
213 const auto c = make_vector<Vec>(1.25, -0.5, 2.0);
215 auto d_a = libMesh::Kokkos::upload_vector_storage<StoragePolicy>(std::vector<Vec>{a},
"mixed_vector_a");
216 auto d_b = libMesh::Kokkos::upload_vector_storage<StoragePolicy>(std::vector<Vec>{
b},
"mixed_vector_b");
219 libMesh::Kokkos::make_vector_storage<StoragePolicy>(
"mixed_vector_vectors", (LIBMESH_DIM > 2) ? 5 : 3);
220 ::Kokkos::View<double *> d_scalars(
"mixed_vector_scalars", (LIBMESH_DIM > 2) ? 7 : 5);
222 const auto ref_sum = a +
b;
223 const auto ref_diff = a -
b;
224 const auto ref_scaled = 1.5 * a;
225 const auto ref_dot = a *
b;
226 const auto ref_contract = a.contract(
b);
227 const auto ref_solid_angle =
232 const auto ref_cross = a.cross(
b);
233 auto ref_unit_cross = ref_cross;
235 ref_unit_cross = ref_cross.unit();
238 ::Kokkos::parallel_for(
244 const auto sum = a_ref +
b;
245 const auto diff = a - b_ref;
246 const auto scaled = Real(1.5) * a_ref;
252 d_scalars(0) = a_ref *
b;
253 d_scalars(1) = b_ref.contract(a);
254 d_scalars(2) = (a_ref == a) ? 1.0 : 0.0;
255 d_scalars(3) = (a_ref !=
b) ? 1.0 : 0.0;
259 const auto cross = a_ref.cross(
b);
260 Vec unit_cross = cross;
262 unit_cross = libMesh::Kokkos::vector_unit<Vec>(cross);
267 d_scalars(6) = (cross == libMesh::Kokkos::vector_cross<Vec>(a, b_ref)) ? 1.0 : 0.0;
275 std::vector<Vec> ref = {ref_sum, ref_diff, ref_scaled};
277 ref.push_back(ref_cross);
278 ref.push_back(ref_unit_cross);
287 std::vector<Real> ref = {ref_dot, ref_contract, 1.0, 1.0, ref_solid_angle};
289 ref.push_back(ref_cross_norm_sq);
308 total_fail += run_vector_cases<libMesh::Kokkos::layout_left_storage_policy, libMesh::TypeVector<Real>>(
309 "typevector_kernel_oracle");
310 total_fail += run_vector_cases<libMesh::Kokkos::layout_right_storage_policy, libMesh::TypeVector<Real>>(
311 "typevector_kernel_oracle");
312 total_fail += run_vector_cases<libMesh::Kokkos::layout_left_storage_policy, libMesh::VectorValue<Real>>(
313 "vectorvalue_kernel_oracle");
314 total_fail += run_vector_cases<libMesh::Kokkos::layout_right_storage_policy, libMesh::VectorValue<Real>>(
315 "vectorvalue_kernel_oracle");
317 const int mixed_typevector_left =
318 test_mixed_representation_ops<libMesh::Kokkos::layout_left_storage_policy, libMesh::TypeVector<Real>>();
319 std::printf(
"[vector_mixed_representation_oracle] [%s] [typevector] %s (%d failures)\n",
320 libMesh::Kokkos::storage_policy_name<libMesh::Kokkos::layout_left_storage_policy>(),
321 mixed_typevector_left ?
"FAIL" :
"PASS",
322 mixed_typevector_left);
323 total_fail += mixed_typevector_left;
325 const int mixed_typevector_right =
326 test_mixed_representation_ops<libMesh::Kokkos::layout_right_storage_policy, libMesh::TypeVector<Real>>();
327 std::printf(
"[vector_mixed_representation_oracle] [%s] [typevector] %s (%d failures)\n",
328 libMesh::Kokkos::storage_policy_name<libMesh::Kokkos::layout_right_storage_policy>(),
329 mixed_typevector_right ?
"FAIL" :
"PASS",
330 mixed_typevector_right);
331 total_fail += mixed_typevector_right;
333 const int mixed_vectorvalue_left =
334 test_mixed_representation_ops<libMesh::Kokkos::layout_left_storage_policy, libMesh::VectorValue<Real>>();
335 std::printf(
"[vector_mixed_representation_oracle] [%s] [vectorvalue] %s (%d failures)\n",
336 libMesh::Kokkos::storage_policy_name<libMesh::Kokkos::layout_left_storage_policy>(),
337 mixed_vectorvalue_left ?
"FAIL" :
"PASS",
338 mixed_vectorvalue_left);
339 total_fail += mixed_vectorvalue_left;
341 const int mixed_vectorvalue_right =
342 test_mixed_representation_ops<libMesh::Kokkos::layout_right_storage_policy, libMesh::VectorValue<Real>>();
343 std::printf(
"[vector_mixed_representation_oracle] [%s] [vectorvalue] %s (%d failures)\n",
344 libMesh::Kokkos::storage_policy_name<libMesh::Kokkos::layout_right_storage_policy>(),
345 mixed_vectorvalue_right ?
"FAIL" :
"PASS",
346 mixed_vectorvalue_right);
347 total_fail += mixed_vectorvalue_right;
350 std::printf(
"[vector_host_traits_oracle] %s (%d failures)\n",
351 host_fail ?
"FAIL" :
"PASS",
353 total_fail += host_fail;