Write a multi-threaded C/C++ program for finding all the prime numbers that are ≤ a given positive integer n using the Sieve of Eratosthenes method, based on a data-parallel model as described in the design as below. Suppose the executable is named sieve, the following command executes the program to find all primes up to 10000 using 4 parallel threads.
sieve 10000 4
Design
Create as many threads as requested in the commandline. Each thread gets an equal partition (equal to the extent possible) of the integer list, and continue with the following loop up to the last prime that is ≤ L n _|. Then the sublists are gathered and all primes are output.
repeat
get the next prime p
strike out all multiples of p in the range of the partition
until done