-
Notifications
You must be signed in to change notification settings - Fork 757
"illegal memory access" when using a custom copy constructor with thrust::transform
#1578
Comments
Using a Also be aware that You may want to consider having a host-only container that maintains the lifetime of the |
Thank you for this pointer, that was eye-opening.
I understand that I guess my question here is what is
I have considered this solution as well, was trying to come up with a solution that had only one container. |
I found this interesting and played around a bit with your code. With CUDA 11.5, it seems to work if you declare your copy-constructor as host-device function, and use the flag
On my machine, this produces the following long output.
|
Very interesting to see the behavior of |
Not sure if this is a bug or intended behavior. I wrote this short working example that shows what I am trying to do;
The goal is to create a self-contained class that includes the shared_ptr/thrust vector within it, but be able to use that class on the GPU. And for that, I wrote a simple copy constructor that allows it to be used within a kernel. It works when I use it in a simple custom kernel or within a lambda operator that is called within a kernel. However, when I use
thrust::transform
to mimic the same behavior it results in an illegal memory access error. Is that the intended behavior? I was imagining transform shouldn't be doing anything complicated to make this cause the memory access error.Output
System information
$ nvcc --version nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2021 NVIDIA Corporation Built on Sun_Aug_15_21:14:11_PDT_2021 Cuda compilation tools, release 11.4, V11.4.120 Build cuda_11.4.r11.4/compiler.30300941_0 $ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.6 LTS Release: 18.04 Codename: bionic $ wsl.exe --status Default Distribution: Ubuntu-18.04 Default Version: 2 Windows Subsystem for Linux was last updated on 10/6/2021 WSL automatic updates are on. Kernel version: 5.10.60.1
The text was updated successfully, but these errors were encountered: