컴퓨터/linux2011. 4. 8. 18:37
리눅스를 사용하는 많은 분들이 즐겨 쓰는 컴파일러는 단연 gcc 이죠. 리눅스의 웬만한 프로그램들의 기본을 이루고 있을 뿐만 아니라 무엇보다도 무료라는 점이 매력적입니다. (vidual stdio의 가격을 생각해 본다면 참;; )

그런데 의외로 사람들이 잘 모르는 부분중에 하나가 gcc가 시중에 있는 웬만한 컴파일러에 비해 컴파일한 프로그램의 속도가 느리다는 것입니다. 계산 과학쪽을 하는 사람들뿐만 아니라 어떤 상용프로그램들도 느리다는 건데요. (그렇다고 인텔 cpu에서만 작동하는 프로그램도 웃기겠네요.)
그런 문제를 해결해 주는 상당히 고속의 컴파일러가 있습니다. 
바로 intel compiler에요. ^^ 리눅스에서 명령어로 쓸려면 icc 라고 쓰고 gcc랑 동일하게 사용하시면 됨니다. 

우선 설치를 해보도록 하죠. 먼저 인텔 홈페이지에 들어가서 무료인 noncommercial version을 받습니다. noncommercial version은 아쉽게도 맥이나 윈도우에서는 사용할수가 없습니다. 
가서 약관에 동의하고 자신의 머신의 기종에 따라(32bit인지 64bit인지) 컴파일러를 다운받습니다.  기종을 확인하는 법은
$cat /proc/cpuinfo
를 봐서 CPU기종을 확인 하는 방법이 있고
$uname -a
란 명령어로 운영체제의 종류를 파악합니다. i686 이면 32bit, x86_64이면 64bit 입니다. 중간에 메일주소를 써줘야하는데 잘 써줘야 합니다. 그래야 씨리얼번호가 제대로 오거든요. 
다운을 다 받았으면 먼저 JAVA Runtime Environment 란걸 먼저 설치해줍니다. 이게 없으면 인스톨이 안되요. 원래 어느정도 충족조건이 있지만 웬만한건 다 충족하고 이게 충족이 잘 안됩니다. 

$sudo apt-get install gcj

JAVA Runtime Environment 가 이렇게 설치가 되면

$tar xvfz l_ccompxe_(.....).tgz
$cd ./l_ccompxe_(.......)
$sudo ./install.sh
을 해주면 인스톨을 하기 시작합니다. 

Step no: 1 of 6 | Welcome
--------------------------------------------------------------------------------
Welcome to the Intel(R) Composer XE 2011 Update 2 for Linux* installation
program.

Intel(R) C++ Composer XE 2011 Update 2 for Linux* includes not only the
high-performance Intel(R) C++ Compiler XE, but also Intel(R) Debugger, Intel(R) 
Threading Building Blocks (Intel(R) TBB), Intel(R) Integrated Performance
Primitives (Intel(R) IPP), and Intel(R) Math Kernel Library (Intel(R) MKL) to
create a strong foundation for building robust, high performance parallel code
at significant price savings.
--------------------------------------------------------------------------------
You will complete the steps below during this installation:
Step 1 : Welcome
Step 2 : License
Step 3 : Activation
Step 4 : Options
Step 5 : Installation
Step 6 : Complete
--------------------------------------------------------------------------------
Press "Enter" key to continue or "q" to quit: 

이런글이 나옵니다. 간단한 설명인데 그냥 엔터 치시면 됨니다. 

Step no: 1 of 6 | Options > Missing Optional Pre-requisite(s)
--------------------------------------------------------------------------------
There is one or more optional unresolved issues. It is highly recommended to fix
it all before you continue the installation. You can fix it without exiting from
the installation and re-check. Or you can quit from the installation, fix it and
run the installation again.
--------------------------------------------------------------------------------
Missing optional pre-requisite
-- unsupported OS
--------------------------------------------------------------------------------
1. Skip missing optional pre-requisites [default]
2. Show the detailed info about issue(s)
3. Re-check the pre-requisites

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

지원하지 않는 운영체제다고 하는데 그냥 무시하시면 됨니다. 
그다음에 약관이 좌르륵 나옵니다. 알았다고 accept이라고 타이핑하고 엔터

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]: 
 
