Friday July 27, 2007 GCC vs GCCfss vs Studio performance on SPARC
Here is a relative performance chart for several versions of plain GCC including the latest GCC 4.2, just released GCCfss 4.0.4, previous GCCfss 4.0.3, upcoming GCCfss 4.2 and Studio 12 with the most recent patches.
All runs were done on UltraSPARC 4+ box on SPEC CPU2006 FP base with C and C++ benchmarks.

GCC flags:
-O3 -mcpu=ultrasparc3 -funroll-loops -ffast-math -fprefetch-loop-arrays
GCCfss and Studio flags:
-fast -xipo=2 -xpagesize=4M -xprefetch_level=2 -xalias_level=std/layout/compatible
The runs are not SPEC conforming, since Fortran benchmarks were not run, but very representative of any floating point heavy application on SPARC. So consider them an 'estimate'.
Some observations:
We got our next version of GCCfss 4.0.4 available for download here
Main differences vs GCCfss 4.0.3:
Upcoming GCCfss (GCC for Sparc Systems) 4.0.4 is going to relocatable.
While working on building OpenSolaris with gcc4/gccfss I encountered one interesting bug which can be demonstrated by the following simple C program:
void foo (long long *);
void bar (long a, long long b)
{
typeof (a+b) c;
foo (&c);
}
compiled with gcc 3.4 it will print the warning:
$ gcc3 -c simple.c -m64 simple.c: In function `bar': simple.c:6: warning: passing arg 1 of `foo' from incompatible pointer type
whereas gcc 4.x will compile this testcase without any warnings.
The reason for that is GCC 3.x consider 'long + long_long' expression as 'long' type in 64-bit mode which is incorrect.
Why would I care ?
There are multiple places in OpenSolaris where it needs to print 64-bit value and it is done with '%llx' printf specifier. Due to this gcc 3.4 bug the Solaris sources were using '%lx' specifier to print expressions involving long and longlong types and now our changes to compile ON with gcc 4.x would break ON build with /usr/sfw/bin/gcc 3.4 unless the fix can be backported into "csl-sol210-3_4" Solaris specific gcc branch.
All in all, Solaris seems to be overdue to upgrade to some newer version of GCC.
Posted by alexey ( Feb 26 2007, 12:45:09 PM PST ) PermalinkBy working on gcc4/gccfss for OpenSolaris project I found one interesting difference between Studio and GCC compilers.
Studio treats all enumration types in C as signed integers, whereas GCC can put them in unsigned type depending on the values of enumerators.
At first it may look like a minor difference, but in Solaris there was this piece of code:
typedef enum {
A = 0,
B,
C
} en_t;
en_t var;
for (;var >= A; var--);
From GCC point of view the expression "var>=A" is always true, so the loop is collapsed into for(;;) even at -O0 optimization level.
From Studio point of view this code is fine.
Both are correct, because the choice of type is implementation defined by C standard.
One user reported an interesting problem: the same application was giving one result on Ultra III and different result on Ultra IV and Ultra II.
Turned out that some operations on floating point were trapping into the OS on ultra3 and Solaris fp emulator executed them in IEEE compliant way whereas Ultra4 and Ultra2 were executing the same code natively on cpu and because 'non-standard' bit in fsr register was set, Ultra4/2 chips produced different result than Solaris emulation.
Of course this behaviour of Ultra3 is documented, but you really need to be a chip guru to know/remember such details.
That's just something to be aware of if you use floating point a lot
and compile with -ffast-math or -fsimple or -fns flags with GCCfss.
GCCfss 4.0.3 patch update is available
We've just released a patch for GCCfss 4.0.3. It's located at the same place place on SDLC website.
Please download it, remove old 4.0.3 packages and install new 4.0.3 packages.
This patch contains several fixes for the problems reported on the cooltools forum.
You would need to download both packages (SUNW0scgfss and SUNW0gccfss), since the bugfixes went into both.
Please give it a try and send us your feedback. We're constantly working on improving GCCfss and the user feedback makes it even better.
Posted by alexey ( Nov 03 2006, 09:33:58 PM PST ) PermalinkWe got our next version of GCCfss 4.0.3 available for download here
Main differences vs GCCfss 4.0.2:
While dealing with yet another c++ bug, I remembered this:
"C++ programmers must use floppy disk instead of hard drive, because C++ has an advantage over C"
Rules of CS national competition. 1993.
Wish c++ stayed as it was in 1st edition.
Posted by alexey ( Aug 17 2006, 10:33:13 PM PDT ) PermalinkGoogling around on a nice sunny day I found out that GMP (GNU Multiple Precision Library) failed to build with GCCfss version 4.0.2 in 64-bit. It turned out that 'addccc' instruction wasn't recognized by Sun code generator. The supported form of it 'addxcc' was there, but v9 variant 'addccc' was missing. Certainly an easy fix. So upcoming version of GCCfss version 4.0.3 will understand this instruction and to make sure that gmp has no other issues with GCCfss we built it and tested it in 32-bit and 64-bit.
Ohh, yes, GCCfss version 4.0.3 is about to be released.
Posted by alexey ( Aug 06 2006, 09:24:03 PM PDT ) Permalink Comments [2]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.