I am a bit confused with textures. I have too many parameters for a kernel that I am passing them in a structure. Those variables that are not textures do not give me any trouble. But I seem to be having some trouble with those that are bound to textures. The process I am using is as follows;
declare structures containing parameters on host and device
create structure parameters on device
assign parameters to host structure
cudaMemcopy host structure to device structure
(This works because I have done it with non-texture parameters)
Before calling the kernel in file a.cu I calculate the thread grid and bind parameter s from the structure to texture sTex via
cudaBindTexture(0, sTex, parameters->s,numBodies*sizeof(float));
I then pass the structure to the kernel, execute the kernel then unbind sTex.
The kernel and texture are defined in a separate file b.cu. In the kernel code I refer to the texture as follows
parameters->sorted_s[index] = FETCH(s, sortedData.y);
But in doing this I get a segmentation fault.
When I refer to the texture in the kernel as follows
parameters->new_s[index] = FETCH(parameters->s, sortedData.y);
I get the compile error that the parameters structure does not contain sTex.
So my question is, if the texture is defined in the same file as the kernel and the kernel call and texture binding are in a different file then do I have to pass the bound variable or the texture, and if using a structure then how should the texture be referenced and dereferenced?