1
1
# S is a Val{Bool} indicating whether we will need to load the thread index
2
2
# C is a Tuple{...} containing the types of the reduction variables
3
3
struct BatchClosure{F,A,S,C}
4
- f:: F
4
+ f:: F
5
5
end
6
6
function (b:: BatchClosure{F,A,S,C} )(p:: Ptr{UInt} ) where {F,A,S,C}
7
7
(offset, args) = ThreadingUtilities. load (p, A, 2 * sizeof (UInt))
130
130
start,
131
131
stop,
132
132
i,
133
- reductup
133
+ reductup,
134
134
) do p, fptr, argtup, start, stop, i, reductup
135
135
setup_batch! (p, fptr, argtup, start, stop, i, reductup)
136
136
end
185
185
# nthread_total = sum(nthread_tuple)
186
186
Ndp = Nd + one (Nd)
187
187
end
188
- C != = 0 && push! (
189
- q. args,
190
- quote
191
- @nexprs $ C j -> RVAR_j = reducinits[j]
192
- end
193
- )
188
+ C != = 0 && push! (q. args, quote
189
+ @nexprs $ C j -> RVAR_j = reducinits[j]
190
+ end )
194
191
launch_quote = if S
195
192
if C === 0
196
193
:(launch_batched_thread! (cfunc, tid, argtup, start, stop, tid % UInt))
@@ -211,27 +208,23 @@ end
211
208
if C != = 0
212
209
push! (
213
210
rem_quote. args,
214
- :(@nexprs $ C j -> RVAR_j = reducops[j](RVAR_j, thread_results[j]))
211
+ :(@nexprs $ C j -> RVAR_j = reducops[j](RVAR_j, thread_results[j])),
215
212
)
216
213
end
217
214
update_retv = if C === 0
218
- Expr (:block )
215
+ Expr (:block )
219
216
else
220
217
quote
221
218
thread_results = load_threadlocals (tid, argtup, needtid, reducinits)
222
219
@nexprs $ C j -> RVAR_j = reducops[j](RVAR_j, thread_results[j])
223
220
end
224
221
end
225
222
ret_quote = Expr (:return )
226
- if C === 0
227
- push! (ret_quote. args, nothing )
228
- else
229
- redtup = Expr (:tuple )
230
- for j in 1 : C
231
- push! (redtup. args, Symbol (" RVAR_" , j))
232
- end
233
- push! (ret_quote. args, redtup)
223
+ redtup = Expr (:tuple )
224
+ for j ∈ 1 : C
225
+ push! (redtup. args, Symbol (" RVAR_" , j))
234
226
end
227
+ push! (ret_quote. args, redtup)
235
228
236
229
block = quote
237
230
start = zero (UInt)
@@ -321,16 +314,16 @@ end
321
314
@label SERIAL
322
315
if S
323
316
if C === 0
324
- reducres = f! (args, one (Int), ulen % Int, 1 )
325
- return reducres
317
+ f! (args, one (Int), ulen % Int, 1 )
318
+ return ()
326
319
else
327
320
reducres = f! (args, one (Int), ulen % Int, 1 , reducinits)
328
321
return reducres
329
322
end
330
323
else
331
324
if C === 0
332
- reducres = f! (args, one (Int), ulen % Int)
333
- return reducres
325
+ f! (args, one (Int), ulen % Int)
326
+ return ()
334
327
else
335
328
reducres = f! (args, one (Int), ulen % Int, reducinits)
336
329
return reducres
0 commit comments