Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEA]: Let block-algorithms take const arrays for input parameters #1296

Open
1 task done
pauleonix opened this issue Jan 18, 2024 · 0 comments
Open
1 task done

[FEA]: Let block-algorithms take const arrays for input parameters #1296

pauleonix opened this issue Jan 18, 2024 · 0 comments
Labels
feature request New feature or request.

Comments

@pauleonix
Copy link
Contributor

pauleonix commented Jan 18, 2024

Is this a duplicate?

Area

CUB

Is your feature request related to a problem? Please describe.

#include <cub/cub.cuh>

__global__ void foo() {
    const int tid = blockDim.x * blockIdx.x + threadIdx.x;
    const int gstride = blockDim.x * gridDim.x;

    const int thread_data[] = {tid, tid + gstride};

    typedef cub::BlockReduce<int, 128> BlockReduce;
    __shared__ typename BlockReduce::TempStorage temp_storage;
    const int aggregate = BlockReduce(temp_storage).Sum(thread_data);
}

does not compile because the interfaces by CUB take non-const arrays as input parameters. This prevents users from writing const-correct kernel functions using CUB block-scope algorithms. cub::BlockReduce::Sum is only one example. The same issue appears for basically all interfaces taking multiple input values as a C-style array including cub::StoreDirectBlocked and similar direct store functions.

Describe the solution you'd like

As confirmed by @gevtushenko in #1288, CUB's block-scope algorithms (in particular the overloads taking C arrays residing in registers or local memory) should take const-qualified arrays for input parameters.

Describe alternatives you've considered

Not writing const-correct kernel-functions can lead to bugs and makes code less readable.

Additional context

No response

@pauleonix pauleonix added the feature request New feature or request. label Jan 18, 2024
@github-project-automation github-project-automation bot moved this to Todo in CCCL Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request.
Projects
Status: Todo
Development

No branches or pull requests

1 participant