PSCF v1.1
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 int Memory::nAllocate_ = 0;
15
17 int Memory::nDeallocate_ = 0;
18
20 int Memory::total_ = 0;
21
23 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 */
47 { return total_; }
48
49 /*
50 * Return maximum amount of allocated memory thus far.
51 */
53 { return max_; }
54
55 #ifdef UTIL_MPI
56 int Memory::max(MPI::Intracomm& communicator)
57 {
58 int maxGlobal;
59 int maxLocal = max_;
60 communicator.Allreduce(&maxLocal, &maxGlobal, 1, MPI::INT, MPI::MAX);
61 return maxGlobal;
62 }
63 #endif
64
65}
static int max()
Return the maximum amount of allocated heap memory thus far.
Definition: Memory.cpp:52
static int nAllocate()
Return number of times allocate() was called.
Definition: Memory.cpp:34
static void initStatic()
Call this just to guarantee initialization of static memory.
Definition: Memory.cpp:28
static int total()
Return total amount of memory currently allocated.
Definition: Memory.cpp:46
static int nDeallocate()
Return number of times deallocate() was called.
Definition: Memory.cpp:40
Utility classes for scientific computation.
Definition: accumulators.mod:1