10. MPI factorizing numbers
For this assignment, clone the following code on the Teach cluster:
$ git clone /home/l/lcl_uotphy1610/lcl_uotphy1610s1466/mpifactorThis is an MPI controller/worker (master/slave) program to factorize all integers from 1 up to MAXN in parallel
- One process is the controller
- All others are workers
- Work is distributed dynamically
The function "factorize" uses trial division to compute the prime factorization of n, and returns [p1, p2, ..., pk, n] where: p1...pk are prime factors, and n is appended at the end.
The program is incomplete it is your task to write the following functions:
void send_number(long long number, int to_rank);
long long receive_number(int from_rank);
void send_vector(rvector<long long>& x, int to_rank);
rvector<long long> receive_vector(int& from_rank);
Prototypes and documenting comments of these are already in the code.
As usual, you should use git and comments.
You should run your code with "make run" for testing. This actually runs
mpirun -np 4 ./mpifactor -v 20
The "20" is the maximum number to factor, and "-v" adds verbose messages to the output.
To measure the speedup, run the code as follows in an slurm job script that requests 2 nodes (for a total of 80 cores):
time mpirun -np N ./mpifactor 60000 > factorsN.txt
for N=2,8,20,40 and 80.
Add the job script and its timing output to your repo (not the factorsN.txt files!). Submit your repo for the assignment by Monday April 13, at 12 noon. The usual late penalty applies.