This program is a variation on programming assignment


This program is a variation on programming assignment 3.4. You are to write an MPI program that computes a global sum using a butterfly construct. In this case, you merely have to write the program for comm_sz (or p) to be a power of 2.
Do not use the MPI_Allreduce or similar calls for message passing communication. You are only allowed to use MPI_Send, MPI_Recv, and/or MPI_Sendrecv (the last one may be most preferable to avoid deadlock situations when implementing the butterfly structured communication).

Other Requirements

Previously, you were required to use a command-line parameter to obtain the number of processors. In fact, it's more appropriate and easier to use the MPI_Comm_size function to determine the number of processors. You can do this either way, but I guarantee I will not test the program with numbers other than 1, 2, 4, 8, 16, 32, etc. (i.e. powers of 2).
Use the number of processors also as a random number seed. Simply generate an array with as many integer elements as there are processors.
The contents of the array should be distributed by process 0 to all other processes - i.e. one value per process.
The output of the program is each process reporting the global sum it determined. For example, assume a program run on 4 processes generated the following values: 24 3 19 5. It is easy to figure out (by hand) that the global sum should be 51, so the output of the program should be similar to:

process 0: 51
process 1: 51
process 2: 51
process 3: 51

Note that the processes won't necessarily report things in numeric order - i.e. they are allowed to simply print their result when finished, so it's likely they will not be printed in numeric order.
Name your main program prog04.cpp. You can leave it in your home directory (or a subdirectory), where I will examine it. Otherwise, you can upload a copy of the program in a zip file, if you wish.

In your comment block to begin your main program, other than the function of the program and the variable dictionary, include a set of comments of the following format. It is very important for you to include your name, the compiler you used, the due date, and the program identity:

// Name: Joe M. Student
// Program: CSC 478/578 Program 4


Your program should follow "reasonable" rules of style, with appropriate indentation and commenting.

Required minimum 2 page

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: This program is a variation on programming assignment
Reference No:- TGS081118

Expected delivery within 24 Hours