Mac (Under) the Knife: Troubleshooting
This blog post references my cover story, 'Mac (Under) the Knife: Piecing Together the PowerPC Puzzle' in the September 15, 2005 edition of EDN.
If you'd like to explore the SPEC benchmarks on PowerPC-based hardware for yourself, there's no need to tackle hurdles we've already surmounted. Initial compilation of the SPECINT code with “-O0” and “-O3” flags set on the GCC compiler was unsuccessful with the “eon” routine. Project co-participant Eric Nedervold explains, “The 'eon' test was just a mismatch in header files; the question is whether the fmax() function returns a float or a double. Looking in my ANSI C standard, I don't find fmax(), so it must be part of the UNIX libraries, which are guided by tradition, not by any standard (though POSIX may have something to say)….The code was written assuming fmax() returned a float; somewhere along the way; someone tried to run it on a system where fmax() returns a double, so they threw a patch into the code allowing you to change that assumption via a preprocessor flag. So down in the ‘Portability flags’ section of the cfg files, we changed:
252.eon=default=default=default:
EXTRA_CXXFLAGS=-DHAS_ERRLIST
to
252.eon=default=default=default:
EXTRA_CXXFLAGS=-DHAS_ERRLIST
-DFMAX_IS_DOUBLE.
And that made the compiler happy.”
Further problems reared their ugly heads when we attempted to create G4- and G5-optimized variants of the compiled SPECINT code, employing GCC's “-fast” flag. In some cases, the compiler crashed, and when we got compiled code, the routines wouldn't successfully run. So we undertook a tedious step-by-step dissection and iterative removal of the various compiler settings comprehended by the generic “-fast” directive in the hopes of discovering and deleting the offending flags. Nedervold explains, “I put all the flags that -fast is supposed to expand into, into the OPTIMIZE variable as one line:
-O3 -falign-loops-max-skip=15 -falign-jumps-max-skip=15 -falign-loops=16 –falign-jumps=16 -falign-functions=16 -malign-natural -ffast-math -funroll-loops ftree-loop-linear -ftree-loop-memset -mcpu=G4 -mpowerpc-gpopt mtune=G4 -fsched-interblock fgcse-sm -mpowerpc64
and ran it. I still ended up with multiple declaration warnings for variables in the 'crafty' test. If I remember right, multiple declarations of a variable are illegal in C++, but not necessarily in C. Because 'crafty' is a C program, this seems to be a compiler bug.
“I then used a divide-and-conquer approach to try to figure out which flags were causing the problem.I found that -ftree-loop-memset would crash the compiler (you can comment out flags with a pound sign; put one before it and then one after it, and you can see this). I pulled that flag, and then everything compiled fine. Perhaps this was all just a GCC bug.I ran the tests.
“On the 'gzip' test it produced bad output:
*** Miscompare of input.graphic.out, see /Users/spec/spec/benchspec/CINT2000/164.gzip/run/00000002/input.graphic.out.mis
*** Miscompare of input.log.out, see /Users/spec/spec/benchspec/CINT2000/164.gzip/run/00000002/input.log.out.mis
*** Miscompare of input.program.out, see /Users/spec/spec/benchspec/CINT2000/164.gzip/run/00000002/input.program.out.mis
*** Miscompare of input.random.out, see /Users/spec/spec/benchspec/CINT2000/164.gzip/run/00000002/input.random.out.mis
*** Miscompare of input.source.out, see /Users/spec/spec/benchspec/CINT2000/164.gzip/run/00000002/input.source.out.mis,
which was quite discouraging, as this process had already taken a long time.I looked at the manual page, where it warned:
Continued with 'Mac (Under) the Knife: Troubleshooting Continued'….















