Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
3 changes: 3 additions & 0 deletions .github/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ CI/CD workflows, automation, security scanning, and package distribution.

## Workflows
- **conda-package.yml** — main build/test pipeline (Linux/Windows, Python 3.10-3.14)
- **conda-package-cf.yml** — build/test using only conda-forge channel (Linux/Windows, Python 3.10-3.14)
- **build-with-clang.yml** — Linux Clang compiler compatibility validation
- **build-with-standard-clang.yml** — standard Clang compiler compatibility validation
- **build_pip.yml** — validates editable build
- **pre-commit.yml** — code quality checks (flake8, etc.)
- **openssf-scorecard.yml** — security posture scanning

Expand Down
4 changes: 2 additions & 2 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ Higher-precedence file overrides; lower must not restate overridden guidance.
- Never include secrets/tokens/credentials in files.

## Source-of-truth files
- Build/config: `pyproject.toml`, `setup.py`
- Build/config: `pyproject.toml`, `meson.build`
- Recipe/deps: `conda-recipe/meta.yaml`, `conda-recipe/conda_build_config.yaml`
- CI: `.github/workflows/*.{yml,yaml}`
- API contracts: `mkl/__init__.py`, `mkl/_mkl_service.pyx`
- API contracts: `mkl/__init__.py`, `mkl/_py_mkl_service.pyx`
- Tests: `mkl/tests/test_mkl_service.py`

## MKL-specific constraints
Expand Down
16 changes: 6 additions & 10 deletions .github/workflows/build-with-clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
python: ["3.10", "3.11", "3.12", "3.13"]
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]

env:
ONEAPI_ROOT: /opt/intel/oneapi
Expand All @@ -37,10 +37,9 @@ jobs:
sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
sudo apt-get update

- name: Install Intel OneAPI
- name: Install Intel oneAPI
run: |
sudo apt-get install intel-oneapi-compiler-dpcpp-cpp
sudo apt-get install intel-oneapi-tbb
sudo apt-get install intel-oneapi-mkl-devel

- name: Setup Python
Expand All @@ -55,12 +54,8 @@ jobs:
fetch-depth: 0

- name: Install mkl-service dependencies
uses: BSFishy/pip-action@8f2d471d809dc20b6ada98c91910b6ae6243f318 # v1
with:
packages: |
cython
setuptools>=77
pytest
run: |
pip install meson-python cython cmake ninja

- name: List oneAPI folder content
run: ls ${{ env.ONEAPI_ROOT }}/compiler
Expand All @@ -71,9 +66,10 @@ jobs:
echo "$CMPLR_ROOT"
export CC="$CMPLR_ROOT/bin/icx"
export CFLAGS="${CFLAGS} -fno-fast-math"
python setup.py develop
pip install . --no-build-isolation --no-deps --verbose

- name: Run mkl-service tests
run: |
source ${{ env.ONEAPI_ROOT }}/setvars.sh
pip install pytest
pytest -s -v --pyargs mkl
56 changes: 56 additions & 0 deletions .github/workflows/build-with-standard-clang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build project with standard clang compiler

on:
pull_request:
push:
branches: [master]

permissions: read-all

jobs:
build-with-standard-clang:
runs-on: ubuntu-latest

strategy:
matrix:
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]

env:
COMPILER_ROOT: /usr/bin

defaults:
run:
shell: bash -el {0}

steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@3155a141048f8f89c06b4cdae32e7853e97536bc # 0.13.0
with:
access_token: ${{ github.token }}

- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang

- name: Setup Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python }}
architecture: x64

- name: Checkout repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0

- name: Install mkl-service dependencies
run: |
pip install meson-python cython cmake ninja mkl-devel

- name: Build mkl-service
run: |
export CC=${{ env.COMPILER_ROOT }}/clang
pip install -e ".[test]" --no-build-isolation --verbose
pip list
python -m pytest -v mkl/tests
43 changes: 43 additions & 0 deletions .github/workflows/build_pip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Editable build using pip

on:
push:
branches:
- master
pull_request:

permissions: read-all

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}

strategy:
matrix:
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0

- uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0
with:
miniforge-version: latest
channels: conda-forge
activate-environment: test
python-version: ${{ matrix.python }}

