Closed GoogleCodeExporter closed 9 years ago
Sorry, this isn't really a defect, I couldn't see how to change it.
The compiler error is here:
error: no suitable constructor exists to convert from "float *" to
"thrust::device_vector<float, thrust::device_malloc_allocator<float>>"
I spent a long time looking for how to do this without creating a host vector
and then transferring to the device again (including documentation on the
device_vector) but I just can't seem to find it.
Original comment by JacobGMa...@gmail.com
on 2 Mar 2012 at 3:24
Hi Jacob,
For data that already resides on the GPU you don't need a device_vector at all,
just "wrap" the raw pointer with device_ptr, as illustrated in this example
[1]. You can use a pair of device_ptrs to initialize a device_vector too, but
keep in mind that will cost you a copy (and more memory) while wrapping the
pointer is basically free.
I believe device_ptr is discussed in the QuickStartGuide, though we could
probably give it some more emphasis. The GPU Computing Gems chapter about
Thrust [2] discusses this topic in the context of interoperability.
Anyway, I'll keep this issue open as a reminder to improve the docs/examples.
[1] http://code.google.com/p/thrust/source/browse/examples/cuda/wrap_pointer.cu
[2]
http://thrust.googlecode.com/files/Thrust%20-%20A%20Productivity-Oriented%20Libr
ary%20for%20CUDA.pdf
Original comment by wnbell
on 2 Mar 2012 at 4:02
Forwarded to https://github.com/thrust/thrust/issues/44
Original comment by jaredhoberock
on 7 May 2012 at 8:49
Original issue reported on code.google.com by
JacobGMa...@gmail.com
on 2 Mar 2012 at 3:22