This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Ideas for rewrite of libm-test



Uli suggested to me to rewrite libm-test so that it contains platform
specific epsilons and told me some ideas.  I've discussed this further 
with Andreas Schwab and like to tell you the current state of our
discussion.  I haven't implemented anything yet - I first like to
discuss the ideas before I start.


libm-test.c will be slightly changed to give us the chance for
automatic building of platform specific files.  The platform specific
files will generated by a perl script.  Since we don't expect that
perl is installed on user system, all generated files are added to
glibc.

I think it's best to start with an example explaining the ideas we
had:

These lines from libm-test.c:
  result = FUNC(modf) (89.6, &intpart);
  check_eps ("modf (89.6, &x) returns 0.6", result, 0.6,
	     CHOOSE (6e-15L, 6e-15, 2e-6));
  check ("modf (89.6, &x) sets x to 89", intpart, 89);

will be changed for libm-test.template to:
  result = FUNC(modf) (89.6, &intpart);
  check ("modf (89.6, &x) returns 0.6", result, 0.6, REPLACE);
  check ("modf (89.6, &x) sets x to 89", intpart, 89, REPLACE);


Platform specific epsilons will be generated (please note that the
epsilons are just examples!):

Epsilons (for alpha, lives in sysdeps/alpha/Epsilons):
Test "modf (89.6, &x) returns 0.6":
float: 1e-7
Test "modf (89.6, &x) sets x to 89":
float: fail

Epsilons (for i386, lives in sysdeps/i386/Epsilons):
Test "modf (89.6, &x) returns 0.6":
ldouble: 1e-16

Epsilons (for i686, lives in sysdeps/i386/i686/Epsilons):
Test "modf (89.6, &x) returns 0.6":
double: 1e-14

Epsilons (generic, might live in sysdeps/ieee754/Epsilons or
sysdeps/generic/Epsilons):
Test "modf (89.6, &x) sets x to 89":
double: 1e15

Some notes:
- The tag for the tests is the string that's used in the call to check.
- The special word "fail" allows us to mark known failures, e.g. complex
  float support on alpha.
- We could easily extend this to hardware platform and operating
  system files if this becomes neccessary.

A perl script will read libm-test.template and all Epsilons that are
relevant for a platform (like the reading of Versions) and generate a
number of files:
- libm-test.c and libm-test.h
- platform specific files epsilon.h 
libm-test.c includes the platform specific epsilon.h and then libm-test.h

The example fragment of libm-test.c might be transformed to:
  result = FUNC(modf) (89.6, &intpart);
  check ("modf (89.6, &x) returns 0.6", result, 0.6, DELTA47, FAIL47);
  check ("modf (89.6, &x) sets x to 89", intpart, 89, DELTA48, FAIL48);

DELTAxx and FAILxx are numbered automatically.

The epsilon.h fragments are:

epsilon.h (for sysdeps/alpha):
#define DELTA47 CHOOSE(0,1e15,1e-7)
#define FAIL48 CHOOSE(0,0,1)

epsilon.h (for sysdeps/i386/i686):
#define DELTA47 CHOOSE(0,1e-14,0)

epsilon.h (for sysdeps/i386):
#define DELTA47 CHOOSE(1e-16,1e15,0)

libm-test.h contains a fall back for all macros since the epsilon.h
files only contain the needed macros:
#ifndef DELTA47
# define DELTA47 0
#endif
#ifndef DELTA48
# define DELTA48 0
#endif
#ifndef FAIL47
# define FAIL47 0
#endif
#ifndef FAIL48
# define FAIL48 0
#endif

I'd also like to enhance libm-test so that it generates automatically
the "Epsilons" file - this allows easier switching to the new format
and helps with porting to new targets.

What do you think?

Andreas
-- 
 Andreas Jaeger   aj@suse.de    aj@arthur.rhein-neckar.de
  for pgp-key finger ajaeger@aixd1.rhrk.uni-kl.de

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]