NVIDIA / NVIDIA/cccl

[NV 2716223] `adjacent_difference` generates a warning (warning: calling a __host__ function from a __host__ __device__ function) with the OpenMP backend

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

Description

Using `thrust::adjacent_difference` with `thrust::omp::par` execution policy produces the warning

```
thrust/system/detail/generic/adjacent_difference.inl(73): warning: calling a __host__ function from a __host__ __device__ function is not allowed
detected during:
instantiation of "OutputIterator thrust::system::detail::generic::adjacent_difference(thrust::execution_policy &, InputIterator, InputIterator, OutputIterator, BinaryFunction) [with DerivedPolicy=thrust::system::omp::detail::par_t, InputIterator=__gnu_cxx::__normal_iterator>>, OutputIterator=__gnu_cxx::__normal_iterator>>, BinaryFunction=thrust::minus]"
```

when passing `std::vector` iterators.

Minimal example:
```
#include
#include
#include

#include

int main(){
std::vector a{0};
std::vector b{1};

thrust::adjacent_difference(thrust::omp::par, a.begin(), a.end(), b.begin());
auto k = thrust::min(a.begin(), b.begin());
thrust::sort(thrust::omp::par, a.begin(), a.end());
}
```

Code is compiled with `nvcc main.cu -Xcompiler "-fopenmp" -o main`.
Cuda compilation tools, release 10.1, V10.1.243
The latest thrust version from Github is used.

NVBug 2716223

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.