SplineInterpolator1D< NT, Coordinates > Class Template Reference#

DiFfRG: DiFfRG::SplineInterpolator1D< NT, Coordinates > Class Template Reference
DiFfRG
Discretization Framework for functional Renormalization Group flows

A spline interpolator for 1D data, callable from host AND device code. More...

#include <spline_interpolator_1d.hh>

Public Types

using ctype = typename Coordinates::ctype
 
using value_type = NT
 

Public Member Functions

 SplineInterpolator1D (const Coordinates &coordinates)
 Construct a SplineInterpolator1D with internal, zeroed data and a coordinate system.
 
KOKKOS_DEFAULTED_FUNCTION SplineInterpolator1D (const SplineInterpolator1D &)=default
 Shallow copy of ALL views, valid in host and in device code. See LinearInterpolator1D.
 
template<typename NT2 >
void update (const NT2 *in_data, const ctype lower_y1=std::numeric_limits< ctype >::max(), const ctype upper_y1=std::numeric_limits< ctype >::max())
 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.
 
ctype KOKKOS_FUNCTION index (const typename Coordinates::ctype x) const
 Map a physical coordinate onto the (clamped) grid index.
 
NT KOKKOS_FUNCTION at (const ctype raw_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.
 

Static Public Attributes

static constexpr size_t dim = 1
 

Private Types

using ValueViewType = Kokkos::View<NT *, GPU_memory, Kokkos::MemoryTraits<Kokkos::RandomAccess>>
 
using CoeffViewType = ValueViewType
 
using HostValueViewType = typename ValueViewType::host_mirror_type
 
using HostCoeffViewType = typename CoeffViewType::host_mirror_type
 

Private Member Functions

KOKKOS_FORCEINLINE_FUNCTION NT value (const size_t i) const
 Read one value from whichever buffer belongs to the executing side.
 
KOKKOS_FORCEINLINE_FUNCTION NT coeff (const size_t i) const
 Read one spline coefficient from whichever buffer belongs to the executing side.
 
void build_y2 (const ctype lower_y1, const ctype upper_y1)
 

Private Attributes

const Coordinates coordinates
 
const size_t size
 
ValueViewType device_values
 
CoeffViewType device_coeffs
 
HostValueViewType host_values
 
HostCoeffViewType host_coeffs
 

Static Private Attributes

static constexpr bool has_separate_device
 

Detailed Description

template<typename NT, typename Coordinates>
class DiFfRG::SplineInterpolator1D< NT, Coordinates >

A spline interpolator for 1D data, callable from host AND device code.

See LinearInterpolator1D for the host/device dispatch rationale.

Template Parameters
NTinput data type
Coordinatescoordinate system of the input data

Member Typedef Documentation

◆ CoeffViewType

template<typename NT , typename Coordinates >
using DiFfRG::SplineInterpolator1D< NT, Coordinates >::CoeffViewType = ValueViewType
private

◆ ctype

template<typename NT , typename Coordinates >
using DiFfRG::SplineInterpolator1D< NT, Coordinates >::ctype = typename Coordinates::ctype

◆ HostCoeffViewType

template<typename NT , typename Coordinates >
using DiFfRG::SplineInterpolator1D< NT, Coordinates >::HostCoeffViewType = typename CoeffViewType::host_mirror_type
private

◆ HostValueViewType

template<typename NT , typename Coordinates >
using DiFfRG::SplineInterpolator1D< NT, Coordinates >::HostValueViewType = typename ValueViewType::host_mirror_type
private

◆ value_type

template<typename NT , typename Coordinates >
using DiFfRG::SplineInterpolator1D< NT, Coordinates >::value_type = NT

◆ ValueViewType

template<typename NT , typename Coordinates >
using DiFfRG::SplineInterpolator1D< NT, Coordinates >::ValueViewType = Kokkos::View<NT *, GPU_memory, Kokkos::MemoryTraits<Kokkos::RandomAccess>>
private

Constructor & Destructor Documentation

◆ SplineInterpolator1D() [1/2]

template<typename NT , typename Coordinates >
DiFfRG::SplineInterpolator1D< NT, Coordinates >::SplineInterpolator1D ( const Coordinates & coordinates)
inline

Construct a SplineInterpolator1D with internal, zeroed data and a coordinate system.

Parameters
coordinatescoordinate system of the data

◆ SplineInterpolator1D() [2/2]

template<typename NT , typename Coordinates >
KOKKOS_DEFAULTED_FUNCTION DiFfRG::SplineInterpolator1D< NT, Coordinates >::SplineInterpolator1D ( const SplineInterpolator1D< NT, Coordinates > & )
default

Shallow copy of ALL views, valid in host and in device code. See LinearInterpolator1D.

Member Function Documentation

◆ at()

template<typename NT , typename Coordinates >
NT KOKKOS_FUNCTION DiFfRG::SplineInterpolator1D< NT, Coordinates >::at ( const ctype raw_idx) const
inline

Interpolate at a grid index previously obtained from index().

Clamping lives here, not in index(), so that index() depends ONLY on the coordinate system. That is exactly the precondition under which a caller may share one index across several interpolators; folding a size-dependent clamp into it would silently break sharing between interpolators of different length.

◆ build_y2()

template<typename NT , typename Coordinates >
void DiFfRG::SplineInterpolator1D< NT, Coordinates >::build_y2 ( const ctype lower_y1,
const ctype upper_y1 )
inlineprivate

◆ coeff()

template<typename NT , typename Coordinates >
KOKKOS_FORCEINLINE_FUNCTION NT DiFfRG::SplineInterpolator1D< NT, Coordinates >::coeff ( const size_t i) const
inlineprivate

Read one spline coefficient from whichever buffer belongs to the executing side.

◆ data()

template<typename NT , typename Coordinates >
const NT * DiFfRG::SplineInterpolator1D< NT, Coordinates >::data ( ) const
inline

Read-only handle to the host values.

Deliberately const: a host-side write would leave both the device buffers and the spline coefficients stale, and there is no public way to push it. Route mutations through update().

◆ get_coordinates()

template<typename NT , typename Coordinates >
const Coordinates & DiFfRG::SplineInterpolator1D< NT, Coordinates >::get_coordinates ( ) const
inline

Get the coordinate system of the data.

Returns
const Coordinates& the coordinate system

◆ index()

template<typename NT , typename Coordinates >
ctype KOKKOS_FUNCTION DiFfRG::SplineInterpolator1D< NT, Coordinates >::index ( const typename Coordinates::ctype x) const
inline

Map a physical coordinate onto the (clamped) grid index.

Split out of operator() because it is the expensive half: for a logarithmic axis Coordinates::backward is a fp64 log1p, which costs ~200 fp64 instructions on current NVIDIA parts, against ~10 for the spline evaluation itself. A generated kernel that evaluates many dressings at the SAME momentum pays that log1p once per dressing, because each interpolator owns its own coordinates members and the compiler cannot prove they are equal across objects – so it cannot CSE the transform. Hoisting index() lets the caller pay it once.

The returned index is only meaningful for interpolators sharing this coordinate system.

◆ operator()()

template<typename NT , typename Coordinates >
NT KOKKOS_FUNCTION DiFfRG::SplineInterpolator1D< NT, Coordinates >::operator() ( const typename Coordinates::ctype x) const
inline

Interpolate the data at a given point.

Parameters
xthe point at which to interpolate
Returns
NT the interpolated value

◆ operator[]()

template<typename NT , typename Coordinates >
NT DiFfRG::SplineInterpolator1D< NT, Coordinates >::operator[] ( size_t i) const
inline

Host-side element access. Always valid, including on a copy.

◆ update()

template<typename NT , typename Coordinates >
template<typename NT2 >
void DiFfRG::SplineInterpolator1D< NT, Coordinates >::update ( const NT2 * in_data,
const ctype lower_y1 = std::numeric_limits<ctype>::max(),
const ctype upper_y1 = std::numeric_limits<ctype>::max() )
inline

Replace the data, leaving host AND device current. The only mutator.

See LinearInterpolator1D::update() for why the host fill is a plain copy and why the single trailing fence is not optional.

◆ value()

template<typename NT , typename Coordinates >
KOKKOS_FORCEINLINE_FUNCTION NT DiFfRG::SplineInterpolator1D< NT, Coordinates >::value ( const size_t i) const
inlineprivate

Read one value from whichever buffer belongs to the executing side.

Member Data Documentation

◆ coordinates

template<typename NT , typename Coordinates >
const Coordinates DiFfRG::SplineInterpolator1D< NT, Coordinates >::coordinates
private

◆ device_coeffs

template<typename NT , typename Coordinates >
CoeffViewType DiFfRG::SplineInterpolator1D< NT, Coordinates >::device_coeffs
private

◆ device_values

template<typename NT , typename Coordinates >
ValueViewType DiFfRG::SplineInterpolator1D< NT, Coordinates >::device_values
private

◆ dim

template<typename NT , typename Coordinates >
size_t DiFfRG::SplineInterpolator1D< NT, Coordinates >::dim = 1
staticconstexpr

◆ has_separate_device

template<typename NT , typename Coordinates >
bool DiFfRG::SplineInterpolator1D< NT, Coordinates >::has_separate_device
staticconstexprprivate
Initial value:
=
!std::is_same_v<typename ValueViewType::memory_space, typename HostValueViewType::memory_space>

◆ host_coeffs

template<typename NT , typename Coordinates >
HostCoeffViewType DiFfRG::SplineInterpolator1D< NT, Coordinates >::host_coeffs
private

◆ host_values

template<typename NT , typename Coordinates >
HostValueViewType DiFfRG::SplineInterpolator1D< NT, Coordinates >::host_values
private

◆ size

template<typename NT , typename Coordinates >
const size_t DiFfRG::SplineInterpolator1D< NT, Coordinates >::size
private

The documentation for this class was generated from the following file: