Skip to content
Snippets Groups Projects
Unverified Commit 09df32fb authored by Carsten Bauer's avatar Carsten Bauer Committed by GitHub
Browse files

Merge pull request #22 from xwuupb/master

parents d465a426 13f45f30
No related branches found
No related tags found
No related merge requests found
Pipeline #33622 passed
......@@ -6,12 +6,12 @@ default_vector_length() = Int(4 * last_cachesize() / sizeof(Float64))
_nthreads_string(nthreads) = avxt() ? "@avxt" : string(nthreads)
function _threadidcs(N, nthreads)
Nperthread = floor(Int, N / nthreads)
rest = rem(N, nthreads)
thread_indices = collect(Iterators.partition(1:N, Nperthread))
if rest != 0
# last thread compensates for the nonzero remainder
thread_indices[end - 1] = (thread_indices[end - 1].start):(thread_indices[end].stop)
Nperthread, rest = divrem(N, nthreads)
thread_indices = Vector{UnitRange{Int64}}(undef, nthreads)
for i in 1:nthreads
thread_indices[i] = i rest ?
(((i - 1) * (Nperthread + 1) + 1):(i * (Nperthread + 1))) :
(((i - 1) * Nperthread + 1 + rest):(i * Nperthread + rest ))
end
return thread_indices
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment