{"library":"mkl-include","title":"Intel® oneAPI Math Kernel Library Headers","description":"Intel® oneAPI Math Kernel Library (oneMKL) is a highly optimized, extensively threaded math library for high-performance computing. The `mkl-include` package provides the C and Data Parallel C++ (DPC++) programming language interfaces (header files) required for building applications and other libraries that link against oneMKL. It helps optimize numerical routines for Intel® CPUs and GPUs. The current version is 2025.3.1, with frequent releases aligning with the Intel oneAPI toolkit cadence.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install mkl-include"],"cli":null},"imports":["This package provides C/C++ header files and is not directly imported in Python user code. Python interaction with MKL is typically through other libraries (e.g., NumPy, SciPy, or `mkl-service`) that are built to use MKL."],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import numpy as np\nimport os\n\n# --- Check if NumPy is linked against MKL (requires mkl-service or similar detection) ---\ntry:\n    import mkl\n    print(f\"MKL-service is imported. MKL version: {mkl.get_version()}\")\n    print(f\"MKL number of threads: {mkl.get_max_threads()}\")\n    print(\"NumPy is likely using MKL through the loaded mkl-service library.\")\nexcept ImportError:\n    print(\"mkl-service not found. Checking numpy config.\")\n\n# A more direct way to check NumPy's backend (may not explicitly show MKL vs OpenBLAS, etc.)\nprint(f\"\\nNumPy config:\\n{np.show_config()}\")\n\n# --- Example of using mkl-service to control MKL runtime (if installed) ---\nif 'mkl' in locals():\n    # Set MKL to use a specific number of threads for a domain\n    mkl.set_num_threads(2)\n    print(f\"\\nMKL threads set to: {mkl.get_max_threads()}\")\n    \n    # Perform a computation that would benefit from MKL\n    a = np.random.rand(1000, 1000)\n    b = np.random.rand(1000, 1000)\n    c = a @ b # Matrix multiplication, often MKL-accelerated\n    print(f\"Matrix multiplication completed. Shape: {c.shape}\")\n\n# To explicitly use MKL for a library like NumPy, you generally install a MKL-optimized build.\n# Example (concept, exact command depends on source):\n# pip install numpy scipy --index-url https://urob.github.io/numpy-mkl # For specific MKL wheels","lang":"python","description":"The `mkl-include` package itself is not directly used in Python code. Instead, it provides the necessary build-time headers for other Python libraries (like NumPy or SciPy) to be compiled and linked against the Intel oneMKL for performance acceleration. This quickstart demonstrates how to check if NumPy is utilizing MKL (e.g., via `mkl-service`) and how to use `mkl-service` for runtime control over MKL behavior within Python.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}