LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-10-2005, 10:49 AM   #1
kriton12
Member
 
Registered: Oct 2002
Posts: 81

Rep: Reputation: 16
What makes it i686 optimized ?


My question is what exactly makes a distro i686 optimized. There are a couple of distro's that say they are built off of a slackware base but optimized for i686 architecture. I've searched around these forums a bit and all I've come up with are:

1. Software is compiled with the --march=i686 and -mcpu=whatever flags set for optimization.

2. The kernel is compiled with options for i686 architecture

3. Slackware and most packages for it are already optimized for i686, but have compatibility built in for i386 or i486 and are named as such.

So does that mean if I install slack 10.1 and compile my own kernel selecting my cpu specifically, I'm running an i686 optimized distro?

I was tempted to look into a couple of these other distro's but I really don't understand the difference when they say they are optimized for i686. When it comes down to it, it sounds like the only real differences between distro's are configuration changes, package management tools, and the default packages it uses (extra software and/or newer versions).

I'm not naming any specific distro's because I don't intend to start any flaming or troll feeding. I'm not asking why slack is/isn't better, i'm just curious when people say so and so distro is basically slack but optimized for i686, what exactly does that mean, and is slack pretty much already optimized for i686 just with support for older hardware built in as well?

If anyone can shed any light on this for me, I'd appreciate it.
 
Old 03-10-2005, 11:01 AM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
You answer your own question with the 1 and the 2

Basically a Linux distribution is based on two things :
- kernel
- softwares applications and libraries
The Kernel part is named Linux and the software part is named GNU, that's why
some purists call this system GNU/Linux

To optimize a system for i686 architecture, you configure the kernel processor feature to
i686 and you compile all the softwares applications, libraries with the gcc optimizer option
(also called CFLAGS for c language and CXXFLAGS for c++)
http://linuxreviews.org/howtos/compiling/
 
Old 03-10-2005, 02:48 PM   #3
__J
Senior Member
 
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973

Rep: Reputation: 46
Re: What makes it i686 optimized ?

Quote:
Originally posted by kriton12
My question is what exactly makes a distro i686 optimized. There are a couple of distro's that say they are built off of a slackware base but optimized for i686 architecture. I've searched around these forums a bit and all I've come up with are:

1. Software is compiled with the --march=i686 and -mcpu=whatever flags set for optimization.

2. The kernel is compiled with options for i686 architecture

3. Slackware and most packages for it are already optimized for i686, but have compatibility built in for i386 or i486 and are named as such.

So does that mean if I install slack 10.1 and compile my own kernel selecting my cpu specifically, I'm running an i686 optimized distro?

I was tempted to look into a couple of these other distro's but I really don't understand the difference when they say they are optimized for i686. When it comes down to it, it sounds like the only real differences between distro's are configuration changes, package management tools, and the default packages it uses (extra software and/or newer versions).

I'm not naming any specific distro's because I don't intend to start any flaming or troll feeding. I'm not asking why slack is/isn't better, i'm just curious when people say so and so distro is basically slack but optimized for i686, what exactly does that mean, and is slack pretty much already optimized for i686 just with support for older hardware built in as well?

If anyone can shed any light on this for me, I'd appreciate it.
slack is built with -mcpu=i686. the -march option tells gcc to optimize for a specific arch ( and will not run on anything lower). For example, if you compiled an app with -march=athlon-xp and tried to run it on a Duron processor, it wouldn't run. but if you compiled and app with -mcpu=athlon-xp, gcc would optimize it for the athlon-xp, but it would run on an i486.
 
Old 03-12-2005, 10:12 AM   #4
jawkins
LQ Newbie
 
Registered: Jan 2005
Location: London
Distribution: Slackware
Posts: 20

Rep: Reputation: 0
Re: Re: What makes it i686 optimized ?

Quote:
Originally posted by __J
the -march option tells gcc to optimize for a specific arch ( and will not run on anything lower).
This in an oversimplification. The -march option defines the specific ISA (Instruction Set Architecture) which is to be targeted. This is the set of machine instructions that a particular CPU is capable of executing. As modern x86 ISAs are supersets of older ones, to say that compiling for a later ISA means it won't run on an older one is a fallacy - it may or may not run on an older architecture, depending on which instructions are generated. It's not guaranteed to run on anything else, but it might. I just compiled "Hello world" with -march=athlon-xp and it runs fine on a PII.

