代写 C MPI scala parallel compiler Comp3036J Parallel and Cluster Computing

Comp3036J Parallel and Cluster Computing
Module Title: Assignment Type: Project Title:
Project Date: Assignment Compiler: Weighting:
Parallel and Cluster Computing
MPI Program Assignment 1 08/04/2018
Dr. Brett Becker 30%
Monday, April 22, 2018, 23:59 Beijing Time
One .c file, submitted to moodle AND left on beckett3 as described
Using your experience from Tutorial 2 (MPI Badminton), the lecture notes, and the recommended texts, write an MPI Program that does the following:
1. The root process reads the file Array.csv into an array of integers. Array.csv is on beckett3 at /tmp/assign1/Array.csv and contains 10,000 integers separated by commas.
2. The root process only should calculate and print the following:
a. Calculate the sum of all integers
b. Calculate the mode of all integers
c. Calculate the frequency of the mode
d. Calculate the dot product of the first 5,000 integers and the second 5,000 integers. If we call the first 5,000 A, and the second 5,000 B, the dot product is A[0] * B[0] + A[1] * B[1] + …
3. The root process will then need to communicate the appropriate data to the other processes using some collective communications to complete a, b, c and d above, in parallel, using all tasks available to do calculations (including the root process). You will also need some communications to finish the calculations. The calculations themselves should be done in separate functions. So, you should have four functions (sum, mode, freq_mode, dot_prod).
4. The result of the parallel calculations of a, b, c, and d above should be printed.
5. Your program should work with 2 and 3 processes.
i. If your program is run with 1, or 4+ processes, it should be terminated immediately.
ii. As 10,000 doesn’t evenly divide by three, you’ll have to figure out what to do for three processes! There are good, and not so good ways to do this. The best solutions would work for more than three processes (e.g. 5).
Due Date:
Method of Submission:
below. The date of the file on beckett3 must be on or before the above. Do not change your file after this. I suggest you don’t touch it!
Task:

6. So, your program, each time it runs, should print the results twice – once calculated sequentially by the root, and once for the parallel calculations. Obviously the calculations should be the same!
Additional Requirements and Information:
1. Your code should be well commented:
a. Assume that someone reading your code knows C but DOES NOT know MPI. Aim to
have them understand the MPI with your comments. These comments may be a
little longer than ‘normal’ comments – this is ok.
b. Point out with comments where you have used communications (collective or
otherwise, and what those communications do.
2. Your code should be flexible, scalable, elegant. For example: collective communications
should be favoured over point-to-point, if I decided to have you run your code with 11 processes, would it work?
Deliverables
1) One well commented .c MPI file named “A1_.c”, where is your UCD student number. Example: A1_12345678.c, uploaded to moodle.
2) Your .c file should also be left on beckett3 in the following directory:
a) /home//assignment_1/ where is your username. Example:
/home/s12345678/assignment_1/A1_12345678.c
b) These should be the same!
c) These files should be named exactly as above. You are fourth year students. Read these
instructions carefully. I will deduct marks for not following instructions.
Marking
Your code will be marked by the following criteria:
1. Correctness of code and code meeting all specified requirements (including number of
processes, correct calculations, and dealing with the issue of 3 processes, but see all
requirements above).
2. Comments explaining MPI calls including explaining strategy to use appropriate
communications.
3. Elegance of solution: you should aim to have concise, clear code, avoiding unnecessary code.