[PyCUDA] Complex reduction problem

Frank D. Lind flind at haystack.mit.edu
Mon Nov 29 14:04:40 PST 2010


Hi,

I'm attempting to use complex numbers in a reduction. It appears that 
complex numbers are not allowed as return values from reductions.

A simple example using gpuarray and the sum reduction:


import pycuda
import pycuda.gpuarray
import pycuda.autoinit
import pycuda.driver as drv
import numpy

a = numpy.random.randn(100).astype(numpy.complex64)
b = numpy.random.randn(100).astype(numpy.complex64)

a_gpu = pycuda.gpuarray.to_gpu(a)
b_gpu = pycuda.gpuarray.to_gpu(b)


gpu_result = pycuda.gpuarray.sum(a_gpu * b_gpu.conj())

result = numpy.dot(a,b.conj())

print gpu_result - result


results in a compile problem :


*** compiler output in /tmp/tmp9FkFFC
Traceback (most recent call last):
   File "test_muladd.py", line 15, in <module>
     gpu_result = pycuda.gpuarray.sum(a_gpu * b_gpu.conj())
   File 
"/usr/local/midas/baseline/2010/python-2.6.2/pkg/lib/python2.6/site-packages/pycuda-0.94.2-py2.6-linux-x86_64.egg/pycuda/gpuarray.py", 
line 977, in sum
     krnl = get_sum_kernel(dtype, a.dtype)
   File "<string>", line 2, in get_sum_kernel
   File 
"/usr/local/midas/baseline/2010/python-2.6.2/pkg/lib/python2.6/site-packages/pycuda-0.94.2-py2.6-linux-x86_64.egg/pycuda/tools.py", 
line 485, in context_dependent_memoize
     result = func(*args)
   File 
"/usr/local/midas/baseline/2010/python-2.6.2/pkg/lib/python2.6/site-packages/pycuda-0.94.2-py2.6-linux-x86_64.egg/pycuda/reduction.py", 
line 271, in get_sum_kernel
     keep=True)
   File 
"/usr/local/midas/baseline/2010/python-2.6.2/pkg/lib/python2.6/site-packages/pycuda-0.94.2-py2.6-linux-x86_64.egg/pycuda/reduction.py", 
line 188, in __init__
     preamble=preamble)
   File 
"/usr/local/midas/baseline/2010/python-2.6.2/pkg/lib/python2.6/site-packages/pycuda-0.94.2-py2.6-linux-x86_64.egg/pycuda/reduction.py", 
line 163, in get_reduction_kernel_and_types
     name, keep, options, preamble)
   File 
"/usr/local/midas/baseline/2010/python-2.6.2/pkg/lib/python2.6/site-packages/pycuda-0.94.2-py2.6-linux-x86_64.egg/pycuda/reduction.py", 
line 147, in get_reduction_module
     return SourceModule(src, options=options, keep=keep)
   File 
"/usr/local/midas/baseline/2010/python-2.6.2/pkg/lib/python2.6/site-packages/pycuda-0.94.2-py2.6-linux-x86_64.egg/pycuda/compiler.py", 
line 238, in __init__
     arch, code, cache_dir, include_dirs)
   File 
"/usr/local/midas/baseline/2010/python-2.6.2/pkg/lib/python2.6/site-packages/pycuda-0.94.2-py2.6-linux-x86_64.egg/pycuda/compiler.py", 
line 228, in compile
     return compile_plain(source, options, keep, nvcc, cache_dir)
   File 
"/usr/local/midas/baseline/2010/python-2.6.2/pkg/lib/python2.6/site-packages/pycuda-0.94.2-py2.6-linux-x86_64.egg/pycuda/compiler.py", 
line 107, in compile_plain
     cmdline, stdout=stdout, stderr=stderr)
pycuda.driver.CompileError: nvcc compilation of /tmp/tmp9FkFFC/kernel.cu 
failed
[command: nvcc --cubin -arch sm_20 
-I/usr/local/midas/baseline/2010/python-2.6.2/pkg/lib/python2.6/site-packages/pycuda-0.94.2-py2.6-linux-x86_64.egg/pycuda/../include/pycuda 
--keep kernel.cu]
[stderr:
kernel.cu(7): error: name followed by "::" must be a class or namespace 
name

kernel.cu(7): error: expected an identifier

kernel.cu(7): error: expected a ";"

kernel.cu(11): warning: invalid attribute for variable 
"reduce_kernel_stage1"

kernel.cu(11): error: incomplete type is not allowed

kernel.cu(11): error: identifier "out_type" is undefined

kernel.cu(11): error: identifier "out" is undefined

kernel.cu(11): error: expected a ")"

kernel.cu(13): error: expected a ";"

kernel.cu(36): warning: parsing restarts here after previous syntax error

kernel.cu(40): error: expected a declaration

kernel.cu(45): error: expected a declaration

kernel.cu(49): error: expected a declaration

kernel.cu(61): warning: parsing restarts here after previous syntax error

kernel.cu(64): error: expected a declaration

12 errors detected in the compilation of "kernel.cpp4.ii".
]

This may need a fix.

-- Frank Lind
-------------- next part --------------
A non-text attachment was scrubbed...
Name: flind.vcf
Type: text/x-vcard
Size: 333 bytes
Desc: not available
URL: <http://lists.tiker.net/pipermail/pycuda/attachments/20101129/233833a2/attachment.vcf>


More information about the PyCUDA mailing list