Public Types | |
typedef int | fpu_flags_type |
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 &) |
void | postActions (ModuleDescription const &, char const *debugInfo) |
void | postActions (ModuleCallingContext const &, char const *debugInfo) |
void | preActions (ModuleDescription const &, char const *debugInfo) |
void | preActions (ModuleCallingContext const &, char const *debugInfo) |
void | setPrecision (bool precisionDouble) |
Private Attributes | |
fpu_flags_type | defaultState_ |
bool | reportSettings_ |
std::map< std::string, fpu_flags_type > | stateMap_ |
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:
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.
Warning. The flags that control the behavior of floating point are globally available. Anything could potentially change them at any point in time, including the module itself and third party code that module calls. In a threading environment if the module waits in the middle of execution and others tasks run on the same thread, they could potentially change the behavior. Also if the module internally creates tasks that run on other threads those will run with whatever settings are on that thread unless special code has been written in the module to set the floating point exception control flags.
Note that we did tests to determine that the floating point exception control of feenableexcept was thread local and therefore could be use with the multithreaded framework. Although the functions in fenv.h that are part of the standard are required to be thread local, we were unable to find any documentation about this for feenableexcept which is an extension of the GCC compiler. Hopefully our test on one machine can be safely extrapolated to all machines ...
Precision control is obsolete in x86_64 architectures and other architectures CMS currently uses (maybe we should remove this part of the service). It has no effect. The x86_64 architecture uses SSE for floating point calculations, not x87. SSE always uses 64 bit precision. Precision control works for x87 floating point calculations 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. (most other CPUs round to 64 bits by default and/or do not allow control of the precision of floating point calculations).
Definition at line 175 of file EnableFloatingPointExceptions.cc.
Definition at line 178 of file EnableFloatingPointExceptions.cc.
edm::service::EnableFloatingPointExceptions::EnableFloatingPointExceptions | ( | ParameterSet const & | pset, |
ActivityRegistry & | registry | ||
) |
Definition at line 258 of file EnableFloatingPointExceptions.cc.
References defaultState_, echoState(), enableAndDisableExcept(), establishModuleEnvironments(), edm::ParameterSet::getUntrackedParameter(), postEndJob(), postModuleBeginJob(), postModuleBeginStream(), postModuleConstruction(), postModuleEndJob(), postModuleEndStream(), postModuleEvent(), postModuleGlobalBeginLumi(), postModuleGlobalBeginRun(), postModuleGlobalEndLumi(), postModuleGlobalEndRun(), postModuleStreamBeginLumi(), postModuleStreamBeginRun(), postModuleStreamEndLumi(), postModuleStreamEndRun(), preModuleBeginJob(), preModuleBeginStream(), preModuleConstruction(), preModuleEndJob(), preModuleEndStream(), preModuleEvent(), preModuleGlobalBeginLumi(), preModuleGlobalBeginRun(), preModuleGlobalEndLumi(), preModuleGlobalEndRun(), preModuleStreamBeginLumi(), preModuleStreamBeginRun(), preModuleStreamEndLumi(), preModuleStreamEndRun(), reportSettings_, setPrecision(), edm::ActivityRegistry::watchPostEndJob(), edm::ActivityRegistry::watchPostModuleBeginJob(), edm::ActivityRegistry::watchPostModuleBeginStream(), edm::ActivityRegistry::watchPostModuleConstruction(), edm::ActivityRegistry::watchPostModuleEndJob(), edm::ActivityRegistry::watchPostModuleEndStream(), edm::ActivityRegistry::watchPostModuleEvent(), edm::ActivityRegistry::watchPostModuleGlobalBeginLumi(), edm::ActivityRegistry::watchPostModuleGlobalBeginRun(), edm::ActivityRegistry::watchPostModuleGlobalEndLumi(), edm::ActivityRegistry::watchPostModuleGlobalEndRun(), edm::ActivityRegistry::watchPostModuleStreamBeginLumi(), edm::ActivityRegistry::watchPostModuleStreamBeginRun(), edm::ActivityRegistry::watchPostModuleStreamEndLumi(), edm::ActivityRegistry::watchPostModuleStreamEndRun(), edm::ActivityRegistry::watchPreModuleBeginJob(), edm::ActivityRegistry::watchPreModuleBeginStream(), edm::ActivityRegistry::watchPreModuleConstruction(), edm::ActivityRegistry::watchPreModuleEndJob(), edm::ActivityRegistry::watchPreModuleEndStream(), edm::ActivityRegistry::watchPreModuleEvent(), edm::ActivityRegistry::watchPreModuleGlobalBeginLumi(), edm::ActivityRegistry::watchPreModuleGlobalBeginRun(), edm::ActivityRegistry::watchPreModuleGlobalEndLumi(), edm::ActivityRegistry::watchPreModuleGlobalEndRun(), edm::ActivityRegistry::watchPreModuleStreamBeginLumi(), edm::ActivityRegistry::watchPreModuleStreamBeginRun(), edm::ActivityRegistry::watchPreModuleStreamEndLumi(), and edm::ActivityRegistry::watchPreModuleStreamEndRun().
|
private |
Definition at line 759 of file EnableFloatingPointExceptions.cc.
Referenced by EnableFloatingPointExceptions(), establishModuleEnvironments(), postActions(), postEndJob(), and preActions().
|
private |
Definition at line 711 of file EnableFloatingPointExceptions.cc.
References filterCSVwithJSON::target.
Referenced by EnableFloatingPointExceptions(), establishModuleEnvironments(), postActions(), and preActions().
|
private |
Definition at line 323 of file EnableFloatingPointExceptions.cc.
References assert(), def, defaultState_, echoState(), enableAndDisableExcept(), flags, edm::ParameterSet::getUntrackedParameter(), edm::ParameterSet::getUntrackedParameterSet(), reportSettings_, stateMap_, and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by EnableFloatingPointExceptions().
|
static |
Definition at line 545 of file EnableFloatingPointExceptions.cc.
References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addNode(), edm::ParameterSetDescription::addUntracked(), edm::ConfigurationDescriptions::setComment(), edm::ParameterSetDescription::setComment(), and edm::ParameterDescriptionNode::setComment().
|
private |
Definition at line 600 of file EnableFloatingPointExceptions.cc.
References defaultState_, echoState(), enableAndDisableExcept(), edm::ModuleDescription::moduleLabel(), and reportSettings_.
Referenced by postModuleBeginJob(), postModuleBeginStream(), postModuleConstruction(), postModuleEndJob(), postModuleEndStream(), postModuleEvent(), postModuleGlobalBeginLumi(), postModuleGlobalBeginRun(), postModuleGlobalEndLumi(), postModuleGlobalEndRun(), postModuleStreamBeginLumi(), postModuleStreamBeginRun(), postModuleStreamEndLumi(), and postModuleStreamEndRun().
|
private |
Definition at line 641 of file EnableFloatingPointExceptions.cc.
References defaultState_, echoState(), enableAndDisableExcept(), edm::ModuleCallingContext::moduleDescription(), edm::ModuleDescription::moduleLabel(), edm::ModuleCallingContext::previousModuleOnThread(), reportSettings_, and stateMap_.
void edm::service::EnableFloatingPointExceptions::postEndJob | ( | ) |
Definition at line 367 of file EnableFloatingPointExceptions.cc.
References echoState(), and reportSettings_.
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleBeginJob | ( | ModuleDescription const & | md | ) |
Definition at line 395 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleBeginStream | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 419 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleConstruction | ( | ModuleDescription const & | md | ) |
Definition at line 383 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleEndJob | ( | ModuleDescription const & | md | ) |
Definition at line 407 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleEndStream | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 431 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleEvent | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 539 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleGlobalBeginLumi | ( | GlobalContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 467 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleGlobalBeginRun | ( | GlobalContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 443 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleGlobalEndLumi | ( | GlobalContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 479 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleGlobalEndRun | ( | GlobalContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 455 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleStreamBeginLumi | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 515 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleStreamBeginRun | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 491 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleStreamEndLumi | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 527 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleStreamEndRun | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 503 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
|
private |
Definition at line 575 of file EnableFloatingPointExceptions.cc.
References defaultState_, echoState(), enableAndDisableExcept(), edm::ModuleDescription::moduleLabel(), reportSettings_, stateMap_, and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by preModuleBeginJob(), preModuleBeginStream(), preModuleConstruction(), preModuleEndJob(), preModuleEndStream(), preModuleEvent(), preModuleGlobalBeginLumi(), preModuleGlobalBeginRun(), preModuleGlobalEndLumi(), preModuleGlobalEndRun(), preModuleStreamBeginLumi(), preModuleStreamBeginRun(), preModuleStreamEndLumi(), and preModuleStreamEndRun().
|
private |
Definition at line 616 of file EnableFloatingPointExceptions.cc.
References defaultState_, echoState(), enableAndDisableExcept(), edm::ModuleCallingContext::moduleDescription(), edm::ModuleDescription::moduleLabel(), reportSettings_, stateMap_, and AlCaHLTBitMon_QueryRunRegistry::string.
void edm::service::EnableFloatingPointExceptions::preModuleBeginJob | ( | ModuleDescription const & | md | ) |
Definition at line 389 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleBeginStream | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 413 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleConstruction | ( | ModuleDescription const & | md | ) |
Definition at line 377 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleEndJob | ( | ModuleDescription const & | md | ) |
Definition at line 401 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleEndStream | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 425 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleEvent | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 533 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleGlobalBeginLumi | ( | GlobalContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 461 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleGlobalBeginRun | ( | GlobalContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 437 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleGlobalEndLumi | ( | GlobalContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 473 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleGlobalEndRun | ( | GlobalContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 449 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleStreamBeginLumi | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 509 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleStreamBeginRun | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 485 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleStreamEndLumi | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 521 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleStreamEndRun | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 497 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
|
private |
Definition at line 706 of file EnableFloatingPointExceptions.cc.
Referenced by EnableFloatingPointExceptions().
|
private |
Definition at line 246 of file EnableFloatingPointExceptions.cc.
Referenced by EnableFloatingPointExceptions(), establishModuleEnvironments(), postActions(), and preActions().
|
private |
Definition at line 248 of file EnableFloatingPointExceptions.cc.
Referenced by EnableFloatingPointExceptions(), establishModuleEnvironments(), postActions(), postEndJob(), and preActions().
|
private |
Definition at line 247 of file EnableFloatingPointExceptions.cc.
Referenced by establishModuleEnvironments(), postActions(), and preActions().