[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: abs()
Greetings! Just confirmed this on intel as well. Amazing! I don't
know why I hadn't thought of it before. Definitely the way to go.
Take care,
Peter Strazdins <peter@bullet.anu.edu.au> writes:
> Hi Clint,
>
> probably this is well-known, but for Sparc, gcc -O compiles a call to
> the standard maths function fabs() as a fabss instruction (this works
> for single or double precision). Nothing could be easier :).
> The latest Solaris compilers (f95 at least) will convert the conditional
> ( (x) >= 0.0 ? (x) : -(x) ) to an fabss too.
>
> Regards, Peter
>
> eg. #define ATL_dabs(x) fabs(x)
>
> >> From owner-atlas-comm@cs.utk.edu Sun May 13 03:32:06 2001
> ...
> >> My guess is that there are system-dependant ways to make fabs() one cycle
> >> nonetheless, and I'm hoping some of you know or can easily discover them.
> >> Anyway, I want to ask anyone who can figure out to do fabs() without an if
> >> to post to the list. The solution can be as nonportable as you want;
> >> I figure in-line assembler may be required, but hopefully it can be used
> >> with a C macro. Here's an example macro for double precision:
> >>
> >> #define ATL_dabs(x) ( (x) >= 0.0 ? (x) : -(x) )
> >>
> >> If anyone can do it without the if, I think we can speedup quite a few
> >> routines . . .
> >>
> >> Any pointers appreciated,
> >> Clint
> >>
>
>
--
Camm Maguire camm@enhanced.com
==========================================================================
"The earth is but one country, and mankind its citizens." -- Baha'u'llah
- References:
- Re: abs()
- From: Peter Strazdins <peter@bullet.anu.edu.au>