Hi,
At some point in my code I expected a division by 0 to raise a condition but
it didn't and produced #.SB-EXT:DOUBLE-FLOAT-POSITIVE-INFINITY silently.
I never changed floating point traps explicitly, but I realized that
merely loading BLAS changes them:
CL-USER> (sb-int:get-floating-point-modes)
(:TRAPS (:OVERFLOW :INVALID :DIVIDE-BY-ZERO) :ROUNDING-MODE :NEAREST
:CURRENT-EXCEPTIONS (:INEXACT) :ACCRUED-EXCEPTIONS (:INEXACT) :FAST-MODE NIL)
CL-USER> (require :cffi)
NIL
CL-USER> (sb-int:get-floating-point-modes)
(:TRAPS (:OVERFLOW :INVALID :DIVIDE-BY-ZERO) :ROUNDING-MODE :NEAREST
:CURRENT-EXCEPTIONS (:INEXACT) :ACCRUED-EXCEPTIONS (:INEXACT) :FAST-MODE NIL)
CL-USER> (cffi:load-foreign-library "libblas.so")
#<CFFI:FOREIGN-LIBRARY {10035EFFC1}>
CL-USER> (sb-int:get-floating-point-modes)
(:TRAPS NIL :ROUNDING-MODE :NEAREST :CURRENT-EXCEPTIONS (:INEXACT)
:ACCRUED-EXCEPTIONS (:INEXACT) :FAST-MODE NIL)
After this, things like (/ 0d0) won't raise a condition.
As I don't have a lot of experience with floating point traps, I would
appreciate any advice on how to deal with this. Is it normal that
foreign libraries change floating point traps? Should I fight it (eg
reset it every time I call a foreign function or load a library), or
learn to work around it?
Thanks,
Tamas
|