BOAST 1.0.1 → 1.0.2
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 +2 -1
- data/lib/BOAST/CKernel.rb +84 -32
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 088ca11e6055b1cdd5e9580b43be12939db50203
|
4
|
+
data.tar.gz: 720f4cdd6c10a19380a5d00872d291e73b1b4c85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 528c03146b6b66b806caa187f14a1a9ee8417399ea0ba769b13860384eb0840ac40446f5bdac646771efc569372f2b4a2e8fd25a514d438059de6c78dc46ae9c
|
7
|
+
data.tar.gz: 05f318ecd0a323e045c1dd8cc6e6722a6a7aefd90d35214e2306aac0ec400abbd8858aa4a670ffe04ae15d7e33478578853620600a0d6a8b0df9f8bb09956ccb
|
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.
|
3
|
+
s.version = "1.0.2"
|
4
4
|
s.author = "Brice Videau"
|
5
5
|
s.email = "brice.videau@imag.fr"
|
6
6
|
s.homepage = "https://github.com/Nanosim-LIG/boast"
|
@@ -42,5 +42,6 @@ Gem::Specification.new do |s|
|
|
42
42
|
s.add_dependency 'narray', '>=0.6.0.8'
|
43
43
|
s.add_dependency 'opencl_ruby_ffi', '>=0.4'
|
44
44
|
s.add_dependency 'systemu', '>=2.2.0'
|
45
|
+
s.add_dependency 'os', '>=0.9.6'
|
45
46
|
s.add_dependency 'PAPI', '>=0.101'
|
46
47
|
end
|
data/lib/BOAST/CKernel.rb
CHANGED
@@ -6,6 +6,7 @@ require 'rbconfig'
|
|
6
6
|
require 'systemu'
|
7
7
|
require 'yaml'
|
8
8
|
require 'pathname'
|
9
|
+
require 'os'
|
9
10
|
|
10
11
|
module BOAST
|
11
12
|
@@compiler_default_options = {
|
@@ -37,13 +38,16 @@ module BOAST
|
|
37
38
|
|
38
39
|
module PrivateStateAccessor
|
39
40
|
private_boolean_state_accessor :verbose
|
41
|
+
private_boolean_state_accessor :debug_source
|
40
42
|
private_boolean_state_accessor :ffi
|
41
43
|
end
|
42
44
|
|
43
45
|
boolean_state_accessor :verbose
|
46
|
+
boolean_state_accessor :debug_source
|
44
47
|
boolean_state_accessor :ffi
|
45
48
|
@@ffi = false
|
46
49
|
@@verbose = false
|
50
|
+
@@debug_source = false
|
47
51
|
FORTRAN_LINE_LENGTH = 72
|
48
52
|
|
49
53
|
module_function
|
@@ -81,6 +85,7 @@ module BOAST
|
|
81
85
|
@@compiler_default_options[:LD] = ENV["LD"] if ENV["LD"]
|
82
86
|
@@verbose = ENV["VERBOSE"] if ENV["VERBOSE"]
|
83
87
|
@@ffi = ENV["FFI"] if ENV["FFI"]
|
88
|
+
@@debug_source = ENV["DEBUG_SOURCE"] if ENV["DEBUG_SOURCE"]
|
84
89
|
end
|
85
90
|
|
86
91
|
read_boast_config
|
@@ -184,7 +189,7 @@ module BOAST
|
|
184
189
|
cflags += " #{openmp_cflags}"
|
185
190
|
end
|
186
191
|
|
187
|
-
rule
|
192
|
+
rule ".#{RbConfig::CONFIG["OBJEXT"]}" => '.c' do |t|
|
188
193
|
c_call_string = "#{c_compiler} #{cflags} -c -o #{t.name} #{t.source}"
|
189
194
|
runner.call(t, c_call_string)
|
190
195
|
end
|
@@ -200,7 +205,7 @@ module BOAST
|
|
200
205
|
cxxflags += " #{openmp_cxxflags}"
|
201
206
|
end
|
202
207
|
|
203
|
-
rule
|
208
|
+
rule ".#{RbConfig::CONFIG["OBJEXT"]}" => '.cpp' do |t|
|
204
209
|
cxx_call_string = "#{cxx_compiler} #{cxxflags} -c -o #{t.name} #{t.source}"
|
205
210
|
runner.call(t, cxx_call_string)
|
206
211
|
end
|
@@ -217,7 +222,7 @@ module BOAST
|
|
217
222
|
fcflags += " #{openmp_fcflags}"
|
218
223
|
end
|
219
224
|
|
220
|
-
rule
|
225
|
+
rule ".#{RbConfig::CONFIG["OBJEXT"]}" => '.f90' do |t|
|
221
226
|
f_call_string = "#{f_compiler} #{fcflags} -c -o #{t.name} #{t.source}"
|
222
227
|
runner.call(t, f_call_string)
|
223
228
|
end
|
@@ -228,7 +233,7 @@ module BOAST
|
|
228
233
|
cudaflags = options[:NVCCFLAGS]
|
229
234
|
cudaflags += " --compiler-options '-fPIC'"
|
230
235
|
|
231
|
-
rule
|
236
|
+
rule ".#{RbConfig::CONFIG["OBJEXT"]}" => '.cu' do |t|
|
232
237
|
cuda_call_string = "#{cuda_compiler} #{cudaflags} -c -o #{t.name} #{t.source}"
|
233
238
|
runner.call(t, cuda_call_string)
|
234
239
|
end
|
@@ -236,7 +241,8 @@ module BOAST
|
|
236
241
|
|
237
242
|
def setup_linker(options)
|
238
243
|
ldflags = options[:LDFLAGS]
|
239
|
-
ldflags += " -L#{RbConfig::CONFIG["libdir"]} #{RbConfig::CONFIG["LIBRUBYARG"]}
|
244
|
+
ldflags += " -L#{RbConfig::CONFIG["libdir"]} #{RbConfig::CONFIG["LIBRUBYARG"]}"
|
245
|
+
ldflags += " -lrt" if not OS.mac?
|
240
246
|
ldflags += " -lcudart" if @lang == CUDA
|
241
247
|
c_compiler = options[:CC]
|
242
248
|
c_compiler = "cc" if not c_compiler
|
@@ -248,7 +254,15 @@ module BOAST
|
|
248
254
|
ldflags += " #{openmp_ldflags}"
|
249
255
|
end
|
250
256
|
|
251
|
-
|
257
|
+
if OS.mac? then
|
258
|
+
ldflags = "-Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress #{ldflags}"
|
259
|
+
ldshared = "-dynamic -bundle"
|
260
|
+
else
|
261
|
+
ldflags = "-Wl,-Bsymbolic-functions -Wl,-z,relro -rdynamic -Wl,-export-dynamic #{ldflags}"
|
262
|
+
ldshared = "-shared"
|
263
|
+
end
|
264
|
+
|
265
|
+
return [linker, ldshared, ldflags]
|
252
266
|
end
|
253
267
|
|
254
268
|
def setup_compilers(options = {})
|
@@ -482,8 +496,10 @@ EOF
|
|
482
496
|
module_file = File::open(module_file_name,"w+")
|
483
497
|
set_output( module_file )
|
484
498
|
fill_module(module_file, module_name)
|
485
|
-
|
486
|
-
|
499
|
+
if debug_source? then
|
500
|
+
module_file.rewind
|
501
|
+
puts module_file.read
|
502
|
+
end
|
487
503
|
module_file.close
|
488
504
|
set_lang( previous_lang )
|
489
505
|
set_output( previous_output )
|
@@ -503,6 +519,10 @@ EOF
|
|
503
519
|
path = source_file.path
|
504
520
|
target = path.chomp(File::extname(path))+".o"
|
505
521
|
fill_code(source_file)
|
522
|
+
if debug_source? then
|
523
|
+
source_file.rewind
|
524
|
+
puts source_file.read
|
525
|
+
end
|
506
526
|
source_file.close
|
507
527
|
return [source_file, path, target]
|
508
528
|
end
|
@@ -589,7 +609,7 @@ EOF
|
|
589
609
|
compiler_options.update(options)
|
590
610
|
return build_opencl(compiler_options) if @lang == CL
|
591
611
|
|
592
|
-
linker, ldflags = setup_compilers(compiler_options)
|
612
|
+
linker, ldshared, ldflags = setup_compilers(compiler_options)
|
593
613
|
|
594
614
|
extension = @@extensions[@lang]
|
595
615
|
|
@@ -597,10 +617,10 @@ EOF
|
|
597
617
|
|
598
618
|
if not ffi? then
|
599
619
|
module_file_name, module_name = create_module_source(path)
|
600
|
-
module_target = module_file_name.chomp(File::extname(module_file_name))+".
|
601
|
-
module_final = module_file_name.chomp(File::extname(module_file_name))+".
|
620
|
+
module_target = module_file_name.chomp(File::extname(module_file_name))+"."+RbConfig::CONFIG["OBJEXT"]
|
621
|
+
module_final = module_file_name.chomp(File::extname(module_file_name))+"."+RbConfig::CONFIG["DLEXT"]
|
602
622
|
else
|
603
|
-
module_final = path.chomp(File::extname(path))+".
|
623
|
+
module_final = path.chomp(File::extname(path))+"."+RbConfig::CONFIG["DLEXT"]
|
604
624
|
module_name = "Mod_" + File::split(path.chomp(File::extname(path)))[1].gsub("-","_")
|
605
625
|
end
|
606
626
|
|
@@ -608,16 +628,16 @@ EOF
|
|
608
628
|
|
609
629
|
if not ffi? then
|
610
630
|
file module_final => [module_target, target] do
|
611
|
-
#puts "#{linker}
|
612
|
-
sh "#{linker}
|
631
|
+
#puts "#{linker} #{ldshared} -o #{module_final} #{module_target} #{target} #{kernel_files.join(" ")} #{ldflags}"
|
632
|
+
sh "#{linker} #{ldshared} -o #{module_final} #{module_target} #{target} #{(kernel_files.collect {|f| f.path}).join(" ")} #{ldflags}"
|
613
633
|
end
|
614
634
|
Rake::Task[module_final].invoke
|
615
635
|
|
616
636
|
require(module_final)
|
617
637
|
else
|
618
638
|
file module_final => [target] do
|
619
|
-
#puts "#{linker}
|
620
|
-
sh "#{linker}
|
639
|
+
#puts "#{linker} #{ldshared} -o #{module_final} #{target} #{kernel_files.join(" ")} #{ldflags}"
|
640
|
+
sh "#{linker} #{ldshared} -o #{module_final} #{target} #{(kernel_files.collect {|f| f.path}).join(" ")} #{ldflags}"
|
621
641
|
end
|
622
642
|
Rake::Task[module_final].invoke
|
623
643
|
create_ffi_module(module_name, module_final)
|
@@ -693,12 +713,24 @@ EOF
|
|
693
713
|
module_file.print <<EOF
|
694
714
|
#include "ruby.h"
|
695
715
|
#include <inttypes.h>
|
696
|
-
#include <time.h>
|
697
716
|
#ifdef HAVE_NARRAY_H
|
698
717
|
#include "narray.h"
|
699
718
|
#endif
|
700
719
|
EOF
|
701
|
-
if
|
720
|
+
if OS.mac? then
|
721
|
+
module_file.print <<EOF
|
722
|
+
#if __cplusplus
|
723
|
+
extern "C" {
|
724
|
+
#endif
|
725
|
+
#include <mach/mach_time.h>
|
726
|
+
#if __cplusplus
|
727
|
+
}
|
728
|
+
#endif
|
729
|
+
EOF
|
730
|
+
else
|
731
|
+
module_file.print "#include <time.h>\n"
|
732
|
+
end
|
733
|
+
if @lang == CUDA then
|
702
734
|
module_file.print "#include <cuda_runtime.h>\n"
|
703
735
|
end
|
704
736
|
end
|
@@ -754,8 +786,9 @@ EOF
|
|
754
786
|
_boast_array_size = _boast_n_ary->total * na_sizeof[_boast_n_ary->type];
|
755
787
|
cudaMalloc( (void **) &#{param.name}, _boast_array_size);
|
756
788
|
cudaMemcpy(#{param.name}, (void *) _boast_n_ary->ptr, _boast_array_size, cudaMemcpyHostToDevice);
|
757
|
-
} else
|
789
|
+
} else {
|
758
790
|
rb_raise(rb_eArgError, "wrong type of argument %d", #{i});
|
791
|
+
}
|
759
792
|
EOF
|
760
793
|
else
|
761
794
|
module_file.print <<EOF
|
@@ -765,8 +798,9 @@ EOF
|
|
765
798
|
struct NARRAY *_boast_n_ary;
|
766
799
|
Data_Get_Struct(_boast_rb_ptr, struct NARRAY, _boast_n_ary);
|
767
800
|
#{param.name} = (void *) _boast_n_ary->ptr;
|
768
|
-
} else
|
801
|
+
} else {
|
769
802
|
rb_raise(rb_eArgError, "wrong type of argument %d", #{i});
|
803
|
+
}
|
770
804
|
EOF
|
771
805
|
end
|
772
806
|
end
|
@@ -785,9 +819,13 @@ EOF
|
|
785
819
|
set_decl_module(false)
|
786
820
|
module_file.print " #{@procedure.properties[:return].type.decl} _boast_ret;\n" if @procedure.properties[:return]
|
787
821
|
module_file.print " VALUE _boast_stats = rb_hash_new();\n"
|
788
|
-
module_file.print " VALUE _boast_refs = rb_hash_new();\n"
|
789
822
|
module_file.print " VALUE _boast_event_set = Qnil;\n"
|
790
|
-
|
823
|
+
if OS.mac? then
|
824
|
+
module_file.print " uint64_t _mac_boast_start, _mac_boast_stop;\n"
|
825
|
+
module_file.print " mach_timebase_info_data_t _mac_boast_timebase_info;\n"
|
826
|
+
else
|
827
|
+
module_file.print " struct timespec _boast_start, _boast_stop;\n"
|
828
|
+
end
|
791
829
|
module_file.print " unsigned long long int _boast_duration;\n"
|
792
830
|
end
|
793
831
|
|
@@ -847,7 +885,6 @@ EOF
|
|
847
885
|
def get_PAPI_options(module_file)
|
848
886
|
module_file.print <<EOF
|
849
887
|
if( _boast_rb_opts != Qnil ) {
|
850
|
-
VALUE _boast_rb_array_data = Qnil;
|
851
888
|
_boast_rb_ptr = rb_hash_aref(_boast_rb_opts, ID2SYM(rb_intern("PAPI")));
|
852
889
|
if( _boast_rb_ptr != Qnil ) {
|
853
890
|
VALUE _boast_PAPI = Qnil;
|
@@ -936,9 +973,9 @@ EOF
|
|
936
973
|
end
|
937
974
|
module_file.print <<EOF
|
938
975
|
cudaFree( (void *) #{param.name});
|
939
|
-
} else
|
976
|
+
} else {
|
940
977
|
rb_raise(rb_eArgError, "wrong type of argument %d", #{i});
|
941
|
-
|
978
|
+
}
|
942
979
|
EOF
|
943
980
|
end
|
944
981
|
end
|
@@ -947,6 +984,7 @@ EOF
|
|
947
984
|
@procedure.parameters.each_with_index do |param,i|
|
948
985
|
if param.scalar_output? then
|
949
986
|
if first then
|
987
|
+
module_file.print " VALUE _boast_refs = rb_hash_new();\n"
|
950
988
|
module_file.print " rb_hash_aset(_boast_stats,ID2SYM(rb_intern(\"reference_return\")),_boast_refs);\n"
|
951
989
|
first = false
|
952
990
|
end
|
@@ -964,10 +1002,6 @@ EOF
|
|
964
1002
|
end
|
965
1003
|
|
966
1004
|
def store_result(module_file)
|
967
|
-
if @lang != CUDA then
|
968
|
-
module_file.print " _boast_duration = (unsigned long long int)_boast_stop.tv_sec * (unsigned long long int)1000000000 + _boast_stop.tv_nsec;\n"
|
969
|
-
module_file.print " _boast_duration -= (unsigned long long int)_boast_start.tv_sec * (unsigned long long int)1000000000 + _boast_start.tv_nsec;\n"
|
970
|
-
end
|
971
1005
|
module_file.print " rb_hash_aset(_boast_stats,ID2SYM(rb_intern(\"duration\")),rb_float_new((double)_boast_duration*(double)1e-9));\n"
|
972
1006
|
if @procedure.properties[:return] then
|
973
1007
|
type_ret = @procedure.properties[:return].type
|
@@ -983,7 +1017,7 @@ EOF
|
|
983
1017
|
module_preamble(module_file, module_name)
|
984
1018
|
|
985
1019
|
module_file.puts "VALUE method_run(int _boast_argc, VALUE *_boast_argv, VALUE _boast_self) {"
|
986
|
-
|
1020
|
+
increment_indent_level
|
987
1021
|
check_args(module_file)
|
988
1022
|
|
989
1023
|
argc = @procedure.parameters.length
|
@@ -1002,19 +1036,37 @@ EOF
|
|
1002
1036
|
|
1003
1037
|
get_PAPI_options(module_file)
|
1004
1038
|
|
1005
|
-
|
1039
|
+
if OS.mac? then
|
1040
|
+
module_file.print " _mac_boast_start = mach_absolute_time();\n"
|
1041
|
+
else
|
1042
|
+
module_file.print " clock_gettime(CLOCK_REALTIME, &_boast_start);\n"
|
1043
|
+
end
|
1006
1044
|
|
1007
1045
|
create_procedure_call(module_file)
|
1008
1046
|
|
1009
|
-
|
1047
|
+
if OS.mac? then
|
1048
|
+
module_file.print " _mac_boast_stop = mach_absolute_time();\n"
|
1049
|
+
else
|
1050
|
+
module_file.print " clock_gettime(CLOCK_REALTIME, &_boast_stop);\n"
|
1051
|
+
end
|
1010
1052
|
|
1011
1053
|
get_PAPI_results(module_file)
|
1012
1054
|
|
1055
|
+
if @lang != CUDA then
|
1056
|
+
if OS.mac? then
|
1057
|
+
module_file.print " mach_timebase_info(&_mac_boast_timebase_info);\n"
|
1058
|
+
module_file.print " _boast_duration = (_mac_boast_stop - _mac_boast_start) * _mac_boast_timebase_info.numer / _mac_boast_timebase_info.denom;\n"
|
1059
|
+
else
|
1060
|
+
module_file.print " _boast_duration = (_boast_stop.tv_sec - _boast_start.tv_sec) * (unsigned long long int)1000000000 + _boast_stop.tv_nsec - _boast_start.tv_nsec;\n"
|
1061
|
+
end
|
1062
|
+
end
|
1063
|
+
|
1013
1064
|
get_results(module_file, argv, rb_ptr)
|
1014
1065
|
|
1015
1066
|
store_result(module_file)
|
1016
1067
|
|
1017
1068
|
module_file.print " return _boast_stats;\n"
|
1069
|
+
decrement_indent_level
|
1018
1070
|
module_file.print "}"
|
1019
1071
|
end
|
1020
1072
|
|
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
|
+
version: 1.0.2
|
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-
|
11
|
+
date: 2015-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: narray
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 2.2.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: os
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.9.6
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.9.6
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: PAPI
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|