[PyCUDA] My modification to PyCUDA

Andreas Klöckner lists at informa.tiker.net
Mon Mar 1 11:47:30 PST 2010


Hi Daniel, all,

Complex number support is now in PyCUDA git. Please read below for how
it happened and what remains to be done--and please help get it done! :)

On Freitag 08 Januar 2010, Ying Wai (Daniel) Fan wrote:
> > I don't quite agree with your treatment of the complex scalars.
> > Couple possibilities:
> >
> > 1) We ship a "fixed" version of the struct module that can serialize
> > complex numbers.
> >
> > 2) struct can be fooled into serializing "2f" and get the real and imag
> > components separately.
> >
> > 3) We serialize numpy complex byte-for-byte via
> > buffer(numpy.complex(3j)), circumventing the need for
> > struct to understand complex.
> >
> > What do you think?
> 
> I think option 2 is better, as 

Not agreed.

> it requires less work to implement 

Not agreed.

> and thus less work to maintain

Not agreed at all. After some thinking, I've come to the conclusion
that this would require an endless string of workarounds and would make
PyCUDA's argument packing untenably slow.

> Hopefully, future versions of struct will support complex numbers.

They will (PEP 3118), but in a post-3.1 timeframe. [1]

I've implemented option 1. Shipping our own struct module will be
necessary from 2.7 onward anyway, until someone comes up with a better
solution. [2]

There is now complex number support in PyCUDA's mainline git, and this
will be in 0.94. I found it necessary to do this now to prevent
fragmenting PyCUDA into different versions--one that works with parret,
one that works with pycudafft, etc. In particular, I did not care too
much for your decision to release a forked PyCUDA without coordinating
with the mailing list.

I've landed this support, but for now it's somewhat less-than-perfect.
In particular, we need:

- proper implementations of .real and .imag.
- tests of all the cumath functions with complex numbers

If you rely on complex numbers in PyCUDA, PLEASE consider helping out
with one of these. Thanks!

Andreas

[1] http://bugs.python.org/issue3132
[2] http://bugs.python.org/issue1530559
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.tiker.net/pipermail/pycuda/attachments/20100301/2dcc2b1d/attachment-0001.pgp>


More information about the PyCUDA mailing list