Floating point exception handling

Jugoslav Dujic
Total Points:
6,542
Status Points:
6,542
Black Belt
May 8, 2008 7:40 AM PDT
Rate
 
#1
John.Keenan:
Am I correct in assumming that the floating point processor control word is changed when entering the fortran code and then returned to its previous state when exiting the Fortran code? In other words the state of the calling environment should have no affect on the Fortran floating point processor specification.


No. Even for code compiled with /fpe:0 (produce exceptions), exceptions can still be masked by the FPCW, which is outside of control of your dll. In my Dll I have:
integer, parameter:: FP_MASK=  FPCW$INVALID.or.FPCW$ZERODIVIDE
integer(2)::                           iFp, iFpu

call getcontrolfpqq(iFpu)
#ifdef RELEASE
    iFp=ior(iFpu,FP_MASK)
#else
   iFp=iand(iFpu, not(FP_MASK))
#endif
call setcontrolfpqq(iFp)
at entry of every entry-point routine (well, actually,  in one wrapper function, but the code is always executed). Probably the FPCW should be set back to the original value on return (so that the dll "plays nice").


--------
Jugoslav
www.xeffort.com


Intel Software Network Forums Statistics

8473 users have contributed to 31605 threads and 100654 posts to date.
In the past 24 hours, we have 30 new thread(s) 110 new posts(s), and 160 new user(s).

In the past 3 days, the most popular thread for everyone has been gemm(A,A,A) like possible? The most posts were made to gemm(A,A,A) like possible? The post with the most views is Dear Steve, excuse me for a d

Please welcome our newest member Kevin Johnson