PRIME_NUMBER_PARALLEL is a MATLAB program which counts the number of primes between 1 and N.
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.
There is very little memory traffic and no communication, so this program is a good test for the pure computational speedup offered by MATLAB's Parallel Programming Toolbox.
On a single computer, using the MATLAB Parallel Toolbox, the following results were observed for the elapsed time using 1 client and 0, 1, 2 and 4 "labs" or "workers":
N | 1+0 | 1+1 | 1+2 | 1+4 |
---|---|---|---|---|
50 | 0.067 | 0.179 | 0.176 | 0.278 |
500 | 0.008 | 0.023 | 0.027 | 0.032 |
5,000 | 0.100 | 0.142 | 0.097 | 0.061 |
50,000 | 7.694 | 9.811 | 5.251 | 2.719 |
500,000 | 609.764 | 826.534 | 432.233 | 222.284 |
On the Ithaca cluster with the MATLAB Parallel Toolbox version 4.1, running with the "ithaca" configuration across multiple nodes, the following results were observed:
N | 1+8 | 1+16 | 1+32 | 1+64 |
---|---|---|---|---|
5 | 0.377 | 0.357 | 0.360 | 0.412 |
50 | 0.221 | 0.433 | 0.430 | 0.504 |
500 | 0.056 | 0.121 | 0.199 | 0.416 |
5,000 | 0.058 | 0.087 | 0.215 | 0.428 |
50,000 | 1.080 | 0.564 | 0.326 | 0.357 |
500,000 | 81.649 | 39.987 | 19.237 | 9.808 |
The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.
BIRTHDAY_REMOTE, a MATLAB program which runs a Monte Carlo simulation of the birthday paradox, and includes instructions on how to run the job, via MATLAB's BATCH facility, on a remote system such as Virginia Tech's ITHACA cluster.
COLLATZ_PARALLEL is a MATLAB program which seeks the maximum Collatz sequence between 1 and N; it runs in parallel using MATLAB's "parfor" facility.
FDI_OPT, a MATLAB program which demonstrates the use of MATLAB's FMINCON constrained minimization function, taking advantage of MATLAB's Parallel Computing Toolbox for faster execution.
JTB_CODIST, a MATLAB program which demonstrates how the linear system associated with a finite element problem can be treated as a codistributed array whose entries are assigned to different MATLAB workers, so that the matrix is assembled in parallel.
LINEAR_SOLVE_DISTRIBUTED is a MATLAB program which solves a linear system A*x=b using MATLAB's spmd facility, so that the matrix A is "distributed" across multiple MATLAB workers.
MATLAB_PARALLEL, examples which illustrate "local" parallel programming on a single computer with MATLAB's Parallel Computing Toolbox.
MD_PARALLEL is a MATLAB program which carries out a molecular dynamics simulation in parallel, using MATLAB's "PARFOR" feature.
PRIME_NUMBER is a MATLAB program which counts the number of primes between 1 and N.
PRIME_NUMBER_OPEN_MP is a C program which counts the number of primes between 1 and N, using OpenMP for parallel execution.
PRIME_NUMBER_SPMD is a MATLAB program which counts the number of primes between 1 and N; running in parallel using MATLAB's "SPMD" feature.
QUAD_SPMD is a MATLAB program which estimates an integral using quadrature; running in parallel using MATLAB's "SPMD" feature.
SATISFIABILITY_PARALLEL is a MATLAB program which demonstrates, for a particular circuit, an exhaustive search for solutions of the circuit satisfiability problem, running in parallel using MATLAB's "PARFOR" feature.
TIMING_PARALLEL is a directory of MATLAB programs which illustrates how to time a parallel MATLAB program.
MathWorks documentation for the Parallel Computing Toolbox is available at http://www.mathworks.com/products/parallel-computing/.
You can go up one level to the MATLAB source codes.