Ubuntu 11.10に Intel(R) C++ Studio XE 2011 SP1 Update 1 for Linux

インストール

Intel Compilerの評価版をインストール。種類がいろいろとあるけれども基本は下位互換な模様。

  1. Intel C++ Composer XE 2011:インテルのCとC++コンパイラーおよびライブラリーが入った製品
  2. Intel Composer XE 2011:Intel C++ Composer XE 2011にFortranコンパイラ
  3. Intel Cluster Studio 2011:Intel Composer XE 2011 + MPIライブラリー + 開発環境
  4. Intel Parallel Studio XE 2011:たぶん、Intel Cluster Studio 2011 + 並列処理解析ツール

Intel C++ Composer XE 2011だけ、C++用のアピールだけど、その他はCとC++がデフォルトで入っており、Fortranがプラスされる場合はパッケージ名に「Intel Fortran 〜」となっている模様。

評価版をIntelのWebサイトか日本における販売担当のXLSoftのインテル製品ダウンロードからダウンロードする。ダウンロードの際には登録して、ライセンスキーを発行してもらう。

今回は、c_studio_xe_2011_sp1_update1.tgzをダウンロードした。

% tar xvfz c_studio_xe_2011_sp1_update1.tgz
% cd c_studio_xe_2011_sp1_update1
% sudo ./install.sh

表示メッセージをとっておくのを忘れたけれども、基本はデフォルトのまま進める。unsupported OSという表示がでるが気にせずインストール続行。

Step 3 アクティベーションIntel Compilerの評価版入手時にライセンスキーを発行してもらっているので1を選ぶ。

Step no: 3 of 6 | Activation
--------------------------------------------------------------------------------
If you have purchased this product and have the serial number and a connection
to the internet you can choose to activate the product at this time. Activation
is a secure and anonymous one-time process that verifies your software licensing
rights to use the product. Alternatively, you can choose to evaluate the
product or defer activation by choosing the evaluate option. Evaluation software
will time out in about one month. Also you can use license file, license
manager, or the system you are installing on does not have internet access
activation options.
--------------------------------------------------------------------------------
1. I want to activate my product using a serial number [default]
2. I want to evaluate my product or activate later 
3. I want to activate either remotely, or by using a license file, or by using a
   license manager

h. Help
b. Back to the previous menu
q. Quit
--------------------------------------------------------------------------------
Please type a selection or press "Enter" to accept default choice [1]: 

Step 4はインストール場所など。/usr/binなどにいれると面倒なので、そのままにした。

Step no: 4 of 6 | Options
--------------------------------------------------------------------------------
You are now ready to begin installation. You can use all default installation
settings by simply choosing the "Start installation Now" option or you can
customize these settings by selecting any of the change options given below
first. You can view a summary of the settings by selecting 
"Show pre-install summary".
--------------------------------------------------------------------------------
1. Start installation Now

2. Change install directory      [ /opt/intel ]
3. Change components to install  [ All ]
4. Change advanced options
5. Show pre-install summary

h. Help
b. Back to the previous menu
q. Quit
--------------------------------------------------------------------------------
Please type a selection or press "Enter" to accept default choice [1]: 
WARNING: Destination directory already exists.
Would you like to overwrite this directory? ( Yes/No ) [ Yes ] : Yes

インストールが始まる。特にトラブルなくインストール終了。インストールが成功すると以下の説明がでる。

Thank you for installing and using the
Intel(R) C++ Studio XE 2011 SP1 Update 1 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.

Support services start when you install or activate your product, so please
create your Subscription Service support account now to take full advantage of
your product purchase. This support account provides access to free product
updates, interactive issue management, technical support, sample code, and
documentation.

To create your support account, visit
https://registrationcenter.intel.com/RegCenter/registerexpress.aspx?clientsn=「ライセンスキー」

To get started using Intel(R) VTune(TM) Amplifier XE 2011 Update 5:
    - Add the product bin64 (or bin32) directory (located in
/opt/intel/vtune_amplifier_xe_2011) to
      your PATH environment variable.
      To start the graphical user interface: amplxe-gui
      To use the command-line interface: amplxe-cl
    - To view a table of getting started documents:
/opt/intel/vtune_amplifier_xe_2011/
      documentation/en/documentation_amplifier.htm.
To get started using Intel(R) Inspector XE 2011 Update 7:
    - Add the product bin64 (or bin32) directory (located in
/opt/intel/inspector_xe_2011) to
      your PATH environment variable.
      To start the graphical user interface: inspxe-gui
      To use the command-line interface: inspxe-cl
    - To view a table of getting started documents:
/opt/intel/inspector_xe_2011/
      documentation/en/documentation_inspector_xe.htm.
To get started using Intel(R) C++ Composer XE 2011 Update 7 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:
           $ source /opt/intel/bin/compilervars.sh intel64
      To invoke the installed compilers:
           For C++: icpc
           For C: icc
      To get help, append the -help option or precede with the man command.
    - To view a table of getting started documents:
/opt/intel/composer_xe_2011_sp1/Documentation/
      en_US/documentation_c.htm.
      
To view movies and additional training, visit
http://www.intel.com/software/products.

シェルのソースファイルに以下を加える。私の場合はzshを使っているので.zshrc.mineに加えた。

source /opt/intel/bin/iccvars.sh ia32 (32ビットOSの場合)
source /opt/intel/bin/iccvars.sh intel64 (64ビットOSの場合)

反映させてバージョンを確かめる。

% source ~/.zshrc
% icc --version
icc (ICC) 12.1.0 20111011
(C) 1985-2011 Intel Corporation.  無断での引用、転載を禁じます。

コンパイル時の注意

Ubuntu 11.10でiccコンパイルしようとすると以下のエラーがでる。

/usr/include/features.h(323): 致命的なエラー: ソース ファイル "bits/predefs.h" を開けません。
  #include <bits/predefs.h>

原因はDebian GNU/Linuxのマルチアーキテクチャ対応方針のために、アーキテクチャに依存するヘッダファイルを/usr/include/アーキテクチャ以下においているため。

Ubunt 11.10では predefs.h は以下にある。

% locate predefs.h
/usr/include/i386-linux-gnu/bits/predefs.h

対応方法は2つ。副作用ありならばシンボリックリンク。面倒でも副作用なしならば、コンパイル時に-Iオプションで指定。環境変数で対応する方法もある(CPATH、C_INCLUDE_PATHなど)らしいのだけどうまくいかなかった。

シンボリックリンクの場合。

% sudo ln -s /usr/include/i386-linux-gnu/* /usr/include/

コンパイル時のオプション

% icc -O2 -I "/usr/include/i386-linux-gnu" hogehoge.c