|
Boost Users : |
Subject: [Boost-users] [Math] BOOST_FPU_EXCEPTION_GUARD on Linux
From: David Roberts (dave_at_[hidden])
Date: 2013-11-13 07:55:48
Hello,
I have a program that makes considerable use of the gamma distribution from Boost.Math.
Profiling with OProfile has shown that, on Linux, this program spends about 20% of its runtime calling the functions fesetexceptflag() and feclearexcept(). The code responsible for calling these is in the BOOST_FPU_EXCEPTION_GUARD macro which is defined in boost/math/tools/config.hpp.
I have looked back through the source history to see when and why this macro was added, and it was in changeset 3186 from September 2006 with the comment "More linux fixes: finally got AMD64 machines to behave correctly" (see https://svn.boost.org/trac/boost/changeset/3186). In Boost 1.54 the conditions under which the guard macro is defined have been refined since it was originally added, but the guard class itself remains the same as in 2006.
Given the performance penalty I am suffering as a result of constantly clearing and reseting the floating point exception flags, I have a couple of questions about this functionality:
1) Can anyone provide a specific test case that did not work without the BOOST_FPU_EXCEPTION_GUARD functionality but was fixed by its addition? It would be very useful to have such a test case because then I can check if this is still a problem on recent versions of Linux.
2) The commit comment for changeset 3186 refers to AMD64. Does this mean the original problem only occurred on AMD CPUs, or does this refer to the architecture, and hence it affected both Intel and AMD CPUs?
Many thanks,
David Roberts
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net