-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runtime error passing mutable variable to a kernel function #51
Comments
On master I get a different assertion:
|
I had met a lot the second compile error long times ago(only support pointer of array as kernel arg). It happens if you try to use a member variable of a struct in the kernel(e.g. calling My silly workaround currently is:
Hope this information helps :) |
The struct issue was a known issue for which we used the "magic_id" hack as a workaround. However, this is fixed on master since some time (one/two months or so). The problem here is a pattern that is not allowed in CUDA/OpenCL: modifying a "host variable" on the GPU. The proper solution would be to:
Nevertheless, we should have a look at this. |
Thanks Fanyu for your help. Actually, yes, I agree with Richard. Passing a mut struct from host to device should be seen as a bad practice. I didn't mean to modify the host variable on the device. The thing is, I modified the host variable twice before passing it to the device that's why I needed to make mut. In that case, I guess it would be better to use pure functional form and pass the variable to the host function that modifies it. Then make the host function return a new struct that is received in an immutable variable. |
Add %core.conv and %core.bitcast axioms
The following code:
causes the runtime error:
This only happens if d is mut. If it is immutable it compiles fine.
Sometimes, the same thing causes another runtime error:
However, I couldn't reproduce this same issue in a stand alone example outside my code. If it is of any help, I can try to find out when either of the errors happen exactly.
The text was updated successfully, but these errors were encountered: