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

8293 users have contributed to 31241 threads and 99118 posts to date.
In the past 24 hours, we have 12 new thread(s) 11 new posts(s), and 21 new user(s).

In the past 3 days, the most popular thread for everyone has been huge pages on linux? The most posts were made to Pipeline buffer between stages? The post with the most views is Another example attached (Tr

Please welcome our newest member bwillems