BOAST 2.0.2 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/BOAST.gemspec +4 -3
  3. data/lib/BOAST.rb +1 -0
  4. data/lib/BOAST/Language/Arithmetic.rb +5 -1
  5. data/lib/BOAST/Language/BOAST_OpenCL.rb +6 -6
  6. data/lib/BOAST/Language/Case.rb +11 -11
  7. data/lib/BOAST/Language/Comment.rb +2 -2
  8. data/lib/BOAST/Language/Config.rb +5 -5
  9. data/lib/BOAST/Language/DataTypes.rb +31 -29
  10. data/lib/BOAST/Language/Expression.rb +16 -16
  11. data/lib/BOAST/Language/For.rb +6 -6
  12. data/lib/BOAST/Language/FuncCall.rb +7 -7
  13. data/lib/BOAST/Language/HighLevelOperators.rb +6 -6
  14. data/lib/BOAST/Language/If.rb +7 -7
  15. data/lib/BOAST/Language/Index.rb +31 -31
  16. data/lib/BOAST/Language/Intrinsics.rb +27 -27
  17. data/lib/BOAST/Language/OpenMP.rb +19 -19
  18. data/lib/BOAST/Language/Operators.rb +62 -50
  19. data/lib/BOAST/Language/Pragma.rb +4 -4
  20. data/lib/BOAST/Language/Procedure.rb +47 -47
  21. data/lib/BOAST/Language/Slice.rb +14 -14
  22. data/lib/BOAST/Language/State.rb +1 -1
  23. data/lib/BOAST/Language/Transitions.rb +1 -1
  24. data/lib/BOAST/Language/Variable.rb +83 -90
  25. data/lib/BOAST/Language/While.rb +4 -4
  26. data/lib/BOAST/Optimization/Optimization.rb +61 -37
  27. data/lib/BOAST/Runtime/AffinityProbe.rb +99 -15
  28. data/lib/BOAST/Runtime/CRuntime.rb +18 -6
  29. data/lib/BOAST/Runtime/CUDARuntime.rb +11 -7
  30. data/lib/BOAST/Runtime/CoExecute.rb +77 -0
  31. data/lib/BOAST/Runtime/CompiledRuntime.rb +274 -110
  32. data/lib/BOAST/Runtime/Compilers.rb +15 -15
  33. data/lib/BOAST/Runtime/Config.rb +3 -0
  34. data/lib/BOAST/Runtime/EnergyProbe.rb +86 -71
  35. data/lib/BOAST/Runtime/FFIRuntime.rb +1 -1
  36. data/lib/BOAST/Runtime/FORTRANRuntime.rb +15 -5
  37. data/lib/BOAST/Runtime/MPPARuntime.rb +30 -19
  38. data/lib/BOAST/Runtime/OpenCLRuntime.rb +2 -2
  39. data/lib/BOAST/Runtime/Probe.rb +122 -41
  40. metadata +29 -8
@@ -139,7 +139,7 @@ def self.run(*args)
139
139
  @kernel.set_arg(i, params[i])
140
140
  }
141
141
  gws = opts[:global_work_size]
142
- if not gws then
142
+ unless gws then
143
143
  raise ":global_work_size or :block_number are required to run OpenCL kernels!" unless opts[:block_number]
144
144
  gws = []
145
145
  opts[:block_number].each_index { |i|
@@ -148,7 +148,7 @@ def self.run(*args)
148
148
  }
149
149
  end
150
150
  lws = opts[:local_work_size]
151
- if not lws then
151
+ unless lws then
152
152
  lws = opts[:block_size]
153
153
  end
154
154
  event1 = @queue.enqueue_NDrange_kernel(@kernel, gws, :local_work_size => lws)
@@ -32,52 +32,109 @@ EOF
32
32
  end
33
33
  end
34
34
 
