Skip to content

Commit 762caad

Browse files
committed
Refine AGENTS docs and resolve PR review comments
1 parent f4fb7ab commit 762caad

7 files changed

Lines changed: 94 additions & 47 deletions

File tree

.github/AGENTS.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
CI/CD workflows, automation, security scanning, and package distribution.
44

55
## Workflows
6-
- **conda-package.yml** — main build/test pipeline (Linux/Windows/macOS, Python 3.10-3.14)
7-
- **build-with-clang.yml** — Clang compiler compatibility validation
6+
- **conda-package.yml** — main build/test pipeline (Linux/Windows, Python 3.10-3.14)
7+
- **build-with-clang.yml**Linux Clang compiler compatibility validation
88
- **pre-commit.yml** — code quality checks (flake8, etc.)
99
- **openssf-scorecard.yml** — security posture scanning
1010

1111
## CI/CD policy
1212
- Keep build matrix (Python versions, platforms) in workflow files only
13-
- Required checks: conda build + test on all supported Python versions
13+
- Required checks: conda build + test on supported Python versions/platforms in CI
1414
- Artifact naming: `$PACKAGE_NAME $OS Python $VERSION`
1515
- Channels: `conda-forge`, `conda-forge/label/python_rc`, Intel channel
1616

@@ -21,8 +21,7 @@ CI/CD workflows, automation, security scanning, and package distribution.
2121

2222
## Platform specifics
2323
- **Linux:** RTLD_GLOBAL handling for MKL library loading
24-
- **Windows:** DLL search path configuration
25-
- **macOS:** dylib loading and rpath setup
24+
- **Windows:** DLL search path configuration for venv/runtime loading
2625

2726
## Notes
2827
- Workflow/job renames are breaking for downstream tooling

.github/copilot-instructions.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# GitHub Copilot Instructions — mkl-service
2+
3+
## Identity
4+
You are an expert Python/Cython/C developer working on `mkl-service` at Intel.
5+
Apply Intel engineering standards: correctness first, minimal diffs, no assumptions.
6+
7+
## Source of truth
8+
This file is canonical for Copilot/agent behavior.
9+
`AGENTS.md` files provide project context.
10+
11+
## Precedence
12+
copilot-instructions > nearest AGENTS > root AGENTS
13+
Higher-precedence file overrides; lower must not restate overridden guidance.
14+
15+
## Mandatory flow
16+
1. Read root `AGENTS.md`. If absent, stop and report.
17+
2. For each edited file, locate and follow the nearest `AGENTS.md`.
18+
3. If no local file exists, inherit rules from root `AGENTS.md`.
19+
20+
## Contribution expectations
21+
- Keep diffs minimal; prefer atomic single-purpose commits.
22+
- Preserve public API signatures in `mkl/__init__.py` unless change is explicitly requested.
23+
- For user-visible behavior changes: update tests in `mkl/tests/test_mkl_service.py`.
24+
- For bug fixes: add or extend regression tests in the same change.
25+
- Do not generate code without corresponding test updates when behavior changes.
26+
- Run `pre-commit run --all-files` when `.pre-commit-config.yaml` is present.
27+
28+
## Authoring rules
29+
- Use source-of-truth files for all mutable details.
30+
- Never invent/hardcode versions, CI matrices, channels, or compiler flags.
31+
- Prefer stable local entry points:
32+
- `python -m pip install -e .`
33+
- `pytest -vv --pyargs mkl`
34+
- Never include secrets/tokens/credentials in files.
35+
36+
## Source-of-truth files
37+
- Build/config: `pyproject.toml`, `setup.py`
38+
- Recipe/deps: `conda-recipe/meta.yaml`, `conda-recipe/conda_build_config.yaml`
39+
- CI: `.github/workflows/*.{yml,yaml}`
40+
- API contracts: `mkl/__init__.py`, `mkl/_mkl_service.pyx`
41+
- Tests: `mkl/tests/test_mkl_service.py`
42+
43+
## MKL-specific constraints
44+
- Linux runtime init path may require `RTLD_GLOBAL` preloading (`mkl/_mklinitmodule.c`).
45+
- Windows venv DLL handling is in `mkl/_init_helper.py`.
46+
- Threading/runtime controls affect downstream MKL-backed libraries (NumPy/SciPy/etc.); maintain compatibility.
47+
- For behavior and semantics of support functions, align with Intel oneMKL developer reference docs.

AGENTS.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@
33
Entry point for agent context in this repo.
44

55
## What this repository is
6-
`mkl-service` provides Python API for runtime control of Intel® OneMKL (Math Kernel Library). It exposes support functions for:
6+
`mkl-service` provides a Python API for runtime control of Intel® oneMKL (Math Kernel Library). It exposes support functions for:
77
- Threading control (set/get number of threads, domain-specific threading)
88
- Version information (MKL version, build info)
99
- Memory management (peak memory usage, memory statistics)
1010
- Conditional Numerical Reproducibility (CNR)
1111
- Timing functions (get CPU/wall clock time)
1212
- Miscellaneous utilities (MKL_VERBOSE control, etc.)
1313

