Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong number of parallel threads when number of elements is relatively small compared to degree of parallelism #7

Open
awalland opened this issue Oct 10, 2012 · 1 comment

Comments

@awalland
Copy link

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.

@petr-tichy
Copy link

see #11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants