I have some workload and want to work on it using all threads. If I do
Threads.@threads for _ in 1:nthreads()
# doit
end
Is it guaranteed, that all threads are used, or could it be that one thread occurs multiple times?
For instance does the following always hold:
using Base.Threads: threadid, nthreads, @threads
ret = fill(-1, Threads.nthreads())
@threads for _ in 1:nthreads()
ret[threadid()] = threadid()
end
@test ret == 1:nthreads()