ATLAS Offline Software
PerfMonTestPolyVectorAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include <map>
8 
9 #include "Hit.h"
11 
12 /* #define DEBUG_ME 1 */
13 
14 using namespace PerfMonTest;
15 using namespace::std;
16 
18 
20 // Public methods:
22 
23 // Constructors
25 PolyVectorAlg::PolyVectorAlg( const std::string& name,
26  ISvcLocator* pSvcLocator ) :
27  AthAlgorithm ( name, pSvcLocator ),
28  m_vectorSize(1024*1024), m_2bReserved(m_vectorSize), m_mixture(1), m_mapIt(false)
29 {
30  declareProperty("VectorSize", m_vectorSize, "the size of the Hit container");
31  declareProperty("ToBeReserved", m_2bReserved, "the number of element to be reserved");
32  declareProperty("Mixture", m_mixture, "equal to the ratio DHIT/FHIT - 1 (default 1 == all DHits)");
33  declareProperty("MapIt", m_mapIt, "add current hit to a map");
34 }
35 
36 // Destructor
39 {
40  ATH_MSG_DEBUG("Calling destructor");
41 }
42 
43 // Athena Algorithm's Hooks
46 {
47  ATH_MSG_INFO("Initializing ");
48  return StatusCode::SUCCESS;
49 }
50 
52 {
53  ATH_MSG_INFO("Finalizing ");
54  return StatusCode::SUCCESS;
55 }
56 
58 {
59  ATH_MSG_DEBUG("Executing ");
60  HitPtrContainer vptr;
61  vptr.reserve(m_2bReserved.value());
62  int vcap(vptr.capacity());
63  int vold;
64 #ifdef DEBUG_ME
65  IHit* p1(0);
66  IHit* p2(0);
67 #endif
68  IHit* p3(0);
69  cout << "initial capacity " << vcap << endl;
70  int size(m_vectorSize.value());
71  for(int i(0); i<size; ++i) {
72  vold=vcap;
73 #ifdef DEBUG_ME
74  p1=p2;
75  p2=p3;
76 #endif
77  p3=(i % m_mixture.value()) ?
78  (IHit*)new FHit(i, i, i):
79  (IHit*)new DHit(i, i, i);
80  vptr.push_back(p3);
81  vcap=vptr.capacity();
82  if (m_mapIt.value()) m_mixMap[i]=p3;
83  if (vold != vcap) cout << "iteration " << i << " new capacity " << vcap <<endl;
84 #ifdef DEBUG_ME
85  if (((int)p3-(int)p2) != ((int)p2-(int)p1)) cout << "iteration " << i << " new chunk @" << hex << p3 << " previous was @" << p2 << dec << endl;
86 #ifdef REALLY_DEBUG_ME
87  cout << "iteration " << i << " P3 @" << hex << p3 << " p2 @" << p2 << " p1 @" << p1 << dec << ' ' << (int)p3-(int)p2 << ' ' <<(int)p2-(int)p1 <<endl;
88 #endif
89 #endif
90  }
91 
92  return StatusCode::SUCCESS;
93 }
DataVector::reserve
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
HitPtrContainer
DataVector< IHit > HitPtrContainer
Definition: PerfMonTestPolyVectorAlg.cxx:17
PerfMonTest::PolyVectorAlg::m_mapIt
BooleanProperty m_mapIt
Property to introduce some fragmentation.
Definition: PerfMonTestPolyVectorAlg.h:46
PerfMonTest::FHit
Definition: Control/PerformanceMonitoring/PerfMonTests/src/Hit.h:30
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
PerfMonTest::PolyVectorAlg::m_2bReserved
IntegerProperty m_2bReserved
Property to setup the amount of elements to reserve.
Definition: PerfMonTestPolyVectorAlg.h:42
AthMsgStreamMacros.h
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
PerfMonTest::DHit
Definition: Control/PerformanceMonitoring/PerfMonTests/src/Hit.h:15
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
PerfMonTest::PolyVectorAlg::PolyVectorAlg
PolyVectorAlg()
no implementation
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
PerfMonTest::IHit
Definition: Control/PerformanceMonitoring/PerfMonTests/src/Hit.h:8
PerfMonTest::PolyVectorAlg::m_mixture
IntegerProperty m_mixture
Property to set DHIT/FHIT ratio.
Definition: PerfMonTestPolyVectorAlg.h:44
PerfMonTest::PolyVectorAlg::execute
virtual StatusCode execute()
Definition: PerfMonTestPolyVectorAlg.cxx:57
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
PerfMonTestPolyVectorAlg.h
lumiFormat.i
int i
Definition: lumiFormat.py:85
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
Hit.h
PerfMonTest
PerfMonTestPolyVectorAlg.h Example for the memory optimization tutorial.
Definition: Control/PerformanceMonitoring/PerfMonTests/src/Hit.h:7
PerfMonTest::PolyVectorAlg::finalize
virtual StatusCode finalize()
Definition: PerfMonTestPolyVectorAlg.cxx:51
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
AthAlgorithm
Definition: AthAlgorithm.h:47
DataVector::capacity
size_type capacity() const noexcept
Returns the total number of elements that the collection can hold before needing to allocate more mem...
PerfMonTest::PolyVectorAlg::m_mixMap
std::map< int, IHit * > m_mixMap
Definition: PerfMonTestPolyVectorAlg.h:47
PerfMonTest::PolyVectorAlg::m_vectorSize
IntegerProperty m_vectorSize
Property to setup the size of the Hit container.
Definition: PerfMonTestPolyVectorAlg.h:40
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataVector.h
An STL vector of pointers that by default owns its pointed-to elements.
PerfMonTest::PolyVectorAlg::~PolyVectorAlg
virtual ~PolyVectorAlg()
Destructor:
Definition: PerfMonTestPolyVectorAlg.cxx:38
TRTCalib_cfilter.p3
p3
Definition: TRTCalib_cfilter.py:132
PerfMonTest::PolyVectorAlg::initialize
virtual StatusCode initialize()
Definition: PerfMonTestPolyVectorAlg.cxx:45