Commit e68753f6 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

Merge branch 'scipy_fft' into 'NIFTy_6'

Switch FFT to scipy.fft

See merge request !398
parents 0dd75ecd fc1371dd
Pipeline #65875 passed with stages
in 16 minutes and 22 seconds
......@@ -14,7 +14,6 @@ RUN apt-get update && apt-get install -y \
# more optional NIFTy dependencies
&& pip3 install git+https://gitlab.mpcdf.mpg.de/ift/pyHealpix.git \
&& pip3 install git+https://gitlab.mpcdf.mpg.de/ift/nifty_gridder.git \
&& pip3 install git+https://gitlab.mpcdf.mpg.de/mtr/pypocketfft.git \
&& pip3 install jupyter \
&& rm -rf /var/lib/apt/lists/*
......
......@@ -47,7 +47,6 @@ Installation
- [Python 3](https://www.python.org/) (3.5.x or later)
- [SciPy](https://www.scipy.org/)
- [pypocketfft](https://gitlab.mpcdf.mpg.de/mtr/pypocketfft)
Optional dependencies:
- [pyHealpix](https://gitlab.mpcdf.mpg.de/ift/pyHealpix) (for harmonic
......@@ -56,6 +55,7 @@ Optional dependencies:
interferometry responses)
- [mpi4py](https://mpi4py.scipy.org) (for MPI-parallel execution)
- [matplotlib](https://matplotlib.org/) (for field plotting)
- [pypocketfft](https://gitlab.mpcdf.mpg.de/mtr/pypocketfft) (for faster FFTs)
### Sources
......@@ -73,7 +73,6 @@ NIFTy6 and its mandatory dependencies can be installed via:
sudo apt-get install git python3 python3-pip python3-dev
pip3 install --user git+https://gitlab.mpcdf.mpg.de/ift/nifty.git@NIFTy_6
pip3 install --user git+https://gitlab.mpcdf.mpg.de/mtr/pypocketfft
Plotting support is added via:
......@@ -91,6 +90,14 @@ MPI support is added via:
sudo apt-get install python3-mpi4py
Pypocketfft is added via:
pip3 install --user git+https://gitlab.mpcdf.mpg.de/mtr/pypocketfft
If this library is present, NIFTy will detect it automatically and prefer
it over SciPy's FFT. The underlying code is actually the same, but
pypocketfft is compiled with optimizations for the host CPU and can provide
significantly faster transforms.
### Running the tests
To run the tests, additional packages are required:
......
......@@ -9,7 +9,6 @@ NIFTy6 and its mandatory dependencies can be installed via::
sudo apt-get install git python3 python3-pip python3-dev
pip3 install --user git+https://gitlab.mpcdf.mpg.de/ift/nifty.git@NIFTy_6
pip3 install --user git+https://gitlab.mpcdf.mpg.de/mtr/pypocketfft
Plotting support is added via::
......@@ -27,6 +26,14 @@ MPI support is added via::
sudo apt-get install python3-mpi4py
Pypocketfft is added via:
pip3 install --user git+https://gitlab.mpcdf.mpg.de/mtr/pypocketfft
If this library is present, NIFTy will detect it automatically and prefer
it over SciPy's FFT. The underlying code is actually the same, but
pypocketfft is compiled with optimizations for the host CPU and can provide
significantly faster transforms.
NIFTy documentation is provided by Sphinx. To build the documentation::
sudo apt-get install python3-sphinx-rtd-theme dvipng
......
......@@ -15,7 +15,6 @@
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
import pypocketfft
_nthreads = 1
......@@ -29,14 +28,35 @@ def set_nthreads(nthr):
_nthreads = int(nthr)
def fftn(a, axes=None):
return pypocketfft.c2c(a, axes=axes, nthreads=_nthreads)
try:
import pypocketfft
def ifftn(a, axes=None):
return pypocketfft.c2c(a, axes=axes, inorm=2, forward=False,
nthreads=_nthreads)
def fftn(a, axes=None):
return pypocketfft.c2c(a, axes=axes, nthreads=max(_nthreads, 0))
def hartley(a, axes=None):
return pypocketfft.genuine_hartley(a, axes=axes, nthreads=_nthreads)
def ifftn(a, axes=None):
return pypocketfft.c2c(a, axes=axes, inorm=2, forward=False,
nthreads=max(_nthreads, 0))
def hartley(a, axes=None):
return pypocketfft.genuine_hartley(a, axes=axes,
nthreads=max(_nthreads, 0))
except ImportError:
import scipy.fft
def fftn(a, axes=None):
return scipy.fft.fftn(a, axes=axes, workers=_nthreads)
def ifftn(a, axes=None):
return scipy.fft.ifftn(a, axes=axes, workers=_nthreads)
def hartley(a, axes=None):
tmp = scipy.fft.fftn(a, axes=axes, workers=_nthreads)
return tmp.real+tmp.imag
......@@ -39,8 +39,8 @@ setup(name="nifty6",
packages=find_packages(include=["nifty6", "nifty6.*"]),
zip_safe=True,
license="GPLv3",
setup_requires=['scipy'],
install_requires=['scipy'],
setup_requires=['scipy>=1.4.1'],
install_requires=['scipy>=1.4.1'],
python_requires='>=3.5',
classifiers=[
"Development Status :: 4 - Beta",
......
......@@ -63,7 +63,7 @@ def test_fft1D(d, dtype, op):
@pmp('dim2', [9, 12])
@pmp('d1', [0.1, 1, 3.7])
@pmp('d2', [0.4, 1, 2.7])
@pmp('nthreads', [0, 1, 2, 3, 4])
@pmp('nthreads', [-1, 1, 2, 3, 4])
def test_fft2D(dim1, dim2, d1, d2, dtype, op, nthreads):
ift.fft.set_nthreads(nthreads)
assert_(ift.fft.nthreads() == nthreads)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment