Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Fortran computes cosine 300 times faster than C (on Sun3) Message-ID: <1989Mar8.234929.9905@utzoo.uucp> Organization: U of Toronto Zoology References: <765@uceng.UC.EDU> Date: Wed, 8 Mar 89 23:49:29 GMT In article <765@uceng.UC.EDU> achhabra@uceng.UC.EDU (atul k chhabra) writes: >I chanced upon a segment of code that runs approximately 300 times faster in >FORTRAN than in C. I have tried the code on Sun3(OS3.5) and on Sun4(OS4.0) >(of course, on Sun4 the -f68881 flag was not used.) The results are similar >on both machines. Can anyone enlighten me on this bizzare result? Two things. First, you're asking for single-precision cosine in Fortran and double-precision in C. Second, Sun's Fortran optimizer is much better than their C optimizer, and it has noticed that you're not *doing* anything with those values and deleted the whole computation. You're timing the C code against an empty Fortran loop. -- Welcome to Mars! Your | Henry Spencer at U of Toronto Zoology passport and visa, comrade? | uunet!attcan!utzoo!henry henry@zoo.toronto.edu