Closed ergawy closed 7 years ago
On master I get a different assertion:
Assertion failed: (I != ValueMap.end() && "Value not in slotcalculator!"), function getValueID, file llvm/lib/Bitcode/Writer/ValueEnumerator.cpp, line 135.
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 func_in_kernel(aStruct.memberVar);
), and the aStruct is defined outside this kernel.
My silly workaround currently is:
// before calling kernel
let varToUse = aStruct.memberVar;
// in kernel
func_in_kernel(varToUse);
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.
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.