PBO and CUDA Texture

Hi, I’m having a strange problem using CUDA texture to read a PBO. Basically I want to read data from an OpenGL texture in CUDA, so I read the texture into a PBO and map it to CUDA. After that, in order to speed up data processing, I want to use CUDA texture fetching. Most of the examples and discussions I read suggest that I should copy the data to a CUDA array and then bind it to a texture. However, the texture is too big and I’m using too much GPU memory that it’s not possible for me to allocate a CUDA array of the size of my texture. As such, I try to bind the PBO to a CUDA texture through the linear pointer returned by cudaGLMapBufferObject(). I think this will provide me with a little speed up over accessing the global memory directly.

However, reading the PBO using texture fetching like this sometime gives me wrong reading. As such, I want to ask if any of you have experiencing a similar problem, if there is a way to fix that, or if it’s not possible to read a PBO through CUDA texture that way. Thanks a lot.

FYI, I’m using 16 bits 4 channels Integer Texture on N8800GTX with CUDA 1.1.

Hum… A colleague of mine would like to do something very similar. He’d like to be able to use a texture to use a vertex buffer, do something with the value, and write the result back to the vertex buffer mapped by CUDA. But according to you, it seems not to be possible. Could we have a confirmation from NVIDIA or from anyone else who already tried as well?

I’m not saying that it’s not possible. As I think, this should work fine, because a PBO mapped to CUDA global memory looks just like a block allocated by cudaMalloc. However I don’t know why using CUDA texture fetching gives me wrong value sometimes (very rare, like once every 10^9 fetch). Change back to using pointer works perfectly. Can it possibly be a driver issue, or maybe because of some special memory arrangement of the mapped PBO?

Sorry, I misunderstood. I thought you always had wrong reads with texture. But actually you only catch a wrong value once in a while… Curious. Maybe you could post the code, even if I don’t think you made a mistake, NVIDIA’s gonna need a simple code, that they can reproduce it if this is a bug. Or maybe someone will see something wrong.

Sounds like a bug somewhere, either your code or cuda. I assume you’re using a texture bound to linear memory and thus use tex1Dfetch()? How do you determine that an incorrect value is returned by a fetch? Minimize your code into a repro case - have each thread fetch from the index that produces the unexpected value and write it to gmem. Then please post the .cu file so that it can be compiled into an executable to verify the issue.

Paulius