Skip to content

Commit 522a634

Browse files
authored
Merge pull request #60 from Krastanov/master
kwargs are now gensym-ed
2 parents 3a7ae44 + 3558512 commit 522a634

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
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.0"
4+
version = "0.6.1"
55

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

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
Polyester.jl provides low overhead threading.
1111
The primary API is `@batch`, which can be used in place of `Threads.@threads`.
12+
The number of available threads is still governed by [`--threads` or `JULIA_NUM_THREADS`](https://docs.julialang.org/en/v1.6/manual/multi-threading/#Starting-Julia-with-multiple-threads), as reported by `Threads.nthreads()`.
1213
Lets look at a simple benchmark.
1314
```julia
1415
using Polyester, LinearAlgebra, BenchmarkHistograms
@@ -18,7 +19,7 @@ function axpy_serial!(y, a, x)
1819
y[i] = muladd(a, x[i], y[i])
1920
end
2021
end
21-
# One thread per core, the default
22+
# One thread per core, the default (the threads are not pinned)
2223
function axpy_per_core!(y, a, x)
2324
@batch per=core for i in eachindex(y,x)
2425
y[i] = muladd(a, x[i], y[i])

src/closure.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ function extractargs!(arguments::Vector{Symbol}, defined::Dict{Symbol,Symbol}, e
106106
end
107107
end
108108
elseif head === :kw
109+
args[2] = getgensym!(defined, args[2])
109110
return
110111
end
111112
for i startind:length(args)
@@ -388,6 +389,9 @@ LoopVectorization.jl currently only uses up to 1 thread per physical core. Becau
388389
is some overhead to switching the number of threads used, `per=core` is `@batch`'s default,
389390
so that `Polyester.@batch` and `LoopVectorization.@tturbo` work well together by default.
390391
392+
Threads are not pinned to a given CPU core and the total number of available threads is
393+
still governed by `--threads` or `JULIA_NUM_THREADS`.
394+
391395
You can pass both `per=(core/thread)` and `minbatch=N` options at the same time, e.g.
392396
393397
@batch per=thread minbatch=2000 for i in Iter; ...; end

test/runtests.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,16 @@ end
345345
@test allocated(f) < 300 + 40*Threads.nthreads()
346346
end
347347

348+
@testset "gensym" begin
349+
# issue 59 (lack of gensym for keyword arguments)
350+
function f(; kw=10) kw end
351+
buf = [0,0]
352+
@batch for i in 1:2
353+
buf[i] = f(; kw=i)
354+
end
355+
@test buf==[1,2]
356+
end
357+
348358
if VERSION v"1.6"
349359
println("Package tests complete. Running `Aqua` checks.")
350360
Aqua.test_all(Polyester)

0 commit comments

Comments
 (0)