Skip to content

Commit a04f060

Browse files
committed
workaround for #353 (disable threading in case of CartesianIndex-ing)
1 parent fab052e commit a04f060

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/reconstruct_loopset.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ Execute an `@turbo` block. The block's code is represented via the arguments:
718718
pushfirst!(ls.preamble.args, :(var"#lv#tuple#args#" = reassemble_tuple(Tuple{var"#LB#",var"#V#"}, var"#flattened#var#arguments#")))
719719
post = hoist_constant_memory_accesses!(ls)
720720
# return @show avx_body(ls, var"#UNROLL#")
721-
q = if last(var"#UNROLL#") > 1
721+
q = if (last(var"#UNROLL#") > 1) && length(var"#LPSYM#") == length(ls.loops)
722722
inline, u₁, u₂, v, isbroadcast, W, rs, rc, cls, l1, l2, l3, nt = var"#UNROLL#"
723723
# wrap in `var"#OPS#", var"#ARF#", var"#AM#", var"#LPSYM#"` in `Expr` to homogenize types
724724
avx_threads_expr(

test/threading.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ function convlayer_direct!(
102102
out
103103
end
104104

105+
function thread_cartesian_indices!(dst, src)
106+
@turbo thread=true for i in eachindex(dst, src)
107+
dst[i] = src[i]
108+
end
109+
end
110+
111+
112+
105113
@testset "Threading" begin
106114
@show @__LINE__
107115
dcd = DenseConvDims{2,(5,5),3,6}()
@@ -139,6 +147,10 @@ end
139147
out2 = similar(out1);
140148
@test conv!(out1, A, kern) conv_baseline!(out2, A, kern)
141149
end
150+
151+
src_big = rand(4, 10); dst_big = similar(src_big); src = view(src_big, 2:3, :); dst = view(dst_big, 2:3, :);
152+
thread_cartesian_indices!(dst, src); dst src
153+
142154
end
143155

144156

0 commit comments

Comments
 (0)