include/pops/mesh/execution/for_each.hpp File ReferenceΒΆ
|
adc_cpp 0.3.0
Model-free C++23 core for coupled hyperbolic-elliptic systems on adaptive (AMR) meshes, with MPI and GPU (Kokkos) backends
|
for_each_cell and reductions: the parallelism SEAM over the cells of a Box2D; sync_host / sync_device: the residency COHERENCE seam (counterpart for host accesses). More...
#include <pops/core/foundation/kokkos_env.hpp>#include <pops/core/foundation/types.hpp>#include <pops/mesh/index/box2d.hpp>#include <cstdint>#include <cstdlib>#include <type_traits>#include <Kokkos_Core.hpp>
Include dependency graph for for_each.hpp:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Namespaces | |
| namespace | pops |
| namespace | pops::detail |
Functions | |
| std::int64_t | pops::detail::foreach_serial_threshold () |
| void | pops::sync_host () |
| Makes the HOST residency valid before a host access (read/write from the host). | |
| void | pops::sync_device () |
| Marks a DEVICE residency (upcoming kernel). | |
| template<class F > | |
| void | pops::for_each_cell (const Box2D &b, F f) |
Applies f to EACH cell (i, j) of box b (bounds inclusive), via Kokkos::parallel_for (Serial / OpenMP / Cuda depending on the Kokkos install). | |
| template<class F > | |
| Real | pops::for_each_cell_reduce_sum (const Box2D &b, F f) |
SUM reduction of f(i, j) over box b. | |
| template<class F > | |
| Real | pops::for_each_cell_reduce_max (const Box2D &b, F f) |
MAX reduction of f(i, j) over box b. | |
| template<class F > | |
| Real | pops::reduce_max_cell (const Box2D &b, F f) |
MAX reduction with a REDUCING FUNCTOR: f receives (i, j, Real& acc) and updates acc, passed DIRECTLY to Kokkos::parallel_reduce without a wrapper lambda (device-clean path for a kernel instantiated cross-TU). | |
| template<class F > | |
| Real | pops::reduce_min_cell (const Box2D &b, F f) |
| template<class F > | |
| Real | pops::reduce_sum_cell (const Box2D &b, F f) |
SUM reduction with a REDUCING FUNCTOR: f receives (i, j, Real& acc) and accumulates, passed DIRECTLY to Kokkos::parallel_reduce without a wrapper lambda (device-clean cross-TU path). | |
Detailed Description
for_each_cell and reductions: the parallelism SEAM over the cells of a Box2D; sync_host / sync_device: the residency COHERENCE seam (counterpart for host accesses).
KOKKOS IS THE ONLY on-node backend: this seam compiles ONLY under POPS_HAS_KOKKOS (cf. CMake, which makes Kokkos mandatory; without it, #error below). The functor is taken BY VALUE and receives (i, j); it captures Array4 handles by value (POD), never the Fab nor anything virtual: exactly the constraint of a device kernel. The on-node target (sequential = Kokkos Serial, CPU multi-thread = Kokkos OpenMP, GPU = Kokkos Cuda/HIP) is chosen AT KOKKOS INSTALLATION, not by an pops flag: a single for_each_cell call (Kokkos::parallel_for over MDRangePolicy<Rank<2>>) covers all three. The CPU -> GPU switch therefore does NOT change the call sites. FP CHOICE: the SUM reduction (Kokkos::Sum) reassociates the addition per tile -> DETERMINISTIC per tile (idempotent: same data, same backend -> same bits) but NOT bit-identical to a lexicographic sum; this holds for Serial, OpenMP and Cuda (a single path, Kokkos). The MAX reduction is exact everywhere (max associative/commutative in IEEE754). sync_host() = a targeted device_fence() before a host access; sync_device() = no-op under unified memory (scaffolding for a future non-unified path).
Generated by