From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111c93,b79a29863eb727e7 X-Google-Attributes: gid111c93,public From: cekim@ix.netcom.com Subject: Re: gcc vs Dec Unix c Date: 1998/01/13 Message-ID: <884563899.2019688456@dejanews.com> X-Deja-AN: 315506692 References: <884291935.1575288842@dejanews.com> <694nm1$74c$1@news2.xs4all.nl> <884364975.2133262340@dejanews.com> <695t9e$kft$1@agate.berkeley.edu> <884411893.151322629@dejanews.com> X-Originating-IP-Addr: 204.32.195.111 (nas-nh5-15.ix.netcom.com) X-Authenticated-Sender: cekim@ix.netcom.com To: cekim@ix.netcom.com X-Http-User-Agent: Mozilla/4.04 [en] (X11; I; Linux 2.0.32 i686) Organization: Deja News Posting Service X-Article-Creation-Date: Mon Jan 12 00:11:39 1998 GMT Newsgroups: comp.os.linux.alpha Craig Burley 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