Floating Point-The Results Are In!

Greg Lehey grog at lemis.com
Fri May 8 20:16:15 AEST 1998


On Fri,  8 May 1998 at  0:14:03 -0400, Ed G. wrote:
Content-Description: Mail message body
>> I'll believe this when you pinpoint the instructions.
>
> Your skepticism spurred me to examine a Unix utility in depth to see
> whether my results hold up.  They do.
>
> According to my count, tar uses 106 floating point operations.  Here
> are the first few.  The complete list, tar3.txt, is attached as
> well for your perusal. If you'd like to look at the complete
> disassembled code for tar, let me know.
>
> [root at oskar uv7]# ../dis/disuv7.pl < tar | grep ';17'
> file header: 410 37400 4254 27422 20270 0 0 1
> read 16128 bytes
> prog string is 16128 bytes
> 0:  SETD   ;170011
> 20532:  STCFD F0,(R1)   ;176011
> 20562:  STF F0,(R1)   ;174011
> 22406:  LDF F0,(R4)+   ;172424
> 22410:  STF F0,-(SP)   ;174046
> 22460:  LDF F0,(R4)+   ;172424
> 22462:  STF F0,-(SP)   ;174046
> 22620:  LDF F0,(R4)+   ;172424
> 22622:  STF F0,-(SP)   ;174046
> 24124:  LDF F0,4(R5)   ;172465 000004
> 24130:  STF F0,-(SP)   ;174046
> 26616:  LDF F0,#56200   ;172427 056200
>
> I chose tar as an example because it is an important utility and
> because it is a relatively heavy user of floating point (as guaged
> by the number of floating point ops contained in tar).

I don't know what the code above is intended to do, but it's not
floating point.  At the very best, it would indicate the use of the
floating point registers for straightforward data moves.  I stand by
my assertion that tar doesn't use floating point, neither in the
Seventh Edition nor elsewhere.

For the fun of it, I took the source of tar from the Seventh Edition
(/usr/src/cmd/tar/tar.c) and compiled it on 2.11BSD.  I had some minor
compilation problems due to different directory structures, which I
solved by #ifdefing out the following code:

#if 0
                        for (j=0; j < DIRSIZ; j++)
                                *cp2++ = dbuf.d_name[j];
                        *cp2 = '\0';
                        close(infile);
                        putfile(buf, cp);
                        infile = open(".", 0);
                        i++;
                        lseek(infile, (long) (sizeof(dbuf) * i), 0);
#endif

I think we can agree that they don't contain FP code.  Here are some
results:

[23] root--> cc -n -s -O tar.c -S
[24] root--> grep -i ldf tar.s
[25] root--> grep -i mul tar.s


> The following routines in 7th Edition tar appear to use floating
> point:
>
>> _filbuf
>> _innum
>> atof
>> cvt
>> ecvt
>> fcvt
>> gcvt
>> isatty
>> main
>> mktemp

atof, cvt, ecvt, fcvt and gcvt are conversion routines which use
floating point, so I can agree that they would contain FP code which,
however, would not be used.  isatty is a library routine which is
simple enough to quote:

/*
 * Returns 1 iff file is a tty
 */

#include <sgtty.h>

isatty(f)
{
        struct sgttyb ttyb;

        if (gtty(f, &ttyb) < 0)
                return(0);
        return(1);
}

Evidently there's no FP code there.

It's fun to go looking for things like this.  But never trust
anything, especially not your own judgement, until you have a couple
of different ways to prove it.  You have the sources there; go ahead
and check them out.

Greg
--
See complete headers for address and phone numbers
finger grog at lemis.com for PGP public key

Received: (from major at localhost)
	by minnie.cs.adfa.oz.au (8.8.8/8.8.8) id XAA15293
	for pups-liszt; Fri, 8 May 1998 23:10:26 +1000 (EST)


More information about the TUHS mailing list