* gcc vs Dec Unix c
@ 1998-01-08 5:00 fonte
1998-01-09 5:00 ` Toon Moene
` (3 more replies)
0 siblings, 4 replies; 32+ messages in thread
From: fonte @ 1998-01-08 5:00 UTC (permalink / raw)
To: fonte
We have a Dec Alpha (EV56-LX 533 MHz w/ a NCR PCI Ultra SCSI
controller) running linux (RedHat 5.0). The floating point performance
is poor. From reading the news groups it seems the gcc compiled
executable is much slower then Dec's and the solution is to compile under
Dec Unix and then switch back to Linux. Is this the best solution (if we
don't want to covert our code to fortran)? Given only one system what is
the best way to do this? We have Dec Unix 4.0b but it will not install
on our system (the kernel does not like our scsi controller). For those
of you with similiar equipment out there what have you done i.e. what
works? What srm do we need (we have lx164.rom which allows us to at
least start the installation of DU 4.0b). We also have AlphaBios 5.60-3
which allows us to launch WinNT or Linux. Do we need DU 4.0c? And
finally if we do get DU up and running. Once we compile our code under
DU what libraries do we need to move over to linux, where to they need to
be installed, etc. I have not found a faq that deals with any of this.
Thanks,
Michael
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-08 5:00 gcc vs Dec Unix c fonte
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 ` Toon Moene
1998-01-09 5:00 ` Toon Moene
3 siblings, 1 reply; 32+ messages in thread
From: Jaap Schellekens @ 1998-01-09 5:00 UTC (permalink / raw)
fonte@pc2.nmrlab.hscsyr.edu wrote:
: We have a Dec Alpha (EV56-LX 533 MHz w/ a NCR PCI Ultra SCSI
: controller) running linux (RedHat 5.0). The floating point performance
: is poor.
Are you sure about that? libm performance is rather poor on Linux/Alpha
but straight floating point (Say LU decomposition) is rather comparable
to DU. Maybe singeling out the problem functions can help you more than
taking the (expensive) dive in DU.
cheers,
jaap
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-08 5:00 gcc vs Dec Unix c fonte
1998-01-09 5:00 ` Toon Moene
1998-01-09 5:00 ` Jaap Schellekens
@ 1998-01-09 5:00 ` Toon Moene
1998-01-09 5:00 ` Toon Moene
3 siblings, 0 replies; 32+ messages in thread
From: Toon Moene @ 1998-01-09 5:00 UTC (permalink / raw)
fonte@pc2.nmrlab.hscsyr.edu wrote:
> We have a Dec Alpha (EV56-LX 533 MHz w/ a NCR PCI Ultra SCSI
> controller) running linux (RedHat 5.0). The floating point performance
> is poor. From reading the news groups it seems the gcc compiled
> executable is much slower then Dec's and the solution is to compile under
> Dec Unix and then switch back to Linux. Is this the best solution (if we
> don't want to covert our code to fortran)?
OK, my advice would be to start (and stay) with Fortran, but you already knew
that :-)
No kiddin'. I'm willing to look into a (reasonably sized) piece of C code
where the problems lie. Of course, this assumes that you (via (g)prof) have
been able to spot the hot-spot in your application.
HTH,
--
Toon Moene (mailto:toon@moene.indiv.nluug.nl)
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Phone: +31 346 214290; Fax: +31 346 214286
g77 Support: mailto:fortran@gnu.org; NWP: http://www.knmi.nl/hirlam
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-08 5:00 gcc vs Dec Unix c fonte
@ 1998-01-09 5:00 ` Toon Moene
1998-01-09 5:00 ` Jaap Schellekens
` (2 subsequent siblings)
3 siblings, 0 replies; 32+ messages in thread
From: Toon Moene @ 1998-01-09 5:00 UTC (permalink / raw)
fonte@pc2.nmrlab.hscsyr.edu wrote:
> We have a Dec Alpha (EV56-LX 533 MHz w/ a NCR PCI Ultra SCSI
> controller) running linux (RedHat 5.0). The floating point performance
> is poor. From reading the news groups it seems the gcc compiled
> executable is much slower then Dec's and the solution is to compile under
> Dec Unix and then switch back to Linux. Is this the best solution (if we
> don't want to covert our code to fortran)?
One thing you could do is compile under DEC Unix (non-shared) and then run
the executable on Linux. If it's indeed significantly faster than the gcc
compiled one, it would be interesting to find out the cause.
Although I only have experience in upping the performance of g77 compiled
code, if you can condens the problematic code to a reasonably sized example,
I'm willing to look into it.
--
Toon Moene (mailto:toon@moene.indiv.nluug.nl)
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Phone: +31 346 214290; Fax: +31 346 214286
g77 Support: mailto:fortran@gnu.org; NWP: http://www.knmi.nl/hirlam
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-09 5:00 ` Jaap Schellekens
@ 1998-01-09 5:00 ` cekim
1998-01-09 5:00 ` Peter Mardahl
1998-01-14 5:00 ` Donald K.Sinclair
0 siblings, 2 replies; 32+ messages in thread
From: cekim @ 1998-01-09 5:00 UTC (permalink / raw)
To: cekim
In article <694nm1$74c$1@news2.xs4all.nl>,
schj@xs1.xs4all.nl (Jaap Schellekens) wrote:
>
> fonte@pc2.nmrlab.hscsyr.edu wrote:
> : We have a Dec Alpha (EV56-LX 533 MHz w/ a NCR PCI Ultra SCSI
> : controller) running linux (RedHat 5.0). The floating point performance
> : is poor.
>
> Are you sure about that? libm performance is rather poor on Linux/Alpha
> but straight floating point (Say LU decomposition) is rather comparable
> to DU. Maybe singeling out the problem functions can help you more than
> taking the (expensive) dive in DU.
>
> cheers,
>
> jaap
>
I can tell you that the cos() function is one that is particularly slow
in linux. I ran a loop using this very trivially 100 million times on an
164LX and a PPRO200. The PPRO with the -O flag took 1 min, 6 sec.
The alpha (533MHz LX)took 6 min,53 sec!!!!
Take the cos() out and run with the fp adds and multiplies in this loop
that keep things moving, and those number change to 3 sec for the alpha
and 4 sec for the PPRO.
SO!. there is obvisouly a problem with the cos() function!!!
Looking at the assembly output with the -O flag confirms that all of the
problem rests in the cos() function as the rest of the code is pretty
mundane and similar, save the additional loads and stores that come with
RISCdom.
I am running the stock RH4.2 on the alpha and 5.0 on the intel, so some
of this is my fault. I am looking into my options for better
optimization.
-Mike
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-08 5:00 gcc vs Dec Unix c fonte
` (2 preceding siblings ...)
1998-01-09 5:00 ` Toon Moene
@ 1998-01-09 5:00 ` Toon Moene
3 siblings, 0 replies; 32+ messages in thread
From: Toon Moene @ 1998-01-09 5:00 UTC (permalink / raw)
fonte@pc2.nmrlab.hscsyr.edu wrote:
> We have a Dec Alpha (EV56-LX 533 MHz w/ a NCR PCI Ultra SCSI
> controller) running linux (RedHat 5.0). The floating point performance
> is poor. From reading the news groups it seems the gcc compiled
> executable is much slower then Dec's and the solution is to compile under
> Dec Unix and then switch back to Linux. Is this the best solution (if we
> don't want to covert our code to fortran)?
Well, first of all, you should have started with Fortran, instead of cowering
out to it :-)
But, on the other hand, if you can trim the code that's causing the trouble
by perusing the -pg flag on compiles and (g)prof, I'm more than willing to
look into the generated code to see how it can be improved.
Disclaimer: Currently, I only know how to improve g77 generated code.
--
Toon Moene (mailto:toon@moene.indiv.nluug.nl)
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Phone: +31 346 214290; Fax: +31 346 214286
g77 Support: mailto:fortran@gnu.org; NWP: http://www.knmi.nl/hirlam
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
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-14 5:00 ` Donald K.Sinclair
1 sibling, 2 replies; 32+ messages in thread
From: Peter Mardahl @ 1998-01-09 5:00 UTC (permalink / raw)
In article <884364975.2133262340@dejanews.com>, <cekim@ix.netcom.com> wrote:
!In article <694nm1$74c$1@news2.xs4all.nl!,
! schj@xs1.xs4all.nl (Jaap Schellekens) wrote:
!
!I can tell you that the cos() function is one that is particularly slow
!in linux. I ran a loop using this very trivially 100 million times on an
!164LX and a PPRO200. The PPRO with the -O flag took 1 min, 6 sec.
!
!The alpha (533MHz LX)took 6 min,53 sec!!!!
!
!Take the cos() out and run with the fp adds and multiplies in this loop
!that keep things moving, and those number change to 3 sec for the alpha
!and 4 sec for the PPRO.
!
!SO!. there is obvisouly a problem with the cos() function!!!
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.
PeterM
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-09 5:00 ` Peter Mardahl
@ 1998-01-09 5:00 ` Craig Burley
1998-01-10 5:00 ` cekim
1 sibling, 0 replies; 32+ messages in thread
From: Craig Burley @ 1998-01-09 5:00 UTC (permalink / raw)
peterm@landau.EECS.Berkeley.EDU (Peter Mardahl) writes:
> 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.
The former is true. The latter does not follow. Go read up on
computer architecture (see comp.arch and related FAQs for
starting in-line references) to find out why. (There are *some*
operations that are best done "in hardware", by which you really
mean "via explicit instructions instead of using `ordinary'
instructions". I don't *think* cos() is one of these. An excellent
example of one would be bit-reverse, e.g. where bit_reverse(i), with
i being a 64-bit integer, returns a number j such that bit 0 of j
equals bit 63 of i, bit 1 of j equals bit 62 of i, and so on.
A less-certain example might be population count (returns the number
of `1' bits in i). These sorts of instructions benefit from
low-level specialized hardware especially compared to traditional
low-level instructions like add, shift, and test. CISC machines
were designed assuming there was a general advantage to "compressing"
the instruction stream that typically outweighed that of executing
a simpler instruction stream faster; RISC machines are designed
with the opposite general assumption, and the Alpha is a pretty
solid proof that it's true, for now, I believe. But cos() is
*not* a low-level operation.)
--
"Practice random senselessness and act kind of beautiful."
James Craig Burley, Software Craftsperson burley@gnu.org
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
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
1 sibling, 1 reply; 32+ messages in thread
From: cekim @ 1998-01-10 5:00 UTC (permalink / raw)
To: cekim
In article <695t9e$kft$1@agate.berkeley.edu>,
peterm@landau.EECS.Berkeley.EDU (Peter Mardahl) wrote:
>
> In article <884364975.2133262340@dejanews.com>, <cekim@ix.netcom.com> wrote:
> !In article <694nm1$74c$1@news2.xs4all.nl!,
> ! schj@xs1.xs4all.nl (Jaap Schellekens) wrote:
> !
> !I can tell you that the cos() function is one that is particularly slow
> !in linux. I ran a loop using this very trivially 100 million times on an
> !164LX and a PPRO200. The PPRO with the -O flag took 1 min, 6 sec.
> !
> !The alpha (533MHz LX)took 6 min,53 sec!!!!
> !
> !Take the cos() out and run with the fp adds and multiplies in this loop
> !that keep things moving, and those number change to 3 sec for the alpha
> !and 4 sec for the PPRO.
> !
> !SO!. there is obvisouly a problem with the cos() function!!!
>
> 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.
You are quite correct(FCOS in TASM), I completely forgot about
that(hardware implimentation in x86). I never worked too much with x86 fp
at assembly level and certainly not recently. 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.
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.
SO:
Oops!! and ouch!! (in terms of performace)
Live, learn, forget, relearn, die :)
I'll stop posting late at night to prevent such errors in the future.
/Mike
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-10 5:00 ` cekim
@ 1998-01-10 5:00 ` Craig Burley
1998-01-13 5:00 ` cekim
0 siblings, 1 reply; 32+ messages in thread
From: Craig Burley @ 1998-01-10 5:00 UTC (permalink / raw)
[I'm cross-posting this to comp.arch, since it's definitely got
architecture-relevant content.]
cekim@ix.netcom.com writes:
> In article <695t9e$kft$1@agate.berkeley.edu>,
> 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.
>
> You are quite correct(FCOS in TASM), I completely forgot about
> that(hardware implimentation in x86). I never worked too much with x86 fp
> at assembly level and certainly not recently. 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.
> 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,
since I wrote that code myself) recognize COS() in a program and,
when optimization (maybe -ffast-math too?) is suitably enabled, implement
that via "fcos" in assembler on the x86 architecture. (I'm pretty
sure it replaces SQRT() with "fsqrt", anyway.) If gas *does*
replace "call cos" with "fcos", let us know -- I'd love to know,
but have never noticed this while debugging (and disassembling)
x86 code. (Maybe gdb replaces "fcos" with "call cos"? ;-)
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.
(Another optimization Glen Clark asked me for about a year ago
is to have g77 recognize SIN(X) and COS(X) being needed around the
same "time" and thus use the Pentium's ability to deliver both more
quickly than one followed by the other...something I haven't
gotten around to yet, and would guess egcs would be more likely
to address in the near future than I.)
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
we already *know* GNU/Linux, g77, and gcc generate slow
code on Alphas, including calls to some libm.a procedures
that also are slow (and are fairly Linux-specific).
Don't assume the Alpha *hardware* is slow until you've used the
fastest *software* available on it. And, for FP performance,
including stuff like cos(), I believe that *usually* means
Digital UNIX, C, and Fortran. Even then, you might not be
looking at the *fastest* achievable on the Alpha -- or,
conceivably, on the Pentium, though I'd have a hard time
believing there was lots more performance headroom available
on a cos()-heavy benchmark by avoiding the Pentium's cos()
instruction, simply because of the Pentium being register-starved
(though, for all I know, it has register renaming, OOO, and
other clever stuff that mitigates this problem sufficiently
to make a *software* replacement for "fcos", that also is
substantially faster, a distinct possibility).
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).
Since I've actually both followed, and gone against, the advice
of hardware designers on such issues, I've learned that they
are, often, right, but not always. (E.g. on Prime machines
I actually *hugely* sped up some code by using the "deplored"
LDC/STC [LoaD Character/STore Character] instructions for
a printf()-type routine used throughout the system, called IOA$.
It's unlikely this could have been made any faster by avoiding
LDC/STC, but I don't recall how hard I tried. Though, the huge
speed-up was really obtained by rewriting the original Fortran
code into assembler. How huge a speed-up? Well, the PRIMOS
[rough] equivalent of GNU/Linux "ps aux", called "usage",
literally used *half* the CPU time, as measured by itself of
course, when my IOA$ was linked in. Given how much of "usage"
was devoted to calling PRIMOS kernel routines and such to collect,
and compute, data, only to print roughly a 25x80 screenful of
text via IOA$, that suggests at least one, possibly nearly two,
orders of magnitude improvement for IOA$ itself. But that was
mostly due to *not* using *other* hardware instructions, namely, not
using the fancier string instructions, which we generally knew
to avoid when we cared about performance.)
--
"Practice random senselessness and act kind of beautiful."
James Craig Burley, Software Craftsperson burley@gnu.org
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-10 5:00 ` Craig Burley
@ 1998-01-13 5:00 ` cekim
1998-01-13 5:00 ` Yan-Song Chen
` (3 more replies)
0 siblings, 4 replies; 32+ messages in thread
From: cekim @ 1998-01-13 5:00 UTC (permalink / raw)
To: cekim
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
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-13 5:00 ` cekim
@ 1998-01-13 5:00 ` Yan-Song Chen
1998-01-13 5:00 ` Greg Lindahl
1998-01-15 5:00 ` Lupo LeBoucher
1998-01-13 5:00 ` Rob Komar
` (2 subsequent siblings)
3 siblings, 2 replies; 32+ messages in thread
From: Yan-Song Chen @ 1998-01-13 5:00 UTC (permalink / raw)
cekim@ix.netcom.com wrote:
: 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
The math library performance of Alpha-Linux has been a serious problem for
a long time. It hurts Alpha-Linux's FP performance seriously. But it seems
nobody care or nobody able to enhance it. But it is not Alpha chip's fault,
Alpha CPU can run cos faster than x86 at SAME CLOCK RATE, I remember with
Digital's C compiler and math library, it takes about 100-120 cycles to do
cos,(If you don't care the last digit, there is another function can calculate
cos in about 60-70 cycles). But the math function in gcc library has
very poor performance, I remeber it takes more than 1000 cycles to do cos
before.
1)x86 use floating point instruction FCOS to calculate cos function, it is
implemented used micro code. Alpha, as a RISC cpu, implement cos as a library
function. But it doesn't mean that Alpha does cos slower than x86. With
good math library implementation, it is more efficient than a single FCOS
instruction.
2)It is Linux's libm slow down the Alpha's FP performance, not the Alpha
CPU itself.
3)I think we have two methods to improve Alpha's CPU performance:
a) somebody may be able to improve linux libm.a floating point special
function's performance.
b) Maybe we can push Digital to port it is math library to linux so we can
get a commercial version of math library.
Alpha is intrinsicly faster than x86, but you have to know how to get
its best performance.
--
yansong chen
--
YChen@uh.edu
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-13 5:00 ` cekim
1998-01-13 5:00 ` Yan-Song Chen
@ 1998-01-13 5:00 ` Rob Komar
1998-01-13 5:00 ` Craig Burley
1998-01-14 5:00 ` gcc vs Dec Unix c bmeyer
3 siblings, 0 replies; 32+ messages in thread
From: Rob Komar @ 1998-01-13 5:00 UTC (permalink / raw)
cekim@ix.netcom.com wrote:
[snip]
: 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.
:
See libc/sysdeps/linux/i386/math/cos.S in the libc/libm source tree.
FCOS is invoked.
--
Robert Komar Physics Dept., Univ. of British Columbia, Canada
(stationed at the Sudbury Neutrino Observatory)
My mail address can be got from the following Unix command:
echo 'robkviaphysicsZubcZca' | tr 'Z' '.' | sed 's/via/@/'
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-13 5:00 ` cekim
1998-01-13 5:00 ` Yan-Song Chen
1998-01-13 5:00 ` Rob Komar
@ 1998-01-13 5:00 ` Craig Burley
1998-01-13 5:00 ` James Van Buskirk
1998-01-13 5:00 ` [++] x86 FCOS (Was: Re: gcc vs Dec Unix c) Terje Mathisen
1998-01-14 5:00 ` gcc vs Dec Unix c bmeyer
3 siblings, 2 replies; 32+ messages in thread
From: Craig Burley @ 1998-01-13 5:00 UTC (permalink / raw)
cekim@ix.netcom.com writes:
> 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.
I stand by my statement -- the context was *general-purpose
processor* designs, not including special-purpose hardware.
In general-purpose processor designs, you often have to design
your hardware while still encumbered by the "quirks" to which you
refer.
Of course, if you can use clever hardware to reduce a lengthy
operation to one that is sufficiently short in all cases, you
get to skip lots of stuff, including task switching, interrupt
worries, and so on.
FCOS would appear to be a candidate for this sort of thing,
but I don't believe Intel has quite accomplished that in any
of its CPUs.
In other words, I believe Intel's FCOS implementations all are
basically just like internally microcoded operations. But that's
just speculation on my part.
> 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.
That's not the entire issue.
Let's assume FCOS, implemented using the "vanilla" instruction
set that *is* hard-wired, in the sense that this set is basically
"single-cycle" for some definition of "cycle" that is the same
length for two processors. (Usually that includes add, sub, and,
or, maybe shifts, tests, branches, and so on.)
Now, let's assume one of these processors has no FCOS, so it
*must* be implemented in software. Let's say it takes 50 cycles
in the average case.
The other processor has an FCOS implemented in hardware, and
let's say it takes 20 cycles in the average case.
Is the FCOS-laden processor faster at doing lots of FCOS
operations?
Not necessarily. "Assuming all else is the same" is basically
never the case in real processor design.
So, the *first* processor has used the design time and die space
to implement parallel functional units, additional registers,
pipelining, register renaming, whatever, while the second processor
devotes those resources solely to its FCOS implementation.
The effect of this is that the first processor still takes 50
cycles to do an FCOS, but to do two FCOS operations in a row
it takes 60 cycles, to do three it takes 70 cycles, and so on.
The result is that one thousand FCOS operations takes ~10000
cycles on the first processor.
Meanwhile, the second processor's dedicated FCOS hardware is
not parallelized, not pipelined, etc., so for those same thousand
operations, it takes ~20000 cycles -- in other words, the
*hardware* implementation is twice as slow!
Agreed, the first processor can probably achieve its speeds only
when the software is coded properly, but that's why God created
compiler writers. ("And he saw that everything was very good.
And God brought forth compiler users. And there were many bugs
found upon the lands." ;-)
This scenario reflects the realities of the CISC/supercomputer/VLIW/RISC
world somewhat, but ignores, for the purpose of illustration, other
factors, such as the fact that the first processor *probably*
can tolerate more increase of clock rate (faster cycle time) due
to having a less-complex instruction decode (no FCOS probably means
no other "engage weird hardware and wait for it to finish"
operations).
> 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!!!
I don't disagree with any of that.
The thing I disagreed with was the flat-out statement that, because
Pentium implemented FCOS in hardware and Alpha did not, therefore
Pentium would *always* beat Alpha in FCOS-heavy benchmarks.
As should be clear by now, thanks to Robert Harley's post, not
only was I right, but the reality is that the reason you see
faster Pentium performance is that you don't mind getting wrong
answers.
Modify your Alpha's implementation of FCOS in a way that allows
the returning of wrong answers, and I bet it'll go *much* faster
than Pentium, for sufficiently interesting definitions of "wrong".
;-)
> 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, that does make more sense.
> 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 don't think gcc usually uses native assembler format unless
it has to (e.g. was configured that way). One of the central
ideas of the GNU project is to minimize (instead of, as
hardware vendors like to do to lock-in their customers, maximize)
differences between machines and operating systems. So, gas
offers a fairly "regular" syntax, presumably without getting
too pedantic about it, across all the processors it supports,
so that most vanilla instructions look about the same on all
CPUs. (E.g. I suspect "add x,y,z" in gas always means
`z := x + y', instead of meaning that on some CPUs and meaning
`x := y + z' on others.) Note that I've hardly looked at gas
at all, myself, except by reading gcc output, and I pretty much
pick up syntax by context, regardless of the machine I'm
debugging on at the time. (That's what learning assembly coding
at age 12 can do for you. ;-)
> 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.
I don't believe gas does #2. "call cos" is, AFAIK, a pretty universal
way to tell the assembler to assemble a call to the procedure named
"cos", *not* an opportunity to insert some in-line assembler code via
some kind of macro facility. I think you're saying the same thing
via #1, i.e. I believe you're right, but want to be specific.
You can verify this for yourself by disassembling the resulting
executable. Have you tried this?
> 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?
Yup, if I'm reading your statement right. I don't think this is
a "pre-processing" phase of gas any more than assembling a
vanilla "ld" instruction uses a pre-processing phase.
> 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!!!
No, not really. All you need is poorly implemented code, which gcc
*has*, in its history, as many compilers have, been quite good at
producing for the Alpha. Teaching compilers to produce code
that is properly optimized for the target processor is fun, but
takes sufficient expertise that those of us who know how to do
it typically get paid so much for so little work that we have time
to engage in debates like this. ;-)
> Is that going on? Tell me I will start hacking that out right away:)
Please, if you speed up any of the GNU/Linux software (libm, libc, etc.)
to run faster on Alpha, tell us all about it, donate the source
back, etc.! This sort of thing has been a *long-known* issue
(over a year that I've known about problems with things like
Linux libm and, IIRC, BLAS on Alpha). I haven't really kept
track of to the extent of improvements since about a year ago
or so, but I'm sure there's always more progress to be made.
> > 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!! :)
Yup, I just felt it was fair to point out that the x86 could perhaps
be made to run even faster on your benchmark, though probably
only a little bit. (I suspect the FCOS overlaps the "return"
instruction, and maybe even the subsequent "call" instruction,
depending on how the benchmark is coded.)
And, I *suspect* the Pentium Pro (or PII?), the one that returns
wrong results for your benchmark, could be modified to return
correct results without much of a hit in benchmark time, but
I'm not sure if that's true. I've read about the inaccurate
PI approximation in the Pentia on comp.arch, and don't
recall whether t's simply a matter of a bogus approximation,
or hardware assuming it can use a lower-precision approximation
than is necessary to compute correct results. The latter might
mean using a higher-precision one would require a more time-consuming
modulo operation (in hardware), thus slowing down FCOS for
at least operands outside the minimum domain, perhaps for
all operands.
> > 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!?!
Microcode can jump in where software does not. And, either way,
when parallel instruction units are available and usable, it
can make software *appear* to "disappear".
For example, what do you think is the difference in execution
time between the following chunks of code on a Sun UltraSPARC-1:
addcc %i0,%i1,%o0 /* add and produce condition codes */
addccc %i2,%o0,%o0 /* add with condition codes, etc. */
addccc %i3,%o0,%o0
addc %i4,%o0,%o0
sll %g1,1,%g1 /* shift left 1 bit */
addcc %i0,%i1,%o0 /* add and produce condition codes */
or %g1,12,%g1
addccc %i2,%o0,%o0 /* add with condition codes, etc. */
and %g1,255,%g1
addccc %i3,%o0,%o0
xor %g1,1023,%g1
addc %i4,%o0,%o0
Assuming %i0, %i1, and %g1 are all either written, or not, in the
previous cycle, the answer is "there is no difference", even though
more work is being done by the second code sequence...but this *would*
be about twice as slow:
sll %g1,1,%g1 /* shift left 1 bit */
or %g1,12,%g1
and %g1,255,%g1
xor %g1,1023,%g1
addcc %i0,%i1,%o0 /* add and produce condition codes */
addccc %i2,%o0,%o0 /* add with condition codes, etc. */
addccc %i3,%o0,%o0
addc %i4,%o0,%o0
Even though the above, third, sequence accomplishes exactly
the same thing as the previous (second), it takes about
twice as long to execute!
(Apologies if I'm too out-of-practice on Ultras to have gotten this
exactly right.)
The reason is that the second, interleaved example makes use of
the *two* independent ALUs in the UltraSPARC-1. Both can perform
most "vanilla" ALU ops (add, sub, or, and), one can also perform
shifts, the other can also perform condition-code generation and
incorporation. (Dunno whether the instruction pairs have to be
aligned properly to make this really work...haven't investigated
that yet, as my Ultra-1 remains off-line, awaiting my investing
time to install Solaris, get it up on my LAN, install GNU
software, etc.)
So, the Pentium might well be performing FCOS in parallel with
some of the independent instructions in your code stream,
including possibly call, return, load, and other miscellaneous
instructions, which could *appear* to make it take much less
time than it does.
And *still* the Alpha could, with appropriate software, perform
the benchmark faster, assuming the same results were permissible!
Maybe not, but the Alpha is *not* out of the running *simply*
because Pentia implement FCOS in hardware while Alpha does not.
As I said, that distinction -- hardware vs. software, which is
*really* instruction-set vs. requires-software-implementation
(since any x86 chip could just trap on FCOS and leave it to
a software implementation as well) -- has little relevance
in the overall picture of determining performance, even for
*one* benchmark.
(In fact, this is a good question to ask yourself. The SPARCv9
instruction set defines POPC, a population-count instruction,
which returns the number of bits set in a 64-bit value. Let's
say the Alpha does not. Now, which do you think runs faster,
code making heavy use of POPC on an Ultra-1, or *longer*
equivalent code on the Alpha that does the same operation
using low-level instructions? Answer: the Alpha will likely
to be faster. Even though POPC is implemented "in hardware" on
the Ultra-1. Why? Because, although POPC *could* be
implemented in hardware probably as less than a 3-cycle
operation, the Ultra-1 implements it as "trap to OS for
instruction emulation". ;-)
This is all in the statistical sense, of course. Once you
truly *know* how the Pentium and Alpha do their respective
jobs, it might be 100% clear that lack of hardware assist
cripples Alpha (not the case I believe, but I'm just saying...).
So, *speculating* that the Pentium does FCOS faster simply
because it has an instruction to perform it is wrong.
However, *knowing* that's the case is okay, if you truly know it.
> > 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?
Perhaps. They won't have more, and perhaps have less, incentive
to make FCOS fast, pipelined, and parallel for their audience than
Digital does for its Alpha audience, but that's just speculation on
my part, based on my observation that Alpha is intended for
high-performance scientific markets that Intel doesn't really
target (at least not with it's x86 line).
> 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.
That, and, I think there's more room for tweaking (over and above
"vanila" code generation and traditional optimizations) on the
Alpha, especially 21164 and, who knows, maybe 21264, chips, than
there is for x86.
Put another way: it's not so much that Alphas have more registers
than Pentiums. Maybe they don't. What they *do* have is more
*programmer-visible* registers (especially of the general-purpose
variety). This tends to expose more of the internal workings
and timings of the processor to software, thus putting more
burden on the software author (compiler or human coder) to
properly schedule instructions and allocate variables to
registers. One still needs to properly schedule instructions
different ways on different x86 machines, but there's less
register "magic" to play on them, because there are fewer
registers that are *visible*.
The way I'm most familiar with this impacting code generation
is the ability to interleave independent threads of code.
Ultra-1s and Alphas permit that in many ways I assume Pentia
do not (by "permit" I really mean "make worthwhile for
generating faster code ;-). The old 128-bit VLIW machine
I worked in *really* permitted that, and optimizing scalar
code both by hand and within the Fortran compiler the
company built for it was something of a specialty of mine.
(The real brains behind *that* operation had already pretty
much squeezed out all of the loop performance, though I still
helped out some with that.)
> 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.
Smells that way to me too. Dunno if Robert Harley's post
is the last word on this topic; I'd like to believe that,
even for this out-of-minimal-domain values benchmark, it
*could* be more efficiently handled by the GNU/Linux/Alpha
cos() routines, but haven't made time to look at it myself yet.
(And, I don't have the same degree of confidence I have with
less-mathematical code. When it comes to low-level optimizations,
I'm more of a bit-banger than an algorithm-fiddler.)
> Oh well, I guess I either nede to use fotran or handcode my math
> functions.
GNU fortran (g77) might not help you much, but Digital Fortran
should...perhaps so if it offers a version of COS() that returns
Pentium's (wrong) answers. ;-)
> 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.
Yup, use "stepi" in gdb (on the Pentium) and see if you find it
shortly after "call cos". Let us know.
--
"Practice random senselessness and act kind of beautiful."
James Craig Burley, Software Craftsperson burley@gnu.org
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-13 5:00 ` Yan-Song Chen
@ 1998-01-13 5:00 ` Greg Lindahl
1998-01-15 5:00 ` Lupo LeBoucher
1 sibling, 0 replies; 32+ messages in thread
From: Greg Lindahl @ 1998-01-13 5:00 UTC (permalink / raw)
phys6k@Menudo.UH.EDU (Yan-Song Chen) writes:
> b) Maybe we can push Digital to port it is math library to linux so we can
> get a commercial version of math library.
This is a 2-step process -- the library requires Digital C to compile.
-- g
^ permalink raw reply [flat|nested] 32+ messages in thread
* [++] x86 FCOS (Was: Re: gcc vs Dec Unix c)
1998-01-13 5:00 ` Craig Burley
1998-01-13 5:00 ` James Van Buskirk
@ 1998-01-13 5:00 ` Terje Mathisen
1998-01-13 5:00 ` Andy Glew
1 sibling, 1 reply; 32+ messages in thread
From: Terje Mathisen @ 1998-01-13 5:00 UTC (permalink / raw)
(This was a very long post, I'll just snip & comment on a few items:)
Craig Burley wrote:
> cekim@ix.netcom.com writes:
[snip]
> Of course, if you can use clever hardware to reduce a lengthy
> operation to one that is sufficiently short in all cases, you
> get to skip lots of stuff, including task switching, interrupt
> worries, and so on.
>
> FCOS would appear to be a candidate for this sort of thing,
> but I don't believe Intel has quite accomplished that in any
> of its CPUs.
>
> In other words, I believe Intel's FCOS implementations all are
> basically just like internally microcoded operations. But that's
> just speculation on my part.
From what I learned during the FDIV/FPATAN workaround task 3 years ago,
I'd have to say you're right:
All the trancendental (or at least the trigonometric) function on
Pentium+ fpus use a combination of table lookups and polynomial or
rational approximations, implemented with microcode.
The main advantages of microcode vs. asm seems to be that the microcode
has direct access to the 2-3 guard bits, as well as the capability to
run some algorithms at non-standard (reduced) precision.
It might also be the case that microcode can achieve slightly better
latency on some operations, maybe by bypassing the
normalization/rounding step after some internal operations.
> > 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.
This is right, in that it would be _very_ hard to achieve full 80
(1+15+64) bit accuracy using asm code.
> Let's assume FCOS, implemented using the "vanilla" instruction
> set that *is* hard-wired, in the sense that this set is basically
> "single-cycle" for some definition of "cycle" that is the same
> length for two processors. (Usually that includes add, sub, and,
> or, maybe shifts, tests, branches, and so on.)
[snipped discussion of why software implementations can be faster than
microcode, due to much better latency hiding, when doing many FCOS
operations in parallel.]
> The result is that one thousand FCOS operations takes ~10000
> cycles on the first processor.
>
> Meanwhile, the second processor's dedicated FCOS hardware is
> not parallelized, not pipelined, etc., so for those same thousand
> operations, it takes ~20000 cycles -- in other words, the
> *hardware* implementation is twice as slow!
This is of course valid.
However, If I ever had to do 10K FCOS operations in parallel, I would
definitely look into a much more agressive table-driven algorithm:
By definition, if FCOS is so critical for my executiuon time, I would
gladly pay the penalty of filling both data and code caches with
FCOS-specific stuff.
Assuming a lookup table with 1K entries (10-11 bits), it should be
possible to get double-accurate results with just a couple of polynomial
operations.
> > 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!!!
>
> I don't disagree with any of that.
>
> The thing I disagreed with was the flat-out statement that, because
> Pentium implemented FCOS in hardware and Alpha did not, therefore
> Pentium would *always* beat Alpha in FCOS-heavy benchmarks.
>
> As should be clear by now, thanks to Robert Harley's post, not
> only was I right, but the reality is that the reason you see
> faster Pentium performance is that you don't mind getting wrong
> answers.
>
> Modify your Alpha's implementation of FCOS in a way that allows
> the returning of wrong answers, and I bet it'll go *much* faster
> than Pentium, for sufficiently interesting definitions of "wrong".
The interesting (to me) definition here is: What happens if the input
value is outside N*PI, for N larger than 1 or 2.
Intel have documented the value of PI they use in the FPU to do range
reduction, it has about 66-67 significant bits.
Wouldn't it still be possible to write code which checks the input value
first?
float pi_array[];
double mycos(double x)
{
if (( double px = fabs(x)) > COS_ACCURACY_LIMIT)) {
double n = floor(px * (1.0 / 3.141592653589793238462643383279));
/* Subtract N times a multi-precision value for PI */
for (i = 0; i < PI_ARRAY_SIZE; i++) {
px -= pi_array[i] * n; // Exact if enough guard bits!
}
if (x < 0) px = -px;
x = px;
}
return FCOS(x);
}
I can see that is is easy to extend the range of accuracy by quite a
bit, i.e. to exponents up to about 20-30, but to get all the way to
2^1024, the maximum possible input value, would require quite a lot more
work!
Terje
> So, the Pentium might well be performing FCOS in parallel with
> some of the independent instructions in your code stream,
> including possibly call, return, load, and other miscellaneous
> instructions, which could *appear* to make it take much less
> time than it does.
On a PPro, using call/ret in a simple loop like the one aboe, wouldn't
really matter, since (allmost?) all fp operations allow the integer ops
to run simultaneously, so for the code above, the less than 10 cycles
used for a subroutine call would still be completely hidden by the FCOS
execution time.
> This is all in the statistical sense, of course. Once you
> truly *know* how the Pentium and Alpha do their respective
> jobs, it might be 100% clear that lack of hardware assist
> cripples Alpha (not the case I believe, but I'm just saying...).
>
> So, *speculating* that the Pentium does FCOS faster simply
> because it has an instruction to perform it is wrong.
>
> However, *knowing* that's the case is okay, if you truly know it.
I do believe that an Alpha cannot beat FCOS, assuming both that the
input values are inrange, and you need long double (extended) precision.
However, code like this is very rare indeed. :-)
> Perhaps. They won't have more, and perhaps have less, incentive
> to make FCOS fast, pipelined, and parallel for their audience than
> Digital does for its Alpha audience, but that's just speculation on
> my part, based on my observation that Alpha is intended for
> high-performance scientific markets that Intel doesn't really
> target (at least not with it's x86 line).
That might be so, but I am still impressed by the job Peter Tang did on
the Pentium trancendentals: Getting less than 1 ulp errors for all
in-range inputs is _hard_.
> The way I'm most familiar with this impacting code generation
> is the ability to interleave independent threads of code.
> Ultra-1s and Alphas permit that in many ways I assume Pentia
> do not (by "permit" I really mean "make worthwhile for
> generating faster code ;-).
Actually, the Pentium might be the cpu where hand-interleaving (i.e.
optimized asm) can gain you the most performance. PentiumPro/PII is a
different matter, since the OO core handles at least a good chunk of the
bad compiler-generated code out there.
Terje
--
- <Terje.Mathisen@hda.hydro.com>
Using self-discipline, see http://www.eiffel.com/discipline
"almost all programming can be viewed as an exercise in caching"
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-13 5:00 ` Craig Burley
@ 1998-01-13 5:00 ` James Van Buskirk
1998-01-14 5:00 ` brianh
1998-01-13 5:00 ` [++] x86 FCOS (Was: Re: gcc vs Dec Unix c) Terje Mathisen
1 sibling, 1 reply; 32+ messages in thread
From: James Van Buskirk @ 1998-01-13 5:00 UTC (permalink / raw)
Craig Burley wrote in message ...
>As should be clear by now, thanks to Robert Harley's post, not
>only was I right, but the reality is that the reason you see
>faster Pentium performance is that you don't mind getting wrong
>answers.
The Pentium answers look wrong only if the ideal input to the
FCOS instruction is k*2**n, where k & n are integers and
|k| < 2**53. The alpha answers could be generated possibly by
an algorithm that normalizes the (unbiased) exponent to 0 (or
perhaps less) if it is initially greater than this, calculates
the cosine of the resulting normalized number, then uses angle
doubling (cos(2**(n+1)*theta) = 2*cos(2**n*theta)-1) to make up
for the exponent modification in the first step. As R. Harley
points out, such an approach can give you accurate results for
numbers of the form k*2**n, but you pay big time for this
'accuracy' even when your input isn't of this form. Perhaps
the C standard requires this, though...
It seems like it wouldn't be a bad idea to switch to an approach
that reduced the input modulo pi when the exponent gets big
enough; if the user required exact results for numbers of the
form k*2**n, she could use trig identities in her program
instead of burdening the rest of the library users with her
otherwise unwarranted overhead. Of course if the input is > 2**53,
in absolute value a reasonable output would be a NaN.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [++] x86 FCOS (Was: Re: gcc vs Dec Unix c)
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
0 siblings, 1 reply; 32+ messages in thread
From: Andy Glew @ 1998-01-13 5:00 UTC (permalink / raw)
To: Terje Mathisen
> On a PPro, using call/ret in a simple loop like the one aboe, wouldn't
> really matter, since (allmost?) all fp operations allow the integer ops
> to run simultaneously, so for the code above, the less than 10 cycles
> used for a subroutine call would still be completely hidden by the FCOS
> execution time.
Sorry: the PPro and Pentium II allow FADD, FMUL, FDIV, FSQRT to run
simultaneously with integer operations, since these are done in hardware,
i.e. via dedicated function units and pipelines, with special sequencers
and state machines for FDIV and FSQRT.
However, the transcendentals are done in long microcode sequences,
that essentially take over the entire micromachine. Thus, except for overlap
at the beginning and end, the transcendentals are not done simultaneously with integer
operations. (Except for overlap with already started long lasting operations
like cache misses, divides, etc. - the pipeline isn't flushed (unless the microcode has
a branch misprediction).)
If transcendentals were considered more important, they could be done in hardware,
with dedicated sequencers (probably sharing access to the multiplier and divider logic,
although that shared access would be painful).
There are, of course, hardware assists to make the microcode run faster.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
@ 1998-01-13 5:00 Robert Harley
1998-01-14 5:00 ` cekim
0 siblings, 1 reply; 32+ messages in thread
From: Robert Harley @ 1998-01-13 5:00 UTC (permalink / raw)
cekim@ix.netcom.com writes:
>PPRO 200 w/cos =10 minutes -120 billion cycles
>ALpha 533 w/cos =65 minutes -2.08 trillion cycles
I think everyone is missing the point here.
You called cos() with some very large arguments.
With small arguments the Alpha's software is twice as fast as the
PPro's hardware.
With large arguments, the Alpha slows down to a sixth the speed of the
PPro. The reason is simple: the PPro gives wrong answers. Intel
didn't bother to reduce mod pi properly.
Example:
cos(1.0) a million times:
answer time error
Alpha 0.54030230586813976501 0.344 4.76 E-17
PPro 0.54030230586813976501 0.620 4.76 E-17
cos(123456789.0) a million times:
answer time error
Alpha -0.16283121219902166321 3.925 -1.00 E-17
PPro -0.16283121220058985323 0.700 -1.57 E-12
Note that the error on the PPro is 100000 times too big for double
precision.
Bye,
Rob.
PS: Note that there is lots of room to optimise the software cos() e.g.,
I doubled the speed in one application. The PPro's hardware
obviously cannot be optimised by the user.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-13 5:00 ` James Van Buskirk
@ 1998-01-14 5:00 ` brianh
1998-01-14 5:00 ` James Van Buskirk
0 siblings, 1 reply; 32+ messages in thread
From: brianh @ 1998-01-14 5:00 UTC (permalink / raw)
In article <69hce6$8je@sjx-ixn6.ix.netcom.com>,
James Van Buskirk <torsop@ix.netcom.com> wrote:
>
>FCOS instruction is k*2**n, where k & n are integers and
>|k| < 2**53.
Stupid question: can't all IEEE floating point numbers be treated as
being in this form? Or, actually, with a little modification- if
the floating point number is m * 2**e, where 1 <= m < 2, and e is a
small integer, then couldn't you set k = m * 2**p and n = e-p, where
p is the precision of the floating point number (53 in the case of IEEE
doubles)?
Or am I missing something obvious?
I don't speak for Bit 3.
Brian
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-14 5:00 ` brianh
@ 1998-01-14 5:00 ` James Van Buskirk
0 siblings, 0 replies; 32+ messages in thread
From: James Van Buskirk @ 1998-01-14 5:00 UTC (permalink / raw)
brianh@bit3.com wrote in message ...
>In article <69hce6$8je@sjx-ixn6.ix.netcom.com>,
>James Van Buskirk <torsop@ix.netcom.com> wrote:
>>
>
>>FCOS instruction is k*2**n, where k & n are integers and
>>|k| < 2**53.
>
>Stupid question: can't all IEEE floating point numbers be treated as
>being in this form? Or, actually, with a little modification- if
>the floating point number is m * 2**e, where 1 <= m < 2, and e is a
>small integer, then couldn't you set k = m * 2**p and n = e-p, where
>p is the precision of the floating point number (53 in the case of IEEE
>doubles)?
>
>Or am I missing something obvious?
Yes, all IEEE 754 double precision floating point numbers are in this
form, but the point that I was trying to make (with the word 'ideal')
was that not all numbers are of this form. Thus when your program
calls for cos(x), the number x cannot be represented, in general,
with perfect accuracy as an IEEE 754 double precision floating
point number. For example, when your program calculates
cos(1234567890.d0), the number you really want the cosine of could
be anywhere from 1234567890-2^(-23) to 1234567890+2^(-23). In an
ordinary program one should not, in my opinion, be dismayed if the
cosine of any number in this range is returned. In fact Intel uses
an internal 66-bit value of pi when it reduces to the range of
validity for its minmax polynomial, so the range goes down to
1234567890-2^(-36) to 1234567890+2^(-36), and the value returned
e.g. by LF90 corresponds to an input in that range. Digital's
alpha compilers (e.g. DVF90 Pro) seem to interpret the input as
exact and produce the double precision cosine of the 'exact' input
to double precision accuracy (confirmed by comparing 100 digit
Mathematica output.) In many contexts, the extra accuracy is
illusory as the input in the above case would have to be known to 30
bits more accuracy for the last bit of the output to have any
meaning. Curiously, DVF90 Pro gets the same results with both
the 'fast' and the 'accurate' math libraries, although the 'accurate'
library takes about twice as long to get there. In cases where the
IEEE 754 representation of the input is exact, Digital is doing
much better than Intel here but I think that those cases are
relatively rare.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-14 5:00 ` Donald K.Sinclair
@ 1998-01-14 5:00 ` cekim
1998-01-14 5:00 ` Rob Komar
1 sibling, 0 replies; 32+ messages in thread
From: cekim @ 1998-01-14 5:00 UTC (permalink / raw)
To: cekim
In article <69h2g1$s4t@milo.mcs.anl.gov>,
Donald K.Sinclair wrote:
> I decided to try your test on my 600Mhz Alpha PC164LX in fortran rather than
> C. I performed the test in both 32 and 64 bit precision. The 64 bit version of
> the code I ran (costest.f) was:
> real*8 x,y
> x=1.2345d0
> y=0.567d0
> do 1 n=1,100000000
> x=x+0.001d0
> y=y+dcos(x)
> The egcs/g77 code took 50.7 seconds to execute in 32bit arithmetic and 51.4
> seconds in 64 bit arithmetic (does this mean that their 32bit cos routine
> actually uses the 64bit routine?).
> Perhaps the suggestion made by others that fortran is the language of choice
> is correct.
just for kicks (533LX):
#include
#include
main()
{
long i=0;
float X,Y;
int min=0,sec=0;
X=1.9088848;
Y=.354256;
time_t tyme1,tyme2;
printf("\nSTART\n");
time(&tyme1);
for(i=0;i<100000000;i++){
X=X+0.00464;
Y=(Y)+cos(X);
}
time(&tyme2);
printf("X=%f Y=%f",X,Y);
printf("\nTotal loops %d",i);
min=(tyme2-tyme1)/60; //Why waste time figuring out a more elegant way??
sec=(tyme2-tyme1)-(min*60);
printf("\n%d Min, %d sec\n",min,sec);
printf("\nDone\n");
}
***********
START
X=131072.000000 Y=1048576.000000
Total loops 100000000
1 Min, 0 sec
DONE
***********
Obviously the above is not meant to be the pinnacle of
pretty C code, nore am I concerned that I chopped off
the fractional portion of the answer in the printout. :)
When competing against an intel chip(the original
intention of this bench) accuracy is not the most
important thing ;)
So, with ECGS/G77 we have a marginal improvement when
using 1:1(at least close to 1:1) code in Fortran. How
much of that is 533 vs 600MHz?? I am guessing something
less than 10%, but that puts it very close.
Note that we have large numbers here again with respect
to the exponent of the floating point number. It would
seem that the performance hit of keeping track of your
2*pi's and keeping the numbers in small radians is well
worth it with long repetative use of the cos()
The microway compiler does show some very interesting
results in Fortran :)
/Mike
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-13 5:00 ` cekim
` (2 preceding siblings ...)
1998-01-13 5:00 ` Craig Burley
@ 1998-01-14 5:00 ` bmeyer
1998-01-15 5:00 ` cekim
3 siblings, 1 reply; 32+ messages in thread
From: bmeyer @ 1998-01-14 5:00 UTC (permalink / raw)
cekim@ix.netcom.com writes:
>PPRO 200 w/cos =10 minutes -120 billion cycles
>ALpha 533 w/cos =65 minutes -2.08 trillion cycles
[...]
>I asked the loop to run 1 billion times so I have rougly [2000 ALPHA] cycles
>per loop given the number above for the PPRO.
I find this result confusing. I just tried the following program on
my ALPHA:
==========
#include <stdio.h>
#include <math.h>
int main(int argc, char** argv)
{
double a,b,c;
long count;
a=2; b=3; c=4;
for (count=0;count<10000000;count++) {
a=cos(a)/b+c/a;
}
printf("Answer is %f\n",a);
}
==========
Once with and once without the cos (i.e. "a=a/b+c/a;"). The difference
in exacution time was about 4.5 seconds on my 433MHz ALPHA, or roughly
2 billion cycles. However, the ALPHA calculated TEN million cosines
in that time, for only 200 (two HUNDRED) cycles per cosine.
Is it possible you timed your stuff using "time", and have an old and
broken version of time? Or that you may have fallen victim to the
1:10 difference in HZ between linux/Intel and linux/ALPHA?
>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.
There certainly is one if I compile the above on Intel, using gcc -O6.
Bernie
--
============================================================================
"It's a magical world, Hobbes ol' buddy...
...let's go exploring"
Calvin's final words, on December 31st, 1995
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-09 5:00 ` cekim
1998-01-09 5:00 ` Peter Mardahl
@ 1998-01-14 5:00 ` Donald K.Sinclair
1998-01-14 5:00 ` cekim
1998-01-14 5:00 ` Rob Komar
1 sibling, 2 replies; 32+ messages in thread
From: Donald K.Sinclair @ 1998-01-14 5:00 UTC (permalink / raw)
I decided to try your test on my 600Mhz Alpha PC164LX in fortran rather than
C. I performed the test in both 32 and 64 bit precision. The 64 bit version of
the code I ran (costest.f) was:
real*8 x,y
x=1.2345d0
y=0.567d0
do 1 n=1,100000000
x=x+0.001d0
y=y+dcos(x)
1 continue
write(6,*) y
stop
end
I compiled it using both the egcs-1.0 g77, and the Microway NDP fortran
compilers using respectively:
g77 -O5 costest.f
and
mf77 -O5 -fastlib contest.f
The egcs/g77 code took 50.7 seconds to execute in 32bit arithmetic and 51.4
seconds in 64 bit arithmetic (does this mean that their 32bit cos routine
actually uses the 64bit routine?).
The Microway NDP code took 15.5 seconds to execute in 32bit arithmetic and
29.2 seconds in 64bit arithmetic.
Perhaps the suggestion made by others that fortran is the language of choice
is correct.
Don Sinclair.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [++] x86 FCOS (Was: Re: gcc vs Dec Unix c)
1998-01-13 5:00 ` Andy Glew
@ 1998-01-14 5:00 ` Terje Mathisen
0 siblings, 0 replies; 32+ messages in thread
From: Terje Mathisen @ 1998-01-14 5:00 UTC (permalink / raw)
Andy Glew wrote:
> Sorry: the PPro and Pentium II allow FADD, FMUL, FDIV, FSQRT to run
> simultaneously with integer operations, since these are done in hardware,
> i.e. via dedicated function units and pipelines, with special sequencers
> and state machines for FDIV and FSQRT.
>
> However, the transcendentals are done in long microcode sequences,
> that essentially take over the entire micromachine. Thus, except for overlap
> at the beginning and end, the transcendentals are not done simultaneously with integer
> operations. (Except for overlap with already started long lasting operations
> like cache misses, divides, etc. - the pipeline isn't flushed (unless the microcode has
> a branch misprediction).)
OK, so I learn something new every day!
If FCOS takes about 100 cycles, and the remaining part of the test loop
somewhere between 3 and 10, the latter value when implemented with a
CALL/FCOS/RET sequence, it would still make less than 10% difference in
the actual running time.
> There are, of course, hardware assists to make the microcode run faster.
Of course! :-)
Terje
--
- <Terje.Mathisen@hda.hydro.com>
Using self-discipline, see http://www.eiffel.com/discipline
"almost all programming can be viewed as an exercise in caching"
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-14 5:00 ` Donald K.Sinclair
1998-01-14 5:00 ` cekim
@ 1998-01-14 5:00 ` Rob Komar
1998-01-16 5:00 ` Torbjorn Lindgren
1 sibling, 1 reply; 32+ messages in thread
From: Rob Komar @ 1998-01-14 5:00 UTC (permalink / raw)
Donald K.Sinclair (dks@sgi9.hep.anl.gov) wrote:
[snip]
: The egcs/g77 code took 50.7 seconds to execute in 32bit arithmetic and 51.4
: seconds in 64 bit arithmetic (does this mean that their 32bit cos routine
: actually uses the 64bit routine?).
Actually, they both use the 80 bit routine. The transcendental functions
provided by the 387 FPU are always done in extended double precision mode
in the FPU's stack (regardless of the precision setting of the FPU).
Cheers,
Robert Komar Physics Dept., Univ. of British Columbia, Canada
(stationed at the Sudbury Neutrino Observatory)
My mail address can be got from the following Unix command:
echo 'robkviaphysicsZubcZca' | tr 'Z' '.' | sed 's/via/@/'
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-13 5:00 Robert Harley
@ 1998-01-14 5:00 ` cekim
0 siblings, 0 replies; 32+ messages in thread
From: cekim @ 1998-01-14 5:00 UTC (permalink / raw)
To: cekim
harley@pauillac.inria.fr (Robert Harley):
>I think everyone is missing the point here.
>You called cos() with some very large arguments.
>
>With small arguments the Alpha's software is twice as fast as the
>PPro's hardware.
>
>With large arguments, the Alpha slows down to a sixth the speed of the
>PPro. The reason is simple: the PPro gives wrong answers. Intel
>didn't bother to reduce mod pi properly.
Now that is a much better explanation. I was about to test just such a
thing as I relized that this might have some impact.
Thank you for clearing that up, I will keep my arguments small(radians
anyone?)
:)
Also:
Robert Komar:
>See libc/sysdeps/linux/i386/math/cos.S in the libc/libm source tree.
>FCOS is invoked
After some brief hunting in the include dir, I see that fcos is indeed an
option for gcc, but I guess there is still some question as to what is
required to invoke the use of this option(ie: compile flags)?
This was not a good answer:
Peter:
>implimentation is really that much faster than the alpha implimentation.
>Just FYI, "implimentation" is spelled "implementation", at least in the USA.
Yes, quite true(spelled that way everywhere as far as I know), I tend to
get sloppy and stay that way with spelling.
As a (former?) studied musician, I find that the hands do as they please,
while being dreadful spellers. I hope I do not offend...
I have always thought systems with noise in the channel which still
function correctly were far more fascinating than those with no noise,
which function perfectly.
I should get points for consistency, though?
Happy compiling..
/Mike
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
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
1 sibling, 1 reply; 32+ messages in thread
From: Lupo LeBoucher @ 1998-01-15 5:00 UTC (permalink / raw)
In article <69ftrf$1co$1@Masala.CC.UH.EDU>,
Yan-Song Chen <phys6k@Menudo.UH.EDU> wrote:
>The math library performance of Alpha-Linux has been a serious problem for
>a long time. It hurts Alpha-Linux's FP performance seriously. But it seems
>nobody care or nobody able to enhance it.
It has already been enhanced a couple of times. There seems to be lots of
little problems with the compiler and the libraries (egcs seems like a
great step in the right direction; it got rid of the awful 32bit index
problem which plagued many matrix related numerical routines).
>b) Maybe we can push Digital to port it is math library to linux so we can
>get a commercial version of math library.
There was actually some movement towards doing this over a year and a
half ago. I managed to even work my way into finding out who would have
been responsible for it. It died somewhere along the way, perhaps over
business considerations or philosophical differences. In any case, this
fast library is available to users of Windows NT, so there can be no
fundamental objection to Digital compiling an enhanced library for
Linux-AXP. If someone is interested in poking digital some more, have a
look at the AXP-list history of about 1&3/4 year ago for teh relevant
names and numbers.
-Lupo
"I pine for the sheer stupidity of the old macho days, when men would
brandish hammers and build huge, bulky cars that sucked up gas and tore
open the ozone layer and crushed small animals beneath totally useless but
totally cool-looking tail fins." -Dennis Leary <ix@pentagon.io.com>
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-15 5:00 ` Lupo LeBoucher
@ 1998-01-15 5:00 ` Greg Lindahl
0 siblings, 0 replies; 32+ messages in thread
From: Greg Lindahl @ 1998-01-15 5:00 UTC (permalink / raw)
ix@xanadu.io.com (Lupo LeBoucher) writes:
> In any case, this
> fast library is available to users of Windows NT, so there can be no
> fundamental objection to Digital compiling an enhanced library for
> Linux-AXP. If someone is interested in poking digital some more, have a
> look at the AXP-list history of about 1&3/4 year ago for teh relevant
> names and numbers.
I talked to the library guy at SC'97 and he said the compiler was
needed. I talked to the compiler guys and they needed a business
reason to spend the $$. I am compiling a list of potential buyers,
both x86 and alpha; I'll post on comp.os.linux.announce soonish.
-- g
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-14 5:00 ` gcc vs Dec Unix c bmeyer
@ 1998-01-15 5:00 ` cekim
0 siblings, 0 replies; 32+ messages in thread
From: cekim @ 1998-01-15 5:00 UTC (permalink / raw)
To: cekim
In article <69h5rc$5bl$1@wombat.cs.monash.edu.au>,
bmeyer@bruce.cs.monash.edu.au wrote:
>
> cekim@ix.netcom.com writes:
> >PPRO 200 w/cos =10 minutes -120 billion cycles
> >ALpha 533 w/cos =65 minutes -2.08 trillion cycles
> [...]
> >I asked the loop to run 1 billion times so I have rougly [2000 ALPHA] cycles
> >per loop given the number above for the PPRO.
>
> I find this result confusing. I just tried the following program on
> my ALPHA:
>
> ==========
> #include <stdio.h>
> #include <math.h>
>
> int main(int argc, char** argv)
> {
> double a,b,c;
> long count;
>
> a=2; b=3; c=4;
>
> for (count=0;count<10000000;count++) {
> a=cos(a)/b+c/a;
> }
> printf("Answer is %f\n",a);
> }
> ==========
>
> Once with and once without the cos (i.e. "a=a/b+c/a;"). The difference
> in exacution time was about 4.5 seconds on my 433MHz ALPHA, or roughly
> 2 billion cycles. However, the ALPHA calculated TEN million cosines
> in that time, for only 200 (two HUNDRED) cycles per cosine.
>
> Is it possible you timed your stuff using "time", and have an old and
> broken version of time? Or that you may have fallen victim to the
> 1:10 difference in HZ between linux/Intel and linux/ALPHA?
>
> >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.
>
> There certainly is one if I compile the above on Intel, using gcc -O6.
>
> Bernie
> --
> ============================================================================
> "It's a magical world, Hobbes ol' buddy...
> ...let's go exploring"
> Calvin's final words, on December 31st, 1995
hmmm....
No, time() is not to blame as I could see from the clock that
it took an hour!!
Mr. Harley's answre also sheds some light here:
You are computing "a" as a=cos(a)/Eq(see above)/a
This makes a very small number (quick math, shoot me if
I am wrong :))
a=cos(small)/big/small OR a=cos(a)/(Really big) =>
small exponent in sci/ieee notation
(ie: fp hardware activity of exponent crunching minimized!!)
According to Mr. Harley, this will execute significantly
faster than "large" number, which I take to mean large
exponent in floating point calculation.
Disaggreements, clarifications, I did not spend any more
time thinking about this than writing, but it seems clear to me.
BTW:
changing me initial equation:
A=A+constant>1;
B=B+constant>1;
C=Cos(b)+a;
To multiply A and B by fractional numbers (ie: small exponent),
reduces execution time down to 2.5 minutes from 65 minutes,
thus verifying Mr. Harley's statement.
A=A*constant<1;
B=B*constant<1;
C=Cos(b)+a;
/Mike
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-14 5:00 ` Rob Komar
@ 1998-01-16 5:00 ` Torbjorn Lindgren
1998-01-17 5:00 ` Rob Komar
0 siblings, 1 reply; 32+ messages in thread
From: Torbjorn Lindgren @ 1998-01-16 5:00 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 763 bytes --]
Rob Komar <robk@nntp.ucs.ubc.ca> wrote:
>Donald K.Sinclair (dks@sgi9.hep.anl.gov) wrote:
>[snip]
>: The egcs/g77 code took 50.7 seconds to execute in 32bit arithmetic and 51.4
>: seconds in 64 bit arithmetic (does this mean that their 32bit cos routine
>: actually uses the 64bit routine?).
>
>Actually, they both use the 80 bit routine. The transcendental functions
>provided by the 387 FPU are always done in extended double precision mode
>in the FPU's stack (regardless of the precision setting of the FPU).
Whoa, you are telling us that he has a 387 in his "600Mhz Alpha
PC164LX" :-) Not blody likely!
Alpha's has 64-bit FPU register.
--
Torbj�rn Lindgren
E-mail: tl@funcom.com
If Santa ever DID deliver presents on Christmas Eve, he's dead now.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: gcc vs Dec Unix c
1998-01-16 5:00 ` Torbjorn Lindgren
@ 1998-01-17 5:00 ` Rob Komar
0 siblings, 0 replies; 32+ messages in thread
From: Rob Komar @ 1998-01-17 5:00 UTC (permalink / raw)
Torbjorn Lindgren (tl@funcom.com) wrote:
: Rob Komar <robk@nntp.ucs.ubc.ca> wrote:
: >Actually, they both use the 80 bit routine. The transcendental functions
: >provided by the 387 FPU are always done in extended double precision mode
: >in the FPU's stack (regardless of the precision setting of the FPU).
:
: Whoa, you are telling us that he has a 387 in his "600Mhz Alpha
: PC164LX" :-) Not blody likely!
:
: Alpha's has 64-bit FPU register.
Well, they have all kinds of competitively-priced PC parts in the
PC164LX machines, so why not the FPU? But seriously, yes, I was
quite mistaken. I guess I scanned the original message too quickly,
and assumed that it was an x86 machine when I saw the bit about the same
times for the various precisions. Thanks for fixing my blunder.
--
Robert Komar Physics Dept., Univ. of British Columbia, Canada
(stationed at the Sudbury Neutrino Observatory)
My mail address can be got from the following Unix command:
echo 'robkviaphysicsZubcZca' | tr 'Z' '.' | sed 's/via/@/'
^ permalink raw reply [flat|nested] 32+ messages in thread
end of thread, other threads:[~1998-01-17 5:00 UTC | newest]
Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-01-08 5:00 gcc vs Dec Unix c fonte
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
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-13 5:00 ` Craig Burley
1998-01-13 5:00 ` James Van Buskirk
1998-01-14 5:00 ` brianh
1998-01-14 5:00 ` James Van Buskirk
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-14 5:00 ` gcc vs Dec Unix c bmeyer
1998-01-15 5:00 ` cekim
1998-01-14 5:00 ` Donald K.Sinclair
1998-01-14 5:00 ` cekim
1998-01-14 5:00 ` Rob Komar
1998-01-16 5:00 ` Torbjorn Lindgren
1998-01-17 5:00 ` Rob Komar
1998-01-09 5:00 ` Toon Moene
1998-01-09 5:00 ` Toon Moene
-- strict thread matches above, loose matches on Subject: below --
1998-01-13 5:00 Robert Harley
1998-01-14 5:00 ` cekim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox