CUDA texture memory space
When I bind an array to a texture in CUDA,
- is that array copy to a texture space? or,
- 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.
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:
- 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.
- 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.
精彩评论