You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: mkl_fft/interfaces/README.md
+23Lines changed: 23 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,8 @@ This interface is a drop-in replacement for the [`scipy.fft`](https://scipy.gith
42
42
43
43
* Helper functions: `fftshift`, `ifftshift`, `fftfreq`, `rfftfreq`, `set_workers`, `get_workers`. All of these functions, except for `set_workers` and `get_workers`, serve as a fallback to the SciPy implementation and are included for completeness.
44
44
45
+
Note that in computing FFTs, the default value of `workers` parameter is the maximum number of threads available unlike the default behavior of SciPy where only one thread is used.
46
+
45
47
The following example shows how to use this interface for calculating a 1D FFT.
46
48
47
49
```python
@@ -102,3 +104,24 @@ with scipy.fft.set_backend(mkl_backend, only=True):
102
104
print(f"Time with OneMKL FFT backend installed: {t2:.1f} seconds")
103
105
# Time with MKL FFT backend installed: 9.1 seconds
104
106
```
107
+
108
+
In the following example, we use `set_worker` to control the number of threads when `mkl_fft` is being used as a backend for SciPy.
109
+
110
+
```python
111
+
import numpy, mkl, scipy
112
+
import mkl_fft.interfaces.scipy_fft as mkl_fft
113
+
import scipy
114
+
a = numpy.random.randn(128, 64) +1j*numpy.random.randn(128, 64)
115
+
scipy.fft.set_global_backend(mkl_fft) # set mkl_fft as global backend
116
+
117
+
mkl.verbose(1)
118
+
# True
119
+
mkl.get_max_threads()
120
+
# 112
121
+
y = scipy.signal.fftconvolve(a, a) # Note that Nthr:112
0 commit comments