Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

Commit

Permalink
Merge ffd42d1 into 5bf384b
Browse files Browse the repository at this point in the history
  • Loading branch information
Roger-luo committed Jul 2, 2020
2 parents 5bf384b + ffd42d1 commit 1f4855e
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/instruct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,13 @@ const THREAD_THRESHOLD = 10

# generates the threading expression
macro threads(ex)
if Threads.nthreads() == 1 # do nothing in single threading mode
return esc(:(@inbounds $ex))
else
return esc(quote
if log2dim1(state) < THREAD_THRESHOLD
@inbounds $ex
else
@inbounds Threads.@threads $ex
end
end)
end
esc(quote
if (Threads.nthreads() == 1) || log2dim1(state) < $THREAD_THRESHOLD
@inbounds $ex
else
@inbounds Threads.@threads $ex
end
end)
end

# to avoid potential ambiguity, we limit them to tuple for now
Expand Down Expand Up @@ -209,8 +205,7 @@ function YaoBase.instruct!(
b, c = U1.vals
step = 1 << (loc - 1)
step_2 = 1 << loc
if log2dim1(state) < THREAD_THRESHOLD
end

@threads for j = 0:step_2:size(state, 1)-step
@inbounds for i = j+1:j+step
swaprows!(state, i, i + step, c, b)
Expand Down

0 comments on commit 1f4855e

Please sign in to comment.