question about diagnosing texture reference problems

I am trying to debug a very annoying problem in a rather large program,
which has all the symptoms of a memory problem: I think that it is caused
by my overwriting memory that I did not intend to overwrite in the GPU. (I
did run cuda-memcheck by the way, and it did not see anything, nor does
valgrind on the host side, but moving on to my real questions…)

But the symptom is that the tex2d reference always returns 0. Now, I
happen to think that the reason it might be doing this is that I may have
clobbered the 2D array I created to hold the values, but I wonder:

  1. Other than the array for the texture map having values of zero, is there
    any other reason why a tex2D would return 0 ?

  2. What happens if the texture has not been set up properly ? what does
    it return in that case ?

  3. Is there any way from the GPU or host side to detect when a kernel tries
    to use an improperly set up texture map ? Is there an error bit somewhere,
    or a value that it could return ?

Hopefully this makes sense to somebody and can advise me.

Thank you again for your help …

MW

The problem turned out to be the problem of referencing texture maps
in more than one source file (eg .cu file). I had a perfectly compiled
program broken up logically by function, and that caused the problems.

You know guys, this could be better documented.

Also, could use some way of finding out there was an error, other
than just noting the results are wrong. See my question above.

Thank you,
MW