prime_mpi a C++ code which counts the number of primes between 1 and N, using the Message Passing Interface (MPI) to carry out the calculation in parallel.
The algorithm is completely naive. For each integer I, it simply checks whether any smaller J evenly divides it. The total amount of work for a given N is thus roughly proportional to 1/2*N^2.
This program is mainly a starting point for investigations into parallelization.
The latest versions of MPI no longer support the special C++ MPI bindings, so the examples given here have reverted to using the C MPI bindings.
The information on this web page is distributed under the MIT license.
prime_mpi is available in a C version and a C++ version and a Fortran90 version and a Python version.
mpi_test, a C++ code which uses the message passing interface (MPI) for parallel computations in a distributed memory environment.
prime_openmp, a C++ code which counts the number of primes between 1 and N, using OpenMP for parallel execution.
prime, a C++ code which counts the number of primes between 1 and N, intended as a starting point for the creation of a parallel version.