The ... in this case includes a loop that performs simple operations corresponding to math factorizations and that can go up to i iterations, so for every iteration of the outer loop, the loop of the factorization has increased work.
In literal code its:
factor = 2
done = i
while (factor < done)
if i % factor == 0
sum += factor + div(i, factor)
done = div(i, factor)
if done == factor
sum -= factor
end
end
factor += 1
end
I ran few more tests to check what I could relate to your answer and I noticed that thread 1 would always have the higher number of tasks. Based on what you said, could I say that the first iterations aren’t time consuming enough so the Julia scheduler re-uses the master thread? Does the Julia scheduler have higher priority in distributing the tasks than the implementation of the ThreadedEx?
These are some of the distribution of tasks that I got:
-
50k iterations and 4 threads:
- 18751
- 12500
- 12500
- 6250
-
350k iterations and 4 threads:
- 131251
- 87500
- 87500
- 43750