Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Compiling the Linux Kernel

gordan
Beginner
501 Views
Is there a patch and/or instructions available for compiling the Linux kernel with ICC? I have seen information/patches around on doing this with ICC7 for kernels around v2.4.21 and ICC8 for early 2.6.x kernels, and even a few patches for 2.6.x series kernels for the IA64 architecture, but nothing for ICC9 or ICC10 for late 2.4.x kernels on IA32.

I managed to get 2.4.34.5 (latest) to compile with ICC10 (ICC9 gets confused very early on thinking there's a function parameter number mismatch somewhere in panic.c for some reason), but for some reason I can only get the Pentium3 version to compile if I specify -march=pentium3. If I leave it as i686, I get an undefined reference _intel_fast_memcpy or some such in a number of modules, and I can't find a reference to that function anywhere in the kernel source.

And even for P3, I can get the kernel to boot as far as finding the first CPU, and then it locks up.

Are there any resources available on this subject? It strikes me as a fairly major/obvious application of ICC.
0 Kudos
9 Replies
TimP
Honored Contributor III
501 Views
_intel_fast_memcpy() is likely introduced by macro replacement for memcpy() in the in icc's own include directory. Instantiations of it would be in icc's own libraries. It may be the major performance optimization obtained by using icc rather than a recent version of gcc. A related trend has been to make IA hardware less dependent on special tweaks to memcpy(). If you want to do it the gcc way, the header is at your disposal.
It's possible the impetus has gone from efforts to build kernel with icc, since recent gcc versions are quite effective on recent IA platforms.
0 Kudos
gordan
Beginner
501 Views
It's possible the impetus has gone from efforts to build kernel with icc, since recent gcc versions are quite effective on recent IA platforms.

I don't know about the impetus, but I know that most code I tried compiling with ICC runs between 25% (MySQL) and 450% faster (home-brewed number crunching library) than with GCC. This is comparing ICC v9 and GCC 3.2.2 on RH9 (similar to RHEL3), on a Pentium III. I accept that this is arguably not up to date WRT CPU and distribution, but for starters GCC still hasn't got production quality vectorization as of the last time I checked the docs.

I found a mention in the release notes that adding -lirc to ld line resolves dependency, but that doesn't seem to work for the kernel. It is also suggested to replace ld with icc for linking, but ICC doesn't seem to understand the -m linker flag. I'm not sure if omitting -m elf_i386 is OK or not, but either way, after that the -e/-entry flag isn't understood by icc. Is there an equivalent option on ICC to set the symbol for the execution start?

And, why does compiling with -march=pentium3 not throw up the missing _intel_fast_memcpy symbol? Chanking -march=i686 to -march=pentium3 seems to make that particular problem go away. With -march=pentium3 it compiles and links, and boots right up to detecting the 1st CPU, but then locks up solid.

Can you suggest a work-around patch regarding what you mentioned about the header files?
0 Kudos
levicki
Valued Contributor I
501 Views

For best performance I would suggest changing to another Linux distribution, namely Gentoo.

After that, reading this HOWTO ICC and Portage would be a next logical step.

What I really wonder however, is why Intel doesn't work closely with Linux kernel folks to make kernel compileable with Intel C++ Compiler out of the box. Surely that would be beneficial to Intel?

0 Kudos
gordan
Beginner
501 Views
They used to. There used to be a page on the Intel site about this. The whole thing was dropped some time around or after 2.4.20 kernel.

I think there are some later patches for 2.6.x, but nothing particularly current.

No idea why this was dropped...
0 Kudos
levicki
Valued Contributor I
501 Views

You can also try this patch from pyrillion.org. It is meant for 2.6.5 and 2.6.6 kernels but you may be able to adapt it provided you know kernel structure good enough.

0 Kudos
John_O_Intel
Employee
501 Views
Hi,
In addition, we have a white paper that talks about building the Linux kernel at http://download.intel.com/support/performancetools/c/linux/sb/linuxkernelbuildwhitepaper.pdf

Best regards,
_|ohnO

0 Kudos
gordan
Beginner
501 Views
I saw that whitepaper before. It's IA64-centric, only mentions rather old kernel versions, and doesn't provide links to any of the mentioned "temporary" patches and wrappers required. In other words, it's only slightly better than useless. :-(
0 Kudos
Feilong_H_Intel
Employee
501 Views

Hi,

Please try to add this compiler option -fno-builtin. If this doesn't work, try to link libirc_s.a to the kernel image by modifying the makefile in the root directory of the Linux kernel. For example,

@@ -600,7 +600,7 @@
quiet_cmd_vmlinux__ ?= LD $@
cmd_vmlinux__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) -o $@
-T $(vmlinux-lds) $(vmlinux-init)
- --start-group $(vmlinux-main) --end-group
+ --start-group $(vmlinux-main) /opt/intel/cc/10.0.025/lib/libirc_s.a --end-group
$(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) FORCE ,$^)

Regards,

Feilong

0 Kudos
gordan
Beginner
501 Views
I don't suppose you might have a similar patch for v2.4 kernels for ICC v9.1?
0 Kudos
Reply