SplineInterpolator1DStack< NT, Coordinates > Class Template Reference#

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

A stack of 1D splines, callable from host AND device code. More...

#include <spline_interpolator_1d_stack.hh>

Public Types

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

Public Member Functions

 SplineInterpolator1DStack (const Coordinates &coordinates)
 Construct a SplineInterpolator1DStack with zeroed data and a coordinate system.
 
KOKKOS_DEFAULTED_FUNCTION SplineInterpolator1DStack (const SplineInterpolator1DStack &)=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, in the row-major order update() takes its input in.
 
device::array< typename Coordinates::ctype, 2 > KOKKOS_FUNCTION index (const typename Coordinates::ctype s, const typename Coordinates::ctype x) const
 Map physical coordinates onto grid indices.
 
NT KOKKOS_FUNCTION at (const device::array< typename Coordinates::ctype, 2 > &raw) const
 Interpolate at grid indices previously obtained from index().
 
NT KOKKOS_FUNCTION operator() (const typename Coordinates::ctype s, 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, in the mirror's storage order.
 

Static Public Attributes

static constexpr size_t dim = 2
 

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 size_t j) const
 Read one value from whichever buffer belongs to the executing side.
 
KOKKOS_FORCEINLINE_FUNCTION NT coeff (const size_t i, const size_t j) const
 Read one spline coefficient from whichever buffer belongs to the executing side.
 
void build_y2 (const size_t sidx, const ctype lower_y1, const ctype upper_y1)
 

Private Attributes

const Coordinates coordinates
 
const device::array< size_t, 2 > sizes
 
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::SplineInterpolator1DStack< NT, Coordinates >

A stack of 1D splines, callable from host AND device code.

Nearest-neighbour in the stack axis, spline in the data axis. 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::SplineInterpolator1DStack< NT, Coordinates >::CoeffViewType = ValueViewType
private

◆ ctype

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

◆ HostCoeffViewType

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

◆ HostValueViewType

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

◆ value_type

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

◆ ValueViewType

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

Constructor & Destructor Documentation

◆ SplineInterpolator1DStack() [1/2]

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

Construct a SplineInterpolator1DStack with zeroed data and a coordinate system.

Parameters
coordinatescoordinate system of the data

◆ SplineInterpolator1DStack() [2/2]

template<typename NT , typename Coordinates >
KOKKOS_DEFAULTED_FUNCTION DiFfRG::SplineInterpolator1DStack< NT, Coordinates >::SplineInterpolator1DStack ( const SplineInterpolator1DStack< 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::SplineInterpolator1DStack< NT, Coordinates >::at ( const device::array< typename Coordinates::ctype, 2 > & raw) const
inline

Interpolate at grid indices previously obtained from index().

◆ build_y2()

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

◆ coeff()

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

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

◆ data()

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

Read-only handle to the host values, in the mirror's storage order.

NOTE the storage order is NOT the row-major order update() takes: the device view is pinned to GPU_memory, hence LayoutLeft. Use operator[] for row-major access.

◆ get_coordinates()

template<typename NT , typename Coordinates >
const Coordinates & DiFfRG::SplineInterpolator1DStack< 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 >
device::array< typename Coordinates::ctype, 2 > KOKKOS_FUNCTION DiFfRG::SplineInterpolator1DStack< NT, Coordinates >::index ( const typename Coordinates::ctype s,
const typename Coordinates::ctype x ) const
inline

Map physical coordinates onto grid indices.

Split out of operator() because it is the expensive half: Coordinates::backward is a fp64 log/log1p per logarithmic axis, ~200 fp64 instructions each on current NVIDIA parts against ~10 for the interpolation. A generated kernel evaluating several dressings at the SAME point otherwise pays it once per dressing – the compiler cannot CSE it, because each interpolator owns its own coordinates members and cannot be proven to agree with another's.

Depends only on the coordinate system, so the result may be shared across interpolators that share one. Clamping and stencil resolution stay in at(), since they are size dependent and would otherwise make an index untransferable between interpolators of different extent.

The return type is spelled out rather than deduced: nvcc loses decltype(var) when the initializer has a deduced return type inside a class-template member, and the consumer stores this in a const auto.

◆ operator()()

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

Interpolate the data at a given point.

◆ operator[]()

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

Host-side element access, in the row-major order update() takes its input in.

◆ update()

template<typename NT , typename Coordinates >
template<typename NT2 >
void DiFfRG::SplineInterpolator1DStack< 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.

in_data is row-major; the fill indexes the mirror through operator(), which keeps that contract independent of the mirror's own layout. See LinearInterpolator1D::update() for why the host fill is a plain loop and why the single trailing fence is not optional.

◆ value()

template<typename NT , typename Coordinates >
KOKKOS_FORCEINLINE_FUNCTION NT DiFfRG::SplineInterpolator1DStack< NT, Coordinates >::value ( const size_t i,
const size_t j ) 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::SplineInterpolator1DStack< NT, Coordinates >::coordinates
private

◆ device_coeffs

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

◆ device_values

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

◆ dim

template<typename NT , typename Coordinates >
size_t DiFfRG::SplineInterpolator1DStack< NT, Coordinates >::dim = 2
staticconstexpr

◆ has_separate_device

template<typename NT , typename Coordinates >
bool DiFfRG::SplineInterpolator1DStack< 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::SplineInterpolator1DStack< NT, Coordinates >::host_coeffs
private

◆ host_values

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

◆ sizes

template<typename NT , typename Coordinates >
const device::array<size_t, 2> DiFfRG::SplineInterpolator1DStack< NT, Coordinates >::sizes
private

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