alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
alpaka::fn::Fn< T_FnClass, T_fallbackPolicy, T_registrationPolicy > Struct Template Reference

Base class for function symbols. More...

#include <fn.hpp>

Public Member Functions

template<alpaka::concepts::DeviceSpec T_Any, typename... Args>
constexpr decltype(auto) operator() (T_Any &&any, Args &&... args) const
 Fallback operator() to generic function if not dispatchable for the given device specification.
template<alpaka::concepts::DeviceSpec T_Any, typename... Args>
constexpr decltype(auto) operator() (T_Any &&any, Args &&... args) const
 Fallback operator() to alpaka implementation if the function is not dispatchable for the given device specification.
template<alpaka::concepts::DeviceSpec T_Any, typename... Args>
constexpr decltype(auto) operator() (T_Any &&any, Args &&... args) const
 Call function overload if defined for the given device specification.

Static Public Member Functions

static constexpr decltype(auto) call (alpaka::concepts::DeviceSpec auto &&any, auto &&... args)
 Call the function overload for the given device specification.
static constexpr bool hasRegisteredFallback (alpaka::concepts::DeviceSpec auto const &any)
 Checks if the function overload fallback is registered.
static constexpr bool isRegistered (alpaka::concepts::DeviceSpec auto const &any)
 Checks if a function overload is registered for the given device specification.
static constexpr auto spec (alpaka::concepts::DeviceSpec auto const &any)
 Get the function specification.
template<alpaka::concepts::Api T_Api, alpaka::concepts::DeviceKind T_DeviceKind>
static constexpr auto spec (T_Api api, T_DeviceKind deviceKind)
 Get the function specification.

Detailed Description

template<typename T_FnClass, Fallback T_fallbackPolicy = Fallback::toGeneric, Registration T_registrationPolicy = Registration::none>
struct alpaka::fn::Fn< T_FnClass, T_fallbackPolicy, T_registrationPolicy >

Base class for function symbols.

Template Parameters
T_FnClassThe function symbol to register, dispatch and call. The class should be trivially constructable. By using the static call() function or the operator()
T_fallbackPolicyThe fallback policy if no vendor function overload is defined for the given device specification. If set to Fallback::toAlpaka the alpaka implementation is called if no other overload fits. If set to Fallback::none no fallback is performed and a static assert is triggered if no function overload is defined for the given device specification.
T_registrationPolicyIf set to Registration::enforced the isRegistered() can be called, and it is required to define alpakaFnRegister() for on T_FnClass. If set to Registration::none the isRegistered() function is not available and no registration of the vendor function overloads is required. If set to Registration::alwaysTrue isRegistered() will always return true. This can be used to skip the registration of the function symbol.

Definition at line 154 of file fn.hpp.

Member Function Documentation

◆ call()

template<typename T_FnClass, Fallback T_fallbackPolicy = Fallback::toGeneric, Registration T_registrationPolicy = Registration::none>
constexpr decltype(auto) alpaka::fn::Fn< T_FnClass, T_fallbackPolicy, T_registrationPolicy >::call ( alpaka::concepts::DeviceSpec auto && any,
auto &&... args )
inlinestaticconstexpr

Call the function overload for the given device specification.

See the call operator().

Attention
call() is a static function where the call operator required an instance of this class.

Definition at line 286 of file fn.hpp.

◆ hasRegisteredFallback()

template<typename T_FnClass, Fallback T_fallbackPolicy = Fallback::toGeneric, Registration T_registrationPolicy = Registration::none>
constexpr bool alpaka::fn::Fn< T_FnClass, T_fallbackPolicy, T_registrationPolicy >::hasRegisteredFallback ( alpaka::concepts::DeviceSpec auto const & any)
inlinestaticconstexpr

Checks if the function overload fallback is registered.

Similar to isRegistered(alpaka::concepts::DeviceSpec auto const& any) but it checks for the fallback overload only.

Parameters
anyany type which is usable with alpaka::getApi() and alpaka::getDeviceKind()
Returns
true if the function overload fallback for T_FnClass is registered else false.

Definition at line 215 of file fn.hpp.

◆ isRegistered()

