Module: BOAST::PowercapProbe
Class Method Summary
collapse
address_size, address_size=, annotate, annotate=, annotate?, annotate_indepth_list, annotate_indepth_list=, annotate_level, annotate_level=, annotate_list, annotate_list=, architecture, architecture=, array_start, array_start=, chain_code, chain_code=, chain_code?, debug, debug=, debug?, debug_source, debug_source=, debug_source?, decl_module, decl_module=, decl_module?, default_align, default_align=, default_int_signed, default_int_signed=, default_int_signed?, default_int_size, default_int_size=, default_real_size, default_real_size=, disable_openmp, disable_openmp=, disable_openmp?, ffi, ffi=, ffi?, fortran_line_length, fortran_line_length=, get_address_size, get_annotate, get_annotate_indepth_list, get_annotate_level, get_annotate_list, get_architecture, get_array_start, get_chain_code, get_debug, get_debug_source, get_decl_module, get_default_align, get_default_int_signed, get_default_int_size, get_default_real_size, get_disable_openmp, get_ffi, get_fortran_line_length, get_indent_increment, get_indent_level, get_keep_temp, get_lang, get_model, get_optimizer_log, get_optimizer_log_file, get_output, get_replace_constants, get_use_vla, get_verbose, indent_increment, indent_increment=, indent_level, indent_level=, keep_temp, keep_temp=, keep_temp?, lang, lang=, model, model=, optimizer_log, optimizer_log=, optimizer_log?, optimizer_log_file, optimizer_log_file=, output, output=, replace_constants, replace_constants=, replace_constants?, set_address_size, set_annotate, set_annotate_indepth_list, set_annotate_level, set_annotate_list, set_architecture, set_array_start, set_chain_code, set_debug, set_debug_source, set_decl_module, set_default_align, set_default_int_signed, set_default_int_size, set_default_real_size, set_disable_openmp, set_ffi, set_fortran_line_length, set_indent_increment, set_indent_level, set_keep_temp, set_lang, set_model, set_optimizer_log, set_optimizer_log_file, set_output, set_replace_constants, set_use_vla, set_verbose, use_vla, use_vla=, use_vla?, verbose, verbose=, verbose?
Class Method Details
.compute ⇒ Object
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/BOAST/Runtime/EnergyProbe.rb', line 113
def compute
get_output.print <<EOF
{
VALUE results;
int i;
results = rb_hash_new();
for(i=0; i < _boast_energy_nsensors; ++i){
rb_hash_aset(results, ID2SYM(rb_intern(_boast_energy_names[i])), rb_float_new((_boast_energy_1[i] - _boast_energy_0[i]) * 1e-6));
}
rb_hash_aset(_boast_stats, ID2SYM(rb_intern("energy")), results);
}
EOF
end
|
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
|
# File 'lib/BOAST/Runtime/EnergyProbe.rb', line 16
def configure
get_output.print <<EOF
{
char buf[128];
char path[128];
char *s;
FILE *f;
int nproc;
int i;
if( _boast_energy_nsensors ){
free(_boast_energy_files);
for(i=0; i < _boast_energy_nsensors; ++i)
free(_boast_energy_names[i]);
free(_boast_energy_names);
_boast_energy_nsensors = 0;
}
_boast_energy_files = malloc(1);
_boast_energy_names = malloc(1);
for(nproc = 0; ; ++nproc){
sprintf(path,"/sys/devices/virtual/powercap/intel-rapl/intel-rapl:%d",nproc);
sprintf(buf,"%s/energy_uj",path);
f = fopen(buf, "rt");
if(!f)
break;
i = 0;
do{
int _boast_fread_ret;
fclose(f);
++_boast_energy_nsensors;
_boast_energy_files = realloc(_boast_energy_files, _boast_energy_nsensors * sizeof(*_boast_energy_files));
_boast_energy_names = realloc(_boast_energy_names, _boast_energy_nsensors * sizeof(*_boast_energy_names));
_boast_energy_files[_boast_energy_nsensors-1] = malloc(128);
_boast_energy_names[_boast_energy_nsensors-1] = malloc( 16);
s = _boast_energy_names[_boast_energy_nsensors-1];
sprintf(_boast_energy_files[_boast_energy_nsensors-1],"%s",buf);
sprintf(buf, "%s/name", path);
f = fopen(buf, "r");
_boast_fread_ret = fread(buf, 1, sizeof(buf), f);
fclose(f);
if(_boast_fread_ret == 0)
rb_raise(rb_eArgError, "Energy probe read error!");
/* last character read is a line break */
buf[_boast_fread_ret-1] = 0;
sprintf(s, "%d.%s", nproc, buf);
sprintf(path,"/sys/devices/virtual/powercap/intel-rapl/intel-rapl:%d/intel-rapl:%d:%d",nproc,nproc,i++);
sprintf(buf,"%s/energy_uj",path);
f = fopen(buf, "rt");
}while(f);
}
if( ! _boast_energy_nsensors ){
free( _boast_energy_files );
free( _boast_energy_names );
}else{
_boast_energy_0 = malloc(_boast_energy_nsensors * sizeof(*_boast_energy_0));
_boast_energy_1 = malloc(_boast_energy_nsensors * sizeof(*_boast_energy_1));
}
}
EOF
end
|
.decl ⇒ Object
9
10
11
12
13
14
15
|
# File 'lib/BOAST/Runtime/EnergyProbe.rb', line 9
def decl
get_output.puts "char **_boast_energy_files = 0;"
get_output.puts "char **_boast_energy_names = 0;"
get_output.puts "uint64_t *_boast_energy_0 = 0;"
get_output.puts "uint64_t *_boast_energy_1 = 0;"
get_output.puts "int _boast_energy_nsensors = 0;"
end
|
5
6
7
8
|
# File 'lib/BOAST/Runtime/EnergyProbe.rb', line 5
def
get_output.puts "#include <stdio.h>"
get_output.puts "#include <stdint.h>"
end
|
.is_available? ⇒ Boolean
126
127
128
|
# File 'lib/BOAST/Runtime/EnergyProbe.rb', line 126
def is_available?
[] != Dir.glob( '/sys/class/powercap/intel-rapl:0:0' )
end
|
.start ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/BOAST/Runtime/EnergyProbe.rb', line 77
def start
get_output.print <<EOF
{
char buf[32];
FILE *f;
int i;
for(i = 0; i < _boast_energy_nsensors; ++i){
int _boast_fread_ret;
f = fopen(_boast_energy_files[i], "r");
_boast_fread_ret = fread(buf, 1, sizeof(buf), f);
fclose(f);
if(_boast_fread_ret == 0)
rb_raise(rb_eArgError, "Energy probe read error!");
_boast_energy_0[i] = atoll(buf);
}
}
EOF
end
|
.stop ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# File 'lib/BOAST/Runtime/EnergyProbe.rb', line 95
def stop
get_output.print <<EOF
{
char buf[32];
FILE *f;
int i;
for(i = 0; i < _boast_energy_nsensors; ++i){
int _boast_fread_ret;
f = fopen(_boast_energy_files[i], "r");
_boast_fread_ret = fread(buf, 1, sizeof(buf), f);
fclose(f);
if(_boast_fread_ret == 0)
rb_raise(rb_eArgError, "Energy probe read error!");
_boast_energy_1[i] = atoll(buf);
}
}
EOF
end
|