forked from abacusmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemory.h
More file actions
85 lines (73 loc) · 1.99 KB
/
memory.h
File metadata and controls
85 lines (73 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef MEMORY_H
#define MEMORY_H
#include <fstream>
#include <iomanip>
#include <iostream>
#include <string>
namespace ModuleBase
{
/**
* @brief Record memory consumption during computation.
* @author Mohan
* @note 8 bit = 1 Byte; 1024 Byte = 1 KB;
* 1024 KB = 1 MB; 1024 MB = 1 GB
*
*/
class Memory
{
public:
Memory();
~Memory();
/**
* @brief Record memory consumed during computation
*
* @param class_name The name of a class
* @param name The name of a quantity
* @param n The number of the quantity
* @param type The type of data
* @param accumulate Useless, always set false
* @return double
*/
static double record(const std::string &class_name,
const std::string &name,
const long &n,
const std::string &type,
const bool accumulate = false);
static double &get_total(void)
{
return total;
}
static void finish(std::ofstream &ofs);
/**
* @brief Print memory consumed (> 1 MB) in a file
*
* @param ofs The output file stream for print out memory records
*/
static void print_all(std::ofstream &ofs);
static void print(const int find_in);
/**
* @brief Calculate memory requirements for various
* types of data
*
* @param n The number of a type of data
* @param type The type of data
* @return double
*/
static double calculate_mem(const long &n, const std::string &type);
private:
static double total;
static std::string *name;
static std::string *class_name;
static double *consume;
static int n_memory;
static int n_now;
static bool init_flag;
static int complex_matrix_memory; //(16 Byte)
static int double_memory; //(8 Byte)
static int int_memory; //(4 Byte)
static int bool_memory;
static int short_memory; //(2 Byte)
static int float_memory; //(4 Byte)
};
} // namespace ModuleBase
#endif