NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: gcc, march and sse

Le Ven 5 décembre 2008 4:12, Jim Capozzoli a écrit :
> On Wed, Dec 3, 2008 at 10:26 AM, Joel Carnat <> 
> wrote:
>> Hello,
>> I read that Slackware Linux compiles most of its packages with
>> "-march=i486 -mtune=i686". As far as I understood gcc's manpage, this
>> means "keep code compatible with 486 CPU but allow the use pentiumpro
>> special features", right ?
>> Still from the man page, MMX is supported since "pentium2 (or
>> pentium-mmx
>> only)", SSE since "pentium3", SSE2 since "pentium-m", SSE3 since
>> "prescott".
>> I tweaked my mk.conf to compile pkgsrc (on a domU) using "-O2 -march=486
>> -mtune=686" but I'm now wondering if any on those compiled programs will
>> use MMX or SSE when running on my laptop or intel-based servers (intel
>> core2duo).
>> Then second question, in case the previous thought is correct, if I use
>> "-march=i486 -mtune=nocona", is there a way to see which instruction the
>> program uses ? For example, if I compile xorg/firefox/mplayer and then
>> run
>> it in a special manner, can I see that the core2duo uses MMX/SSE*
>> instruction while the C3 only use MMX instruction (from the same binary)
>> ?
>> TIA,
>>    Jo
> Well, there's this script or something that can figure out the ideal
> flags for you so you don't have to worry about it.

well... from the domU I compile, I think it says : use pentium4.
but I expect this will not run on my VIA C3 proc because of SSE2.

> On my pentium3 machine it has everything building with MMX
> instruction, and everything seems to be working nicely.

well... the primary idea was which flags to pass to gcc so that it
compiles optimal code that can run on a VIA C3 (MMX + SSE), an Intel ATOM
(MMX + SSE2) and a core2duo (MMX + SSE3) rather than "which flags to use
on a particular CPU".

I thought I could tell GCC to compile code with kind of "if CPU supports
feature_X, use it at run-time" inside. So that, lets say, seti@home uses
MMX+SSE on the VIA, MMX+SSE2 on the Atom and MMX+SS3 on the Core2Duo.

As far as I understood the informations from this thread, it doesn't make
sense at all since forcing the use of a particular feature breaks the code
for CPU that does not support it.

I ended up using '-Os -march=c3-2 -mtune=nocona".
The whole compilation process is not yet finish but I expect firefox/xfce
and mplayer to run on every CPU I have/mentionned.


Home | Main Index | Thread Index | Old Index