GaudiParallelizer Class Reference

#include <src/GaudiParallelizer.h>

Inheritance diagram for GaudiParallelizer:
Collaboration diagram for GaudiParallelizer:

Classes

class  AlgorithmEntry
 

Public Member Functions

 GaudiParallelizer (const std::string &name, ISvcLocator *pSvcLocator)
 Standard constructor. More...
 
virtual ~GaudiParallelizer ()
 Destructor. More...
 
virtual StatusCode initialize ()
 Algorithm initialization. More...
 
virtual StatusCode execute ()
 Algorithm execution. More...
 
virtual StatusCode finalize ()
 Algorithm finalization. More...
 
void membershipHandler (Property &theProp)
 for asynchronous changes in the list of algorithms 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 () 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 (DataObject *object, const std::string &address, const bool useRootInTES=true) const
 Register a data object or container into Gaudi Event Transient Store. More...
 
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 (protected) More...
 
 ~GaudiAlgorithm () override=default
 destructor, virtual and protected More...
 
SmartIF< INTupleSvc > & evtColSvc () const
 Access the standard event collection service. More...
 
 GaudiAlgorithm (const GaudiAlgorithm &)=delete
 
GaudiAlgorithmoperator= (const GaudiAlgorithm &)=delete
 
template<class T >
PropertydeclareProperty (const std::string &name, DataObjectHandle< T > &hndl, const std::string &doc="none") const
 
- 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, DataObject *object, const std::string &location, const bool useRootInTES=true) const
 Register a data object or container into Gaudi Event Transient Store. More...
 
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...
 
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...
 
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...
 
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...
 
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 Statisticscounters () const
 accessor to all counters More...
 
StatEntitycounter (const std::string &tag) const
 accessor to certain counter by name More...
 
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. More...
 
 GaudiCommon (const std::string &type, const std::string &name, const IInterface *parent)
 Tool constructor. 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...
 
 ~Algorithm () override=default
 Destructor. 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 () 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) 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 filterPassed () const override
 Did this algorithm pass or fail its filter criterion for the last event? More...
 
void setFilterPassed (bool state) override
 Set the filter passed flag to the specified state. More...
 
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
 Obsoleted name, kept due to the backwards compatibility. More...
 
SmartIF< IDataProviderSvc > & detSvc () const
 The standard detector data service. More...
 
SmartIF< IDataProviderSvc > & detDataService () const
 Obsoleted name, kept due to the backwards compatibility. More...
 
SmartIF< IConversionSvc > & detCnvSvc () const
 The standard detector data persistency conversion service. More...
 
SmartIF< IConversionSvc > & detDataCnvService () const
 Obsoleted name, kept due to the backwards compatibility. More...
 
SmartIF< IDataProviderSvc > & eventSvc () const
 The standard event data service. More...
 
SmartIF< IDataProviderSvc > & evtSvc () const
 shortcut for method eventSvc More...
 
SmartIF< IDataProviderSvc > & eventDataService () const
 Obsoleted name, kept due to the backwards compatibility. More...
 
SmartIF< IConversionSvc > & eventCnvSvc () const
 The standard event data persistency conversion service. More...
 
SmartIF< IConversionSvc > & eventDataCnvService () const
 Obsoleted name, kept due to the backwards compatibility. More...
 
SmartIF< IHistogramSvc > & histoSvc () const
 The standard histogram service. More...
 
SmartIF< IHistogramSvc > & histogramDataService () const
 Obsoleted name, kept due to the backwards compatibility. More...
 
SmartIF< INTupleSvc > & ntupleSvc () const
 The standard N tuple service. More...
 
SmartIF< INTupleSvc > & ntupleService () const
 Obsoleted name, kept due to the backwards compatibility. More...
 
SmartIF< IRndmGenSvc > & randSvc () const
 AIDA-based NTuple service Returns a pointer to the AIDATuple 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
 
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 setProperty (const Property &p) override
 Implementation of IProperty::setProperty. More...
 
StatusCode setProperty (const std::string &s) override
 Implementation of IProperty::setProperty. More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 Implementation of IProperty::setProperty. More...
 
StatusCode getProperty (Property *p) const override
 Implementation of IProperty::getProperty. More...
 
