intel MKL的安装和使用

本文档介绍了Intel Math Kernel Library(Intel MKL)的安装、配置环境变量、运行示例以及自动链接Visual C/C++项目的方法。Intel MKL提供广泛的计算支持,包括BLAS、LAPACK线性代数函数、PARDISO稀疏求解器、向量数学和统计函数等。通过mklvars.bat文件设置环境变量,并通过提供的示例检查系统上的正确运行。对于Microsoft Visual C/C++项目,可以配置自动链接Intel MKL,简化链接过程。

来源于官方文档地址:https://software.intel.com/en-us/articles/intel-math-kernel-library-documentation/
Intel MKL provides comprehensive functionality support in these major areas of computation:
• BLAS (level 1, 2, and 3) and LAPACK linear algebra routines, offering vector, vector-matrix, and matrixmatrix operations.
• Intel MKL PARDISO (a direct sparse solver based on Parallel Direct Sparse Solver PARDISO*), an iterative sparse solver, and supporting sparse BLAS (level 1, 2, and 3) routines for solving sparse systems of equations, as well as a distributed version of Intel MKL PARDISO solver provided for use on clusters.
• Vector Mathematics (VM) routines for optimized mathematical operations on vectors.
• Vector Statistics (VS) routines, which offer high-performance vectorized random number generators (RNG) for several probability distributions, convolution and correlation routines, and summary statistics functions.
• Data Fitting Library, which provides capabilities for spline-based approximation of functions, derivatives and integrals of functions, and search.
• Deep Neural Network (DNN) primitive functions with C language interface.
很丰富的支持。

这里写图片描述

get started

After installing the Intel® Math Kernel Library (Intel® MKL), verify that the library is properly installed and configured:
1. Intel MKL installs in the directory. Check that the subdirectory of referred to as was created. Check that subdirectories for Intel MKL redistributable DLLs redist\ia32_win\mkl and redist \intel64_win\mkl were created in the directory (See redist.txt in the Intel MKL documentation directory for a list of files that can be redistributed.)
2. If you want to keep multiple versions of Intel MKL installed on your system, update your build scripts to point to the correct Intel MKL version.
3. Check that the mklvars.bat file appears in the \bin directory. Use this file to assign Intel MKL-specific values to several environment variables, as explained in Scripts to Set Environment Variables Setting Environment Variables .
4. To understand how the Intel MKL directories are structured, see Structure of the Intel® Math Kernel Library.
5. To make sure that Intel MKL runs on your system, launch an Intel MKL example, as explained in Using Code Examples.

配置环境变量

这里写图片描述

运行范例

The Intel MKL package includes code examples, located in the examples subdirectory of the installation directory. Use the examples to determine:
• Whether Intel MKL is working on your system
• How you should call the library

这里写图片描述

这里写图片描述

Automatically Linking Your Microsoft Visual C/C++* Project with Intel® MKL

Configure your Microsoft Visual C/C++* project for automatic linking with Intel MKL as follows: 1. Go to Project>Properties>Configuration Properties>Intel Performance Libraries.
2. Change the Use MKL property setting by selecting Parallel, Sequential, or Cluster as appropriate. Specific Intel MKL libraries that link with your application may depend on more project settings. For details, see the documentation for Intel®Parallel Studio XE Composer Edition for C++.

Using the Single Dynamic Library

You can simplify your link line through the use of the Intel MKL Single Dynamic Library (SDL).
To use SDL, place mkl_rt.lib on your link line.
For example: icl.exe application.c mkl_rt.lib

mkl_rt.lib is the import library for mkl_rt.dll.
SDL enables you to select the interface and threading library for Intel MKL at run time. By default, linking with SDL provides:
• Intel LP64 interface on systems based on the Intel® 64 architecture
• Intel threading To use other interfaces or change threading preferences, including use of the sequential version of Intel MKL, you need to specify your choices using functions or environment variables as explained in section Dynamically Selecting the Interface and Threading Layer.

getting help and support

Intel provides a support web site that contains a rich repository of self help information, including getting started tips, known product issues, product errata, license information, user forums, and more. Visit the Intel MKL support website at http://www.intel.com/software/products/support/. You can get context-sensitive help when editing your code in the Microsoft Visual Studio* integrated development environment (IDE). See Getting Assistance for Programming in the Microsoft Visual Studio* IDE for details.

### 如何逐步安装 Intel MKL #### 准备工作 为了成功安装 Intel Math Kernel Library (MKL),确保操作系统已更新至最新状态并安装必要的依赖项。对于 Linux 用户,建议先安装内核头文件以支持后续操作[^3]。 #### 下载 Intel MKL 访问官方网站获取最新的 Intel MKL 版本。选择适合目标平台的操作系统版本下载相应的安装包。通常会提供图形界面命令行两种安装方式供用户选择。 #### 自定义安装选项 启动安装程序时推荐采用自定义模式来精确控制所需组件的选择。这有助于减少磁盘占用并仅保留必需的功能模块。如果C盘有足够的存储空间,则无需调整默认路径设置[^4]。 #### 设置环境变量 完成软件部署之后,需配置系统的环境变量以便能够顺利调用库函数。部分情况下这些变动会在安装过程中自动完成;然而手动确认总是更为稳妥的做法。具体方法取决于所使用的Shell类型(如bash,zsh等),一般涉及编辑`~/.bashrc`或其他类似的初始化脚本文件,在其中加入指向新安装目录下的bin与lib子文件夹的PATH声明语句以及LD_LIBRARY_PATH设定指令。 #### 测试验证安装成果 最后一步是对刚刚装好的Intel MKL执行简单的测试案例加以检验其可用性性能表现。官方文档提供了多个可供参考的例子,位于Support Files for Intel MKL Examples下,按照指示加载对应的项目即可开始尝试[^1]。 ```python import numpy as np from scipy import linalg # 创建随机矩阵A A = np.random.rand(100, 100) # 使用Intel MKL加速线性代数运算 result = linalg.inv(A) print(result) ```
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Z_shsf

来包瓜子嘛,谢谢客官~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值