compiler thoughts

All | Personal | Sun
Main | gcc4ss flags »
20060307 Tuesday March 07, 2006

GCC for SPARC Systems is live!

Finally we got "GCC for SPARC Systems" out:
http://cooltools.sunsource.net/gcc/

To get the most out of SPARC chips the compiler optimizations are important. Apps on x86 chips usually don't gain much if recompiled for the specific chip. The difference between -mcpu=i386 and -mcpu=i686 gcc switch is relatively small. On SPARC the correct chip switch is more important. US2 comiled apps will suffer on early US3.

The plain GCC is using SPARC V7 ABI as a default. That means no integer mul/div instructions and schedulling for pretty old chip. Not every GCC user knows about -mcpu flag and its effect. Some users use -mcpu=v9 for all their needs, because other -mcpu switches don't produce a desirable speedup. Some users add only -mv8plus flag, see no difference in run-time and get upset. A few internal details of SPARC chips are not public and it's tough for GCC to do the perfect tuning. Read after write penalties are not modelled correctly in GCC scheduler yet. The cost of prefetch instruction and prefetch implication on the different SPARC chips didn't made into GCC backend. The users of gcc 4.0.x have to cope with early US3 tuning. The future gcc 4.2 release is going to have some support for Niagara. So the Niagara users have an option to wait till stable gcc 4.2 is released, or try its development snapshot, or go with gcc4ss+scg4ss which already has Niagara specific tuning.

With GCC for SPARC Systems (gcc4ss) the code generation, tuning, insn scheduling,etc is done by Sun Code Generator for SPARC Systems (scg4ss) that knows everything about underlying architecture. Going from GCC's V7 to tuned code normally buys a nice speedup for integer code and a lot more for floating point.

The default arch selection for gcc4ss is v8plus (since it's tough now days to find pre-v8plus chip) and tuning is done for 'blended' model, which is trying to produce close to optimum tuning on most of the modern SPARC chips. So just recompiling with gcc4ss with the same old gcc flags can give a significant boost in performance.

Alexey.

Posted by alexey ( Mar 07 2006, 09:21:54 AM PST ) Permalink Comments [5]

Comments:

WRT the default ABI being V7. If you think that is an important problem, it's a 3 lines patch to change the default, and it would probably be accepted. A lot of people configure gcc using --with-cpu=v9, that way the default is not V7 anymore. About the scheduling information, if you'd file bug reports about the problems that you know, they might get fixed....

Posted by p on March 10, 2006 at 10:54 PM PST #

I find it hard to believe that gcc sparc backend maintainers don't know about v7 implications. Worth a try, of course.

Posted by Alexey on March 11, 2006 at 01:01 AM PST #

I am quite sure that the sparc maintainers are aware of the implications of V7. But a lot of gcc users are also aware (and so are system administrators that compile gcc to not default to V7). But you are right in one respect, there's no real reason for gcc to default to V7 at this time. Changing it is trivial.

Posted by p on March 11, 2006 at 10:33 AM PST #

I wish the gcc users knew about the default. I haven't seen a single case so far. btw gcc manual doesn't mention this flag in the sparc specific part of it, so it doesn't help either. But I've seen lots of users who think that -mcpu=v9 is for 64-bit mode only and other users who think that -mv8plus makes a difference when specified alone. Also I believe that sparc-*-freebsd has mcpu=ultrasparc as a default, but Solaris for some reason is still on v7. What especially weird is that gcc generates v7 .s, but calls assembler with -xarch=v8. Also Solaris no longer runs on v7.

Posted by Alexey on March 13, 2006 at 12:33 AM PST #

btw pre-release gcc testing happens in the default config only. If there are any bugs with --with-cpu they will not be caught until some user find it. So the administrators who setup their gccs with that flag do that on their own risk.

Posted by Alexey on March 13, 2006 at 12:36 AM PST #

Post a Comment:

Comments are closed for this entry.

Disclaimer:

This site is a personal blog and is to be used for informational purposes only. The views expressed on this blog are those of the author only, and should not be attributed to any past or present employers.

Calendar

RSS Feeds

Search

Links

Navigation

Referers