Hi Nathan,

On Sat, 2 Jul 2011 12:48:08 -0700, Nathan Hillier wrote:
I am currently working my way through the_ CUDA By Example _book,
porting to PyCuda as I go. I've reached the first example that makes
use of a struct. I'm a bit unsure of how to properly deal with this in
PyCuda. I followed the documentation as best I could, and I wrote a
kernel test out if my wrapper was working correctly. The kernel
executes without error, but fails to alter data in the struct. Code
follows, and isĀ attachedĀ for easy viewing in your favorite editor.

First of all, sorry for the long delay in responding. In my opinion, the right way of dealing with this would be to use numpy record arrays as Python-side stand-ins for structs. One might even write code to register their dtypes with PyCUDA, so that array code can work with them sort of automatically (although it's not clear how useful this latter bit would be). One useful component would be to have code that automatically spits out a C struct declaration for a given numpy dtype--that would minimize redundancy and thereby the chance for mistakes. In the past, I've cobbled together such a code generator that used the Python struct module, but I wouldn't recommend that--it was slow and painful. See code here:

https://github.com/inducer/cgen/blob/master/cgen/__init__.py#L343

Hope this helps,
Andreas


_______________________________________________
PyCUDA mailing list
[email protected]
http://lists.tiker.net/listinfo/pycuda

Reply via email to