The Gaudi Framework  v30r3 (a5ef0a68)
CPUCruncher Class Reference

A class that implements a search for prime numbers. More...

#include <src/CPUCruncher.h>

Inheritance diagram for CPUCruncher:
Collaboration diagram for CPUCruncher:

Public Types

typedef tbb::concurrent_hash_map< std::string, unsigned int > CHM
 
- Public Types inherited from Algorithm
using Factory = Gaudi::PluginService::Factory< IAlgorithm *(const std::string &, ISvcLocator *)>
 
- Public Types inherited from extends< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >, IDataHandleHolder >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 

Public Member Functions

bool isClonable () const override
 
StatusCode execute () override
 the execution of the algorithm More...
 
StatusCode initialize () override
 Its initialization. More...
 
StatusCode finalize () override
 the finalization of the algorithm More...
 
double get_runtime () const
 
 CPUCruncher (const std::string &name, ISvcLocator *pSvc)
 
virtual ~CPUCruncher ()
 virtual & protected desctrustor More...
 
- Public Member Functions inherited from GaudiAlgorithm
StatusCode initialize () override
 standard initialization method More...
 
StatusCode execute () override
 standard execution method More...
 
StatusCode finalize () override
 standard finalization method More...
 
StatusCode sysExecute (const EventContext &ctx) override
 the generic actions for the execution. More...
 
void put (IDataProviderSvc *svc, DataObject *object, const std::string &address, const bool useRootInTES=true) const
 Register a data object or container into Gaudi Event Transient Store. More...
 
void put (IDataProviderSvc *svc, std::unique_ptr< DataObject > object, const std::string &address, const bool useRootInTES=true) const
 
const DataObjectput (DataObject *object, const std::string &address, const bool useRootInTES=true) const
 Register a data object or container into Gaudi Event Transient Store. More...
 
