Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/build-with-clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ jobs:
- name: Run mkl_fft tests
run: |
source ${{ env.ONEAPI_ROOT }}/setvars.sh
pip install scipy mkl-service pytest
pip install pytest mkl-service scipy dask
pytest -s -v --pyargs mkl_fft
46 changes: 22 additions & 24 deletions .github/workflows/conda-package-cf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:

strategy:
matrix:
python_ver: ["3.10", "3.11", "3.12", "3.13", "3.14"]
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
numpy: ['numpy">=2"']
experimental: [false]
runner: [ubuntu-latest]
Expand All @@ -100,7 +100,7 @@ jobs:
- name: Download artifact
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
with:
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python_ver }}
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}

- name: Add conda to system path
run: echo "$CONDA"/bin >> "$GITHUB_PATH"
Expand All @@ -119,7 +119,7 @@ jobs:
- name: Collect dependencies
run: |
CHANNELS=(-c "$GITHUB_WORKSPACE"/channel ${{ env.CHANNELS }})
conda create -n ${{ env.TEST_ENV_NAME }} "$PACKAGE_NAME" python=${{ matrix.python_ver }} ${{ matrix.numpy }} "${CHANNELS[@]}" --only-deps --dry-run > lockfile
conda create -n ${{ env.TEST_ENV_NAME }} "$PACKAGE_NAME" python=${{ matrix.python }} ${{ matrix.numpy }} "${CHANNELS[@]}" --only-deps --dry-run > lockfile

- name: Display lockfile
run: cat lockfile
Expand All @@ -135,15 +135,15 @@ jobs:
with:
path: ~/.conda/pkgs
key:
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python_ver }}-${{hashFiles('lockfile') }}
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }}
restore-keys: |
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python_ver }}-
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-

- name: Install mkl_fft
run: |
CHANNELS=(-c "$GITHUB_WORKSPACE"/channel ${{ env.CHANNELS }})
conda create -n ${{ env.TEST_ENV_NAME }} python=${{ matrix.python_ver }} ${{ matrix.numpy }} "$PACKAGE_NAME" pytest scipy "${CHANNELS[@]}"
conda create -n ${{ env.TEST_ENV_NAME }} python=${{ matrix.python }} ${{ matrix.numpy }} "$PACKAGE_NAME" pytest scipy dask "${CHANNELS[@]}"
# Test installed packages
conda list -n ${{ env.TEST_ENV_NAME }}

Expand All @@ -155,7 +155,9 @@ jobs:

build_windows:
runs-on: windows-latest

defaults:
run:
shell: cmd /C CALL {0}
strategy:
matrix:
include:
Expand Down Expand Up @@ -184,12 +186,13 @@ jobs:
with:
miniforge-version: latest
activate-environment: build
python-version: ${{ matrix.python }}
channels: conda-forge
conda-remove-defaults: 'true'
python-version: ${{ matrix.python }}

- name: Install conda-build
run: conda install -n base conda-build
run: |
conda install -n base -y conda-build
conda list -n base

- name: Cache conda packages
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
Expand All @@ -203,12 +206,8 @@ jobs:
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-

- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0

- name: Build conda package with NumPy 2.x
run: |
conda activate
conda build --no-test --python ${{ matrix.python }} --numpy ${{ matrix.numpy }} -c conda-forge --override-channels conda-recipe-cf

- name: Store conda paths as envs
Expand All @@ -231,7 +230,7 @@ jobs:

strategy:
matrix:
python_ver: ["3.10", "3.11", "3.12", "3.13", "3.14"]
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
numpy: ['numpy">=2"']
experimental: [false]
runner: [windows-latest]
Expand All @@ -244,15 +243,14 @@ jobs:
- name: Download artifact
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
with:
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python_ver }}
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}

- uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0
with:
miniforge-version: latest
activate-environment: ${{ env.TEST_ENV_NAME }}
python-version: ${{ matrix.python_ver }}
channels: conda-forge
conda-remove-defaults: 'true'
activate-environment: ${{ env.TEST_ENV_NAME }}
python-version: ${{ matrix.python }}

- name: Create conda channel with the artifact bit
shell: cmd /C CALL {0}
Expand Down Expand Up @@ -291,7 +289,7 @@ jobs:
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
SET PACKAGE_VERSION=%%F
)
conda install -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% python=${{ matrix.python_ver }} ${{ matrix.numpy }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile
conda install -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% python=${{ matrix.python }} ${{ matrix.numpy }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile

- name: Display lockfile content
shell: pwsh
Expand All @@ -304,9 +302,9 @@ jobs:
with:
path: /home/runner/conda_pkgs_dir
key:
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python_ver }}-${{hashFiles('lockfile') }}
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }}
restore-keys: |
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python_ver }}-
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-

- name: Install mkl_fft
Expand All @@ -320,8 +318,8 @@ jobs:
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
SET PACKAGE_VERSION=%%F
)
SET "TEST_DEPENDENCIES=pytest scipy"
conda install -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% %TEST_DEPENDENCIES% python=${{ matrix.python_ver }} ${{ matrix.numpy }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }}
SET "TEST_DEPENDENCIES=pytest scipy dask"
conda install -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% %TEST_DEPENDENCIES% python=${{ matrix.python }} ${{ matrix.numpy }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }}

- name: Report content of test environment
shell: cmd /C CALL {0}
Expand Down
22 changes: 9 additions & 13 deletions .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ jobs:
- name: Install mkl_fft
run: |
CHANNELS=(-c "$GITHUB_WORKSPACE"/channel ${{ env.CHANNELS }})
conda create -n ${{ env.TEST_ENV_NAME }} "$PACKAGE_NAME"=${{ env.PACKAGE_VERSION }} python=${{ matrix.python }} pytest "${CHANNELS[@]}"
conda create -n ${{ env.TEST_ENV_NAME }} "$PACKAGE_NAME"=${{ env.PACKAGE_VERSION }} python=${{ matrix.python }} pytest dask "${CHANNELS[@]}"
conda install -n ${{ env.TEST_ENV_NAME }} "scipy>=1.10" "${CHANNELS[@]}"
# Test installed packages
conda list -n ${{ env.TEST_ENV_NAME }}
Expand All @@ -155,7 +155,9 @@ jobs:

build_windows:
runs-on: windows-latest

defaults:
run:
shell: cmd /C CALL {0}
strategy:
matrix:
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
Expand All @@ -173,14 +175,13 @@ jobs:
with:
miniforge-version: latest
activate-environment: build
python-version: ${{ matrix.python }}
channels: conda-forge
conda-remove-defaults: 'true'
python-version: ${{ matrix.python }}

- name: Install conda-build
run: |
conda activate
conda install -n base conda-build
conda install -n base -y conda-build
conda list -n base

- name: Cache conda packages
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
Expand All @@ -194,12 +195,8 @@ jobs:
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-

- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0

- name: Build conda package
run: |
conda activate
conda build --no-test --python ${{ matrix.python }} -c https://software.repos.intel.com/python/conda -c conda-forge --override-channels conda-recipe

- name: Store conda paths as envs
Expand Down Expand Up @@ -239,10 +236,9 @@ jobs:
- uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0
with:
miniforge-version: latest
channels: conda-forge
activate-environment: ${{ env.TEST_ENV_NAME }}
python-version: ${{ matrix.python }}
channels: conda-forge
conda-remove-defaults: 'true'

