JuliaLang/julia — pull request #3339 by c42f (2013-06-10 07:04:13+00:00)
Title: RFC: Improve static load balancing in @parallel

This patch ensures that static load balancing is as good as possible: each
worker process gets either M or M+1 elements of the input range. Previously
the remainder of the work would all go to the last process, which increases
the wall time by up to a factor of two.

Also fix a bug in preduce() which could cause a bounds exception when the
length of the input range was smaller than the number of workers. It's not
clear to me that this is actually a bug in the code, or a bug in the way that
bounds checking for ranges works. In particular the following seem to be
inconsistent:

julia> (1:10)[11:10]
ERROR: BoundsError()
in getindex at range.jl:111

vs

julia> ([1:10])[11:10]
0-element Int64 Array