You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unify accumulator type handling across CUB/Thrust #3993
I vaguely remember that not every reduce or scan algorithm uses ::cuda::std::__accumulator_t to determine the accumulator type to use. We should consolidate this behavior.
I had another look and realized that the C++ standard seems to determine the accumulator type to either be the iterator value type or the initial value type. So it seems the divergence between CUB and Thrust is fine.
This is also related and relevant to SIMD reduction. Using cuda::std::plus<> vs. cuda::std::plus<T> could affect performance. e.g. cuda::std::plus<> applied to int16_t induces implicit promotion which disables SIMD
I discussed this again with @gevtushenko today, because it came up in #8495. We want to move Thrust's behavior to CUB, but this is a breaking change. A user could pass a lambda with a __device__ operator() as scan operator, for which accumulator_t would fail to determine the return type, which is a source breaking change. So we need to wait until CCCL 4.0.
Specifically, we should change the Thrust scan backend to call the public CUB API.
Activity
bernhardmgruber commentedon Mar 5, 2025
@gevtushenko said there is divergence between CUB and Thrust. CUB uses
__accumulator_t, whereas Thrust uses the type of the initial value.bernhardmgruber commentedon Mar 5, 2025
I had another look and realized that the C++ standard seems to determine the accumulator type to either be the iterator value type or the initial value type. So it seems the divergence between CUB and Thrust is fine.
fbusato commentedon Mar 5, 2025
This is also related and relevant to SIMD reduction. Using
cuda::std::plus<>vs.cuda::std::plus<T>could affect performance. e.g.cuda::std::plus<>applied toint16_tinduces implicit promotion which disables SIMDbernhardmgruber commentedon Apr 20, 2026
I discussed this again with @gevtushenko today, because it came up in #8495. We want to move Thrust's behavior to CUB, but this is a breaking change. A user could pass a lambda with a
__device__ operator()as scan operator, for whichaccumulator_twould fail to determine the return type, which is a source breaking change. So we need to wait until CCCL 4.0.Specifically, we should change the Thrust scan backend to call the public CUB API.
fbusato commentedon Apr 20, 2026
I started this work in
but probably the PR is too old to be recovered