Hi Daniel, To be honest, I'd much prefer an overloaded 'complex' class over just "float2", which could mean any number of things. I.e. this would be just like std::complex (which we can't use directly since nvcc doesn't like it).
I've prototyped this based on STLPort's [1] excellent complex arithmetic class in a new branch 'complex' in PyCUDA's git. Check out 'examples/demo_complex.py'. This needs some work before it's ready for prime time, but I think it might be a better way forward. What do you think? Andreas [1] License is MIT-compatible, I think? Any lawyers? On Donnerstag 24 Dezember 2009, Ying Wai (Daniel) Fan wrote: > Hi, > > Regarding my complex arithmetic wrapper (complex.py) posted previously > on this mailing list, the following changes need to be made to make it > work. One usage scenario of the wraper is arithmetic operations on the > output of CUFFT, which is in float2 datatype on the GPU. > > diff --git a/pycuda/tools.py b/pycuda/tools.py > index f91a6d5..d7af3a9 100644 > --- a/pycuda/tools.py > +++ b/pycuda/tools.py > @@ -371,6 +371,8 @@ def dtype_to_ctype(dtype, with_fp_tex_hack=False): > return "fp_tex_double" > else: > return "double" > + elif dtype == numpy.complex64: > + return "float2" > else: > raise ValueError, "unable to map dtype '%s'" % dtype > > @@ -447,6 +449,7 @@ def parse_c_arg(c_arg): > elif tp in ["char"]: dtype = numpy.int8 > elif tp in ["unsigned char"]: dtype = numpy.uint8 > elif tp in ["bool"]: dtype = numpy.bool > + elif tp in ["float2"]: dtype = numpy.complex64 > else: raise ValueError, "unknown type '%s'" % tp > > return arg_class(dtype, name) > > Daniel >
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ PyCUDA mailing list PyCUDA@tiker.net http://tiker.net/mailman/listinfo/pycuda_tiker.net