Fortran computes cosine 300 times faster than C (on Sun3)
Henry Spencer
henry at utzoo.uucp
Thu Mar 9 09:49:29 AEST 1989
In article <765 at uceng.UC.EDU> achhabra at 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 at zoo.toronto.edu
More information about the Comp.lang.c
mailing list