MPI: Finding an Element in an Array

Due: November 30, 2106

Write a MPI program to find an element in a large array, namely an integer array of size 10,00,000 (10L). First, using a sequential prograam, generate a random array of size 10L such that each element is randomly generated in the range 1 to 50,000. Then write a MPI program in which process 0 first reads the file and distributes to all the processes using MPI_Scatter. Then process 0 generates a random number, which is the element/key to find in the array, and sends this key to all the processes. Then all the processes search for this key in their respective sub-arrays. Write a sequential program that finds the same key in the same array. Find the speedup of the parallel over the sequential program.

Do this multiple times, specifically 20 times, each time with a different key but with the same 10L array. For each such key, report the sequential and parallel times, and speedups. Report the min, max and average speedup obtained.

Your challenge is to obtain good speedup over the sequential program. Caution/Hint: Naive/intuitive method of parallelism can result in more work and hence can cause slowdown over sequential program.

Perform this assignment for 32, 64 and 128 cores.

For platform for doing this MPI assignment, refer to the platform notes in the class webpage.