Skip to content
Merged
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
46 changes: 46 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[flake8]
extend-ignore =
# whitespace before ':' (currently conflicts with black formatting):
E203,
# line too long (in docstrings):
E501,
# ‘from module import *’ used; unable to detect undefined names:
F403,
# doc line too long (105 > 80 characters):
W505,
# missing docstring in public module:
D100,
# missing docstring in public class:
D101,
# missing docstring in public method:
D102,
# missing docstring in public function:
D103,
# missing docstring in public package:
D104,
# missing docstring in magic method:
D105,
# missing docstring in __init__:
D107,
# no blank lines allowed after function docstring:
D202,
# 1 blank line required between summary line and description:
D205,
# first line should end with a period:
D400,
# first line should be in imperative mood:
D401,
# first line should not be the function's "signature":
D402,

per-file-ignores =
mkl/__init__.py: E402, F401, F405

filename = *.py, *.pyx, *.pxi, *.pxd
max_line_length = 80
max-doc-length = 80
show-source = True

# Print detailed statistic if any issue detected
count = True
statistics = True
4 changes: 4 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# $ git config blame.ignoreRevsFile .git-blame-ignore-revs

# Add pre-commit hooks
9c1fb5bd9b946c2eaaf1ea882e789efcccf66b53
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,7 +73,7 @@ jobs:
export CFLAGS="${CFLAGS} -fno-fast-math"
python setup.py develop

- name: Run mkl-service tests
- name: Run mkl-service tests
run: |
source ${{ env.ONEAPI_ROOT }}/setvars.sh
pytest -s -v --pyargs mkl
8 changes: 4 additions & 4 deletions .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- uses: actions/[email protected]
with:
fetch-depth: 0
Expand All @@ -114,7 +114,7 @@ jobs:

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

- name: Upload artifact
uses: actions/[email protected]
with:
Expand Down Expand Up @@ -254,9 +254,9 @@ jobs:
restore-keys: |
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-

# add intel-openmp as an explicit dependency
# to avoid it being missed when package version is specified exactly
# to avoid it being missed when package version is specified exactly
- name: Install mkl-service
shell: cmd
run: |
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: pre-commit

on:
pull_request:
push:
branches: [master]

permissions: read-all

jobs:
pre-commit:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repo
uses: actions/[email protected]

- name: Set up python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Set up pip packages
uses: BSFishy/pip-action@v1
with:
packages: |
codespell
pylint

- name: Set up clang-format
run: |
sudo apt-get install -y clang-format-14
sudo unlink /usr/bin/clang-format
sudo ln -s /usr/bin/clang-format-14 /usr/bin/clang-format
clang-format --version

- name: Run pre-commit checks
uses: pre-commit/[email protected]
103 changes: 103 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-ast
- id: check-builtin-literals
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-toml
- id: debug-statements
- id: destroyed-symlinks
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: trailing-whitespace

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-check-mock-methods
- id: python-no-eval
- id: python-no-log-warn
- id: python-use-type-annotations
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
- id: text-unicode-replacement-char

- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
- id: codespell
additional_dependencies:
- tomli

- repo: https://github.com/psf/black
rev: 25.1.0
hooks:
- id: black
exclude: "_vendored/conv_template.py"

- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.3.5
hooks:
- id: clang-format
args: ["-i"]

- repo: https://github.com/MarcoGorelli/cython-lint
rev: v0.16.6
hooks:
- id: cython-lint
- id: double-quote-cython-strings

- repo: https://github.com/pycqa/flake8
rev: 7.1.2
hooks:
- id: flake8
args: ["--config=.flake8"]
additional_dependencies:
- flake8-docstrings==1.7.0
- flake8-bugbear==24.4.26

- repo: https://github.com/pycqa/isort
rev: 6.0.1
hooks:
- id: isort
name: isort (python)
- id: isort
name: isort (cython)
types: [cython]
- id: isort
name: isort (pyi)
types: [pyi]

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.14.0
hooks:
- id: pretty-format-toml
args: [--autofix]

- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
require_serial: true
args:
[
"-rn", # Only display messages
"-sn", # Don't display the score
"--errors-only",
"--disable=import-error",
]

- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
- id: shellcheck
45 changes: 21 additions & 24 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,51 @@
`mkl-service` changelog
=======================
# changelog
All notable changes to this project will be documented in this file.

[dev] (MM/DD/YY)
================
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

Migrated from `setup.py` to `pyproject.toml`
## [dev] (MM/DD/YY)

Added support for python 3.13
### Added
* Added support for python 3.13 [gh-72](github.com/IntelPython/mkl-service/pull/72)

2.3.0
=====
### Changed
* Migrated from `setup.py` to `pyproject.toml` [gh-66](github.com/IntelPython/mkl-service/pull/66)


## [2.3.0]

Fixed CI to actually execute tests. Populated CBWR constants to match MKL headers.

Added tests checking that `cbwr_set` and `cbwr_get` round-trip.

2.2.0
=====
## [2.2.0]

Closed issues #8, #7 and #5.
Closed issues #8, #7 and #5.

Extended `mkl.cbwr_set` to recognize `'avx512_e1'`, `'avx512_mic_e1'`, as as strict conditional numerical reproducibility, supported via `'avx2,strict'`, `'avx512,strict'` (see [issue/8](http://github.com/IntelPython/mkl-service/issues/8)).

Extended `mkl.cbwrt_get()` to mean `mkl.cbwr('all')`.

2.1.0
=====
## [2.1.0]

Change in setup script to not use `numpy.distutils` thus removing numpy as build-time dependency.

Change in conda-recipe to allow conda build to build the recipe, but ignoring run export on mkl-service coming from mkl-devel metadata.
Change in conda-recipe to allow conda build to build the recipe, but ignoring run export on mkl-service coming from mkl-devel metadata.

2.0.2
=====
## [2.0.2]

Correction to `setup.py` to not require Cython at the installation time.

2.0.1
=====
## [2.0.1]

Re-release, with some changes necessary for public CI builds to work.

2.0.0
=====
## [2.0.0]

Work-around for VS 9.0 not having `inline` keyword, allowing the package to build on Windows for Python 2.7

2.0.0
=====
## [2.0.0]

Rerelease of `mkl-service` package with version bumped to 2.0.0 to avoid version clash with `mkl-service` package from Anaconda.

Expand All @@ -57,7 +55,6 @@ Loading the package with `import mkl` initializes Intel(R) MKL library to use LP

The choice of threading layer can be controlled with environment variable `MKL_THREADING_LAYER`. However the unset variable is interpreted differently that in Intel(R) MKL itself. If `mkl-service` detects that Gnu OpenMP has been loaded in Python space, the threading layer of Intle(R) MKL will be set to Gnu OpenMP, instead of Intel(R) OpenMP.

1.0.0
=====
## [1.0.0]

Initial release of `mkl-service` package.
24 changes: 15 additions & 9 deletions examples/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,45 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# pylint: disable=no-member

import mkl
import re

import mkl


def enable_best_instructions_set():
for instructions_set in ['avx512', 'avx2', 'avx', 'sse4_2']:
if mkl.enable_instructions(instructions_set) == 'success':
for instructions_set in ["avx512", "avx2", "avx", "sse4_2"]:
if mkl.enable_instructions(instructions_set) == "success":
result = instructions_set
break
else:
result = 'error'
result = "error"

return result


def is_max_supported_instructions_set(instructions_set):
result = False
if re.search(instructions_set.replace('4_2', '4.2'), mkl.get_version()['Processor'].decode(), re.IGNORECASE):
if re.search(
instructions_set.replace("4_2", "4.2"),
mkl.get_version()["Processor"].decode(),
re.IGNORECASE,
):
result = True

return result


if __name__ == '__main__':
if __name__ == "__main__":
time_begin = mkl.dsecnd()
print(mkl.get_version_string())

instructions_set = enable_best_instructions_set()
print('Enable snstructions set: ' + str(instructions_set))
print("Enable snstructions set: " + str(instructions_set))

is_max = is_max_supported_instructions_set(instructions_set)
print('Is the best supported instructions set: ' + str(is_max))
print("Is the best supported instructions set: " + str(is_max))

time_end = mkl.dsecnd()
print('Execution time: ' + str(time_end - time_begin))
print("Execution time: " + str(time_end - time_begin))
Loading