COMP528-JAN21 University of Liverpool
COMP528-JAN21 – Lab 5
Coordinator: Fabio Papacchini
Message Passing Interface (MPI) #3
The contents of the labs may be useful in assignments and written assessments.
Login to Barkla and obtain today’s lab file/s:
cd
tar -xzf /users/papacchf/COMP528-JAN21/labs/lab05.tgz
cd intro-mpi-collectives
If you now list the directory (using “ls”) you should see:
chkPrime.c prime-bcast-gather-skeleton.c prime-serial.c prime-scatter-gather-skeleton.c
Note that question 1 was originally question 4 from MPI#2 labs (previous lab). The remaining questions
are for you to try different MPI implementations to undertake the same logic. As an outline, the “prime”
code is parallelised in each case by dividing up the full range of numbers to search so that each MPI process
has a subset to search, so that there will be some speed-up (but non-ideal due to load imbalance since each MPI
process may find a different number of primes in its subset). After each process has completed its search, the
number of primes found is sent to the root process which sums to output the total number of primes found,
and each process outputs the primes it found.
All code should be compiled in batch, with zero optimisation. You should focus on getting correct and
working code in each case. If you have time, you should then apply good practice of running each compiled
code a number of times on the compute nodes, using the quickest time for each set of runs. You should plot
on a single graph the time for each implementation as a function of number of cores, and repeat for input
sizes 1000, 5000, 10000 and 20000 and be able to clearly explain your findings.
You are encouraged to follow all the steps in this document. You can email me your solutions
(please write “COMP528 Lab5” in the subject), and I will provide you with feedback on them.
1 “Finding Primes” Example illustrating some MPI Broadcast
1. The code in “prime-serial.c” should be fairly clear. It reads in a number and then returns how many
prime numbers from 1 to that number and lists the prime numbers. Run this and test the output.
2. The skeleton code in “prime-bcast-gather-skeleton.c” is for you to complete such that it uses MPI
to share out the work finding the prime numbers. You will need to
(a) Work out why we have several “MPI Bcast” calls and what each is doing.
(b) Amend the “i” for loop from i=1 to i