Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion glibc very old
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Vincent Lefevre  
View profile  
 More options Jul 25 2012, 8:40 pm
Newsgroups: linux.debian.devel
From: Vincent Lefevre <vinc...@vinc17.net>
Date: Thu, 26 Jul 2012 02:40:02 +0200
Local: Wed, Jul 25 2012 8:40 pm
Subject: Re: glibc very old
On 2012-07-26 03:58:33 +0900, Miles Bader wrote:

> Vincent Lefevre <vinc...@vinc17.net> writes:
> >> So... these functions were made almost an order of magnitude slower
> >> in the (overwhelmingly) common case, in order to handle rare and
> >> exceptional cases...?

> > This depends on the processor. You should get a processor that
> > handles rounding-mode change in a better way (the slowdown should
> > not be noticeable when you just run the program, without looking at
> > the exact running time).

> It's about 5 times slower on both phenom2 (AMD) and core2 (Intel)
> cpus.... I dunno if these are unusual.

I can reproduce a 3.4x slowdown with:

#include <stdio.h>
#include <float.h>
#include <math.h>
#include <fenv.h>
#pragma STDC FENV_ACCESS ON

int main (void)
{
  volatile double x = 1.0, y;
  int i;

  for (i = 0; i < 100000000; i++)
    {
      fesetround (FE_TONEAREST);
      y = exp(x);
      fesetround (FE_TONEAREST);
    }
  return y == 0.0;

}

and Debian's glibc and Intel Core 2 Duo. I'll try to have more
information about why the processor doesn't detect that the
rounding mode doesn't change.

But with:

#include <stdio.h>
#include <float.h>
#include <math.h>
#include <fenv.h>
#pragma STDC FENV_ACCESS ON

int main (void)
{
  volatile double x = 1.0, y;
  int i;

  for (i = 0; i < 100000000; i++)
    {
      int r = fegetround();
      if (r != FE_TONEAREST)
        fesetround (FE_TONEAREST);
      y = exp(x);
      if (r != FE_TONEAREST)
        fesetround (r);
    }
  return y == 0.0;

}

I only get a 9% slowdown. I suppose that withing glibc code, it can
be lower. The advantage of this method compared to remembering the
rounding mode in glibc is that it is 100% safe, in case the user or
some library bypasses the C libary to change the rounding mode.

I think that there could be an optimization like that in
fesetround() too.

> Ok, I guess there's no really guaranteed way to make it fast, so
> glibc's method (with arch-specific reimplementations for those cases
> where it proves to be slow) it is reasonable enough ...

Yes, the chosen method could depend on the processor.

--
Vincent Lefèvre <vinc...@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

--
To UNSUBSCRIBE, email to debian-devel-REQU...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20120726002713.GA6...@xvii.vinc17.org


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.