I was wondering if I could get a couple of examples that implement textures. I have tried writing many different kernels in an attempt to get a high texture cache hit ratio, but I always seem to get 0 texture cache hits and 100% misses.
Any thoughts or suggestions?
For a little more information, I am using cudaArrays which are allocated with cudaMalloc3DArray. Textures are bound with cudaBindTextureToArray.
Sorry to be a pain, and thanks in advance for any help,
Yes, I have taken a look at them but there is a couple of things that I don’t like about them. First off, they don’t provide any rational for why they access textures the way they do and best practices. Another reason is that they are overly complicated. All I am really looking for is if someone has some small example code I could use.
I was wondering if anyone has any updates? I have looked at the NVidia samples, but cannot figure out the trick to getting a good texture cache hit ratio.
Sorry to be a pain and thanks in advance,
Unfortunately, there doesnt seem to be any good examples of the use (or at least the initialization
from the host of 3D arrays/textures. This is really unfortunate, because what is clear is that the
initialization and use of 3D arrays/textures is not intuitive, has clearly been hacked, or more politely
“evolved organically” over time, and without explicit documentation or examples, I cant figure it out.
simpleTexture3D in particular reads the initialization data in binary form from a preformatted file, which
is NOT HELPFUL in explaining how the data should be organized.
That’s easier to answer… you put the data in a 1D array, running the x index fastest. Then, cudaMemcpy3D to a cudaArray. Then, bind the texture to the array. When reading, the main trick is remembering that values are assumed to lie at the voxel centres. So, if you want to read the exact value you wrote, you have to add 0.5 to the co-ordinates.