Ticket #468 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

[with patch] quaddouble wrapper sets fpu precision to 53 bits for entire sage session

Reported by: bober Owned by: bober
Priority: major Milestone: sage-2.8.7
Component: basic arithmetic Keywords: quaddouble, fpu, ReadQuadDouble
Cc: Author(s):
Report Upstream: Reviewer(s):
Merged in: Work issues:

Description

sage/rings/real_rqdf.pyx contains the following code:

cdef class RealQuadDoubleField_class(Field):
    """
    Real Quad Double Field
    """

    def __init__(self):
        fpu_fix_start(self.cwf)        

    def __dealloc__(self):
        fpu_fix_end(self.cwf)

On systems where fpu_fix_start() does something, it sets the fpu precision to 53 bits. A poor side effect of this is that the type long double ought to have 64 bits of precision on some systems, but it doesn't when it is used in code run from SAGE.

The short term fix will be to rewrite the wrapper to have an fpu_fix_start() and fpu_fix_end() call before and after every arithmetic operation on a RealQuadDouble element, and nowhere else, to make sure that the quaddouble wrapper doesn't ever unexpected change the fpu precision.

It would also be nice to have a doctest that can check the fpu precision, so it can be checked that nothing ever changes it unexpectedly.

Attachments

5834.patch Download (19.7 KB) - added by bober 3 years ago.
This patch should fix this issue.
5835-fpu-status.patch Download (5.2 KB) - added by bober 3 years ago.
x86 specific fpu stuff -- see ticket discussion (this should NOT be included in sage)

Change History

Changed 3 years ago by bober

This patch should fix this issue.

Changed 3 years ago by bober

x86 specific fpu stuff -- see ticket discussion (this should NOT be included in sage)

Changed 3 years ago by bober

The attachment 5835-fpu-status.patch provides a module for checking/setting the fpu precision on an x86 processor, which can be useful for debugging problems like this one. Some example usage of this patch:

sage: import sage.misc.fpu as fpu
sage: fpu.get_precision()
'extended'
sage: fpu.set_double_precision()
sage: fpu.get_precision()
'double'
sage: fpu.set_single_precision()
sage: fpu.get_precision()
'single'
sage: fpu.set_extended_precision()
sage: fpu.get_precision()
'extended'

This patch should NOT be included in sage currently, as it relies on an x86 processor to function, and also just isn't written very nicely in general.

Changed 3 years ago by bober

  • component changed from algebraic geometry to basic arithmetic

Changed 3 years ago by bober

  • milestone set to sage-2.9

Changed 2 years ago by mhansen

  • summary changed from quaddouble wrapper sets fpu precision to 53 bits for entire sage session to [with patch] quaddouble wrapper sets fpu precision to 53 bits for entire sage session
  • milestone changed from sage-2.9 to sage-2.8.7

Changed 2 years ago by was

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.