Article View: comp.std.c++
Article #2260Re: F90 vs C++/C, optimization question?
From: Peter Schmitteckert
Date: Thu, 19 Oct 1995 19:01
Date: Thu, 19 Oct 1995 19:01
57 lines
2748 bytes
2748 bytes
In article <45ld1i$m7i@cicg-communication.grenet.fr>, enseeg14@grenet.fr () writes:
[..]
> C has always been the language where _THE PROGRAMMER_ could make his
> own optimization, but this style of programming is getting deprecated
> according to most C++ who basically say "rely on the compiler, optimize
> only as a last minute operation". But here I have an example of what
> would be very unefficient in C/C++ compared to F90:
>
> > for (i = 0 ; i < n ; i++) {
> > for (j = 0 ; j < n ; j++) {
> > a[i][j] = b[i][j] * c[i] ;
> > }
> > }
>
> > do j = 1,m
> > do i = 1, n
> > a (i,j) = b(i,j) * c(i)
> > enddo
> > enddo
>
[...]
As a physicist programming in C++ I have to compare the performance of my
programs to those written in FORTRAN.
C++ routines written in a FORTRAN _style_ are often slower than the routines
written in FORTRAN.
Nevertheless my programs are faster since I try to avoid loops
as the one mentioned above, hiding the actual calculation in linear
algebra classes in which I call BLAS routines.
And why not using a FORTRAN subroutine in special cases ?
What's really needed, in my opinion, is not a change in the language which enables
the compiler to perform better optimization, but powerful libraries & classes,
e.g. a BLAS class or sophisticated matrix classes (like LAPACK++ (LAPACK+=2 ?) ).
Regards Peter
------------------------------------------------------------
Peter Schmitteckert --- Lehrstuhl fuer Theoret. Physik 2
Institut f\"ur Physik --- D 86135 Uni Augsburg
e-mail: Peter.Schmitteckert@Physik.Uni-Augsburg.de
URL: http://www.physik.uni-augsburg.de/theo2/Group/Schmitteckert.html
Phone: +49-821-5977-246 Fax: +49-821-5977-262
[Moderator's note: this discusson seems to be drifting away from the
C++ standard, so I've inserted a Followup-to line to redirect
followups to comp.lang.c++. You should edit the Newsgroups line if
your reply is relevant to the standard and if you want it to appear in
comp.std.c++. mha]
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<DGnyCx.B30@Yuri.CC.Uni-Augsburg.DE>Path:
arc1-ca.pugleaf.net!Physik.Uni-Augsburg.DE!petersReferences:
<45ld1i$m7i@cicg-communication.grenet.fr>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!Physik.Uni-Augsburg.DE!peters From: peters@Physik.Uni-Augsburg.DE (Peter Schmitteckert) Newsgroups: comp.std.c++ Subject: Re: F90 vs C++/C, optimization question? Followup-To: comp.lang.c++ Date: 19 Oct 1995 19:01:42 GMT Organization: Universitaet Augsburg Approved: matt@physics2.Berkeley.EDU (Matt Austern) Message-ID: <DGnyCx.B30@Yuri.CC.Uni-Augsburg.DE> References: <45ld1i$m7i@cicg-communication.grenet.fr> NNTP-Posting-Host: physics2.berkeley.edu