I am passing in a 2D array as a cuda array into my kernel. I know that you can read cuda arrays only texture fetches, and I am doing this through tex2d(). But if I need to modify this data, how can I write to the 2D array? Just as a simple example, suppose I just want to square each element in the array. How can I write to cuda array?
I can’t find anything on the writing in the programming guide.
in your initialization function. Then pass devPtr to the kernel when you call it.
I wouldn’t. device variables are more trouble then they are worth. And you cannot dynamically choose the size, which makes them worthless in 99.999% of all cases.