Re: Size of assembly programs...
- From: "Samuel Stearley" <spamtrap@xxxxxxxxxx>
- Date: 27 Dec 2006 02:58:44 -0800
Is it possible to discuss something in this news groups without someone
feeling the need to tell us that we should be sure to only optimize the
bottle necks?
robertwessel2@xxxxxxxxx wrote:
Steven Nichols wrote:
Compilers take the number of things into account that they they were
programmed for. Humans can take much more into account (in code design)
than the machine. The idea that a good optimizing compiler can do as
well as handwritten ASM is still a myth as far as I can tell at this
point. Compilers are getting better all the time.
I don't think there's any doubt that a good assembler programmer can,
given adequate time, outperform (or at least match) any compiler in
terms of code performance. Except perhaps in the minds of the
marketing departments of some compiler writers. ;-) That being said,
much of the complex instruction/register/functional unit/etc.
scheduling needed for many advanced CPUs is quite tedious and labor
intensive, and something that compilers can do reasonably well.
Unfortunately, (A) most assembler programmer's aren't that good, and
(B), those that are usually don't have near the time needed to dedicate
to the task except in relatively small portions of the application.
It's the old 90/10 rule: 90% of the CPU time is spent in 10% of the
code - any sane programmer will concentrate on making the 10% fast, and
getting the 90% done as quickly as possible while still being correct.
That often means that the 90%, when written in assembler, ends up being
fairly stylized and simplistic code, and not very optimized at all.
And *that* code will very, very often be beaten by a good compiler.
The 10% is another story, but even there it's quite common to start
with either simplistic code or an HLL implementation, so that things
*work*, and then optimize the bottlenecks (which are often surprising,
and don't make themselves obvious until you profile the code).
None of which is to say that there aren't clearly areas where compilers
get terribly lost. If the problem doesn't fit the HLL well, it's
unlikely that the resulting code will be very good. A good example is
a software implementation of DES (although even the best assembler
implementations of DES still suck - DES being designed to be
implemented in hardware, not software - but they're an order of
magnitude faster than say a good C version). Another example is the
double width integer multiplication available on many CPUs - if you're
doing a bignum library that's very handy, and totally inaccessible from
C.
.
- Follow-Ups:
- Re: Size of assembly programs...
- From: Tim Roberts
- Re: Size of assembly programs...
- From: robertwessel2@xxxxxxxxx
- Re: Size of assembly programs...
- References:
- Size of assembly programs...
- From: João Jerónimo
- Re: Size of assembly programs...
- From: Steven Nichols
- Re: Size of assembly programs...
- From: robertwessel2@xxxxxxxxx
- Size of assembly programs...
- Prev by Date: Having trouble posting?
- Next by Date: Re: Size of assembly programs...
- Previous by thread: Re: Size of assembly programs...
- Next by thread: Re: Size of assembly programs...
- Index(es):
Relevant Pages
|
|