Block-Structured AMR Software Framework
AMReX_MemProfiler.H
Go to the documentation of this file.
1 
2 #ifndef BL_MEMPROFILER_H
3 #define BL_MEMPROFILER_H
4 #include <AMReX_Config.H>
5 
6 #include <AMReX_INT.H>
7 
8 #include <stack>
9 #include <functional>
10 #include <string>
11 #include <vector>
12 #include <map>
13 #include <iosfwd>
14 #include <memory>
15 
16 namespace amrex {
17 
19 {
20 public:
21 
22  struct MemInfo {
24  Long hwm_bytes;
25  };
26 
27  struct NBuildsInfo {
30  };
31 
32  static void add (const std::string& name, std::function<MemInfo()>&& f);
33  static void add (const std::string& name, std::function<NBuildsInfo()>&& f);
34 
35  static void report (const std::string& prefix = std::string());
36 
37  static void Finalize ();
38 
39  MemProfiler (const MemProfiler&) = delete;
40  MemProfiler& operator= (const MemProfiler&) = delete;
41 
44 
45 private:
46 
47  void report_ (const std::string& prefix, const std::string& memory_log_name) const;
48 
49  struct Bytes {
50  Long mn;
51  Long mx;
52  };
53  friend std::ostream& operator<< (std::ostream& os,
54  const MemProfiler::Bytes& bytes);
55 
56  struct Builds {
57  int mn;
58  int mx;
59  };
60  friend std::ostream& operator<< (std::ostream& os,
61  const MemProfiler::Builds& builds);
62 
63  static MemProfiler& getInstance ();
64 
65  static std::unique_ptr<MemProfiler> the_instance;
66 
67  std::vector<std::string> the_names;
68  std::vector<std::function<MemInfo()> > the_funcs;
69 
70  std::vector<std::string> the_names_builds;
71  std::vector<std::function<NBuildsInfo()> > the_funcs_builds;
72 };
73 
74 }
75 
76 #endif
Definition: AMReX_MemProfiler.H:19
void report_(const std::string &prefix, const std::string &memory_log_name) const
Definition: AMReX_MemProfiler.cpp:79
std::vector< std::function< NBuildsInfo()> > the_funcs_builds
Definition: AMReX_MemProfiler.H:71
~MemProfiler()
Definition: AMReX_MemProfiler.H:43
std::vector< std::string > the_names_builds
Definition: AMReX_MemProfiler.H:70
static std::unique_ptr< MemProfiler > the_instance
Definition: AMReX_MemProfiler.H:65
static MemProfiler & getInstance()
Definition: AMReX_MemProfiler.cpp:51
MemProfiler & operator=(const MemProfiler &)=delete
static void add(const std::string &name, std::function< MemInfo()> &&f)
Definition: AMReX_MemProfiler.cpp:25
static void report(const std::string &prefix=std::string())
Definition: AMReX_MemProfiler.cpp:66
static void Finalize()
Definition: AMReX_MemProfiler.cpp:60
std::vector< std::function< MemInfo()> > the_funcs
Definition: AMReX_MemProfiler.H:68
MemProfiler(const MemProfiler &)=delete
friend std::ostream & operator<<(std::ostream &os, const MemProfiler::Bytes &bytes)
Definition: AMReX_MemProfiler.cpp:331
MemProfiler()
Definition: AMReX_MemProfiler.H:42
std::vector< std::string > the_names
Definition: AMReX_MemProfiler.H:67
static int f(amrex::Real t, N_Vector y_data, N_Vector y_rhs, void *user_data)
Definition: AMReX_SundialsIntegrator.H:44
Definition: AMReX_Amr.cpp:49
Definition: AMReX_MemProfiler.H:56
int mn
Definition: AMReX_MemProfiler.H:57
int mx
Definition: AMReX_MemProfiler.H:58
Definition: AMReX_MemProfiler.H:49
Long mx
Definition: AMReX_MemProfiler.H:51
Long mn
Definition: AMReX_MemProfiler.H:50
Definition: AMReX_MemProfiler.H:22
Long current_bytes
Definition: AMReX_MemProfiler.H:23
Long hwm_bytes
Definition: AMReX_MemProfiler.H:24
Definition: AMReX_MemProfiler.H:27
int current_builds
Definition: AMReX_MemProfiler.H:28
int hwm_builds
Definition: AMReX_MemProfiler.H:29