Skip to content

Commit c1ab1d3

Browse files
committed
Add max num threads checks for lowering fewer threaded loops
1 parent fb214dc commit c1ab1d3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/codegen/lower_threads.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -617,11 +617,11 @@ function avx_threads_expr(
617617
num_candiates = sum(valid_thread_loop)
618618
# num_to_thread = min(num_candiates, 2)
619619
# candidate_ids =
620-
if num_candiates == 0 # it was called from `avx_body` but now `nt` was set to `1`
620+
if (num_candiates == 0) || (nt 1) # it was called from `avx_body` but now `nt` was set to `1`
621621
avx_body(ls, UNROLL)
622-
elseif num_candiates == 1
622+
elseif (num_candiates == 1) || (nt 3)
623623
thread_one_loops_expr(ls, ua, valid_thread_loop, nt, c, UNROLL, OPS, ARF, AM, LPSYM)
624-
else
624+
else # requires at least 4 threads
625625
thread_two_loops_expr(ls, ua, valid_thread_loop, nt, c, UNROLL, OPS, ARF, AM, LPSYM)
626626
end
627627
end

0 commit comments

Comments
 (0)