Intel Composer XE 2013 Update 2 Linux (Ubuntu 14.04) 安裝筆記

序言:在intel處理器平臺上編寫應用程序,如果能使用Intel公司開發的C/C++編譯器(即Intel C/C++ Compiler,以下簡稱ICPC)能充分的利用SSE這樣的單指令多操作數指令,能大大加速矩陣、矢量和循環運算的執行速度。此外,ICPC從版本11開始逐步支持C++ 11標準。

本文以Ubuntu 14.04(64位)爲例,介紹ICPC Parallel Studio XE 2013 (Update2,x64)在Linux下的完整安裝過程。

【轉載請註明出處,多謝支持!】


一、安裝前的準備

首先確認下載的安裝包存放在Linux內建的磁盤分區上,即格式位EXT,否則後續直接解壓時可能出現部分文件的屬性設置不對。在Ubuntu下,可以臨時將壓縮包拷貝到用戶根目錄的“下載”文件夾中。

啓動控制檯(Ctrl+Alt+T),輸入如下命令($ 表示提示符,不用輸入):

$ cd $HOME/下載

或者直接在圖形界面中找到“下載”文件夾,然後在右鍵菜單中選擇“在終端中打開“”也可以直接進入到需要操作的目錄中。接着輸入解壓命令:

tar –xzvfname-of-downloaded-file

其中,name-of-downloaded-file是你下載的軟件包名稱,例如“Intel.Paralle.Studio.XE.2013.Update2.x64.Linux.tgz”。執行命令後稍等一會兒,tar命令會在當前目錄下生成一個與壓縮包完全一樣名稱的目錄,其中包含的就是整個需要安裝的ICPC軟件包(其實該文件夾類似於DVD的根目錄)。

有關的軟件和硬件配置要求,可以查閱文件夾中的“Release_Notes_Studio_XE_2013_L.pdf”。如果軟、硬件要求具備,就可以進行下一步了。

注意,對於Ubuntu的支持,文檔中只明確說了支持12.04版,但後面將會看到14.04實際上也可以使用,不過需要將GCC編譯器的版本指定爲V4.4即可。


二、開始安裝

安裝一共分爲7步:

步驟1:啓動安裝腳本

啓動前請確認“install.sh”的文件屬性,如下圖。


請注意第一組當前用戶屬性位(從左邊開始第2-4位)“rwx”,即具備讀、寫和運行屬性,而且文件是以綠色高亮顯示,表示屬性正常。

$ ./install.sh        


腳本啓動後會看到安裝提示(如下):



一般根據推薦選擇第1項,即讓所有用戶都可以使用編譯器。


隨後開始初始化。注意安裝過程中千萬不要隨意按“Ctrl+C”,否則會強行終止腳本。


步驟2:閱讀許可協議

這一步主要是閱讀和接受許可協議,不用多說微笑



在閱讀完畢後,直接按“q”鍵盤退出,然後輸入“accept”(注意全部小寫)



步驟3:激活許可證

如果你手頭有許可證,那麼請注意這一步的操作(如果沒有許可證文件可以選擇第1項然後選“Evaluation”)。



選擇第3項“I want to activate either remotely, or by using a license file, or by using a license manager”(注意文字說明,有時候該項放在第4個位置)。之後,屏幕上會進一步詢問具體的激活方式(如下圖):


選擇第2項,然後稍等幾秒中,安裝腳本會接着提示:“Please type the full path to your license file(s)”,此時請輸入許可證的完整路徑。如果使用粘貼建議從“編輯”菜單操作爲妥,以免誤按Ctrl+C組合鍵。


注意路徑和文件名一定完整。如果一切順利,可以看到許可證激活成功。


步驟4:是否參與“Software Improvement Program(軟件改進計劃)”



這一步是詢問用戶是否參與“軟件改進計劃”,一般選擇參與(即第1項)。如果非常介意隱私數據就選擇第2項。無論選哪項都可以,不用糾結。吐舌頭


步驟5:設定安裝路徑和組件選項

接下來會讓你設定安裝路徑和選項(如下圖),這一步爲了省事我選擇的是默認選項。如果你的硬盤控件很緊張,可以考慮選擇第3項,去掉部分不需要的組件(例如Vtune、Inspector等等)。注意:如果沒有特殊原因,不建議修改默認的安裝目錄(即opt/intel)。



在繼續之前,如果需要可以選擇第5項,確認一下所有的安裝選項(如下圖)。

Pre-install Summary


步驟6:安裝腳本執行安裝配置(等待大約20-30分鐘)

在安裝正式開始之前,可能會出現Ptrace被鎖定的警告(如下圖)。

Pre-Intall Warning

或者由於Ubuntu 14.04的版本不是 Intel官方測試的支持版本,出現兼容性警告。這些都可以在安裝時暫時忽略。


步驟7:安裝結束及安裝過程摘要

整個安裝過程順利結束後,會提示用戶結束並給出摘要。以下是摘要全文(在你自己的安裝過程中,可能因配置有所差異)。請注意其中紅色文字,它們分別給出瞭如何啓動相關組件的概要說明。


Step no: 7 of 7 | Complete

--------------------------------------------------------------------------------
Thank you for installing and using the
Intel(R) Parallel Studio XE 2013 Update 2 for Linux*

Reminder: Intel(R) VTune(TM) Amplifier XE users must be members of the "vtune"
permissions group in order to use Event-based Sampling.

To register your product purchase, visit
https://registrationcenter.intel.com/RegCenter/registerexpress.aspx?media=5G9
    
