sqrt function doesn't use FPU sqrt instruction ?

sqrt function doesn't use FPU sqrt instruction ?

Post by Tom Haberlan » Fri, 26 Aug 1994 07:17:56



Does sqrt (in libm.a or libmfast.a) use the FPU coprocessor
square root instruction (see page B-53 in the MIPS R4000 User's Manual)
or does it compute it manually ?

I disassembled the executable of a simple program that computes the
square root of a number using sqrt() and found no trace of the
instruction.

Whats up here ?  Somehow I feel like I'm being cheated.

System is Indy R4400, IRIX 5.2.  languaage is Ada.

____________________________________________________________________________
Tom Haberlandt             | Reality's a horde of mice nibbling away in the


____________________________________________________________________________
"I don't speak for my employer."  - Woof !
____________________________________________________________________________

 
 
 

sqrt function doesn't use FPU sqrt instruction ?

Post by Martin Knoblau » Sat, 27 Aug 1994 19:34:08



|> Does sqrt (in libm.a or libmfast.a) use the FPU coprocessor
|> square root instruction (see page B-53 in the MIPS R4000 User's Manual)
|> or does it compute it manually ?
|>

  Both are using software algorithms. They are intended to be
compatible with the mips1 instruction set (there used to be
a libfastm.a in /usr/lib/mips2, but I don't know what happened
to it. It made not much sense anyway).

  The hardware sqrt is only supported in the misp2 instruction
set ("-mips2" switch to the compiler). In that case (at least
C and Fortran do it) the call to the sqrt routine in libm or
libfastm is replaced with a sqrt.s/sqrt.d instruction (reducing
call overhead and using the speed). You will find the difference
in an assembly listing of your program. The libraries are not
involved.

Martin
--
+---------------------------------+-----------------------------------+
|Martin Knoblauch                 | Silicon Graphics GmbH             |
|Application Center               | Am Hochacker 3 - Technopark       |
|Silicon Graphics Computer Systems| D-85630 Grasbrunn-Neukeferloh, FRG|
|                                 | Phone: (+int) 89 46108-179 or -0  |
|                                 | Fax:   (+int) 89 46108-190 (-222) |
+---------------------------------+-----------------------------------+

+---------------------------------------------------------------------+

 
 
 

sqrt function doesn't use FPU sqrt instruction ?

Post by Martin Knoblau » Sat, 27 Aug 1994 19:53:58



Quote:(Martin Knoblauch) writes:



|> |> Does sqrt (in libm.a or libmfast.a) use the FPU coprocessor
|> |> square root instruction (see page B-53 in the MIPS R4000 User's
|> Manual)
|> |> or does it compute it manually ?
|> |>
|>  
|>   Both are using software algorithms. They are intended to be
|> compatible with the mips1 instruction set (there used to be
|> a libfastm.a in /usr/lib/mips2, but I don't know what happened
|> to it. It made not much sense anyway).
|>
|>   The hardware sqrt is only supported in the misp2 instruction
|> set ("-mips2" switch to the compiler). In that case (at least
|> C and Fortran do it) the call to the sqrt routine in libm or
|> libfastm is replaced with a sqrt.s/sqrt.d instruction (reducing
|> call overhead and using the speed). You will find the difference
|> in an assembly listing of your program. The libraries are not
|> involved.
|>

  I actually checked out the "old" compilers from 4.0.5. They
didn't generate different code for sqrt when you specified
"-mips2". The difference was made on linking, when you had
to use the libs from /usr/lib/mips2. There libm/libfastm
used the hardware-sqrt instead of the software algorithm.
The disadvantage of that step was that you still had the
overhead of calling/returning_from a function. The new
compilers save cycles here.

  The conclusion of this is of course: libfastm only makes
sense for mips1 programs. And whenever you can use "-mips2"
for programs that are intended to run on R4x00 processors.

Martin
--
+---------------------------------+-----------------------------------+
|Martin Knoblauch                 | Silicon Graphics GmbH             |
|Application Center               | Am Hochacker 3 - Technopark       |
|Silicon Graphics Computer Systems| D-85630 Grasbrunn-Neukeferloh, FRG|
|                                 | Phone: (+int) 89 46108-179 or -0  |
|                                 | Fax:   (+int) 89 46108-190 (-222) |
+---------------------------------+-----------------------------------+

+---------------------------------------------------------------------+