35
- def decl
35
+ def preamble
36
+ get_output.print <<EOF
37
+ struct _boast_timer_struct {
38
+ EOF
36
39
  if OS.mac? then
37
- get_output.print " uint64_t _mac_boast_start, _mac_boast_stop;\n"
38
- get_output.print " mach_timebase_info_data_t _mac_boast_timebase_info;\n"
40
+ get_output.print <<EOF
41
+ uint64_t start, stop;
42
+ mach_timebase_info_data_t timebase_info;
43
+ EOF
39
44
  else
40
- get_output.print " struct timespec _boast_start, _boast_stop;\n"
45
+ get_output.print <<EOF
46
+ struct timespec start, stop;
47
+ EOF
41
48
  end
42
- BOAST::decl RESULT
43
- end
49
+ push_env(:indent_level => 2) {
50
+ BOAST::decl RESULT
51
+ }
52
+ get_output.print <<EOF
53
+ };
44
54
 
45
- def configure
46
- end
55
+ static inline void _boast_timer_start(struct _boast_timer_struct * _boast_timer) {
56
+ EOF
57
+ if OS.mac? then
58
+ get_output.print " _boast_timer->start = mach_absolute_time();\n"
59
+ else
60
+ get_output.print " clock_gettime(CLOCK_REALTIME, &_boast_timer->start);\n"
61
+ end
62
+ get_output.print <<EOF
63
+ }
47
64
 
48
- def start
65
+ static inline void _boast_timer_stop(struct _boast_timer_struct * _boast_timer) {
66
+ EOF
49
67
  if OS.mac? then
50
- get_output.print " _mac_boast_start = mach_absolute_time();\n"
68
+ get_output.print " _boast_timer->stop = mach_absolute_time();\n"
51
69
  else
52
- get_output.print " clock_gettime(CLOCK_REALTIME, &_boast_start);\n"
70
+ get_output.print " clock_gettime(CLOCK_REALTIME, &_boast_timer->stop);\n"
53
71
  end
54
- end
72
+ get_output.print <<EOF
73
+ }
55
74
 
56
- def stop
75
+ static inline void _boast_timer_compute(struct _boast_timer_struct * _boast_timer) {
76
+ EOF
57
77
  if OS.mac? then
58
- get_output.print " _mac_boast_stop = mach_absolute_time();\n"
78
+ get_output.print " mach_timebase_info(&_boast_timer->timebase_info);\n"
79
+ get_output.print " _boast_timer->#{RESULT} = (_boast_timer->stop - _boast_timer->start) * _boast_timer->timebase_info.numer / _boast_timer->timebase_info.denom;\n"
59
80
  else
60
- get_output.print " clock_gettime(CLOCK_REALTIME, &_boast_stop);\n"
81
+ get_output.print " _boast_timer->#{RESULT} = (int64_t)(_boast_timer->stop.tv_sec - _boast_timer->start.tv_sec) * 1000000000ll + _boast_timer->stop.tv_nsec - _boast_timer->start.tv_nsec;\n"
61
82
  end
62
- end
83
+ get_output.print <<EOF
84
+ }
63
85
 