template<typename T_FnClass, Fallback T_fallbackPolicy = Fallback::toGeneric, Registration T_registrationPolicy = Registration::none>
constexpr bool alpaka::fn::Fn< T_FnClass, T_fallbackPolicy, T_registrationPolicy >::isRegistered ( alpaka::concepts::DeviceSpec auto const & any)
inlinestaticconstexpr

Checks if a function overload is registered for the given device specification.

You can use the result to optionally call the function overload and disable at compile time code sections similar to C++ preprocessor guards.

void alpakaFnRegister(Foo::Spec<alpaka::api::Host, alpaka::deviceKind::Cpu>)
{
}
if constexpr (Foo::isRegistered(queue))
{
// more code
Foo::call(queue,args ...);
// more code
}
#define ALPAKA_FN_SYMBOL(fnName,...)
Define a function symbol class for alpaka's function interface.
Definition fn.hpp:319
@ none
No fallback is performed in case no overload is fitting.
Definition fn.hpp:91
@ enforced
It is required to define alpakaFnRegister() for a function symbol.
Definition fn.hpp:105
Parameters
anyany type which is usable with alpaka::getApi() and alpaka::getDeviceKind()
Returns
true if the function overload T_FnClass is registered else false. It does not try to check if a fallback overload is dispatchable, to check fallback registrations use hasRegisteredFallback(alpaka::concepts::DeviceSpec auto const& any).

Definition at line 200 of file fn.hpp.

◆ operator()() [1/3]

template<typename T_FnClass, Fallback T_fallbackPolicy = Fallback::toGeneric, Registration T_registrationPolicy = Registration::none>
template<alpaka::concepts::DeviceSpec T_Any, typename... Args>
decltype(auto) alpaka::fn::Fn< T_FnClass, T_fallbackPolicy, T_registrationPolicy >::operator() ( T_Any && any,
Args &&... args ) const
inlineconstexpr

Fallback operator() to generic function if not dispatchable for the given device specification.

This operator() is only enabled if T_fallbackPolicy is set toGeneric and function is dispatchable without a device specification.

Definition at line 273 of file fn.hpp.

◆ operator()() [2/3]

template<typename T_FnClass, Fallback T_fallbackPolicy = Fallback::toGeneric, Registration T_registrationPolicy = Registration::none>
template<alpaka::concepts::DeviceSpec T_Any, typename... Args>
decltype(auto) alpaka::fn::Fn< T_FnClass, T_fallbackPolicy, T_registrationPolicy >::operator() ( T_Any && any,
Args &&... args ) const
inlineconstexpr

Fallback operator() to alpaka implementation if the function is not dispatchable for the given device specification.

This operator() is only enabled if T_fallbackPolicy is set to toAlpaka and function is dispatchable for the given device specification.

Definition at line 249 of file fn.hpp.

◆ operator()() [3/3]

template<typename T_FnClass, Fallback T_fallbackPolicy = Fallback::toGeneric, Registration T_registrationPolicy = Registration::none>
template<alpaka::concepts::DeviceSpec T_Any, typename... Args>
decltype(auto) alpaka::fn::Fn< T_FnClass, T_fallbackPolicy, T_registrationPolicy >::operator() ( T_Any && any,
Args &&... args ) const
inlineconstexpr

Call function overload if defined for the given device specification.

Definition at line 231 of file fn.hpp.

◆ spec() [1/2]

template<typename T_FnClass, Fallback T_fallbackPolicy = Fallback::toGeneric, Registration T_registrationPolicy = Registration::none>
constexpr auto alpaka::fn::Fn< T_FnClass, T_fallbackPolicy, T_registrationPolicy >::spec ( alpaka::concepts::DeviceSpec auto const & any)
inlinestaticconstexpr

Get the function specification.

Returns
the function specification for the given entity.

Definition at line 162 of file fn.hpp.

◆ spec() [2/2]

template<typename T_FnClass, Fallback T_fallbackPolicy = Fallback::toGeneric, Registration T_registrationPolicy = Registration::none>
template<alpaka::concepts::Api T_Api, alpaka::concepts::DeviceKind T_DeviceKind>
constexpr auto alpaka::fn::Fn< T_FnClass, T_fallbackPolicy, T_registrationPolicy >::spec ( T_Api api,
T_DeviceKind deviceKind )
inlinestaticconstexpr

Get the function specification.

Returns
the function specification for the given entity.

Definition at line 168 of file fn.hpp.


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