PSCF v1.4.0
Memory.cpp
1/*
2* Util Package - C++ Utilities for Scientific Computation
3*
4* Copyright 2010 - 2017, The Regents of the University of Minnesota
5* Distributed under the terms of the GNU General Public License.
6*/
7
8#include "Memory.h"
9
10namespace Util
11{
12
14 long int Memory::nAllocate_ = 0;
15
17 long int Memory::nDeallocate_ = 0;
18
20 long int Memory::total_ = 0;
21
23 long int Memory::max_ = 0;
24
25 /*
26 * Call this to ensure compilation of this file.
27 */
29 { max_ = 0; }
30
31 /*
32 * Return number of calls to allocate.
33 */
35 { return nAllocate_; }
36
37 /*
38 * Return number of calls to deallocate.
39 */
41 { return nDeallocate_; }
42
43 /*
44 * Return total amount of memory allocated thus far.
45 */
46 long int Memory::total()
47 { return total_; }
48
49 /*
50 * Return maximum amount of allocated memory thus far.
51 */
52 long int Memory::max()
53 { return max_; }
54
55 #ifdef UTIL_MPI
56 /*
57 * Return maximum amount of memory allocated on any one processor.
58 */
59 long int Memory::max(MPI::Intracomm& communicator)
60 {
61 long int maxGlobal;
62 long int maxLocal = max_;
63 communicator.Allreduce(&maxLocal, &maxGlobal, 1,
64 MPI::LONG_INT, MPI::MAX);
65 return maxGlobal;
66 }
67 #endif
68
69}
static long int nDeallocate()
Return number of times deallocate() was called.
Definition Memory.cpp:40
static long int nAllocate()
Return number of times allocate() was called.
Definition Memory.cpp:34
static long int max()
Return the maximum amount of allocated heap memory thus far.
Definition Memory.cpp:52
static long int total()
Return total amount of memory currently allocated.
Definition Memory.cpp:46
static void initStatic()
Call this just to guarantee initialization of static memory.
Definition Memory.cpp:28
Utility classes for scientific computation.