14-
Originally part of Intel® Distribution for Python*, now standalone package available via conda-forge and Intel channels.
14+
Originally part of Intel® Distribution for Python*, now a standalone package available via conda-forge and Intel channels.
1515

1616
## Key components
1717
- **Python interface:** `mkl/__init__.py` — public API surface
1818
- **Cython wrapper:** `mkl/_mkl_service.pyx` — wraps MKL support functions
19-
- **C init module:** `mkl/_mklinitmodule.c` — MKL library initialization
20-
- **Helper:** `mkl/_init_helper.py`loading and RTLD_GLOBAL handling
19+
- **C init module:** `mkl/_mklinitmodule.c`Linux-side MKL runtime preloading / initialization
20+
- **Helper:** `mkl/_init_helper.py`Windows venv DLL loading helper
2121
- **Build system:** setuptools + Cython
2222

2323
## Build dependencies
2424
**Required:**
25-
- Intel® OneMKL
25+
- Intel® oneMKL
2626
- Cython
2727
- Python 3.10+
2828

@@ -33,11 +33,11 @@ python setup.py install
3333
```
3434

3535
## CI/CD
36-
- **Platforms:** Linux, Windows, macOS
36+
- **Platforms in CI workflows:** Linux, Windows
3737
- **Python versions:** 3.10, 3.11, 3.12, 3.13, 3.14
3838
- **Workflows:** `.github/workflows/`
39-
- `conda-package.yml` — main build/test pipeline
40-
- `build-with-clang.yml` — Clang compatibility
39+
- `conda-package.yml` — main conda build/test pipeline
40+
- `build-with-clang.yml`Linux Clang compatibility
4141
- `pre-commit.yml` — code quality checks
4242
- `openssf-scorecard.yml` — security scanning
4343

@@ -48,9 +48,9 @@ python setup.py install
4848
## Usage
4949
```python
5050
import mkl
51-
mkl.set_num_threads(4) # Set global thread count
52-
mkl.domain_set_num_threads(1, "fft") # FFT functions run sequentially
53-
mkl.get_version_string() # MKL version info
51+
mkl.set_num_threads(4) # Set global thread count
52+
mkl.domain_set_num_threads(1, "fft") # FFT functions run sequentially
53+
mkl.get_version_string() # MKL version info
5454
```
5555

5656
## How to work in this repo
@@ -62,12 +62,13 @@ mkl.get_version_string() # MKL version info
6262

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

6970
## Notes
70-
- RTLD_GLOBAL required for MKL on Linux (handled by `RTLD_for_MKL` context manager)
71+
- RTLD_GLOBAL preloading is required on Linux (handled by `RTLD_for_MKL` context manager)
7172
- MKL must be available at runtime (conda: mkl, pip: relies on system MKL)
7273
- Threading functions affect NumPy, SciPy, and other MKL-backed libraries
7374

conda-recipe/AGENTS.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,29 @@ Conda package build recipe for conda-forge and Intel channel distribution.
66
- **meta.yaml** — package metadata, dependencies, build requirements
77
- **build.sh** — Linux/macOS build script
88
- **bld.bat** — Windows build script
9-
- **conda_build_config.yaml**build matrix (Python versions, platforms)
9+
- **conda_build_config.yaml**compiler / stdlib pinning used by conda-build variants
1010

1111
## Build configuration
1212
- **Channels:** `conda-forge`, `conda-forge/label/python_rc`, Intel channel
13-
- **Python versions:** 3.10, 3.11, 3.12, 3.13, 3.14
14-
- **Compilers:** system default (GCC/Clang/MSVC)
15-
- **Dependencies:** mkl (runtime), mkl-devel (build), cython
13+
- **Python versions in CI build matrix:** 3.10, 3.11, 3.12, 3.13, 3.14
14+
- **Compilers:** pinned via `conda_build_config.yaml` (GCC/GXX on Linux, VS2022 on Windows)
15+
- **Dependencies:** `mkl` (runtime), `mkl-devel` (build), `cython`
1616

1717
## Build outputs
1818
- Conda package: `mkl-service-<version>-<build>.conda`
19-
- Platform-specific: `linux-64/`, `win-64/`, `osx-64/`, `osx-arm64/`
19+
- Platform-specific artifacts from CI currently: `linux-64/`, `win-64/`
2020

2121
## CI usage
2222
- Built in `.github/workflows/conda-package.yml`
2323
- Artifacts uploaded per Python version and platform
24-
- Test stage uses built artifacts from channel
24+
- Test stage uses built artifacts from a temporary local channel
2525

2626
## Platform specifics
27-
- **Linux:** RTLD_GLOBAL handling in build script
27+
- **Linux:** RTLD_GLOBAL handling in runtime init path
2828
- **Windows:** MKL library path configuration
29-
- **macOS:** Universal2 builds for Intel + ARM (if supported)
29+
- **macOS:** recipe scripts exist, but current GitHub Actions matrix does not build/test macOS
3030

3131
## Maintenance
32-
- Keep `conda_build_config.yaml` in sync with CI matrix
33-
- MKL version pin: track Intel MKL releases
34-
- Python 3.14: requires `conda-forge/label/python_rc` until stable
32+
- Keep recipe metadata in sync with workflow matrix and package metadata
33+
- MKL version pinning: track Intel MKL releases through recipe deps
34+
- Python 3.14 in CI uses `conda-forge/label/python_rc` while pre-release

examples/AGENTS.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
Usage examples for mkl-service runtime control API.
44

55
## Files
6-
- **example.py** — basic usage: threading control, version info, timing
6+
- **example.py** — basic usage: MKL version query, instruction dispatch control, and timing
77

88
## Examples cover
9-
- Setting global thread count with `mkl.set_num_threads()`
10-
- Domain-specific threading (FFT, BLAS, etc.)
11-
- Querying MKL version and build info
12-
- Memory usage statistics
13-
- Timing functions for benchmarking
9+
- Querying MKL version/build info (`get_version()`, `get_version_string()`)
10+
- Controlling instruction dispatch with `enable_instructions()`
11+
- Using `dsecnd()` for simple timing
1412

1513
## Running examples
1614
```bash
@@ -19,5 +17,5 @@ python examples/example.py
1917

