2015-07-19 211 views
3

我剛剛安裝了用於Fortran OS X *(學生版)的英特爾®Parallel Studio XE Composer版。它帶有Math Kernel Library,這就是我購買它的原因。我很難開始使用MKL。這是我一步一步完成的。如何在命令行上使用英特爾Fortran編譯器和MKL

1)安裝了用於Fortran OS X *的英特爾®Parallel Studio XE Composer Edition(沒有問題)。我可以使用ifort運行一個'hello world'腳本,並在末尾拋出-mkl鏈接命令(沒有調用任何mkl命令)。

2)以下these instructions我使用intel提供的腳本(精確地位於opt/intel/bin中)設置我的環境變量。我有intel 64位架構(根據ifort -V),所以我使用bash mklvars.sh intel64 mod ilp64。它運行沒有錯誤(或任何輸出)。

3)我寫下面的代碼,以使用MKL的gemm命令fortran95。只需乘以2個矩陣。

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 test -mkl編譯。我收到以下錯誤:

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並得到相同的結果。

我注意到有很多人使用MKL的人開始自己的代碼USE mkl95_blas, ONLY: gemm,所以我把在上面的兩個例子,並得到上述implicit none

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的run a simple script in XCODE,所以這絕對是我正在做的事情,而不是我的安裝。

+0

查看是否可以找到該模塊的路徑... – Jeff

+1

您必須爲rigjt include路徑設置環境。這是您在英特爾支持論壇上應該詢問的一個典型問題,您需要爲您的支持付費。 –

+0

感謝弗拉基米爾,看到您的評論後,我嘗試了MKL的英特爾支持論壇,並在那裏找到了一些幫助。 – benten

回答

1

該文檔告訴您在提供的compilervars.sh腳本上使用「source」命令來使所有資源可用。例如:

源//bin/compilervars.sh

這將增加MKL的包括和庫路徑,使編譯器和鏈接可以找到它們。如果您需要更多幫助,請詢問https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x您可以通過https://software.intel.com/en-us/forums/intel-math-kernel-library獲得MKL特定幫助

+0

另外,顯然OS X中的.mod文件的名稱與別處不同。我將我的'use'語句更改爲:USE blas95,它反映了我的.mod文件的名稱。這個改變+你對source命令的建議做到了訣竅。 (具體來說,我看了[此鏈接](https://software.intel.com/zh-cn/forums/topic/281190))。 – benten

+1

不,發生了什麼事是MKL更改了更新的MKL版本中模塊的名稱。有關詳細信息,請參閱MKL發行說明。 –

+0

啊,很高興知道這不是一個OS X的事情。 – benten