Mailinglist Archive: opensuse-factory (850 mails)

< Previous Next >
Re: [opensuse-factory] Dist Meeting 2006-09-14: Proposed Agenda
  • From: Robert Schiele <rschiele@xxxxxxxxx>
  • Date: Thu, 14 Sep 2006 00:17:34 +0200
  • Message-id: <20060913221734.GH5937@xxxxxxxxxxxxxxxxxx>
On Wed, Sep 13, 2006 at 04:46:30PM -0400, Marc Collin wrote:
> time to start, time to run function.....
>
> when i created some program in C for a company i used often something similar
> to....
>
> g++ -O2 -funroll-all-loops -fomit-frame-pointer -ffast-math -march=x86-64 -mfpmath=sse
> program_name.cpp -o program_name
>
> i get about 10% faster then the standard syntax....

Compared to what?

Measured on what sort of algorithms?

I'l try to explain why your suggestion does not really make sense:

- -funroll-all-loops unrolls even loops where performance gains are at least
questionable. On the other hand loop unrolling can always lead to cache
thrashing and thus slowing down code in the average case.

- -fomit-frame-pointer is on for -O2 on plattforms where it does not hurt
debugging anyways. On the other plattforms it makes debugging practically
impossible.

- -ffast-math is critical (as mentioned already in another mail) because it
makes the compiler violate standards.

- -march=x86-64 --- What do you expect from that except cluttering the command
line?

- -mfpmath=sse is default anyway on x86-64.

As a conclusion the only thing that does make sense here is -O2 which is used
anyway.

As a general rule of thumb: Never use an "optimization" if not _both_ of the
following conditions hold true:

1. You know exactly what (side) effects your "optimization" does provide.

2. You can _prove_ by numbers that the "optimization" does provide a
_significant_ benefit in a _typical_ use case.

Robert

--
Robert Schiele
Dipl.-Wirtsch.informatiker mailto:rschiele@xxxxxxxxx

"Quidquid latine dictum sit, altum sonatur."
< Previous Next >