| The Gaudi Framework v32r1 (f65d50dc)

Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
CPUCruncher Class Reference

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

`#include <src/CPUCruncher.h>`

Inheritance diagram for CPUCruncher:
[legend]
Collaboration diagram for CPUCruncher:
[legend]

## Public Types
typedef tbb::concurrent_hash_map< std::string, unsigned int > | CHM

## 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 DataObject * | put (DataObject *object, const std::string &address, const bool useRootInTES=true) const
| Register a data object or container into Gaudi Event Transient Store. More...
const DataObject * | put (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
GaudiAlgorithm & | operator= (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...
DataObject * | put (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...
DataObject * | put (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...
IUpdateManagerSvc * | updMgrSvc () 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...
StatEntity & | counter (const std::string &tag) const
| accessor to certain counter by name More...
StatEntity & | counter (const std::string &tag)
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 Services & | services () const
| get the list of aquired services More...
const std::string & | context () const
| Returns the "context" string. Used to identify different processing states. More...
Public Member Functions inherited from FixTESPath< BASE >
template<typename U = BASE, typename = std::enable_if_t<std::is_base_of_v<Gaudi::Algorithm, BASE>, U>>
| FixTESPath (const std::string &name, ISvcLocator *pSvcLocator)
| Algorithm constructor - the SFINAE constraint below ensures that this is constructor is only defined if BASE derives from Algorithm. More...
template<typename U = BASE, typename = std::enable_if_t<std::is_base_of_v<AlgTool, BASE>, U>>
| FixTESPath (const std::string &type, const std::string &name, const IInterface *ancestor)
| Tool constructor - SFINAE-ed to insure this constructor is only defined if BASE derives from AlgTool. More...
StatusCode | initialize () override
const std::string & | rootInTES () const
| Returns the "rootInTES" string. More...
std::string | fullTESLocation (std::string_view location, bool useRootInTES) const
| Returns the full correct event location given the rootInTes settings. More...

## Private Member Functions
| CPUCruncher ()
| the default constructor is disabled More...
| CPUCruncher (const CPUCruncher &)
| the copy constructor is disabled More...
CPUCruncher & | operator= (const CPUCruncher &)
| the assignement operator is disabled More...
void | declareRuntimeRequestedOutputs ()
| The CPU intensive function. 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< 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
SmartIF< ICPUCrunchSvc > | m_crunchSvc

## Static Private Attributes
static CHM | m_name_ncopies_map

## Additional Inherited Members
Protected Types inherited from GaudiCommon< Algorithm >
using | base_class = FixTESPath< Algorithm >
typedef std::map< std::string, StatEntity > | StatisticsOwn
| 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 Attributes inherited from GaudiCommon< Algorithm >
SmartIF< ICounterSummarySvc > | m_counterSummarySvc
| a pointer to the CounterSummarySvc 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

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 19 of file CPUCruncher.h.

## Member Typedef Documentation

## ◆ CHM

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

Definition at line 22 of file CPUCruncher.h.

## Constructor & Destructor Documentation

## ◆ CPUCruncher() [1/3]

CPUCruncher::CPUCruncher | ( | const std::string & | name,
|  | ISvcLocator * | pSvc
| ) |  |

Definition at line 23 of file CPUCruncher.cpp.

25 : GaudiAlgorithm( name, pSvc ) {
26
27 // Register the algo in the static concurrent hash map in order to
28 // monitor the # of copies
29 CHM::accessor name_ninstances;
30 m_name_ncopies_map.insert( name_ninstances, name );
31 name_ninstances->second += 1;
32 }
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
CPUCruncher::m_name_ncopies_map
static CHM m_name_ncopies_map
Definition: CPUCruncher.h:75
GaudiAlgorithm::GaudiAlgorithm
GaudiAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Standard constructor.
Definition: GaudiAlgorithm.cpp:35

## ◆ ~CPUCruncher()

CPUCruncher::~CPUCruncher | ( |  | ) |
| virtual

virtual & protected desctrustor

Definition at line 34 of file CPUCruncher.cpp.

34 {
35 for ( uint i = 0; i < m_inputHandles.size(); ++i ) delete m_inputHandles[i];
36
37 for ( uint i = 0; i < m_outputHandles.size(); ++i ) delete m_outputHandles[i];
38 }
CPUCruncher::m_outputHandles
std::vector< DataObjectHandle< DataObject > * > m_outputHandles
Definition: CPUCruncher.h:73
CPUCruncher::m_inputHandles
std::vector< DataObjectHandle< DataObject > * > m_inputHandles
Definition: CPUCruncher.h:72
std::vector::size
T size(T... args)

## ◆ CPUCruncher() [2/3]

CPUCruncher::CPUCruncher | ( |  | ) |
| private

the default constructor is disabled

## ◆ CPUCruncher() [3/3]

CPUCruncher::CPUCruncher | ( | const CPUCruncher & |  | ) |
| private

the copy constructor is disabled

## Member Function Documentation

## ◆ declareRuntimeRequestedOutputs()

void CPUCruncher::declareRuntimeRequestedOutputs | ( |  | ) |
| private

The CPU intensive function.

Pick up late-attributed data outputs

Definition at line 79 of file CPUCruncher.cpp.

79 {
80 //
81 for ( const auto& k : outputDataObjs() ) {
82 auto outputHandle = new DataObjectHandle<DataObject>( k, Gaudi::DataHandle::Writer, this );
83 VERBOSE_MSG << "found late-attributed output: " << outputHandle->objKey() << endmsg;
84 m_outputHandles.push_back( outputHandle );
85 declareProperty( "dummy_out_" + outputHandle->objKey(), *( m_outputHandles.back() ) );
86 }
87
88 initDataHandleHolder();
89
90 m_declAugmented = true;
91 }
CPUCruncher::m_outputHandles
std::vector< DataObjectHandle< DataObject > * > m_outputHandles
Definition: CPUCruncher.h:73
VERBOSE_MSG
#define VERBOSE_MSG
Definition: CPUCruncher.cpp:19
DataObjectHandle< DataObject >
std::vector::push_back
T push_back(T... args)
std::vector::back
T back(T... args)
Gaudi::DataHandle::Writer
Definition: DataHandle.h:29
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
CPUCruncher::m_declAugmented
bool m_declAugmented
Definition: CPUCruncher.h:52

## ◆ execute()

StatusCode CPUCruncher::execute | ( |  | ) |
| override

the execution of the algorithm

Definition at line 95 of file CPUCruncher.cpp.

96 {
97
98 if ( m_loader && !m_declAugmented ) declareRuntimeRequestedOutputs();
99
100 float crunchtime;
101
102 if ( m_local_rndm_gen ) {
103 /* This will disappear with a thread safe random number generator service.
104 * Use basic Box-Muller to generate Gaussian random numbers.
105 * The quality is not good for in depth study given that the generator is a
106 * linear congruent.
107 * Throw away basically a free number: we are in a cpu cruncher after all.
108 * The seed is taken from the clock, but we could assign a seed per module to
109 * ensure reproducibility.
110 *
111 * This is not an overkill but rather an exercise towards a thread safe
112 * random number generation.
113 */
114
115 auto getGausRandom = []( double mean, double sigma ) -> double {
116 unsigned int seed = std::clock();
117
118 auto getUnifRandom = []( unsigned int& seed ) -> double {
119 // from "Numerical Recipes"
120 constexpr unsigned int m = 232;
121 constexpr unsigned int a = 1664525;
122 constexpr unsigned int c = 1013904223;
123 seed = ( a * seed + c ) % m;
124 const double unif = double( seed ) / m;
125 return unif;
126 };
127
128 double unif1, unif2;
129 do {
130 unif1 = getUnifRandom( seed );
131 unif2 = getUnifRandom( seed );
132 } while ( unif1 == 0. );
133
134 const double normal = sqrt( -2. * log( unif1 ) ) * cos( 2 * M_PI * unif2 );
135
136 return normal * sigma + mean;
137 };
138
139 crunchtime = fabs( getGausRandom( m_avg_runtime * ( 1. - m_sleepFraction ), m_var_runtime ) );
140 // End Of temp block
141 } else {
142 // Should be a member.
143 HiveRndm::HiveNumbers rndmgaus( randSvc(), Rndm::Gauss( m_avg_runtime * ( 1. - m_sleepFraction ), m_var_runtime ) );
144 crunchtime = std::fabs( rndmgaus() );
145 }
146 unsigned int crunchtime_ms = 1000 * crunchtime;
147
148 // Prepare to sleep (even if we won't enter the following if clause for sleeping).
149 // This is needed to distribute evenly among all algorithms the overhead (around sleeping) which is harmful when
150 // trying to achieve uniform distribution of algorithm timings.
151 const double dreamtime = m_avg_runtime * m_sleepFraction;
152 const std::chrono::duration<double> dreamtime_duration( dreamtime );
153 tbb::tick_count startSleeptbb;
154 tbb::tick_count endSleeptbb;
155
156 // Start to measure the total time here, together with the dreaming process straight ahead
157 tbb::tick_count starttbb = tbb::tick_count::now();
158
159 // If the algorithm was set as I/O-bound, we will replace requested part of crunching with plain sleeping
160 if ( isIOBound() ) {
161 // in this block (and not in other places around) msgLevel is checked for the same reason as above, when
162 // preparing to sleep several lines above: to reduce as much as possible the overhead around sleeping
163 DEBUG_MSG << "Dreaming time will be: " << int( 1000 * dreamtime ) << " ms" << endmsg;
164
165 ON_DEBUG startSleeptbb = tbb::tick_count::now();
166 std::this_thread::sleep_for( dreamtime_duration );
167 ON_DEBUG endSleeptbb = tbb::tick_count::now();
168
169 // actual sleeping time can be longer due to scheduling or resource contention delays
170 ON_DEBUG {
171 const double actualDreamTime = ( endSleeptbb - startSleeptbb ).seconds();
172 debug() << "Actual dreaming time was: " << int( 1000 * actualDreamTime ) << "ms" << endmsg;
173 }
174 } // end of "sleeping block"
175
176 DEBUG_MSG << "Crunching time will be: " << crunchtime_ms << " ms" << endmsg;
177 const EventContext& context = Gaudi::Hive::currentContext();
178 DEBUG_MSG << "Start event " << context.evt() << " in slot " << context.slot() << " on pthreadID " << std::hex
179 << pthread_self() << std::dec << endmsg;
180
181 VERBOSE_MSG << "inputs number: " << m_inputHandles.size() << endmsg;
182 for ( auto& inputHandle : m_inputHandles ) {
183 if ( !inputHandle->isValid() ) continue;
184
185 VERBOSE_MSG << "get from TS: " << inputHandle->objKey() << endmsg;
186 DataObject* obj = nullptr;
187 for ( unsigned int i = 0; i < m_rwRepetitions; ++i ) { obj = inputHandle->get(); }
188 if ( obj == nullptr ) error() << "A read object was a null pointer." << endmsg;
189 }
190
191 m_crunchSvc->crunch_for( std::chrono::milliseconds( crunchtime_ms ) );
192
193 // Return error on fraction of events if configured
194 if ( m_failNEvents > 0 && context.evt() > 0 && ( context.evt() % m_failNEvents ) == 0 ) {
195 return StatusCode::FAILURE;
196 }
197
198 VERBOSE_MSG << "outputs number: " << m_outputHandles.size() << endmsg;
199 for ( auto& outputHandle : m_outputHandles ) {
200 if ( !outputHandle->isValid() ) continue;
201
202 VERBOSE_MSG << "put to TS: " << outputHandle->objKey() << endmsg;
203 outputHandle->put( new DataObject() );
204 }
205
206 tbb::tick_count endtbb = tbb::tick_count::now();
207 const double actualRuntime = ( endtbb - starttbb ).seconds();
208
209 DEBUG_MSG << "Finish event " << context.evt() << " in " << int( 1000 * actualRuntime ) << " ms" << endmsg;
210
211 DEBUG_MSG << "Timing: ExpectedCrunchtime= " << crunchtime_ms << " ms. ExpectedDreamtime= " << int( 1000 * dreamtime )
212 << " ms. ActualTotalRuntime= " << int( 1000 * actualRuntime )
213 << " ms. Ratio= " << ( crunchtime + dreamtime ) / actualRuntime << endmsg;
214
215 setFilterPassed( !m_invertCFD );
216
217 return StatusCode::SUCCESS;
218 }
CPUCruncher::m_crunchSvc
SmartIF< ICPUCrunchSvc > m_crunchSvc
Definition: CPUCruncher.h:78
ICPUCrunchSvc::crunch_for
virtual std::chrono::milliseconds crunch_for(const std::chrono::milliseconds &) const =0
std::chrono::duration
CPUCruncher::m_sleepFraction
Gaudi::Property< float > m_sleepFraction
Definition: CPUCruncher.h:62
gaudirun.c
c
Definition: gaudirun.py:487
CPUCruncher::m_loader
Gaudi::Property< bool > m_loader
Definition: CPUCruncher.h:53
std::clock
T clock(T... args)
CPUCruncher::m_rwRepetitions
Gaudi::Property< unsigned int > m_rwRepetitions
Definition: CPUCruncher.h:61
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
std::this_thread::sleep_for
T sleep_for(T... args)
Rndm::Gauss
Parameters for the Gauss random number generation.
Definition: RndmGenerators.h:22
CPUCruncher::m_outputHandles
std::vector< DataObjectHandle< DataObject > * > m_outputHandles
Definition: CPUCruncher.h:73
EventContext
This class represents an entry point to all the event specific data.
Definition: EventContext.h:24
VERBOSE_MSG
#define VERBOSE_MSG
Definition: CPUCruncher.cpp:19
GaudiPython.HistoUtils.mean
mean
Definition: HistoUtils.py:875
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:92
HiveRndm::HiveNumbers
Definition: HiveNumbers.h:28
CPUCruncher::m_invertCFD
Gaudi::Property< bool > m_invertCFD
Definition: CPUCruncher.h:65
CPUCruncher::m_inputHandles
std::vector< DataObjectHandle< DataObject > * > m_inputHandles
Definition: CPUCruncher.h:72
Gaudi::Hive::currentContext
GAUDI_API const EventContext & currentContext()
Definition: ThreadLocalContext.cpp:20
std::cos
T cos(T... args)
GaudiCommon< Algorithm >::context
const std::string & context() const
Returns the "context" string. Used to identify different processing states.
Definition: GaudiCommon.h:707
std::fabs
T fabs(T... args)
DEBUG_MSG
#define DEBUG_MSG
Definition: CPUCruncher.cpp:16
Gaudi::Accumulators::sqrt
auto sqrt(std::chrono::duration< Rep, Period > d)
sqrt for std::chrono::duration
Definition: Counters.h:28
GaudiPython.Bindings.DataObject
DataObject
Definition: Bindings.py:55
std::vector::size
T size(T... args)
CPUCruncher::declareRuntimeRequestedOutputs
void declareRuntimeRequestedOutputs()
The CPU intensive function.
Definition: CPUCruncher.cpp:79
CPUCruncher::m_avg_runtime
Gaudi::Property< double > m_avg_runtime
Definition: CPUCruncher.h:58
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
CPUCruncher::m_failNEvents
Gaudi::Property< unsigned int > m_failNEvents
Definition: CPUCruncher.h:66
std::hex
T hex(T... args)
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
CPUCruncher::m_local_rndm_gen
Gaudi::Property< bool > m_local_rndm_gen
Definition: CPUCruncher.h:60
CPUCruncher::m_var_runtime
Gaudi::Property< double > m_var_runtime
Definition: CPUCruncher.h:59
Gaudi.Configuration.log
log
Definition: Configuration.py:13
ON_DEBUG
#define ON_DEBUG
Definition: CPUCruncher.cpp:15
CPUCruncher::m_declAugmented
bool m_declAugmented
Definition: CPUCruncher.h:52

## ◆ finalize()

StatusCode CPUCruncher::finalize | ( |  | ) |
| override

the finalization of the algorithm

Definition at line 222 of file CPUCruncher.cpp.

223 {
224 MsgStream log( msgSvc(), name() );
225
226 unsigned int ninstances;
227
228 {
229 CHM::const_accessor const_name_ninstances;
230 m_name_ncopies_map.find( const_name_ninstances, name() );
231 ninstances = const_name_ninstances->second;
232 }
233
234 constexpr double s2ms = 1000.;
235 // do not show repetitions
236 if ( ninstances != 0 ) {
237 info() << "Summary: name= " << name() << "\t avg_runtime= " << m_avg_runtime * s2ms << "\t n_clones= " << ninstances
238 << endmsg;
239
240 CHM::accessor name_ninstances;
241 m_name_ncopies_map.find( name_ninstances, name() );
242 name_ninstances->second = 0;
243 }
244
245 return GaudiAlgorithm::finalize();
246 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
AvalancheSchedulerErrorTest.msgSvc
msgSvc
Definition: AvalancheSchedulerErrorTest.py:67
CPUCruncher::m_name_ncopies_map
static CHM m_name_ncopies_map
Definition: CPUCruncher.h:75
GaudiAlgorithm::finalize
StatusCode finalize() override
standard finalization method
Definition: GaudiAlgorithm.cpp:55
CPUCruncher::m_avg_runtime
Gaudi::Property< double > m_avg_runtime
Definition: CPUCruncher.h:58
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Gaudi.Configuration.log
log
Definition: Configuration.py:13

## ◆ get_runtime()

double CPUCruncher::get_runtime | ( |  | ) | const
| inline

Definition at line 33 of file CPUCruncher.h.

33 { return m_avg_runtime; }
CPUCruncher::m_avg_runtime
Gaudi::Property< double > m_avg_runtime
Definition: CPUCruncher.h:58

## ◆ initialize()

StatusCode CPUCruncher::initialize | ( |  | ) |
| override

Its initialization.

Definition at line 40 of file CPUCruncher.cpp.

40 {
41 auto sc = GaudiAlgorithm::initialize();
42 if ( !sc ) return sc;
43
44 m_crunchSvc = serviceLocator()->service( "CPUCrunchSvc" );
45 if ( !m_crunchSvc.isValid() ) {
46 fatal() << "unable to acquire CPUCruncSvc" << endmsg;
47 return StatusCode::FAILURE;
48 }
49
50 // if an algorithm was setup to sleep, for whatever period, it effectively becomes I/O-bound
51 if ( m_sleepFraction != 0.0f ) setIOBound( true );
52
53 // This is a bit ugly. There is no way to declare a vector of DataObjectHandles, so
54 // we need to wait until initialize when we've read in the input and output key
55 // properties, and know their size, and then turn them
56 // into Handles and register them with the framework by calling declareProperty. We
57 // could call declareInput/declareOutput on them too.
58
59 int i = 0;
60 for ( auto k : m_inpKeys ) {
61 DEBUG_MSG << "adding input key " << k << endmsg;
62 m_inputHandles.push_back( new DataObjectHandle<DataObject>( k, Gaudi::DataHandle::Reader, this ) );
63 declareProperty( "dummy_in_" + std::to_string( i ), *( m_inputHandles.back() ) );
64 i++;
65 }
66
67 i = 0;
68 for ( auto k : m_outKeys ) {
69 DEBUG_MSG << "adding output key " << k << endmsg;
70 m_outputHandles.push_back( new DataObjectHandle<DataObject>( k, Gaudi::DataHandle::Writer, this ) );
71 declareProperty( "dummy_out_" + std::to_string( i ), *( m_outputHandles.back() ) );
72 i++;
73 }
74
75 return sc;
76 }
CPUCruncher::m_crunchSvc
SmartIF< ICPUCrunchSvc > m_crunchSvc
Definition: CPUCruncher.h:78
CPUCruncher::m_sleepFraction
Gaudi::Property< float > m_sleepFraction
Definition: CPUCruncher.h:62
GaudiAlgorithm::initialize
StatusCode initialize() override
standard initialization method
Definition: GaudiAlgorithm.cpp:42
std::to_string
T to_string(T... args)
SmartIF::isValid
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:62
CPUCruncher::m_outputHandles
std::vector< DataObjectHandle< DataObject > * > m_outputHandles
Definition: CPUCruncher.h:73
Gaudi::DataHandle::Reader
Definition: DataHandle.h:29
DataObjectHandle< DataObject >
std::vector::push_back
T push_back(T... args)
CPUCruncher::m_inputHandles
std::vector< DataObjectHandle< DataObject > * > m_inputHandles
Definition: CPUCruncher.h:72
DEBUG_MSG
#define DEBUG_MSG
Definition: CPUCruncher.cpp:16
std::vector::back
T back(T... args)
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
Gaudi::DataHandle::Writer
Definition: DataHandle.h:29
CPUCruncher::m_outKeys
Gaudi::Property< std::vector< std::string > > m_outKeys
Definition: CPUCruncher.h:56
CPUCruncher::m_inpKeys
Gaudi::Property< std::vector< std::string > > m_inpKeys
Definition: CPUCruncher.h:55
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ isClonable()

bool CPUCruncher::isClonable | ( |  | ) | const
| inline override

Definition at line 24 of file CPUCruncher.h.

24 { return true; }

## ◆ operator=()

CPUCruncher& CPUCruncher::operator= | ( | const CPUCruncher & |  | ) |
| private

the assignement operator is disabled

## Member Data Documentation

## ◆ m_avg_runtime

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

Definition at line 58 of file CPUCruncher.h.

## ◆ m_crunchSvc

SmartIF<ICPUCrunchSvc> CPUCruncher::m_crunchSvc
| private

Definition at line 78 of file CPUCruncher.h.

## ◆ m_declAugmented

bool CPUCruncher::m_declAugmented {false}
| private

Definition at line 52 of file CPUCruncher.h.

## ◆ m_failNEvents

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

Definition at line 66 of file CPUCruncher.h.

## ◆ m_inpKeys

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

Definition at line 55 of file CPUCruncher.h.

## ◆ m_inputHandles

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

Definition at line 72 of file CPUCruncher.h.

## ◆ m_invertCFD

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

Definition at line 65 of file CPUCruncher.h.

## ◆ m_loader

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

Definition at line 53 of file CPUCruncher.h.

## ◆ m_local_rndm_gen

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 60 of file CPUCruncher.h.

## ◆ m_name_ncopies_map

CPUCruncher::CHM CPUCruncher::m_name_ncopies_map
| static private

Definition at line 75 of file CPUCruncher.h.

## ◆ m_outKeys

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

Definition at line 56 of file CPUCruncher.h.

## ◆ m_outputHandles

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

Definition at line 73 of file CPUCruncher.h.

## ◆ m_rwRepetitions

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

Definition at line 61 of file CPUCruncher.h.

## ◆ m_sleepFraction

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 62 of file CPUCruncher.h.

## ◆ m_var_runtime

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

Definition at line 59 of file CPUCruncher.h.

## ◆ MAX_INPUTS

const uint CPUCruncher::MAX_INPUTS = 40
| private

Definition at line 69 of file CPUCruncher.h.

## ◆ MAX_OUTPUTS

const uint CPUCruncher::MAX_OUTPUTS = 10
| private

Definition at line 70 of file CPUCruncher.h.

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

- GaudiHive/src/CPUCruncher.h
- GaudiHive/src/CPUCruncher.cpp