In mykernel.cu, still define:
texture< float, 1, cudaReadModeElementType> tex;
when calling mykernel(texture< float, 1, cudaReadModeElementType>& ), can I call this way:
mykernel(tex)
However, same warnings during the compiling.
During runtime, in mykernel(tex), when I call:
tex1D(tex, 1.0f)
It will crash with the following error:
First-chance exception at 0x7c812a5b in mykernel.exe: Microsoft C++ exception: cudaError at memory location 0x0012ec98
The address of tex is valid, but it is not able to yield its content.
My objective was to store constants in the texture and use them in the kernel. That way, the computation can be faster, I suppose.
cudaBindTexture is a host function, not a kernel.
The tex.xx instruction can only fetch from a constant ID. So passing a reference as parameter is obviously impossible.