FPU status and loading modules

Ralf Juengling <[email protected]> Sat, 2 May 2009 16:50:13 -0700 (PDT)
Newsgroups gmane.lisp.lush.devel
Message-ID <[email protected]>
Hi all,

Here is an odd thing that I was not aware of until now:
Loading a module might change the state of the FPU.
For example:

? (/ 1 0)

*** / : Floating exception
Debug toplevel [y/N] ?n
?
? (libload "blas/blas-config")
  [blas-config.lsh]
  [fortran.lsh]
= "/usr/share/lush/packages/blas/blas-config.lsh"
?
? (mod-load blas-libblas)
= "/usr/lib/libblas.so"
? (/ 1 0)
= Inf
?


This gave me some headaches when trying to track down the
cause of a floating point error. The error did not seem
to be deterministic (sometimes an error was raised and
sometimes not, when going through the very same code path).
I think it had to do with the side-effect of mod-load.

Now the question is what should we do about it. If we think
it legitimate that module initialization code reconfigures
the FPU (I assume that's what is happening when loading
libblas.so), then the current behavior of mod-load is ok.
Perhaps mod-load should warn when this happens, though.
If we think this is not legitimate, then we may change
mod-load to have it save the FPU state before and restore
it when done with loading.

Any opinions?

Ralf







------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf