libcudf
23.12.00
|
Files | |
file | type_dispatcher.hpp |
Defines the mapping between cudf::type_id runtime type information and concrete C++ types. | |
Classes | |
struct | cudf::dispatch_storage_type< Id > |
Use this specialization on type_dispatcher whenever you only need to operate on the underlying stored type. More... | |
Macros | |
#define | CUDF_TYPE_MAPPING(Type, Id) |
Macro used to define a mapping between a concrete C++ type and a cudf::type_id enum. More... | |
#define | MAP_NUMERIC_SCALAR(Type) |
Macro used to define scalar type and scalar device type for cudf::numeric_scalar template class for numeric C++ types. More... | |
#define | MAP_TIMESTAMP_SCALAR(Type) |
Macro used to define scalar type and scalar device type for cudf::timestamp_scalar template class for timestamp C++ types. More... | |
#define | MAP_DURATION_SCALAR(Type) |
Macro used to define scalar type and scalar device type for cudf::duration_scalar template class for duration C++ types. More... | |
Typedefs | |
template<cudf::type_id Id> | |
using | cudf::id_to_type = typename id_to_type_impl< Id >::type |
Maps a cudf::type_id to its corresponding concrete C++ type. More... | |
template<typename T > | |
using | cudf::device_storage_type_t = std::conditional_t< std::is_same_v< numeric::decimal32, T >, int32_t, std::conditional_t< std::is_same_v< numeric::decimal64, T >, int64_t, std::conditional_t< std::is_same_v< numeric::decimal128, T >, __int128_t, T > >> |
"Returns" the corresponding type that is stored on the device when using cudf::column More... | |
template<typename T > | |
using | cudf::scalar_type_t = typename type_to_scalar_type_impl< T >::ScalarType |
Maps a C++ type to the scalar type required to hold its value. More... | |
template<typename T > | |
using | cudf::scalar_device_type_t = typename type_to_scalar_type_impl< T >::ScalarDeviceType |
Maps a C++ type to the scalar device type required to hold its value. More... | |
Functions | |
template<typename T > | |
constexpr type_id | cudf::type_to_id () |
Maps a C++ type to its corresponding cudf::type_id More... | |
template<typename T > | |
constexpr bool | cudf::type_id_matches_device_storage_type (type_id id) |
Checks if fixed_point -like types have template type T matching the column's stored type id. More... | |
template<template< cudf::type_id > typename IdTypeMap = id_to_type_impl, typename Functor , typename... Ts> | |
CUDF_HOST_DEVICE constexpr decltype(auto) __forceinline__ | cudf::type_dispatcher (cudf::data_type dtype, Functor f, Ts &&... args) |
Invokes an operator() template with the type instantiation based on the specified cudf::data_type 's id() . More... | |
template<template< cudf::type_id > typename IdTypeMap = id_to_type_impl, typename F , typename... Ts> | |
CUDF_HOST_DEVICE constexpr decltype(auto) __forceinline__ | cudf::double_type_dispatcher (cudf::data_type type1, cudf::data_type type2, F &&f, Ts &&... args) |
Dispatches two type template parameters to a callable. More... | |
std::string | cudf::type_to_name (data_type type) |
Return a name for a given type. More... | |
#define CUDF_TYPE_MAPPING | ( | Type, | |
Id | |||
) |
Macro used to define a mapping between a concrete C++ type and a cudf::type_id
enum.
Type | The concrete C++ type |
Id | The cudf::type_id enum |
Definition at line 142 of file type_dispatcher.hpp.
#define MAP_DURATION_SCALAR | ( | Type | ) |
Macro used to define scalar type and scalar device type for cudf::duration_scalar
template class for duration C++ types.
Type | The duration C++ type |
Definition at line 312 of file type_dispatcher.hpp.
#define MAP_NUMERIC_SCALAR | ( | Type | ) |
Macro used to define scalar type and scalar device type for cudf::numeric_scalar
template class for numeric C++ types.
Type | The numeric C++ type |
Definition at line 214 of file type_dispatcher.hpp.
#define MAP_TIMESTAMP_SCALAR | ( | Type | ) |
Macro used to define scalar type and scalar device type for cudf::timestamp_scalar
template class for timestamp C++ types.
Type | The timestamp C++ type |
Definition at line 291 of file type_dispatcher.hpp.
using cudf::device_storage_type_t = typedef std::conditional_t<std::is_same_v<numeric::decimal32, T>, int32_t, std::conditional_t<std::is_same_v<numeric::decimal64, T>, int64_t, std::conditional_t<std::is_same_v<numeric::decimal128, T>, __int128_t, T> >> |
"Returns" the corresponding type that is stored on the device when using cudf::column
For decimal32
, the storage type is an int32_t
. For decimal64
, the storage type is an int64_t
. For decimal128
, the storage type is an __int128_t
.
Use this "type function" with the using
type alias:
T | The literal type that is stored on the host |
Definition at line 111 of file type_dispatcher.hpp.
using cudf::id_to_type = typedef typename id_to_type_impl<Id>::type |
Maps a cudf::type_id
to its corresponding concrete C++ type.
Example:
t | The cudf::type_id to map |
Definition at line 93 of file type_dispatcher.hpp.
using cudf::scalar_device_type_t = typedef typename type_to_scalar_type_impl<T>::ScalarDeviceType |
Maps a C++ type to the scalar device type required to hold its value.
T | The concrete C++ type to map |
Definition at line 340 of file type_dispatcher.hpp.
using cudf::scalar_type_t = typedef typename type_to_scalar_type_impl<T>::ScalarType |
Maps a C++ type to the scalar type required to hold its value.
T | The concrete C++ type to map |
Definition at line 332 of file type_dispatcher.hpp.
|
constexpr |
Dispatches two type template parameters to a callable.
This function expects a callable f
with an operator()
template accepting two typename template parameters T1
and T2
.
type1 | The data_type used to dispatch a type for the first template parameter of the callable F |
type2 | The data_type used to dispatch a type for the second template parameter of the callable F |
f | The callable whose operator() template is invoked |
args | Parameter pack forwarded to the operator() invocation F . |
f.template operator<T1, T2>(args)
Definition at line 593 of file type_dispatcher.hpp.
|
constexpr |
Invokes an operator()
template with the type instantiation based on the specified cudf::data_type
's id()
.
Example usage with a functor that returns the size of the dispatched type:
The type_dispatcher
uses cudf::type_to_id<t>
to provide a default mapping of cudf::type_id
s to dispatched C++ types. However, this mapping may be customized by explicitly specifying a user-defined trait struct for the IdTypeMap
. For example, to always dispatch int32_t
It is sometimes necessary to customize the dispatched functor's operator()
for different types. This can be done in several ways.
The first method is to use explicit template specialization. This is useful for specializing behavior for single types. For example, a functor that prints int32_t
or double
when invoked with either of those types, else it prints unhandled type
:
A second method is to use SFINAE with std::enable_if_t
. This is useful for specializing for a set of types that share some property. For example, a functor that prints integral
or floating point
for integral or floating point types:
For more info on SFINAE and std::enable_if
, see https://eli.thegreenplace.net/2014/sfinae-and-enable_if/
The return type for all template instantiations of the functor's "operator()" lambda must be the same, else there will be a compiler error as you would be trying to return different types from the same function.
id_to_type_impl | Maps a cudf::type_id its dispatched C++ type |
Functor | The callable object's type |
Ts | Variadic parameter pack type |
dtype | The cudf::data_type whose id() determines which template instantiation is invoked |
f | The callable whose operator() template is invoked |
args | Parameter pack of arguments forwarded to the operator() invocation |
operator()
Definition at line 442 of file type_dispatcher.hpp.
|
constexpr |
Checks if fixed_point
-like types have template type T
matching the column's stored type id.
T | The type that is stored on the device |
id | The data_type::id of the column |
true
If T matches the stored column type_id
false
If T does not match the stored column type_id
Definition at line 127 of file type_dispatcher.hpp.
|
inlineconstexpr |
Maps a C++ type to its corresponding cudf::type_id
When explicitly passed a template argument of a given type, returns the appropriate type_id
enum for the specified C++ type.
For example:
T | The type to map to a cudf::type_id |
cudf::type_id
corresponding to the specified type Definition at line 57 of file type_dispatcher.hpp.