From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111c93,2cb1c7dcdf4349e1 X-Google-Attributes: gid111c93,public From: Joachim Wesner Subject: Re: sin() on alpha. Date: 1998/05/24 Message-ID: <35674B96.4F02DB91@frankfurt.netsurf.de>#1/1 X-Deja-AN: 355930828 Content-Transfer-Encoding: 7bit References: <3565295F.7367C07E@dirac.phys.uwm.edu> Content-Type: text/plain; charset=us-ascii Organization: OMNILINK -- your link to the Net MIME-Version: 1.0 Newsgroups: comp.os.linux.alpha Dong-Woon Park wrote: > > Thanks for replies. > > > Why polynomials are faster ? I don't know at all about the way > co-processor or libm works. Doesn't libm use these schemes? or is > there any chance to lose some accuracy using polynomials instead of > sin() libm provides ? > the actual libm uses polynomials, however 1) approximating over a certain range is only one part of the task, you need also do range reduction for larger arguments and this can be a nontrivial task for example for the trig-functions. It is *NOT* good enough to subtract a multiple of a double precision pi value to get into the range, this will give you a totally wrong result for say sin(1e6). Somebody would probably say, this is pointless, because the relative precision in the large argument is so much lower, however, the usual philosophy here is to take the big number as "exact" and to demand that the routine should give the same result for that large number as an infinite precision calculation (within the few lowest bits). Usually that means you need to simulate kind of a quad floating precision calculation here. 2) the libm range reduction is pretty complex (way larger in sourcecode than any of the approximation routines therein), I think a bit overdone in precision and it seems that gcc does a bad job in compiling it. 3) Likewise the approximation polymials in libm are a bit to much on the save side regarding (theoretical) precision, that is mostly lost in the rest of the calculation, that is only double precision, for speed. 4) Still, my measurements clearly show that for large arguments, running time in libm is mostly governed by range reduction and not approximation. 5) goto in japan rewrote part of the sine and cos routines in assembler and optimized the approximation with respect to the pipelined nature of the alpha, however, it seems he still uses the c-Version of the too slow original range reduction, and looses again for large arguments. I'm working on a different set of routines that uses a somewhat simpler approximation that sacrifices some accuracy for speed and it seems I have a more effective range reduction. However, in the recent days I have been porting very interesting routines from Cray they use on their Multiple-Alpha machine (somebody pointed those out here) that have virtually constant running times for all arguments. The copyright status of those is not yet totally clear, these could be pretty interesting for us. See my other post. Joachim