const PropertygetProperty (const std::string &name) const override
 Implementation of IProperty::getProperty. More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 Implementation of IProperty::getProperty. More...
 
const std::vector< Property * > & getProperties () const override
 Implementation of IProperty::getProperties. More...
 
bool hasProperty (const std::string &name) const override
 Implementation of IProperty::hasProperty. More...
 
PropertyMgrgetPropertyMgr ()
 
StatusCode setProperties ()
 Set the algorithm's properties. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none") const
 
template<class T >
PropertydeclareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none") const
 
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...
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
EventContextgetContext () const
 get the context More...
 
void setContext (EventContext *context)
 set the context More...
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 
virtual const DataObjIDCollextraInputDeps () const override
 
virtual const DataObjIDCollextraOutputDeps () const override
 
virtual void acceptDHVisitor (IDataHandleVisitor *) const override
 
const DataObjIDCollinputDataObjs () const
 
const DataObjIDColloutputDataObjs () const
 
void commitHandles () override
 
void registerTool (IAlgTool *tool) const
 
void deregisterTool (IAlgTool *tool) const
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 
const std::vector< IAlgTool * > & tools () const
 
bool isClonable () const override
 Specifies the clonability of the algorithm. More...
 
unsigned int cardinality () const override
 Return the cardinality. More...
 
const std::vector< std::string > & neededResources () const override
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
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...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const __attribute__((deprecated))
 Backward compatibility function for getting the output level. More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 

Protected Member Functions

StatusCode decodeNames ()
 Decode a vector of string. More...
 
- Protected Member Functions inherited from GaudiCommon< Algorithm >
 ~GaudiCommon () override=default
 Destructor. More...
 
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
virtual void declareInput (Gaudi::DataHandle *im) override
 
virtual void declareOutput (Gaudi::DataHandle *im) override
 
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...
 
- Protected Member Functions inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Private Attributes

StringArrayProperty m_names
 Input string, list of algorithms. More...
 
std::vector< AlgorithmEntrym_entries
 List of algorithms to process. More...
 
bool m_modeOR
 Indicates that the OR is wanted instead of AND. More...
 
bool m_measureTime
 Flag to measure time. More...
 
bool m_returnOK
 Forces the sequencer to return a good status. More...
 
ISequencerTimerToolm_timerTool
 Pointer to the timer tool. More...
 
int m_timer
 Timer number for the sequencer. More...
 
tbb::task_group m_task_group
 TBB task group. More...
 
unsigned short m_nthreads
 Number of threads in the thread pool. More...
 

Additional Inherited Members

- Public Types inherited from Algorithm
typedef Gaudi::PluginService::Factory< IAlgorithm *, const std::string &, ISvcLocator * > Factory
 
- Public Types inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Protected Types inherited from GaudiCommon< Algorithm >
using base_class = Algorithm
 
typedef std::map< std::string, StatEntityStatistics
 the actual type of general counters More...
 
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 Attributes inherited from GaudiCommon< Algorithm >
SmartIF< ICounterSummarySvcm_counterSummarySvc
 a pointer to the CounterSummarySvc More...
 
std::vector< std::stringm_counterList
 list of counters to declare. Set by property CounterList. This can be a regular expression. More...
 
std::vector< std::stringm_statEntityList
 
- Protected Attributes inherited from Algorithm
EventContextm_event_context
 Event specific data for multiple event processing. More...
 
SmartIF< PropertyMgrm_propertyMgr
 For management of properties. More...
 
std::unique_ptr< IDataHandleVisitorm_updateDataHandles
 Hook for for derived classes to provide a custom visitor for data handles. More...
 
- 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

Author
Illya Shapoval
Date
09/12/2011

Definition at line 20 of file GaudiParallelizer.h.

Constructor & Destructor Documentation

GaudiParallelizer::GaudiParallelizer ( const std::string name,
ISvcLocator pSvcLocator 
)

Standard constructor.

Definition at line 21 of file GaudiParallelizer.cpp.

