Assignment 1 Final
See the page Assignment 1 Introduction for an overview.
You should finish the Milestone before beginning this part.
Your task here is to write an MPI program for a set of tasks communicating in a ring topology.
Copyright By PowCoder代写 加微信 powcoder
On page 37 m of the textbook, you can see a picture of processors connected by a ring interconnect.
In such a network, it is only possible for a given processor to communicate directly with either its left or its right neighbour. We are
going to try to emulate this behaviour with MPI tasks. Hence, when emulating ring communication, point to point communication
events must always have immediate neighbours as source and destination.
We are going to be mostly concerned with moving numbers in a circular fashion around the ring.
Think about this pseudocode. Remember that it is executed simultaneously by all tasks.
send m to the right
Receive m from the left
Remembering that m is local to each task, this has the effect of shifting the set of m values one element to the right.
For example, consider four tasks, such that in task i, variable m has the value j.
In other words, in task O, m is O, in task 1, it is 1 and so on
Then, before we execute the code above, the m values will be: 0, 1, 2. 3.
After the code is executed. we will have: 3. 0. 1. 2.
Draw a diagram showing the four tasks, and the communication events, to make sure that you understand this.
Also, write down the left and right neighbours of each task.
For example, the left neighbour of task 2 is 1, its right neighbour is 3.
Think carefully about tasks O and 3.
We are asking you to carry out these steps:
1. Initialise the m values in each task, by having the master processor send values to each slave processor, such that processor i
receives value j and sets variable m to the value j it receives, using point-to-point communication. Note that we are not doing ring
emulation here – that comes in the next step.
2. Do a left circular shift of the m-values three places to the left by shifting values to the left, 3 times, around the ring. In the
example above, the result after execution will be: 3,0,1,2.
3. After that is done, each task outputs its m-value. The outputs need not be in order.
Make sure to print out a record of each communication.
For example, before a Send operation, output something like this: “Task O sending number 5 to task 3”
And after a Receive operation, something like this: “Task 3 received number 5 from task O”
Your assignment will be assessed primarily from a report detailing your design, method and results – but you will significantly lose
marks if your code is not valid code, ie: if your code does not successfully implement the design you outline in the report, you will
receive zero for that portion of the report
Explain clearly the following points:
1. Design of the initialisation phase.
2. How vou implement the neighbour relationship.
3. Design of the left circular shift phase.
4. Design of the output phase.
In your report, include output from the program for an example.
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com