Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Compiling the kernel (2.6) with icc.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
nagzi
n00b
n00b


Joined: 29 Dec 2003
Posts: 37
Location: Canada

PostPosted: Tue Mar 23, 2004 7:58 pm    Post subject: Compiling the kernel (2.6) with icc. Reply with quote

I'm going to assume that the reader already has icc installed (I'll help a little bit with getting it working). Look to this thread for some tips on getting it installed. You'll have to make sure that /opt/intel/compiler80/bin is in your path or make symlinks to icc and icpc in a dir that is in your path. Also you're going to have to make symlinks to some libs in a dir thats listed in your /etc/ld.so.conf, other wise your /opt/intel/compiler80/lib entry will disappear everytime you emerge something (if someone knows how to fix this please let me know! :wink: ).

For the path:

Code:
cd /usr/bin
ln -s /opt/intel/compiler80/bin/icc
ln -s /opt/intel/compiler80/bin/icpc

Now for the libs:

Code:
cd /usr/lib
ln -s /opt/intel/compiler80/lib/libcprts.so libcprts.so.5
ln -s /opt/intel/compiler80/lib/libcxa.so libcxa.so.5
ln -s /opt/intel/compiler80/lib/libunwind.so libunwind.so.5
ln -s /opt/intel/compiler80/lib/libcxaguard.so libcxaguard.so.5
ldconfig

With your favorite editor open /usr/src/linux-'uname -r'/Makefile. Now goto approximately line 163. This may or may not change from kernel version to kernel version or with different kernel patches applied. Myself I'm running 2.6.3 with mm1 patch plus the supermount patch. The lines that you want should look like:

Code:
HOSTCC          = gcc
HOSTCXX         = g++
HOSTCFLAGS      = -Wall -Wstrict-prototypes -O2
HOSTCXXFLAGS    = -O2

Now edit the first two lines and change gcc and g++ to icc and icpc. You can also change the cflags too, but that can be taking some risk. I did however change it from O2 to O3 with no probs. After editing, my lines now look like:

Code:
HOSTCC          = icc
HOSTCXX         = icpc
HOSTCFLAGS      = -Wall -Wstrict-prototypes -O3
HOSTCXXFLAGS    = -O3

Hopefully this will work for most people, if not I'll help as best as I can. Hopefully we can start getting more interest and talking about icc, since the main thread has sort of died down. :cry:

Well that should be it. Thats what I had to do to get icc compiling the kernel. There are a few other tips for icc, but those are for emerges.

PS: Incase the subject didn't click in, this is for the 2.6 kernel. I have absolutely no idea if this works for 2.4 or not.

PSS: Don't be to harsh, this is my first posting of a tip. :roll:
Back to top
View user's profile Send private message
PillowBiter
n00b
n00b


Joined: 16 Mar 2004
Posts: 26
Location: Palm Bay, FL

PostPosted: Tue Mar 23, 2004 9:17 pm    Post subject: Reply with quote

Are there any advantages to using intels compiler vs gcc?
Back to top
View user's profile Send private message
Markus_T
n00b
n00b


Joined: 09 Feb 2004
Posts: 49
Location: Berlin

PostPosted: Tue Mar 23, 2004 9:19 pm    Post subject: Reply with quote

Cool,
I didn't know, that it is that easy.
Has anybody experimented with the
profile-guided optimization options?
Anyway, I will try it out in the next days.
Back to top
View user's profile Send private message
nagzi
n00b
n00b


Joined: 29 Dec 2003
Posts: 37
Location: Canada

PostPosted: Wed Mar 24, 2004 4:19 pm    Post subject: Reply with quote

PillowBiter wrote:
Are there any advantages to using intels compiler vs gcc?


Well, Intel's compiler is suppose to produce to faster code. And I can't say that I notice any difference since I upgraded to 2.6 and started using icc for the kernel at the sametime.
Back to top
View user's profile Send private message
TenPin
Guru
Guru


Joined: 26 Aug 2002
Posts: 500
Location: Kansas City

PostPosted: Wed Mar 24, 2004 5:00 pm    Post subject: Reply with quote

The kernel is all discrete math and icc only really increases performance significantly for floating point math. Also, I wouldn't like to use -O3 as you are more likely to end up with a broken kernel. GCC is the tried and tested platform and -O2 is considered fine. I think if there were any real benefits from using -O3 on the kernel we would know about it.
Back to top
View user's profile Send private message
Markus_T
n00b
n00b


Joined: 09 Feb 2004
Posts: 49
Location: Berlin

PostPosted: Thu Mar 25, 2004 8:33 am    Post subject: Reply with quote

Quote:

GCC is the tried and tested platform and -O2 is considered fine. I think if there were any real benefits from using -O3 on the kernel we would know about it.

GCC -O3 != ICC -O3
BTW, I'm using:
HOSTCFLAGS = -Wall -Wstrict-prototypes -O3 -ip
HOSTCXXFLAGS = -O3 -ip
right now, without any problems.
The -ipo flag does not work, but maybe one only has to make
trivial changes in the Makefile to get it right.
Back to top
View user's profile Send private message
Markus_T
n00b
n00b


