33 namespace CUDF_EXPORT
cudf {
58 return type_id::EMPTY;
65 struct type_to_name_impl {
72 inline std::string operator()()
78 template <cudf::type_
id t>
79 struct id_to_type_impl {
91 template <cudf::type_
id Id>
109 template <
typename T>
111 std::conditional_t<std::is_same_v<numeric::decimal32, T>, int32_t,
112 std::conditional_t<std::is_same_v<numeric::decimal64, T>, int64_t,
113 std::conditional_t<std::is_same_v<numeric::decimal128, T>, __int128_t, T>>>;
125 template <
typename T>
128 return (
id == type_id::DECIMAL32 && std::is_same_v<T, int32_t>) ||
129 (
id == type_id::DECIMAL64 && std::is_same_v<T, int64_t>) ||
130 (
id == type_id::DECIMAL128 && std::is_same_v<T, __int128_t>) ||
id == type_to_id<T>();
140 #ifndef CUDF_TYPE_MAPPING
141 #define CUDF_TYPE_MAPPING(Type, Id) \
143 constexpr inline type_id type_to_id<Type>() \
148 inline std::string type_to_name_impl::operator()<Type>() \
150 return CUDF_STRINGIFY(Type); \
153 struct id_to_type_impl<Id> { \
199 return type_id::INT8;
210 template <cudf::type_
id Id>
215 template <
typename T>
216 struct type_to_scalar_type_impl {
226 #ifndef MAP_NUMERIC_SCALAR
227 #define MAP_NUMERIC_SCALAR(Type) \
229 struct type_to_scalar_type_impl<Type> { \
230 using ScalarType = cudf::numeric_scalar<Type>; \
231 using ScalarDeviceType = cudf::numeric_scalar_device_view<Type>; \
249 struct type_to_scalar_type_impl<std::string> {
255 struct type_to_scalar_type_impl<
cudf::string_view> {
286 struct type_to_scalar_type_impl<
cudf::list_view> {
292 struct type_to_scalar_type_impl<
cudf::struct_view> {
303 #ifndef MAP_TIMESTAMP_SCALAR
304 #define MAP_TIMESTAMP_SCALAR(Type) \
306 struct type_to_scalar_type_impl<Type> { \
307 using ScalarType = cudf::timestamp_scalar<Type>; \
308 using ScalarDeviceType = cudf::timestamp_scalar_device_view<Type>; \
324 #ifndef MAP_DURATION_SCALAR
325 #define MAP_DURATION_SCALAR(Type) \
327 struct type_to_scalar_type_impl<Type> { \
328 using ScalarType = cudf::duration_scalar<Type>; \
329 using ScalarDeviceType = cudf::duration_scalar_device_view<Type>; \
344 template <
typename T>
352 template <
typename T>
450 #pragma nv_exec_check_disable
452 template <
template <cudf::type_
id>
typename IdTypeMap = id_to_type_impl,
459 switch (dtype.id()) {
461 return f.template operator()<
typename IdTypeMap<type_id::INT8>::type>(
462 std::forward<Ts>(args)...);
464 return f.template operator()<
typename IdTypeMap<type_id::INT16>::type>(
465 std::forward<Ts>(args)...);
467 return f.template operator()<
typename IdTypeMap<type_id::INT32>::type>(
468 std::forward<Ts>(args)...);
470 return f.template operator()<
typename IdTypeMap<type_id::INT64>::type>(
471 std::forward<Ts>(args)...);
473 return f.template operator()<
typename IdTypeMap<type_id::UINT8>::type>(
474 std::forward<Ts>(args)...);
475 case type_id::UINT16:
476 return f.template operator()<
typename IdTypeMap<type_id::UINT16>::type>(
477 std::forward<Ts>(args)...);
478 case type_id::UINT32:
479 return f.template operator()<
typename IdTypeMap<type_id::UINT32>::type>(
480 std::forward<Ts>(args)...);
481 case type_id::UINT64:
482 return f.template operator()<
typename IdTypeMap<type_id::UINT64>::type>(
483 std::forward<Ts>(args)...);
484 case type_id::FLOAT32:
485 return f.template operator()<
typename IdTypeMap<type_id::FLOAT32>::type>(
486 std::forward<Ts>(args)...);
487 case type_id::FLOAT64:
488 return f.template operator()<
typename IdTypeMap<type_id::FLOAT64>::type>(
489 std::forward<Ts>(args)...);
491 return f.template operator()<
typename IdTypeMap<type_id::BOOL8>::type>(
492 std::forward<Ts>(args)...);
493 case type_id::TIMESTAMP_DAYS:
494 return f.template operator()<
typename IdTypeMap<type_id::TIMESTAMP_DAYS>::type>(
495 std::forward<Ts>(args)...);
496 case type_id::TIMESTAMP_SECONDS:
497 return f.template operator()<
typename IdTypeMap<type_id::TIMESTAMP_SECONDS>::type>(
498 std::forward<Ts>(args)...);
499 case type_id::TIMESTAMP_MILLISECONDS:
500 return f.template operator()<
typename IdTypeMap<type_id::TIMESTAMP_MILLISECONDS>::type>(
501 std::forward<Ts>(args)...);
502 case type_id::TIMESTAMP_MICROSECONDS:
503 return f.template operator()<
typename IdTypeMap<type_id::TIMESTAMP_MICROSECONDS>::type>(
504 std::forward<Ts>(args)...);
505 case type_id::TIMESTAMP_NANOSECONDS:
506 return f.template operator()<
typename IdTypeMap<type_id::TIMESTAMP_NANOSECONDS>::type>(
507 std::forward<Ts>(args)...);
508 case type_id::DURATION_DAYS:
509 return f.template operator()<
typename IdTypeMap<type_id::DURATION_DAYS>::type>(
510 std::forward<Ts>(args)...);
511 case type_id::DURATION_SECONDS:
512 return f.template operator()<
typename IdTypeMap<type_id::DURATION_SECONDS>::type>(
513 std::forward<Ts>(args)...);
514 case type_id::DURATION_MILLISECONDS:
515 return f.template operator()<
typename IdTypeMap<type_id::DURATION_MILLISECONDS>::type>(
516 std::forward<Ts>(args)...);
517 case type_id::DURATION_MICROSECONDS:
518 return f.template operator()<
typename IdTypeMap<type_id::DURATION_MICROSECONDS>::type>(
519 std::forward<Ts>(args)...);
520 case type_id::DURATION_NANOSECONDS:
521 return f.template operator()<
typename IdTypeMap<type_id::DURATION_NANOSECONDS>::type>(
522 std::forward<Ts>(args)...);
523 case type_id::DICTIONARY32:
524 return f.template operator()<
typename IdTypeMap<type_id::DICTIONARY32>::type>(
525 std::forward<Ts>(args)...);
526 case type_id::STRING:
527 return f.template operator()<
typename IdTypeMap<type_id::STRING>::type>(
528 std::forward<Ts>(args)...);
530 return f.template operator()<
typename IdTypeMap<type_id::LIST>::type>(
531 std::forward<Ts>(args)...);
532 case type_id::DECIMAL32:
533 return f.template operator()<
typename IdTypeMap<type_id::DECIMAL32>::type>(
534 std::forward<Ts>(args)...);
535 case type_id::DECIMAL64:
536 return f.template operator()<
typename IdTypeMap<type_id::DECIMAL64>::type>(
537 std::forward<Ts>(args)...);
538 case type_id::DECIMAL128:
539 return f.template operator()<
typename IdTypeMap<type_id::DECIMAL128>::type>(
540 std::forward<Ts>(args)...);
541 case type_id::STRUCT:
542 return f.template operator()<
typename IdTypeMap<type_id::STRUCT>::type>(
543 std::forward<Ts>(args)...);
545 #ifndef __CUDA_ARCH__
548 CUDF_UNREACHABLE(
"Invalid type_id.");
556 template <
typename T1>
557 struct double_type_dispatcher_second_type {
559 #pragma nv_exec_check_disable
561 template <
typename T2,
typename F,
typename... Ts>
562 CUDF_HOST_DEVICE __forceinline__ decltype(
auto) operator()(F&& f, Ts&&... args)
const
564 return f.template operator()<T1, T2>(std::forward<Ts>(args)...);
568 template <
template <cudf::type_
id>
typename IdTypeMap>
569 struct double_type_dispatcher_first_type {
571 #pragma nv_exec_check_disable
573 template <
typename T1,
typename F,
typename... Ts>
578 return type_dispatcher<IdTypeMap>(type2,
579 detail::double_type_dispatcher_second_type<T1>{},
581 std::forward<Ts>(args)...);
603 #pragma nv_exec_check_disable
605 template <
template <cudf::type_
id>
typename IdTypeMap = id_to_type_impl,
typename F,
typename... Ts>
609 return type_dispatcher<IdTypeMap>(type1,
610 detail::double_type_dispatcher_first_type<IdTypeMap>{},
613 std::forward<Ts>(args)...);
Indicator for the logical data type of an element in a column.
A type of scalar_device_view that stores a pointer to a fixed_point value.
An owning class to represent a fixed_point number in device memory.
An owning class to represent a list value in device memory.
A non-owning, immutable view of device data that represents a list of elements of arbitrary type (inc...
A type of scalar_device_view that stores a pointer to a numerical value.
An owning class to represent a numerical value in device memory.
An owning class to represent a singular value.
A type of scalar_device_view that stores a pointer to a string value.
An owning class to represent a string in device memory.
A non-owning, immutable view of device data that is a variable length char array representing a UTF-8...
An owning class to represent a struct value in device memory.
A non-owning, immutable view of device data that represents a struct with fields of arbitrary types (...
A type for representing a number with a fixed amount of precision.
Concrete type definition for dictionary columns.
Concrete type definitions for int32_t and int64_t durations in varying resolutions.
Class definition for fixed point data type.
dictionary_wrapper< int32_t > dictionary32
32-bit integer indexed dictionary wrapper
fixed_point< int32_t, Radix::BASE_10 > decimal32
32-bit decimal fixed point
fixed_point< int64_t, Radix::BASE_10 > decimal64
64-bit decimal fixed point
fixed_point< __int128_t, Radix::BASE_10 > decimal128
128-bit decimal fixed point
detail::timestamp< cudf::duration_ms > timestamp_ms
Type alias representing a cudf::duration_ms (int64_t) since the unix epoch.
detail::timestamp< cudf::duration_s > timestamp_s
Type alias representing a cudf::duration_s (int64_t) since the unix epoch.
detail::timestamp< cudf::duration_D > timestamp_D
Type alias representing a cudf::duration_D (int32_t) since the unix epoch.
cuda::std::chrono::duration< int64_t, cuda::std::chrono::nanoseconds::period > duration_ns
Type alias representing an int64_t duration of nanoseconds.
cuda::std::chrono::duration< int32_t, cuda::std::chrono::days::period > duration_D
Type alias representing an int32_t duration of days.
cuda::std::chrono::duration< int64_t, cuda::std::chrono::milliseconds::period > duration_ms
Type alias representing an int64_t duration of milliseconds.
cuda::std::chrono::duration< int64_t, cuda::std::chrono::microseconds::period > duration_us
Type alias representing an int64_t duration of microseconds.
detail::timestamp< cudf::duration_us > timestamp_us
Type alias representing a cudf::duration_us (int64_t) since the unix epoch.
detail::timestamp< cudf::duration_ns > timestamp_ns
Type alias representing a cudf::duration_ns (int64_t) since the unix epoch.
cuda::std::chrono::duration< int64_t, cuda::std::chrono::seconds::period > duration_s
Type alias representing an int64_t duration of seconds.
#define MAP_TIMESTAMP_SCALAR(Type)
Macro used to define scalar type and scalar device type for cudf::timestamp_scalar template class for...
constexpr type_id type_to_id< char >()
Specialization to map 'char' type to type_id::INT8.
std::string type_to_name(data_type type)
Return a name for a given type.
#define MAP_DURATION_SCALAR(Type)
Macro used to define scalar type and scalar device type for cudf::duration_scalar template class for ...
CUDF_HOST_DEVICE constexpr decltype(auto) __forceinline__ 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 i...
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 > >> device_storage_type_t
"Returns" the corresponding type that is stored on the device when using cudf::column
typename type_to_scalar_type_impl< T >::ScalarDeviceType scalar_device_type_t
Maps a C++ type to the scalar device type required to hold its value.
#define CUDF_TYPE_MAPPING(Type, Id)
Macro used to define a mapping between a concrete C++ type and a cudf::type_id enum.
typename type_to_scalar_type_impl< T >::ScalarType scalar_type_t
Maps a C++ type to the scalar type required to hold its value.
constexpr type_id type_to_id()
Maps a C++ type to its corresponding cudf::type_id
CUDF_HOST_DEVICE constexpr decltype(auto) __forceinline__ double_type_dispatcher(cudf::data_type type1, cudf::data_type type2, F &&f, Ts &&... args)
Dispatches two type template parameters to a callable.
typename id_to_type_impl< Id >::type id_to_type
Maps a cudf::type_id to its corresponding concrete C++ type.
constexpr bool 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.
#define MAP_NUMERIC_SCALAR(Type)
Macro used to define scalar type and scalar device type for cudf::numeric_scalar template class for n...
#define CUDF_FAIL(...)
Indicates that an erroneous code path has been taken.
type_id
Identifies a column's logical element type.
fixed_point and supporting types
A strongly typed wrapper for indices in a DICTIONARY type column.
Use this specialization on type_dispatcher whenever you only need to operate on the underlying stored...
device_storage_type_t< id_to_type< Id > > type
The underlying type.
Concrete type definitions for int32_t and int64_t timestamps in varying resolutions as durations sinc...
Type declarations for libcudf.
#define CUDF_HOST_DEVICE
Indicates that the function or method is usable on host and device.