-mcpu (deprecated and now called -mtune which probably better reflects its purpose) defines optimisations of the outputted object which don't depend on the specific ISA, eg instruction ordering.

Quote:
For example, if you compiled an app with -march=athlon-xp and tried to run it on a Duron processor, it wouldn't run.
This is a particularly bad example as later Durons are based on the Athlon XP core and have the exact same ISA AFAIK. In fact, if you wanted to optomise for a Duron, you'd have to use one of the -march=athlon* options, because gcc doesn't define any Duron specific ones.

Jim
 
Old 03-12-2005, 10:27 AM   #5
chbin
Member
 
Registered: Mar 2005
Distribution: slackware-current
Posts: 379

Rep: Reputation: 31
simple put. if both march and mcpu are specified at compile time then.

march = the lowest arch are it will run on
mcpu = what the code is optimized for


if just march is specified
march = the code is optimized for this arch, but will run on higher arch just not effiently.
mcpu = march by default
 
Old 03-12-2005, 10:49 AM   #6
cathectic
Member
 
Registered: Sep 2004
Location: UK, Europe
Distribution: Slackware64
Posts: 761

Rep: Reputation: 35
march: The architecture your program is compiled for. If you build for i486, it is backwards compatible by the nature of the later chips, not by anything fancy on the compiler side.

Edit: The following is wrong and has been corrected in my later post

mcpu: The processor of the machine you are compiling on. It does *not* affect the code you produce at the end, just the instruction scheduling for the machine you are building on (i.e. tries to speed up the compiling, but you still get the same output)

(In GCC 3.4, this is now march and mtune)

Very few programs will benefit from a specific -march being set above i486, so for compatibility, leave it as i486, and just change the -mcpu/-mtune to match your processor (probably i686 as has already been said)

Last edited by cathectic; 03-13-2005 at 07:37 PM.
 
Old 03-12-2005, 10:53 AM   #7
chbin
Member
 
Registered: Mar 2005
Distribution: slackware-current
Posts: 379

Rep: Reputation: 31
now that is clear. a little bit about i486, i586, i686

they refers to the instruction set that the processor has.

ever hear of assembly code? that is when a program enters the cpu instruction line by line. for instance add would be one instrucion.

add ax, 7 ; --> means: ax = ax + 7; where ax is a register in the cpu used for storage.

now i486 has certain built in instructions, i586 has more, and an i686 has even more. they are all backwards compatible of course. an i686 would inculde everything in i484 and i586 and just add new ones. not that diffucult to understand, right?

so when you optimize for a specific arch the compiler optimizing the binary to use that specific instruction set. if you tell it to include a lower arch it will but will make the executable bigger of course becuase it has to write some code for the lower arch.

optimizing for a specific arch is not as great a thing as people think (gentoo lovers)! Sorry, I had to mention that. it only makes a difference if the program is using 100% cpu. A lot of times it is acually better to optimize for size using Os, becuase most of the time waiting is spent loading the program from disk to memory. And when the program loads it's not using 100% cpu so it doesn't matter if it's optimized or not. makes sense, right?
 
Old 03-12-2005, 11:02 AM   #8
chbin
Member
 
Registered: Mar 2005
Distribution: slackware-current
Posts: 379

Rep: Reputation: 31
the bottle neck of your system is the disk not the cpu, most of the time. you wont notice a difference between a 2.8Ghz or a 3.0Ghz cpu. But if you can increase disk perfomance that same 7%. Wow what a difference it makes!
 
Old 03-12-2005, 11:18 AM   #9
chbin
Member
 
Registered: Mar 2005
Distribution: slackware-current
Posts: 379

Rep: Reputation: 31
so when you optimize for a specific arch the compiler optimizing the binary to use that specific instruction set. if you tell it to include a lower arch it will but will make the executable bigger of course becuase it has to write some code for the lower arch.

scratch that... cathectic has enlightened me. thanks.
 
Old 03-13-2005, 06:36 AM   #10
jawkins
LQ Newbie
 
