Path: utzoo!attcan!uunet!gill!paul From: paul@gill.UUCP (Paul Nordstrom) Newsgroups: comp.lang.c++ Subject: Re: C++ vrs Fortran for linear algebra. Summary: results for Sun 3/60, OS 4.0.1, Oregon c++ Keywords: matrix Message-ID: <508@gill.UUCP> Date: 28 Jul 89 22:18:25 GMT References: <3967@portia.Stanford.EDU> Organization: Gill & Co., L.P., San Francisco, CA Lines: 51 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 ------------------------------------------------- > /* Benchmark Fortran equivalent (actually ratfor) code went here >// 7.0sec 1575556480. DEC 3100 (f77 -O3) >// 13.1sec 1575559552 DEC 3100 (C++ -O2) >// On a sun 3/60 w/ 12 MB and Oregon c++ 1.2Ag /usr/local/paul % time bench total=1576677723.402206 1576677724. if double precision 108.7u 0.3s 1:52 96% 0+12k 5+1io 4pf+0w /usr/local/paul % !! time bench total=1576677723.402206 1576677724. if double precision 108.8u 0.2s 1:50 98% 0+12k 0+0io 0pf+0w One thing bothers me though... my results are so accurate I think that the compiler is using double precision, even though the program specifies float. Havn't found anything relevant in the manual. Obviously that would explain some of the difference in the timing. I don't think that that is the the entire difference, though :-). -- Paul Nordstrom Gill & Co., L.P. uunet!gill!paul