E.V.E
v2023.02.15
Loading...
Searching...
No Matches
Extensions points

Detailed Description

Macros, classes and functions designed to extend EVE externally.

Classes

struct  eve::callable< Func, OptionsValues, Options >
 CRTP base class defining an EVE's Callable Object. More...
struct  eve::constant_callable< Func, OptionsValues, Options >
 CRTP base class giving an EVE's Callable Object the constant function semantic. More...
struct  eve::elementwise_callable< Func, OptionsValues, Options >
 CRTP base class giving an EVE's Callable Object the elementwise function semantic. More...
struct  eve::options< Settings >
 Wrapper class around bundle of options passed to eve::callable. More...
struct  eve::decorated_with< OptionsValues, Options >
 Helper class to aggregate options handlers and states. More...
struct  eve::relative_conditional_option
 Option specification for decoration via relative conditional value and expressions. More...
struct  eve::conditional_option
 Option specification for decoration via conditional value and expressions. More...

Macros

#define EVE_CALLABLE_OBJECT_FROM(NS, TYPE, NAME)
 Generate the generic function interface for any EVE-compatible Callable Object.
#define EVE_CALLABLE_OBJECT(TYPE, NAME)
 Generate the generic function interface for an actual eve::callable.
#define EVE_DISPATCH_CALL(...)
 Generate the proper call to current EVE's Callable Object implementation.
#define EVE_DISPATCH_CALL_NT(...)
 Generate the proper call to current EVE's Callable Object implementation, skips the translation mekanism.
#define EVE_CALLABLE_NAMESPACE()
 Register a namespace as suitable for containing eve::callable overloads.
#define EVE_REQUIRES(ARCH)
 Flag a function to support delayed calls on given architecture.

Concepts

concept  eve::callable_object
 EVE callable object

Variables

template<typename Func, auto... Opt>
constexpr bool eve::supports_options = requires{ (std::declval<Func>()[Opt], ...); }
 Checks if a callable function supports given options.
template<template< typename > class Func>
constexpr auto eve::functor = Func<eve::options<>>{}
 EVE's Callable Object generator.
constexpr _::condition_key_t eve::condition_key = {}
 Keyword for retrieving conditionals decorator.

Macro Definition Documentation

◆ EVE_CALLABLE_OBJECT

#define EVE_CALLABLE_OBJECT ( TYPE,
NAME )
Value:
template<typename... Args> \
static EVE_FORCEINLINE constexpr auto deferred_call(auto arch, Args&&...args) noexcept \
-> decltype(NAME(eve::_::adl_helper, arch, EVE_FWD(args)...)) \
{ \
return NAME(eve::_::adl_helper, arch, EVE_FWD(args)...); \
} \
using callable_tag_type = TYPE \

Generate the generic function interface for an actual eve::callable.

Defined in Header

#include <eve/module/core.hpp>

Use inside a Callable Object definition to generate the required EVE protocol of function's resolution based on type and architecture information using overload from the eve::_ namespace.

Warning
EVE_CALLABLE_OBJECT is mostly used for EVE Callable Object definition. If you want to use EVE's overload facility for your own library, use EVE_CALLABLE_OBJECT_FROM.
Parameters
TYPECurrent Callable Object type
NAMEFunction identifier for overloads. Calls to eve::_::NAME are supposed to succeed.

Usage

EVE_CALLABLE_OBJECT generates the expected code for defining a EVE Callable Object. EVE Callable Object are function object which supports decorators and use an external function to specify its implementation.

EVE_CALLABLE_OBJECT relies on its enclosing type to provide at least one declaration of a member function named call which represent the expected prototype of the function object, including potential constraints, and its associated return type. EVE_CALLABLE_OBJECT also relies on the existence of an appropriate number of function overloads named NAME defined in the eve::_ namespace. Those function contains the implementation of the Callable Object overload for each pre-defined function.

Example

#include <iostream>
#include <type_traits>
#include <eve/traits/overload.hpp>
#include <eve/wide.hpp>
namespace eve
{
template<typename Options>
struct func_t : callable<func_t, Options>
{
// operator() are defined here to maximize quality of error message. They all use EVE_DISPATCH_CALL at some point.
template<eve::integral_value T>
EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); }
EVE_FORCEINLINE double operator()(double v) const { return EVE_DISPATCH_CALL(v); }
EVE_FORCEINLINE void operator()(float) const = delete;
// This ties the function object to the overload set
EVE_CALLABLE_OBJECT(func_t, func_);
};
// Build the callable object from the function object type
inline constexpr auto func = functor<func_t>;
};
// As func_t used EVE_CALLABLE_OBJECT, we should write overloads in eve::_
namespace eve::_
{
auto func_(EVE_REQUIRES(cpu_), eve::callable_options auto const&, eve::integral_value auto x) { return x*x; }
auto func_(EVE_REQUIRES(cpu_), eve::callable_options auto const&, double x) { return 1./x; }
}
int main()
{
std::cout << eve::func(8) << "\n";
std::cout << eve::func(eve::wide<short>{77}) << "\n";
std::cout << eve::func(25.) << "\n";
std::cout << "Is func(double) supported : "
<< std::boolalpha << std::is_invocable_v<eve::tag_t<eve::func>, double>
<< "\n";
std::cout << "Is func(float) supported : "
<< std::boolalpha << std::is_invocable_v<eve::tag_t<eve::func>, float>
<< "\n";
std::cout << "Is func(wide<float>) supported: "
<< std::boolalpha << std::is_invocable_v<eve::tag_t<eve::func>, eve::wide<float>>
<< "\n";
}
#define EVE_CALLABLE_OBJECT(TYPE, NAME)
Generate the generic function interface for an actual eve::callable.
Definition protocol.hpp:157
constexpr auto functor
EVE's Callable Object generator.
Definition supports.hpp:107
#define EVE_REQUIRES(ARCH)
Flag a function to support delayed calls on given architecture.
Definition protocol.hpp:226
#define EVE_DISPATCH_CALL(...)
Generate the proper call to current EVE's Callable Object implementation.
Definition protocol.hpp:194
Definition abi.hpp:19
EVE Main Namespace.
Definition abi.hpp:19
Wrapper for SIMD registers.
Definition wide.hpp:94

