core 1.5.0
Shared MPI block decomposition, asynchronous ghost-layer exchange, SDF geometry, load balancing (header-only C++20)
Loading...
Searching...
No Matches
vector_ops.hpp
Go to the documentation of this file.
1// core — the small device (Kokkos) vector primitives the CSR solvers are written in.
2//
3// Lifted verbatim from the AMR tree (peclet/core/amr/momentum.hpp + pcg.hpp, 2026-09-10;
4// QUALITY_PLAN G.2). Plain (unweighted) dot, BiCGStab / CG direction updates, axpy, negate: each is
5// one parallel_for / parallel_reduce over a peclet::core::View<double>. The dot is a device
6// reduction, so its summation order — and therefore the last bits of a Krylov iterate — depends on
7// the backend and thread count; the elementwise updates are bit-exact.
8#ifndef PECLET_CORE_SOLVER_VECTOR_OPS_HPP
9#define PECLET_CORE_SOLVER_VECTOR_OPS_HPP
10
13
14namespace peclet::core::solver {
15
17inline double dotPlain(View<const double> a, View<const double> b, Index n) {
18 double s = 0.0;
19 Kokkos::parallel_reduce(
20 "amr::mom_dot", n, KOKKOS_LAMBDA(const Index i, double& acc) { acc += a(i) * b(i); }, s);
21 return s;
22}
23
27 double omega, Index n) {
28 Kokkos::parallel_for(
29 "amr::mom_pupdate", n,
30 KOKKOS_LAMBDA(const Index i) { p(i) = r(i) + beta * (p(i) - omega * v(i)); });
31}
32
34inline void axpy(View<double> y, double a, View<const double> x, Index n) {
35 Kokkos::parallel_for("amr::pcg_axpy", n, KOKKOS_LAMBDA(const Index i) { y(i) += a * x(i); });
36}
37
39inline void zpby(View<double> p, View<const double> z, double b, Index n) {
40 Kokkos::parallel_for(
41 "amr::pcg_zpby", n, KOKKOS_LAMBDA(const Index i) { p(i) = z(i) + b * p(i); });
42}
43
45inline void negate(View<double> x, Index n) {
46 Kokkos::parallel_for("amr::pcg_negate", n, KOKKOS_LAMBDA(const Index i) { x(i) = -x(i); });
47}
48
49} // namespace peclet::core::solver
50
51#endif // PECLET_CORE_SOLVER_VECTOR_OPS_HPP
void bicgPUpdate(View< double > p, View< const double > r, View< const double > v, double beta, double omega, Index n)
BiCGStab direction update: p = r + β(p − ω v).
double dotPlain(View< const double > a, View< const double > b, Index n)
Plain (unweighted) dot product.
void zpby(View< double > p, View< const double > z, double b, Index n)
p = z + b·p (CG direction update)
void axpy(View< double > y, double a, View< const double > x, Index n)
y += a·x
void negate(View< double > x, Index n)
y = −x (negate in place)
Kokkos::View< T *, MemSpace > View
1D device array.
Definition view.hpp:26
std::int64_t Index
Signed index type for grids and particles (supersedes block_decomposer's long int IndxT).
Definition types.hpp:15