thrust::uninitialized_copy(_n) gives a runtime error when mixing memories
- Dominant language
- C++
- Stars
- 2.5k
- Forks
- 487
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 296
Description
For example:
```cpp
auto src = std::allocator{}.allocate(3);
auto dst = thrust::cuda::allocator{}.allocate(3);
// thrust::copy_n(src, 3, dst); // this is ok
thrust::uninitialized_copy_n(src, 3, dst);
```
gives:
```cpp
thrust::system::system_error: uninitialized_copy_n: failed to synchronize: cudaErrorIllegalAddress: an illegal memory access was encountered
```
Using `thurst::copy(_n)` instead works.
I am using the `uninitialized_copy` because it is the natural function to use in generic code (of this library https://gitlab.com/correaa/boost-multi) when copy constructing arrays (from host to device).
For example:
```cpp
multi::array CPU = ...;
multi::array GPU{CPU};
// ^^^ "allocate[gpu] + uninit_copy[cpu->gpu]" seems more correct than "allocate[gpu] + copy[cpu->cpu]", generically speaking
// however uninit_copy seems to be more limited that copy in thrust.
```
I am using `nvcc 11.7` and `thrust 1.15`.
I understand that not all algorithms should work for all combinations of memory spaces (e.g. `thrust::equal(cpu, cpu + n, gpu)`) but I feel that `thurst::uninitialized_copy` should.
is this a defect in `thrust::uninitialized_copy(_n)` or is it by design?
Contributor guide
Assessment
This issue has not been assessed yet.