alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
alpaka::fn Namespace Reference

alpaka'S function interface More...

Namespaces

namespace  api
namespace  concepts

Classes

struct  Fn
 Base class for function symbols. More...

Enumerations

enum class  Fallback : int {
  toGeneric = 1 ,
  toAlpaka = 2 ,
  none = 3
}
 Fallback policy for function calls. More...
enum class  Registration : int {
  alwaysTrue = 1 ,
  enforced = 2 ,
  none = 3
}
 Policy to control if a function symbol must be registered. More...

Detailed Description

alpaka'S function interface

This file defines the interface for registering, dispatching and calling function overloads specialize for device specifications. A device specification consists of an alpaka API and device kind. These functions can be dispatched to third-party libraries (e.g. cuBLAS) and can be used in alpaka onHost or onAcc. The function interface of alpaka provides a way to work natively with alpaka objects while being able to use third party interfaces for functionality not provided in alpaka or in cases where the vendor implementation provides better performance. For each exposed function you can provide a fallback to an alpaka implementation for a device specification or a device specification independent generic implementation. This keeps your code base portable even if you can not dispatch to a third party/vendor library and avoids preprocessor macros around function calls. The preprocessor macro ALPAKA_FN_SYMBOL() should be used to declare a function symbol. A function symbol follows all requirements to be used as kernel within alpaka.

The main components of the interface are:

  • alpaka::fn::Fn: The function symbol baseclass that can be used to register, dispatch and call third party functions.
  • alpakaFnRegister: A function template that can be specialized to register a function overload for a device specification. This is optional and only required if Registration::enforced is set to the function symbol. It allows the usage of isRegistered() function to check if a third party function overload is defined.
  • alpakaFnDispatch: A function template that can be specialized to dispatch a function symbol to a third party function depending on the device specification.

For an example of how to use the interface see example/vendorApi.

Enumeration Type Documentation

◆ Fallback

enum class alpaka::fn::Fallback : int
strong

Fallback policy for function calls.

This enum defines the fallback policy for function calls. It is used as a template parameter in alpaka::fn::Fn or ALPAKA_FN_SYMBOL to specify the fallback behavior if no vendor function overload is defined for the given device specification.

Enumerator
toGeneric 

The generic implementation is called if no other overload fits.

Should be used to ensure portability between different heterogeneous APIs.

toAlpaka 

The alpaka implementation is called if no other overload fits.

Should be used to ensure portability between different heterogeneous APIs.

none 

No fallback is performed in case no overload is fitting.

Should be used if you want to ensure that a third party function overload is guaranteed to be called.

Definition at line 75 of file fn.hpp.

◆ Registration

enum class alpaka::fn::Registration : int
strong

Policy to control if a function symbol must be registered.

Enumerator
alwaysTrue 

The isRegistered() function will always return true.

This can be used to skip the registration of the function symbol via alpakaFnRegister().

enforced 

It is required to define alpakaFnRegister() for a function symbol.

isRegistered() can be called to check if a vendor function overload is registered for the given device specification.

none 

The isRegistered() function is not available and no registration of the vendor function overloads is required.

This can be used if you do not want to use the isRegistered() function and do not want to require the definition of alpakaFnRegister() for a function symbol.

Definition at line 96 of file fn.hpp.