ATLAS Offline Software
PerfMonTestPolyVectorAlgWithArenas.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include "AthAllocators/DataPool.h" /* NEW */
8 
9 #include "Hit.h"
11 /* #define DEBUG_ME 1 */
12 
13 using namespace PerfMonTest;
14 
16 
17 
19 {
20  DataPool<DHit> dhitPool;
21  DataPool<FHit> fhitPool;
22  ATH_MSG_DEBUG("Executing ");
23  HitPtrContainer vptr(SG::VIEW_ELEMENTS); //<<< NEW
24  vptr.reserve(m_2bReserved.value());
25  int vcap(vptr.capacity());
26  int vold;
27 #ifdef DEBUG_ME
28  IHit* p1(0);
29  IHit* p2(0);
30 #endif
31  IHit* p3(0);
32  std::cout << "initial capacity " << vcap << std::endl;
33  int size(m_vectorSize.value());
34  for(int i(0); i<size; ++i) {
35  vold=vcap;
36 #ifdef DEBUG_ME
37  p1=p2;
38  p2=p3;
39 #endif
40  p3=(i % m_mixture.value()) ?
41  (IHit*) new(fhitPool.nextElementPtr()) FHit(i, i, i):
42  (IHit*) new(dhitPool.nextElementPtr()) DHit(i, i, i); //<<< NEW
43  vptr.push_back(p3);
44  vcap=vptr.capacity();
45  if (m_mapIt.value()) m_mixMap[i]=p3;
46  if (vold != vcap) std::cout << "iteration " << i << " new capacity " << vcap <<std::endl;
47 #ifdef DEBUG_ME
48  if (((int)p3-(int)p2) != ((int)p2-(int)p1)) std::cout << "iteration " << i << " new chunk @" << hex << p3 << " previous was @" << p2 << dec << std::endl;
49 #ifdef REALLY_DEBUG_ME
50  std::cout << "iteration " << i << " P3 @" << hex << p3 << " p2 @" << p2 << " p1 @" << p1 << dec << ' ' << (int)p3-(int)p2 << ' ' <<(int)p2-(int)p1 <<std::endl;
51 #endif
52 #endif
53  }
54 
55  return StatusCode::SUCCESS;
56 }
DataVector::reserve
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
PerfMonTest::FHit
Definition: Control/PerformanceMonitoring/PerfMonTests/src/Hit.h:30
AthMsgStreamMacros.h
PerfMonTest::PolyVectorAlgWithArenas::m_mapIt
Gaudi::Property< bool > m_mapIt
Property to introduce some fragmentation.
Definition: PerfMonTestPolyVectorAlgWithArenas.h:36
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
PerfMonTest::PolyVectorAlgWithArenas::m_vectorSize
Gaudi::Property< int > m_vectorSize
Property to setup the size of the Hit container.
Definition: PerfMonTestPolyVectorAlgWithArenas.h:30
PerfMonTest::DHit
Definition: Control/PerformanceMonitoring/PerfMonTests/src/Hit.h:15
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
PerfMonTest::IHit
Definition: Control/PerformanceMonitoring/PerfMonTests/src/Hit.h:8
PerfMonTestPolyVectorAlgWithArenas.h
PerfMonTest::PolyVectorAlgWithArenas::m_2bReserved
Gaudi::Property< int > m_2bReserved
Property to setup the amount of elements to reserve.
Definition: PerfMonTestPolyVectorAlgWithArenas.h:32
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
PerfMonTest::PolyVectorAlgWithArenas::execute
virtual StatusCode execute() override
Definition: PerfMonTestPolyVectorAlgWithArenas.cxx:18
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
DataPool::nextElementPtr
pointer nextElementPtr()
obtain the next available element in pool by pointer pool is resized if its limit has been reached On...
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
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
HitPtrContainer
DataVector< IHit > HitPtrContainer
Definition: PerfMonTestPolyVectorAlgWithArenas.cxx:15
DataVector::capacity
size_type capacity() const noexcept
Returns the total number of elements that the collection can hold before needing to allocate more mem...
DataPool.h
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
PerfMonTest::PolyVectorAlgWithArenas::m_mixture
Gaudi::Property< int > m_mixture
Property to set DHIT/FHIT ratio.
Definition: PerfMonTestPolyVectorAlgWithArenas.h:34
DataVector.h
An STL vector of pointers that by default owns its pointed-to elements.
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
PerfMonTest::PolyVectorAlgWithArenas::m_mixMap
std::map< int, IHit * > m_mixMap
Definition: PerfMonTestPolyVectorAlgWithArenas.h:37
DataPool
a typed memory pool that saves time spent allocation small object. This is typically used by containe...
Definition: DataPool.h:63
TRTCalib_cfilter.p3
p3
Definition: TRTCalib_cfilter.py:132