Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjusted workes to threads logic to agree with what is in scipy.fft #47

Merged
merged 2 commits into from
Jan 14, 2020

Conversation

oleksandr-pavlyk
Copy link
Collaborator

@peterbell10

In [1]: import numpy as np, mkl_fft, mkl_fft._scipy_fft_backend as mkl_be, scipy, scipy.fft, mkl

In [2]: x = np.random.randn(8*7).reshape((7, 8))
   ...: with scipy.fft.set_backend(mkl_be, only=True):
   ...:     ff = scipy.fft.fft2(x, workers=-4)
   ...: ff2 = scipy.fft.fft2(x)
MKL_VERBOSE Intel(R) MKL 2020.0 Product build 20191102 for Intel(R) 64 architecture Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX2) enabled processors
, Lnx 2.40GHz intel_thread
MKL_VERBOSE FFT(drfo7:8:8x8:1:1,bScale:0.0178571,tLim:1,desc:0x56202b943cc0) 37.40us CNR:OFF Dyn:1 FastMM:1 TID:0  NThr:16,FFT:13

…ssue a warning if cpu_count(0 ends up being higher than MKL's max_threads. The warning is only issued once
@oleksandr-pavlyk
Copy link
Collaborator Author

Negative worker value is now interpreted relative to os.cpu_count() value, but if it exceeds Intel(R) MKL's own get_max_threads(), a one-time warning is issued:

(t_scipy-1.4.0) [14:40:32 linbox mkl_fft]$ ipython
Python 3.7.5 (default, Nov 23 2019, 04:02:01)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.11.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import numpy as np, mkl_fft, mkl_fft._scipy_fft_backend as mkl_be, scipy, scipy.fft, mkl

In [2]: x = np.random.randn(8*7).reshape((7, 8))
   ...: with scipy.fft.set_backend(mkl_be, only=True):
   ...:     ff = scipy.fft.fft2(x, workers=-4)
   ...: ff2 = scipy.fft.fft2(x)
/tmp/mkl_fft/_scipy_fft_backend.py:59: UserWarning: os.cpu_count() returned value of 32 greater than mkl.get_max_threads()'s value of 16. Using negative values of worker option may amount to requesting more threads than Intel(R) MKL can acommodate.
  ).format(self.cpu_count, max_threads))

In [3]: x = np.random.randn(8*7).reshape((7, 8))
   ...: with scipy.fft.set_backend(mkl_be, only=True):
   ...:     ff = scipy.fft.fft2(x, workers=-4)
   ...: ff2 = scipy.fft.fft2(x)

In [4]: np.allclose(ff, ff2)
Out[4]: True

@oleksandr-pavlyk oleksandr-pavlyk merged commit 2d79309 into master Jan 14, 2020
@oleksandr-pavlyk oleksandr-pavlyk deleted the adjust-workers-behavior-in-fft-backend branch January 14, 2020 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants