From: cekim@ix.netcom.com
To: cekim@ix.netcom.com
Subject: Re: gcc vs Dec Unix c
Date: 1998/01/13 [thread overview]
Message-ID: <884563899.2019688456@dejanews.com> (raw)
In-Reply-To: y6vhvrhpem.fsf@tweedledumb.cygnus.com
Craig Burley <burley@tweedledumb.cygnus.com> wrote:
> cekim@ix.netcom.com writes:
>
> > peterm@landau.EECS.Berkeley.EDU (Peter Mardahl) wrote:
> > > I believe that x86 implements cos in HARDWARE, while Alpha does NOT.
> > > Therefore, if you're doing cos() quite a lot, the x86 will stomp
> > > alpha, and most other RISC.
> > I should have realized
> > such a gap could have only come from hard vs soft code. Never expected
> > such a thing in a RISC, of course.
>
> Whether an operation is done "in hardware" or "in software" has
> *little* relevance to its performance, in practice, and that's
> most certainly true in this particular case.
Well, *little* might be a *little* strong. I write VHDL to perform such
things and can without much effort achieve orders of magnitude more GOPS,
FLOPS and MIPS than software on any architecture, becasue I am not
encumbered by the load/store/register quirks of any architecture, much
less task switching and shared memory.
If intel had any sense at all(gaping hole jump in), they would have
implimented the fcos function such that would avoid all(most) of the
slowdowns that typically follow such repetative calculations. Thus,
software would have to work very hard to match this and may not ever be
able to given some inaccessable internal register space and so on.
Yes, hardware can be made to appear slow by poor software and creative
programming can always squeeze a little more out of slow hardware.
I was not __accusing__ the alpha of being slow, I happen to like it and
paid a great deal for its speed!! Just a recognition that it would be
very easy and not surprising if the lack of hardware, high level math
functions slowed individual operations down. Just hopefully not this
much!!!
read on...
> > One thing that threw me off of that trail is that the ".s" assembly dump
> > has "call cos" instead of the TASM or AT&T equivalent "FCOS". I assume
> > Gcc just replaces this with the appropriate code or macro according to
> > the host architecture.
>
> Nope. At least, I challenge you to prove your theory -- to
> my knowledge, gcc *can't*, and gas *doesn't*, replace "call cos"
> in assembly code with "fcos". However, gcc might (and g77 should,
Oops I meant to say "gas" there not GCC..
Ok here is where I get a little confused for lack of experience with the
underpinnings of GCC:
"call cos" is meaningless to AT&T-style asm unless there is a
corresponding "cos" subroutine in some header. That I know :)
I was assuming that one of two things must be done here: 1. "cos()"
exists in GCC lib as lookup/series/something. That macro calls this code
and is inserted by the pre-processing of gas. 2. On an architecture with
FCOS or similar support, one could invoke the use of the hardware code
through flags, as you mentioned.
So, you seem to indicate that, having not known about or used those
flags. I would have most likely compiled something using scenario #1
above?
I realize that GCC makes slow code on the alpha, but that(x86 was using
software) is a little rediculus. Given the the code did little else
other than impliment the cosine function. That would mean that the GCC
code was 6X slower on fp hardware that is 3X faster.
You would literaly have to insert wait states!!!
Is that going on? Tell me I will start hacking that out right away:)
> So, you can probably tweak-up the performance of your x86 program
> by ensuring theat "fcos" is used in-line, one way or the other.
****
x86 was already doing a bang up job, I want faster alpha!! :)
****
> Probably *the* biggest reason for the observations of bad
> performance of cos() on an Alpha that, otherwise, would be
> considered somewhat faster than a particular Pentium
> configuration, is simply that the *software* is slow. And
****
Given that I tested the same code with and without the cos function:
ie:
C=A*B;
AND then
C=A*cos(B); //for the purposes of demonstration
And the ALpha ran 65 minutes with cos and 4 sec without. I can safely
say that it is the cos function(*software*) which is the problem. So some
hypothetical math:
PPRO 200 w/cos =10 minutes -120 billion cycles
ALpha 533 w/cos =65 minutes -2.08 trillion cycles
Assuming niether using hardware FCOS:
Alpha is executing 17.33 cycles for each 1 PPRO cycle to perform the same
function (with more available register space!)
Some more hypothetical math:
I asked the loop to run 1 billion times so I have rougly 120 cycles per
loop given the number above for the PPRO.
Old TASM book reports that the 486 uses ~241 clocks to do FCOS. I hope
the P6 is a little more efficient, so it seems that there is precious
little time for software to jump in here and still get these execution
times!?!
> In my experience, somewhat encouraged by people who do actual
> *hardware* design (of CPUs), complicated hardware instructions
> often should be *avoided*, for maximum performance, in favor
> of a software solution employing the *exact same CPU*'s lower-level
> instructions (which they've had more time to thoroughly optimize)
Not surprising with a newer function, but this one has been around since
386/387.
Am I giving Intel too much credit here?
I am not surprised that the alpha is choking a little here, it has a long
way to go to catch up (in linux) to the amount of time that the x86 had
had for tweaking.
I am very surprised if the difference between the x86 software
implimentation is really that much faster than the alpha implimentation.
The alpha's speed(literaly clock speed) is leaves a 2X-3X window for bad
coding and RISCness yet the alpha is 6X slower in the end? Sounds fishy.
Oh well, I guess I either nede to use fotran or handcode my math
functions.
I am very curious now, I would like to hunt through the code and see if
there is an FCOS in there. I would hope there is.
/Mike
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
next prev parent reply other threads:[~1998-01-13 5:00 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-01-08 5:00 gcc vs Dec Unix c fonte
1998-01-09 5:00 ` Toon Moene
1998-01-09 5:00 ` Toon Moene
1998-01-09 5:00 ` Toon Moene
1998-01-09 5:00 ` Jaap Schellekens
1998-01-09 5:00 ` cekim
1998-01-09 5:00 ` Peter Mardahl
1998-01-09 5:00 ` Craig Burley
1998-01-10 5:00 ` cekim
1998-01-10 5:00 ` Craig Burley
1998-01-13 5:00 ` cekim [this message]
1998-01-13 5:00 ` Craig Burley
1998-01-13 5:00 ` [++] x86 FCOS (Was: Re: gcc vs Dec Unix c) Terje Mathisen
1998-01-13 5:00 ` Andy Glew
1998-01-14 5:00 ` Terje Mathisen
1998-01-13 5:00 ` gcc vs Dec Unix c James Van Buskirk
1998-01-14 5:00 ` brianh
1998-01-14 5:00 ` James Van Buskirk
1998-01-13 5:00 ` Yan-Song Chen
1998-01-13 5:00 ` Greg Lindahl
1998-01-15 5:00 ` Lupo LeBoucher
1998-01-15 5:00 ` Greg Lindahl
1998-01-13 5:00 ` Rob Komar
1998-01-14 5:00 ` bmeyer
1998-01-15 5:00 ` cekim
1998-01-14 5:00 ` Donald K.Sinclair
1998-01-14 5:00 ` Rob Komar
1998-01-16 5:00 ` Torbjorn Lindgren
1998-01-17 5:00 ` Rob Komar
1998-01-14 5:00 ` cekim
-- strict thread matches above, loose matches on Subject: below --
1998-01-13 5:00 Robert Harley
1998-01-14 5:00 ` cekim
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox