#include <EnableFloatingPointExceptions.h>
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:
1. floating-point exceptions (on a module by module basis if desired) 2. precision control on x87 FP processors (obsolete for 64 bit x86_64)
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 120 of file EnableFloatingPointExceptions.h.
Definition at line 123 of file EnableFloatingPointExceptions.h.
edm::service::EnableFloatingPointExceptions::EnableFloatingPointExceptions | ( | ParameterSet const & | pset, |
ActivityRegistry & | registry | ||
) |
Definition at line 79 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 580 of file EnableFloatingPointExceptions.cc.
Referenced by EnableFloatingPointExceptions(), establishModuleEnvironments(), postActions(), postEndJob(), and preActions().
|
private |
Definition at line 532 of file EnableFloatingPointExceptions.cc.
References cond::rpcobimon::current, and filterCSVwithJSON::target.
Referenced by EnableFloatingPointExceptions(), establishModuleEnvironments(), postActions(), and preActions().
|
private |
Definition at line 144 of file EnableFloatingPointExceptions.cc.
References def, defaultState_, echoState(), enableAndDisableExcept(), flags, edm::ParameterSet::getUntrackedParameter(), edm::ParameterSet::getUntrackedParameterSet(), reportSettings_, stateMap_, and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by EnableFloatingPointExceptions().
|
static |
Definition at line 366 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 421 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 462 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 188 of file EnableFloatingPointExceptions.cc.
References echoState(), and reportSettings_.
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleBeginJob | ( | ModuleDescription const & | md | ) |
Definition at line 216 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleBeginStream | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 240 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleConstruction | ( | ModuleDescription const & | md | ) |
Definition at line 204 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleEndJob | ( | ModuleDescription const & | md | ) |
Definition at line 228 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleEndStream | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 252 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleEvent | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 360 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleGlobalBeginLumi | ( | GlobalContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 288 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleGlobalBeginRun | ( | GlobalContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 264 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleGlobalEndLumi | ( | GlobalContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 300 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleGlobalEndRun | ( | GlobalContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 276 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleStreamBeginLumi | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 336 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleStreamBeginRun | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 312 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleStreamEndLumi | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 348 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::postModuleStreamEndRun | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 324 of file EnableFloatingPointExceptions.cc.
References postActions().
Referenced by EnableFloatingPointExceptions().
|
private |
Definition at line 396 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 437 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 210 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleBeginStream | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 234 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleConstruction | ( | ModuleDescription const & | md | ) |
Definition at line 198 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleEndJob | ( | ModuleDescription const & | md | ) |
Definition at line 222 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleEndStream | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 246 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleEvent | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 354 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleGlobalBeginLumi | ( | GlobalContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 282 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleGlobalBeginRun | ( | GlobalContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 258 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleGlobalEndLumi | ( | GlobalContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 294 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleGlobalEndRun | ( | GlobalContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 270 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleStreamBeginLumi | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 330 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleStreamBeginRun | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 306 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleStreamEndLumi | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 342 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
void edm::service::EnableFloatingPointExceptions::preModuleStreamEndRun | ( | StreamContext const & | , |
ModuleCallingContext const & | mcc | ||
) |
Definition at line 318 of file EnableFloatingPointExceptions.cc.
References preActions().
Referenced by EnableFloatingPointExceptions().
|
private |
Definition at line 527 of file EnableFloatingPointExceptions.cc.
Referenced by EnableFloatingPointExceptions().
|
private |
Definition at line 191 of file EnableFloatingPointExceptions.h.
Referenced by EnableFloatingPointExceptions(), establishModuleEnvironments(), postActions(), and preActions().
|
private |
Definition at line 193 of file EnableFloatingPointExceptions.h.
Referenced by EnableFloatingPointExceptions(), establishModuleEnvironments(), postActions(), postEndJob(), and preActions().
|
private |
Definition at line 192 of file EnableFloatingPointExceptions.h.
Referenced by establishModuleEnvironments(), postActions(), and preActions().