Re: Why is using single-precision slower than using double-precision

luigi@paris.CS.Berkeley.EDU (Luigi Semenzato)
Wed, 23 Nov 1994 22:14:14 GMT

          From comp.compilers

Related articles
Why is using single-precision slower than using double-precision zxu@monalisa.usc.edu (1994-11-23)
Re: Why is using single-precision slower than using double-precision weaver@weitek.COM (1994-11-23)
Re: Why is using single-precision slower than using double-precision meissner@osf.org (1994-11-23)
Re: Why is using single-precision slower than using double-precision scott@cs.arizona.edu (1994-11-23)
Re: Why is using single-precision slower than using double-precision joelw@convex.convex.com (1994-11-23)
Re: Why is using single-precision slower than using double-precision koppel@omega.ee.lsu.edu (1994-11-23)
Re: Why is using single-precision slower than using double-precision bevan@cs.man.ac.uk (1994-11-23)
Re: Why is using single-precision slower than using double-precision luigi@paris.CS.Berkeley.EDU (1994-11-23)
Re: Why is using single-precision slower than using double-precision davidm@Rational.COM (1994-11-23)
Re: Why is using single-precision slower than using double-precision dsmentek@hpfcla.fc.hp.com (1994-11-23)
Re: Why is using single-precision slower than using double-precision trobey@taos.arc.unm.edu (1994-11-23)
Re: Why is using single-precision slower than using double-precision kenneta@hubcap.clemson.edu (1994-11-23)
Re: Why is using single-precision slower than using double-precision dik@cwi.nl (1994-11-24)
Re: Why is using single-precision slower than using double-precision davidc@panix.com (David B. Chorlian) (1994-11-24)
[5 later articles]
| List of all articles for this month |
Newsgroups: comp.parallel,comp.arch,comp.compilers
From: luigi@paris.CS.Berkeley.EDU (Luigi Semenzato)
Status: RO
Originator: rmuise@dragon.acadiau.ca
Organization: University of California, Berkeley
References: <3aqv5k$e27@monalisa.usc.edu>
Date: Wed, 23 Nov 1994 22:14:14 GMT

In article <3aqv5k$e27@monalisa.usc.edu>,
Zhiwei Xu <zxu@monalisa.usc.edu> wrote:


>Can any one explain why a C program using single precision (float) is slower
>that the same code using double precision (double)?


> w = 1.0 / (double) N ;
> for(i=1;i<=N;i=i+1) {
> local = ( ((double) i) - 0.5 ) * w ;
> pi = pi + 4.0 / ( 1.0 + local * local ) ;
> }


It would have been better if you reported the results,
particularly the system time. A possible explanation is that
when you use floats this code spends a lot of time in the
denormalized exception handler. Denormalized numbers are
a feature of IEEE floating point that insure graceful underflow
for numbers close to zero. They are too expensive to
implement in hardware, so the floating point unit traps and
lets system software handle them. On some systems you can
request to turn this feature off and simply underflow.


In general, though, I would not expect single precision code
to be any faster than double precision. Most floating point
units are optimized for double precision and if you use single
precision at best you will spend extra time in converting between
the two formats. Single precision is used for compactness, not
for speed. ---Luigi







Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.