Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Effective streaming questions

Reply
Thread Tools

Effective streaming questions

 
 
James Kanze
Guest
Posts: n/a
 
      09-08-2008
On Sep 8, 1:17 am, Jerry Coffin <(E-Mail Removed)> wrote:
> In article <7b2ad5ae-f0c8-40da-9ac8-f2aa1087e5f5
> @f36g2000hsa.googlegroups.com>, (E-Mail Removed) says...


> [ ... ]
> > With a really good compiler, that's not necessarily true. The
> > compiler will produce much better code than you could write by
> > hand. (Admittedly most C++ compilers aren't that good. Yet.)


> Sadly, I've yet to see any compiler for any language for which
> that was true. Most compilers do better than most people
> realize, but a decent (not even great) assembly language
> programmer virtually never has any difficulty doing better.


Globally, or locally. I've actually used a Fortran compiler
that did better than assembler programmers globally. Locally,
of course, for some specific constructs, it could be beaten, but
an assembler programmer's memory (e.g. with regard to what's in
each register) isn't as good as that of the compiler.

I suspect that it depends on the architecture as well. A
machine with complicated timing constraints in the pipeline and
a lot of registers favors the compiler; a machine with few
registers and relatively few issues concerning the pipeline
(Intel?) favors the programmer.

> OTOH, you're unlikely to get a _significant_ improvement
> except by knowing quite a bit and/or dealing with relatively
> unusual situations.


It's the dealing with unusual situations which really pays off.
If the machine supports decimal arithmetic at the hardware
level, for example, a few well placed lines of assembler will
make all the difference in a BigDecimal class.

> > > That being the case, writing all that code by hand rarely
> > > accomplishes anything useful at all.


> > Writing everything in assembler is always a waste of time.


> I'd agree that it's true 99.9% (and maybe even add another '9'
> or two on the end) of the time, but not quite always. An
> obvious example would be a talking greeting card. Here the
> price of even a small amount of memory is a significant
> percentage of the overall price, and there's little enough
> product differentiation that one being even marginally less
> expensive than another could lead to essentially shutting the
> second out of the market entirely.


Agreed. I'd forgotten about things like that.

> IOW, using a higher level language for even part of the final
> product virtually guarantees failure. OTOH, I'm the first to
> admit that such situations are _quite_ unusual, to put it
> mildly.


Maybe not that unusual, but in such cases, you generally don't
have the option of C++ anyway. (You might have C, but even
that's not really certain.

> For typical desktop and/or server applications, the
> situation is entirely different.


> > Conceivably, if the profiler shows a problem in one tight
> > loop, and all other attempts fail to achieve enough
> > performance, rewriting that one loop in assembler might
> > accomplish something, assuming you know the machine very,
> > very well.


> I've written enough assembly language to be able to say with
> reasonable certainty that the situation's a bit more positive
> than that -- if you know the assembly language _reasonably_
> well, and find a justification for doing so, you can pretty
> much guarantee doing better than any compiler around today.


For a single loop, perhaps, and even then, I'm not really
convinced. I know that I couldn't improve most of the loops
generated by the Fortran compiler on the Perkin-Elmer (formally
Interdata) 8/32, and I knew the assembler and the processor well
enough to teach it, and to write drivers and such.

--
James Kanze (GABI Software) email:(E-Mail Removed)
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
StreamRipper - record streaming audio - questions L Mehl Computer Support 64 02-05-2006 12:06 AM
Couple of questions : RSS and streaming johnsonholding@yahoo.com HTML 3 01-26-2006 05:13 PM
Re: Questions....questions....questions Patrick Michael A+ Certification 0 06-16-2004 04:53 PM
Streaming xml questions Guillaume Dargaud XML 1 02-23-2004 06:49 PM



Advertisments