diff options
author | Martin Teichmann <lkb.teichmann@gmail.com> | 2013-02-01 14:36:18 +0100 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-04-01 15:41:34 -0600 |
commit | 5ad97ea70b126a1a13abc4d7500f0281ba4ddd50 (patch) | |
tree | c3c7ab34d1fc328b323fb34058a9bf1cab0270a3 /numpy | |
parent | 0563ebf44c3d333a9abdc6530cd74514455f99c9 (diff) | |
download | numpy-5ad97ea70b126a1a13abc4d7500f0281ba4ddd50.tar.gz |
Allow threads for FFT calculations
This patch adds lines to release the Global Interpreter Lock
while calculating an FFT with fftpack.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/fft/fftpack_litemodule.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/numpy/fft/fftpack_litemodule.c b/numpy/fft/fftpack_litemodule.c index 499c72828..6f6a6c9f3 100644 --- a/numpy/fft/fftpack_litemodule.c +++ b/numpy/fft/fftpack_litemodule.c @@ -45,10 +45,12 @@ fftpack_cfftf(PyObject *NPY_UNUSED(self), PyObject *args) nrepeats = PyArray_SIZE(data)/npts; dptr = (double *)PyArray_DATA(data); NPY_SIGINT_ON; + Py_BEGIN_ALLOW_THREADS; for (i = 0; i < nrepeats; i++) { cfftf(npts, dptr, wsave); dptr += npts*2; } + Py_END_ALLOW_THREADS; NPY_SIGINT_OFF; PyArray_Free(op2, (char *)wsave); return (PyObject *)data; @@ -96,10 +98,12 @@ fftpack_cfftb(PyObject *NPY_UNUSED(self), PyObject *args) nrepeats = PyArray_SIZE(data)/npts; dptr = (double *)PyArray_DATA(data); NPY_SIGINT_ON; + Py_BEGIN_ALLOW_THREADS; for (i = 0; i < nrepeats; i++) { cfftb(npts, dptr, wsave); dptr += npts*2; } + Py_END_ALLOW_THREADS; NPY_SIGINT_OFF; PyArray_Free(op2, (char *)wsave); return (PyObject *)data; @@ -131,7 +135,9 @@ fftpack_cffti(PyObject *NPY_UNUSED(self), PyObject *args) } NPY_SIGINT_ON; + Py_BEGIN_ALLOW_THREADS; cffti(n, (double *)PyArray_DATA((PyArrayObject*)op)); + Py_END_ALLOW_THREADS; NPY_SIGINT_OFF; return (PyObject *)op; @@ -183,6 +189,7 @@ fftpack_rfftf(PyObject *NPY_UNUSED(self), PyObject *args) NPY_SIGINT_ON; + Py_BEGIN_ALLOW_THREADS; for (i = 0; i < nrepeats; i++) { memcpy((char *)(rptr+1), dptr, npts*sizeof(double)); rfftf(npts, rptr+1, wsave); @@ -191,6 +198,7 @@ fftpack_rfftf(PyObject *NPY_UNUSED(self), PyObject *args) rptr += rstep; dptr += npts; } + Py_END_ALLOW_THREADS; NPY_SIGINT_OFF; PyArray_Free(op2, (char *)wsave); Py_DECREF(data); @@ -245,6 +253,7 @@ fftpack_rfftb(PyObject *NPY_UNUSED(self), PyObject *args) dptr = (double *)PyArray_DATA(data); NPY_SIGINT_ON; + Py_BEGIN_ALLOW_THREADS; for (i = 0; i < nrepeats; i++) { memcpy((char *)(rptr + 1), (dptr + 2), (npts - 1)*sizeof(double)); rptr[0] = dptr[0]; @@ -252,6 +261,7 @@ fftpack_rfftb(PyObject *NPY_UNUSED(self), PyObject *args) rptr += npts; dptr += npts*2; } + Py_END_ALLOW_THREADS; NPY_SIGINT_OFF; PyArray_Free(op2, (char *)wsave); Py_DECREF(data); @@ -285,7 +295,9 @@ fftpack_rffti(PyObject *NPY_UNUSED(self), PyObject *args) return NULL; } NPY_SIGINT_ON; + Py_BEGIN_ALLOW_THREADS; rffti(n, (double *)PyArray_DATA((PyArrayObject*)op)); + Py_END_ALLOW_THREADS; NPY_SIGINT_OFF; return (PyObject *)op; |