Skip to content

Unify accumulator type handling across CUB/Thrust #3993

Open

Description

@bernhardmgruber

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.

Activity

  1. bernhardmgruber commented on Mar 5, 2025

    @bernhardmgruber
    ContributorAuthor

    @gevtushenko said there is divergence between CUB and Thrust. CUB uses __accumulator_t, whereas Thrust uses the type of the initial value.

  2. bernhardmgruber commented on Mar 5, 2025

    @bernhardmgruber
    ContributorAuthor

    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.

  3. fbusato commented on Mar 5, 2025

    @fbusato
    Contributor

    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

  4. bernhardmgruber commented on Apr 20, 2026

    @bernhardmgruber
    ContributorAuthor

    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.

  5. fbusato commented on Apr 20, 2026

    @fbusato
    Contributor

    I started this work in

    but probably the PR is too old to be recovered

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

  • Status
    Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions