inclusive_scan_by_keys calls the 'sum' operator needlessly
- Dominant language
- C++
- Stars
- 2.5k
- Forks
- 486
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 295
Description
inclusive_scan_by_keys is called with a one-element keys vector. It should just copy the first input element to the output vector but in addition it invokes the 'sum' operator 4096 times!
Reproduction code (bug.cu)
```
#include
#include
#include
class Agg {
public:
__device__ int operator()(int x, int y) {
printf("%d %d\n", x, y);
return x + y;
}
};
int main(int argc, char** argv) {
auto partitions = thrust::device_vector(1, 0);
auto in = thrust::device_vector(1, 0);
auto out = thrust::device_vector(1, 0);
thrust::inclusive_scan_by_key(
partitions.begin(),
partitions.end(),
in.begin(),
out.begin(),
thrust::equal_to(),
Agg()
);
return 0;
}
```
Build
```
nvcc --std=c++14 -o bug bug.cu
```
Environment
```
CentOS 7 (Kernel 3.10.0-1160.el7.x86_64)
NVIDIA-SMI 470.82.01
Driver Version: 470.82.01
CUDA Version: 11.4
GPU: NVIDIA GeForce RTX 2060
```
Contributor guide
Assessment
This issue has not been assessed yet.