- name: Install MKL
run: |
conda install mkl-devel mkl

- name: Build with pip
run: |
pip install --no-cache-dir meson-python ninja cmake cython
pip install -e ".[test]" --no-build-isolation --verbose
pip list
python -m pytest -v mkl/tests
32 changes: 25 additions & 7 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,44 @@ Originally part of Intel® Distribution for Python*, now a standalone package av

## Key components
- **Python interface:** `mkl/__init__.py` — public API surface
- **Cython wrapper:** `mkl/_mkl_service.pyx` — wraps MKL support functions
- **Cython wrapper:** `mkl/_py_mkl_service.pyx` — wraps MKL support functions
- **C init module:** `mkl/_mklinitmodule.c` — Linux-side MKL runtime preloading / initialization
- **Helper:** `mkl/_init_helper.py` — Windows venv DLL loading helper
- **Build system:** setuptools + Cython
- **Build system:** meson-python + Cython

## Build dependencies
**Required:**
- Intel® oneMKL
- meson-python
- CMake
- Ninja
- Cython
- Python 3.10+

**Conda environment:**
**Build against an existing `mkl` installation:**

Install the build dependencies via Conda:
```bash
conda install -c conda-forge mkl-devel cython meson-python cmake ninja
```
or via pip:
```bash
python -m pip install mkl-devel cython meson-python cmake ninja
```
then build without pulling a fresh `mkl` into an isolated build:
```bash
conda install -c conda-forge mkl-devel cython
python setup.py install
python -m pip install --no-deps --no-build-isolation .
```

## CI/CD
- **Platforms in CI workflows:** Linux, Windows
- **Python versions:** 3.10, 3.11, 3.12, 3.13, 3.14
- **Workflows:** `.github/workflows/`
- `conda-package.yml` — main conda build/test pipeline
- `conda-package-cf.yml` — conda build/test using only conda-forge channel
- `build-with-clang.yml` — Linux Clang compatibility
- `build-with-standard-clang.yml` — standard Clang compiler compatibility validation
- `build_pip.yml` — validates editable build
- `pre-commit.yml` — code quality checks
- `openssf-scorecard.yml` — security scanning

Expand All @@ -61,15 +76,16 @@ mkl.get_version_string() # MKL version info
- **Docs:** MKL support functions documented in [Intel oneMKL Developer Reference](https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-c/2025-2/support-functions.html)

## Code structure
- **Cython layer:** `_mkl_service.pyx` + `_mkl_service.pxd` (C declarations)
- **Cython layer:** `_py_mkl_service.pyx` + `_mkl_service.pxd` (C declarations)
- **C init:** `_mklinitmodule.c` handles Linux preloading (`dlopen(..., RTLD_GLOBAL)`) for MKL runtime
- **Windows loading helper:** `_init_helper.py` handles DLL path setup in Windows venv
- **Python wrapper:** `__init__.py` imports `_py_mkl_service` (generated from `.pyx`)
- **Version:** `_version.py` (dynamic via setuptools)
- **Version:** `_version.py`

## Notes
- RTLD_GLOBAL preloading is required on Linux (handled by `RTLD_for_MKL` context manager)
- MKL must be available at runtime (conda: mkl, pip: relies on system MKL)
- Do **not** add `mkl` to `[project].dependencies` in `pyproject.toml` (its PyPI wheel lacks `.dist-info`, which breaks `pip check`).
- Threading functions affect NumPy, SciPy, and other MKL-backed libraries

## Directory map
Expand All @@ -85,4 +101,6 @@ Below directories have local `AGENTS.md` for deeper context:
For broader IntelPython ecosystem context, see:
- `mkl_umath` (MKL-backed NumPy ufuncs)
- `mkl_random` (MKL-based random number generation)
- `mkl_fft` (MKL-based fast fourier transform functions)
- `dpnp` (Data Parallel NumPy)
- `dpctl` (Data Parallel Control)
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

