MPI: Needle in a Haystack (Finding an element in a large array)

Refer to the MPI class lecture slides that has a MPI program involving two processes that tries to find a particular element in an array distributed across the two processes. Now write a MPI program that works with any number of processes. 

For this program, generate a random double array of size 1000000 (i.e., 1 million) with random integer elements between 1 to 5000000 (5 million). You can either generate this array in process 0 and distribute it equally across all the processes or generate this array to a file and make the processes read from different portions of the file (e.g., using fseek). Now an integer element is given as input to the program and the processes start searching for this element in their local sub arrays. As soon as a process finds the element, it informs the other processes and all processes will stop searching. Process 0 should print the global index of the overall array in which the element was found.

Execute the program with different number of processes including 1 (sequential), 2, 4, 8, 16, 32 and 64. For each number of processes, execute with 50 different random input numbers for searching and in each case, measure the time taken for the search. Report the average time (across the 50 instances) taken for each number of processes. Plot the execution times and speedups for different number of processes. Ensure that you execute different processes on different cores.
Prepare a report with the methodology, execution times, and speedup graphs.

Your relative marks for this assignment will be based on the relative times for parallel programs. For uniform comparison among all of you, the TA will be sending an input file of 1 million elements and 50 random input numbers for searching.