CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
edm::service::EnableFloatingPointExceptions Class Reference

Public Types

typedef int fpu_flags_type
 

Public Member Functions

 EnableFloatingPointExceptions (ParameterSet const &pset, ActivityRegistry &registry)
 
void postEndJob ()
 
void postModuleBeginJob (ModuleDescription const &)
 
void postModuleBeginStream (StreamContext const &, ModuleCallingContext const &)
 
void postModuleConstruction (ModuleDescription const &)
 
void postModuleEndJob (ModuleDescription const &md)
 
void postModuleEndStream (StreamContext const &, ModuleCallingContext const &)
 
void postModuleEvent (StreamContext const &, ModuleCallingContext const &)
 
void postModuleGlobalBeginLumi (GlobalContext const &, ModuleCallingContext const &)
 
void postModuleGlobalBeginRun (GlobalContext const &, ModuleCallingContext const &)
 
void postModuleGlobalEndLumi (GlobalContext const &, ModuleCallingContext const &)
 
void postModuleGlobalEndRun (GlobalContext const &, ModuleCallingContext const &)
 
void postModuleStreamBeginLumi (StreamContext const &, ModuleCallingContext const &)
 
void postModuleStreamBeginRun (StreamContext const &, ModuleCallingContext const &)
 
void postModuleStreamEndLumi (StreamContext const &, ModuleCallingContext const &)
 
void postModuleStreamEndRun (StreamContext const &, ModuleCallingContext const &)
 
void preModuleBeginJob (ModuleDescription const &)
 
void preModuleBeginStream (StreamContext const &, ModuleCallingContext const &)
 
void preModuleConstruction (ModuleDescription const &)
 
void preModuleEndJob (ModuleDescription const &md)
 
void preModuleEndStream (StreamContext const &, ModuleCallingContext const &)
 
void preModuleEvent (StreamContext const &, ModuleCallingContext const &)
 
void preModuleGlobalBeginLumi (GlobalContext const &, ModuleCallingContext const &)
 
void preModuleGlobalBeginRun (GlobalContext const &, ModuleCallingContext const &)
 
void preModuleGlobalEndLumi (GlobalContext const &, ModuleCallingContext const &)
 
void preModuleGlobalEndRun (GlobalContext const &, ModuleCallingContext const &)
 
void preModuleStreamBeginLumi (StreamContext const &, ModuleCallingContext const &)
 
void preModuleStreamBeginRun (StreamContext const &, ModuleCallingContext const &)
 
void preModuleStreamEndLumi (StreamContext const &, ModuleCallingContext const &)
 
void preModuleStreamEndRun (StreamContext const &, ModuleCallingContext const &)
 

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_
 

Detailed Description

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 175 of file EnableFloatingPointExceptions.cc.

Member Typedef Documentation

Definition at line 178 of file EnableFloatingPointExceptions.cc.

Constructor & Destructor Documentation

edm::service::EnableFloatingPointExceptions::EnableFloatingPointExceptions ( ParameterSet const &  pset,
ActivityRegistry registry 
)

Definition at line 258 of file EnableFloatingPointExceptions.cc.

Member Function Documentation

void edm::service::EnableFloatingPointExceptions::echoState ( ) const
private

Definition at line 759 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::enableAndDisableExcept ( fpu_flags_type  target)
private

Definition at line 711 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::establishModuleEnvironments ( ParameterSet const &  pset)
private

Definition at line 323 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 545 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::postActions ( ModuleDescription const &  description,
char const *  debugInfo 
)
private

Definition at line 600 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::postActions ( ModuleCallingContext const &  mcc,
char const *  debugInfo 
)
private

Definition at line 641 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::postEndJob ( )

Definition at line 367 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::postModuleBeginJob ( ModuleDescription const &  md)

Definition at line 395 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::postModuleBeginStream ( StreamContext const &  ,
ModuleCallingContext const &  mcc 
)

Definition at line 419 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::postModuleConstruction ( ModuleDescription const &  md)

Definition at line 383 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::postModuleEndJob ( ModuleDescription const &  md)

