Article View: comp.sys.sun
Article #12706Re: Fortran 300 times faster than C for computing cosine
From: Keith Bierman - SPD Languages Ma...
Date: Tue, 09 May 1989 21:50
Date: Tue, 09 May 1989 21:50
53 lines
1787 bytes
1787 bytes
I'm sorry for the very tardy reply, but I was out of town, my machine (and
office) were moved, and my dog ate my transmittal :>
chuck@trantor.harris-atd.com (Chuck Musciano) writes:
>X-Sun-Spots-Digest: Volume 7, Issue 230, message 1 of 16
>
>Compare the code generated for "sin(x) + cos(x)" in FORTRAN and C. In
>FORTRAN (a5@(-0x7ffc) is x):
>
> fcoss a5@(-0x7ffc),fp0
> fsins a5@(-0x7ffc),fp1
> faddx fp1,fp0
>
One can do better. Here is some source:
real x
x = 10.0
y = sin(x)+cos(x)
print*,y
end
and we compile (f77v1.2)
f77 -O3 -f68881 -S
.... stuff removed
|#PROLOGUE# 1
fmoves L1D20,fp7
fsincosx fp7,fp1:fp0
faddx fp1,fp0
fmoves fp0,VAR_SEG1+4
pea v.16
jbsr _s_wsle
since we can compute sin and cos together with a big savings.
Don't forget to use the inline library
/usr/lib/f77/f68881/libm.il
for your floating point needs.
Cheers.
--
Keith H. Bierman |*My thoughts are my own. Only my work belongs to Sun*
It's Not My Fault | Marketing Technical Specialist
-- I Voted for Bill & Opus| Languages and Performance Tools.
(* strange as it may seem, I do more engineering now *)
Technical Details
Message-ID:
<8905020916.AA02791@chiba.sun.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!rice!sun-spots-requestShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!rice!sun-spots-request From: khb@sun.com (Keith Bierman - SPD Languages Marketing -- MTS) Newsgroups: comp.sys.sun Subject: Re: Fortran 300 times faster than C for computing cosine Keywords: Software Message-ID: <8905020916.AA02791@chiba.sun.com> Date: 9 May 89 21:50:08 GMT Sender: usenet@rice.edu Organization: Sun-Spots Lines: 53 Approved: Sun-Spots@rice.edu Original-Date: Tue, 2 May 89 02:16:17 PDT X-Sun-Spots-Digest: Volume 7, Issue 279, message 1 of 23