Hi Peter,

I'm forwarding your email to the PyCuda mailing list, to which you can 
subscribe at [1]. It may be a few days before I can look at this stuff, in the 
meantime I recall that the topic of GL interop cropped up there yesterday (or 
even today?). Maybe you guys can stick your heads together. I'll definitely 
try to help and merge a finished patch.

Andreas

[1] http://tiker.net/mailman/listinfo/pycuda_tiker.net

On Mittwoch 04 Februar 2009, Peter Berrington wrote:
> Hi, first let me say thanks for making PyCuda, it seems like a terrific
> project and I hope it continues to develop alongside CUDA.
>
> The reason why I am emailing is because I've hit an obstacle trying to
> refactor some code to use PyCuda. I have a python program which was using
> PyCairo to draw a series of triangles to a canvas, and then process them by
> comparing them to a source image. Using numpy this was fairly
> straightforward, however using cairo for drawing and numpy for math seemed
> incredibly slow, and so I was attempting to refactor my code for
> performance. It was simple enough to use PyOpenGL to draw the images, but
> I'm not sure how to access them for computation using PyCuda . I want to
> avoid unnecessarily sending image arrays back and forth between the video
> card and the system.
>
> There is a C example included in Nvidia's CUDA SDK called postProcessGL
> which includes the header "cuda_gl_interop.h". It looks like this header
> provides functions which allow you to access opengl pixel buffer objects
> directly without having to memcpy them anywhere. The functions required to
> do this aren't wrapped in PyCuda so I'm at a loss as to how to proceed. I
> know very little about boost but would it be possible to wrap these
> functions through pycuda? Is there another approach you can recommend that
> might make more sense?
>
> The specific functions used in postProcessGL are:
> cudaGLSetGLDevice(int device);
> cudaGLRegisterBufferObject(GLuint bufObj);
> cudaGLMapBufferObject(void **devPtr, GLuint bufObj);
> cudaGLUnmapBufferObject(GLuint bufObj);
> cudaGLUnregisterBufferObject(GLuint bufObj);
>
> Finally, if I am able to register the pixel buffer object for use by
> PyCuda, can you give me any advice on how I might reimplement my function
> for comparing image arrays? The code I was using previously to compare
> image buffers from cairo is included below; this code seems unnecessarily
> slow to me because it has to create and destroy a new array each time it is
> called; can you offer any suggestions as to how I can make this amenable to
> computation on a GPU?
>
> def rmse(first, second):
>     """ Returns the root mean square error between two image arrays. """
>     assert numpy.size(first) == numpy.size(second)
>     #the arrays are upscaled from 8bit uints to floats to avoid the
> values wrapping at 256
>     difference = numpy.diff(numpy.dstack(
>         (first.astype(numpy.float64),
>         second.astype(numpy.float64))))
>     return 1 - math.sqrt(numpy.mean(numpy.power(difference,2))) / 255.0
>
> Thanks for your time



Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
PyCuda mailing list
[email protected]
http://tiker.net/mailman/listinfo/pycuda_tiker.net

Reply via email to