64
- def compute
86
+ #ifdef RUBY
87
+ static inline void _boast_timer_store(struct _boast_timer_struct * _boast_timer, VALUE _boast_stats) {
88
+ EOF
89
+ get_output.puts " rb_hash_aset(_boast_stats,ID2SYM(rb_intern(\"duration\")),rb_float_new((double)_boast_timer->#{RESULT}*(double)1e-9));"
65
90
  if OS.mac? then
66
- get_output.print " mach_timebase_info(&_mac_boast_timebase_info);\n"
67
- get_output.print " #{RESULT} = (_mac_boast_stop - _mac_boast_start) * _mac_boast_timebase_info.numer / _mac_boast_timebase_info.denom;\n"
91
+ get_output.puts " rb_hash_aset(_boast_stats,ID2SYM(rb_intern(\"start\")),rb_int_new((int64_t)(_boast_timer->start * _boast_timer->timebase_info.numer / _boast_timer->timebase_info.denom)*1000000000ll));"
92
+ get_output.puts " rb_hash_aset(_boast_stats,ID2SYM(rb_intern(\"end\")),rb_int_new((int64_t)(_boast_timer->stop * _boast_timer->timebase_info.numer / _boast_timer->timebase_info.denom)*1000000000ll));"
68
93
  else
69
- get_output.print " #{RESULT} = (int64_t)(_boast_stop.tv_sec - _boast_start.tv_sec) * 1000000000ll + _boast_stop.tv_nsec - _boast_start.tv_nsec;\n"
94
+ get_output.puts " rb_hash_aset(_boast_stats,ID2SYM(rb_intern(\"start\")),rb_int_new((int64_t)_boast_timer->start.tv_sec * 1000000000ll+_boast_timer->start.tv_nsec));"
95
+ get_output.puts " rb_hash_aset(_boast_stats,ID2SYM(rb_intern(\"end\")),rb_int_new((int64_t)_boast_timer->stop.tv_sec * 1000000000ll+_boast_timer->stop.tv_nsec));"
70
96
  end
97
+ get_output.print <<EOF
98
+ }
99
+ #endif
100
+
101
+ EOF
102
+ end
103
+
104
+ def decl
105
+ get_output.print " struct _boast_timer_struct _boast_timer;\n"
106
+ end
107
+
108
+ def configure
109
+ end
110
+
111
+ def start
112
+ get_output.puts " _boast_timer_start(&_boast_params._boast_timer);"
113
+ end
114
+
115
+ def stop
116
+ get_output.puts " _boast_timer_stop(&_boast_params._boast_timer);"
117
+ end
118
+
119
+ def compute
120
+ get_output.puts " _boast_timer_compute(&_boast_params._boast_timer);"
71
121
  end
72
122
 
73
123
  def store
74
- get_output.print " rb_hash_aset(_boast_stats,ID2SYM(rb_intern(\"duration\")),rb_float_new((double)#{RESULT}*(double)1e-9));\n"
124
+ get_output.puts " _boast_timer_store(&_boast_params._boast_timer, _boast_stats);"
75
125
  end
76
126
 
77
127
  def to_yaml
78
128
  get_output.print <<EOF