Definition at line 407 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::postModuleEndStream ( StreamContext const &  ,
ModuleCallingContext const &  mcc 
)

Definition at line 431 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::postModuleEvent ( StreamContext const &  ,
ModuleCallingContext const &  mcc 
)

Definition at line 539 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::postModuleGlobalBeginLumi ( GlobalContext const &  ,
ModuleCallingContext const &  mcc 
)

Definition at line 467 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::postModuleGlobalBeginRun ( GlobalContext const &  ,
ModuleCallingContext const &  mcc 
)

Definition at line 443 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::postModuleGlobalEndLumi ( GlobalContext const &  ,
ModuleCallingContext const &  mcc 
)

Definition at line 479 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::postModuleGlobalEndRun ( GlobalContext const &  ,
ModuleCallingContext const &  mcc 
)

Definition at line 455 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::postModuleStreamBeginLumi ( StreamContext const &  ,
ModuleCallingContext const &  mcc 
)

Definition at line 515 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::postModuleStreamBeginRun ( StreamContext const &  ,
ModuleCallingContext const &  mcc 
)

Definition at line 491 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::postModuleStreamEndLumi ( StreamContext const &  ,
ModuleCallingContext const &  mcc 
)

Definition at line 527 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::postModuleStreamEndRun ( StreamContext const &  ,
ModuleCallingContext const &  mcc 
)

Definition at line 503 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::preActions ( ModuleDescription const &  description,
char const *  debugInfo 
)
private

Definition at line 575 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::preActions ( ModuleCallingContext const &  mcc,
char const *  debugInfo 
)
private

Definition at line 616 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::preModuleBeginJob ( ModuleDescription const &  md)

Definition at line 389 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::preModuleBeginStream ( StreamContext const &  ,
ModuleCallingContext const &  mcc 
)

Definition at line 413 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::preModuleConstruction ( ModuleDescription const &  md)

Definition at line 377 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::preModuleEndJob ( ModuleDescription const &  md)

Definition at line 401 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::preModuleEndStream ( StreamContext const &  ,
ModuleCallingContext const &  mcc 
)

Definition at line 425 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::preModuleEvent ( StreamContext const &  ,
ModuleCallingContext const &  mcc 
)

Definition at line 533 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::preModuleGlobalBeginLumi ( GlobalContext const &  ,
ModuleCallingContext const &  mcc 
)

Definition at line 461 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::preModuleGlobalBeginRun ( GlobalContext const &  ,
ModuleCallingContext const &  mcc 
)

Definition at line 437 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::preModuleGlobalEndLumi ( GlobalContext const &  ,
ModuleCallingContext const &  mcc 
)

Definition at line 473 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::preModuleGlobalEndRun ( GlobalContext const &  ,
ModuleCallingContext const &  mcc 
)

Definition at line 449 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::preModuleStreamBeginLumi ( StreamContext const &  ,
ModuleCallingContext const &  mcc 
)

Definition at line 509 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::preModuleStreamBeginRun ( StreamContext const &  ,
ModuleCallingContext const &  mcc 
)

Definition at line 485 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::preModuleStreamEndLumi ( StreamContext const &  ,
ModuleCallingContext const &  mcc 
)

Definition at line 521 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::preModuleStreamEndRun ( StreamContext const &  ,
ModuleCallingContext const &  mcc 
)

Definition at line 497 of file EnableFloatingPointExceptions.cc.

void edm::service::EnableFloatingPointExceptions::setPrecision ( bool  precisionDouble)
private

Definition at line 706 of file EnableFloatingPointExceptions.cc.

Member Data Documentation

fpu_flags_type edm::service::EnableFloatingPointExceptions::defaultState_
private

Definition at line 246 of file EnableFloatingPointExceptions.cc.

bool edm::service::EnableFloatingPointExceptions::reportSettings_
private

Definition at line 248 of file EnableFloatingPointExceptions.cc.

std::map<std::string, fpu_flags_type> edm::service::EnableFloatingPointExceptions::stateMap_
private

Definition at line 247 of file EnableFloatingPointExceptions.cc.