Skip to main content
SciNet
  • Home
  • All Courses
  • Calendar
  • Certificates
  • SciNet
    Main Site Documentation my.SciNet
  • CCDB
  • More
Close
Toggle search input
English
English Français
You are currently using guest access
Log in
SciNet
Home All Courses Calendar Certificates SciNet Collapse Expand
Main Site Documentation my.SciNet
CCDB
Expand all Collapse all
  1. PHY1610 - Winter 2026
  2. 10. MPI factorizing numbers

10. MPI factorizing numbers

Completion requirements
Opened: Monday, 6 April 2026, 12:00 AM
Due: Monday, 13 April 2026, 12:00 PM

For this assignment, clone the following code on the Teach cluster:

$ git clone /home/l/lcl_uotphy1610/lcl_uotphy1610s1466/mpifactor

This 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.



You are currently using guest access (Log in)
Data retention summary


All content on this website is made available under the Creative Commons Attribution 4.0 International licence, with the exception of all videos which are released under the Creative Commons Attribution-NoDerivatives 4.0 International licence.
Powered by Moodle