라이센스를 인정받으라고 하네요. 우리는 씨리얼 넘버가 있으니까 엔터를 쳐서 1번으로 갑니다.

다음에 바로 씨리얼 넘버 넣으라고 하는데 침착하게 이메일에 있는 씨리얼넘버를 넣어줍니다.

--------------------------------------------------------------------------------
Activation completed successfully.
--------------------------------------------------------------------------------
Press "Enter" key to continue: 

된다고 하네요. ㅎ 

 --------------------------------------------------------------------------------
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/composerxe-2011.2.137 ]
3. Change components to install  [ All ]
4. 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]: 

이제 인스톨을 하려고 합니다. 원래 이부분은 dependency라고 하죠. 깔수있는 조건들을 만족하는지 확인하는 곳입니다. gcj를 깔았으니 조건을 잘 만족하는거죠. 혹시 안되더라도 깔라고 시키는것만 잘 깔면 됨니다. 엔터.

Step no: 5 of 6 | Installation
--------------------------------------------------------------------------------
Each component will be installed individually. If you cancel the installation,
components that have been completely installed will remain on your system. This
installation may take several minutes, depending on your system and the options
you selected.
--------------------------------------------------------------------------------
Installing Intel(R) C++ Compiler XE 12.0 Update 2 for Linux*
              (for applications running on IA-32) component... done
--------------------------------------------------------------------------------
Installing Intel(R) Debugger 12.0 Update 2 for Linux*
              (for applications running on IA-32) component... done
--------------------------------------------------------------------------------
Installing Intel(R) Math Kernel Library 10.3 Update 2 for Linux*
              (for applications running on IA-32) component... done
--------------------------------------------------------------------------------
Installing Intel(R) Integrated Performance Primitives 7.0 Update 2 for Linux*
              (for applications running on IA-32) component... done
--------------------------------------------------------------------------------
Installing Intel(R) Threading Building Blocks 3.0 Update 5 core files and
examples for Linux* component... done
--------------------------------------------------------------------------------
Press "Enter" key to continue

살살 깔리네요. 엔터.

 Step no: 6 of 6 | Complete
--------------------------------------------------------------------------------
Thank you for installing and for using the
Intel(R) Composer XE 2011 Update 2 for Linux*.

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

To create your support account, please visit the Subscription Services web site
https://registrationcenter.intel.com/RegCenter/registerexpress.aspx?clientsn=N5D
5-F4K7MMS7

To get started using Intel(R) Composer XE 2011 Update 2 located in
/opt/intel/composerxe-2011.2.137: 
- 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 install-dir/bin/compilervars.csh intel64
     For bash:
        $ source install-dir/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.
- To view a table of getting started documents: 
  install-dir/Documentation/en_US/documentation_c.htm.

Movies and additional training are available on our website at
www.intel.com/software/products.
--------------------------------------------------------------------------------
q. Quit [default]
--------------------------------------------------------------------------------
Please type a selection or press "Enter" to accept default choice [q]: 

잘깔렸다고 하네요. 그 다음에 shell에 설정을 해주어야 쓸수가 있는데요. 우리는 모두 bash 쉘을 쓰니까 $ source install-dir/bin/compilervars.sh intel64 쓰면 되겠네요. installed-dir 은 일반적으로 /opt/intel/composerxe-(......)에 있습니다.

$echo "source /opt/intel/composerxe-(......)/bin/compilervars.sh intel64" >> ~/.bashrc
위에 써있듯이 64bit면 intel64 를 쓰고 32bit면 ia32라고 써야합니다.
$bash
bash 한번 실행해주고 나서 
$icc 
라고 치면 잘 된다는걸 알수 있습니다. ^^ 이제 잘 쓰기만 하면되요.
(C++은 icpc란 명령어를 사용합니다. fortran은 ifort)

제 경험상 계산 시간이 1/3정도 더 줄어들더라구요. 1/3이 작아 보이지만 삼일 계산할걸 이틀만에 끝낸다는거니.. 정말 기가 막힙니다. 알고리즘에 따라서 반 정도밖에 안걸리거나 빨리지지 않는 경우도 있는데 그건 어쩔수 없죠. ㅋ 그래도 피부로 느낄수 있는 속도향상을 맛볼수가 있습니다. 
Posted by blindfish