Hi,
I am running a kernel which accesses memory using textures, on two GPUs. I am using the standard way of using textures, that is declare the texture as global variable and then do a tex1Dfetch in the kernel. Since I am using multiple GPUs, therefore multiple threads, and the texture is a global variable, this leads to racing conditions.
Since I don’t know a way to do this without using a global variable, I declared a vector of textures, which I index using a thread-local variable. Therefore the declaration
texture<int, 1, cudaReadModeElementType> tex;
became
texture<int, 1, cudaReadModeElementType> tex[2];
and the access became from
tex1Dfetch(tex,p)
became
tex1Dfetch(tex[current_thread],p)
The problem is that this does not compile. I am getting the following error:
error: a value of type "_Z7textureIiLi1EL19cudaTextureReadMode0EE" cannot be assigned to an entity of type "__i1texture"
iBeg = (((__T237 = ((tex[current_thread]))) , ((__T239 = (__itexfetchi(__T237, ((((((__T238.x) = i) , ((__T238.y) = 0)) , ((__T238.z) = 0)) , ((__T238.w) = 0)) , __T238)))) , ((__T239.x)))) - 1);
Thinking that there might be some weird problem with using vectors of textures, I put the texture in a structure, and then indexed that with the thread index. But I am getting the same error …
Does someone have any idea how to solve this? Or maybe a way to use textures without using a global variable ?
Thanks,
Serban