BOAST 1.0.4 → 1.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5eb4ec74e14155954a1ecc7c3004e79088160c4
4
- data.tar.gz: a4226683ccc72753105a61c2af6a9ddb0ce69bc3
3
+ metadata.gz: 36ff960759ff464e552e84ee45f3245cec255920
4
+ data.tar.gz: f52d3d583ba030d9affb8bd4e903c10c7a6ddd97
5
5
  SHA512:
6
- metadata.gz: 7f1ac4576270947a645a2b8878f771d0c2dde7974d963b6c57a29eda1dc7a48be24003dc6df38f05e6f17fa9689ebf820634c0007495fecbe4c75bfddec8f5f0
7
- data.tar.gz: fc98fd3ce8322e5c995167f043170ef42b61b49b14409d1c66d7cdea0a019e19cbef085012f8341f4add6b254b28e6d660094ffcf65676acdc3316b0bcc7051c
6
+ metadata.gz: 49d7f2414f2b8703c1cef9e13945c8d6eb19a28dc728d25d8bef58238fef5aa1707397f5ad49948a9696a308cf1b57fffe9c43f96d03f45721386ab785642a09
7
+ data.tar.gz: a2d91030cb407b63743e24112eace210ae077865014567dd7f6d1e114e64dcc06e1830d471b11c932369ee1e65a565b0e17b24f0d4d1d539e04194dcdae3d169
data/BOAST.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'BOAST'
3
- s.version = "1.0.4"
3
+ s.version = "1.0.5"
4
4
  s.author = "Brice Videau"
5
5
  s.email = "brice.videau@imag.fr"
6
6
  s.homepage = "https://github.com/Nanosim-LIG/boast"
@@ -55,12 +55,14 @@ module BOAST
55
55
  extend OpenCLRuntime
56
56
  when CUDA
57
57
  extend CUDARuntime
58
+ @probes = []
58
59
  when FORTRAN
59
60
  extend FORTRANRuntime
60
61
  extend FFIRuntime if ffi?
61
62
  else
62
63
  if @architecture == MPPA then
63
64
  extend MPPARuntime
65
+ @probes = [MPPAProbe]
64
66
  else
65
67
  extend CRuntime
66
68
  extend FFIRuntime if ffi?
@@ -9,6 +9,7 @@ module BOAST
9
9
  alias get_params_value_old get_params_value
10
10
  alias fill_decl_module_params_old fill_decl_module_params
11
11
  alias create_procedure_call_parameters_old create_procedure_call_parameters
12
+ alias store_results_old store_results
12
13
 
13
14
  def fill_module_header
14
15
  fill_module_header_old
@@ -64,6 +65,7 @@ EOF
64
65
  get_output.print <<EOF
65
66
  size_t _boast_block_size[3] = {1,1,1};
66
67
  size_t _boast_block_number[3] = {1,1,1};
68
+ int64_t _boast_duration;
67
69
  EOF
68
70
  end
69
71
 
@@ -153,6 +155,11 @@ EOF
153
155
  EOF
154
156
  end
155
157
 
158
+ def store_results
159
+ store_results_old
160
+ get_output.print " rb_hash_aset(_boast_stats,ID2SYM(rb_intern(\"duration\")),rb_float_new((double)_boast_duration*(double)1e-9));\n"
161
+ end
162
+
156
163
  end
157
164
 
158
165
  end
@@ -318,10 +318,10 @@ EOF
318
318
 
319
319
  @probes.map(&:stop)
320
320
 
321
- @probes.map(&:compute)
322
-
323
321
  get_results
324
322
 
323
+ @probes.map(&:compute)
324
+
325
325
  store_results
326
326
 
327
327
  get_output.puts " return _boast_stats;"
@@ -1,5 +1,59 @@
1
1
  module BOAST
2
2
 
3
+ module MPPAProbe
4
+ extend PrivateStateAccessor
5
+
6
+ module_function
7
+
8
+ # Monitoring has to be started before transfer begin and after transfers end as we don't have sync points in between.
9
+ def header
10
+ get_output.puts "#include <mppa_mon.h>"
11
+ end
12
+
13
+ def decl
14
+ get_output.print <<EOF
15
+ float _mppa_avg_pwr;
16
+ float _mppa_energy;
17
+ float _mppa_duration;
18
+ mppa_mon_ctx_t * _mppa_ctx;
19
+ mppa_mon_sensor_t _mppa_pwr_sensor[] = {MPPA_MON_PWR_MPPA0};
20
+ mppa_mon_measure_report_t * _mppa_report;
21
+ mppa_mon_open(0, &_mppa_ctx);
22
+ mppa_mon_measure_set_sensors(_mppa_ctx, _mppa_pwr_sensor, 1);
23
+ mppa_mon_measure_start(_mppa_ctx);
24
+ EOF
25
+ end
26
+
27
+ def configure
28
+ end
29
+
30
+ def start
31
+ end
32
+
33
+ def stop
34
+ end
35
+
36
+ def compute
37
+ get_output.print <<EOF
38
+ mppa_mon_measure_stop(_mppa_ctx, &_mppa_report);
39
+ _mppa_avg_pwr = 0;
40
+ _mppa_energy = 0;
41
+ for(_mppa_i=0; _mppa_i < _mppa_report->count; _mppa_i++){
42
+ _mppa_avg_pwr += _mppa_report->measures[_mppa_i].avg_power;
43
+ _mppa_energy += _mppa_report->measures[_mppa_i].total_energy;
44
+ }
45
+ _mppa_avg_pwr = _mppa_avg_pwr/(float) _mppa_report->count;
46
+ _mppa_duration = _mppa_report->total_time;
47
+ mppa_mon_measure_free_report(_mppa_report);
48
+ mppa_mon_close(_mppa_ctx);
49
+ rb_hash_aset(_boast_stats,ID2SYM(rb_intern("mppa_avg_pwr")),rb_float_new(_mppa_avg_pwr));
50
+ rb_hash_aset(_boast_stats,ID2SYM(rb_intern("mppa_energy")),rb_float_new(_mppa_energy));
51
+ rb_hash_aset(_boast_stats,ID2SYM(rb_intern("mppa_duration")), rb_float_new(_mppa_duration));
52
+ EOF
53
+ end
54
+
55
+ end
56
+
3
57
  module MPPARuntime
4
58
  include CRuntime
5
59
 
@@ -95,10 +149,11 @@ module BOAST
95
149
  fill_library_header
96
150
  get_output.puts "#include <mppaipc.h>"
97
151
  get_output.puts "#include <mppa/osconfig.h>"
152
+ get_output.puts "#include <time.h>"
98
153
  end
99
154
 
100
155
  def copy_array_param_from_host( param )
