If the numbers are big enough for you to bother parallelizing it, the synchronization cost probably doesn't matter.
This comment was marked helpful 0 times.
LeeK
@jpaulson What do you mean by the numbers are big enough? If a serial program is parallelized to use 4 cores, but your program ends up spending half its time synchronizing, then the cost might be significant and it might be worth doing something about it like what is mentioned in the next slide.
This comment was marked helpful 0 times.
bscohen
It was not specifically brought up, but one other problem I imagined that might occur with a work queue is that the hardest piece of work is removed from the queue last - then every other worker sits idle while the one worker tackles the large problem.
It would've been more desirable to start the hard work up front, and then knock out the "easy" work in the mean time
This comment was marked helpful 0 times.
martin
serialization in this program is the ratio of the sum of the black regions and the sum of the blue region.
This comment was marked helpful 0 times.
pebbled
@LeeK What jpaulson is pointing out is that the larger the potential primes are, the greater the proportion of time the threads spend in is_prime (since the runtime of is_prime is logarithmic at best)
If the numbers are big enough for you to bother parallelizing it, the synchronization cost probably doesn't matter.
This comment was marked helpful 0 times.
@jpaulson What do you mean by the numbers are big enough? If a serial program is parallelized to use 4 cores, but your program ends up spending half its time synchronizing, then the cost might be significant and it might be worth doing something about it like what is mentioned in the next slide.
This comment was marked helpful 0 times.
It was not specifically brought up, but one other problem I imagined that might occur with a work queue is that the hardest piece of work is removed from the queue last - then every other worker sits idle while the one worker tackles the large problem.
It would've been more desirable to start the hard work up front, and then knock out the "easy" work in the mean time
This comment was marked helpful 0 times.
serialization in this program is the ratio of the sum of the black regions and the sum of the blue region.
This comment was marked helpful 0 times.
@LeeK What jpaulson is pointing out is that the larger the potential primes are, the greater the proportion of time the threads spend in is_prime (since the runtime of is_prime is logarithmic at best)
This comment was marked helpful 0 times.