CUDA texture shared between many kernels How do i share cuda textures between different files?

Hi there
I just upgraded to cuda 2.3 and encountered a problem.
I am writing a program where different kernels uses the same data source, which in this case is
stored in textures for cache performance.
Previuosly(cuda 2.1) i could declare the textures (1d,2d and 3d) in a seperat file (.cuh) and
then include this file in the every kernel file. This way i could have on .cu file pr kernel and still use
the textures. But this does not work any longer with cuda 2.3, and to get my program up and running i have
to paste all things into the same file(now its about 2000 lines of code Doh!!).
Is there a trick or a “right” way to do this, so i don’t have to battle with one giant .cu file that takes a long time to compile and
is very difficult to maintain?

All help is very appriciated

Peter Trier

your problem may be related to the one discussed here:
http://forums.nvidia.com/index.php?showtopic=102830

apparently there is some change/bug in 2.3 in which it is now required that binding and fetching occur within the same .cu file.

of course rather than making this literally one file, you can always #include “yourkernel.cu”. (so the compiler sees only one large file - you may have to also mark yourkernel.cu to not be compiled independently once it is included in another file, or you could get an error of redefining your functions.)