const DataObjectput (std::unique_ptr< DataObject > object, const std::string &address, const bool useRootInTES=true) const
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type get (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Templated access to the data in Gaudi Transient Store. More...
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type getIfExists (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Templated access to the data in Gaudi Transient Store. More...
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type get (const std::string &location, const bool useRootInTES=true) const
 Templated access to the data from Gaudi Event Transient Store. More...
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type getIfExists (const std::string &location, const bool useRootInTES=true) const
 Templated access to the data in Gaudi Transient Store. More...
 
template<class TYPE >
TYPE * getDet (IDataProviderSvc *svc, const std::string &location) const
 Templated access to the detector data from the Gaudi Detector Transient Store. More...
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type getDetIfExists (IDataProviderSvc *svc, const std::string &location) const
 Templated access to the detector data from the Gaudi Detector Transient Store. More...
 
template<class TYPE >
TYPE * getDet (const std::string &location) const
 Templated access to the detector data from the Gaudi Detector Transient Store. More...
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type getDetIfExists (const std::string &location) const
 Templated access to the detector data from the Gaudi Detector Transient Store. More...
 
template<class TYPE >
bool exist (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Check the existence of a data object or container in the Gaudi Transient Event Store. More...
 
template<class TYPE >
bool exist (const std::string &location, const bool useRootInTES=true) const
 Check the existence of a data object or container in the Gaudi Transient Event Store. More...
 
template<class TYPE >
bool existDet (IDataProviderSvc *svc, const std::string &location) const
 Check the existence of detector objects in the Gaudi Transient Detector Store. More...
 
template<class TYPE >
bool existDet (const std::string &location) const
 Check the existence of detector objects in the Gaudi Transient Detector Store. More...
 
template<class TYPE , class TYPE2 >
Gaudi::Utils::GetData< TYPE >::return_type getOrCreate (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Get the existing data object from Gaudi Event Transient store. More...
 
template<class TYPE , class TYPE2 >
Gaudi::Utils::GetData< TYPE >::return_type getOrCreate (const std::string &location, const bool useRootInTES=true) const
 Get the existing data object from Gaudi Event Transient store. More...
 
 GaudiAlgorithm (const std::string &name, ISvcLocator *pSvcLocator)
 Standard constructor. More...
 
 GaudiAlgorithm (const GaudiAlgorithm &)=delete
 
GaudiAlgorithmoperator= (const GaudiAlgorithm &)=delete
 
SmartIF< INTupleSvc > & evtColSvc () const
 Access the standard event collection service. More...
 
- Public Member Functions inherited from GaudiCommon< Algorithm >
Gaudi::Utils::GetData< TYPE >::return_type get (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Templated access to the data in Gaudi Transient Store. More...
 
Gaudi::Utils::GetData< TYPE >::return_type getIfExists (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Quicker version of the get function which bypasses the check on the retrieved data. More...
 
bool exist (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Check the existence of a data object or container in the Gaudi Transient Event Store. More...
 
Gaudi::Utils::GetData< TYPE >::return_type getOrCreate (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Get the existing data object from Gaudi Event Transient store. More...
 
DataObjectput (IDataProviderSvc *svc, std::unique_ptr< DataObject > object, const std::string &location, const bool useRootInTES=true) const
 Register a data object or container into Gaudi Event Transient Store. More...
 
DataObjectput (IDataProviderSvc *svc, DataObject *object, const std::string &location, const bool useRootInTES=true) const
 
TOOL * tool (const std::string &type, const std::string &name, const IInterface *parent=0, bool create=true) const
 Useful method for the easy location of tools. More...
 
TOOL * tool (const std::string &type, const IInterface *parent=0, bool create=true) const
 A useful method for the easy location of tools. More...
 
SmartIF< SERVICE > svc (const std::string &name, const bool create=true) const
 A useful method for the easy location of services. More...
 
IUpdateManagerSvcupdMgrSvc () const
 Short-cut to locate the Update Manager Service. More...
 
WARN_UNUSED StatusCode Error (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
 Print the error message and return with the given StatusCode. More...
 
WARN_UNUSED StatusCode Warning (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
 Print the warning message and return with the given StatusCode. More...
 
WARN_UNUSED StatusCode Info (const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const size_t mx=10) const
 Print the info message and return with the given StatusCode. More...
 
WARN_UNUSED StatusCode Print (const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const MSG::Level lev=MSG::INFO) const
 Print the message and return with the given StatusCode. More...
 
void Assert (const bool ok, const std::string &message="", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Assertion - throw exception if the given condition is not fulfilled. More...
 
void Assert (const bool ok, const char *message, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Assertion - throw exception if the given condition is not fulfilled. More...
 
void Exception (const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Create and (re)-throw a given GaudiException. More...
 
void Exception (const std::string &msg, const std::exception &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Create and (re)-throw a given exception. More...
 
void Exception (const std::string &msg="no message", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Create and throw an exception with the given message. More...
 
const Statistics counters () const
 accessor to all counters More...
 
StatEntitycounter (const std::string &tag) const
 accessor to certain counter by name More...
 
StatEntitycounter (const std::string &tag)
 
void registerCounter (const std::string &tag, Gaudi::Accumulators::PrintableCounter &r)
 
bool typePrint () const
 Insert the actual C++ type of the algorithm/tool in the messages ? More...
 
bool propsPrint () const
 Print properties at initialization ? More...
 
bool statPrint () const
 Print statistical counters at finalization ? More...
 
bool errorsPrint () const
 Print error counters at finalization ? More...
 
long printStat (const MSG::Level level=MSG::ALWAYS) const
 perform the actual printout of statistical counters More...
 
long printErrors (const MSG::Level level=MSG::ALWAYS) const
 perform the actual printout of error counters More...
 
long printProps (const MSG::Level level=MSG::ALWAYS) const
 perform the actual printout of properties More...
 
void registerCondition (const std::string &condition, StatusCode(CallerClass::*mf)()=nullptr)
 register the current instance to the UpdateManagerSvc as a consumer for a condition. More...
 
void registerCondition (const std::string &condition, CondType *&condPtrDest, StatusCode(CallerClass::*mf)()=NULL)
 register the current instance to the UpdateManagerSvc as a consumer for a condition. More...
 
void registerCondition (char *condition, StatusCode(CallerClass::*mf)()=NULL)
 just to avoid conflicts with the version using a pointer to a template class. More...
 
void registerCondition (TargetClass *condition, StatusCode(CallerClass::*mf)()=NULL)
 register the current instance to the UpdateManagerSvc as a consumer for a condition. More...
 
StatusCode runUpdate ()
 asks the UpdateManagerSvc to perform an update of the instance (if needed) without waiting the next BeginEvent incident. More...
 
 GaudiCommon (const std::string &name, ISvcLocator *pSvcLocator)
 Algorithm constructor - the SFINAE constraint below ensures that this is constructor is only defined if PBASE derives from Algorithm. More...
 
 GaudiCommon (const std::string &type, const std::string &name, const IInterface *ancestor)
 Tool constructor - SFINAE-ed to insure this constructor is only defined if PBASE derives from AlgTool. More...
 
StatusCode initialize () override
 standard initialization method More...
 
StatusCode finalize () override
 standard finalization method More...
 
StatusCode release (const IInterface *interface) const
 Manual forced (and 'safe') release of the active tool or service. More...
 
const Servicesservices () const
 get the list of aquired services More...
 
const std::stringcontext () const
 Returns the "context" string. Used to identify different processing states. More...
 
const std::stringrootInTES () const
 Returns the "rootInTES" string. More...
 
const std::string fullTESLocation (const std::string &location, const bool useRootInTES) const
 Returns the full correct event location given the rootInTes settings. More...
 
- Public Member Functions inherited from Algorithm
 Algorithm (const std::string &name, ISvcLocator *svcloc, const std::string &version=PACKAGE_VERSION)
 Constructor. More...
 
StatusCode sysStart () override
 Reinitialization method invoked by the framework. More...
 
StatusCode sysInitialize () override
 Initialization method invoked by the framework. More...
 
StatusCode sysReinitialize () override
 Reinitialization method invoked by the framework. More...
 
StatusCode sysRestart () override
 Restart method invoked by the framework. More...
 
StatusCode sysExecute (const EventContext &ctx) override
 The actions to be performed by the algorithm on an event. More...
 
StatusCode sysStop () override
 System stop. More...
 
StatusCode sysFinalize () override
 System finalization. More...
 
StatusCode sysBeginRun () override
 beginRun method invoked by the framework. More...
 
StatusCode sysEndRun () override
 endRun method invoked by the framework. More...
 
const std::stringname () const override
 The identifying name of the algorithm object. More...
 
const Gaudi::StringKeynameKey () const override
 
const std::stringtype () const override
 The type of the algorithm object. More...
 
void setType (const std::string &type) override
 
const std::stringversion () const override
 
unsigned int index () const override
 
StatusCode configure () override
 Dummy implementation of IStateful::configure() method. More...
 
StatusCode terminate () override
 Dummy implementation of IStateful::terminate() method. More...
 
StatusCode initialize () override
 the default (empty) implementation of IStateful::initialize() method More...
 
StatusCode start () override
 the default (empty) implementation of IStateful::start() method More...
 
StatusCode stop () override
 the default (empty) implementation of IStateful::stop() method More...
 
StatusCode finalize () override
 the default (empty) implementation of IStateful::finalize() method More...
 
StatusCode reinitialize () override
 the default (empty) implementation of IStateful::reinitialize() method More...
 
StatusCode restart () override
 the default (empty) implementation of IStateful::restart() method More...
 
Gaudi::StateMachine::State FSMState () const override
 returns the current state of the algorithm More...
 
Gaudi::StateMachine::State targetFSMState () const override
 returns the state the algorithm will be in after the ongoing transition More...
 
bool isExecuted () const override
 Has this algorithm been executed since the last reset? More...
 
void setExecuted (bool state) const override
 Set the executed flag to the specified state. More...
 
void resetExecuted () override
 Reset the executed state of the Algorithm for the duration of the current event. More...
 
StatusCode beginRun () override
 Algorithm begin run. More...
 
StatusCode endRun () override
 Algorithm end run. This method is called at the end of the event loop. More...
 
bool isEnabled () const override
 Is this algorithm enabled or disabled? More...
 
bool isSequence () const override
 Are we a Sequence? More...
 
bool filterPassed () const override
 Did this algorithm pass or fail its filter criterion for the last event? More...
 
void setFilterPassed (bool state) const override
 Set the filter passed flag to the specified state. More...
 
unsigned int errorCount () const
 Get the number of failures of the algorithm. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
SmartIF< IServiceservice (const std::string &name, const bool createIf=true, const bool quiet=false) const
 Return a pointer to the service identified by name (or "type/name") More...
 
template<class T >
SmartIF< T > service (const std::string &name, bool createIf=true, bool quiet=false) const
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
SmartIF< IChronoStatSvc > & chronoSvc () const
 The standard Chrono & Stat service, Return a pointer to the service if present. More...
 
SmartIF< IChronoStatSvc > & chronoStatService () const
 
SmartIF< IDataProviderSvc > & detSvc () const
 The standard detector data service. More...
 
SmartIF< IDataProviderSvc > & detDataService () const
 
SmartIF< IConversionSvc > & detCnvSvc () const
 The standard detector data persistency conversion service. More...
 
SmartIF< IConversionSvc > & detDataCnvService () const
 
SmartIF< IDataProviderSvc > & eventSvc () const
 The standard event data service. More...
 
SmartIF< IDataProviderSvc > & evtSvc () const
 shortcut for method eventSvc More...
 
SmartIF< IDataProviderSvc > & eventDataService () const
 
SmartIF< IConversionSvc > & eventCnvSvc () const
 The standard event data persistency conversion service. More...
 
SmartIF< IConversionSvc > & eventDataCnvService () const
 
SmartIF< IHistogramSvc > & histoSvc () const
 The standard histogram service. More...
 
SmartIF< IHistogramSvc > & histogramDataService () const
 
SmartIF< INTupleSvc > & ntupleSvc () const
 The standard N tuple service. More...
 
SmartIF< INTupleSvc > & ntupleService () const
 
SmartIF< IRndmGenSvc > & randSvc () const
 The standard RandomGen service, Return a pointer to the service if present. More...
 
SmartIF< IToolSvc > & toolSvc () const
 The standard ToolSvc service, Return a pointer to the service if present. More...
 
SmartIF< IExceptionSvc > & exceptionSvc () const
 Get the exception Service. More...
 
SmartIF< IAlgContextSvc > & contextSvc () const
 get Algorithm Context Service More...
 
SmartIF< ITimelineSvc > & timelineSvc () const
 
SmartIF< ISvcLocator > & serviceLocator () const override
 The standard service locator. More...
 
SmartIF< ISvcLocator > & svcLoc () const
 shortcut for method serviceLocator More...
 
SmartIF< IHiveWhiteBoard > & whiteboard () const
 
SmartIF< IAlgExecStateSvc > & algExecStateSvc () const
 
bool registerContext () const
 register for Algorithm Context Service? More...
 
StatusCode createSubAlgorithm (const std::string &type, const std::string &name, Algorithm *&pSubAlg)
 Create a sub algorithm. More...
 
const std::vector< Algorithm * > * subAlgorithms () const
 List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms. More...
 
std::vector< Algorithm * > * subAlgorithms ()
 List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms. More...
 
StatusCode setProperties ()
 Set the algorithm's properties. More...
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none")
 
SmartIF< IMonitorSvc > & monitorSvc () const
 Access the monitor service. More...
 
template<class T >
void declareInfo (const std::string &name, const T &var, const std::string &desc) const
 Declare monitoring information. More...
 
void declareInfo (const std::string &name, const std::string &format, const void *var, int size, const std::string &desc) const
 Declare monitoring information (special case) More...
 
const EventContextgetContext () const override
 get the context More...
 
void acceptDHVisitor (IDataHandleVisitor *) const override
 
void registerTool (IAlgTool *tool) const
 
void deregisterTool (IAlgTool *tool) const
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, bool createIf=true)
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
 
template<class T >
void addToolsArray (ToolHandleArray< T > &hndlArr)
 
const std::vector< IAlgTool * > & tools () const
 
bool isIOBound () const
 
void setIOBound (bool value)
 
unsigned int cardinality () const override
 Return the cardinality. More...
 
const std::vector< std::string > & neededResources () const override
 
std::ostreamtoControlFlowExpression (std::ostream &os) const override
 Produce string represention of the control flow expression. More...
 
- Public Member Functions inherited from DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >
std::vector< Gaudi::DataHandle * > inputHandles () const override
 
std::vector< Gaudi::DataHandle * > outputHandles () const override
 
virtual const DataObjIDCollextraInputDeps () const override
 
virtual const DataObjIDCollextraOutputDeps () const override
 
void declare (Gaudi::DataHandle &handle) override
 
void renounce (Gaudi::DataHandle &handle) override
 
const DataObjIDCollinputDataObjs () const override
 
const DataObjIDColloutputDataObjs () const override
 
void addDependency (const DataObjID &id, const Gaudi::DataHandle::Mode &mode) override
 
- Public Member Functions inherited from extends< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >, IDataHandleHolder >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p) override
 set the property form another property More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 set the property from name and the value More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &name) const override
 get the property by name More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (const std::string &name) const override
 Return true if we have a property with the given name. More...
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const
 Backward compatibility function for getting the output level. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 

Private Member Functions

 CPUCruncher ()
 the default constructor is disabled More...
 
 CPUCruncher (const CPUCruncher &)
 the copy constructor is disabled More...
 
CPUCruncheroperator= (const CPUCruncher &)
 the assignement operator is disabled More...
 
void findPrimes (const unsigned long int)
 The CPU intensive function. More...
 
void calibrate ()
 Calibrate. More...
 
long unsigned int getNCaliIters (double)
 
void declareRuntimeRequestedOutputs ()
 Pick up late-attributed data outputs. More...
 

Private Attributes

bool m_declAugmented {false}
 
Gaudi::Property< bool > m_loader {this, "Loader", false, "Declare the algorithm to be a data loader"}
 
Gaudi::Property< std::vector< std::string > > m_inpKeys {this, "inpKeys", {}, ""}
 
Gaudi::Property< std::vector< std::string > > m_outKeys {this, "outKeys", {}, ""}
 
Gaudi::Property< double > m_avg_runtime {this, "avgRuntime", 1., "Average runtime of the module."}
 
Gaudi::Property< double > m_var_runtime {this, "varRuntime", 0.01, "Variance of the runtime of the module."}
 
Gaudi::Property< bool > m_local_rndm_gen {this, "localRndm", true, "Decide if the local random generator is to be used"}
 
Gaudi::Property< bool > m_shortCalib {this, "shortCalib", false, "Enable coarse grained calibration"}
 
Gaudi::Property< unsigned int > m_rwRepetitions {this, "RwRepetitions", 1, "Increase access to the WB"}
 
Gaudi::Property< float > m_sleepFraction
 
Gaudi::Property< bool > m_invertCFD {this, "InvertDecision", false, "Invert control flow decision."}
 
Gaudi::Property< unsigned int > m_failNEvents {this, "FailNEvents", 0, "Return FAILURE on every Nth event"}
 
const uint MAX_INPUTS = 40
 
const uint MAX_OUTPUTS = 10
 
std::vector< DataObjectHandle< DataObject > * > m_inputHandles
 
std::vector< DataObjectHandle< DataObject > * > m_outputHandles
 

Static Private Attributes

static std::vector< unsigned int > m_niters_vect
 
static std::vector< double > m_times_vect
 
static CHM m_name_ncopies_map
 

Additional Inherited Members

- Public Attributes inherited from Algorithm
friend AlgorithmManager
 
- Protected Types inherited from GaudiCommon< Algorithm >
using base_class = Algorithm
 
typedef std::map< std::string, StatEntityStatisticsOwn
 the actual type of general counters More...
 
typedef std::map< std::string, std::reference_wrapper< Gaudi::Accumulators::PrintableCounter > > Statistics
 
typedef std::map< std::string, unsigned int > Counter
 the actual type error/warning counter More...
 
typedef std::vector< IAlgTool * > AlgTools
 storage for active tools More...
 
typedef std::vector< SmartIF< IService > > Services
 storage for active services More...
 
- Protected Member Functions inherited from GaudiCommon< Algorithm >
StatusCode releaseTool (const IAlgTool *tool) const
 manual forced (and 'safe') release of the tool More...
 
StatusCode releaseSvc (const IInterface *svc) const
 manual forced (and 'safe') release of the service More...
 
- Protected Member Functions inherited from Algorithm
std::vector< IAlgTool * > & tools ()
 
bool isInitialized () const override
 Has the Algorithm already been initialized? More...
 
bool isFinalized () const override
 Has the Algorithm already been finalized? More...
 
void setIndex (const unsigned int &idx) override
 set instantiation index of Alg More...
 
AlgExecStateexecState (const EventContext &ctx) const
 reference to AlgExecState of Alg More...
 
- Protected Member Functions inherited from DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >
void initDataHandleHolder ()
 initializes all handles - called by the sysInitialize method of any descendant of this More...
 
- Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >
Gaudi::Details::PropertyBaseproperty (const std::string &name) const
 
- Protected Member Functions inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from GaudiCommon< Algorithm >
SmartIF< ICounterSummarySvcm_counterSummarySvc
 a pointer to the CounterSummarySvc More...
 
- Protected Attributes inherited from Algorithm
std::unique_ptr< IDataHandleVisitorm_updateDataHandles
 Hook for for derived classes to provide a custom visitor for data handles. More...
 
- Protected Attributes inherited from DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >
DataObjIDColl m_inputDataObjs
 
DataObjIDColl m_outputDataObjs
 
- Static Protected Attributes inherited from GaudiCommon< Algorithm >
static const bool IgnoreRootInTES
 Simple definition to be used with the new useRootInTES argument get<TYPE> and put methods. More...
 
static const bool UseRootInTES
 Simple definition to be used with the new useRootInTES argument get<TYPE> and put methods. More...
 

Detailed Description

A class that implements a search for prime numbers.

A lot of allocations are performed on purpose not to stress only the FP unit of the CPU.

Definition at line 18 of file CPUCruncher.h.

Member Typedef Documentation

typedef tbb::concurrent_hash_map<std::string, unsigned int> CPUCruncher::CHM

Definition at line 22 of file CPUCruncher.h.

Constructor & Destructor Documentation

CPUCruncher::CPUCruncher ( const std::string name,
ISvcLocator pSvc 
)

Definition at line 25 of file CPUCruncher.cpp.

27  : GaudiAlgorithm( name, pSvc )
28 {
29 
30  declareProperty( "NIterationsVect", m_niters_vect, "Number of iterations for the calibration." );
31  declareProperty( "NTimesVect", m_times_vect, "Number of seconds for the calibration." );
32 
33  // Register the algo in the static concurrent hash map in order to
34  // monitor the # of copies
35  CHM::accessor name_ninstances;
36  m_name_ncopies_map.insert( name_ninstances, name );
37  name_ninstances->second += 1;
38 }
static std::vector< unsigned int > m_niters_vect
Definition: CPUCruncher.h:75
static CHM m_name_ncopies_map
Definition: CPUCruncher.h:85
static std::vector< double > m_times_vect
Definition: CPUCruncher.h:76
Gaudi::Details::PropertyBase * declareProperty(const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
Definition: Algorithm.h:370
GaudiAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Standard constructor.
CPUCruncher::~CPUCruncher ( )
virtual

virtual & protected desctrustor

Definition at line 40 of file CPUCruncher.cpp.

41 {
42  for ( uint i = 0; i < m_inputHandles.size(); ++i ) delete m_inputHandles[i];
43 
44  for ( uint i = 0; i < m_outputHandles.size(); ++i ) delete m_outputHandles[i];
45 }
std::vector< DataObjectHandle< DataObject > * > m_outputHandles
Definition: CPUCruncher.h:83
std::vector< DataObjectHandle< DataObject > * > m_inputHandles
Definition: CPUCruncher.h:82
T size(T...args)
CPUCruncher::CPUCruncher ( )
private

the default constructor is disabled

CPUCruncher::CPUCruncher ( const CPUCruncher )
private

the copy constructor is disabled

Member Function Documentation

void CPUCruncher::calibrate ( )
private

Calibrate.

Definition at line 86 of file CPUCruncher.cpp.

87 {
88  m_niters_vect = {0, 500, 600, 700, 800, 1000, 1300, 1600, 2000, 2300, 2600, 3000, 3300, 3500, 3900,
89  4200, 5000, 6000, 8000, 10000, 12000, 15000, 17000, 20000, 25000, 30000, 35000, 40000, 60000};
90  if ( !m_shortCalib ) {
91  m_niters_vect.push_back( 100000 );
92  m_niters_vect.push_back( 200000 );
93  }
94 
96  m_times_vect[0] = 0.;
97 
98  info() << "Starting calibration..." << endmsg;
99  for ( unsigned int i = 1; i < m_niters_vect.size(); ++i ) {
100  unsigned long niters = m_niters_vect[i];
101  unsigned int trials = 30;
102  do {
103  auto start_cali = tbb::tick_count::now();
104  findPrimes( niters );
105  auto stop_cali = tbb::tick_count::now();
106  double deltat = ( stop_cali - start_cali ).seconds();
107  m_times_vect[i] = deltat;
108  DEBUG_MSG << "Calibration: # iters = " << niters << " => " << deltat << endmsg;
109  trials--;
110  } while ( trials > 0 and m_times_vect[i] < m_times_vect[i - 1] ); // make sure that they are monotonic
111  }
112  info() << "Calibration finished!" << endmsg;
113 }
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
void findPrimes(const unsigned long int)
The CPU intensive function.
T resize(T...args)
T push_back(T...args)
static std::vector< unsigned int > m_niters_vect
Definition: CPUCruncher.h:75
static std::vector< double > m_times_vect
Definition: CPUCruncher.h:76
#define DEBUG_MSG
Definition: CPUCruncher.cpp:18
T size(T...args)
Gaudi::Property< bool > m_shortCalib
Definition: CPUCruncher.h:66
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
void CPUCruncher::declareRuntimeRequestedOutputs ( )
private

Pick up late-attributed data outputs.

Definition at line 200 of file CPUCruncher.cpp.

201 {
202  //
203  for ( const auto& k : outputDataObjs() ) {
204  auto outputHandle = new DataObjectHandle<DataObject>( k, Gaudi::DataHandle::Writer, this );
205  VERBOSE_MSG << "found late-attributed output: " << outputHandle->objKey() << endmsg;
206  m_outputHandles.push_back( outputHandle );
207  declareProperty( "dummy_out_" + outputHandle->objKey(), *( m_outputHandles.back() ) );
208  }
209 
211 
212  m_declAugmented = true;
213 }
void initDataHandleHolder()
initializes all handles - called by the sysInitialize method of any descendant of this ...
std::vector< DataObjectHandle< DataObject > * > m_outputHandles
Definition: CPUCruncher.h:83
#define VERBOSE_MSG
Definition: CPUCruncher.cpp:21
T push_back(T...args)
T back(T...args)
Gaudi::Details::PropertyBase * declareProperty(const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
Definition: Algorithm.h:370
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
bool m_declAugmented
Definition: CPUCruncher.h:57
StatusCode CPUCruncher::execute ( )
override

the execution of the algorithm

Definition at line 217 of file CPUCruncher.cpp.

218 {
219 
221 
222  float crunchtime;
223 
224  if ( m_local_rndm_gen ) {
225  /* This will disappear with a thread safe random number generator service.
226  * Use basic Box-Muller to generate Gaussian random numbers.
227  * The quality is not good for in depth study given that the generator is a
228  * linear congruent.
229  * Throw away basically a free number: we are in a cpu cruncher after all.
230  * The seed is taken from the clock, but we could assign a seed per module to
231  * ensure reproducibility.
232  *
233  * This is not an overkill but rather an exercise towards a thread safe
234  * random number generation.
235  */
236 
237  auto getGausRandom = []( double mean, double sigma ) -> double {
238 
239  unsigned int seed = std::clock();
240 
241  auto getUnifRandom = []( unsigned int& seed ) -> double {
242  // from "Numerical Recipes"
243  constexpr unsigned int m = 232;
244  constexpr unsigned int a = 1664525;
245  constexpr unsigned int c = 1013904223;
246  seed = ( a * seed + c ) % m;
247  const double unif = double( seed ) / m;
248  return unif;
249  };
250 
251  double unif1, unif2;
252  do {
253  unif1 = getUnifRandom( seed );
254  unif2 = getUnifRandom( seed );
255  } while ( unif1 == 0. );
256 
257  const double normal = sqrt( -2. * log( unif1 ) ) * cos( 2 * M_PI * unif2 );
258 
259  return normal * sigma + mean;
260  };
261 
262  crunchtime = fabs( getGausRandom( m_avg_runtime * ( 1. - m_sleepFraction ), m_var_runtime ) );
263  // End Of temp block
264  } else {
265  // Should be a member.
267  crunchtime = std::fabs( rndmgaus() );
268  }
269 
270  // Prepare to sleep (even if we won't enter the following if clause for sleeping).
271  // This is needed to distribute evenly among all algorithms the overhead (around sleeping) which is harmful when
272  // trying to achieve uniform distribution of algorithm timings.
273  const double dreamtime = m_avg_runtime * m_sleepFraction;
274  const std::chrono::duration<double> dreamtime_duration( dreamtime );
275  tbb::tick_count startSleeptbb;
276  tbb::tick_count endSleeptbb;
277 
278  // Start to measure the total time here, together with the dreaming process straight ahead
279  tbb::tick_count starttbb = tbb::tick_count::now();
280 
281  // If the algorithm was set as I/O-bound, we will replace requested part of crunching with plain sleeping
282  if ( isIOBound() ) {
283  // in this block (and not in other places around) msgLevel is checked for the same reason as above, when
284  // preparing to sleep several lines above: to reduce as much as possible the overhead around sleeping
285  DEBUG_MSG << "Dreaming time will be: " << dreamtime << endmsg;
286 
287  ON_DEBUG startSleeptbb = tbb::tick_count::now();
288  std::this_thread::sleep_for( dreamtime_duration );
289  ON_DEBUG endSleeptbb = tbb::tick_count::now();
290 
291  // actual sleeping time can be longer due to scheduling or resource contention delays
292  ON_DEBUG
293  {
294  const double actualDreamTime = ( endSleeptbb - startSleeptbb ).seconds();
295  debug() << "Actual dreaming time was: " << actualDreamTime << "s" << endmsg;
296  }
297  } // end of "sleeping block"
298 
299  DEBUG_MSG << "Crunching time will be: " << crunchtime << endmsg;
301  DEBUG_MSG << "Start event " << context.evt() << " in slot " << context.slot() << " on pthreadID " << std::hex
302  << pthread_self() << std::dec << endmsg;
303 
304  VERBOSE_MSG << "inputs number: " << m_inputHandles.size() << endmsg;
305  for ( auto& inputHandle : m_inputHandles ) {
306  if ( !inputHandle->isValid() ) continue;
307 
308  VERBOSE_MSG << "get from TS: " << inputHandle->objKey() << endmsg;
309  DataObject* obj = nullptr;
310  for ( unsigned int i = 0; i < m_rwRepetitions; ++i ) {
311  obj = inputHandle->get();
312  }
313  if ( obj == nullptr ) error() << "A read object was a null pointer." << endmsg;
314  }
315 
316  const unsigned long n_iters = getNCaliIters( crunchtime );
317  findPrimes( n_iters );
318 
319  // Return error on fraction of events if configured
320  if ( m_failNEvents > 0 && context.evt() > 0 && ( context.evt() % m_failNEvents ) == 0 ) {
321  return StatusCode::FAILURE;
322  }
323 
324  VERBOSE_MSG << "outputs number: " << m_outputHandles.size() << endmsg;
325  for ( auto& outputHandle : m_outputHandles ) {
326  if ( !outputHandle->isValid() ) continue;
327 
328  VERBOSE_MSG << "put to TS: " << outputHandle->objKey() << endmsg;
329  outputHandle->put( new DataObject() );
330  }
331 
332  tbb::tick_count endtbb = tbb::tick_count::now();
333 
334  const double actualRuntime = ( endtbb - starttbb ).seconds();
335 
336  DEBUG_MSG << "Finish event " << context.evt()
337  // << " on pthreadID " << context.m_thread_id
338  << " in " << actualRuntime << " seconds" << endmsg;
339 
340  DEBUG_MSG << "Timing: ExpectedCrunchtime= " << crunchtime << " ExpectedDreamtime= " << dreamtime
341  << " ActualTotalRuntime= " << actualRuntime << " Ratio= " << ( crunchtime + dreamtime ) / actualRuntime
342  << " Niters= " << n_iters << endmsg;
343 
345 
346  return StatusCode::SUCCESS;
347 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
SmartIF< IRndmGenSvc > & randSvc() const
The standard RandomGen service, Return a pointer to the service if present.
Definition: Algorithm.cpp:827
Gaudi::Property< float > m_sleepFraction
Definition: CPUCruncher.h:68
void setFilterPassed(bool state) const override
Set the filter passed flag to the specified state.
Definition: Algorithm.cpp:791
ContextID_t slot() const
Definition: EventContext.h:40
Gaudi::Property< bool > m_loader
Definition: CPUCruncher.h:58
void findPrimes(const unsigned long int)
The CPU intensive function.
T clock(T...args)
Gaudi::Property< unsigned int > m_rwRepetitions
Definition: CPUCruncher.h:67
T sleep_for(T...args)
const std::string & context() const
Returns the "context" string. Used to identify different processing states.
Definition: GaudiCommon.h:748
Parameters for the Gauss random number generation.
std::vector< DataObjectHandle< DataObject > * > m_outputHandles
Definition: CPUCruncher.h:83
This class represents an entry point to all the event specific data.
Definition: EventContext.h:24
long unsigned int getNCaliIters(double)
#define VERBOSE_MSG
Definition: CPUCruncher.cpp:21
ContextEvt_t evt() const
Definition: EventContext.h:39
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
constexpr double m
Definition: SystemOfUnits.h:94
Gaudi::Property< bool > m_invertCFD
Definition: CPUCruncher.h:71
std::vector< DataObjectHandle< DataObject > * > m_inputHandles
Definition: CPUCruncher.h:82
GAUDI_API const EventContext & currentContext()
T cos(T...args)
T fabs(T...args)
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
#define DEBUG_MSG
Definition: CPUCruncher.cpp:18
T size(T...args)
void declareRuntimeRequestedOutputs()
Pick up late-attributed data outputs.
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Gaudi::Property< double > m_avg_runtime
Definition: CPUCruncher.h:63
bool isIOBound() const
Definition: Algorithm.h:476
Gaudi::Property< unsigned int > m_failNEvents
Definition: CPUCruncher.h:72
T hex(T...args)
T sqrt(T...args)
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi::Property< bool > m_local_rndm_gen
Definition: CPUCruncher.h:65
Gaudi::Property< double > m_var_runtime
Definition: CPUCruncher.h:64
#define ON_DEBUG
Definition: CPUCruncher.cpp:17
bool m_declAugmented
Definition: CPUCruncher.h:57
StatusCode CPUCruncher::finalize ( )
override

the finalization of the algorithm

Definition at line 351 of file CPUCruncher.cpp.

352 {
353  MsgStream log( msgSvc(), name() );
354 
355  unsigned int ninstances;
356 
357  {
358  CHM::const_accessor const_name_ninstances;
359  m_name_ncopies_map.find( const_name_ninstances, name() );
360  ninstances = const_name_ninstances->second;
361  }
362 
363  constexpr double s2ms = 1000.;
364  // do not show repetitions
365  if ( ninstances != 0 ) {
366  info() << "Summary: name= " << name() << "\t avg_runtime= " << m_avg_runtime * s2ms << "\t n_clones= " << ninstances
367  << endmsg;
368 
369  CHM::accessor name_ninstances;
370  m_name_ncopies_map.find( name_ninstances, name() );
371  name_ninstances->second = 0;
372  }
373 
374  return GaudiAlgorithm::finalize();
375 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:765
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
static CHM m_name_ncopies_map
Definition: CPUCruncher.h:85
StatusCode finalize() override
standard finalization method
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Gaudi::Property< double > m_avg_runtime
Definition: CPUCruncher.h:63
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
void CPUCruncher::findPrimes ( const unsigned long int  n_iterations)
private

The CPU intensive function.

Definition at line 149 of file CPUCruncher.cpp.

150 {
151  // Flag to trigger the allocation
152  bool is_prime;
153 
154  // Let's prepare the material for the allocations
155  unsigned int primes_size = 1;
156  unsigned long* primes = new unsigned long[primes_size];
157  primes[0] = 2;
158 
159  unsigned long i = 2;
160 
161  // Loop on numbers
162  for ( unsigned long int iiter = 0; iiter < n_iterations; iiter++ ) {
163  // Once at max, it returns to 0
164  i += 1;
165 
166  // Check if it can be divided by the smaller ones
167  is_prime = true;
168  for ( unsigned long j = 2; j < i && is_prime; ++j ) {
169  if ( i % j == 0 ) is_prime = false;
170  } // end loop on numbers < than tested one
171 
172  if ( is_prime ) {
173  // copy the array of primes (INEFFICIENT ON PURPOSE!)
174  unsigned int new_primes_size = 1 + primes_size;
175  unsigned long* new_primes = new unsigned long[new_primes_size];
176 
177  for ( unsigned int prime_index = 0; prime_index < primes_size; prime_index++ ) {
178  new_primes[prime_index] = primes[prime_index];
179  }
180  // attach the last prime
181  new_primes[primes_size] = i;
182 
183  // Update primes array
184  delete[] primes;
185  primes = new_primes;
186  primes_size = new_primes_size;
187  } // end is prime
188 
189  } // end of while loop
190 
191  // Fool Compiler optimisations:
192  for ( unsigned int prime_index = 0; prime_index < primes_size; prime_index++ )
193  if ( primes[prime_index] == 4 )
194  debug() << "This does never happen, but it's necessary too fool aggressive compiler optimisations!" << endmsg;
195 
196  delete[] primes;
197 }
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
double CPUCruncher::get_runtime ( ) const
inline

Definition at line 33 of file CPUCruncher.h.

33 { return m_avg_runtime; }
Gaudi::Property< double > m_avg_runtime
Definition: CPUCruncher.h:63
unsigned long CPUCruncher::getNCaliIters ( double  runtime)
private

Definition at line 115 of file CPUCruncher.cpp.

116 {
117 
118  unsigned int smaller_i = 0;
119  double time = 0.;
120  bool found = false;
121  // We know that the first entry is 0, so we start to iterate from 1
122  for ( unsigned int i = 1; i < m_times_vect.size(); i++ ) {
123  time = m_times_vect[i];
124  if ( time > runtime ) {
125  smaller_i = i - 1;
126  found = true;
127  break;
128  }
129  }
130 
131  // Case 1: we are outside the interpolation range, we take the last 2 points
132  if ( not found ) smaller_i = m_times_vect.size() - 2;
133 
134  // Case 2: we maeke a linear interpolation
135  // y=mx+q
136  const double x0 = m_times_vect[smaller_i];
137  const double x1 = m_times_vect[smaller_i + 1];
138  const double y0 = m_niters_vect[smaller_i];
139  const double y1 = m_niters_vect[smaller_i + 1];
140  const double m = ( y1 - y0 ) / ( x1 - x0 );
141  const double q = y0 - m * x0;
142 
143  const unsigned long nCaliIters = m * runtime + q;
144  // always() << x0 << "<" << runtime << "<" << x1 << " Corresponding to " << nCaliIters << " iterations" << endmsg;
145 
146  return nCaliIters;
147 }
static std::vector< unsigned int > m_niters_vect
Definition: CPUCruncher.h:75
constexpr double m
Definition: SystemOfUnits.h:94
static std::vector< double > m_times_vect
Definition: CPUCruncher.h:76
T size(T...args)
StatusCode CPUCruncher::initialize ( )
override

Its initialization.

Definition at line 47 of file CPUCruncher.cpp.

48 {
49  auto sc = GaudiAlgorithm::initialize();
50  if ( !sc ) return sc;
51 
52  if ( m_times_vect.size() == 0 ) calibrate();
53 
54  // if an algorithm was setup to sleep, for whatever period, it effectively becomes I/O-bound
55  if ( m_sleepFraction != 0.0f ) setIOBound( true );
56 
57  // This is a bit ugly. There is no way to declare a vector of DataObjectHandles, so
58  // we need to wait until initialize when we've read in the input and output key
59  // properties, and know their size, and then turn them
60  // into Handles and register them with the framework by calling declareProperty. We
61  // could call declareInput/declareOutput on them too.
62 
63  int i = 0;
64  for ( auto k : m_inpKeys ) {
65  DEBUG_MSG << "adding input key " << k << endmsg;
67  declareProperty( "dummy_in_" + std::to_string( i ), *( m_inputHandles.back() ) );
68  i++;
69  }
70 
71  i = 0;
72  for ( auto k : m_outKeys ) {
73  DEBUG_MSG << "adding output key " << k << endmsg;
75  declareProperty( "dummy_out_" + std::to_string( i ), *( m_outputHandles.back() ) );
76  i++;
77  }
78 
79  return sc;
80 }
Gaudi::Property< float > m_sleepFraction
Definition: CPUCruncher.h:68
void setIOBound(bool value)
Definition: Algorithm.h:478
StatusCode initialize() override
standard initialization method
T to_string(T...args)
std::vector< DataObjectHandle< DataObject > * > m_outputHandles
Definition: CPUCruncher.h:83
void calibrate()
Calibrate.
Definition: CPUCruncher.cpp:86
T push_back(T...args)
std::vector< DataObjectHandle< DataObject > * > m_inputHandles
Definition: CPUCruncher.h:82
static std::vector< double > m_times_vect
Definition: CPUCruncher.h:76
#define DEBUG_MSG
Definition: CPUCruncher.cpp:18
T size(T...args)
T back(T...args)
Gaudi::Property< std::vector< std::string > > m_outKeys
Definition: CPUCruncher.h:61
Gaudi::Details::PropertyBase * declareProperty(const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
Definition: Algorithm.h:370
Gaudi::Property< std::vector< std::string > > m_inpKeys
Definition: CPUCruncher.h:60
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
bool CPUCruncher::isClonable ( ) const
inlineoverride

Definition at line 24 of file CPUCruncher.h.

24 { return true; }
CPUCruncher& CPUCruncher::operator= ( const CPUCruncher )
private

the assignement operator is disabled

Member Data Documentation

Gaudi::Property<double> CPUCruncher::m_avg_runtime {this, "avgRuntime", 1., "Average runtime of the module."}
private

Definition at line 63 of file CPUCruncher.h.

bool CPUCruncher::m_declAugmented {false}
private

Definition at line 57 of file CPUCruncher.h.

Gaudi::Property<unsigned int> CPUCruncher::m_failNEvents {this, "FailNEvents", 0, "Return FAILURE on every Nth event"}
private

Definition at line 72 of file CPUCruncher.h.

Gaudi::Property<std::vector<std::string> > CPUCruncher::m_inpKeys {this, "inpKeys", {}, ""}
private

Definition at line 60 of file CPUCruncher.h.

std::vector<DataObjectHandle<DataObject>*> CPUCruncher::m_inputHandles
private

Definition at line 82 of file CPUCruncher.h.

Gaudi::Property<bool> CPUCruncher::m_invertCFD {this, "InvertDecision", false, "Invert control flow decision."}
private

Definition at line 71 of file CPUCruncher.h.

Gaudi::Property<bool> CPUCruncher::m_loader {this, "Loader", false, "Declare the algorithm to be a data loader"}
private

Definition at line 58 of file CPUCruncher.h.

Gaudi::Property<bool> CPUCruncher::m_local_rndm_gen {this, "localRndm", true, "Decide if the local random generator is to be used"}
private

Definition at line 65 of file CPUCruncher.h.

CPUCruncher::CHM CPUCruncher::m_name_ncopies_map
staticprivate

Definition at line 85 of file CPUCruncher.h.

std::vector< unsigned int > CPUCruncher::m_niters_vect
staticprivate

Definition at line 75 of file CPUCruncher.h.

Gaudi::Property<std::vector<std::string> > CPUCruncher::m_outKeys {this, "outKeys", {}, ""}
private

Definition at line 61 of file CPUCruncher.h.

std::vector<DataObjectHandle<DataObject>*> CPUCruncher::m_outputHandles
private

Definition at line 83 of file CPUCruncher.h.

Gaudi::Property<unsigned int> CPUCruncher::m_rwRepetitions {this, "RwRepetitions", 1, "Increase access to the WB"}
private

Definition at line 67 of file CPUCruncher.h.

Gaudi::Property<bool> CPUCruncher::m_shortCalib {this, "shortCalib", false, "Enable coarse grained calibration"}
private

Definition at line 66 of file CPUCruncher.h.

Gaudi::Property<float> CPUCruncher::m_sleepFraction
private
Initial value:
{
this, "SleepFraction", 0.0f,
"Fraction of time, between 0 and 1, when an algorithm is actually sleeping instead of crunching"}

Definition at line 68 of file CPUCruncher.h.

std::vector< double > CPUCruncher::m_times_vect
staticprivate

Definition at line 76 of file CPUCruncher.h.

Gaudi::Property<double> CPUCruncher::m_var_runtime {this, "varRuntime", 0.01, "Variance of the runtime of the module."}
private

Definition at line 64 of file CPUCruncher.h.

const uint CPUCruncher::MAX_INPUTS = 40
private

Definition at line 79 of file CPUCruncher.h.

const uint CPUCruncher::MAX_OUTPUTS = 10
private

Definition at line 80 of file CPUCruncher.h.


The documentation for this class was generated from the following files: