LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 3323|回复: 18

安装使用intel C++ compiler7.1 小记

[复制链接]
发表于 2003-5-29 12:21:20 | 显示全部楼层 |阅读模式
有关intel cpp compiler(简称icc,但是icc作为其一个命令,只是这个软件包的ia32 cpu的cpp编译器)的介绍可以参见:( http://www.linuxsir.cn/forum.php?mod=viewthread&tid=42324 )。为什么要使用这个编译器呢?
1. linux下面要编译只有gcc,change一下未尝不可。
2. icc针对intel cpu进行优化,照intel网站上面所说是maxium the speed. 这里有一篇评测,从中可以看出不仅p4得到提高,就算是p3,icc的代码在速度上也很有优势。http://www.coyotegulch.com/revie ... tel_gcc_bench2.html
3. 编译的速度提高,在上面测试中可以找到,我也做了一个小比较,在后面。
4. 文档很少,摸着石头过河,很有意思。

首先说安装

在intel注册然后得到一个license文件和下载地址
http://www.intel.com/software/products/compilers/clin/noncom.htm
或者
在这里下载安装包
http://gentoo.oregonstate.edu/distfiles/l_cc_p_7.1.006.tar

在这里下载license文件
ftp://linuxsir:linuxsir@218.6.242.103/upload/l_cpp_26602777.lic

然后将lic文件拷贝到/opt/intel/licenses,执行install安装icc
安装完成之后将icc所在的目录添加到path里面,把/opt/intel/...../lib  添加到ld.so.conf里面执行ldconfig。将/opt/intel/comp.../man/icc.1 拷贝到/usr/share/man/man1/

我用的是bash205b,但是好象不支持icc脚本里面的exec -a,执行icc会出现错误:
/usr/lib/crt1.o: In function `_start':
/usr/lib/crt1.o(.text+0x18): undefined reference to `main'
所以编辑icc脚本将里面exec -a 的 -a和后面的路经去掉。 exec  /opt/intel/compiler70/ia32/bin/iccbin "$@"; 象这样。

接着执行icc,如果得到
iccbin: Command line error: no files specified; for help type "iccbin -help"
就是安装好了。

然后说软件包的编译。
首先设置环境变量,用icc代替gcc。并且使用icc自己的linker。
export LD=xild
export AR=xiar
export CC=icc
export CXX=icc

优化参数上面不太一样,我的设置是
export CFLAGS="-march=pentiumiii -O2"
export CXXFLAGS="-march=pentiumiii -O2 "

注意icc的march参数和gcc的设置不一样,比如gcc里面是pentium3. 具体可以看man icc

接着,如果不出意外就可以编译了。
我尝试编译了distcc,bash205b,gnet,都没有问题。

编译时间上面我做了一个比较,用icc编译bash205b
real    1m7.926s
user    0m41.750s
sys     0m10.510s
同样情况下面gcc
real    1m49.384s
user    1m21.770s
sys     0m9.380s
 楼主| 发表于 2003-5-29 12:29:12 | 显示全部楼层
刚刚开始实验,没加太多优化参数,具体怎么设置优化以安装之后opt/intel里面有一个training的目录,包括了怎么设置优化参数的html。

在gentoo的论坛上面有人说了一下具体那些包会有问题:
Known to compile "out of the box"
zlib-1.1.4-r1
libdvdcss-1.2.6
libfame-0.9.0
alsa-xmms-1.27-r19
eog-2.2.1
**mpqc-2.1.2
xmms-1.27-r19
bzip2-1.0.2-r2
gzip-1.3.3-r1
tar-1.13.25-r3
jpeg-6b-r3
libpng-1.2.5-r4
libogg-1.0
libvorbis-1.0-r2
libmikmod-3.1.10
libsdl-1.2.5-r1
mpg123-0.59r-r2
alsa-oss-0.9.1
openquicktime-1.0-r1

Do not compile
mpeg-lib-1.3.1-r1
xine-lib-1_beta10
gimp-1.2.3
xine-ui-0.9.20
tiff-3.5.7-r1
giflib-4.1.0-r3
imlib-1.9.14
lame-3.93.1-r1
libmpeg2-0.3.1
jpeg-mmx-1.1.2-r1
xvid-0.9.1

Configuration Problems
mozilla-1.2.1-r5
unzip-5.5.0-r1
gtk-perl-0.7008-r9
zip-2.3-r1
PDL-2.3.2-r2
libmpeg3-1.5-r1
quicktime4linux-1.5.5-r1

这些包看来是要用gcc来做一下
 楼主| 发表于 2003-5-29 12:41:52 | 显示全部楼层
现在正在尝试编译内核,用icc。如果成功,hoho,这个lfs八成是可以用icc来做了。这样如果使用p4,可是有福了哦。

找到了一个针对2.5.45的补丁(还不知到是不是完整)。ft
http://lwn.net/Articles/14293/
安装这个补丁没有错误

修改内核的Makefile,将里面设置gcc,g++,ld,ar 的地方都换成前面提到的参数。
然后make menuconfig。。。。出错。:(
  icc -Wp,-MD,scripts/.fixdep.d    -o scripts/fixdep scripts/fixdep.c
ld: unrecognized option '--compile_dependencies'
ld: use the --help option for usage information
make[1]: *** [scripts/fixdep] 4└N⎽ 1
make: *** [scripts] 4└N⎽ 2
为啥还用ld呢,还得再琢磨一下。
发表于 2003-5-29 17:18:17 | 显示全部楼层
如果把内核用ICC重新编译下,不知与GCC有何差异?
发表于 2003-5-29 21:11:08 | 显示全部楼层
是free的吗?应该不会开源吧。
发表于 2003-5-29 23:57:16 | 显示全部楼层
不开源,但是free for linux
最初由 noword 发表
是free的吗?应该不会开源吧。
 楼主| 发表于 2003-5-30 01:16:29 | 显示全部楼层
用起来没有gcc那么方便但是为了速度上面的提高还是值得的
有关用icc编译内和的报道见过一个说是有了50%的速度提高。

icc针对HT(hyper threading)的cpu作了很大的优化,再多线乘的情况下比gcc编译出来的东西块很多。具体可以在google上面找hyper threading ,intel compiler 等等可以有不少结果。唯一不好的地方就是都是测评,没有告诉你怎么编译的。
 楼主| 发表于 2003-5-30 01:45:03 | 显示全部楼层
转一个有关HT的小文章。
Linux* Issues with Hyper-Threaded Technology
For Linux to make use of HT Technology an SMP kernel must be installed. This is confirmed by the output of uname -a, which shows the kernel version ending in SMP. The output of cat /proc/cpuinfo (see below) will show the number of CPU's and their properties. HT Technology is shown by the presence of the ht flag. If the computer BIOS supports SMP (or an analogous option is activated in BIOS), the machine can be used as an SMP system with Linux. When the SMP kernel is installed, it will seem as if double the physical processors are available. At present the errata kernels 2.4.9-21 and 2.4.9-31 have HT Technology support, but you have to pass "acpismp=force" on the kernel command line to enable it.


  1. > $cat /proc/cpuinfo
  2. > processor       : 0
  3. > vendor_id       : GenuineIntel
  4. > cpu family      : 15
  5. > model           : 1
  6. > model name      : Intel(R) Pentium(R) 4 CPU 1.70GHz
  7. > stepping        : 2
  8. > cpu MHz         : 1694.907
  9. > cache size      : 256 KB
  10. > fdiv_bug        : no
  11. > hlt_bug         : no
  12. > f00f_bug        : no
  13. > coma_bug        : no
  14. > fpu             : yes
  15. > fpu_exception   : yes
  16. > cpuid level     : 2
  17. > wp              : yes
  18. > flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
  19. > mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm
  20. > bogomips        : 3381.65
  21. >
复制代码


The Linux 2.4 kernel will not be developed to take an active advantage of HT Technology and patches may be required to fix some possible problems. Rusty Russell (a Linux developer) mentions: "The hyperthreading issue... is likely to throw a new set of complications into the mix. A processor which does hyperthreading looks like two independent CPUs, but it [processes] should not be scheduled [by the scheduler] as such - it is better to divide process across real (hardware) processors first."

Work is underway in the Linux community to add HT Technology patches to the 2.4 release of the Linux kernel. HT Technology changes to Linux are being exploited by Carrier Grade Linux Change Project under the ODSL (see below). HT Technology offers performance enhancement potentials that are a prime requirement of the carrier grade environment. Active utilization of HT Technology will likely appear in the standard 2.5 Linux kernel, although it has not yet been placed into the development queue due to prerequisite work being done.

Linux HT Technology Capable Compilers
The Intel Linux C++ Compiler 6.0 has increased levels of Linux and industry standards support that provide improved compatibility with GNU C, broader support of Linux distributions, support for the C++ ABI object model and GNU inline ASM for IA32. - The Intel C++ Compiler supports OpenMP API version 1.0 and performs code transformation for shared memory parallel programming. The Intel compiler supports multi-threaded application development and debugging, with support for OpenMP 1.0 for C and new support for OpenMP 1.0 for C++. This makes it fully capable of designing HT Technology enabled applications on HT Technology enabled hardware.
 楼主| 发表于 2003-5-30 02:01:20 | 显示全部楼层
http://support.intel.com/support ... s/c/linux/index.htm

这里还有一些非常有用的文档。
发表于 2003-5-30 09:00:44 | 显示全部楼层
好,我们网站的服务器就是用了两台,又1.8至强的CPU,在7.2下只显示2个CPU,但是在7.3下就可以显示4个CPU
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表