Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CUDA texture memory space

When I bind an array to a texture in CUDA,

  1. is that array copy to a texture space? or,
  2. is that array reference as a texture?

If the answer is 1., then i can bind a texture and safety fetch data from the texture memory space while I write the result to the array, which is allocated in global memory.

If the answer is 2., then, is the texture memory a global memory space where the data is cached and spatially fetched?

I'd like to know about this topic, as I've seen some question related to this topic and I've not the answer clear right now.

Thanks in advance.

like image 582
pQB Avatar asked Jul 11 '11 09:07

pQB


1 Answers

The answer is the second option, but from there things get a little more complex. There is no such thing as "texture memory", just global memory which is accessed via dedicated hardware which include an on GPU read cache (6-8kb per MP depending on card, see table F-2 in Appending F of Cuda Programming Guide) and a number of hardware accelerated filtering/interpolation actions. There are two ways the texture hardware can be used in CUDA:

  1. Bind linear memory to a texture and read from it in a kernel using the 1D fetch API. In this case the texture hardware is really just acting as a read-through cache, and (IIRC) there are no filtering actions available.
  2. Create a CUDA array, copy the contents of linear memory to that array, and bind it to a texture. The resulting CUDA array contains a spatially ordered version of the linear source, stored in global memory in some sort of (undocumented) space filling curve. The texture hardware provides cached access to that array, include simultaneous memory reads with hardware accelerated filtering.

You might find the overview of the GT200 architecture written by David Kanter worth reading to get a better idea of how the actual architecture implements the memory hierarchy the APIs expose.

like image 200
talonmies Avatar answered Sep 20 '22 13:09

talonmies