16 #include <sys/times.h> 17 #include <tbb/tick_count.h> 21 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) ) 22 #define DEBUG_MSG ON_DEBUG debug() 24 #define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) ) 25 #define VERBOSE_MSG ON_VERBOSE verbose() 36 if ( base_class::initialize().isFailure() ) {
37 error() <<
"Error initializing base class" <<
endmsg;
54 m_niters_vect = {0, 500, 600, 700, 800, 1000, 1300, 1600, 2000, 2300,
55 2600, 3000, 3300, 3500, 3900, 4200, 5000, 6000, 8000, 10000,
56 12000, 15000, 17000, 20000, 25000, 30000, 35000, 40000, 50000, 60000};
66 warning() <<
"NIterationsVect[0]= " <<
m_niters_vect.value().at( 0 ) <<
" but needs to be zero. resetting it." 81 debug() <<
"Starting calibration run " << irun + 1 <<
" ..." <<
endmsg;
82 for (
unsigned int i = 1; i <
m_niters_vect.value().size(); ++i ) {
84 unsigned int trials = 30;
86 auto start_cali = tbb::tick_count::now();
88 auto stop_cali = tbb::tick_count::now();
89 auto deltat = ( stop_cali - start_cali ).seconds();
95 if ( i ==
m_niters_vect.value().size() - 1 && minCalibTime_us != 0 ) {
116 unsigned int smaller_i = 0;
119 double corrRuntime = runtime.
count();
123 if (
time > corrRuntime ) {
139 const double m = (double)( y1 - y0 ) / (double)( x1 - x0 );
140 const double q = y0 -
m * x0;
142 const unsigned int nCaliIters =
m * corrRuntime + q;
144 VERBOSE_MSG <<
"x0: " << x0 <<
" x1: " << x1 <<
" y0: " << y0 <<
" y1: " << y1 <<
" m: " <<
m <<
" q: " << q
145 <<
" itr: " << nCaliIters <<
endmsg;
157 unsigned int primes_size = 1;
158 unsigned long* primes =
new unsigned long[primes_size];
164 for (
unsigned long int iiter = 0; iiter < n_iterations; iiter++ ) {
170 for (
unsigned long j = 2; j < i && is_prime; ++j ) {
171 if ( i % j == 0 ) is_prime =
false;
176 unsigned int new_primes_size = 1 + primes_size;
177 unsigned long* new_primes =
new unsigned long[new_primes_size];
179 for (
unsigned int prime_index = 0; prime_index < primes_size; prime_index++ ) {
180 new_primes[prime_index] = primes[prime_index];
183 new_primes[primes_size] = i;
188 primes_size = new_primes_size;
194 for (
unsigned int prime_index = 0; prime_index < primes_size; prime_index++ )
195 if ( primes[prime_index] == 4 )
196 debug() <<
"This does never happen, but it's necessary too fool aggressive compiler optimisations!" <<
endmsg;
208 auto start_cali = tbb::tick_count::now();
210 auto stop_cali = tbb::tick_count::now();
214 DEBUG_MSG <<
"crunch for " << crunchtime.
count() <<
" ms == " << niters <<
" iter. actual time: " << actual.
count()
215 <<
" ms. ratio: " << float( actual.
count() ) / crunchtime.
count() <<
endmsg;
std::chrono::milliseconds crunch_for(const std::chrono::milliseconds &crunchtime) const override
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Gaudi::Property< unsigned int > m_minCalibTime
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
constexpr static const auto SUCCESS
#define DECLARE_COMPONENT(type)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
unsigned int getNCaliIters(std::chrono::microseconds runtime) const
Gaudi::Property< bool > m_shortCalib
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Gaudi::Property< float > m_corrFact
Gaudi::Property< int > m_numCalibRuns
void findPrimes(unsigned int) const
constexpr static const auto FAILURE
virtual StatusCode initialize() override
std::vector< unsigned int > m_times_vect
CPUCrunchSvc(const std::string &name, ISvcLocator *svc)
Gaudi::Property< std::vector< unsigned int > > m_niters_vect
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.