Skip to content

Commit

Permalink
Test adding KMP_DUPLICATE_LIB_OK
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanbabbar04 committed Feb 15, 2023
1 parent 3f221fc commit c051426
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 23 deletions.
3 changes: 3 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:

variables:
NUMBA_NUM_THREADS: 1
KMP_DUPLICATE_LIB_OK: FALSE

steps:
- task: UsePythonVersion@0
Expand All @@ -62,6 +63,7 @@ jobs:
python -m pip install --upgrade pip setuptools wheel django
pip install -r requirements-dev.txt
pip install .
pip uninstall -y intel-openmp
displayName: 'Install prerequisites and library'
- script: |
Expand Down Expand Up @@ -91,6 +93,7 @@ jobs:
python -m pip install --upgrade pip setuptools wheel django
pip install -r requirements-dev.txt
pip install .
pip uninstall -y intel-openmp
displayName: 'Install prerequisites and library'
- script: |
Expand Down
9 changes: 3 additions & 6 deletions pylops/signalprocessing/fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import numpy.typing as npt
import scipy.fft

from mkl_fft import _numpy_fft as pymkl_fft
from mkl_fft._scipy_fft_backend import fftshift as mkl_fftshift, ifftshift as mkl_ifftshift

from pylops import LinearOperator
from pylops.signalprocessing._baseffts import _BaseFFT, _FFTNorms
from pylops.utils import deps
Expand Down Expand Up @@ -402,9 +405,6 @@ def __init__(

@reshaped
def _matvec(self, x: NDArray) -> NDArray:
from mkl_fft import _numpy_fft as pymkl_fft
from mkl_fft._scipy_fft_backend import fftshift as mkl_fftshift, ifftshift as mkl_ifftshift

if self.ifftshift_before:
x = mkl_ifftshift(x, axes=self.axis)
if not self.clinear:
Expand All @@ -425,9 +425,6 @@ def _matvec(self, x: NDArray) -> NDArray:

@reshaped
def _rmatvec(self, x: NDArray) -> NDArray:
from mkl_fft import _numpy_fft as pymkl_fft
from mkl_fft._scipy_fft_backend import fftshift as mkl_fftshift, ifftshift as mkl_ifftshift

if self.fftshift_after:
x = mkl_ifftshift(x, axes=self.axis)
if self.real:
Expand Down
8 changes: 3 additions & 5 deletions pylops/signalprocessing/fft2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
import warnings
from typing import Dict, Optional, Sequence, Union

from pylops.signalprocessing.fftnd import _FFTND_mklfft
import numpy as np
import scipy.fft
from mkl_fft._scipy_fft_backend import fftshift as mkl_fftshift, ifftshift as mkl_ifftshift


from pylops import LinearOperator
from pylops.signalprocessing._baseffts import _BaseFFTND, _FFTNorms
from pylops.utils.decorators import reshaped
from pylops.utils.typing import DTypeLike, InputDimsLike
from pylops.signalprocessing.fftnd import _FFTND_mklfft

logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING)

Expand Down Expand Up @@ -265,8 +267,6 @@ def __init__(

@reshaped
def _matvec(self, x):
from mkl_fft._scipy_fft_backend import fftshift as mkl_fftshift, ifftshift as mkl_ifftshift

if self.ifftshift_before.any():
x = mkl_ifftshift(x, axes=self.axes[self.ifftshift_before])
if not self.clinear:
Expand All @@ -287,8 +287,6 @@ def _matvec(self, x):

@reshaped
def _rmatvec(self, x):
from mkl_fft._scipy_fft_backend import fftshift as mkl_fftshift, ifftshift as mkl_ifftshift

if self.fftshift_after.any():
x = mkl_ifftshift(x, axes=self.axes[self.fftshift_after])
if self.real:
Expand Down
14 changes: 2 additions & 12 deletions pylops/signalprocessing/fftnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import numpy as np
import numpy.typing as npt
from mkl_fft._scipy_fft_backend import fftshift as mkl_fftshift, ifftshift as mkl_iffshift
from mkl_fft._numpy_fft import ifft, asarray, _cook_nd_args, irfft, fft, rfft

from pylops.signalprocessing._baseffts import _BaseFFTND, _FFTNorms
from pylops.utils.backend import get_sp_fft
Expand Down Expand Up @@ -235,8 +237,6 @@ def __init__(

@reshaped
def _matvec(self, x: NDArray) -> NDArray:
from mkl_fft._scipy_fft_backend import fftshift as mkl_fftshift, ifftshift as mkl_iffshift

if self.ifftshift_before.any():
x = mkl_iffshift(x, axes=self.axes[self.ifftshift_before])
if not self.clinear:
Expand All @@ -257,8 +257,6 @@ def _matvec(self, x: NDArray) -> NDArray:

@reshaped
def _rmatvec(self, x: NDArray) -> NDArray:
from mkl_fft._scipy_fft_backend import fftshift as mkl_fftshift, ifftshift as mkl_iffshift

if self.fftshift_after.any():
x = mkl_iffshift(x, axes=self.axes[self.fftshift_after])
if self.real:
Expand All @@ -285,8 +283,6 @@ def _rmatvec(self, x: NDArray) -> NDArray:

@staticmethod
def rfftn(a, s=None, axes=None, norm=None):
from mkl_fft._numpy_fft import asarray, _cook_nd_args, fft, rfft

a = asarray(a)
s, axes = _cook_nd_args(a, s, axes)
a = rfft(a, s[-1], axes[-1], norm)
Expand All @@ -296,8 +292,6 @@ def rfftn(a, s=None, axes=None, norm=None):

@staticmethod
def irfftn(a, s=None, axes=None, norm=None):
from mkl_fft._numpy_fft import ifft, asarray, _cook_nd_args, irfft

a = asarray(a)
s, axes = _cook_nd_args(a, s, axes, invreal=1)
for ii in range(len(axes) - 1):
Expand All @@ -307,8 +301,6 @@ def irfftn(a, s=None, axes=None, norm=None):

@staticmethod
def fftn(a, s=None, axes=None, norm=None):
from mkl_fft._numpy_fft import asarray, _cook_nd_args, fft

a = asarray(a)
s, axes = _cook_nd_args(a, s, axes)
itl = list(range(len(axes)))
Expand All @@ -319,8 +311,6 @@ def fftn(a, s=None, axes=None, norm=None):

@staticmethod
def ifftn(a, s=None, axes=None, norm=None):
from mkl_fft._numpy_fft import ifft, asarray, _cook_nd_args

a = asarray(a)
s, axes = _cook_nd_args(a, s, axes)
itl = list(range(len(axes)))
Expand Down

0 comments on commit c051426

Please sign in to comment.