22  : GaudiAlgorithm(name, pSvcLocator)
23  , m_timerTool( 0 )
24 {
25  declareProperty( "Members" , m_names );
26  declareProperty( "ModeOR" , m_modeOR = false );
27  declareProperty( "MeasureTime" , m_measureTime = false );
28  declareProperty( "ReturnOK" , m_returnOK = false );
29  declareProperty( "NumberOfThreads", m_nthreads = 0 );
30 
32 }
virtual Property & declareUpdateHandler(std::function< void(Property &)> fun)
set new callback for update
Definition: Property.cpp:72
bool m_returnOK
Forces the sequencer to return a good status.
Property * declareProperty(const std::string &name, DataObjectHandle< T > &hndl, const std::string &doc="none") const
bool m_modeOR
Indicates that the OR is wanted instead of AND.
StringArrayProperty m_names
Input string, list of algorithms.
void membershipHandler(Property &theProp)
for asynchronous changes in the list of algorithms
ISequencerTimerTool * m_timerTool
Pointer to the timer tool.
bool m_measureTime
Flag to measure time.
unsigned short m_nthreads
Number of threads in the thread pool.
GaudiParallelizer::~GaudiParallelizer ( )
virtual

Destructor.

Definition at line 37 of file GaudiParallelizer.cpp.

37 {}

Member Function Documentation

StatusCode GaudiParallelizer::decodeNames ( )
protected

Decode a vector of string.

Definition at line 139 of file GaudiParallelizer.cpp.

