peach
peach copied to clipboard
wrong number of parallel threads when number of elements is relatively small compared to degree of parallelism
hi!
thanks a lot for peach, i think it's a great way to parallelize things, but there's a bug when the number of elements to be looped is less than 2*threads:
#!/usr/bin/env ruby
require 'peach'
@max_threads=10
@elements=19
exports = Array.new
puts "start"
$i = 0;
$num = @elements;
while $i < $num do
exports.push($i)
$i +=1;
end
puts "array initialized"
def do_export(num)
print " |export #{num} "
%x(sleep 5)
end
puts "max_threads: #{@max_threads}"
exports.peach(@max_threads) do |export|
do_export(export)
end
this code will execute 19 threads instead of 10.
see #11