Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!husc6!psuvax1!news From: schwartz@shire.cs.psu.edu (Scott Schwartz) Newsgroups: comp.lang.c++ Subject: Re: C++ vrs Fortran for linear algebra. Message-ID: Date: 30 Jul 89 06:41:44 GMT References: <3967@portia.Stanford.EDU> <508@gill.UUCP> Sender: news@psuvax1.cs.psu.edu Organization: Pennsylvania State University, computer science Lines: 43 In-reply-to: paul@gill.UUCP's message of 28 Jul 89 22:18:25 GMT In article <3967@portia.Stanford.EDU>, jon@hanauma (Jon Claerbout) writes: |ABSTRACT: C++ can be customized to look like Fortran in its | array subscription, but it has an advantage | over Fortran that variable dimensioned arrays | can be dynamically allocated. | A benchmark shows C++ about half as fast on a DEC 3100. | |ANALYSIS: fortran C | real x(n,m) x = alloc( n*m* sizeof(float)) | x(i,j) = etc x[ i + index[j] ] = etc | |COMMENT: This is a great example for C++ textbook writers. | |COMPILER: AT&T C++ version 1.2.1 | |DEMONSTRATION BELOW ------------------------------------------------- |// 7.0sec 1575556480. DEC 3100 (f77 -O3) |// 13.1sec 1575559552 DEC 3100 (C++ -O2) Results for a Sun4/280: # f77 -O4 -R x.r /usr/lib/libm.il time xr 1576677724. if double precision 1575556480. here in single 7.4u 0.1s 0:11 64% 0+432k 0+0io 0pf+0w # g++ -O -fno-defer-pop -fstrength-reduce x.cc -lm time xc total=1575556480.000000 1576677724. if double precision 19.3u 0.1s 0:34 56% 0+208k 0+0io 0pf+0w Using Dirk Grunwald's modifications: time yc total=1576677723.737338 1576677724. if double precision 24.6u 0.1s 0:27 90% 0+360k 0+0io 0pf+0w -- Scott Schwartz