BOAST 1.3.2 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/BOAST.gemspec +1 -1
- data/lib/BOAST.rb +3 -0
- data/lib/BOAST/Language/Operators.rb +2 -2
- data/lib/BOAST/Language/Procedure.rb +2 -1
- data/lib/BOAST/Runtime/CKernel.rb +0 -3
- data/lib/BOAST/Runtime/CUDARuntime.rb +6 -4
- data/lib/BOAST/Runtime/CompiledRuntime.rb +23 -3
- data/lib/BOAST/Runtime/Config.rb +2 -1
- data/lib/BOAST/Runtime/EnergyProbe.rb +231 -0
- data/lib/BOAST/Runtime/OpenCLRuntime.rb +2 -0
- data/lib/BOAST/Runtime/RubyEnergyMonitor.rb +46 -0
- data/lib/BOAST/Runtime/Temperature.rb +58 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0018ca6c7cd0bb34a289e2bca33368e17dc80f39'
|
4
|
+
data.tar.gz: ddb3f445eb1115dc1d095dae2f9e6b8d418e6e66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf37152987945905a54ae8d267d5c657724caa6f74fb694a99be6ed9ccb4a773fa62b3881273c376c96a2909b14635ea05399fed4270360806d8c6029c6e7b1d
|
7
|
+
data.tar.gz: '098705bf24623a96a9ad8368b6644fb4b6c3b9f24636ffbdef10f23f589c247d13f88e34a8b5c87c35cc52c86dca5842b20536d875b0796e22c5a957fb46cd6d'
|
data/BOAST.gemspec
CHANGED
data/lib/BOAST.rb
CHANGED
@@ -30,6 +30,8 @@ require 'BOAST/Language/Pragma.rb'
|
|
30
30
|
require 'BOAST/Runtime/Config.rb'
|
31
31
|
require 'BOAST/Runtime/Probe.rb'
|
32
32
|
require 'BOAST/Runtime/AffinityProbe.rb'
|
33
|
+
require 'BOAST/Runtime/EnergyProbe.rb'
|
34
|
+
require 'BOAST/Runtime/Temperature.rb'
|
33
35
|
require 'BOAST/Runtime/Compilers.rb'
|
34
36
|
require 'BOAST/Runtime/OpenCLRuntime.rb'
|
35
37
|
require 'BOAST/Runtime/CompiledRuntime.rb'
|
@@ -41,6 +43,7 @@ require 'BOAST/Runtime/FFIRuntime.rb'
|
|
41
43
|
require 'BOAST/Runtime/MPPARuntime.rb'
|
42
44
|
require 'BOAST/Runtime/CKernel.rb'
|
43
45
|
require 'BOAST/Runtime/NonRegression.rb'
|
46
|
+
require 'BOAST/Runtime/RubyEnergyMonitor.rb'
|
44
47
|
require 'BOAST/Language/Parens.rb'
|
45
48
|
require 'BOAST/Language/BOAST_OpenCL.rb'
|
46
49
|
require 'BOAST/Optimization/Optimization.rb'
|
@@ -412,7 +412,7 @@ module BOAST
|
|
412
412
|
end
|
413
413
|
return @return_type.copy("vload#{@return_type.type.vector_length}(0, #{a2})", DISCARD_OPTIONS) if lang == CL
|
414
414
|
return @return_type.copy("_m_from_int64( *((int64_t * ) #{a2} ) )", DISCARD_OPTIONS) if get_architecture == X86 and @return_type.type.total_size*8 == 64
|
415
|
-
if @source.alignment
|
415
|
+
if @source.alignment and @return_type.type.total_size and ( @source.alignment % @return_type.type.total_size ) == 0 then
|
416
416
|
instruction = intrinsics(:LOADA, @return_type.type)
|
417
417
|
else
|
418
418
|
instruction = intrinsics(:LOAD, @return_type.type)
|
@@ -536,7 +536,7 @@ module BOAST
|
|
536
536
|
return "vstore#{type.vector_length}( #{@source}, 0, #{dst} )" if lang == CL
|
537
537
|
return "*((int64_t * ) #{dst}) = _m_to_int64( #{@source} )" if get_architecture == X86 and type.total_size*8 == 64
|
538
538
|
|
539
|
-
if @dest.alignment
|
539
|
+
if @dest.alignment and type.total_size and ( @dest.alignment % type.total_size ) == 0 then
|
540
540
|
instruction = intrinsics(:STOREA, type)
|
541
541
|
else
|
542
542
|
instruction = intrinsics(:STORE, type)
|
@@ -20,6 +20,7 @@ module BOAST
|
|
20
20
|
# @param [Hash] properties set of named properties for the Procedure.
|
21
21
|
# @option properties [Array<Variables>] :constants list of constant variables that are used in the Procedure. (see parameter in Fortran).
|
22
22
|
# @option properties [Array<#to_s>] :headers list of headers that need to be included in order to compile the Procedure
|
23
|
+
# @option propertirs [Variable] :return a Variable that will be returned. Procedure becomes a function, return type is the same as the returned variable. The variable will be declared at the start of the procedure.
|
23
24
|
def initialize(name, parameters=[], properties={}, &block)
|
24
25
|
@name = name
|
25
26
|
@parameters = parameters
|
@@ -269,7 +270,7 @@ module BOAST
|
|
269
270
|
end
|
270
271
|
if lang == CUDA then
|
271
272
|
s += ", " if parameters.first
|
272
|
-
s += "size_t *
|
273
|
+
s += "size_t *_boast_block_number, size_t *_boast_block_size, int _boast_repeat"
|
273
274
|
end
|
274
275
|
s += ")"
|
275
276
|
return s
|
@@ -55,8 +55,6 @@ module BOAST
|
|
55
55
|
else
|
56
56
|
@architecture = get_architecture
|
57
57
|
end
|
58
|
-
@probes = [TimerProbe, PAPIProbe]
|
59
|
-
@probes.push AffinityProbe unless OS.mac?
|
60
58
|
|
61
59
|
case @lang
|
62
60
|
when CL
|
@@ -70,7 +68,6 @@ module BOAST
|
|
70
68
|
else
|
71
69
|
if @architecture == MPPA then
|
72
70
|
extend MPPARuntime
|
73
|
-
@probes = [MPPAProbe]
|
74
71
|
else
|
75
72
|
extend CRuntime
|
76
73
|
extend FFIRuntime if ffi?
|
@@ -29,14 +29,16 @@ module BOAST
|
|
29
29
|
get_output.write <<EOF
|
30
30
|
extern "C" {
|
31
31
|
#{@procedure.send(:boast_header_s,CUDA)}{
|
32
|
-
dim3 dimBlock(
|
33
|
-
dim3 dimGrid(
|
32
|
+
dim3 dimBlock(_boast_block_size[0], _boast_block_size[1], _boast_block_size[2]);
|
33
|
+
dim3 dimGrid(_boast_block_number[0], _boast_block_number[1], _boast_block_number[2]);
|
34
34
|
cudaEvent_t __start, __stop;
|
35
35
|
float __time;
|
36
36
|
cudaEventCreate(&__start);
|
37
37
|
cudaEventCreate(&__stop);
|
38
38
|
cudaEventRecord(__start, 0);
|
39
|
-
|
39
|
+
for( int _boast_i = 0; _boast_i < _boast_repeat; _boast_i ++) {
|
40
|
+
#{@procedure.name}<<<dimGrid,dimBlock>>>(#{@procedure.parameters.join(", ")});
|
41
|
+
}
|
40
42
|
cudaEventRecord(__stop, 0);
|
41
43
|
cudaEventSynchronize(__stop);
|
42
44
|
cudaEventElapsedTime(&__time, __start, __stop);
|
@@ -125,7 +127,7 @@ EOF
|
|
125
127
|
end
|
126
128
|
|
127
129
|
def create_procedure_call_parameters
|
128
|
-
return create_procedure_call_parameters_old + ["_boast_block_number", "_boast_block_size"]
|
130
|
+
return create_procedure_call_parameters_old + ["_boast_block_number", "_boast_block_size", "_boast_repeat"]
|
129
131
|
end
|
130
132
|
|
131
133
|
def create_procedure_call
|
@@ -179,6 +179,7 @@ EOF
|
|
179
179
|
def fill_check_args
|
180
180
|
get_output.print <<EOF
|
181
181
|
VALUE _boast_rb_opts;
|
182
|
+
int _boast_repeat = 1;
|
182
183
|
if( _boast_argc < #{@procedure.parameters.length} || _boast_argc > #{@procedure.parameters.length + 1} )
|
183
184
|
rb_raise(rb_eArgError, "Wrong number of arguments for #{@procedure.name} (%d for #{@procedure.parameters.length})!", _boast_argc);
|
184
185
|
_boast_rb_opts = Qnil;
|
@@ -202,6 +203,14 @@ EOF
|
|
202
203
|
rb_funcall(_boast_run_opts, rb_intern("update"), 1, _boast_rb_opts);
|
203
204
|
_boast_rb_opts = _boast_run_opts;
|
204
205
|
}
|
206
|
+
if ( _boast_rb_opts != Qnil ){
|
207
|
+
VALUE _boast_repeat_value = Qnil;
|
208
|
+
_boast_repeat_value = rb_hash_aref(_boast_rb_opts, ID2SYM(rb_intern("repeat")));
|
209
|
+
if(_boast_repeat_value != Qnil)
|
210
|
+
_boast_repeat = NUM2UINT(_boast_repeat_value);
|
211
|
+
if(_boast_repeat < 0)
|
212
|
+
_boast_repeat = 1;
|
213
|
+
}
|
205
214
|
EOF
|
206
215
|
end
|
207
216
|
|
@@ -270,10 +279,12 @@ EOF
|
|
270
279
|
end
|
271
280
|
|
272
281
|
def create_procedure_call
|
273
|
-
get_output.
|
274
|
-
get_output.print "
|
282
|
+
get_output.puts " for(int _boast_i = 0; _boast_i < _boast_repeat; ++_boast_i){"
|
283
|
+
get_output.print " _boast_ret = " if @procedure.properties[:return]
|
284
|
+
get_output.print " #{method_name}( "
|
275
285
|
get_output.print create_procedure_call_parameters.join(", ")
|
276
|
-
get_output.
|
286
|
+
get_output.print " );"
|
287
|
+
get_output.puts " }"
|
277
288
|
end
|
278
289
|
|
279
290
|
def copy_scalar_param_to_ruby(param, ruby_param)
|
@@ -400,6 +411,15 @@ EOF
|
|
400
411
|
compiler_options.update(options)
|
401
412
|
linker, ldshared, ldflags = setup_compilers(compiler_options)
|
402
413
|
@compiler_options = compiler_options
|
414
|
+
@probes = []
|
415
|
+
if @compiler_options[:probes] then
|
416
|
+
@probes = @compiler_options[:probes]
|
417
|
+
elsif get_lang != CUDA
|
418
|
+
@probes = [TimerProbe, PAPIProbe]
|
419
|
+
@probes.push EnergyProbe if EnergyProbe
|
420
|
+
@probes.push AffinityProbe unless OS.mac?
|
421
|
+
end
|
422
|
+
@probes = [MPPAProbe] if @architecture == MPPA
|
403
423
|
|
404
424
|
@marker = Tempfile::new([@procedure.name,""])
|
405
425
|
|
data/lib/BOAST/Runtime/Config.rb
CHANGED
@@ -0,0 +1,231 @@
|
|
1
|
+
module BOAST
|
2
|
+
module PowercapProbe
|
3
|
+
extend PrivateStateAccessor
|
4
|
+
module_function
|
5
|
+
def header
|
6
|
+
get_output.puts "#include <stdio.h>"
|
7
|
+
get_output.puts "#include <stdint.h>"
|
8
|
+
end
|
9
|
+
def decl
|
10
|
+
get_output.puts "char **_boast_energy_files = 0;"
|
11
|
+
get_output.puts "char **_boast_energy_names = 0;"
|
12
|
+
get_output.puts "uint64_t *_boast_energy_0 = 0;"
|
13
|
+
get_output.puts "uint64_t *_boast_energy_1 = 0;"
|
14
|
+
get_output.puts "int _boast_energy_nsensors = 0;"
|
15
|
+
end
|
16
|
+
def configure
|
17
|
+
get_output.print <<EOF
|
18
|
+
{
|
19
|
+
char buf[128];
|
20
|
+
char path[128];
|
21
|
+
char *s;
|
22
|
+
FILE *f;
|
23
|
+
int nproc;
|
24
|
+
int i;
|
25
|
+
if( _boast_energy_nsensors ){
|
26
|
+
free(_boast_energy_files);
|
27
|
+
for(i=0; i < _boast_energy_nsensors; ++i)
|
28
|
+
free(_boast_energy_names[i]);
|
29
|
+
free(_boast_energy_names);
|
30
|
+
_boast_energy_nsensors = 0;
|
31
|
+
}
|
32
|
+
_boast_energy_files = malloc(1);
|
33
|
+
_boast_energy_names = malloc(1);
|
34
|
+
|
35
|
+
for(nproc = 0; ; ++nproc){
|
36
|
+
sprintf(path,"/sys/devices/virtual/powercap/intel-rapl/intel-rapl:%d",nproc);
|
37
|
+
sprintf(buf,"%s/energy_uj",path);
|
38
|
+
f = fopen(buf, "rt");
|
39
|
+
if(!f)
|
40
|
+
break;
|
41
|
+
i = 0;
|
42
|
+
do{
|
43
|
+
int _boast_fread_ret;
|
44
|
+
fclose(f);
|
45
|
+
++_boast_energy_nsensors;
|
46
|
+
_boast_energy_files = realloc(_boast_energy_files, _boast_energy_nsensors * sizeof(*_boast_energy_files));
|
47
|
+
_boast_energy_names = realloc(_boast_energy_names, _boast_energy_nsensors * sizeof(*_boast_energy_names));
|
48
|
+
_boast_energy_files[_boast_energy_nsensors-1] = malloc(128);
|
49
|
+
_boast_energy_names[_boast_energy_nsensors-1] = malloc( 16);
|
50
|
+
s = _boast_energy_names[_boast_energy_nsensors-1];
|
51
|
+
sprintf(_boast_energy_files[_boast_energy_nsensors-1],"%s",buf);
|
52
|
+
sprintf(buf, "%s/name", path);
|
53
|
+
f = fopen(buf, "r");
|
54
|
+
_boast_fread_ret = fread(buf, 1, sizeof(buf), f);
|
55
|
+
fclose(f);
|
56
|
+
if(_boast_fread_ret == 0)
|
57
|
+
rb_raise(rb_eArgError, "Energy probe read error!");
|
58
|
+
/* last character read is a line break */
|
59
|
+
buf[_boast_fread_ret-1] = 0;
|
60
|
+
sprintf(s, "%d.%s", nproc, buf);
|
61
|
+
|
62
|
+
sprintf(path,"/sys/devices/virtual/powercap/intel-rapl/intel-rapl:%d/intel-rapl:%d:%d",nproc,nproc,i++);
|
63
|
+
sprintf(buf,"%s/energy_uj",path);
|
64
|
+
f = fopen(buf, "rt");
|
65
|
+
}while(f);
|
66
|
+
}
|
67
|
+
if( ! _boast_energy_nsensors ){
|
68
|
+
free( _boast_energy_files );
|
69
|
+
free( _boast_energy_names );
|
70
|
+
}else{
|
71
|
+
_boast_energy_0 = malloc(_boast_energy_nsensors * sizeof(*_boast_energy_0));
|
72
|
+
_boast_energy_1 = malloc(_boast_energy_nsensors * sizeof(*_boast_energy_1));
|
73
|
+
}
|
74
|
+
}
|
75
|
+
EOF
|
76
|
+
end
|
77
|
+
def start
|
78
|
+
get_output.print <<EOF
|
79
|
+
{
|
80
|
+
char buf[32];
|
81
|
+
FILE *f;
|
82
|
+
int i;
|
83
|
+
for(i = 0; i < _boast_energy_nsensors; ++i){
|
84
|
+
int _boast_fread_ret;
|
85
|
+
f = fopen(_boast_energy_files[i], "r");
|
86
|
+
_boast_fread_ret = fread(buf, 1, sizeof(buf), f);
|
87
|
+
fclose(f);
|
88
|
+
if(_boast_fread_ret == 0)
|
89
|
+
rb_raise(rb_eArgError, "Energy probe read error!");
|
90
|
+
_boast_energy_0[i] = atoll(buf);
|
91
|
+
}
|
92
|
+
}
|
93
|
+
EOF
|
94
|
+
end
|
95
|
+
def stop
|
96
|
+
get_output.print <<EOF
|
97
|
+
{
|
98
|
+
char buf[32];
|
99
|
+
FILE *f;
|
100
|
+
int i;
|
101
|
+
for(i = 0; i < _boast_energy_nsensors; ++i){
|
102
|
+
int _boast_fread_ret;
|
103
|
+
f = fopen(_boast_energy_files[i], "r");
|
104
|
+
_boast_fread_ret = fread(buf, 1, sizeof(buf), f);
|
105
|
+
fclose(f);
|
106
|
+
if(_boast_fread_ret == 0)
|
107
|
+
rb_raise(rb_eArgError, "Energy probe read error!");
|
108
|
+
_boast_energy_1[i] = atoll(buf);
|
109
|
+
}
|
110
|
+
}
|
111
|
+
EOF
|
112
|
+
end
|
113
|
+
def compute
|
114
|
+
get_output.print <<EOF
|
115
|
+
{
|
116
|
+
VALUE results;
|
117
|
+
int i;
|
118
|
+
results = rb_hash_new();
|
119
|
+
for(i=0; i < _boast_energy_nsensors; ++i){
|
120
|
+
rb_hash_aset(results, ID2SYM(rb_intern(_boast_energy_names[i])), rb_float_new((_boast_energy_1[i] - _boast_energy_0[i]) * 1e-6));
|
121
|
+
}
|
122
|
+
rb_hash_aset(_boast_stats, ID2SYM(rb_intern("energy")), results);
|
123
|
+
}
|
124
|
+
EOF
|
125
|
+
end
|
126
|
+
def is_available
|
127
|
+
[] != Dir.glob( '/sys/class/powercap/intel-rapl:0:0' )
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
module RedfstProbe
|
132
|
+
extend PrivateStateAccessor
|
133
|
+
module_function
|
134
|
+
def header
|
135
|
+
get_output.puts "#include <redfst.h>"
|
136
|
+
end
|
137
|
+
def decl
|
138
|
+
get_output.puts "redfst_dev_t *_boast_energy=0;"
|
139
|
+
end
|
140
|
+
def configure
|
141
|
+
get_output.puts "redfst_init();"
|
142
|
+
end
|
143
|
+
def start
|
144
|
+
get_output.puts "redfst_reset();"
|
145
|
+
end
|
146
|
+
def stop
|
147
|
+
get_output.puts "_boast_energy = redfst_get(_boast_energy);"
|
148
|
+
end
|
149
|
+
def compute
|
150
|
+
get_output.print <<EOF
|
151
|
+
{
|
152
|
+
VALUE results;
|
153
|
+
double pkg, pp0, dram;
|
154
|
+
char *s;
|
155
|
+
int i;
|
156
|
+
pkg = pp0 = dram = 0;
|
157
|
+
results = rb_hash_new();
|
158
|
+
for(i=0; i < _boast_energy->count; ++i){
|
159
|
+
rb_hash_aset(results, ID2SYM(rb_intern(_boast_energy->name[i])), rb_float_new(_boast_energy->energy[i]));
|
160
|
+
s = _boast_energy->name[i];
|
161
|
+
while('.'!=*s++)
|
162
|
+
;
|
163
|
+
while('.'!=*s++)
|
164
|
+
;
|
165
|
+
if(!strcmp("pkg",s))
|
166
|
+
pkg += _boast_energy->energy[i];
|
167
|
+
else if(!strcmp("pp0",s))
|
168
|
+
pp0 += _boast_energy->energy[i];
|
169
|
+
else if(!strcmp("dram",s))
|
170
|
+
dram += _boast_energy->energy[i];
|
171
|
+
}
|
172
|
+
rb_hash_aset(results, ID2SYM(rb_intern("total.pkg" )), rb_float_new(pkg));
|
173
|
+
rb_hash_aset(results, ID2SYM(rb_intern("total.pp0" )), rb_float_new(pp0));
|
174
|
+
rb_hash_aset(results, ID2SYM(rb_intern("total.dram")), rb_float_new(dram));
|
175
|
+
rb_hash_aset(results, ID2SYM(rb_intern("total" )), rb_float_new(pkg+dram));
|
176
|
+
rb_hash_aset(_boast_stats, ID2SYM(rb_intern("energy")), results);
|
177
|
+
}
|
178
|
+
EOF
|
179
|
+
end
|
180
|
+
def is_available
|
181
|
+
[] != ENV['LIBRARY_PATH'].split(':').inject([]){|mem, x| []!=mem ? mem : Dir.glob(x+'/libredfst.so')}
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
module EmlProbe
|
186
|
+
extend PrivateStateAccessor
|
187
|
+
module_function
|
188
|
+
def header
|
189
|
+
get_output.puts "#include <eml.h>"
|
190
|
+
end
|
191
|
+
def decl
|
192
|
+
get_output.puts "emlData_t **_boast_energy=0;";
|
193
|
+
get_output.puts "size_t _boast_energy_count=0;";
|
194
|
+
end
|
195
|
+
def configure
|
196
|
+
get_output.puts "emlInit();"
|
197
|
+
get_output.puts "emlDeviceGetCount(&_boast_energy_count);"
|
198
|
+
get_output.puts "_boast_energy = malloc(_boast_energy_count*sizeof(*_boast_energy));"
|
199
|
+
end
|
200
|
+
def start
|
201
|
+
get_output.puts "emlStart();";
|
202
|
+
end
|
203
|
+
def stop
|
204
|
+
get_output.puts "emlStop(_boast_energy);";
|
205
|
+
end
|
206
|
+
def compute
|
207
|
+
get_output.print <<EOF
|
208
|
+
{
|
209
|
+
VALUE results;
|
210
|
+
double consumed;
|
211
|
+
results = rb_hash_new();
|
212
|
+
emlDataGetConsumed(_boast_energy[0], &consumed);
|
213
|
+
rb_hash_aset(results, ID2SYM(rb_intern("total" )), rb_float_new(consumed));
|
214
|
+
rb_hash_aset(_boast_stats, ID2SYM(rb_intern("energy")), results);
|
215
|
+
}
|
216
|
+
EOF
|
217
|
+
end
|
218
|
+
def is_available
|
219
|
+
[] != ENV['LIBRARY_PATH'].split(':').inject([]){|mem, x| []!=mem ? mem : Dir.glob(x+'/libeml.so')}
|
220
|
+
end
|
221
|
+
end
|
222
|
+
if PowercapProbe.is_available
|
223
|
+
EnergyProbe = PowercapProbe
|
224
|
+
elsif RedfstProbe.is_available
|
225
|
+
EnergyProbe = RedfstProbe
|
226
|
+
elsif EmlProbe.is_available
|
227
|
+
EnergyProbe = EmlProbe
|
228
|
+
else
|
229
|
+
EnergyProbe = nil
|
230
|
+
end
|
231
|
+
end
|
@@ -124,11 +124,13 @@ module BOAST
|
|
124
124
|
def build(options={})
|
125
125
|
compiler_options = BOAST::get_compiler_options
|
126
126
|
compiler_options.update(options)
|
127
|
+
@probes = compiler_options[:probes] if compiler_options[:probes]
|
127
128
|
init_opencl(compiler_options)
|
128
129
|
|
129
130
|
run_method = <<EOF
|
130
131
|
def self.run(*args)
|
131
132
|
raise "Wrong number of arguments \#{args.length} for #{@procedure.parameters.length}" if args.length > #{@procedure.parameters.length+1} or args.length < #{@procedure.parameters.length}
|
133
|
+
energy_data = NArray::float(1024)
|
132
134
|
params = []
|
133
135
|
opts = BOAST::get_run_config
|
134
136
|
opts = opts.update(args.pop) if args.length == #{@procedure.parameters.length+1}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module BOAST
|
2
|
+
if false
|
3
|
+
module OpenCLRuntime
|
4
|
+
|
5
|
+
st = BOAST::get_output
|
6
|
+
|
7
|
+
p = BOAST::Procedure("energy_kernel_init",[])
|
8
|
+
ENERGY_PROBE_INIT = BOAST::CKernel::new( :lang => C )
|
9
|
+
ENERGY_PROBE_INIT.procedure = p
|
10
|
+
BOAST::get_output.print <<EOF
|
11
|
+
#include <redfst.h>
|
12
|
+
void energy_kernel_init(void) {
|
13
|
+
redfst_init();
|
14
|
+
}
|
15
|
+
EOF
|
16
|
+
|
17
|
+
p = BOAST::Procedure("energy_kernel_start",[])
|
18
|
+
ENERGY_PROBE_START = BOAST::CKernel::new( :lang => C )
|
19
|
+
ENERGY_PROBE_START.procedure = p
|
20
|
+
BOAST::get_output.print <<EOF
|
21
|
+
#include <redfst.h>
|
22
|
+
void energy_kernel_start(void) {
|
23
|
+
redfst_reset();
|
24
|
+
}
|
25
|
+
EOF
|
26
|
+
|
27
|
+
p = BOAST::Procedure("energy_reading_kernel",[BOAST::Real("data",:dim => BOAST::Dim(),:dir => :out)], [], :return => BOAST::Int("nb_cpus") )
|
28
|
+
ENERGY_PROBE_STOP = BOAST::CKernel::new( :lang => C )
|
29
|
+
ENERGY_PROBE_STOP.procedure = p
|
30
|
+
BOAST::get_output.print <<EOF
|
31
|
+
#include <redfst.h>
|
32
|
+
int energy_reading_kernel( double * data) {
|
33
|
+
redfst_get_all(data);
|
34
|
+
return redfst_ncpus();
|
35
|
+
}
|
36
|
+
EOF
|
37
|
+
|
38
|
+
ENERGY_PROBE_INIT.build( :LDFLAGS => '-lredfst -lm -lcpufreq' )
|
39
|
+
ENERGY_PROBE_START.build( :LDFLAGS => '-lredfst -lm -lcpufreq' )
|
40
|
+
ENERGY_PROBE_STOP.build( :LDFLAGS => '-lredfst -lm -lcpufreq' )
|
41
|
+
|
42
|
+
BOAST::set_output(st)
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module BOAST
|
2
|
+
module Temperature
|
3
|
+
extend PrivateStateAccessor
|
4
|
+
module_function
|
5
|
+
|
6
|
+
def get
|
7
|
+
r = {}
|
8
|
+
Dir.glob("/sys/devices/platform/coretemp.*") {|dir|
|
9
|
+
cpu = dir.match(/[0-9]*$/)[0].to_i
|
10
|
+
r[cpu] = {}
|
11
|
+
Dir.glob(dir+'/hwmon/hwmon*/temp*_input') {|fname|
|
12
|
+
sensor = fname.match(/temp([0-9]+)_input$/)[1].to_i - 1
|
13
|
+
f = File.open(fname, 'r')
|
14
|
+
r[cpu][sensor] = f.read.to_i
|
15
|
+
f.close
|
16
|
+
}
|
17
|
+
}
|
18
|
+
return r
|
19
|
+
end
|
20
|
+
|
21
|
+
def set min_temps=nil
|
22
|
+
return if nil==min_temps
|
23
|
+
now = []
|
24
|
+
self.get.each{ |x,y| now.push y[0] }
|
25
|
+
nthreads = 2* (self.get[0].length-1) * self.get.length
|
26
|
+
fin = true
|
27
|
+
(0...now.length).each {|i|
|
28
|
+
fin = false if now[i] < min_temps[i]
|
29
|
+
}
|
30
|
+
return if fin
|
31
|
+
p = Array.new
|
32
|
+
(0...nthreads).each{|x| p.push fork{self.busy}}
|
33
|
+
while true
|
34
|
+
now = []
|
35
|
+
self.get.each{ |x,y| now.push y[0] }
|
36
|
+
fin = true
|
37
|
+
(0...now.length).each {|i|
|
38
|
+
fin = false if now[i] < min_temps[i]
|
39
|
+
}
|
40
|
+
break if fin
|
41
|
+
end
|
42
|
+
p.each {|x| Process.kill "KILL",x}
|
43
|
+
p.each {|x|
|
44
|
+
begin
|
45
|
+
Process.wait x
|
46
|
+
rescue Errno::ECHILD
|
47
|
+
end
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def busy
|
52
|
+
while true
|
53
|
+
4.2 / 2.78
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: BOAST
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brice Videau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: narray
|
@@ -235,6 +235,7 @@ files:
|
|
235
235
|
- lib/BOAST/Runtime/CompiledRuntime.rb
|
236
236
|
- lib/BOAST/Runtime/Compilers.rb
|
237
237
|
- lib/BOAST/Runtime/Config.rb
|
238
|
+
- lib/BOAST/Runtime/EnergyProbe.rb
|
238
239
|
- lib/BOAST/Runtime/FFIRuntime.rb
|
239
240
|
- lib/BOAST/Runtime/FORTRANRuntime.rb
|
240
241
|
- lib/BOAST/Runtime/MAQAO.rb
|
@@ -243,6 +244,8 @@ files:
|
|
243
244
|
- lib/BOAST/Runtime/OpenCLRuntime.rb
|
244
245
|
- lib/BOAST/Runtime/OpenCLTypes.rb
|
245
246
|
- lib/BOAST/Runtime/Probe.rb
|
247
|
+
- lib/BOAST/Runtime/RubyEnergyMonitor.rb
|
248
|
+
- lib/BOAST/Runtime/Temperature.rb
|
246
249
|
homepage: https://github.com/Nanosim-LIG/boast
|
247
250
|
licenses:
|
248
251
|
- BSD-2-Clause
|