NAG and GNU Fortran Compilers
March 7, 2005 – 10:47 pmThe two Fortran compilers I have used while at Caltech are the NAG and GNU g95 compilers. At some point last summer, I tried to compile my research code with g95 (I had previously only used the NAG compiler), and I noticed that the code ran about four times slower with the GNU compiler. When the code takes about 5 days to run with the NAG compiler, a factor of four performance loss simply isn’t an option. The GNU compiler, being an open source project, is being rapidly updated (almost daily, in fact), and Rick recently told me the GNU people had made some drastic improvements to g95’s optimization settings.
I decided to run a very brief and informal test on my CFD project code to see what the differences are between the two compilers on this particular system. I claim nothing other than these results are what I saw on my lab computer when I ran the tests this evening. For my CFD project, I solve two linearized partial differential equations on a rectangular grid. I ran tests of 50×50 cells, 60×60 cells, 70×70 cells, and 80×80 cells. I compiled the code with the optimization option “-O4″ with each compiler. The times below are in the format of minutes:seconds.
50×50 NAG 1:43 GNU 1:52
60×60 NAG 3:29 GNU 4:11
70×70 NAG 6:46 GNU 7:37
80×80 NAG 11:59 GNU 13:15
As I mentioned, the tests were very informal. I had the program call the system clock and write the time data to a text file when it began and finished the program so that these write statements were as close to the first and last executed statements as possible. At first, I thought I would see a gradual widening of the performance gap between the two compilers [in the (NAG time)/(GNU time) sense] as the computational cost of the program increased, but that did not happen for this particular test case. Regardless, I did not see the four-fold performance improvement of the NAG compiler compared to the GNU compiler as I had last summer (granted, different system and different code). I am curious to see what happens when I try the latest GNU compiler on my research code in the next couple of weeks.
4 Responses to “NAG and GNU Fortran Compilers”
10% is still a reasonably impressive performace boost. This seems like one of those open source applications that really needs to be not-even-a-little-bit-worse than its closed source alternative; most of the people that compile Fortran have grant money.
By MDA on Mar 8, 2005 at 12:02 am
That grant money could be going to Apple instead of NAG, with 17′ Powerbooks flowing our way! *drool*
By Kristján on Mar 8, 2005 at 8:17 am
haha - fair enough.
By MDA on Mar 8, 2005 at 12:45 pm
That’s true about the “not-even-a-little-bit-worse” bit. I will keep running these tests every so often in the hope of (1) finding something I can report back to the developers to help them in their progress and/or (2) finding a version of the GNU compiler that outperforms the NAG compiler I’m currently using. I like the GNU compiler for the same reasons I like almost all open source projects, so I’m rooting hard for them.
By jjk on Mar 8, 2005 at 11:11 pm