cudaArrays: how to use them?

Hi,
i’m trying to use as a kernel destination (writing only) an array obtained from a d3d9 texture… but i can’t figure how to use it correctly as a destination for my kernels!
If i just cast it to void* to use it as plain memory, it works (why?) but sometimes a section of the texture becomes black and unwritable.
Also, the order of writes is sometimes altered, as for example it generates a grayscale if i output the scaled index, but doesn’t work for example with the modulo operator.

Now i resolved the problem writing to plain memory and then doing a device<->device cudamemcpy… but i would like to know what are pros and cons of arrays (i read that it is very slow to write on them?) and why of the unpredictable result…

Thanks!

If I understand what you’re trying to do correctly… you can’t. cudaArrays are opaque objects. You can use cudaMemcpyToArray to put data into them, and you can read the data via textures. But you can’t write to them ‘normally’ and expect comprehensible results.

I don’t believe you are supposed to be able to use CUDA arrays directly like that. The fact you almost can is pretty interesting, but they are supposed to be used purely as data sources for textures.

Uhm so the cudaMemcpyToArray2d is the only way to correctly do that, and i should use arrays only for reading?
Too bad that i have really few read-only buffers…
Is there a way to get a pointer to plain memory for d3d9 textures instead? cudaMemcpy is not really a problem as it’s fast, but still uses twice the memory.