Steve Tate wrote: > A while back (this is probably 5 or 6 years ago) I was trying to get > as fast an FFT as possible, so I was experimenting with split-radix > FFT. Being a C programmer first, I implemented this in C and spent > quite a bit of time getting everything as efficient as possible. When > I was done I decided, on a lark, to implement the same general > algorithm in a very straight-forward fashion using FORTRAN. I spent a > couple of days timing and tuning the C code, and about an hour on the > FORTRAN code. And the FORTRAN code was probably 5% FASTER. That > surprised me quite a bit. Now it could very well be that I was using > gcc as a C compiler, which isn't the greatest compiler in the world, > and I was using a propriety very optimized FORTRAN compiler. So maybe > a better C compiler would give me that 5% of runtime speed back. But > what would give me that 2 days of C tuning time back? A while back (3 years ago, IIRC), someone in my university donated a bottle of champagner (which was turned into a chinese meal later) for the first student who exceeds 30 MFLOPS on our 50 MHz PA-RISCs on 500x500 matrix multiplication (using the standard O(n�) algorithm). The naive fortran version got around 10 MFLOPS (compiled with +O3, where the compiler replaced the multiplication with a call to mat_mult()), the naive C version got around 0.2 MFLOPS (because it was heavily swapping, on machines with more memory, it got around 1 MFLOPS). After a short discussion, whether this is possible, and why champagner, I decided to do it, and I got just above 30 MFLOPS, using GCC. Using HP's C didn't help (it was slightly worse); I examined the assembler output, there was nothing to improve. Well, it was hand-blocked for registers and memory, hand-layoutet so that it got the best out of GCC's weak scheduler... and it took me two days (certainly not full 9-5 days, that was on university). It would have taken longer to generalize the approach (either by writing a general matmul function, or by writing a generator for specialized matmul functions), and certainly, this result is _not_ language-dependent (I could have get it out of Fortran, too). Any language with a code generator that allows me to write code that matches the machine instructions and allows me to choose my memory layout does. I often use C, especially GCC, as portable assembler. GCC's built in operations map to many instructions (including indirect branches, which are missing in ANSI C), and when it doesn't, a bug report often helps great. Writing fast software is complicated, it requires deep knowledge of the machine you use, and 99.9% of the programmers will get better code for numerical programs if they use the better compiler (thus Fortran in most cases). For writing larger applications, I don't use C, because it doesn't allow the design methods I like to tune these applications. I use Forth. -- Bernd Paysan "Late answers are wrong answers!" http://www.informatik.tu-muenchen.de/~paysan/