BOAST 0.994 → 0.995
Sign up to get free protection for your applications and to get access to all the features.
- data/BOAST.gemspec +1 -1
- data/lib/BOAST/CKernel.rb +121 -0
- data/lib/BOAST/DataTypes.rb +4 -0
- metadata +2 -2
data/BOAST.gemspec
CHANGED
data/lib/BOAST/CKernel.rb
CHANGED
@@ -661,6 +661,127 @@ EOF
|
|
661
661
|
end
|
662
662
|
end
|
663
663
|
|
664
|
+
def load_ref_inputs(path = "", suffix = ".in" )
|
665
|
+
return load_ref_files( path, suffix, :in )
|
666
|
+
end
|
667
|
+
|
668
|
+
def load_ref_outputs(path = "", suffix = ".out" )
|
669
|
+
return load_ref_files( path, suffix, :out )
|
670
|
+
end
|
671
|
+
|
672
|
+
def compare_ref(ref_outputs, outputs, epsilon = nil)
|
673
|
+
res = {}
|
674
|
+
@procedure.parameters.each_with_index { |param, indx|
|
675
|
+
if param.direction == :in or param.constant then
|
676
|
+
next
|
677
|
+
end
|
678
|
+
if param.dimension then
|
679
|
+
diff = (outputs[indx] - ref_outputs[indx]).abs
|
680
|
+
if epsilon then
|
681
|
+
diff.each { |elem|
|
682
|
+
raise "Error: #{param.name} different from ref by: #{elem}!" if elem > epsilon
|
683
|
+
}
|
684
|
+
end
|
685
|
+
res[param.name] = diff.max
|
686
|
+
else
|
687
|
+
raise "Error: #{param.name} different from ref: #{outputs[indx]} != #{ref_outputs[indx]} !" if epsilon and (outputs[indx] - ref_outputs[indx]).abs > epsilon
|
688
|
+
res[param.name] = (outputs[indx] - ref_outputs[indx]).abs
|
689
|
+
end
|
690
|
+
}
|
691
|
+
return res
|
692
|
+
end
|
693
|
+
|
694
|
+
def load_ref_files( path = "", suffix = "", intent )
|
695
|
+
proc_path = path + "/#{@procedure.name}."
|
696
|
+
res = []
|
697
|
+
@procedure.parameters.collect { |param|
|
698
|
+
if intent == :out and ( param.direction == :in or param.constant ) then
|
699
|
+
res.push nil
|
700
|
+
next
|
701
|
+
end
|
702
|
+
f = File::new( proc_path+param.name+suffix, "rb" )
|
703
|
+
if param.dimension then
|
704
|
+
if param.type.class == BOAST::Real then
|
705
|
+
case param.type.size
|
706
|
+
when 4
|
707
|
+
type = NArray::SFLOAT
|
708
|
+
when 8
|
709
|
+
type = NArray::FLOAT
|
710
|
+
else
|
711
|
+
STDERR::puts "Unsupported Float size for NArray: #{param.type.size}, defaulting to byte" if BOAST::debug
|
712
|
+
type = NArray::BYTE
|
713
|
+
end
|
714
|
+
elsif param.type.class == BOAST::Int then
|
715
|
+
case param.type.size
|
716
|
+
when 1
|
717
|
+
type = NArray::BYTE
|
718
|
+
when 2
|
719
|
+
type = NArray::SINT
|
720
|
+
when 4
|
721
|
+
type = NArray::SINT
|
722
|
+
else
|
723
|
+
STDERR::puts "Unsupported Int size for NArray: #{param.type.size}, defaulting to byte" if BOAST::debug
|
724
|
+
type = NArray::BYTE
|
725
|
+
end
|
726
|
+
else
|
727
|
+
STDERR::puts "Unkown array type for NArray: #{param.type}, defaulting to byte" if BOAST::debug
|
728
|
+
type = NArray::BYTE
|
729
|
+
end
|
730
|
+
if f.size == 0 then
|
731
|
+
res.push NArray::new(type, 1)
|
732
|
+
else
|
733
|
+
res.push NArray.to_na(f.read, type)
|
734
|
+
end
|
735
|
+
else
|
736
|
+
if param.type.class == BOAST::Real then
|
737
|
+
case param.type.size
|
738
|
+
when 4
|
739
|
+
type = "f"
|
740
|
+
when 8
|
741
|
+
type = "d"
|
742
|
+
else
|
743
|
+
raise "Unsupported Real scalar size: #{param.type.size}!"
|
744
|
+
end
|
745
|
+
elsif param.type.class == BOAST::Int then
|
746
|
+
case param.type.size
|
747
|
+
when 1
|
748
|
+
type = "C"
|
749
|
+
when 2
|
750
|
+
type = "S"
|
751
|
+
when 4
|
752
|
+
type = "L"
|
753
|
+
when 8
|
754
|
+
type = "Q"
|
755
|
+
else
|
756
|
+
raise "Unsupported Int scalar size: #{param.type.size}!"
|
757
|
+
end
|
758
|
+
if param.type.signed? then
|
759
|
+
type.downcase!
|
760
|
+
end
|
761
|
+
end
|
762
|
+
res.push f.read.unpack(type).first
|
763
|
+
end
|
764
|
+
f.close
|
765
|
+
}
|
766
|
+
if @lang == BOAST::CUDA or @lang == BOAST::CL then
|
767
|
+
f = File::new( proc_path +"problem_size", "r")
|
768
|
+
s = f.read
|
769
|
+
local_dim, global_dim = s.scan(/<(.*?)>/)
|
770
|
+
local_dim = local_dim.pop.split(",").collect!{ |e| e.to_i }
|
771
|
+
global_dim = global_dim.pop.split(",").collect!{ |e| e.to_i }
|
772
|
+
(local_dim.length..2).each{ |i| local_dim[i] = 1 }
|
773
|
+
(global_dim.length..2).each{ |i| global_dim[i] = 1 }
|
774
|
+
if @lang == BOAST::CL then
|
775
|
+
local_dim.each_index { |indx| global_dim[indx] *= local_dim[indx] }
|
776
|
+
res.push( { :global_work_size => global_dim, :local_work_size => local_dim } )
|
777
|
+
else
|
778
|
+
res.push( { :block_number => global_dim, :block_size => local_dim } )
|
779
|
+
end
|
780
|
+
f.close
|
781
|
+
end
|
782
|
+
return res
|
783
|
+
end
|
784
|
+
|
664
785
|
def cost(*args)
|
665
786
|
@cost_function.call(*args)
|
666
787
|
end
|
data/lib/BOAST/DataTypes.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: BOAST
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.995'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-06-
|
12
|
+
date: 2014-06-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: narray
|