Intel visual Fortran 调用 MKL

本文介绍了如何在Intel Visual Fortran环境下调用Math Kernel Library (MKL)进行矩阵运算。首先,详细阐述了设置IVF以使用MKL的步骤,包括项目属性配置、头文件引用和库链接。接着,通过dgemm矩阵乘法实例及LAPACK函数gbsv的使用,展示了MKL的实际应用,并提到了编译和调试过程。最后,预告了关于ia32和intel64的区别将在后续博客中讨论。
部署运行你感兴趣的模型镜像

Intel visual Fortran 调用 MKL

MKL 是 BLAS, LAPACK 和 ScalLAPACK 等函数库集成的数学例程。其中,Lapack 包含了求解科学与工程计算中最常见的数值线性代数问题。
1 关于调用MKL IVF的设置
a)项目——属性——Fortran——Libraries——Use Intel Math Kernel Library ——Parallel(/Qmkl:parallel)
设置的实例:
1) 启动VS2010
2) 新建项目——Intel Visual Fortran——Consol Application——Empty Projet《命名文件名和项目名》
3)当use声明被用时,需要添加头文件《mkl安装目录\include文件夹中》如C:\Program Files (x86)\Intel\ComposerXE-2011\mkl\include\lapack
右键点击Header file——添加——现项目(G)《选取头文件》
4)设置MKL:
a)项目——属性—— Fortran —— Preprocessor——Preprocess Source File——选取Yes
b) 项目——属性——Fortran——General——Additional Library Directories ——Edit….《mkl安装目录\lib\ia32(或者intel64)》{ia32与intel64之间的区别有待在下一篇博客介绍}
c)项目——属性—— Linker——Input ——Additional Library Directories ——输入《 mkl_intel_c.lib mkl_intel_thread.lib mkl_core.lib libiomp5md.lib》(针对ia32)
2 MKL实例
1) 矩阵相乘 dgemn:
`program main
integer,parameter::N=3000
integer,parameter::M=2000
integer,parameter::K=4000
real(kind=8) a,b
real(kind=8),pointer::x(:,:)
real(kind=8),pointer::y(:,:)
real(kind=8),pointer::z(:,:)
a=1.0
b=0.0
allocate(x(N,K))
allocate(y(K,M))
allocate(z(N,M))
x=10.0
y=20.0
z=0.0
write (*,*) "Performing matrix multiplication..."
call dgemm('n','n',N,M,K,a,x,N,y,K,b,z,N)
write (*,*) "DONE!"
deallocate(x)
deallocate(y)
deallocate(z)
end

2) MKL 帮助文件中实例
a) 右键点击Source Files——添加——现项目——《C:\Program Files (x86)\Intel\ComposerXE-2011\mkl\examples\lapack95\source》gbsv
b) 右键点击Header file——添加——现项目——《C:\Program Files (x86)\Intel\ComposerXE-2011\mkl\include》mkl_lapack
c) 项目——属性—— Fortran —— Preprocessor——Preprocess Source File——选取Yes
d) 项目——属性——Fortran——General——Additional Library Directories ——Edit….《mkl安装目录\lib\ia32(或者intel64)》{ia32与intel64之间的区别有待在下一篇博客介绍}
e)项目——属性—— Linker——Input ——Additional Library Directories ——输入《 mkl_intel_c.lib mkl_intel_thread.lib mkl_core.lib libiomp5md.lib(增加mkl_lapack95.lib 否则会出现Linker 错误)》(针对ia32)
  f) 编译+调试

mkl 帮助文件

您可能感兴趣的与本文相关的镜像

Kotaemon

Kotaemon

AI应用

Kotaemon 是由Cinnamon 开发的开源项目,是一个RAG UI页面,主要面向DocQA的终端用户和构建自己RAG pipeline

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值