We repeatedly define common functors all over CCCL, like __return_constant (at least 2 occurrences)., equal_to_default_t (4 occurrences), always_true_predicate, equal_to_value, equal_to_t, always_false_t, always_true_t, etc. Sometimes, the definitions are slightly different. We should pick a general enough version of those and put them somewhere central, like <cuda/functional>. They can remain internal, but we may also consider making them public.
The motivation is twofold: cleaner code, but also more opportunity for optmization. cub::DeviceTransform for example can optimize if the predicate is exactly cub::detail::transform::always_true_predicate. Any other predicate type (with the same definition) will not lead to an optimal code path.
We repeatedly define common functors all over CCCL, like
__return_constant(at least 2 occurrences).,equal_to_default_t(4 occurrences),always_true_predicate,equal_to_value,equal_to_t,always_false_t,always_true_t, etc. Sometimes, the definitions are slightly different. We should pick a general enough version of those and put them somewhere central, like<cuda/functional>. They can remain internal, but we may also consider making them public.The motivation is twofold: cleaner code, but also more opportunity for optmization.
cub::DeviceTransformfor example can optimize if the predicate is exactlycub::detail::transform::always_true_predicate. Any other predicate type (with the same definition) will not lead to an optimal code path.