BOAST 0.99995 → 0.99996
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/BOAST.gemspec +2 -1
- data/lib/BOAST/For.rb +21 -5
- data/lib/BOAST/OpenMP.rb +186 -0
- data/lib/BOAST.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40c21d4b9f3af7ba3e0a34a8a55b9a7d65329f8f
|
4
|
+
data.tar.gz: dd8c7914a2b7918295453dbeffd172a505014cf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bbe1a51a60e2cd46ceaa611e45d51e294d893c3b2d528fd586fdbd89bdd1ba0b8a0c3189569989a0c2e5a532b16a71e02b3ce5835a44b0b238214d8cf9e4340
|
7
|
+
data.tar.gz: f661fa69d0309e6c6b2f294925c08b1c6ddf9f854f745d1b1bb8d1f79d6519d105b8f854eb8514c6f75e96bffbd181ff71ee6fd2028ef1f05f6a8f4bcfc126ce
|
data/BOAST.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'BOAST'
|
3
|
-
s.version = "0.
|
3
|
+
s.version = "0.99996"
|
4
4
|
s.author = "Brice Videau"
|
5
5
|
s.email = "brice.videau@imag.fr"
|
6
6
|
s.homepage = "https://forge.imag.fr/projects/boast/"
|
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
lib/BOAST/Print.rb
|
34
34
|
lib/BOAST/State.rb
|
35
35
|
lib/BOAST/Optimization.rb
|
36
|
+
lib/BOAST/OpenMP.rb
|
36
37
|
)
|
37
38
|
s.has_rdoc = true
|
38
39
|
s.license = 'BSD'
|
data/lib/BOAST/For.rb
CHANGED
@@ -1,19 +1,28 @@
|
|
1
1
|
module BOAST
|
2
2
|
|
3
3
|
class For < ControlStructure
|
4
|
+
include OpenMP::Pragma
|
4
5
|
|
5
6
|
attr_reader :iterator
|
6
7
|
attr_reader :begin
|
7
8
|
attr_reader :end
|
8
9
|
attr_reader :step
|
9
10
|
|
10
|
-
def initialize(i, b, e,
|
11
|
+
def initialize(i, b, e, options={}, &block)
|
12
|
+
default_options = {:step => 1}
|
13
|
+
default_options.update( options )
|
11
14
|
@iterator = i
|
12
15
|
@begin = b
|
13
16
|
@end = e
|
14
|
-
@step =
|
17
|
+
@step = default_options[:step]
|
15
18
|
@operator = "<="
|
16
19
|
@block = block
|
20
|
+
@openmp = default_options[:openmp]
|
21
|
+
if @openmp and @openmp.kind_of?(Hash) then
|
22
|
+
@openmp_clauses = @openmp
|
23
|
+
else
|
24
|
+
@openmp_clauses = {}
|
25
|
+
end
|
17
26
|
begin
|
18
27
|
push_env( :replace_constants => true )
|
19
28
|
if @step.kind_of?(Variable) then
|
@@ -33,12 +42,16 @@ module BOAST
|
|
33
42
|
|
34
43
|
@@c_strings = {
|
35
44
|
:for => '"for (#{i} = #{b}; #{i} #{o} #{e}; #{i} += #{s}) {"',
|
36
|
-
:end => '"}"'
|
45
|
+
:end => '"}"',
|
46
|
+
:openmp_for => '"#pragma omp for #{c}"',
|
47
|
+
:openmp_end => '""'
|
37
48
|
}
|
38
49
|
|
39
50
|
@@f_strings = {
|
40
51
|
:for => '"do #{i} = #{b}, #{e}, #{s}"',
|
41
|
-
:end => '"end do"'
|
52
|
+
:end => '"end do"',
|
53
|
+
:openmp_for => '"!$omp do #{c}"',
|
54
|
+
:openmp_end => '"!$omp end do #{c}"'
|
42
55
|
}
|
43
56
|
|
44
57
|
@@strings = {
|
@@ -50,6 +63,8 @@ module BOAST
|
|
50
63
|
|
51
64
|
eval token_string_generator( * %w{for i b e s o})
|
52
65
|
eval token_string_generator( * %w{end})
|
66
|
+
eval token_string_generator( * %w{openmp_for c})
|
67
|
+
eval token_string_generator( * %w{openmp_end c})
|
53
68
|
|
54
69
|
def to_s
|
55
70
|
s = for_string(@iterator, @begin, @end, @step, @operator)
|
@@ -100,6 +115,7 @@ module BOAST
|
|
100
115
|
end
|
101
116
|
|
102
117
|
def open
|
118
|
+
output.puts openmp_for_string(openmp_clauses_to_s) if @openmp
|
103
119
|
s=""
|
104
120
|
s += indent
|
105
121
|
s += to_s
|
@@ -123,7 +139,7 @@ module BOAST
|
|
123
139
|
s += indent
|
124
140
|
s += end_string
|
125
141
|
output.puts s
|
126
|
-
|
142
|
+
output.puts openmp_end_string(openmp_end_clauses_to_s) if @openmp and openmp_end_string(openmp_end_clauses_to_s) != ""
|
127
143
|
end
|
128
144
|
|
129
145
|
end
|
data/lib/BOAST/OpenMP.rb
ADDED
@@ -0,0 +1,186 @@
|
|
1
|
+
module BOAST
|
2
|
+
|
3
|
+
module OpenMP
|
4
|
+
|
5
|
+
module Pragma
|
6
|
+
|
7
|
+
def openmp_pragma_to_s
|
8
|
+
s = ""
|
9
|
+
if lang == FORTRAN then
|
10
|
+
s += "!$omp"
|
11
|
+
elsif lang == C then
|
12
|
+
s += "#pragma omp"
|
13
|
+
else
|
14
|
+
raise "Language does not support OpenMP!"
|
15
|
+
end
|
16
|
+
return s
|
17
|
+
end
|
18
|
+
|
19
|
+
def openmp_clauses_to_s
|
20
|
+
s = ""
|
21
|
+
if @openmp_clauses[:if] then
|
22
|
+
s += " if(#{@openmp_clauses[:if]})"
|
23
|
+
end
|
24
|
+
if @openmp_clauses[:num_threads] then
|
25
|
+
s += " num_threads(#{@openmp_clauses[:num_threads]})"
|
26
|
+
end
|
27
|
+
if @openmp_clauses[:default] then
|
28
|
+
s += " default(#{@openmp_clauses[:default]})"
|
29
|
+
end
|
30
|
+
if @openmp_clauses[:private] then
|
31
|
+
s += " private(#{[@openmp_clauses[:private]].flatten.join(", ")})"
|
32
|
+
end
|
33
|
+
if @openmp_clauses[:firstprivate] then
|
34
|
+
s += " firstprivate(#{[@openmp_clauses[:firstprivate]].flatten.join(", ")})"
|
35
|
+
end
|
36
|
+
if @openmp_clauses[:lastprivate] then
|
37
|
+
s += " lastprivate(#{[@openmp_clauses[:lastprivate]].flatten.join(", ")})"
|
38
|
+
end
|
39
|
+
if lang == C then
|
40
|
+
if @openmp_clauses[:copyprivate] then
|
41
|
+
s += " copyprivate(#{[@openmp_clauses[:copyprivate]].flatten.join(", ")})"
|
42
|
+
end
|
43
|
+
if @openmp_clauses[:nowait] then
|
44
|
+
s += " nowait"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
if @openmp_clauses[:shared] then
|
48
|
+
s += " shared(#{[@openmp_clauses[:shared]].flatten.join(", ")})"
|
49
|
+
end
|
50
|
+
if @openmp_clauses[:copyin] then
|
51
|
+
s += " copyin(#{[@openmp_clauses[:copyin]].flatten.join(", ")})"
|
52
|
+
end
|
53
|
+
if @openmp_clauses[:reduction] then
|
54
|
+
options[:reduction].each { |identifier, list|
|
55
|
+
s += " reduction(#{identifier}: #{list.join(", ")})"
|
56
|
+
}
|
57
|
+
end
|
58
|
+
if @openmp_clauses[:schedule] then
|
59
|
+
s += " schedule(#{@openmp_clauses[:schedule].join(", ")})"
|
60
|
+
end
|
61
|
+
if @openmp_clauses[:collapse] then
|
62
|
+
s += " collapse(#{@openmp_clauses[:collapse]})"
|
63
|
+
end
|
64
|
+
if @openmp_clauses[:ordered] then
|
65
|
+
s += " ordered"
|
66
|
+
end
|
67
|
+
return s
|
68
|
+
end
|
69
|
+
|
70
|
+
def openmp_end_clauses_to_s
|
71
|
+
s = ""
|
72
|
+
if lang == FORTRAN then
|
73
|
+
if @openmp_clauses[:copyprivate] then
|
74
|
+
s += " copyprivate(#{[@openmp_clauses[:copyprivate]].flatten.join(", ")})"
|
75
|
+
end
|
76
|
+
if @openmp_clauses[:nowait] then
|
77
|
+
s += " nowait"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
return s
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
module_function
|
86
|
+
def functorize(klass)
|
87
|
+
name = klass.name.split('::').last
|
88
|
+
s = <<EOF
|
89
|
+
def #{name}(*args,&block)
|
90
|
+
#{name}::new(*args,&block)
|
91
|
+
end
|
92
|
+
|
93
|
+
module_function :#{name}
|
94
|
+
EOF
|
95
|
+
eval s
|
96
|
+
end
|
97
|
+
|
98
|
+
def var_functorize(klass)
|
99
|
+
name = klass.name.split('::').last
|
100
|
+
s = <<EOF
|
101
|
+
def #{name}(*args,&block)
|
102
|
+
Variable::new(args[0],#{name},*args[1..-1], &block)
|
103
|
+
end
|
104
|
+
|
105
|
+
module_function :#{name}
|
106
|
+
EOF
|
107
|
+
eval s
|
108
|
+
end
|
109
|
+
|
110
|
+
module Functor
|
111
|
+
|
112
|
+
def self.extended(mod)
|
113
|
+
BOAST::OpenMP::functorize(mod)
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
class ControlStructure
|
119
|
+
include PrivateStateAccessor
|
120
|
+
include Inspectable
|
121
|
+
include OpenMP::Pragma
|
122
|
+
|
123
|
+
def self.inherited(child)
|
124
|
+
child.extend Functor
|
125
|
+
end
|
126
|
+
|
127
|
+
def self.token_string_generator(name, *args)
|
128
|
+
s = <<EOF
|
129
|
+
def #{name}_string(#{args.join(",")})
|
130
|
+
return eval @@strings[get_lang][:#{name}]
|
131
|
+
end
|
132
|
+
EOF
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
class Parallel < ControlStructure
|
138
|
+
|
139
|
+
def initialize(options = {}, &block)
|
140
|
+
@openmp_clauses = options
|
141
|
+
@block = block
|
142
|
+
end
|
143
|
+
@@c_strings = {
|
144
|
+
:parallel => '"#pragma omp parallel #{c}\n{"',
|
145
|
+
:end => '"}"',
|
146
|
+
}
|
147
|
+
|
148
|
+
@@f_strings = {
|
149
|
+
:parallel => '"!$omp parallel #{c}"',
|
150
|
+
:end => '"!$omp end parallel #{c}"',
|
151
|
+
}
|
152
|
+
|
153
|
+
@@strings = {
|
154
|
+
C => @@c_strings,
|
155
|
+
FORTRAN => @@f_strings
|
156
|
+
}
|
157
|
+
|
158
|
+
eval token_string_generator( * %w{parallel c})
|
159
|
+
eval token_string_generator( * %w{end c})
|
160
|
+
|
161
|
+
def to_s
|
162
|
+
return parallel_string(openmp_clauses_to_s)
|
163
|
+
end
|
164
|
+
|
165
|
+
def open
|
166
|
+
output.puts to_s
|
167
|
+
end
|
168
|
+
|
169
|
+
def pr(*args)
|
170
|
+
open
|
171
|
+
if @block then
|
172
|
+
@block.call(*args)
|
173
|
+
close
|
174
|
+
end
|
175
|
+
return self
|
176
|
+
end
|
177
|
+
|
178
|
+
def close
|
179
|
+
output.puts end_string(openmp_end_clauses_to_s)
|
180
|
+
end
|
181
|
+
|
182
|
+
end
|
183
|
+
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
data/lib/BOAST.rb
CHANGED
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: '0.
|
4
|
+
version: '0.99996'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brice Videau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: narray
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- lib/BOAST/If.rb
|
77
77
|
- lib/BOAST/Index.rb
|
78
78
|
- lib/BOAST/Inspectable.rb
|
79
|
+
- lib/BOAST/OpenMP.rb
|
79
80
|
- lib/BOAST/Operators.rb
|
80
81
|
- lib/BOAST/Optimization.rb
|
81
82
|
- lib/BOAST/Parens.rb
|