如何在命令行上将Intel fortran编译器与MKL结合使用 [英] How to use Intel fortran compiler with MKL on command line
问题描述
我刚刚安装了Fortran OS X *(学生版)的英特尔®Parallel Studio XE Composer版。它带有数学内核库,这就是我购买它的原因。我很难开始MKL。这是我逐步完成的操作。
I've freshly installed the Intel® Parallel Studio XE Composer Edition for Fortran OS X* (student version). It comes with the Math Kernel Library, which is why I bought it. I'm having a hard time getting started with MKL. Here's what I've done step-by-step.
1)安装了用于Fortran OS X *的英特尔®Parallel Studio XE Composer Edition(没问题)。我可以使用 ifort
运行'hello world'脚本,并在末尾使用 -mkl
链接命令问题(尚未调用任何mkl命令)。
1) Installed Intel® Parallel Studio XE Composer Edition for Fortran OS X* (no problem). I can run a 'hello world' script using ifort
and throw the -mkl
link command on at the end with no problem (not calling any mkl commands just yet).
2)之后这些说明我使用intel提供的脚本(精确地位于opt / intel / bin中)设置了环境变量。我有intel 64位体系结构(根据 ifort -V
),所以我使用 bash mklvars.sh intel64 mod ilp64
。它运行无错误(或任何输出)。
2) Following these instructions I set my environment variables using a script provided by intel (located in opt/intel/bin to be precise). I have the intel 64-bit architecture (according to ifort -V
) so I use bash mklvars.sh intel64 mod ilp64
. It runs without error (or any output).
3)我编写了以下代码,以使用MKL的 gemm 命令。只需将2个矩阵相乘即可。
3) I write the following code to use MKL's gemm command for fortran95. Just multiplying 2 matrices.
program test
implicit none
real, dimension(2,2) :: testA, testB, testC
testA = 1
testB = 1
testC = 0 ! I don't think I need this line, but it shouldn't matter
call gemm(testA, testB, testC)
write(*,*) testC
end program test
4)我使用 ifort进行编译test_mkl.f90 -o测试-mkl
。我收到以下错误:
4) I compile with ifort test_mkl.f90 -o test -mkl
. I get the following error:
Undefined symbols for architecture x86_64:
"_gemm_", referenced from:
_MAIN__ in ifortSTVOrB.o
ld: symbol(s) not found for architecture x86_64
未找到符号5)我尝试 ifort test_mkl.f90 -o test -L / opt / intel / mkl / lib -mkl
并得到相同的结果。
5) I try ifort test_mkl.f90 -o test -L/opt/intel/mkl/lib -mkl
and get the same result.
我注意到很多使用MKL的人都以 USE mkl95_blas(仅限:gemm
)开始他们的代码,所以我把上面两个示例中都不隐含
并得到:
I notice a lot of people using MKL begin their code with USE mkl95_blas, ONLY: gemm
, so I put that in above implicit none
in both of the above examples and get:
test_mkl.f90(4): error #7002: Error in opening the compiled module file. Check INCLUDE paths. [MKL95_BLAS]
USE mkl95_blas, ONLY: gemm
--------^
test_mkl.f90(12): error #6406: Conflicting attributes or multiple declaration of name. [GEMM]
call gemm(testA, testB, testC )
---------^
test_mkl.f90(4): error #6580: Name in only-list does not exist. [GEMM]
USE mkl95_blas, ONLY: gemm
--------------------------^
compilation aborted for test_mkl.f90 (code 1)
关于问题是什么或如何解决的任何想法?我已经成功使用MKL在XCODE中运行一个简单的脚本,因此绝对是我在做的事情,而不是我的安装。
Any ideas as to what the problem is or how to fix this? I have successfully run a simple script in XCODE using MKL, so it's definitely something I'm doing and not my installation.
推荐答案
文档告诉您在提供的Compilervars.sh脚本上使用 source命令来使所有资源可用。例如:
The documentation tells you to use the "source" command on the provided compilervars.sh script to make all the resources available. For example:
源//bin/compilervars.sh
source //bin/compilervars.sh
这会将MKL添加到包含和库中路径,以便编译器和链接器可以找到它们。如果您需要更多帮助,请在 https://software.intel.com/zh-cn/forums/intel-fortran-compiler-for-linux-and-mac-os-x 您可以在< a href = https://software.intel.com/en-us/forums/intel-math-kernel-library rel = nofollow> https://software.intel.com/en-us/forums/英特尔数学内核库
This will add MKL to the include and library paths so that the compiler and linker can find them. If you need more help, please ask in https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x You can get MKL-specific help in https://software.intel.com/en-us/forums/intel-math-kernel-library
这篇关于如何在命令行上将Intel fortran编译器与MKL结合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!