NVIDIA / NVIDIA/cccl

Device-side launch of thrust::lower_bound is creating wrong results

Open
#814 11 comments 0 reactions 0 assignees View on GitHub
thrust
Dominant language
C++
Stars
2.5k
Forks
486
Avg merge
2d 6h
Merged PRs (30d)
295

Description

```C++
#include
#include
#include

__global__ void lowerbound(float inp_val) {
constexpr int size = 6;
float a[size] = {0.1, 0.2, 0.4, 0.6, 0.8, 1.};
auto result = thrust::lower_bound(
thrust::device, a, a + size, inp_val);
printf("%ld\n", result - a);
}

int main() {
lowerbound<<<1,1>>>(0.0);
lowerbound<<<1,1>>>(0.1);
lowerbound<<<1,1>>>(0.2);
lowerbound<<<1,1>>>(0.3);
lowerbound<<<1,1>>>(0.4);
lowerbound<<<1,1>>>(0.5);
cudaDeviceSynchronize();
}
```
I get
```
0
0
0
0
0
0
```
on CUDA 11.7 with the latest thrust

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.