McStas and compiler bugs

Investigations indicate that McStas-generated code is very sensitive to bugs in the optimizers of commonly used compilers! This note documents preliminary results on comparing a McStas simulation when compiled with different compilers and optimizations.

Compilers were:

The i386-linux compiled simulations were run on a 300MHz Pentium II. The HPPA compiled simulations were run on the fys-hp-2 workstation.

The results:

Compiler flags I [p/N] MON [p/N] neutrons/sec
gcc-i386 none 3.1e-07/393 17823.7/72244 23k
gcc-i386 -O6 3.3e-07/428 17868.9/72309 25k
egcs -O6 3.6e-07/420 17938.8/72394 30k
pgcc none 2.8e-07/387 17945.1/72334 21k
pgcc -O6 4.8e-07/718 8420.16/34245 36k
cc -Aa 2.9e-07/379 17937.6/72292 17k
cc -Aa +Oall -Wl,-a,archive 1.7e-07/203 17949.7/72351 40k
gcc-hp none 3.0e-07/373 17877.8/71976 19k
gcc-hp -O6 3.2e-07/368 17726.2/71825 22k

As can be seen from the table, PGCC and HP CC with full optimization gives very large speedups on the simulations, but unfortunately also produce incorrect results!

Update

A new release of PGCC (1.1a) seems to correct the bugs and produce correct code. Using the '-mstack-align-double' switch in addition to -O6 it also achieves slightly better performance, about 31k neutrons/sec.
Kristian Nielsen <kristian.nielsen@risoe.dk> / Sep 3, 1998.