Skip to content

[EPIC]: Env-based overloads implementation for all CUB device primitives #5635

Closed
20 of 20 issues completed
Closed

Description

@gonidelis

For every existing CUB device overload add an env-based counterpart that uses the new environment facilities from libcu++.

The goal is that we provide CUB device overloads that do not require explicit memory allocation which requires a 2-phase call. The existing CUB API looks like this:

void *d_temp_storage = nullptr;
size_t temp_storage_bytes = 0;

// First call: determine storage requirements
cub::DeviceScan::InclusiveSum(d_temp_storage, temp_storage_bytes, d_in, d_out, num_items, stream);

// Allocate storage
cudaMalloc(&d_temp_storage, temp_storage_bytes);

// Second call: actual algorithm execution
cub::DeviceScan::InclusiveSum(d_temp_storage, temp_storage_bytes, d_in, d_out, num_items, stream);

Working PRs for reference: #4877 #4985

When the new APIs are added CUB should allow for the users to call the primitives like this:

auto env = cuda::execution::require(cuda::execution::determinism::run_to_run);

// Single call: allocation and execution in one call
cub::DeviceReduce::Sum(input.begin(), output.begin(), input.size(), env);

The new environment argument should enable:

  1. access to deterministic requirements of the algorithm execution
  2. flexibility on the memory resource selection
  3. tuning without reaching for dispatch layer
  4. encapsulate the existing stream selection option

List of primitives that have been provided with env-based overloads

Activity

  1. changed the title [-][EPIC]: Tracking env-based overloads implementation for all CUB primitives[/-] [+][EPIC]: Track env-based overloads implementation for all CUB device primitives[/+] on Aug 22, 2025
  2. bdice commented on Dec 11, 2025

    @bdice
    Contributor

    @gonidelis asked for help prioritizing this. I did a quick analysis of usage in cuDF. Here are our priorities:

    CUB Device Algorithm Usage in libcudf

    Count Algorithm
    12 cub::DeviceReduce::Reduce
    10 cub::DeviceSegmentedReduce::Sum
    10 cub::DeviceRadixSort::SortPairs
    8 cub::DeviceMergeSort::SortKeysCopy
    8 cub::DeviceMemcpy::Batched
    4 cub::DeviceSegmentedSort::SortPairs
    4 cub::DeviceSegmentedReduce::Reduce
    4 cub::DeviceScan::InclusiveScan
    4 cub::DeviceScan::ExclusiveScan
    4 cub::DeviceRadixSort::SortPairsDescending
    4 cub::DeviceRadixSort::SortKeysDescending
    4 cub::DeviceRadixSort::SortKeys
    4 cub::DeviceCopy::Batched
    2 cub::DeviceSegmentedSort::StableSortPairsDescending
    2 cub::DeviceSegmentedSort::StableSortPairs
    2 cub::DeviceSegmentedSort::SortPairsDescending
    2 cub::DeviceSegmentedSort::SortKeys
    2 cub::DeviceScan::InclusiveSum
    2 cub::DeviceScan::InclusiveScanByKey
    2 cub::DeviceMergeSort::StableSortKeysCopy
    2 cub::DeviceMergeSort::SortPairsCopy
    2 cub::DeviceHistogram::HistogramEven
    1 cub::DeviceSelect::If

    Total: 97 usages across 23 distinct algorithms

  3. added theissue type on Jan 15, 2026
  4. 16 remaining items

  5. gonidelis commented on Apr 29, 2026

    @gonidelis
    MemberAuthor

    Full API is covered by env overloads. Follow-up iterations, improvements and missing bits will be taking place as part of #8175

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

Projects

  • Status
    Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions