ATLAS Offline Software
LWPools.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 // //
8 // Implementation of class LWPools //
9 // //
10 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11 // Initial version: May 2009 //
12 // //
14 
15 #include "LWPools.h"
16 
17 //____________________________________________________________________
18 LWPools::PoolList LWPools::s_pools;
19 std::atomic<long long> LWPools::s_bytesDynAlloc = 0;
20 
21 //____________________________________________________________________
22 LWPools::PoolList::PoolList()
23 {
24  nullout();
25 }
26 
27 //____________________________________________________________________
28 void LWPools::PoolList::nullout()
29 {
30  for (size_t i = 0; i < LWPoolSelector::nPools(); i++) {
31  m_poolarr[i] = nullptr;
32  }
33 }
34 
35 //____________________________________________________________________
36 void LWPools::PoolList::cleanup()
37 {
38 #ifdef LW_DEBUG_POOLS_DEBUG_USAGE
39  std::scoped_lock lock (m_mutex);
40  if (!m_memoryHandedOut.empty())
41  std::cout<<"LWPools::PoolList::cleanup() WARNING: "<<m_memoryHandedOut.size()
42  <<" unreleased pool allocations"<<std::endl;
43 #endif
44  for (unsigned i=0;i<LWPoolSelector::nPools();++i) {
45  LWPool* p = m_poolarr[i].exchange (nullptr);
46  if (p)
47  s_bytesDynAlloc -= sizeof(LWPool);
48  delete p;
49  }
51 }
52 
53 //____________________________________________________________________
54 LWPool * LWPools::initPool(unsigned idx,unsigned length)
55 {
59  s_bytesDynAlloc += sizeof(LWPool);
60  LWPool* exp = nullptr;
61  s_pools[idx].compare_exchange_strong (exp, pool);
62  if (exp) {
63  s_bytesDynAlloc -= sizeof(LWPool);
64  delete pool;
65  pool = exp;
66  }
67  return pool;
68 }
69 
70 //____________________________________________________________________
72 {
73  s_pools.cleanup();
74  //Fixme: something here to flush mother pool also
75 }
76 
77 //____________________________________________________________________
79 {
81 }
82 
83 //____________________________________________________________________
85 {
86  long long l(s_bytesDynAlloc);
87  for (unsigned i=0;i<LWPoolSelector::nPools();++i) {
88  LWPool* p = s_pools[i];
89  if (p) l+=p->getMemDishedOut();
90  }
91  return l;
92 }
LWPoolSelector::nPools
static unsigned nPools()
Definition: LWPoolSelector.h:31
LWPools.h
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
LWPools::getTotalPoolMemUsed
static long long getTotalPoolMemUsed()
Definition: LWPools.cxx:84
LWPools::getTotalPoolMemAllocated
static long long getTotalPoolMemAllocated()
Definition: LWPools.cxx:78
LWPoolSelector::numberOfPools
static const unsigned numberOfPools
Definition: LWPoolSelector.h:30
pool
pool namespace
Definition: libname.h:15
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
LWPool::forceCleanupMotherPool
static void forceCleanupMotherPool()
Definition: LWPool.cxx:206
lumiFormat.i
int i
Definition: lumiFormat.py:92
LWPoolSelector::poolSize
static unsigned poolSize(unsigned requestsize)
Definition: LWPoolSelector.h:53
LWPools::s_bytesDynAlloc
static std::atomic< long long > s_bytesDynAlloc
Definition: LWPools.h:60
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
LWPool
Definition: LWPool.h:24
LWPoolSelector::poolIndex
static unsigned poolIndex(unsigned requestsize)
Definition: LWPoolSelector.h:73
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
LWPools::cleanup
static void cleanup()
Definition: LWPools.cxx:71
LWPool::getMotherMemOwned
static long long getMotherMemOwned()
Definition: LWPool.cxx:83
LWPools::initPool
static LWPool * initPool(unsigned poolIndex, unsigned length)
Definition: LWPools.cxx:54