#include <EnableFloatingPointExceptions.h>
Public Types | |
typedef int | fpu_flags_type |
Public Member Functions | |
EnableFloatingPointExceptions (ParameterSet const &pset, ActivityRegistry ®istry) | |
void | postEndJob () |
void | postModule (ModuleDescription const &description) |
void | postModuleBeginJob (ModuleDescription const &description) |
void | postModuleBeginLumi (ModuleDescription const &description) |
void | postModuleBeginRun (ModuleDescription const &description) |
void | postModuleEndJob (ModuleDescription const &description) |
void | postModuleEndLumi (ModuleDescription const &description) |
void | postModuleEndRun (ModuleDescription const &description) |
void | preModule (ModuleDescription const &description) |
void | preModuleBeginJob (ModuleDescription const &description) |
void | preModuleBeginLumi (ModuleDescription const &description) |
void | preModuleBeginRun (ModuleDescription const &description) |
void | preModuleEndJob (ModuleDescription const &description) |
void | preModuleEndLumi (ModuleDescription const &description) |
void | preModuleEndRun (ModuleDescription const &description) |
Static Public Member Functions | |
static void | fillDescriptions (edm::ConfigurationDescriptions &descriptions) |
Private Member Functions | |
void | echoState () const |
void | enableAndDisableExcept (fpu_flags_type target) |
void | establishModuleEnvironments (ParameterSet const &pset) |
void | postActions (ModuleDescription const &description, char const *debugInfo) |
void | preActions (ModuleDescription const &description, char const *debugInfo) |
void | setPrecision (bool precisionDouble) |
Private Attributes | |
fpu_flags_type | defaultState_ |
fpu_flags_type | fpuState_ |
bool | reportSettings_ |
std::map< std::string, fpu_flags_type > | stateMap_ |
std::stack< fpu_flags_type > | stateStack_ |
Description: This service gives cmsRun users the ability to configure the behavior of the Floating Point (FP) environment. There are two separate aspects of the FP environment this service can control:
1. floating-point exceptions (on a module by module basis if desired) 2. precision control on x87 FP processors.
If you do not use the service at all, floating point exceptions will not be trapped anywhere (FP exceptions will not cause a crash). Add something like the following to the configuration file to enable to the exceptions:
process.EnableFloatingPointExceptions = cms.Service("EnableFloatingPointExceptions", moduleNames = cms.untracked.vstring( 'default', 'sendMessages1', 'sendMessages2' ), default = cms.untracked.PSet( enableOverFlowEx = cms.untracked.bool(False), enableDivByZeroEx = cms.untracked.bool(False), enableInvalidEx = cms.untracked.bool(False), enableUnderFlowEx = cms.untracked.bool(False) ), sendMessages1 = cms.untracked.PSet( enableOverFlowEx = cms.untracked.bool(False), enableDivByZeroEx = cms.untracked.bool(True), enableInvalidEx = cms.untracked.bool(False), enableUnderFlowEx = cms.untracked.bool(False) ), sendMessages2 = cms.untracked.PSet( enableOverFlowEx = cms.untracked.bool(False), enableDivByZeroEx = cms.untracked.bool(False), enableInvalidEx = cms.untracked.bool(True), enableUnderFlowEx = cms.untracked.bool(False) ) )
In this example, the "Divide By Zero" exception is enabled only for the module with label "sendMessages1", the "Invalid" exception is enabled only for the module with label sendMessages2 and no floating point exceptions are otherwise enabled.
The defaults for these options are currently all false. (in an earlier version DivByZero, Invalid, and Overflow defaulted to true, we hope to return to those defaults someday when the frequency of such exceptions has decreased)
Enabling exceptions is very useful if you are trying to track down where a floating point value of 'nan' or 'inf' is being generated and is even better if the goal is to eliminate them.
One can also control the precision of floating point operations in x87 FP processors as follows:
process.EnableFloatingPointExceptions = cms.Service("EnableFloatingPointExceptions", setPrecisionDouble = cms.untracked.bool(True) )
If set true (the default if the service is used), the floating precision in the x87 math processor will be set to round results of addition, subtraction, multiplication, division, and square root to 64 bits after each operation instead of the x87 default, which is 80 bits for values in registers (this is the default you get if this service is not used at all).
The precision control only affects Intel and AMD 32 bit CPUs under LINUX. We have not implemented precision control in the service for other CPUs yet (some other CPUs round to 64 bits by default and some other CPUs do not allow control of the precision of floating point calculations, the behavior of other CPUs may need more study in the future).
Definition at line 98 of file EnableFloatingPointExceptions.h.
Definition at line 100 of file EnableFloatingPointExceptions.h.
edm::service::EnableFloatingPointExceptions::EnableFloatingPointExceptions | ( | ParameterSet const & | pset, |
ActivityRegistry & | registry | ||
) |
Definition at line 78 of file EnableFloatingPointExceptions.cc.
References defaultState_, echoState(), enableAndDisableExcept(), establishModuleEnvironments(), fpuState_, edm::ParameterSet::getUntrackedParameter(), postEndJob(), postModule(), postModuleBeginJob(), postModuleBeginLumi(), postModuleBeginRun(), postModuleEndJob(), postModuleEndLumi(), postModuleEndRun(), preModule(), preModuleBeginJob(), preModuleBeginLumi(), preModuleBeginRun(), preModuleEndJob(), preModuleEndLumi(), preModuleEndRun(), reportSettings_, setPrecision(), stateStack_, edm::ActivityRegistry::watchPostEndJob(), edm::ActivityRegistry::watchPostModule(), edm::ActivityRegistry::watchPostModuleBeginJob(), edm::ActivityRegistry::watchPostModuleBeginLumi(), edm::ActivityRegistry::watchPostModuleBeginRun(), edm::ActivityRegistry::watchPostModuleEndJob(), edm::ActivityRegistry::watchPostModuleEndLumi(), edm::ActivityRegistry::watchPostModuleEndRun(), edm::ActivityRegistry::watchPreModule(), edm::ActivityRegistry::watchPreModuleBeginJob(), edm::ActivityRegistry::watchPreModuleBeginLumi(), edm::ActivityRegistry::watchPreModuleBeginRun(), edm::ActivityRegistry::watchPreModuleEndJob(), edm::ActivityRegistry::watchPreModuleEndLumi(), and edm::ActivityRegistry::watchPreModuleEndRun().
|
private |
Definition at line 415 of file EnableFloatingPointExceptions.cc.
Referenced by EnableFloatingPointExceptions(), establishModuleEnvironments(), postActions(), postEndJob(), and preActions().
|
private |
Definition at line 367 of file EnableFloatingPointExceptions.cc.
References cond::rpcobimon::current, and filterCSVwithJSON::target.
Referenced by EnableFloatingPointExceptions(), establishModuleEnvironments(), postActions(), and preActions().
|
private |
Definition at line 127 of file EnableFloatingPointExceptions.cc.
References def, defaultState_, echoState(), enableAndDisableExcept(), flags, fpuState_, edm::ParameterSet::getUntrackedParameter(), edm::ParameterSet::getUntrackedParameterSet(), reportSettings_, and stateMap_.
Referenced by EnableFloatingPointExceptions().
|
static |
Definition at line 265 of file EnableFloatingPointExceptions.cc.
References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addNode(), edm::ParameterSetDescription::addUntracked(), python.Node::node, edm::ConfigurationDescriptions::setComment(), edm::ParameterSetDescription::setComment(), and edm::ParameterDescriptionNode::setComment().
|
private |
Definition at line 326 of file EnableFloatingPointExceptions.cc.
References echoState(), enableAndDisableExcept(), fpuState_, edm::ModuleDescription::moduleLabel(), reportSettings_, and stateStack_.
Referenced by postModule(), postModuleBeginJob(), postModuleBeginLumi(), postModuleBeginRun(), postModuleEndJob(), postModuleEndLumi(), and postModuleEndRun().
void edm::service::EnableFloatingPointExceptions::postEndJob | ( | ) |
Definition at line 171 of file EnableFloatingPointExceptions.cc.
References echoState(), and reportSettings_.
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModule | ( | ModuleDescription const & | description | ) |
Definition at line 259 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleBeginJob | ( | ModuleDescription const & | description | ) |
Definition at line 187 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleBeginLumi | ( | ModuleDescription const & | description | ) |
Definition at line 235 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleBeginRun | ( | ModuleDescription const & | description | ) |
Definition at line 211 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleEndJob | ( | ModuleDescription const & | description | ) |
Definition at line 199 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleEndLumi | ( | ModuleDescription const & | description | ) |
Definition at line 247 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleEndRun | ( | ModuleDescription const & | description | ) |
Definition at line 223 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
|
private |
Definition at line 295 of file EnableFloatingPointExceptions.cc.
References defaultState_, echoState(), enableAndDisableExcept(), fpuState_, edm::ModuleDescription::moduleLabel(), reportSettings_, stateMap_, and stateStack_.
Referenced by preModule(), preModuleBeginJob(), preModuleBeginLumi(), preModuleBeginRun(), preModuleEndJob(), preModuleEndLumi(), and preModuleEndRun().
void edm::service::EnableFloatingPointExceptions::preModule | ( | ModuleDescription const & | description | ) |
Definition at line 253 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleBeginJob | ( | ModuleDescription const & | description | ) |
Definition at line 181 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleBeginLumi | ( | ModuleDescription const & | description | ) |
Definition at line 229 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleBeginRun | ( | ModuleDescription const & | description | ) |
Definition at line 205 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleEndJob | ( | ModuleDescription const & | description | ) |
Definition at line 193 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleEndLumi | ( | ModuleDescription const & | description | ) |
Definition at line 241 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleEndRun | ( | ModuleDescription const & | description | ) |
Definition at line 217 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
|
private |
Definition at line 362 of file EnableFloatingPointExceptions.cc.
Referenced by EnableFloatingPointExceptions().
|
private |
Definition at line 143 of file EnableFloatingPointExceptions.h.
Referenced by EnableFloatingPointExceptions(), establishModuleEnvironments(), and preActions().
|
private |
Definition at line 142 of file EnableFloatingPointExceptions.h.
Referenced by EnableFloatingPointExceptions(), establishModuleEnvironments(), postActions(), and preActions().
|
private |
Definition at line 146 of file EnableFloatingPointExceptions.h.
Referenced by EnableFloatingPointExceptions(), establishModuleEnvironments(), postActions(), postEndJob(), and preActions().
|
private |
Definition at line 144 of file EnableFloatingPointExceptions.h.
Referenced by establishModuleEnvironments(), and preActions().
|
private |
Definition at line 145 of file EnableFloatingPointExceptions.h.
Referenced by EnableFloatingPointExceptions(), postActions(), and preActions().