@@ -111,7 +111,7 @@ function process_args(args; inline = false, check_empty = false, u₁ = zero(Int
111
111
end
112
112
inline, check_empty, u₁, u₂, threads
113
113
end
114
- function avx_macro (mod, src, q, args... )
114
+ function spmd_macro (mod, src, q, args... )
115
115
q = macroexpand (mod, q)
116
116
117
117
if q. head === :for
@@ -124,12 +124,12 @@ function avx_macro(mod, src, q, args...)
124
124
end
125
125
end
126
126
"""
127
- @avx
127
+ @spmd
128
128
129
129
Annotate a `for` loop, or a set of nested `for` loops whose bounds are constant across iterations, to optimize the computation. For example:
130
130
131
- function AmulBavx !(C, A, B)
132
- @avx for m ∈ 1:size(A,1), n ∈ 1:size(B,2)
131
+ function AmulB !(C, A, B)
132
+ @spmd for m ∈ 1:size(A,1), n ∈ 1:size(B,2)
133
133
Cₘₙ = zero(eltype(C))
134
134
for k ∈ 1:size(A,2)
135
135
Cₘₙ += A[m,k] * B[k,n]
@@ -148,23 +148,23 @@ julia> using LoopVectorization
148
148
149
149
julia> a = rand(100);
150
150
151
- julia> b = @avx exp.(2 .* a);
151
+ julia> b = @spmd exp.(2 .* a);
152
152
153
153
julia> c = similar(b);
154
154
155
- julia> @avx @. c = exp(2a);
155
+ julia> @spmd @. c = exp(2a);
156
156
157
157
julia> b ≈ c
158
158
true
159
159
```
160
160
161
161
# Extended help
162
162
163
- Advanced users can customize the implementation of the `@avx `-annotated block
163
+ Advanced users can customize the implementation of the `@spmd `-annotated block
164
164
using keyword arguments:
165
165
166
166
```
167
- @avx inline=false unroll=2 body
167
+ @spmd inline=false unroll=2 body
168
168
```
169
169
170
170
where `body` is the code of the block (e.g., `for ... end`).
@@ -197,42 +197,42 @@ but it applies to the loop ordering and unrolling that will be chosen by LoopVec
197
197
`uᵢ=0` (the default) indicates that LoopVectorization should pick its own value,
198
198
and `uᵢ=-1` disables unrolling for the correspond loop.
199
199
200
- The `@avx ` macro also checks the array arguments using `LoopVectorization.check_args` to try and determine
200
+ The `@spmd ` macro also checks the array arguments using `LoopVectorization.check_args` to try and determine
201
201
if they are compatible with the macro. If `check_args` returns false, a fall back loop annotated with `@inbounds`
202
202
and `@fastmath` is generated. Note that `VectorizationBase` provides functions such as `vadd` and `vmul` that will
203
- ignore `@fastmath`, preserving IEEE semantics both within `@avx ` and `@fastmath`.
203
+ ignore `@fastmath`, preserving IEEE semantics both within `@spmd ` and `@fastmath`.
204
204
`check_args` currently returns false for some wrapper types like `LinearAlgebra.UpperTriangular`, requiring you to
205
205
use their `parent`. Triangular loops aren't yet supported.
206
206
"""
207
- macro avx (args... )
208
- avx_macro (__module__, __source__, last (args), Base. front (args)... )
207
+ macro spmd (args... )
208
+ spmd_macro (__module__, __source__, last (args), Base. front (args)... )
209
209
end
210
210
"""
211
- Equivalent to `@avx `, except it adds `thread=true` as the first keyword argument.
211
+ Equivalent to `@spmd `, except it adds `thread=true` as the first keyword argument.
212
212
Note that later arguments take precendence.
213
213
214
- Meant for convenience, as `@avxt ` is shorter than `@avx thread=true`.
214
+ Meant for convenience, as `@spmdt ` is shorter than `@spmd thread=true`.
215
215
"""
216
- macro avxt (args... )
217
- avx_macro (__module__, __source__, last (args), :(thread= true ), Base. front (args)... )
216
+ macro spmdt (args... )
217
+ spmd_macro (__module__, __source__, last (args), :(thread= true ), Base. front (args)... )
218
218
end
219
219
220
220
"""
221
- @_avx
221
+ @_spmd
222
222
223
- This macro transforms loops similarly to [`@avx `](@ref).
224
- While `@avx` punts to a generated function to enable type-based analysis, `_@avx`
225
- works on just the expressions. This requires that it makes a number of default assumptions. Use of `@avx` is preferred .
223
+ This macro mostly exists for debugging/testing purposes. It does not support many of the use cases of [`@spmd `](@ref).
224
+ It emits loops directly, rather than punting to an `@ generated` function, meaning it doesn't have access to type
225
+ information when generating code or analyzing the loops, often leading to bad performance .
226
226
227
- This macro accepts the `inline` and `unroll` keyword arguments like `@avx `, but ignores the `check_empty` argument.
227
+ This macro accepts the `inline` and `unroll` keyword arguments like `@spmd `, but ignores the `check_empty` argument.
228
228
"""
229
- macro _avx (q)
229
+ macro _spmd (q)
230
230
q = macroexpand (__module__, q)
231
231
ls = LoopSet (q, __module__)
232
232
set_hw! (ls)
233
233
esc (Expr (:block , ls. prepreamble, lower_and_split_loops (ls, - 1 )))
234
234
end
235
- macro _avx (arg, q)
235
+ macro _spmd (arg, q)
236
236
@assert q. head === :for
237
237
q = macroexpand (__module__, q)
238
238
inline, check_empty, u₁, u₂ = check_macro_kwarg (arg, false , false , zero (Int8), zero (Int8), 1 )
@@ -241,8 +241,14 @@ macro _avx(arg, q)
241
241
esc (Expr (:block , ls. prepreamble, lower (ls, u₁ % Int, u₂ % Int, - 1 )))
242
242
end
243
243
244
- macro avx_debug (q)
244
+ macro spmd_debug (q)
245
245
q = macroexpand (__module__, q)
246
246
ls = LoopSet (q, __module__)
247
247
esc (LoopVectorization. setup_call_debug (ls))
248
248
end
249
+
250
+ # define aliases
251
+ const var"@avx" = var"@spmd"
252
+ const var"@avxt" = var"@spmdt"
253
+ const var"@avx_debug" = var"@spmd_debug"
254
+
0 commit comments