79
- printf(":duration: %lf\\n", (double)#{RESULT}*(double)1e-9);
129
+ printf(":duration: %lf\\n", (double)_boast_params._boast_timer.#{RESULT}*(double)1e-9);
80
130
  EOF
131
+ if OS.mac? then
132
+ get_output.puts " printf(\":start: %lld\\n\",(int64_t)(_boast_params._boast_timer.start * _boast_params._boast_timer.timebase_info.numer / _boast_params._boast_timer.timebase_info.denom)*1000000000ll);"
133
+ get_output.puts " printf(\":end: %lld\\n\",(int64_t)(_boast_params._boast_timer.stop * _boast_params._boast_timer.timebase_info.numer / _boast_params._boast_timer.timebase_info.denom)*1000000000ll);"
134
+ else
135
+ get_output.puts " printf(\":start: %lld\\n\",(int64_t)_boast_params._boast_timer.start.tv_sec * 1000000000ll+_boast_params._boast_timer.start.tv_nsec);"
136
+ get_output.puts " printf(\":end: %lld\\n\",(int64_t)_boast_params._boast_timer.stop.tv_sec * 1000000000ll+_boast_params._boast_timer.stop.tv_nsec);"
137
+ end
81
138
  end
82
139
 
83
140
  end
@@ -95,41 +152,72 @@ EOF
95
152
  def header
96
153
  end
97
154
 
98
- def decl
99
- get_output.print " VALUE _boast_event_set = Qnil;\n"
100
- get_output.print " VALUE _boast_papi_results = Qnil;\n"
101
- end
102
-
103
- def configure
155
+ def preamble
104
156
  get_output.print <<EOF
157
+ struct _boast_papi_struct {
158
+ VALUE event_set;
159
+ VALUE results;
160
+ };
161
+
162
+ static void _boast_get_papi_envent_set( VALUE _boast_rb_opts, struct _boast_papi_struct *_boast_papi );
163
+ static void _boast_get_papi_envent_set( VALUE _boast_rb_opts, struct _boast_papi_struct *_boast_papi ) {
164
+ VALUE _boast_event_set = Qnil;
105
165
  if( _boast_rb_opts != Qnil ) {
106
166
  VALUE _boast_PAPI_rb_ptr = Qnil;
107
167
  _boast_PAPI_rb_ptr = rb_hash_aref(_boast_rb_opts, ID2SYM(rb_intern("PAPI")));
108
168
  if( _boast_PAPI_rb_ptr != Qnil ) {
109
169
  VALUE _boast_PAPI = Qnil;
110
170
  VALUE _boast_EventSet = Qnil;
111
- rb_eval_string("require 'PAPI'");
112
171
  _boast_PAPI = rb_const_get(rb_cObject, rb_intern("PAPI"));
113
172
  _boast_EventSet = rb_const_get(_boast_PAPI, rb_intern("EventSet"));
114
173
  _boast_event_set = rb_funcall(_boast_EventSet, rb_intern("new"), 0);
115
174
  rb_funcall(_boast_event_set, rb_intern("add_named"), 1, _boast_PAPI_rb_ptr);
116
175
  }
117
176
  }
177
+ _boast_papi->event_set = _boast_event_set;
178
+ }
179
+
180
+ static void _boast_store_papi_results( struct _boast_papi_struct *_boast_papi, VALUE _boast_rb_opts, VALUE _boast_stats );
181
+ static void _boast_store_papi_results( struct _boast_papi_struct *_boast_papi, VALUE _boast_rb_opts, VALUE _boast_stats ) {
182
+ if( _boast_papi->results != Qnil) {
183
+ VALUE _boast_papi_stats = Qnil;
184
+ _boast_papi_stats = rb_ary_new3(1,rb_hash_aref(_boast_rb_opts, ID2SYM(rb_intern("PAPI"))));
185
+ _boast_papi_stats = rb_funcall(_boast_papi_stats, rb_intern("flatten"), 0);
186
+ _boast_papi_stats = rb_funcall(_boast_papi_stats, rb_intern("zip"), 1, _boast_papi->results);
187
+ _boast_papi->results = rb_funcall(rb_const_get(rb_cObject, rb_intern("Hash")), rb_intern("send"), 2, ID2SYM(rb_intern("[]")), _boast_papi_stats );
188
+ rb_hash_aset(_boast_stats, ID2SYM(rb_intern(\"PAPI\")), _boast_papi->results);
189
+ rb_funcall(_boast_papi->event_set, rb_intern("cleanup"), 0);
190
+ rb_funcall(_boast_papi->event_set, rb_intern("destroy"), 0);
191
+ }
192
+ }
193
+
194
+ EOF
195
+ end
196
+
197
+ def decl
198
+ get_output.print <<EOF
199
+ struct _boast_papi_struct _boast_papi = { Qnil, Qnil };
200
+ EOF
201
+ end
202
+
203
+ def configure
204
+ get_output.print <<EOF
205
+ _boast_get_papi_envent_set( _boast_rb_opts, &_boast_papi );
118
206
  EOF
119
207
  end
120
208
 
121
209
  def start
122
210
  get_output.print <<EOF
123
- if( _boast_event_set != Qnil) {
124
- rb_funcall(_boast_event_set, rb_intern("start"), 0);
211
+ if( _boast_papi.event_set != Qnil) {
212
+ rb_funcall(_boast_papi.event_set, rb_intern("start"), 0);
125
213
  }
126
214
  EOF
127
215
  end
128
216
 
129
217
  def stop
130
218
  get_output.print <<EOF
131
- if( _boast_event_set != Qnil) {
132
- _boast_papi_results = rb_funcall(_boast_event_set, rb_intern("stop"), 0);
219
+ if( _boast_papi.event_set != Qnil) {
220
+ _boast_papi.results = rb_funcall(_boast_papi.event_set, rb_intern("stop"), 0);
133
221
  }
134
222
  EOF
135
223
  end
@@ -139,14 +227,7 @@ EOF
139
227
 
140
228
  def store
141
229
  get_output.print <<EOF
142
- if( _boast_papi_results != Qnil) {
143
- VALUE _boast_papi_stats = Qnil;
144
- _boast_papi_stats = rb_ary_new3(1,rb_hash_aref(_boast_rb_opts, ID2SYM(rb_intern("PAPI"))));
145
- _boast_papi_stats = rb_funcall(_boast_papi_stats, rb_intern("flatten"), 0);
146
- _boast_papi_stats = rb_funcall(_boast_papi_stats, rb_intern("zip"), 1, _boast_papi_results);
147
- _boast_papi_results = rb_funcall(rb_const_get(rb_cObject, rb_intern("Hash")), rb_intern("send"), 2, ID2SYM(rb_intern("[]")), _boast_papi_stats );
148
- rb_hash_aset(_boast_stats,ID2SYM(rb_intern(\"PAPI\")),_boast_papi_results);
149
- }
230
+ _boast_store_papi_results( &_boast_papi, _boast_rb_opts, _boast_stats );
150
231
  EOF
151
232
  end
152
233
 
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: 2.0.2
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brice Videau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-18 00:00:00.000000000 Z
11
+ date: 2017-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: narray
@@ -116,20 +116,40 @@ dependencies:
116
116
  requirements:
117
117
  - - "~>"
118
118
  - !ruby/object:Gem::Version
119
- version: '0'
119
+ version: '1.0'
120
120
  - - ">="
121
121
  - !ruby/object:Gem::Version
122
- version: '0.101'
122
+ version: 1.0.0
123
123
  type: :runtime
124
124
  prerelease: false
125
125
  version_requirements: !ruby/object:Gem::Requirement
126
126
  requirements:
127
127
  - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: '0'
129
+ version: '1.0'
130
130
  - - ">="
131
131
  - !ruby/object:Gem::Version
132
- version: '0.101'
132
+ version: 1.0.0
133
+ - !ruby/object:Gem::Dependency
134
+ name: hwloc
135
+ requirement: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '0.3'
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: 0.3.0
143
+ type: :runtime
144
+ prerelease: false
145
+ version_requirements: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - "~>"
148
+ - !ruby/object:Gem::Version
149
+ version: '0.3'
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: 0.3.0
133
153
  - !ruby/object:Gem::Dependency
134
154
  name: ffi
135
155
  requirement: !ruby/object:Gem::Requirement
@@ -234,6 +254,7 @@ files:
234
254
  - lib/BOAST/Runtime/CKernel.rb
235
255
  - lib/BOAST/Runtime/CRuntime.rb
236
256
  - lib/BOAST/Runtime/CUDARuntime.rb
257
+ - lib/BOAST/Runtime/CoExecute.rb
237
258
  - lib/BOAST/Runtime/CompiledRuntime.rb
238
259
  - lib/BOAST/Runtime/Compilers.rb
239
260
  - lib/BOAST/Runtime/Config.rb
@@ -260,7 +281,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
260
281
  requirements:
261
282
  - - ">="
262
283
  - !ruby/object:Gem::Version
263
- version: 1.9.3
284
+ version: 2.0.0
264
285
  required_rubygems_version: !ruby/object:Gem::Requirement
265
286
  requirements:
266
287
  - - ">="
@@ -268,7 +289,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
289
  version: '0'
269
290
  requirements: []
270
291
  rubyforge_project:
271
- rubygems_version: 2.5.1
292
+ rubygems_version: 2.5.2
272
293
  signing_key:
273
294
  specification_version: 4
274
295
  summary: BOAST is a computing kernel metaprogramming tool.