101
- get_output.write <<EOF
156
+ get_output.print <<EOF
102
157
  mppa_read(_mppa_from_host_size, &_mppa_#{param}_size, sizeof(_mppa_#{param}_size));
103
158
  #{param} = malloc(_mppa_#{param}_size);
104
159
  mppa_read(_mppa_from_host_var, #{param}, _mppa_#{param}_size);
@@ -106,13 +161,13 @@ EOF
106
161
  end
107
162
 
108
163
  def copy_scalar_param_from_host( param )
109
- get_output.write <<EOF
164
+ get_output.print <<EOF
110
165
  mppa_read(_mppa_from_host_var, &#{param}, sizeof(#{param}));
111
166
  EOF
112
167
  end
113
168
 
114
169
  def get_cluster_list_from_host
115
- get_output.write <<EOF
170
+ get_output.print <<EOF
116
171
  mppa_read(_mppa_from_host_size, &_mppa_clust_list_size, sizeof(_mppa_clust_list_size));
117
172
  _clust_list = malloc(_mppa_clust_list_size);
118
173
  _nb_clust = _mppa_clust_list_size / sizeof(*_clust_list);
@@ -121,13 +176,13 @@ EOF
121
176
  end
122
177
 
123
178
  def copy_array_param_to_host(param)
124
- get_output.write <<EOF
179
+ get_output.print <<EOF
125
180
  mppa_write(_mppa_to_host_var, #{param}, _mppa_#{param}_size);
126
181
  EOF
127
182
  end
128
183
 
129
184
  def copy_scalar_param_to_host(param)
130
- get_output.write <<EOF
185
+ get_output.print <<EOF
131
186
  mppa_write(_mppa_to_host_var, &#{param}, sizeof(#{param}));
132
187
  EOF
133
188
  end
@@ -135,8 +190,8 @@ EOF
135
190
  def multibinary_main_io_source_decl
136
191
  #Parameters declaration
137
192
  @procedure.parameters.each { |param|
138
- get_output.write " #{param.type.decl} "
139
- get_output.write "*" if param.dimension or param.scalar_output?
193
+ get_output.print " #{param.type.decl} "
194
+ get_output.print "*" if param.dimension or param.scalar_output?
140
195
  get_output.puts "#{param.name};"
141
196
  if param.dimension then
142
197
  get_output.puts " size_t _mppa_#{param}_size;"
@@ -147,14 +202,20 @@ EOF
147
202
  get_output.puts " #{@procedure.properties[:return].type.decl} _mppa_ret;" if @procedure.properties[:return]
148
203
 
149
204
  #Cluster list declaration
150
- get_output.write <<EOF
205
+ get_output.print <<EOF
151
206
  uint32_t *_clust_list;
152
207
  int _nb_clust;
153
208
  int _mppa_clust_list_size;
154
209
  EOF
155
210
 
211
+ #Timer
212
+ get_output.print <<EOF
213
+ struct timespec _mppa_start, _mppa_stop;
214
+ int64_t _mppa_duration;
215
+ EOF
216
+
156
217
  #Communication variables
157
- get_output.write <<EOF
218
+ get_output.print <<EOF
158
219
  int _mppa_from_host_size, _mppa_from_host_var;
159
220
  int _mppa_to_host_size, _mppa_to_host_var;
160
221
  int _mppa_pid[16], _mppa_i;
@@ -163,7 +224,7 @@ EOF
163
224
 
164
225
  def multibinary_main_io_source_get_params
165
226
  #Receiving parameters from Host
166
- get_output.write <<EOF
227
+ get_output.print <<EOF
167
228
  _mppa_from_host_size = mppa_open("/mppa/buffer/board0#mppa0#pcie0#2/host#2", O_RDONLY);
168
229
  _mppa_from_host_var = mppa_open("/mppa/buffer/board0#mppa0#pcie0#3/host#3", O_RDONLY);
169
230
  EOF
@@ -178,7 +239,7 @@ EOF
178
239
  #Receiving cluster list
179
240
  get_cluster_list_from_host
180
241
 
181
- get_output.write <<EOF
242
+ get_output.print <<EOF
182
243
  mppa_close(_mppa_from_host_size);
183
244
  mppa_close(_mppa_from_host_var);
184
245
  EOF
@@ -186,7 +247,7 @@ EOF
186
247
 
187
248
  def multibinary_main_io_source_send_results
188
249
  #Sending results to Host
189
- get_output.write <<EOF
250
+ get_output.print <<EOF
190
251
  _mppa_to_host_var = mppa_open("/mppa/buffer/host#4/board0#mppa0#pcie0#4", O_WRONLY);
191
252
  EOF
192
253
  @procedure.parameters.each { |param|
@@ -199,7 +260,8 @@ EOF
199
260
  end
200
261
  }
201
262
  copy_scalar_param_to_host("_mppa_ret") if @procedure.properties[:return]
202
- get_output.write <<EOF
263
+ copy_scalar_param_to_host("_mppa_duration")
264
+ get_output.print <<EOF
203
265
  mppa_close(_mppa_to_host_var);
204
266
  EOF
205
267
  end
@@ -210,22 +272,26 @@ EOF
210
272
  multibinary_main_io_source_get_params
211
273
 
212
274
  #Spawning cluster
213
- get_output.write <<EOF
275
+ get_output.print <<EOF
276
+
277
+ clock_gettime(CLOCK_REALTIME, &_mppa_start);
214
278
  for(_mppa_i=0; _mppa_i<_nb_clust; _mppa_i++){
215
279
  _mppa_pid[_mppa_i] = mppa_spawn(_clust_list[_mppa_i], NULL, "comp-part", NULL, NULL);
216
280
  }
217
281
  EOF
218
282
  #Calling IO procedure
219
- get_output.write " _mppa_ret =" if @procedure.properties[:return]
220
- get_output.write " #{@procedure.name}("
221
- get_output.write @procedure.parameters.map(&:name).join(", ")
283
+ get_output.print " _mppa_ret =" if @procedure.properties[:return]
284
+ get_output.print " #{@procedure.name}("
285
+ get_output.print @procedure.parameters.map(&:name).join(", ")
222
286
  get_output.puts ");"
223
287
 
224
288
  #Waiting for clusters
225
- get_output.write <<EOF
289
+ get_output.print <<EOF
226
290
  for(_mppa_i=0; _mppa_i<_nb_clust; _mppa_i++){
227
291
  mppa_waitpid(_mppa_pid[_mppa_i], NULL, 0);
228
292
  }
293
+ clock_gettime(CLOCK_REALTIME, &_mppa_stop);
294
+ _mppa_duration = (int64_t)(_mppa_stop.tv_sec - _mppa_start.tv_sec) * 1000000000ll + _mppa_stop.tv_nsec - _mppa_start.tv_nsec;
229
295
  EOF
230
296
 
231
297
  multibinary_main_io_source_send_results
@@ -247,7 +313,7 @@ EOF
247
313
  end
248
314
  if code then
249
315
  code.rewind
250
- get_output.write code.read
316
+ get_output.print code.read
251
317
  end
252
318
  get_output.puts "int main(int argc, const char* argv[]) {"
253
319
  if mode == :io then
@@ -255,7 +321,7 @@ EOF
255
321
  else
256
322
  fill_multibinary_main_comp_source
257
323
  end
258
- get_output.write <<EOF
324
+ get_output.print <<EOF
259
325
  mppa_exit(0);
260
326
  return 0;
261
327
  }
@@ -293,7 +359,6 @@ EOF
293
359
  def fill_module_header
294
360
  fill_module_header_old
295
361
  get_output.puts "#include <mppaipc.h>"
296
- get_output.puts "#include <mppa_mon.h>"
297
362
  end
298
363
 
299
364
  def fill_decl_module_params
@@ -304,19 +369,11 @@ EOF
304
369
  int _mppa_pid;
305
370
  int _mppa_fd_size;
306
371
  int _mppa_fd_var;
307
- float _mppa_avg_pwr;
308
- float _mppa_energy;
309
- float _mppa_duration;
310
372
  int _mppa_clust_list_size;
311
373
  int _mppa_clust_nb;
374
+ int64_t _boast_duration;
312
375
  uint32_t * _mppa_clust_list;
313
- mppa_mon_ctx_t * _mppa_ctx;
314
- mppa_mon_sensor_t _mppa_pwr_sensor[] = {MPPA_MON_PWR_MPPA0};
315
- mppa_mon_measure_report_t * _mppa_report;
316
- mppa_mon_open(0, &_mppa_ctx);
317
- mppa_mon_measure_set_sensors(_mppa_ctx, _mppa_pwr_sensor, 1);
318
376
  _mppa_load_id = mppa_load(0, 0, 0, \"#{multibinary_path}\");
319
- mppa_mon_measure_start(_mppa_ctx);
320
377
  _mppa_pid = mppa_spawn(_mppa_load_id, NULL, \"io-part\", NULL, NULL);
321
378
  EOF
322
379
  end
@@ -431,32 +488,18 @@ EOF
431
488
  _mppa_fd_var = mppa_open(\"/mppa/buffer/host#4/board0#mppa0#pcie0#4\", O_RDONLY);
432
489
  EOF
433
490
  get_results_old
434
- get_output.puts "mppa_read(_mppa_fd_var, &#{_boast_ret}, sizeof(#{_boast_ret}));" if @procedure.properties[:return]
491
+ get_output.puts " mppa_read(_mppa_fd_var, &_boast_ret, sizeof(_boast_ret));" if @procedure.properties[:return]
492
+ get_output.puts " mppa_read(_mppa_fd_var, &_boast_duration, sizeof(_boast_duration));"
435
493
  get_output.print <<EOF
436
494
  mppa_close(_mppa_fd_var);
437
495
  mppa_waitpid(_mppa_pid, NULL, 0);
438
- mppa_mon_measure_stop(_mppa_ctx, &_mppa_report);
439
496
  mppa_unload(_mppa_load_id);
440
- _mppa_avg_pwr = 0;
441
- _mppa_energy = 0;
442
- for(_mppa_i=0; _mppa_i < _mppa_report->count; _mppa_i++){
443
- _mppa_avg_pwr += _mppa_report->measures[_mppa_i].avg_power;
444
- _mppa_energy += _mppa_report->measures[_mppa_i].total_energy;
445
- }
446
- _mppa_avg_pwr = _mppa_avg_pwr/(float) _mppa_report->count;
447
- _mppa_duration = _mppa_report->total_time;
448
- mppa_mon_measure_free_report(_mppa_report);
449
- mppa_mon_close(_mppa_ctx);
450
497
  EOF
451
498
  end
452
499
 
453
500
  def store_results
454
501
  store_results_old
455
- get_output.print <<EOF
456
- rb_hash_aset(_boast_stats,ID2SYM(rb_intern("mppa_avg_pwr")),rb_float_new(_mppa_avg_pwr));
457
- rb_hash_aset(_boast_stats,ID2SYM(rb_intern("mppa_energy")),rb_float_new(_mppa_energy));
458
- rb_hash_aset(_boast_stats,ID2SYM(rb_intern("mppa_duration")), rb_float_new(_mppa_duration));
459
- EOF
502
+ get_output.print " rb_hash_aset(_boast_stats,ID2SYM(rb_intern(\"duration\")),rb_float_new((double)_boast_duration*(double)1e-9));\n"
460
503
  end
461
504
 
462
505
  end
@@ -53,15 +53,13 @@ EOF
53
53
  end
54
54
 
55
55
  def compute
56
- if @lang != CUDA then
57
- if OS.mac? then
58
- get_output.print " mach_timebase_info(&_mac_boast_timebase_info);\n"
59
- get_output.print " #{RESULT} = (_mac_boast_stop - _mac_boast_start) * _mac_boast_timebase_info.numer / _mac_boast_timebase_info.denom;\n"
60
- else
61
- get_output.print " #{RESULT} = (_boast_stop.tv_sec - _boast_start.tv_sec) * (unsigned long long int)1000000000 + _boast_stop.tv_nsec - _boast_start.tv_nsec;\n"
62
- end
63
- get_output.print " rb_hash_aset(_boast_stats,ID2SYM(rb_intern(\"duration\")),rb_float_new((double)#{RESULT}*(double)1e-9));\n"
56
+ if OS.mac? then
57
+ get_output.print " mach_timebase_info(&_mac_boast_timebase_info);\n"
58
+ get_output.print " #{RESULT} = (_mac_boast_stop - _mac_boast_start) * _mac_boast_timebase_info.numer / _mac_boast_timebase_info.denom;\n"
59
+ else
60
+ get_output.print " #{RESULT} = (int64_t)(_boast_stop.tv_sec - _boast_start.tv_sec) * 1000000000ll + _boast_stop.tv_nsec - _boast_start.tv_nsec;\n"
64
61
  end
62
+ get_output.print " rb_hash_aset(_boast_stats,ID2SYM(rb_intern(\"duration\")),rb_float_new((double)#{RESULT}*(double)1e-9));\n"
65
63
  end
66
64
 
67
65
  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.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brice Videau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-09 00:00:00.000000000 Z
11
+ date: 2015-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: narray