fjarri-attic / pyfft Goto Github PK
View Code? Open in Web Editor NEWFFT for PyCuda and PyOpenCL. The package is deprecated and its functionality is merged into Reikna.
Home Page: http://pypi.python.org/pypi/pyfft
License: Other
FFT for PyCuda and PyOpenCL. The package is deprecated and its functionality is merged into Reikna.
Home Page: http://pypi.python.org/pypi/pyfft
License: Other
When installing pyfft from pipy, using pip, I have the following warning :
PyFFT is deprecated and will not be updated any more.
Its functionality is being moved to Tigger (http://tigger.publicfields.net)
Tigger is nowhere to be found, it should be replaced by Reinka in the message.
It might be advisable to mention in the module docs that pycuda 0.94 is required by pyfft; some of the constructs invoked by pyfft don't exist in pycuda 0.93.
Thanks for this useful tool. Works great! One small issue: the sample code in the documentation failed on my Macbook (OS X Lion) with the error above. The Apple OpenCL driver provides a choice of devices (CPU and GPU) with the default being the CPU device, and the Intel CPU does not support the block size in the sample code. I was able to solve this by changing the context definition line to:
ctx = cl.Context(dev_type=cl.device_type.GPU)
The file cufft/pycuda_fft.py in pycudafft 0.2 attempts to import symbols from the typenames module. This module does not exist in Python 2.6; I had to patch the file to import from the types module.
The file pycudafft/kernel.mako is not installed by default when one runs python setup.py install. Adding the following lines to the setup() call in setup.py would cause it to be installed:
package_dir={'pycudafft': 'pycudafft'},
package_data={'pycudafft': ['*.mako']},
Hi,
can you please update the files on http://pypi.python.org/pypi/pyfft . I used them and ran into the AMD Issue #5.
I experienced a problem that the generated kernel generate errors with AMD OpenCL, e.g. with line
float2 a[4] = {0,0,0,0,0,0,0,0}
I think this is invalid code, but happens to compile fine with NVidia OpenCL. I suggest replacing it with
float2 a[4] = {(float2)(0.0, 0.0), (float2)(0.0, 0.0), (float2)(0.0, 0.0), (float2)(0.0, 0.0)}
Here is a patch for kernel.make (relative to pyfft 0.3.6) that fixes this problem. With this patch pyfft passes al tests on Win7, AMD HD5850, (and still on OS X 10.6.8, Nvidia GT330M)
diff --git a/pyfft/kernel.mako b/pyfft/kernel.mako
index aca776f..9392b82 100644
--- a/pyfft/kernel.mako
+++ b/pyfft/kernel.mako
@@ -713,7 +713,8 @@
## need to fill a[] with zeros, because otherwise nvcc crashes
## (it considers a[] not initialized)
${complex} a[${temp_array_size}] = {${', '.join(['0'] \* temp_array_size \* 2)}};
##${complex} a[${temp_array_size}] = {${', '.join(['0'] \* temp_array_size \* 2)}};
${complex} a[${temp_array_size}] = {${', '.join(['(%s)(0.0f, 0.0f)'%complex] \* temp_array_size)}};
Following the example of http://packages.python.org/pyfft/, I tried a simple FFT with OpenCL (see below)
Note: pyFFT doesn't import with PyOpenCL 2011.2: reason: pyopencl has no attribute VERSION
(cl.py, line 8). I bypassed the issue by removing that check.
After that:
from pyfft.cl import Plan
import numpy
import pyopencl as cl
import pyopencl.array as cl_array
ctx = cl.create_some_context(interactive=False)
queue = cl.CommandQueue(ctx)
plan = Plan((16, 16), queue=queue)
data = numpy.ones((16, 16), dtype=numpy.complex64)
gpu_data = cl_array.to_device(ctx, queue, data)
print gpu_data
[[ 1.+0.j 1.+0.j 1.+0.j 1.+0.j 1.+0.j 1.+0.j 1.+0.j 1.+0.j 1.+0.j
1.+0.j 1.+0.j 1.+0.j 1.+0.j 1.+0.j 1.+0.j 1.+0.j]
...
[ 1.+0.j 1.+0.j 1.+0.j 1.+0.j 1.+0.j 1.+0.j 1.+0.j 1.+0.j 1.+0.j
1.+0.j 1.+0.j 1.+0.j 1.+0.j 1.+0.j 1.+0.j 1.+0.j]]
plan.execute(gpu_data.data)
<pyopencl._cl.CommandQueue object at ...>
result = gpu_data.get()
print result
[[ 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j
0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j
0.+0.j 0.+0.j]
What I expected:
[[ 256.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j
0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j
0.+0.j 0.+0.j] [ 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j
0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j
0.+0.j 0.+0.j]]
(A DC component equals to the sum of all the ones in the initial matrix)
When I attempted to run test/test.py in pyfft-0.3 (after installing pyfft, of course), it failed with the following message:
Traceback (most recent call last):
File "test.py", line 6, in
from pyfft.cuda import plan as FFTPlan
ImportError: cannot import name plan
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.