◆ EVE_CALLABLE_OBJECT_FROM

#define EVE_CALLABLE_OBJECT_FROM ( NS,
TYPE,
NAME )
Value:
template<typename... Args> \
static EVE_FORCEINLINE constexpr auto deferred_call(auto arch, Args&&...args) noexcept \
-> decltype(NAME(NS::adl_helper, arch, EVE_FWD(args)...)) \
{ \
return NAME( NS::adl_helper, arch, EVE_FWD(args)...); \
} \
using callable_tag_type = TYPE \

Generate the generic function interface for any EVE-compatible Callable Object.

Defined in Header

#include <eve/module/core.hpp>

Use inside a Callable Object definition to generate the required EVE protocol of function's resolution based on type and architecture information.

Parameters
NSNamespace in which specialization of the Callable Object will be found. This namespace must have been registered via EVE_CALLABLE_NAMESPACE.
TYPECurrent Callable Object type
NAMEFunction identifier for overloads. Calls to NS::NAME are supposed to succeed.
See also
EVE_CALLABLE_OBJECT
EVE_CALLABLE_NAMESPACE

Usage

EVE_CALLABLE_OBJECT_FROM generates the expected code for defining a EVE Callable Object. EVE Callable Object are function object which supports decorators and use an external function to specify its implementation.

EVE_CALLABLE_OBJECT_FROM relies on its enclosing type to provide at least one declaration of a member function named call which represent the expected prototype of the function object, including potential constraints, and its associated return type. EVE_CALLABLE_OBJECT also relies on the existence of an appropriate number of function overloads named NAME defined in the NS namespace. Those function contains the implementation of the Callable Object overload for each pre-defined function.

Example

#include <iostream>
#include <type_traits>
#include <eve/traits/overload.hpp>
#include <eve/wide.hpp>
// Register my_lib::impl as a proper callable namespace
namespace my_lib::impl { EVE_CALLABLE_NAMESPACE(); }
// EVE_CALLABLE_OBJECT_FROM helps defining your own EVE-like callable in your own library
namespace my_lib
{
template<typename Options>
struct func_t : eve::callable<func_t, Options>
{
// operator() are defined here to maximize quality of error message. They all use EVE_DISPATCH_CALL at some point.
template<eve::integral_value T>
EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); }
EVE_FORCEINLINE double operator()(double v) const { return EVE_DISPATCH_CALL(v); }
EVE_FORCEINLINE void operator()(float) const = delete;
// This ties the function object to the overload set
EVE_CALLABLE_OBJECT_FROM(my_lib::impl, func_t, func_);
};
// Build the callable object from the function object type
inline constexpr auto func = eve::functor<func_t>;
// As func_t used EVE_CALLABLE_OBJECT_FROM, we can write overloads in this namespace
namespace impl
{
auto func_(EVE_REQUIRES(eve::cpu_), eve::callable_options auto const&, eve::integral_value auto x) { return x*x; }
auto func_(EVE_REQUIRES(eve::cpu_), eve::callable_options auto const&, double x) { return 1./x; }
}
}
int main()
{
std::cout << my_lib::func(8) << "\n";
std::cout << my_lib::func(eve::wide<short>{77}) << "\n";
std::cout << my_lib::func(25.) << "\n";
std::cout << "Is func(double) supported : "
<< std::boolalpha << std::is_invocable_v<eve::tag_t<my_lib::func>, double>
<< "\n";
std::cout << "Is func(float) supported : "
<< std::boolalpha << std::is_invocable_v<eve::tag_t<my_lib::func>, float>
<< "\n";
std::cout << "Is func(wide<float>) supported: "
<< std::boolalpha << std::is_invocable_v<eve::tag_t<my_lib::func>, eve::wide<float>>
<< "\n";
}
#define EVE_CALLABLE_NAMESPACE()
Register a namespace as suitable for containing eve::callable overloads.
Definition protocol.hpp:214
#define EVE_CALLABLE_OBJECT_FROM(NS, TYPE, NAME)
Generate the generic function interface for any EVE-compatible Callable Object.
Definition protocol.hpp:109
CRTP base class defining an EVE's Callable Object.
Definition callable.hpp:51

Variable Documentation

◆ condition_key

_::condition_key_t eve::condition_key = {}
inlineconstexpr

Keyword for retrieving conditionals decorator.

Defined in Header

#include <eve/module/core.hpp>

When a eve::decorated_callable is called with an option provided via eve::conditional, the value of the conditional can be retrieved using eve::condition_key

See also
eve::supports

◆ supports_options

template<typename Func, auto... Opt>
bool eve::supports_options = requires{ (std::declval<Func>()[Opt], ...); }
inlineconstexpr

Checks if a callable function supports given options.

Defined in Header

#include <eve/eve.hpp>

This template variable evaluates to true if the callable Func supports all the specified options.

Template Parameters
FuncThe callable function to check
OptThe options to check for support