[FEA] Simplify type-dispatch for code that only cares about the storage type #7390
Labels
feature request
New feature or request
improvement
Improvement / enhancement to an existing function
libcudf
Affects libcudf (C++/CUDA) code.
Is your feature request related to a problem? Please describe.
There are many functions in libcudf that don't care about the actual Element type in a column (e.g., just moving data). This simplifies implementations of code paths for things like
DECIMAL32/64
where we can just use the same path asINT32/64
. Thedevice_storage_type_t
trait provides a convenient way to access the representation of an elements value. In type dispatched code, that looks something like:This is pretty nice, but it would be even nicer if the
type_dispatcher
could automatically just dispatch the "storage" type. Then we wouldn't have to worry about adding theusing storage_type...
code everywhere.Describe the solution you'd like
The
type_dispatcher
was designed to support exactly this kind of use case. A heretofore unused feature of thetype_dispatcher
is that it allows you to customize the type dispatched for a giventype_id
enum value. This is done via aIdTypeMap
template parameter that "maps" acudf::type_id
to the type to dispatch. It is defaulted to do the expected dispatch likeINT32 -> int32_t
, but it can be overriden via an explicit template argument.This makes it very easy to create a "device storage type" dispatcher:
This will now automatically unwrap any wrapper types.
As a side benefit, I believe using this form of the
type_dispatcher
could reduce compile time and binary size as it would reduce the number of unique instantiations of the function objectsoperator()
template. This would be especially true if we madedevice_storage_type_t
unwrap timestamp types to their underlying representation.The text was updated successfully, but these errors were encountered: