Skip to content

Commit

Permalink
Merge pull request #60 from Krastanov/master
Browse files Browse the repository at this point in the history
kwargs are now gensym-ed
  • Loading branch information
chriselrod authored Jan 5, 2022
2 parents 3a7ae44 + 3558512 commit 522a634
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Polyester"
uuid = "f517fe37-dbe3-4b94-8317-1923a5111588"
authors = ["Chris Elrod <[email protected]> and contributors"]
version = "0.6.0"
version = "0.6.1"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

Polyester.jl provides low overhead threading.
The primary API is `@batch`, which can be used in place of `Threads.@threads`.
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()`.
Lets look at a simple benchmark.
```julia
using Polyester, LinearAlgebra, BenchmarkHistograms
Expand All @@ -18,7 +19,7 @@ function axpy_serial!(y, a, x)
y[i] = muladd(a, x[i], y[i])
end
end
# One thread per core, the default
# One thread per core, the default (the threads are not pinned)
function axpy_per_core!(y, a, x)
@batch per=core for i in eachindex(y,x)
y[i] = muladd(a, x[i], y[i])
Expand Down
4 changes: 4 additions & 0 deletions src/closure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ function extractargs!(arguments::Vector{Symbol}, defined::Dict{Symbol,Symbol}, e
end
end
elseif head === :kw
args[2] = getgensym!(defined, args[2])
return
end
for i startind:length(args)
Expand Down Expand Up @@ -388,6 +389,9 @@ LoopVectorization.jl currently only uses up to 1 thread per physical core. Becau
is some overhead to switching the number of threads used, `per=core` is `@batch`'s default,
so that `Polyester.@batch` and `LoopVectorization.@tturbo` work well together by default.
Threads are not pinned to a given CPU core and the total number of available threads is
still governed by `--threads` or `JULIA_NUM_THREADS`.
You can pass both `per=(core/thread)` and `minbatch=N` options at the same time, e.g.
@batch per=thread minbatch=2000 for i in Iter; ...; end
Expand Down
10 changes: 10 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,16 @@ end
@test allocated(f) < 300 + 40*Threads.nthreads()
end

@testset "gensym" begin
# issue 59 (lack of gensym for keyword arguments)
function f(; kw=10) kw end
buf = [0,0]
@batch for i in 1:2
buf[i] = f(; kw=i)
end
@test buf==[1,2]
end

if VERSION v"1.6"
println("Package tests complete. Running `Aqua` checks.")
Aqua.test_all(Polyester)
Expand Down

2 comments on commit 522a634

@chriselrod
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/51748

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.1 -m "<description of version>" 522a634445d42a9bb9d49ff242bbe8bfd6b30a7c
git push origin v0.6.1

Please sign in to comment.