[BUG]: `reduce_by_key` fails with zip_iterator to const pointers
Is this a duplicate?
- [X] I confirmed there appear to be no duplicate issues for this bug and that I agree to the Code of Conduct
Type of Bug
Compile-time Error
Component
Thrust
Describe the bug
The following code fails to compile with CUDA 12.4 (tracked by upstream issue https://github.com/ginkgo-project/ginkgo/issues/1564)
#include <thrust/execution_policy.h>
#include <thrust/iterator/zip_iterator.h>
#include <thrust/reduce.h>
#include <thrust/tuple.h>
void sum_duplicates(int size) {
const int *rows{};
const int *cols{};
const float *in_vals{};
int *out_rows{};
int *out_cols{};
float *out_vals{};
auto in_locs = thrust::make_zip_iterator(thrust::make_tuple(rows, cols));
auto out_locs =
thrust::make_zip_iterator(thrust::make_tuple(out_rows, out_cols));
thrust::reduce_by_key(thrust::device, in_locs, in_locs + size, in_vals,
out_locs, out_vals);
}
Noteworthy: The issue goes away when the pointers are int* instead of const int*
How to Reproduce
- call
nvcc file.cu
Expected behavior
The code compiles (as it did with CUDA <= 12.3)
Reproduction link
No response
Operating System
Ubuntu 22.04
nvidia-smi output
No response
NVCC version
nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2024 NVIDIA Corporation Built on Tue_Feb_27_16:19:38_PST_2024 Cuda compilation tools, release 12.4, V12.4.99 Build cuda_12.4.r12.4/compiler.33961263_0
A possible workaround here is to const_cast the inputs, but I would like to hear if there is a less "unsafe" workaround we can apply.
Are you building against current main or a specific branch?
I just checked, the issue is still present in main
@upsj Thanks a lot for the bug report. I opened a PR with a fix and added your reproducer to out test suite
That was quick, thank you very much!