texture memory to global memory

Hi,

I have a code that uses a texture memory(float array) and tex1DFetch to get the data.
Now, I want to remove texture code and convert it to global memory.

How can I do that? Is the index same with the index in tex1Dfetch call?
For example,

float *f;
//f bind to texture
tex1Dfetch(…,index)

Is f[index] correct if I remove the texture binding?

Please help me out if possible.
Thanks
Martin

You would want to examine how exactly the texture is bound. If the texture is bound to the start of the array pointed to by ‘f’, and if the offset returned by the binding operation is zero, then tex1Dfetch(…,index] is equivalent to f[index].

In the code, the first parameter is set to NULL. I think this is the offset that you are talking about. I changed it to an offset variable and got 0 in return.
Also, the device memory is allocated using cudaMalloc. I think I can access it using f[index].

I have one more question. Is it necessary to completely remove cudabindtexture?
Or I can access using f[index] even after binding?

thanks

Passing NULL as the first argument of a texture binding call is one of my pet peeves: a portability issue wainting to happen. It is good practice to actually retrieve the texture offset, and take appropriate action in case it is non-zero.

You do not have to remove the cudaBindTexture() but if you do not intend to use the texture at all you might as well avoid the overhead and clean up the code. By binding a texture you basically add another mapping for the same storage and this mapping uses a different hardware path to load data.