SIRIUS
7.5.0
Electronic structure library and applications
src
core
power.hpp
Go to the documentation of this file.
1
/** \file power.hpp
2
*
3
* \brief Read power counters on Cray.
4
*/
5
6
#include <fstream>
7
#include <string>
8
9
namespace
sirius
{
10
namespace
power {
11
12
static
double
read_pm_file(
const
std::string& fname)
13
{
14
double
result = 0.;
15
std::ifstream fid(fname.c_str());
16
17
fid >> result;
18
// std::cout << fname << " :: " << result << std::endl;
19
return
result;
20
}
21
22
static
double
device_energy(
void
)
23
{
24
return
read_pm_file(
"/sys/cray/pm_counters/accel_energy"
);
25
}
26
27
static
double
energy()
28
{
29
return
read_pm_file(
"/sys/cray/pm_counters/energy"
);
30
}
31
32
static
double
device_power()
33
{
34
return
read_pm_file(
"/sys/cray/pm_counters/accel_power"
);
35
}
36
37
static
double
power()
38
{
39
return
read_pm_file(
"/sys/cray/pm_counters/power"
);
40
}
41
42
static
int
num_nodes()
43
{
44
// find out the number of nodes
45
char
* ptr = std::getenv(
"SLURM_JOB_NUM_NODES"
);
46
if
(ptr) {
47
return
atoi(ptr);
48
}
else
{
49
return
-1;
50
}
51
}
52
53
}
// namespace power
54
}
// namespace sirius
sirius
Namespace of the SIRIUS library.
Definition:
sirius.f90:5
Generated on Wed Nov 22 2023 17:00:15 for SIRIUS by
1.9.3