ATLAS Offline Software
Control
PerformanceMonitoring
PerfMonTests
src
PerfMonTestCpuCruncherAlg.cxx
Go to the documentation of this file.
1
3
/*
4
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
// PerfMonTestCpuCruncherAlg.cxx
8
// Implementation file for class PerfMonTest::CpuCruncherAlg
9
// Author: S.Binet<binet@cern.ch>
11
12
13
// STL includes
14
#include <chrono>
15
#include <cmath>
16
17
// FrameWork includes
18
#include "Gaudi/Property.h"
19
20
// PerfMonTests includes
21
#include "
PerfMonTestCpuCruncherAlg.h
"
22
23
using namespace
PerfMonTest
;
24
26
// Public methods:
28
29
// Constructors
31
CpuCruncherAlg::CpuCruncherAlg
(
const
std::string&
name
,
32
ISvcLocator* pSvcLocator ) :
33
AthAlgorithm
(
name
, pSvcLocator ),
34
m_random(0)
35
{
36
//
37
// Property declaration
38
//
39
//declareProperty( "Property", m_nProperty );
40
41
declareProperty
(
"MeanCpu"
,
42
m_meanCpuTime
= 100.,
43
"Mean (in ms) of CPU time to consume."
);
44
45
declareProperty
(
"RmsCpu"
,
46
m_rmsCpuTime
= 5.,
47
"RMS (in ms) of CPU time to consume."
);
48
}
49
50
// Destructor
52
CpuCruncherAlg::~CpuCruncherAlg
()
53
{
54
ATH_MSG_DEBUG
(
"Calling destructor"
) ;
55
}
56
57
// Athena Algorithm's Hooks
59
StatusCode
CpuCruncherAlg::initialize
()
60
{
61
ATH_MSG_INFO
(
"Initializing "
<<
name
() <<
"..."
) ;
62
63
// Random number service
64
m_distribution
= std::normal_distribution<double>(
m_meanCpuTime
,
m_rmsCpuTime
);
65
66
ATH_MSG_INFO
(
"CPU usage configuration: <"
67
<<
m_meanCpuTime
<<
"> +/- "
68
<<
m_rmsCpuTime
<<
" ms"
) ;
69
70
71
return
StatusCode::SUCCESS;
72
}
73
74
StatusCode
CpuCruncherAlg::finalize
()
75
{
76
ATH_MSG_INFO
(
"Finalizing "
<<
name
() <<
"..."
) ;
77
return
StatusCode::SUCCESS;
78
}
79
80
StatusCode
CpuCruncherAlg::execute
()
81
{
82
ATH_MSG_DEBUG
(
"Executing "
<<
name
() <<
"..."
) ;
83
84
// Volatile to avoid optimization
85
volatile
double
test_result = 0.0;
86
87
// Sample randomly - use w/ care
88
double
ms_interval =
m_distribution
(
m_random
);
89
90
ATH_MSG_DEBUG
(
"Will burn CPU for "
<< ms_interval <<
" milliseconds ..."
);
91
92
// Define the interval, do some math until the interval is exhausted
93
std::chrono::duration<float, std::milli> chrono_interval(ms_interval);
94
95
auto
start
=
std::chrono::system_clock::now
();
96
97
while
(
std::chrono::system_clock::now
() -
start
< chrono_interval)
98
test_result +=
burn
(5000);
99
100
ATH_MSG_DEBUG
(
"Test result sum is "
<< test_result );
101
102
return
StatusCode::SUCCESS;
103
}
104
105
double
CpuCruncherAlg::burn
(
unsigned
long
nIterations = 10000000lu) {
106
107
// Volatile to avoid optimization
108
volatile
double
sum
= 0.0;
109
110
double
val
;
111
112
for
(
auto
idx
= 0lu;
idx
< nIterations; ++
idx
) {
113
val
= (
double
) (
idx
+ 1) / nIterations * 0.7854;
114
sum
+=
std::tan
(
std::log
(
val
));
115
}
116
117
return
sum
;
118
}
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition:
AthMsgStreamMacros.h:31
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition:
AthCommonDataStore.h:145
mergePhysValFiles.start
start
Definition:
DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
PerfMonTest::CpuCruncherAlg::finalize
virtual StatusCode finalize()
Definition:
PerfMonTestCpuCruncherAlg.cxx:74
PerfMonTest::CpuCruncherAlg::initialize
virtual StatusCode initialize()
Definition:
PerfMonTestCpuCruncherAlg.cxx:59
PerfMonTest::CpuCruncherAlg::burn
double burn(unsigned long nIterations)
Definition:
PerfMonTestCpuCruncherAlg.cxx:105
python.handimod.now
now
Definition:
handimod.py:675
convertTimingResiduals.sum
sum
Definition:
convertTimingResiduals.py:55
PerfMonTest::CpuCruncherAlg::m_meanCpuTime
float m_meanCpuTime
Property to setup the mean (in ms) of CPU time to consume.
Definition:
PerfMonTestCpuCruncherAlg.h:60
PerfMonTest::CpuCruncherAlg::m_distribution
std::normal_distribution< double > m_distribution
Definition:
PerfMonTestCpuCruncherAlg.h:67
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition:
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition:
AthMsgStreamMacros.h:29
PerfMonTest::CpuCruncherAlg::CpuCruncherAlg
CpuCruncherAlg()
Default constructor:
PerfMonTest::CpuCruncherAlg::execute
virtual StatusCode execute()
Definition:
PerfMonTestCpuCruncherAlg.cxx:80
PerfMonTestCpuCruncherAlg.h
PerfMonTest
PerfMonTestPolyVectorAlg.h Example for the memory optimization tutorial.
Definition:
Control/PerformanceMonitoring/PerfMonTests/src/Hit.h:7
drawFromPickle.tan
tan
Definition:
drawFromPickle.py:36
xAOD::double
double
Definition:
CompositeParticle_v1.cxx:159
AthAlgorithm
Definition:
AthAlgorithm.h:47
PerfMonTest::CpuCruncherAlg::m_rmsCpuTime
float m_rmsCpuTime
Property to setup the RMS (in ms) of CPU time to consume.
Definition:
PerfMonTestCpuCruncherAlg.h:63
name
std::string name
Definition:
Control/AthContainers/Root/debug.cxx:228
Pythia8_RapidityOrderMPI.val
val
Definition:
Pythia8_RapidityOrderMPI.py:14
PerfMonTest::CpuCruncherAlg::~CpuCruncherAlg
virtual ~CpuCruncherAlg()
Destructor:
Definition:
PerfMonTestCpuCruncherAlg.cxx:52
python.CaloCondTools.log
log
Definition:
CaloCondTools.py:20
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition:
LArNewCalib_DelayDump_OFC_Cali.py:69
PerfMonTest::CpuCruncherAlg::m_random
std::default_random_engine m_random
Random number setup.
Definition:
PerfMonTestCpuCruncherAlg.h:66
Generated on Sun Dec 22 2024 21:16:05 for ATLAS Offline Software by
1.8.18