2018
## Notes
2119
- Examples assume MKL is installed (conda: `mkl` package)
22-
- Threading changes affect all MKL-backed libraries in the process
23-
- Useful for verifying mkl-service installation and MKL availability
20+
- Example is intended as a lightweight installation/runtime sanity check
21+
- Threading/domain APIs are available in `mkl-service` but not exercised in this example

mkl/AGENTS.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Core Python/Cython implementation: MKL support function wrappers and runtime con
66
- `__init__.py` — public API, RTLD_GLOBAL context manager, module initialization
77
- `_mkl_service.pyx` — Cython wrappers for MKL support functions
88
- `_mkl_service.pxd` — Cython declarations (C function signatures)
9-
- `_mklinitmodule.c` — C extension for MKL library initialization
10-
- `_init_helper.py` — loading helpers and diagnostics
9+
- `_mklinitmodule.c` — C extension for Linux-side MKL runtime preloading/init
10+
- `_init_helper.py`Windows loading helper (DLL path setup in venv)
1111
- `_version.py` — version string (dynamic via setuptools)
1212
- `tests/` — unit tests for API functionality
1313

@@ -38,17 +38,19 @@ Core Python/Cython implementation: MKL support function wrappers and runtime con
3838
- **Thread safety:** All threading functions must be thread-safe
3939
- **API stability:** Preserve function signatures (widely used in ecosystem)
4040
- **MKL dependency:** Assumes MKL is available at runtime (conda: mkl package)
41-
- **RTLD_GLOBAL:** Required on Linux; handled by `RTLD_for_MKL` context manager in `__init__.py`
41+
- **RTLD_GLOBAL preload path:** Linux preload is handled in `_mklinitmodule.c`; Windows DLL setup is in `_init_helper.py`
4242

4343
## Cython details
4444
- `_mkl_service.pyx` → generates `_py_mkl_service` extension module
4545
- `.pxd` file declares external C functions from MKL headers
46-
- Cython build requires MKL headers (mkl-devel)
46+
- Cython build requires MKL headers (`mkl-devel`)
4747

4848
## C init module
4949
- `_mklinitmodule.c``_mklinit` extension
50-
- Ensures MKL library is loaded with correct flags before Cython extension
51-
- Platform-specific: Windows uses `LoadLibrary`, Linux uses `dlopen`
50+
- Ensures MKL runtime is initialized with correct flags before Cython extension
51+
- Platform-specific behavior in current code:
52+
- Linux: `dlopen(..., RTLD_GLOBAL)` preload path (when applicable)
53+
- Windows: runtime DLL loading support is handled by `_init_helper.py`
5254

5355
## Notes
5456
- Domain strings: "fft", "vml", "pardiso", "blas", etc. (see MKL docs)

mkl/tests/AGENTS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ Unit tests for MKL runtime control API.
1010
- Version: `get_version`, `get_version_string` format validation
1111
- Memory: `peak_mem_usage`, `mem_stat` (if supported by MKL build)
1212
- CNR: Conditional Numerical Reproducibility flags
13-
- Edge cases: invalid domains, negative thread counts, thread-local settings
13+
- Edge cases currently covered: thread-local settings and API round-trips
1414

1515
## Running tests
1616
```bash
1717
pytest mkl/tests/
1818
```
1919

2020
## CI integration
21-
- Tests run in conda-package.yml workflow
22-
- Separate test jobs per Python version and platform
23-
- Linux + Windows + macOS coverage
21+
- Tests run in `conda-package.yml` workflow
22+
- Separate test jobs per Python version and CI platform
23+
- CI coverage: Linux + Windows
2424

2525
## Adding tests
2626
- New API functions → add to `test_mkl_service.py` with validation

0 commit comments

Comments
 (0)