Skip to content

Commit

Permalink
Fix a problem in #483
Browse files Browse the repository at this point in the history
  • Loading branch information
chriselrod committed Apr 5, 2023
1 parent 1421459 commit ded74ba
Show file tree
Hide file tree
Showing 3 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 = "LoopVectorization"
uuid = "bdcacae8-1622-11e9-2a5c-532679323890"
authors = ["Chris Elrod <[email protected]>"]
version = "0.12.155"
version = "0.12.156"

[weakdeps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand Down
8 changes: 7 additions & 1 deletion src/codegen/lower_threads.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,13 @@ function push_loop_length_expr!(q::Expr, ls::LoopSet)
if length(ls.loops) == 1
ndynamic == 0 && push!(q.args, l)
elseif l == 1
push!(q.args, mulexpr)
if ndynamic == 1
push!(q.args, last(mulexpr.args))
elseif ndynamic == 0
push!(q.args, l)
else
push!(q.args, mulexpr)
end
elseif ndynamic == 0
push!(q.args, l)
elseif ndynamic == 1
Expand Down
9 changes: 9 additions & 0 deletions test/threading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,13 @@ end
thread_cartesian_indices!(dst, src)
dst src

let a = zeros(3, 2), N = 2
@turbo thread = true for i = 1:1, j = 1:N
a[i, j] += 1.0
end
@test all(isone, @view(a[1, :]))
@test all(iszero, @view(a[2:end, :]))
end


end

2 comments on commit ded74ba

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

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.12.156 -m "<description of version>" ded74ba4229c5bdb286057204aa50a8c8895f472
git push origin v0.12.156

Please sign in to comment.