辅导program、辅导Java/c++编程
- 首页 >> Algorithm 算法 Parallel and Cluster Computing TASK
Method of Submission: Moodle (.pdf and .c file) and beckett4 (.c file)
Please place solution.c in your home directory on beckett4 in a folder called assignment_1 so that it
can be accessed at: /home/your-username/assignment_1/solution.c
Do not edit the file after the due date or the file date on beckett4 will indicate a late submission. Task:
In tutorial 2, you saw how to use MPI collective communication to split a calculation and distribute it
among several processors. However, it is possible to define collective communication in terms of
point-to-point communication. Explain how this is possible by writing a short (max 1 page) design
document and providing the code to accomplish it, based on the task below. Then, write this in C!
In the provided file solution.c, there is call to MPI_Bcast that sends the menu prices from the
process rank 0 (the root process) to all other processes in the communicator. Remove the call to
MPI_Bcast and replace it with calls to MPI point-to-point communication (for example, MPI_Send
and MPI_Recv) as appropriate to ensure that all nodes have the array of menu prices. Assume that
the only the root process (process of rank == 0) has access to the menu prices at the start. 1. Code
Modify solution.c to use point-to-point communication instead of MPI_Bcast. You
must submit code that compiles with the following command line:
o mpicc -std=c11 -o solution solution.c
You will receive full credit if your submission performs the broadcast using point-to- point communication and successfully broadcasts a message to all p processes, with
the exact same result as using MPI_Bcast. The broadcast muststart at the root process (process of rank == 0) The broadcast must use the size of the communicator (that is, the total number of
processes) from MPI. You should not use a constant, hardcoded number. Partial credit will be given if the solution works only in the case of p = 2 processes. The final answer calculated by your version of solution.c that uses point-to-point
communication must match the answer calculated by the version of solution.c that
uses MPI_Bcast. 2. Report (max 1 page report)
o Write a report describing how you implemented solution.c. You must provide:
i. Explanation of the approach chosen
ii. An explanation of the required communication involved in MPI_Bcast.
iii. Any specific choices you made in your implementation. o Report: use 11pt font (Arial, Times New Roman, or Calibri). Provided files
We will provide the following files
o solution.c — MPI program that calculates the total from order.tsv. You must
modify this file and submit it. o make-order.py – run this to create order.tsv
o menu.tsv — provides prices for each menu item
Deliverables
Two files: Design document, at most 1 page, PDF format, uploaded to Moodle before the
deadline. solution.c, with your modifications, uploaded to Moodle before the deadline, AND on beckett4 as described above. Grading
You will be graded on the following: Code correctness (50%). Partial credit will be awarded as appropriate, including all
specifications above including:
o Broadcast isinitiated only by the root process
o Broadcast correctly for 2 processes
o Broadcast correctly for processes, p> 2
o Broadcast correctly for p processes, where p is given by MPI Report (50%). Partial credit will be awarded as appropriate, including all specifications above
including:
o Demonstrates an understanding of communication required
o Explanation of algorithm chosen
o Documentation of implementation choices
o Overall professionalism of the report
Method of Submission: Moodle (.pdf and .c file) and beckett4 (.c file)
Please place solution.c in your home directory on beckett4 in a folder called assignment_1 so that it
can be accessed at: /home/your-username/assignment_1/solution.c
Do not edit the file after the due date or the file date on beckett4 will indicate a late submission. Task:
In tutorial 2, you saw how to use MPI collective communication to split a calculation and distribute it
among several processors. However, it is possible to define collective communication in terms of
point-to-point communication. Explain how this is possible by writing a short (max 1 page) design
document and providing the code to accomplish it, based on the task below. Then, write this in C!
In the provided file solution.c, there is call to MPI_Bcast that sends the menu prices from the
process rank 0 (the root process) to all other processes in the communicator. Remove the call to
MPI_Bcast and replace it with calls to MPI point-to-point communication (for example, MPI_Send
and MPI_Recv) as appropriate to ensure that all nodes have the array of menu prices. Assume that
the only the root process (process of rank == 0) has access to the menu prices at the start. 1. Code
Modify solution.c to use point-to-point communication instead of MPI_Bcast. You
must submit code that compiles with the following command line:
o mpicc -std=c11 -o solution solution.c
You will receive full credit if your submission performs the broadcast using point-to- point communication and successfully broadcasts a message to all p processes, with
the exact same result as using MPI_Bcast. The broadcast muststart at the root process (process of rank == 0) The broadcast must use the size of the communicator (that is, the total number of
processes) from MPI. You should not use a constant, hardcoded number. Partial credit will be given if the solution works only in the case of p = 2 processes. The final answer calculated by your version of solution.c that uses point-to-point
communication must match the answer calculated by the version of solution.c that
uses MPI_Bcast. 2. Report (max 1 page report)
o Write a report describing how you implemented solution.c. You must provide:
i. Explanation of the approach chosen
ii. An explanation of the required communication involved in MPI_Bcast.
iii. Any specific choices you made in your implementation. o Report: use 11pt font (Arial, Times New Roman, or Calibri). Provided files
We will provide the following files
o solution.c — MPI program that calculates the total from order.tsv. You must
modify this file and submit it. o make-order.py – run this to create order.tsv
o menu.tsv — provides prices for each menu item
Deliverables
Two files: Design document, at most 1 page, PDF format, uploaded to Moodle before the
deadline. solution.c, with your modifications, uploaded to Moodle before the deadline, AND on beckett4 as described above. Grading
You will be graded on the following: Code correctness (50%). Partial credit will be awarded as appropriate, including all
specifications above including:
o Broadcast isinitiated only by the root process
o Broadcast correctly for 2 processes
o Broadcast correctly for processes, p> 2
o Broadcast correctly for p processes, where p is given by MPI Report (50%). Partial credit will be awarded as appropriate, including all specifications above
including:
o Demonstrates an understanding of communication required
o Explanation of algorithm chosen
o Documentation of implementation choices
o Overall professionalism of the report