Registered: Jan 2005
Location: London
Distribution: Slackware
Posts: 20

Rep: Reputation: 0
Quote:
Originally posted by cathectic
mcpu: The processor of the machine you are compiling on. It does *not* affect the code you produce at the end, just the instruction scheduling for the machine you are building on (i.e. tries to speed up the compiling, but you still get the same output)
Nonsense. It *does* affect the code you produce. What would be the point in having an option to tell the compiler which machine it's running on? It's in a far better position to enquire which features are supported by the CPU that is executing and even then, I doubt dynamically reordering its own instructions to improve performance is a viable option. If you want optimal performance for the compiler you're using, recompile it for the CPU you're compiling on.

Jim
 
Old 03-13-2005, 07:55 AM   #11
chbin
Member
 
Registered: Mar 2005
Distribution: slackware-current
Posts: 379

Rep: Reputation: 31
I've been thing about that and it would make no sense if it didn't change the code.

So unscratch that!
 
Old 03-13-2005, 03:58 PM   #12
cathectic
Member
 
Registered: Sep 2004
Location: UK, Europe
Distribution: Slackware64
Posts: 761

Rep: Reputation: 35
Jim,

I apologise for my initial mistake - a bit of research clears up that the -mtune does affect the code outputted. So, to make up for my stupidity, the findings of some slighly more thorough research:

The code is optimized for the targetted processor, mostly in terms of scheduling, on -mtune, but does not add any instructions that are not compatible with the processor specified in -march.

For instance, if I specify "-march=i386 -mtune=i686" the code will be optimised for everything it can be for the i686 (especially in terms of instruction scheduling, etc) but it will not generate any instructions that are not compatible with the i386 instruction set.
 
Old 03-15-2005, 04:07 PM   #13
kriton12
Member
 
Registered: Oct 2002
Posts: 81

Original Poster
Rep: Reputation: 16
wow, thanks for all of the information. So essentially any speed gains claimed by a distro saying it's been optimized for i686 architecture is on the whole negligent mainly because of system bottlenecks. I understand that faster processors generally only perform better when you keep the cpu fed and that memory speed and cache size are what affects this. Without getting into a huge hardware discussion is it basically fair to say that Slack 10.1 runs pretty much the same speed as other distros built off of slack and "optimized for i686"? That's kind of what I gather from the general response (albeit not so clear cut).

Oh, and for the record, I'm talking daily, average computing tasks, not high performance gaming or compiling software, just general day to day stuff.
 
Old 03-20-2005, 11:33 PM   #14
Atmchicago
Member
 
Registered: Apr 2003
Location: Baltimore
Distribution: Fedora
Posts: 220

Rep: Reputation: 32
So I'm curious: why are most redhat packages i386, and slackware packages i486?
 
Old 03-21-2005, 12:05 AM   #15
kaon
Member
 
Registered: Dec 2003
Location: Hong Kong SAR
Distribution: Slackware 9.1, 10.x, slackware-current
Posts: 186

Rep: Reputation: 30
Quote:
Originally posted by cathectic
For instance, if I specify "-march=i386 -mtune=i686" the code will be optimised for everything it can be for the i686 (especially in terms of instruction scheduling, etc) but it will not generate any instructions that are not compatible with the i386 instruction set.
If the instruction set is i386 compatible (-march), how can it be optimized for i686 (-mtune)?

Correct me if I am wrong.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ArchLinux is optimized for i686... pppaaarrrkkk Linux - Newbie 3 06-30-2005 02:09 PM
i686 optimized distro wanted flying-tuxman Debian 23 06-11-2005 08:45 AM
2.6.9-5.EL-hugemem-i686, 2.6.9-5.EL-i686, 2.6.9-5.EL-smp-i686 , Which? arsham Linux - General 2 05-07-2005 11:21 PM
2.6.9-5.EL-hugemem-i686, 2.6.9-5.EL-i686, 2.6.9-5.EL-smp-i686 , Which? arsham Linux - Enterprise 1 05-07-2005 07:20 PM
Fedora or other distro optimized for i686 or athlon-xp Apollo77 Linux - Distributions 2 05-25-2004 03:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration