Skip to content

Commit dddb465

Browse files
committed
no kwarg and inline
1 parent a34264a commit dddb465

File tree

3 files changed

+35
-18
lines changed

3 files changed

+35
-18
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Polyester"
22
uuid = "f517fe37-dbe3-4b94-8317-1923a5111588"
33
authors = ["Chris Elrod <elrodc@gmail.com> and contributors"]
4-
version = "0.6.10"
4+
version = "0.6.11"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/batch.jl

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@ function add_var!(q, argtup, gcpres, ::Type{T}, argtupname, gcpresname, k) where
110110
end
111111
@generated function _batch_no_reserve(
112112
f!::F,
113+
threadlocal::Val{thread_local},
113114
threadmask_tuple::NTuple{N},
114115
nthread_tuple,
115116
torelease_tuple,
116117
Nr,
117118
Nd,
118119
ulen,
119-
args::Vararg{Any,K};
120-
threadlocal::Val{thread_local} = Val(false),
120+
args::Vararg{Any,K},
121121
) where {F,K,N,thread_local}
122122
q = quote
123123
$(Expr(:meta, :inline))
@@ -282,12 +282,19 @@ end
282282
# q
283283
# end
284284

285+
@inline function batch(
286+
f!::F,
287+
(len, nbatches)::Tuple{Vararg{Integer,2}},
288+
args::Vararg{Any,K}) where {F,K}
289+
290+
batch(f!, Val{false}(), (len, nbatches), args...)
291+
end
285292

286293
@inline function batch(
287294
f!::F,
295+
threadlocal::Val{thread_local},
288296
(len, nbatches)::Tuple{Vararg{Integer,2}},
289-
args::Vararg{Any,K};
290-
threadlocal::Val{thread_local} = Val{false}(),
297+
args::Vararg{Any,K}
291298
) where {F,K,thread_local}
292299
# threads, torelease = request_threads(Base.Threads.threadid(), nbatches - one(nbatches))
293300
len > 0 || return
@@ -310,14 +317,14 @@ end
310317
Nr = ulen - Nd * nbatch
311318
_batch_no_reserve(
312319
f!,
320+
threadlocal,
313321
map(mask, threads),
314322
nthreads,
315323
torelease,
316324
Nr,
317325
Nd,
318326
ulen,
319-
args...;
320-
threadlocal,
327+
args...
321328
)
322329
end
323330
function batch(

src/closure.jl

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -387,21 +387,31 @@ function enclose(
387387
end
388388
end
389389
push!(q.args, esc(closureq))
390-
batchcall = Expr(
391-
:call,
392-
batch,
393-
esc(closure),
394-
threadtup,
395-
Symbol("##LOOPOFFSET##"),
396-
Symbol("##LOOP_STEP##"),
397-
)
390+
batchcall = if threadlocal !== Symbol("")
391+
Expr(
392+
:call,
393+
batch,
394+
esc(closure),
395+
Val(true),
396+
threadtup,
397+
Symbol("##LOOPOFFSET##"),
398+
Symbol("##LOOP_STEP##"),
399+
)
400+
else
401+
Expr(
402+
:call,
403+
batch,
404+
esc(closure),
405+
Val(false),
406+
threadtup,
407+
Symbol("##LOOPOFFSET##"),
408+
Symbol("##LOOP_STEP##"),
409+
)
410+
end
398411
for a arguments
399412
push!(args.args, get(defined, a, a))
400413
push!(batchcall.args, esc(a))
401414
end
402-
if threadlocal !== Symbol("")
403-
push!(batchcall.args, Expr(:kw, :threadlocal, Val(true)))
404-
end
405415
push!(q.args, batchcall)
406416
quote
407417
if $num_threads() == 1

0 commit comments

Comments
 (0)