|
| | LinearInterpolator1D (const Coordinates &coordinates) |
| | Construct a LinearInterpolator1D with internal, zeroed data and a coordinate system.
|
| |
| KOKKOS_DEFAULTED_FUNCTION | LinearInterpolator1D (const LinearInterpolator1D &)=default |
| | Shallow copy of BOTH views, valid in host and in device code.
|
| |
| template<typename NT2 > |
| void | update (const NT2 *in_data) |
| | Replace the data, leaving host AND device current. The only mutator.
|
| |
| NT | operator[] (size_t i) const |
| | Host-side element access. Always valid, including on a copy.
|
| |
| Coordinates::ctype KOKKOS_FUNCTION | index (const typename Coordinates::ctype x) const |
| | Map a physical coordinate onto the grid index.
|
| |
| NT KOKKOS_FUNCTION | at (const typename Coordinates::ctype idx) const |
| | Interpolate at a grid index previously obtained from index().
|
| |
| NT KOKKOS_FUNCTION | operator() (const typename Coordinates::ctype x) const |
| | Interpolate the data at a given point.
|
| |
| const Coordinates & | get_coordinates () const |
| | Get the coordinate system of the data.
|
| |
| const NT * | data () const |
| | Read-only handle to the host values.
|
| |
template<typename NT, typename Coordinates>
class DiFfRG::LinearInterpolator1D< NT, Coordinates >
A linear interpolator for 1D data, callable from host AND device code.
The object owns one device-resident allocation and its host mirror, and update() leaves both current. There is therefore no memory-space template parameter and no lazily built twin in the other space: at() simply reads whichever buffer belongs to the side it is executing on.
That dispatch cannot be an if constexpr. "Am I on the device" is a property of the compilation pass, not of a template argument, and only CUDA_ARCH carries it. Under nvcc with a GNU host compiler KOKKOS_IF_ON_DEVICE/KOKKOS_IF_ON_HOST are a plain preprocessor selection (Kokkos_Macros.hpp; the NV_IF_TARGET spelling there is gated on KOKKOS_COMPILER_NVHPC, which this build does not use), so each pass compiles exactly one body and each pass ends in a return. This is NOT the nvcc extended-lambda if constexpr miscompile documented in quadrature_integrator.hh – that one is about lambda bodies.
If the dispatch is ever wrong the failure is loud rather than silent: View::operator() runs runtime_check_memory_access_violation, which Kokkos::abort()s with "attempt to access
inaccessible memory space". See tests/physics/interpolation/host_device_dispatch.cc.
- Template Parameters
-
| NT | input data type |
| Coordinates | coordinate system of the input data |
template<typename NT , typename Coordinates >
Map a physical coordinate onto the grid index.
Split out for the same reason as in SplineInterpolator1D: for a logarithmic or focused-log axis Coordinates::backward is a fp64 log/log1p costing ~200 fp64 instructions, and a kernel evaluating several dressings at one momentum otherwise pays it once per dressing (the compiler cannot CSE it, since each interpolator owns its own coordinate members).
Depends only on the coordinate system, so the result may be shared across interpolators that share one – stencil resolution and clamping stay in at().
template<typename NT , typename Coordinates >
template<typename NT2 >
Replace the data, leaving host AND device current. The only mutator.
The mirror is filled by a plain host copy rather than a Kokkos::deep_copy. A deep_copy dispatches onto an execution space and would have to be fenced before the H2D below could be enqueued; a memcpy/loop is complete when it returns. That is what leaves exactly one fence in this function.
The trailing fence is NOT optional: it is what lets the caller refill host_data on the next update() without racing an in-flight H2D copy. Dropping it requires double-buffering the host staging array.
The H2D names an execution space instance. The space-less deep_copy brackets EVERY copy in a global Kokkos::fence() that synchronizes all execution space instances of all enabled backends – measured at ~11.4 cudaDeviceSynchronize calls per copy, i.e. ~98k device-wide barriers in a single 425-RHS YangMills solve. This copy only needs to be ordered against the kernels that read it, which share this execution space instance.