139  {
140 
142  m_entries.clear();
143 
144  //== Get the "Context" option if in the file...
145  auto jos = service<IJobOptionsSvc>( "JobOptionsSvc" );
146  bool addedContext = false; //= Have we added the context ?
147  bool addedRootInTES = false; //= Have we added the rootInTES ?
148 
149 
150  //= Get the Application manager, to see if algorithm exist
151  auto appMgr = service<IAlgManager>("ApplicationMgr");
152  const std::vector<std::string>& nameVector = m_names.value();
154  for ( it = nameVector.begin(); nameVector.end() != it; it++ ) {
156  const std::string &theName = typeName.name();
157  const std::string &theType = typeName.type();
158 
159  //== Check whether the specified algorithm already exists. If not, create it
161  SmartIF<IAlgorithm> myIAlg = appMgr->algorithm(typeName, false); // do not create it now
162  if ( !myIAlg.isValid() ) {
163  //== Set the Context if not in the jobOptions list
164  if ( !context().empty() || !rootInTES().empty() ) {
165  bool foundContext = false;
166  bool foundRootInTES = false;
167  const auto properties = jos->getProperties( theName );
168  if ( properties ) {
169  // Iterate over the list to set the options
170  for ( const auto& p : *properties ) {
171  if ( "Context" == p->name() ) {
172  foundContext = true;
173  }
174  if ( "RootInTES" == p->name() ) {
175  foundRootInTES = true;
176  }
177  }
178  }
179  if ( !foundContext && !context().empty() ) {
180  StringProperty contextProperty( "Context", context() );
181  jos->addPropertyToCatalogue( theName, contextProperty ).ignore();
182  addedContext = true;
183  }
184  if ( !foundRootInTES && !rootInTES().empty() ) {
185  StringProperty rootInTESProperty( "RootInTES", rootInTES() );
186  jos->addPropertyToCatalogue( theName, rootInTESProperty ).ignore();
187  addedRootInTES = true;
188  }
189  }
190 
191  Algorithm *myAlg = nullptr;
192  result = createSubAlgorithm( theType, theName, myAlg );
193  // (MCl) this should prevent bug #35199... even if I didn't manage to
194  // reproduce it with a simple test.
195  if (result.isSuccess()) myIAlg = myAlg;
196  } else {
197  Algorithm *myAlg = dynamic_cast<Algorithm*>(myIAlg.get());
198  if (myAlg) {
199  subAlgorithms()->push_back(myAlg);
200  // when the algorithm is not created, the ref count is short by one, so we have to fix it.
201  myAlg->addRef();
202  }
203  }
204 
205  //== Remove the property, in case this is not a GaudiAlgorithm...
206  if ( addedContext ) {
207  jos->removePropertyFromCatalogue( theName, "Context" ).ignore();
208  addedContext = false;
209  }
210  if ( addedRootInTES ) {
211  jos->removePropertyFromCatalogue( theName, "RootInTES" ).ignore();
212  addedRootInTES = false;
213  }
214 
215  // propagate the sub-algorithm into own state.
216  if ( result.isSuccess () &&
218  myIAlg.isValid () &&
219  Gaudi::StateMachine::INITIALIZED > myIAlg->FSMState() )
220  {
221  StatusCode sc = myIAlg->sysInitialize() ;
222  if ( sc.isFailure() ) { result = sc ; }
223  }
224 
225  // propagate the sub-algorithm into own state.
226  if ( result.isSuccess () &&
228  myIAlg.isValid () &&
229  Gaudi::StateMachine::RUNNING > myIAlg->FSMState() )
230  {
231  StatusCode sc = myIAlg->sysStart () ;
232  if ( sc.isFailure() ) { result = sc ; }
233  }
234 
235  //== Is it an Algorithm ? Strange test...
236  if ( result.isSuccess() ) {
237  // TODO: (MCl) it is possible to avoid the dynamic_cast in most of the
238  // cases by keeping the result of createSubAlgorithm.
239  Algorithm* myAlg = dynamic_cast<Algorithm*>(myIAlg.get());
240  if (myAlg!=0) {
241  // Note: The reference counting is kept by the system of sub-algorithms
242  m_entries.push_back( AlgorithmEntry( myAlg ) );
243  if (msgLevel(MSG::DEBUG)) debug () << "Added algorithm " << theName << endmsg;
244  } else {
245  warning() << theName << " is not an Algorithm - failed dynamic_cast"
246  << endmsg;
247  final = StatusCode::FAILURE;
248  }
249  } else {
250  warning() << "Unable to find or create " << theName << endmsg;
251  final = result;
252  }
253 
254  }
255  //== Print the list of algorithms
256  MsgStream& msg = info();
257  if ( m_modeOR ) msg << "OR ";
258  msg << "Member list: ";
260  ostream_joiner( msg, m_entries, ", ",
261  [](MsgStream& msg,const AlgorithmEntry& entry) -> MsgStream& {
262  Algorithm* myAlg = entry.algorithm();
263  auto myAlgType = System::typeinfoName( typeid(*myAlg) ) ;
264  if ( myAlg->name() != myAlgType ) {
265  msg << myAlgType << "/" ;
266  }
267  return msg << myAlg->name();
268  } );
269  if ( !context().empty() ) msg << ", with context '" << context() << "'";
270  if ( !rootInTES().empty() ) msg << ", with rootInTES '" << rootInTES() << "'";
271  msg << endmsg;
272  return final;
273 
274 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
T empty(T...args)
StatusCode createSubAlgorithm(const std::string &type, const std::string &name, Algorithm *&pSubAlg)
Create a sub algorithm.
Definition: Algorithm.cpp:955
virtual StatusCode sysStart()=0
Startup method invoked by the framework.
const std::string & rootInTES() const
Returns the "rootInTES" string.
Definition: GaudiCommon.h:716
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:297
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
const std::string & context() const
Returns the "context" string. Used to identify different processing states.
Definition: GaudiCommon.h:712
T end(T...args)
bool m_modeOR
Indicates that the OR is wanted instead of AND.
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
virtual StatusCode sysInitialize()=0
Initialization method invoked by the framework.
STL class.
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:820
StringArrayProperty m_names
Input string, list of algorithms.
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
T push_back(T...args)
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:9
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
const TYPE & value() const
explicit conversion
Definition: Property.h:341
Stream & ostream_joiner(Stream &os, Iterator first, Iterator last, Separator sep, OutputElement output=OutputElement{})
Definition: SerializeSTL.h:35
const std::vector< Algorithm * > * subAlgorithms() const
List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms.
Definition: Algorithm.cpp:865
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:74
Gaudi::StateMachine::State FSMState() const override
returns the current state of the algorithm
Definition: Algorithm.h:193
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:62
T begin(T...args)
std::vector< AlgorithmEntry > m_entries
List of algorithms to process.
tuple appMgr
Definition: IOTest.py:83
std::string typeName(const std::type_info &typ)
Definition: Dictionary.cpp:21
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode GaudiParallelizer::execute ( )
virtual

Algorithm execution.

Definition at line 94 of file GaudiParallelizer.cpp.

94  {
96 
97  if ( msgLevel(MSG::DEBUG) ) debug() << "==> Execute algorithms in parallel" << endmsg;
98 
99  for (std::vector<AlgorithmEntry>::iterator itE = m_entries.begin(); m_entries.end() != itE; ++itE ) {
100  Algorithm* myAlg = itE->algorithm();
101  if ( ! myAlg->isEnabled() ) continue;
102  if ( ! myAlg->isExecuted() ) {
103 
104  m_task_group.run(boost::bind(&AlgorithmEntry::run,
105  boost::ref(*itE),
106  boost::ref(*this)));
107  }
108  }
109 
110  m_task_group.wait();
111  if ( msgLevel(MSG::DEBUG) ) debug() << "==> Joining parallel algorithm tasks" << endmsg;
112 
113  for( std::vector<AlgorithmEntry>::const_iterator it = m_entries.begin(); it != m_entries.end(); ++it ){
114  if ( msgLevel(MSG::DEBUG) ) debug() << "Algorithm wrapper " << &*it
115  << " around the algorithm " << it->algorithm()->name()
116  << " received return status code " << it->m_returncode
117  << endmsg;
118  }
119 
120  for( std::vector<AlgorithmEntry>::const_iterator it = m_entries.begin(); it != m_entries.end(); ++it )
121  if ( !(it->m_returncode.isSuccess()) ) return it->m_returncode;
122 
123  setExecuted( true );
125  return StatusCode::SUCCESS;
126 }
void setExecuted(bool state) override
Set the executed flag to the specified state.
Definition: Algorithm.cpp:844
bool isExecuted() const override
Has this algorithm been executed since the last reset?
Definition: Algorithm.cpp:840
tbb::task_group m_task_group
TBB task group.
virtual void start(int index)=0
start the counter, i.e.
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:74
STL class.
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
bool isEnabled() const override
Is this algorithm enabled or disabled?
Definition: Algorithm.cpp:853
std::vector< AlgorithmEntry > m_entries
List of algorithms to process.
ISequencerTimerTool * m_timerTool
Pointer to the timer tool.
bool m_measureTime
Flag to measure time.
int m_timer
Timer number for the sequencer.
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
virtual double stop(int index)=0
stop the counter, return the elapsed time
void run(GaudiParallelizer &prlzr)
Thread task executor method to wrap an algorithm execution in.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode GaudiParallelizer::finalize ( )
virtual

Algorithm finalization.

Definition at line 131 of file GaudiParallelizer.cpp.

131  {
132  if ( msgLevel(MSG::DEBUG) ) debug() << "==> Finalize" << endmsg;
133 
134  return GaudiAlgorithm::finalize(); // must be called after all other actions
135 }
StatusCode finalize() override
standard finalization method
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode GaudiParallelizer::initialize ( )
virtual

Algorithm initialization.

Definition at line 42 of file GaudiParallelizer.cpp.

42  {
43  if ( msgLevel(MSG::DEBUG) ) debug() << "==> Initialize" << endmsg;
44  StatusCode sc = GaudiAlgorithm::initialize(); // must be executed first
45  if ( sc.isFailure() ) return sc; // error printed already by GaudiAlgorithm
46 
47  StatusCode status = decodeNames();
48  if ( !status.isSuccess() ) return status;
49 
50  m_timerTool = tool<ISequencerTimerTool>( "SequencerTimerTool" );
51  if ( m_timerTool->globalTiming() ) m_measureTime = true;
52 
53  if ( m_measureTime ) {
56  } else {
58  m_timerTool = 0;
59  }
60 
61  //== Initialize the algorithms
63  for ( itE = m_entries.begin(); m_entries.end() != itE; itE++ ) {
64  Algorithm* myAlg = itE->algorithm();
65  if ( m_measureTime ) {
66  itE->setTimer( m_timerTool->addTimer( myAlg->name() ) );
67  }
68 
69  status = myAlg->sysInitialize();
70  if ( !status.isSuccess() ) {
71  return Error( "Can not initialize " + myAlg->name(),
72  status );
73  }
74  }
75 
77 
78  if ( m_nthreads != 0 ) {
79  // Construct the TBB task scheduler with m_nthreads threads
80  tbb::task_scheduler_init init( m_nthreads );
81  }
82  else {
83  m_nthreads = tbb::task_scheduler_init::default_num_threads();
84  }
85 
86  if ( msgLevel(MSG::DEBUG) ) debug() << "Number of threads set to be used in the TBB thread pool is "
87  << m_nthreads << endmsg;
88  return StatusCode::SUCCESS;
89 }
virtual void decreaseIndent()=0
Decrease the indentation of the name.
virtual int addTimer(const std::string &name)=0
add a timer entry with the specified name
StatusCode initialize() override
standard initialization method
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
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.
StatusCode decodeNames()
Decode a vector of string.
virtual void increaseIndent()=0
Increase the indentation of the name.
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
virtual bool globalTiming()=0
returns the flag telling that global timing is wanted
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:820
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:74
STL class.
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
std::vector< AlgorithmEntry > m_entries
List of algorithms to process.
ISequencerTimerTool * m_timerTool
Pointer to the timer tool.
bool m_measureTime
Flag to measure time.
int m_timer
Timer number for the sequencer.
unsigned short m_nthreads
Number of threads in the thread pool.
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
StatusCode sysInitialize() override
Initialization method invoked by the framework.
Definition: Algorithm.cpp:105
StatusCode release(const IInterface *interface) const
Manual forced (and 'safe') release of the active tool or service.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
void GaudiParallelizer::membershipHandler ( Property theProp)

for asynchronous changes in the list of algorithms

Definition at line 279 of file GaudiParallelizer.cpp.

280 {
281  // no action for not-yet initialized sequencer
282  if ( Gaudi::StateMachine::INITIALIZED > FSMState() ) { return ; } // RETURN
283 
284  decodeNames().ignore();
285 
286  if ( !m_measureTime ) { return ; } // RETURN
287 
288  // add the entries into timer table:
289 
290  if ( 0 == m_timerTool )
291  { m_timerTool = tool<ISequencerTimerTool>( "SequencerTimerTool" ) ; }
292 
293  if ( m_timerTool->globalTiming() ) m_measureTime = true;
294 
297 
299  m_entries.end() != itE; ++itE )
300  {
301  itE->setTimer( m_timerTool->addTimer( itE->algorithm()->name() ) );
302  }
303 
305 
306 }
virtual void decreaseIndent()=0
Decrease the indentation of the name.
virtual int addTimer(const std::string &name)=0
add a timer entry with the specified name
StatusCode decodeNames()
Decode a vector of string.
virtual void increaseIndent()=0
Increase the indentation of the name.
virtual bool globalTiming()=0
returns the flag telling that global timing is wanted
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:820
STL class.
Gaudi::StateMachine::State FSMState() const override
returns the current state of the algorithm
Definition: Algorithm.h:193
std::vector< AlgorithmEntry > m_entries
List of algorithms to process.
ISequencerTimerTool * m_timerTool
Pointer to the timer tool.
bool m_measureTime
Flag to measure time.
int m_timer
Timer number for the sequencer.
void ignore() const
Definition: StatusCode.h:108