### Changed
* Migrated the build system from `setuptools` to `meson-python`, removing `setup.py` in favor of `meson.build` [gh-174](https://github.com/IntelPython/mkl-service/pull/174)

### Fixed

Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,28 @@ A short example, illustrating its use:
```

For more information about the usage of support functions see [Developer Reference for Intel® oneAPI Math Kernel Library for C](https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-c/2025-2/support-functions.html).

---

## Building

A C compiler and Intel(R) oneAPI Math Kernel Library (oneMKL) are required to build mkl-service from source.

Executing
```sh
python -m pip install .
```

will pull in the required build dependencies, including `mkl`, and build `mkl-service`.

If you already have `mkl` installed (from your system or a Conda environment) and
want to reuse it instead of pulling a fresh copy into an isolated build, first
install the build dependencies:
```sh
python -m pip install mkl-devel meson-python cmake ninja cython
```

then build against the existing installation with:
```sh
python -m pip install --no-build-isolation --no-deps .
```
3 changes: 1 addition & 2 deletions conda-recipe-cf/bld.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@rem Remember to activate Intel Compiler, or remove these two lines to use Microsoft Visual Studio compiler

set MKLROOT=%PREFIX%
%PYTHON% setup.py build --force install --old-and-unmanageable
%PYTHON% -m pip install --no-deps --no-build-isolation .
if errorlevel 1 exit 1
4 changes: 2 additions & 2 deletions conda-recipe-cf/build.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash -x
MKLROOT=$PREFIX $PYTHON setup.py build --force install --old-and-unmanageable
#!/bin/bash -ex
$PYTHON -m pip install --no-deps --no-build-isolation .
Comment thread
ndgrigorian marked this conversation as resolved.
7 changes: 3 additions & 4 deletions conda-recipe-cf/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ source:
build:
number: {{ GIT_DESCRIBE_NUMBER }}
skip: true # [osx and arm64]
script_env:
- WHEELS_OUTPUT_FOLDER
ignore_run_exports:
- blas
- mkl-service
Expand All @@ -19,15 +17,16 @@ requirements:
- {{ compiler('c') }}
- {{ stdlib('c') }}
host:
- meson-python >=0.13.0
- cmake
- ninja
- python
- python-gil # [py>=314]
- pip >=25.0
- setuptools >=77
- mkl-devel # [not osx]
- mkl-devel <2024 # [osx]
- cython
- wheel >=0.45.1
- python-build >=1.2.2
Comment thread
ndgrigorian marked this conversation as resolved.
run:
- python
- python-gil # [py>=314]
Expand Down
7 changes: 0 additions & 7 deletions conda-recipe/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ echo on
rem set CFLAGS=-I%PREFIX%\Library\include %CFLAGS%
rem set LDFLAGS=/LIBPATH:%PREFIX% %LDFLAGS%

set MKLROOT=%CONDA_PREFIX%

"%PYTHON%" setup.py clean --all

:: Make CMake verbose
set "VERBOSE=1"

:: -wnx flags mean: --wheel --no-isolation --skip-dependency-check
%PYTHON% -m build -w -n -x
if %ERRORLEVEL% neq 0 exit 1
Expand Down
9 changes: 3 additions & 6 deletions conda-recipe/build.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
#!/bin/bash
set -ex

export MKLROOT=$CONDA_PREFIX

read -r GLIBC_MAJOR GLIBC_MINOR <<<"$(conda list '^sysroot_linux-64$' \
| tail -n 1 | awk '{print $2}' | grep -oP '\d+' | head -n 2 | tr '\n' ' ')"

${PYTHON} setup.py clean --all

# Make CMake verbose
export VERBOSE=1
if [ -d "build" ]; then
rm -rf build
fi

# -wnx flags mean: --wheel --no-isolation --skip-dependency-check
${PYTHON} -m build -w -n -x
Expand Down
6 changes: 4 additions & 2 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ requirements:
- {{ compiler('c') }}
- {{ stdlib('c') }}
host:
- meson-python >=0.13.0
Comment thread
ndgrigorian marked this conversation as resolved.
- cmake
- ninja
- python
- python-gil # [py>=314]
- python-build >=1.2.2
- pip >=25.0
- setuptools >=77
- mkl-devel
- cython
- wheel >=0.45.1
- python-build >=1.2.2
run:
- python
- python-gil # [py>=314]
Expand Down
Loading
Loading