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

Detect if length of array is too much for MKL to handle, warn if it is #4405

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions pycbc/fft/func_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,27 @@
implementations within PyCBC.
"""

import logging
from pycbc.types import TimeSeries as _TimeSeries
from pycbc.types import FrequencySeries as _FrequencySeries
from .core import _check_fft_args, _check_fwd_args, _check_inv_args
from .backend_support import get_backend

def check_backend(invec, backend):
"""
Add in any checks / warnings we want to give for backend usage

Parameters
----------
invec : TimeSeries or FrequencySeries
The input vector.
backend :
The backend object which has been set for computing FFTs
"""
if len(invec) > 2 ** 24 and backend.__name__ == 'pycbc.fft.mkl':
logging.warning("MKL cannot handle arrays longer than 2^24 in "
"(inverse) FFTs.")

def fft(invec, outvec):
""" Fourier transform from invec to outvec.

Expand All @@ -49,6 +65,7 @@ def fft(invec, outvec):

# The following line is where all the work is done:
backend = get_backend()
check_backend(invec, backend)
backend.fft(invec, outvec, prec, itype, otype)
# For a forward FFT, the length of the *input* vector is the length
# we should divide by, whether C2C or R2HC transform
Expand Down Expand Up @@ -79,6 +96,7 @@ def ifft(invec, outvec):

# The following line is where all the work is done:
backend = get_backend()
check_backend(invec, backend)
backend.ifft(invec, outvec, prec, itype, otype)
# For an inverse FFT, the length of the *output* vector is the length
# we should divide by, whether C2C or HC2R transform
Expand Down