Re: FPU status and loading modules

Ralf Juengling <[email protected]> Fri, 12 Jun 2009 09:30:42 -0700 (PDT)
Newsgroups gmane.lisp.lush.devel
Message-ID <[email protected]>
I have added an API for controlling the FPU to Lush2
and also changed the default FPU state on startup. If
you want to check it out, don't forget to run
./configure again after 'svn up'.

Other, related changes:
* Lush resets the FPU to the default state after an error
* warns if FPU state changes when loading a module
* on platforms supporting POSIX 2001 signal handling error
   messages of trapped FPU exceptions are more detailed
   (what error, at what address)

I used standard interfaces (C99) as much as possible
and glibc and others for things not covered by standards.
So not all parts of the FPU API will work on all platforms
right now (it works on Linux). I happily accept patches
that extends the functionality to other platforms.

Cheers,
Ralf



On Sat, 2 May 2009, Ralf Juengling wrote:

> 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
>
>
>
>
>
>
>

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects