Skip to content

Commit ded74ba

Browse files
committed
Fix a problem in #483
1 parent 1421459 commit ded74ba

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LoopVectorization"
22
uuid = "bdcacae8-1622-11e9-2a5c-532679323890"
33
authors = ["Chris Elrod <[email protected]>"]
4-
version = "0.12.155"
4+
version = "0.12.156"
55

66
[weakdeps]
77
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"

src/codegen/lower_threads.jl

+7-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,13 @@ function push_loop_length_expr!(q::Expr, ls::LoopSet)
196196
if length(ls.loops) == 1
197197
ndynamic == 0 && push!(q.args, l)
198198
elseif l == 1
199-
push!(q.args, mulexpr)
199+
if ndynamic == 1
200+
push!(q.args, last(mulexpr.args))
201+
elseif ndynamic == 0
202+
push!(q.args, l)
203+
else
204+
push!(q.args, mulexpr)
205+
end
200206
elseif ndynamic == 0
201207
push!(q.args, l)
202208
elseif ndynamic == 1

test/threading.jl

+9
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,13 @@ end
172172
thread_cartesian_indices!(dst, src)
173173
dst src
174174

175+
let a = zeros(3, 2), N = 2
176+
@turbo thread = true for i = 1:1, j = 1:N
177+
a[i, j] += 1.0
178+
end
179+
@test all(isone, @view(a[1, :]))
180+
@test all(iszero, @view(a[2:end, :]))
181+
end
182+
183+
175184
end

0 commit comments

Comments
 (0)