This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc 4.3 generates less efficient code than gcc 4.1 or 4.2


On Thu, Jul 03, 2008 at 01:47:44PM +0200, Vincent Lefevre wrote:
> On 2008-07-02 20:08:52 -0400, Michael Meissner wrote:
> > Without having the code in a bug report, there is no way to say what
> > the problem is. It is best if you can take some time to reduce the
> > code to an example that shows clearly where the slowdown occurs. You
> > can use normal -pg profiling, oprofile, or tools like Code
> > Analyst/Vtune to identify where the hot spots are if you don't
> > already know where the hot function is. The simpler you make the
> > example, the more likely somebody will fix it (unless you pay
> > somebody to fix it, and then presumably as part of the
> > investigation, they will reduce it).
> 
> -pg/gprof didn't help since there's more or less a single function
> (in fact there are several ones, but inlined).

I wasn't sure if you knew where the hot-spot functions were since you didn't
post any details about the app.  It sounds like you do.

> In fact, -march solved the problem, and after all, it's not abnormal
> that a later gcc version generates less efficient code if the
> architecture is incorrect. Now, I thought that gcc would have used
> sensible default values (I couldn't find anything in the manual about
> the default architecture).

GCC 4.2 switched the default tuning to -mtune=generic which is a compromise
between the current Intel and AMD systems, each of which have different tuning
parameters.  Obviously it is a balancing act to get the right compromise, and
sometimes the generic tuning is wrong.

> Also, is there a way to *automatically* get the best march value for
> the local machine? In my case, jobs run on various machines (they're
> submitted by SGE): they generate C code, compile it locally and run
> it. I don't even have a direct ssh access to some of these machines.

-march=native was added in GCC 4.2 will probe the system and set the
appropriate tuning defaults.  Some Linux vendors have ported the -march=native
support back to their 4.1 compilers.

> I could instruct my jobs to try different options, do timings and
> cache the best option for the next jobs that will run on the machine,
> but if I can directly get the best one, that would be easier.

I am currently working on a project (function specific option support) that
would allow you to compile a function with different options.  The current
patches that are in review allow you to specify the options for the function,
but you have to do the appropriate glue work to make sure a function compiled
for the right system gets chosen.  I hope to go to the next stage where the
compiler would generate the clone functions and dispatch them automatically.

The twiki that describes function specific options is:
http://gcc.gnu.org/wiki/FunctionSpecificOpt

Milepost is another example of work in this area, and it recently was presented
at the GCC summit.
http://gcc-ici.sourceforge.net/papers/fmtp2008.pdf

-- 
Michael Meissner
email: gnu@the-meissners.org
http://www.the-meissners.org


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]