Re: [PyCUDA] Are sin/log supported for complex number (0.94rc)? Odd results...
Ok, I'll expand on the previous bug report. I'm running 0.94rc HEAD on both my MacBook (CUDA 2.3, Leopard, Python 2.5, gcc) and Windows XP machine (CUDA 2.3, Python 2.6, Microsoft Visual Studio 2008/VS9). In the previous email I stated 'VC8' - that's wrong, I'm using Visual Studio 2008 AKA VS9. I also stated that all complex demos crash on Windows, that's also wrong. The older demos work fine, it is only the new functions that cause a problem. I'm going to continue investigating on Monday, I'll just state the current situation in case anyone can shed light on it. On both the Mac and Windows the older complex demos (demo_complex.py, mandelbrot.py [wiki]) work fine. On both the Mac and Windows I can use cumath.exp(numpy.compex64(...)) and cumath.log(numpy.complex64(...)) just fine along with the ElementwiseKernel equivalent (i.e. using exp and log in the ElementwiseKernel given in my first email). On my Mac I can also now use: sin, tan, sinh, pow (with a float second arg), exp, sqrt which is awesome (many thanks Andreas). On Windows with VS9 these functions cause a compiler error. I've read pycuda-complex-impl.hpp for the last few hours and I can't see any obvious problems (and the same code works fine on the Mac) so I'm a touch stumped. Here's an example: # complex_test.py import pycuda.driver as drv import pycuda.autoinit import pycuda.gpuarray as gpuarray import pycuda.cumath import numpy a = numpy.array(numpy.complex64(1-1j)) a_gpu = gpuarray.to_gpu(a) # works with exp and log, fails with sin etc print pycuda.cumath.sin(a_gpu) # should produce (1.29-0.63j) And this results in: C:\Panalytical\pycuda_git\pycuda0.94\examplespython complex_test.py kernel.cu C:/Python26/lib/site-packages/pycuda-0.94rc-py2.6-win32.egg/pycuda/../include/pycuda\pycuda-complex-impl.hpp(350) : fata l error C1001: An internal error has occurred in the compiler. (compiler file 'msc1.cpp', line 1411) To work around this problem, try simplifying or changing the program near the locations listed above. Please choose the Technical Support command on the Visual C++ Help menu, or open the Technical Support help file for more information Internal Compiler Error in C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\cl.exe. You will be prompted to send an error report to Microsoft later. C:\DOCUME~1\parc\LOCALS~1\Temp\tmpxft_0fb8_-6_kernel.cpp1.ii The process cannot access the file because it is being used by another process. Traceback (most recent call last): File complex_test.py, line 14, in module print pycuda.cumath.sin(a_gpu) # should produce (1.29-0.63j) File C:\Python26\lib\site-packages\pycuda-0.94rc-py2.6-win32.egg\pycuda\cumath.py, line 14, in f func = elementwise.get_unary_func_kernel(func_name, array.dtype) File string, line 1, in lambda File C:\Python26\lib\site-packages\pycuda-0.94rc-py2.6-win32.egg\pycuda\tools.py, line 484, in context_dependent_mem oize result = func(*args) File C:\Python26\lib\site-packages\pycuda-0.94rc-py2.6-win32.egg\pycuda\elementwise.py, line 486, in get_unary_func_ kernel %s_kernel % func_name) File C:\Python26\lib\site-packages\pycuda-0.94rc-py2.6-win32.egg\pycuda\elementwise.py, line 99, in get_elwise_kerne l arguments, operation, name, keep, options, **kwargs) File C:\Python26\lib\site-packages\pycuda-0.94rc-py2.6-win32.egg\pycuda\elementwise.py, line 85, in get_elwise_kerne l_and_types keep, options, **kwargs) File C:\Python26\lib\site-packages\pycuda-0.94rc-py2.6-win32.egg\pycuda\elementwise.py, line 74, in get_elwise_modul e options=options, keep=keep) File C:\Python26\lib\site-packages\pycuda-0.94rc-py2.6-win32.egg\pycuda\compiler.py, line 226, in __init__ arch, code, cache_dir, include_dirs) File C:\Python26\lib\site-packages\pycuda-0.94rc-py2.6-win32.egg\pycuda\compiler.py, line 216, in compile return compile_plain(source, options, keep, nvcc, cache_dir) File C:\Python26\lib\site-packages\pycuda-0.94rc-py2.6-win32.egg\pycuda\compiler.py, line 107, in compile_plain cmdline, stdout=stdout, stderr=stderr) pycuda.driver.CompileError: nvcc compilation of c:\docume~1\parc\locals~1\temp\tmpehg6bh\kernel.cu failed [command: nvcc --cubin -arch sm_11 -IC:\Python26\lib\site-packages\pycuda-0.94rc-py2.6-win32.egg\pycuda\..\include\pycud a kernel.cu] I suspect that for some reason a number of the functions (sin, tan, singh, pow, sqrt etc) are not being recognised by the compiler - if I put in a nonsense name (e.g. sinfhfhfhfhf) then I get the same error, if I miss out a function name then I get the same error. If anyone has suggestions I'd be happy to hear them! Cheers, Ian. On 7 May 2010 14:57, Ian Ozsvald i...@ianozsvald.com wrote: Much obliged Andreas - on my MacBook I confirm that: a = numpy.array(numpy.complex64(1-1j)) # make list of 1 complex element a_gpu = gpuarray.to_gpu(a) print pycuda.cumath.sin(a_gpu) # will print (1.29-0.63j) now prints out the sin (and log) of a complex
Re: [PyCUDA] Are sin/log supported for complex number (0.94rc)? Odd results...
On Montag 19 April 2010, Ian Ozsvald wrote: I find myself out of my depth again. I'm playing with complex numbers using 0.94rc (on Windows XP with CUDA 2.3). I've successfully used simple operations (addition, multiplication) on complex numbers, that resulted in the Mandelbrot example in the wiki. Now I'm trying sin and log and I'm getting errors and one positive result (see the end). I'm not sure if these functions are supported yet? If anyone can point me in the right direction (and perhaps suggest what needs implementing) then I'll have a go at fixing the problem. For reference, you can do the following using numpy on the CPU for verification: In [117]: numpy.sin(numpy.array(numpy.complex64(1-1j))) Out[117]: (1.2984576-0.63496387j) Here are two pieces of test code. At first I used multiplication (rather than sin()) to confirm that the code ran as expected. Next I tried creating a simple complex64 array, passing it to the GPU and then asking for pycuda.cumath.sin() - this results in Error: External calls are not supported. Here's the code and error: Fixed/added in git, both for cumath and elwise. I replaced: pycuda.cumath.sin(a_gpu) # should produce (1.29-0.63j) with: pycuda.cumath.log(a_gpu) # should produce (0.34-0.78j) and the code ran without an error...but produced the wrong result. It generates (1-1j) which looks like a no-op. cumath ops aren't in-place--you need to print the returned value. HTH, Andreas signature.asc Description: This is a digitally signed message part. ___ PyCUDA mailing list PyCUDA@tiker.net http://lists.tiker.net/listinfo/pycuda
[PyCUDA] Are sin/log supported for complex number (0.94rc)? Odd results...
I find myself out of my depth again. I'm playing with complex numbers using 0.94rc (on Windows XP with CUDA 2.3). I've successfully used simple operations (addition, multiplication) on complex numbers, that resulted in the Mandelbrot example in the wiki. Now I'm trying sin and log and I'm getting errors and one positive result (see the end). I'm not sure if these functions are supported yet? If anyone can point me in the right direction (and perhaps suggest what needs implementing) then I'll have a go at fixing the problem. For reference, you can do the following using numpy on the CPU for verification: In [117]: numpy.sin(numpy.array(numpy.complex64(1-1j))) Out[117]: (1.2984576-0.63496387j) Here are two pieces of test code. At first I used multiplication (rather than sin()) to confirm that the code ran as expected. Next I tried creating a simple complex64 array, passing it to the GPU and then asking for pycuda.cumath.sin() - this results in Error: External calls are not supported. Here's the code and error: import pycuda.driver as drv import pycuda.autoinit import pycuda.gpuarray as gpuarray import pycuda.cumath import numpy a = numpy.array(numpy.complex64(1-1j)) # make list of 1 complex element a_gpu = gpuarray.to_gpu(a) pycuda.cumath.sin(a_gpu) # should produce (1.29-0.63j) print a_gpu.get() In [62]: %run complex_test.py kernel.cu tmpxft_0840_-3_kernel.cudafe1.gpu tmpxft_0840_-8_kernel.cudafe2.gpu ./kernel.cu(19): Error: External calls are not supported (found non-inlined call to _ZN6pycuda3sinERKNS_7complexIfEE) --- CompileError Traceback (most recent call last) 16 a = numpy.array(numpy.complex64(1-1j)) # make list of 1 complex element 17 a_gpu = gpuarray.to_gpu(a) --- 18 pycuda.cumath.sin(a_gpu) # should produce (1.29-0.63j) I replaced: pycuda.cumath.sin(a_gpu) # should produce (1.29-0.63j) with: pycuda.cumath.log(a_gpu) # should produce (0.34-0.78j) and the code ran without an error...but produced the wrong result. It generates (1-1j) which looks like a no-op. Next I tried similar functionality using sin() in an ElementwiseKernel, this generates the same Error: External calls are not supported problem: import pycuda.driver as drv import pycuda.autoinit import pycuda.gpuarray as gpuarray import pycuda.cumath import numpy from pycuda.elementwise import ElementwiseKernel complex_gpu = ElementwiseKernel ( pycuda::complexfloat *z, z[i] = sin(z[i]);, complex_fn, #include pycuda-complex.hpp, ) a = numpy.array(numpy.complex64(1-1j)) # make list of 1 complex element a_gpu = gpuarray.to_gpu(a) #sin((1-1j)) should produce (1.29-0.63j) #log((1-1j)) should produce (0.34-0.78j) complex_gpu(a_gpu) print a_gpu.get() In [56]: %run complex_test.py *** compiler output in c:\docume~1\parc\locals~1\temp\tmpjqvxpv kernel.cu kernel.cudafe1.gpu kernel.cudafe2.gpu ./kernel.cu(19): Error: External calls are not supported (found non-inlined call to _ZN6pycuda3sinERKNS_7complexIfEE) --- CompileError Traceback (most recent call last) C:\Panalytical\pycuda_git\pycuda0.94\pycuda\examples\complex_test.py in module() 26 z[i] = sin(z[i]);, 27 complex_fn, --- 28 #include pycuda-complex.hpp, 29 ) CompileError: nvcc compilation of c:\docume~1\parc\locals~1\temp\tmpjqvxpv\kernel.cu failed [command: nvcc --cubin -arch sm_11 -IC:\Python26\lib\site-packages\pycuda-0.94rc-py2.6-win32.egg\pycuda\..\include\pycud a --keep kernel.cu] WARNING: Failure executing file: complex_test.py *However* if I replace sin() with log(): from pycuda.elementwise import ElementwiseKernel complex_gpu = ElementwiseKernel ( pycuda::complexfloat *z, z[i] = log(z[i]);, complex_fn, #include pycuda-complex.hpp, ) then I get the correct result! In [126]: %run complex_test.py (0.346573650837-0.785398185253j) Does anyone know why sin() doesn't work in both cases and log() works in an ElementwiseKernel but not correctly as a pycuda.cumath call? Ian. -- Ian Ozsvald (A.I. researcher, screencaster) i...@ianozsvald.com http://IanOzsvald.com http://morconsulting.com/ http://TheScreencastingHandbook.com http://ProCasts.co.uk/examples.html http://twitter.com/ianozsvald ___ PyCUDA mailing list pyc...@host304.hostmonster.com http://host304.hostmonster.com/mailman/listinfo/pycuda_tiker.net