Chombo + EB  3.2
memusage.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
7  * Please refer to Copyright.txt, in Chombo's root directory.
8  */
9 #endif
10 
11 #ifndef _MEMUSAGE_H_
12 #define _MEMUSAGE_H_
13 
14 #include "REAL.H"
15 #include "BaseNamespaceHeader.H"
16 
17 ///
18 /**
19 Print a line of memory information to pout() with a string label
20  */
21 void print_memory_line(const char *);
22 
23 ///
24 /**
25 Print a line of memory information to pout()
26  */
27 void print_memory_line(void);
28 
29 ///
30 /**
31  If Linux, uses /proc/self/status to find the peak residentSetSize of process
32  and the peak VM size. Units should be MB.
33  Returns 0 if not Linux.
34  */
35 void getPeakMemoryFromOS(Real& VmPeak, Real& VmHWM);
36 
37 ///
38 /**
39  Return the residentSetSize of process from either /proc/self/statm or getrusage(RUSAGE_SELF, &rus)
40  Units should be MB.
41  If /proc/self/statm is used (Linux only), then VM size is also returned.
42  */
43 void getMemoryUsageFromOS(Real& residentSetSize, Real& size);
44 
45 ///
46 /**
47  Maintain backward compatibility in code.
48  Return the residentSetSize of process from either /proc/self/statm or getrusage(RUSAGE_SELF, &rus)
49  Units should be MB.
50  */
52 
53 /**
54 verison that does not convert things to floating-point values
55 */
56 
57 void getMemoryUsageSize(unsigned int& residentSize, unsigned int& size);
58 ///
59 /**
60  */
61 inline unsigned int getMemorySize(void)
62 {
63  unsigned int r, s;
64  getMemoryUsageSize(r, s);
65  return r;
66 }
67 
68 void gather_memory_from_procs(Real end_memory,
69  Real &avg_memory,
70  Real &min_memory,
71  Real &max_memory);
72 
73 void reduce_print_avg_min_max(const char* s, Real value);
74 int reduce_avg_min_max(Real value, Real &avg, Real &min, Real &max);
75 int reduce_avg_min_max_loc(Real value, Real& avg, Real& min, Real& max, int& minloc, int& maxloc);
76 
77 #include "BaseNamespaceFooter.H"
78 
79 #endif
void gather_memory_from_procs(Real end_memory, Real &avg_memory, Real &min_memory, Real &max_memory)
void getMemoryUsageSize(unsigned int &residentSize, unsigned int &size)
IndexTM< T, N > min(const IndexTM< T, N > &a_p1, const IndexTM< T, N > &a_p2)
Definition: IndexTMI.H:394
unsigned int getMemorySize(void)
Definition: memusage.H:61
void getPeakMemoryFromOS(Real &VmPeak, Real &VmHWM)
void print_memory_line(const char *)
double Real
Definition: REAL.H:33
Real get_memory_usage_from_OS(void)
IndexTM< T, N > max(const IndexTM< T, N > &a_p1, const IndexTM< T, N > &a_p2)
Definition: IndexTMI.H:401
int reduce_avg_min_max_loc(Real value, Real &avg, Real &min, Real &max, int &minloc, int &maxloc)
int reduce_avg_min_max(Real value, Real &avg, Real &min, Real &max)
void getMemoryUsageFromOS(Real &residentSetSize, Real &size)
void reduce_print_avg_min_max(const char *s, Real value)