I have a CUarray that I got from my OpenGL-context via cuGraphicsSubResourceGetMappedArray(). Is there a possiblity to use it with cuMemset*()?
Asked
Active
Viewed 1,204 times
1 Answers
4
Nope. You can't get a device pointer into a CUDA array (to pass to cuMemset*()), and NVIDIA has never shipped a memset function for CUDA arrays.
You have to zero out some host memory and do a memcpy (or memcpy's) into the CUDA array, or (if your app runs only on SM 2.0 or later) roll your own with surface stores.

ArchaeaSoftware
- 4,332
- 16
- 21
-
Thank you! What do you mean with the second proposal "roll your own with surface stores"? Do you mean writing a kernel that uses surf3Dwrite to clear the array? – morph Aug 14 '12 at 07:30
-
Yes, that is just what I was proposing - and happily, because surface load/store are untyped, you can write a templated function to store any size operand. See section 10.9.2 in the Texturing chapter of the CUDA handbook for an example in 2D. http://www.cudahandbook.com/uploads/Chapter_10._Texturing.pdf – ArchaeaSoftware Aug 15 '12 at 01:29
-
2Thanks! I implemented both methods and prefer the cuMemcpyAtoA-method over the kernel because it runs significantly faster! – morph Aug 15 '12 at 15:14
-
1If your CUDA array is attached to a renderbuffer or a texture that is part of a framebuffer object in OpenGL you could also initialize it by rendering `glClear(
,...)`. This is the approach I've used and it seems to run very quickly. – matth Jan 13 '15 at 06:12