Is there a widely used multiprocessing abstraction library available for C ++?

I come from Python and head for C ++ with a full throttle. And one of the questions that I recently came up with is the following: is there a widely used open source abstraction library for multiprocessing in C ++? I am thinking of something that makes ala fork a little easier to manage, similar to the Python multiprocessing stdlib library .

I think there is nothing like it. I fully expected Boost :: Process to be there, as Boost :: Thread is .

+4
source share
5 answers

OpenMP (Open Multi-Processing) is the only library I know http://en.wikipedia.org/wiki/OpenMP - it does not, however, process things like this Python does by creating new processes. OpenMP is a compiler extension supported by Microsoft and the GNU GCC .

Example: OpenMP Lattice for Eratosthenes

// odd-only sieve int eratosthenesOdd(int lastNumber, bool useOpenMP) { // enable/disable OpenMP omp_set_num_threads(useOpenMP ? omp_get_num_procs() : 1); // instead of i*i <= lastNumber we write i <= lastNumberSquareRoot to help OpenMP const int lastNumberSqrt = (int)sqrt((double)lastNumber); int memorySize = (lastNumber-1)/2; // initialize char* isPrime = new char[memorySize+1]; #pragma omp parallel for for (int i = 0; i <= memorySize; i++) isPrime[i] = 1; // find all odd non-primes #pragma omp parallel for schedule(dynamic) for (int i = 3; i <= lastNumberSqrt; i += 2) if (isPrime[i/2]) for (int j = i*i; j <= lastNumber; j += 2*i) isPrime[j/2] = 0; // sieve is complete, count primes int found = lastNumber >= 2 ? 1 : 0; #pragma omp parallel for reduction(+:found) for (int i = 1; i <= memorySize; i++) found += isPrime[i]; delete[] isPrime; return found; } 
-1
source

Will MPI match? I think its easy enough to program as soon as you understand it. And this is really a multiprocess

+1
source

Intel TBB and Microsoft PPL are two multi-threaded library tasks.

0
source

I look at the POCO library, which has a section on multiprocessing.
I also consider fork () , which also has a small implementation for Windows.

0
source

Take a look at http://pocoproject.org/ (Process :: launch ()) and http://www.highscore.de/boost/process/ . I would go for the second if I had to choose, but both of them are actually quite far from convenience. Python offers (sigh).

0
source

All Articles