PyFFTW multithreading not working

我只是一个虾纸丫 提交于 2019-12-12 02:34:09

问题


I am running my codes based on PyFFTW wrapper for FFTW3 library. In the plan function call of PyFFTW, there is a parameter "thread" to specify the number of threads to use. I use a fundamental judge, Activity Monitor, to tell whether multithreading works or not. It turns out that the following code runs on one CPU even when I specify thread=4. My laptop is a Mac with 8 cores. Here is my code.

import pyfftw
n_cpu = 4
flags = ('FFTW_MEASURE','FFTW_DESTROY_INPUT')
x_buffer = pyfftw.n_byte_align_empty((8192,8192,), 16, 'complex128')
f_buffer = pyfftw.n_byte_align_empty((8192,8192,), 16, 'complex128')
fftObj  = pyfftw.FFTW(x_buffer, f_buffer,  axes=(-2,-1), direction='FFTW_FORWARD',  flags=flags, thread=n_cpu)
fftObj()

When I run fftObj(), the computer seems to run on one CPU (CPU usage 99% whereas the expected should be 400%). What I want is to have the FFT task distributed among CPUs my laptop has.

Other than trying pyfftw, I have tried writing some other codes in C with OpenMP, and I see from the Activity Monitor that the CPU usage is above 100%. It means that the C code runs on multiple CPUs and my machine does have the multicore feature.

Is there anything that I missed to turn on the multithreading of pyfftw? Or do I misunderstand the meaning of the parameter?

There is a related problem.


回答1:


The argument is threads not thread. Superfluous and invalid arguments should probably be picked up. Fancy going and leaving an issue on github?



来源:https://stackoverflow.com/questions/29534959/pyfftw-multithreading-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!