To get started using Intel(R) VTune(TM) Amplifier XE 2013 Update 4:
    - To set your environment variables: source /opt/intel/vtune_amplifier_xe_2013/amplxe-vars.sh
    - To start the graphical user interface: amplxe-gui
    - To use the command-line interface: amplxe-cl
    - For more getting started resources: /opt/intel/vtune_amplifier_xe_2013/
      documentation/en/welcomepage/get_started.html.

To get started using Intel(R) Inspector XE 2013 Update 4:
    - To set your environment variables: source /opt/intel/inspector_xe_2013/inspxe-vars.sh
    - To start the graphical user interface: inspxe-gui
    - To use the command-line interface: inspxe-cl
    - For more getting started resources: /opt/intel/inspector_xe_2013/
      documentation/en/welcomepage/get_started.html.

To get started using Intel(R) Advisor XE 2013 Update 2:
    - To set your environment variables: source /opt/intel/advisor_xe_2013/advixe-vars.sh
    - To start the graphical user interface: advixe-gui
    - To use the command-line interface: advixe-cl
    - For more getting started resources: /opt/intel/advisor_xe_2013/
      documentation/en/welcomepage/get_started.html.

To get started using Intel(R) Composer XE 2013 Update 2 for Linux*:
    - Set the environment variables for a terminal window using one of the
      following (replace "intel64" with "ia32" if you are using a 32-bit
      platform).
      For csh/tcsh:
           $ source /opt/intel/bin/compilervars.csh intel64
      For bash:(注:Ubuntu 選擇此項)
           $ source /opt/intel/bin/compilervars.sh intel64
      To invoke the installed compilers:
           For C++: icpc

           For C: icc
           For Fortran: ifort

      To get help, append the -help option or precede with the man command.
    - For more getting started resources:
           /opt/intel/composer_xe_2013/Documentation/en_US/get_started_lc.htm.
           /opt/intel/composer_xe_2013/Documentation/en_US/get_started_lf.htm.


      
To view movies and additional training, visit
http://www.intel.com/software/products.

--------------------------------------------------------------------------------
q. Quit [default]
--------------------------------------------------------------------------------

這一步中只需要按q鍵退出即可結束整個安裝過程。


二、安裝驗證

1)驗證性能調節組件(VTune Amplifier、Inspector和Advisor)的安裝


爲了驗證安裝是否正確,可以先嚐試着啓動一個圖形界面的工具試試看。譬如,啓動Intel VTune Amplifier的GUI,命令如下。

$ source /opt/intel/vtune_amplifier_xe_2013/amplxe-vars.sh

$ amplxe-gui


如果安裝正確,應該看到GUI環境順利啓動(參考下圖)。


Intel VTune GUI

其他工具的啓動可以參考第7步安裝結束摘要中加粗的紅色文字。


1)驗證編譯器的安裝(重點)

由於這次安裝的主要目的是爲了使用Intel的編譯器,所以一定要驗證ICPC是否正確安裝。先準備一個符合C++ 11的迷你測試程序。代碼如下,將其保存爲“test.cpp”文件。

//Program to test the new C++11 lambda syntax
#include <iostream>
using namespace std;
int main()
{
    cout << [](int m,int n) {return m + n;} (2,4) <<endl;
    return 0;
}
從安裝過程摘要(注意摘要中加粗的內容)中可以看到,在設置環境變量之後從命令行運行icpc(注意命令全部小寫)對文件進行編譯。需要執行的設定命令爲

$ source /opt/intel/bin/compilervars.sh intel64       

不過,正如本文開頭說的,因爲Ubuntu 14.04中的編譯器版本默認是V4.8,所以直接編譯有些問題——執行“icpc test.cpp”命令後顯示如下出錯信息。

icpc-error

查閱CSDN上的許多博文後,沒發現有現成的答案。於是,我使用如下命令導出了icpc程序的詳細幫助信息。

$ icpc --help >> help.log       

結合幫助信息和Intel的官方文檔(intel-linux-compiler-14-0-gnu-compatibility-rev4.pdf),終於發現指定GCC V4.4所附帶的STL庫進行編譯可以解決這個問題(其間還花了一些功夫搜索/usr/include/下各種庫的目錄,發現GCC 4.4版本的目錄符合出錯位置的依存關係)。於是使用如下命令進行編譯:

$ icpc -gcc-name=/usr/bin/gcc-4.4 -std=c++11 test.cpp -o test.out      

其中,-gcc-name=<dir>中<dir>是指定版本的GCC可執行文件,只要指定它,ICPC會自動尋找依賴關係;-std=c++11是指定按照C++

11標準進行編譯,否則會提示lamda表達式無法解析。編譯成功後可以運行以下test.out程序,會顯示結果爲“6”。


至此,ICPC的所有安裝和測試工作都已完成。另外,順便說一下,ICPC在發行時已經自帶了對Eclipse的支持插件。不過,我更願意用CodeBlocks,更小而且更快。大笑


三、其他參考資料


1)wikipedia上SSE的介紹

2)Intel C/C++ 編譯器各版本對C++ 11 標準的支持程度對比


更新說明:

1) 2015-01-18

修正了一處描述錯誤,在第二部分(二:安裝驗證)中,有關GUI界面工具的啓動命令進行了更正。

更正前:

$ source /opt/intel/vtune_amplifier_xe_2013/amplxe-vars.sh
更正後:
$ source /opt/intel/vtune_amplifier_xe_2013/amplxe-vars.sh
$ amplxe-gui


=======================================================================


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章