7 #include <tbb/tick_count.h> 11 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) ) 12 #define DEBUG_MSG ON_DEBUG debug() 14 #define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) ) 15 #define VERBOSE_MSG ON_VERBOSE verbose() 26 if ( base_class::initialize().isFailure() ) {
27 error() <<
"Error initializing base class" <<
endmsg;
44 m_niters_vect = {0, 500, 600, 700, 800, 1000, 1300, 1600, 2000, 2300,
45 2600, 3000, 3300, 3500, 3900, 4200, 5000, 6000, 8000, 10000,
46 12000, 15000, 17000, 20000, 25000, 30000, 35000, 40000, 50000, 60000};
56 warning() <<
"NIterationsVect[0]= " <<
m_niters_vect.value().at( 0 ) <<
" but needs to be zero. resetting it." 71 debug() <<
"Starting calibration run " << irun + 1 <<
" ..." <<
endmsg;
72 for (
unsigned int i = 1; i <
m_niters_vect.value().size(); ++i ) {
74 unsigned int trials = 30;
76 auto start_cali = tbb::tick_count::now();
78 auto stop_cali = tbb::tick_count::now();
79 auto deltat = ( stop_cali - start_cali ).seconds();
85 if ( i ==
m_niters_vect.value().size() - 1 && minCalibTime_us != 0 ) {
106 unsigned int smaller_i = 0;
109 double corrRuntime = runtime.
count();
113 if ( time > corrRuntime ) {
129 const double m = (double)( y1 - y0 ) / (double)( x1 - x0 );
130 const double q = y0 - m * x0;
132 const unsigned int nCaliIters = m * corrRuntime + q;
134 VERBOSE_MSG <<
"x0: " << x0 <<
" x1: " << x1 <<
" y0: " << y0 <<
" y1: " << y1 <<
" m: " << m <<
" q: " << q
135 <<
" itr: " << nCaliIters <<
endmsg;
147 unsigned int primes_size = 1;
148 unsigned long* primes =
new unsigned long[primes_size];
154 for (
unsigned long int iiter = 0; iiter < n_iterations; iiter++ ) {
160 for (
unsigned long j = 2; j < i && is_prime; ++j ) {
161 if ( i % j == 0 ) is_prime =
false;
166 unsigned int new_primes_size = 1 + primes_size;
167 unsigned long* new_primes =
new unsigned long[new_primes_size];
169 for (
unsigned int prime_index = 0; prime_index < primes_size; prime_index++ ) {
170 new_primes[prime_index] = primes[prime_index];
173 new_primes[primes_size] = i;
178 primes_size = new_primes_size;
184 for (
unsigned int prime_index = 0; prime_index < primes_size; prime_index++ )
185 if ( primes[prime_index] == 4 )
186 debug() <<
"This does never happen, but it's necessary too fool aggressive compiler optimisations!" <<
endmsg;
198 auto start_cali = tbb::tick_count::now();
200 auto stop_cali = tbb::tick_count::now();
204 DEBUG_MSG <<
"crunch for " << crunchtime.
count() <<
" ms == " << niters <<
" iter. actual time: " << actual.
count()
205 <<
" ms. ratio: " << float( actual.
count() ) / crunchtime.
count() <<
endmsg;
unsigned int getNCaliIters(std::chrono::microseconds runtime) const
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Gaudi::Property< unsigned int > m_minCalibTime
void findPrimes(unsigned int) const
constexpr static const auto SUCCESS
#define DECLARE_COMPONENT(type)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
This class is used for returning status codes from appropriate routines.
Gaudi::Property< bool > m_shortCalib
Gaudi::Property< float > m_corrFact
Gaudi::Property< int > m_numCalibRuns
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
constexpr static const auto FAILURE
virtual StatusCode initialize() override
std::vector< unsigned int > m_times_vect
CPUCrunchSvc(const std::string &name, ISvcLocator *svc)
std::chrono::milliseconds crunch_for(const std::chrono::milliseconds &crunchtime) const override
Gaudi::Property< std::vector< unsigned int > > m_niters_vect
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.