Member Data Documentation

std::vector<AlgorithmEntry> GaudiParallelizer::m_entries
private

List of algorithms to process.

Definition at line 72 of file GaudiParallelizer.h.

bool GaudiParallelizer::m_measureTime
private

Flag to measure time.

Definition at line 75 of file GaudiParallelizer.h.

bool GaudiParallelizer::m_modeOR
private

Indicates that the OR is wanted instead of AND.

Definition at line 73 of file GaudiParallelizer.h.

StringArrayProperty GaudiParallelizer::m_names
private

Input string, list of algorithms.

Definition at line 71 of file GaudiParallelizer.h.

unsigned short GaudiParallelizer::m_nthreads
private

Number of threads in the thread pool.

Definition at line 81 of file GaudiParallelizer.h.

bool GaudiParallelizer::m_returnOK
private

Forces the sequencer to return a good status.

Definition at line 76 of file GaudiParallelizer.h.

tbb::task_group GaudiParallelizer::m_task_group
private

TBB task group.

Definition at line 80 of file GaudiParallelizer.h.

int GaudiParallelizer::m_timer
private

Timer number for the sequencer.

Definition at line 78 of file GaudiParallelizer.h.

ISequencerTimerTool* GaudiParallelizer::m_timerTool
private

Pointer to the timer tool.

Definition at line 77 of file GaudiParallelizer.h.


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