Skip to content

Commit

Permalink
Merge pull request #120 from ranocha/hr/fix_packages
Browse files Browse the repository at this point in the history
fix multi-threading in packages (issue 119)
  • Loading branch information
chriselrod committed Sep 29, 2023
2 parents f0e3ef3 + 83df393 commit 65f4d75
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 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.7.6"
version = "0.7.7"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
4 changes: 2 additions & 2 deletions src/closure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ function enclose(exorig::Expr, minbatchsize, per::Symbol, threadlocal_tuple, str
end
if stride
# we are to do length(var"##SUBSTART##":var"##SUBSTOP##") iterations
#
#
loop_start_expr =
:(var"##THREAD##" * var"##LOOP_STEP##" + var"##LOOPOFFSET##" - var"##LOOP_STEP##")
loop_stop_expr = :($loopstart + (var"##SUBSTOP##" - var"##SUBSTART##") * var"##STEP##")
Expand Down Expand Up @@ -430,7 +430,7 @@ function enclose(exorig::Expr, minbatchsize, per::Symbol, threadlocal_tuple, str
end
push!(q.args, batchcall)
quote
var"##NUM#THREADS##" = $(Threads.nthreads())
var"##NUM#THREADS##" = $(Threads.nthreads)()
$(stride ? iter_len_def : nothing)
if (
$(
Expand Down
19 changes: 19 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,25 @@ end
end
end

@testset "issue #119" begin
# https://github.com/JuliaSIMD/Polyester.jl/issues/119
function find_call_to_nthreads(expr)
expr isa Expr || return false
if expr.head === :call
if Base.Threads.nthreads in expr.args
return true
end
end
return any(find_call_to_nthreads, expr.args)
end

expr = @macroexpand @batch for i in 1:100
a[i] = i
end

@test find_call_to_nthreads(expr)
end

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

2 comments on commit 65f4d75

@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/92434

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.7.7 -m "<description of version>" 65f4d75c99e612760bffd74973834b0773c35817
git push origin v0.7.7

Please sign in to comment.