- name: Create conda channel with the artifact bit
shell: cmd /C CALL {0}
Expand Down Expand Up @@ -310,7 +306,7 @@ jobs:
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
SET PACKAGE_VERSION=%%F
)
SET "TEST_DEPENDENCIES=pytest"
SET "TEST_DEPENDENCIES=pytest dask"
conda install -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% %TEST_DEPENDENCIES% python=${{ matrix.python }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }}
conda install -n ${{ env.TEST_ENV_NAME }} scipy -c ${{ env.workdir }}/channel ${{ env.CHANNELS }}
}
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
* Enabled support of Python 3.13 [gh-164](https://github.com/IntelPython/mkl_fft/pull/164)
* Added a new interface for FFT module of Dask accessible through `mkl_fft.interfaces.dask_fft` [gh-214](https://github.com/IntelPython/mkl_fft/pull/214)

### Changed
* Dropped support for `scipy.fftpack` interface [gh-185](https://github.com/IntelPython/mkl_fft/pull/185)
Expand Down
2 changes: 1 addition & 1 deletion conda-recipe-cf/bld.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
set MKLROOT=%PREFIX%
%PYTHON% -m pip install --no-build-isolation --no-deps .
%PYTHON% setup.py build --force install --old-and-unmanageable
if errorlevel 1 exit 1
7 changes: 4 additions & 3 deletions conda-recipe-cf/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash -x

export MKLROOT=$PREFIX
export CFLAGS="-I$PREFIX/include $CFLAGS"
$PYTHON -m pip install --no-build-isolation --no-deps .
# make sure that compiler has been sourced, if necessary

export MKLROOT=${PREFIX}
$PYTHON setup.py build --force install --old-and-unmanageable
16 changes: 16 additions & 0 deletions conda-recipe-cf/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
c_compiler: # [linux]
- gcc # [linux]
cxx_compiler: # [linux]
- gxx # [linux]
cxx_compiler_version: # [linux]
- '14' # [linux]
c_stdlib: # [linux]
- sysroot # [linux]
c_stdlib_version: # [linux]
- '2.28' # [linux]
c_stdlib: # [win]
- vs # [win]
cxx_compiler: # [win]
- vs2022 # [win]
c_compiler: # [win]
- vs2022 # [win]
28 changes: 20 additions & 8 deletions conda-recipe-cf/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
{% set version = "2.2.0dev1" %}
{% set buildnumber = 0 %}

package:
name: mkl_fft
version: {{ version }}
version: {{ GIT_DESCRIBE_TAG }}

source:
path: ../

build:
number: {{ buildnumber }}
number: {{ GIT_DESCRIBE_NUMBER }}
script_env:
- WHEELS_OUTPUT_FOLDER
ignore_run_exports:
- blas

requirements:
build:
- {{ compiler('c') }}
- {{ stdlib('c') }}
host:
- python
- python-gil # [py>=314]
- pip
- setuptools >=77
- mkl-devel
- cython
- numpy
- wheel >=0.41.3
run:
- python
- python-gil # [py>=314]
- mkl-service
- numpy

Expand All @@ -33,14 +37,22 @@ test:
requires:
- pytest
- scipy >=1.10
- dask
imports:
- mkl_fft
- mkl_fft.interfaces
- mkl_fft.interfaces.numpy_fft
- mkl_fft.interfaces.scipy_fft

about:
home: http://github.com/IntelPython/mkl_fft
license: BSD-3-Clause
license_file: LICENSE.txt
summary: NumPy-based implementation of Fast Fourier Transform using Intel® oneAPI Math Kernel Library (OneMKL)
summary: NumPy-based implementation of Fast Fourier Transform using Intel® oneAPI Math Kernel Library (oneMKL)
description: |
<strong>LEGAL NOTICE: Use of this software package is subject to the
software license agreement (as set forth above, in the license section of
the installed Conda package and/or the README file) and all notices,
disclaimers or license terms for third party or open source software
included in or with the software.</strong>
<br/><br/>
EULA: <a href="https://opensource.org/licenses/BSD-3-Clause" target="_blank">BSD-3-Clause</a>
<br/><br/>
4 changes: 2 additions & 2 deletions conda-recipe/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ c_stdlib_version: # [linux]
c_stdlib: # [win]
- vs # [win]
cxx_compiler: # [win]
- vs2017 # [win]
- vs2022 # [win]
c_compiler: # [win]
- vs2017 # [win]
- vs2022 # [win]
1 change: 1 addition & 0 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ test:
- pytest
# This is a temporary python restriction
- scipy >=1.10 # [py<314]
- dask
imports:
- mkl_fft
- mkl_fft.interfaces
Expand Down
42 changes: 41 additions & 1 deletion mkl_fft/interfaces/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Interfaces
The `mkl_fft` package provides interfaces that serve as drop-in replacements for equivalent functions in NumPy and SciPy.
The `mkl_fft` package provides interfaces that serve as drop-in replacements for equivalent functions in NumPy, SciPy, and Dask.

---

Expand Down Expand Up @@ -124,3 +124,43 @@ with mkl_fft.set_workers(4):
y = scipy.signal.fftconvolve(a, a) # Note that Nthr:4
# MKL_VERBOSE FFT(dcbo256x128,input_strides:{0,128,1},output_strides:{0,128,1},bScale:3.05176e-05,tLim:4,unaligned_output,desc:0x563aefe86180) 187.37us CNR:OFF Dyn:1 FastMM:1 TID:0 NThr:4
```

---

## Dask interface - `mkl_fft.interfaces.dask_fft`

This interface is a drop-in replacement for the [`dask.fft`](https://dask.pydata.org/en/latest/array-api.html#fast-fourier-transforms) module and includes **all** the functions available there:

* complex-to-complex FFTs: `fft`, `ifft`, `fft2`, `ifft2`, `fftn`, `ifftn`.

* real-to-complex and complex-to-real FFTs: `rfft`, `irfft`, `rfft2`, `irfft2`, `rfftn`, `irfftn`.

* Hermitian FFTs: `hfft`, `ihfft`.

* Helper routines: `fft_wrap`, `fftfreq`, `rfftfreq`, `fftshift`, `ifftshift`. These routines serve as a fallback to the Dask implementation and are included for completeness.

The following example shows how to use this interface for calculating a 2D FFT.

```python
import numpy, dask
import mkl_fft.interfaces.dask_fft as dask_fft

a = numpy.random.randn(128, 64) + 1j*numpy.random.randn(128, 64)
x = dask.array.from_array(a, chunks=(64, 64))
lazy_res = dask_fft.fft(x)
mkl_res = lazy_res.compute()
np_res = numpy.fft.fft(a)
numpy.allclose(mkl_res, np_res)
# True

# There are two chunks in this example based on the size of input array (128, 64) and chunk size (64, 64)
# to confirm that MKL FFT is called twice, turn on verbosity
import mkl
mkl.verbose(1)
# True

mkl_res = lazy_res.compute() # MKL_VERBOSE FFT is shown twice below which means MKL FFT is called twice
# MKL_VERBOSE oneMKL 2024.0 Update 2 Patch 2 Product build 20240823 for Intel(R) 64 architecture Intel(R) Advanced Vector Extensions 512 (Intel(R) AVX-512) with support for INT8, BF16, FP16 (limited) instructions, and Intel(R) Advanced Matrix Extensions (Intel(R) AMX) with INT8 and BF16, Lnx 3.80GHz intel_thread
# MKL_VERBOSE FFT(dcfo64*64,input_strides:{0,1},output_strides:{0,1},input_distance:64,output_distance:64,bScale:0.015625,tLim:32,unaligned_input,desc:0x7fd000010e40) 432.84us CNR:OFF Dyn:1 FastMM:1 TID:0 NThr:112
# MKL_VERBOSE FFT(dcfo64*64,input_strides:{0,1},output_strides:{0,1},input_distance:64,output_distance:64,bScale:0.015625,tLim:32,unaligned_input,desc:0x7fd480011300) 499.00us CNR:OFF Dyn:1 FastMM:1 TID:0 NThr:112
```
Loading
Loading