Speclib  0.1.2
The library for writing better CUDA libraries
sp::ScalarSpecialiser Struct Reference

Specialises input scalar types to compile-time-constant sp::Scalar derivatives, if possible. More...

#include <Scalar.hpp>

Inheritance diagram for sp::ScalarSpecialiser:
[legend]

Static Public Member Functions

template<typename T >
constexpr static bool test ()
 
template<typename ArgType , typename... Stuff>
static auto specialise (const ArgType &thisArg, sp::int_sequence<>, Stuff &&... stuff)
 
template<int Int, int... Ints, typename ArgType , typename... Stuff>
static auto specialise (const ArgType &thisArg, sp::int_sequence< Int, Ints... >, Stuff &&... stuff)
 
template<typename ArgType , typename Fn , typename... Stuff>
static auto run (const ArgType &thisArg, Fn &fn, Stuff &&... stuff)
 Replace scalars with sp::Scalars<> with the appropriate ScalarKind. More...
 
- Static Public Member Functions inherited from sp::Specialiser
template<typename T >
static constexpr bool test ()
 Return true iff the specialiser is able to specialise arguments of type T. More...
 
template<typename... O, typename ArgType , typename... Stuff>
static auto run (const ArgType &thisArg, Stuff &&... stuff)
 Specialise an argument. More...
 

Detailed Description

Specialises input scalar types to compile-time-constant sp::Scalar derivatives, if possible.

This Specialiser checks if the runtime value of any scalar argument is equal to an entry in the target functor type's overload of Specialisable::ScalarsToSpecialise. If it is, the argument is replaced by an sp::Scalar of a type that is constexpr-convertible to the scalar value.

This will produce one expansion branch for every entry in the target functor's ScalarsToSpecialise, plus a general case for runtime-determined values.

Member Function Documentation

◆ run()

template<typename ArgType , typename Fn , typename... Stuff>
static auto sp::ScalarSpecialiser::run ( const ArgType &  thisArg,
Fn &  fn,
Stuff &&...  stuff 
)
static

Replace scalars with sp::Scalars<> with the appropriate ScalarKind.

This will lead to the generation of special versions of the target function for degenerate scalar values (like 0, 1, etc.)