LinearInterpolator3D< NT, Coordinates > Class Template Reference#

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

A linear interpolator for 3D data, callable from host AND device code. More...

#include <linear_interpolator_3d.hh>

Public Types

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

Public Member Functions

 LinearInterpolator3D (const Coordinates &coordinates)
 Construct a LinearInterpolator3D with internal, zeroed data and a coordinate system.
 
KOKKOS_DEFAULTED_FUNCTION LinearInterpolator3D (const LinearInterpolator3D &)=default
 Shallow copy of BOTH views, valid in host and in device code. See LinearInterpolator1D.
 
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, in the row-major order update() takes its input in.
 
device::array< ctype, 3 > KOKKOS_FUNCTION index (const ctype &x, const ctype &y, const ctype &z) const
 Map physical coordinates onto grid indices.
 
NT KOKKOS_FUNCTION at (const device::array< ctype, 3 > &idx) const
 Interpolate at grid indices previously obtained from index().
 
NT KOKKOS_FUNCTION operator() (const ctype &x, const ctype &y, const ctype &z) 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 = 3
 

Private Types

using ViewType = Kokkos::View<NT ***, GPU_memory, Kokkos::MemoryTraits<Kokkos::RandomAccess>>
 
using HostViewType = typename ViewType::host_mirror_type
 

Private Member Functions

KOKKOS_FORCEINLINE_FUNCTION NT value (const size_t i, const size_t j, const size_t k) const
 Read one element from whichever buffer belongs to the executing side.
 

Private Attributes

const Coordinates coordinates
 
const device::array< size_t, 3 > sizes
 
ViewType device_data
 
HostViewType host_data
 

Static Private Attributes

static constexpr bool periodic_x = is_periodic_axis_v<Coordinates, 0>
 
static constexpr bool periodic_y = is_periodic_axis_v<Coordinates, 1>
 
static constexpr bool periodic_z = is_periodic_axis_v<Coordinates, 2>
 
static constexpr bool has_separate_device
 

Detailed Description

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

A linear interpolator for 3D 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

◆ ctype

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

◆ HostViewType

template<typename NT , typename Coordinates >
using DiFfRG::LinearInterpolator3D< NT, Coordinates >::HostViewType = typename ViewType::host_mirror_type
private

◆ value_type

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

◆ ViewType

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

Constructor & Destructor Documentation

◆ LinearInterpolator3D() [1/2]

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

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

Parameters
coordinatescoordinate system of the data

◆ LinearInterpolator3D() [2/2]

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

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

Member Function Documentation

◆ at()

template<typename NT , typename Coordinates >
NT KOKKOS_FUNCTION DiFfRG::LinearInterpolator3D< NT, Coordinates >::at ( const device::array< ctype, 3 > & idx) const
inline

Interpolate at grid indices previously obtained from index().

◆ data()

template<typename NT , typename Coordinates >
const NT * DiFfRG::LinearInterpolator3D< 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; see LinearInterpolator2D.

◆ get_coordinates()

template<typename NT , typename Coordinates >
const Coordinates & DiFfRG::LinearInterpolator3D< 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< ctype, 3 > KOKKOS_FUNCTION DiFfRG::LinearInterpolator3D< NT, Coordinates >::index ( const ctype & x,
const ctype & y,
const ctype & z ) 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::LinearInterpolator3D< NT, Coordinates >::operator() ( const ctype & x,
const ctype & y,
const ctype & z ) const
inline

Interpolate the data at a given point.

◆ operator[]()

template<typename NT , typename Coordinates >
NT DiFfRG::LinearInterpolator3D< 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::LinearInterpolator3D< NT, Coordinates >::update ( const NT2 * in_data)
inline

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

in_data is row-major; see LinearInterpolator2D::update() for why the fill indexes the mirror through operator() instead of copying flat, and LinearInterpolator1D::update() for why the single trailing fence is not optional.

◆ value()

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

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

Member Data Documentation

◆ coordinates

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

◆ device_data

template<typename NT , typename Coordinates >
ViewType DiFfRG::LinearInterpolator3D< NT, Coordinates >::device_data
private

◆ dim

template<typename NT , typename Coordinates >
size_t DiFfRG::LinearInterpolator3D< NT, Coordinates >::dim = 3
staticconstexpr

◆ has_separate_device

template<typename NT , typename Coordinates >
bool DiFfRG::LinearInterpolator3D< NT, Coordinates >::has_separate_device
staticconstexprprivate
Initial value:
=
!std::is_same_v<typename ViewType::memory_space, typename HostViewType::memory_space>

◆ host_data

template<typename NT , typename Coordinates >
HostViewType DiFfRG::LinearInterpolator3D< NT, Coordinates >::host_data
private

◆ periodic_x

template<typename NT , typename Coordinates >
bool DiFfRG::LinearInterpolator3D< NT, Coordinates >::periodic_x = is_periodic_axis_v<Coordinates, 0>
staticconstexprprivate

◆ periodic_y

template<typename NT , typename Coordinates >
bool DiFfRG::LinearInterpolator3D< NT, Coordinates >::periodic_y = is_periodic_axis_v<Coordinates, 1>
staticconstexprprivate

◆ periodic_z

template<typename NT , typename Coordinates >
bool DiFfRG::LinearInterpolator3D< NT, Coordinates >::periodic_z = is_periodic_axis_v<Coordinates, 2>
staticconstexprprivate

◆ sizes

template<typename NT , typename Coordinates >
const device::array<size_t, 3> DiFfRG::LinearInterpolator3D< NT, Coordinates >::sizes
private

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