Joined: 09 Feb 2004
Posts: 49
Location: Berlin

PostPosted: Thu Mar 25, 2004 10:52 pm    Post subject: Reply with quote

Well, if you use
make V=1 (verbose mode)
to build the kernel, you will see that
actually gcc is used to build the kernel. :oops:
Now thats more than embarrassing...
Icc is only invoked for a few config progs
at the beginning of the kernel build. 8O
Back to top
View user's profile Send private message
TenPin
Guru
Guru


Joined: 26 Aug 2002
Posts: 500
Location: Kansas City

PostPosted: Thu Mar 25, 2004 10:52 pm    Post subject: Reply with quote

Markus_T wrote:
Quote:

GCC is the tried and tested platform and -O2 is considered fine. I think if there were any real benefits from using -O3 on the kernel we would know about it.

GCC -O3 != ICC -O3
BTW, I'm using:
HOSTCFLAGS = -Wall -Wstrict-prototypes -O3 -ip
HOSTCXXFLAGS = -O3 -ip
right now, without any problems.
The -ipo flag does not work, but maybe one only has to make
trivial changes in the Makefile to get it right.


Maybe not but considering the highest level optimisations of both compilers is -O3 I would suspect they are very similar.

My main point is that theres not much point (probably none) rushing out to compile your kernel with icc in the hope that it will make your kernel faster.
Back to top
View user's profile Send private message
hbp4c
n00b
n00b


Joined: 17 Apr 2002
Posts: 46
Location: Charlottesville, Va

PostPosted: Wed Mar 31, 2004 8:41 pm    Post subject: Reply with quote

I admit I'd be happy to see if intel's compilers would build the kernel, if for no other reason than to prove if icc is a good and fully capable compiler.

Before icc8 was released, intel insisted that it would be nearly 100% gcc compatible, and while they made great strides to make it so, it still comes up short on a few bits of code.

I and the others here in my workplace (astronomy at UVa) have our own code which using gcc can take hours longer to run than using the intel compilers to optimize the same code.

My only reccomendation about tuning the kernel makefiles is make sure you have a backup kernel to resort to in case you new one goes kaboom :twisted:
Back to top
View user's profile Send private message
uglyb0b
Apprentice
Apprentice


Joined: 07 Sep 2003
Posts: 280

PostPosted: Wed Mar 31, 2004 9:07 pm    Post subject: Reply with quote

Icc makes faster code on Opterons.
_________________
Blog.

Linux geek and Mac whore.
Back to top
View user's profile Send private message
zrl
n00b
n00b


Joined: 20 Jan 2004
Posts: 47

PostPosted: Sun May 23, 2004 5:07 am    Post subject: Reply with quote

icc is used for only few files;
gcc is actually compiling 98% of all;

if you change part of the Makefile as follow:
AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)xild
CC = $(CROSS_COMPILE)icc
CPP = $(CC) -E
AR = $(CROSS_COMPILE)xiar


every thing will be done by icc, however, it spit at me with following:
Quote:
CHK include/linux/version.h
CC arch/i386/kernel/asm-offsets.s
iccbin: Command line warning: ignoring option '-W'; no argument required
iccbin: Command line warning: ignoring option '-p'; no argument required
iccbin: Command line warning: ignoring unknown option '-fomit-frame-pointer'
include/linux/kernel.h(10): catastrophic error: could not open source file "stdarg.h"
#include <stdarg.h>
^

compilation aborted for arch/i386/kernel/asm-offsets.c (code 4)
make[1]: *** [arch/i386/kernel/asm-offsets.s] Error 4
make: *** [arch/i386/kernel/asm-offsets.s] Error 2
Back to top
View user's profile Send private message
moocha
Watchman
Watchman


Joined: 21 Oct 2003
Posts: 5722

PostPosted: Sun May 23, 2004 5:21 am    Post subject: Reply with quote

If you're interested in compiling your kernel with icc, take a look at this thread - but be forewarned that an icc-compiled kernel is almost sure not to work.
_________________
Military Commissions Act of 2006: http://tinyurl.com/jrcto

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety."
-- attributed to Benjamin Franklin
Back to top
View user's profile Send private message
lomi
n00b
n00b


Joined: 09 Jan 2003
Posts: 73

PostPosted: Sun May 23, 2004 9:35 am    Post subject: Reply with quote

would this make any difference to an amd user?
Back to top
View user's profile Send private message
moocha
Watchman
Watchman


Joined: 21 Oct 2003
Posts: 5722

PostPosted: Sun May 23, 2004 10:20 am    Post subject: Reply with quote

In theory yes. The Intel compiler produces code that is faster on AMD architectures too. The gain isn't as big as with Intel architectures though (hardly surprising :D).
_________________
Military Commissions Act of 2006: http://tinyurl.com/jrcto

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety."
-- attributed to Benjamin Franklin
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum