Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!ames!sgi!shinobu!odin!bananapc.wpd.sgi.com!ciemo From: ciemo@bananapc.wpd.sgi.com (Dave Ciemiewicz) Newsgroups: comp.sys.sgi Subject: Re: C++ and C Message-ID: <4537@odin.SGI.COM> Date: 26 Feb 90 00:32:57 GMT References: <4534@odin.SGI.COM> <205*doelz@urz.unibas.ch> Sender: news@odin.SGI.COM Reply-To: ciemo@bananapc.wpd.sgi.com (Dave Ciemiewicz) Organization: Silicon Graphics, Inc. Lines: 48 After some sanity checking by a fellow engineer, I must clarify a few points. In article <4534@odin.SGI.COM>, ciemo@bananapc.wpd.sgi.com (Dave Ciemiewicz) writes: > In article <205*doelz@urz.unibas.ch>, doelz@urz.unibas.ch (Reinhard > Doelz) writes: > > Hi , > > we are about rewriting our graphics application in order to tune code. > > We have some own object-oriented modules which would fit > > pretty nicely in C++ structures. However, as tuning is the > > ultimate target, does anyone know about > > > > * C++ performance in comparison to 'plain' C modular structures > > It really does depend on your application and how you implement your C++ > classes and how you previously implemented the same data abstractions in > 'plain' C. For instance, the use of C++ derived classes and virtual member > functions can produce faster code than might be equivalently implemented > using a data type tag and switch statement in C. Judicious use of C++ inline > functions can also speedup some code. > > Unfortunately, no one can give you a pat answer one way or another. There > have been some claims made on comp.lang.c++ though I haven't followed those > discussions in awhile. Including me. The sanity check of a test program definitely showed me that switch statements can produce faster code than using virtual functions and not as I claimed in the prior message. However, maintaining the code which uses the virtual functions is easier. By-the-by, I just proved this to myself using C++ and pixie. Sigh. More proof you can't rely on hearsay to see that one thing is faster than another. The proof is in the profile. > > > > * Optimizer issues: problems with O3? > > The AT&T C++ Translator from SGI just produces C code. There should not be > any problems with using -O3 optimization. > There is an issue concerning -O3 optimization. -O3 and -c are mutually exclusive with the MIPS cc. The C++ translator uses the -c flag in the creation of object code. Hence, you will need to have C++ generate the intermediate ..c files and then manually compile them together using cc -O3. Ugly, but it will still provides the -O3 optimization. --- Ciemo