开发者

Sieve of Eratosthenes by Data parallel method

开发者 https://www.devze.com 2023-01-17 21:01 出处:网络
I am trying to implement the Sieve of Eratosthenes problem by data parallel method using pthreads, but I am not able to figure out how does thread-1 on finding \"2\" is a prime number broadcast that t

I am trying to implement the Sieve of Eratosthenes problem by data parallel method using pthreads, but I am not able to figure out how does thread-1 on finding "2" is a prime number broadcast that to all the other threads and when all the other thre开发者_运维知识库ads mark multiples of 2 they should wait again for the next prime. How will the multiple wait for the threads be implemented?


Before looking at the actual program constructs, you first need to get your algorithm right. I think you have a problem finding a function here because you do not have a proper algorithm for a parallel sieve.

For starters, a key criterium in parallel algorithms is the distribution of work across threads. If all threads did precisely the same, there would be no speedup at all. But it's entirely unclear here what the work distribution is.

I am not even certain that your threads should be waiting. That's inefficient; the best designs are those where all threads are performing work at all times.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号