Re: [xslt] 1.1.15 test failure on Redhat 7.1, RHEL 2.1/x86, 3/x86, 4/x86



On 2005-11-21 06:32:31 -0500, Daniel Veillard wrote:
> On Tue, Nov 15, 2005 at 03:23:18AM +0100, Vincent Lefevre wrote:
> > This won't solve all the problems. You can download
> > 
> >   http://www.vinc17.org/software/tst-ieee754.xsl
> > 
> > and run "xsltproc tst-ieee754.xsl tst-ieee754.xsl". On my Debian x86
> > machine, I get:
> > 
> > Not a conforming XPath implementation.
> 
>   This seems to come down to compliance of floating point
> implementations in chips and how the compilers cope with the
> differences.

The x86 processor is a conforming IEEE-754 implementation.
Concerning the rounding precision, here's what the standard
says:

  Normally, a result is rounded to the precision of its destination.
  However, some systems deliver results only to double or extended
  destinations. On such a system the user, which may be a high-level
  language compiler, shall be able to specify that a result be rounded
  instead to single precision, though it may be stored in the double
  or extended format with its wider exponent range. [FOOTNOTE 4:
  Control of rounding precision is intended to allow systems
  whose destinations are always double or extended to mimic, in the
  absence of over/underflow, the precisions of systems with single and
  double destinations. An implementation should not provide operations
  that combine double or extended operands to produce a single result,
  nor operations that combine double extended operands to produce a
  double result, with only one rounding.] Similarly, a system that
  delivers results only to double extended destinations shall permit
  the user to specify rounding to single or double precision. Note
  that to meet the specifications in 4.1, the result cannot suffer
  more than one rounding error.

> I'm not sure it's really something we can fix at the libxslt level
> (or libxml2 rather since the arithmetics for that stylesheet is in
> libxml2 xpath.c actually).

As requested by the IEEE-754 standard, the x86 processor can be
configured to round results to double precision (though its registers
are 80-bit wide). The way to do that is not portable, but fortunately,
only Linux/x86 seems to have the processor configured by default in
extended precision (well, perhaps Solaris/x86 too, but I could never
tried).

There would be 2 solutions to detect whether a rounding precision
change is necessary:
  1. Do a configure test for the existence of <fpu_control.h>.
  2. Do a hard-coded test such as
       #if __linux && __i386 && ! __SSE2__
     (I'm not sure what's the right one, but this could be tested
     on many platforms...)

Now, the other problem is where the rounding precision should be
changed. There would be 2 solutions:
  1. in the library (that would be libxml2), where need be (e.g.
     switch to double before the operation and restore the old mode
     after the operation);
  2. in the programs themselves (e.g. xsltproc) at the beginning
     (for instance).

Note that JVM's have the same problem, which has been dealt with
in Sun's and IBM's JVM's, and more lately in SableVM, JamVM and
Kaffe.

-- 
Vincent Lefèvre <vincent vinc17 org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]