CSCI 3366 Spring 2004 Homework Two Continuing our discussion of divide and conquer algorithms, we will write a C-MPI program which will perform a simple parallel sort. The master process will generate an array of a given size (command line) of random numbers to be sorted. Depending on the number of processors available, the array will be divided among the processors so that each has an equal share to sort. You may use an ordinary bubble sort (since we wish to make the processors work hard in order to gain some benefit from parallelism). The processors will sort their chunk of the array, and pass the sorted array back to the master process, who will display the sorted results. It is the master process's responsibility to merge the sorted chunks to provide the original array in sorted order. (However, since bubble sort is O(n^2) and merge is O(n), the bubble sort dominates the time taken for the sort.) Using MPI_Wtime(), time how long it takes to sort various array sizes using a varying number of processors, and see what you can conclude. I recommend files of size increasing by an order of magnitude each time, such as 1000, 10000, 100000, 1000000, and perhaps some inbetween. You may also try 1, 2, 4, 8, 16 processors, etc and maybe note the machine speeds as well. Homework due Tuesday, February 3, 2004 int Bubble(int *a, int n) { int notstop, i; notstop = 1; while (notstop == 1) { notstop = 0; for (i=0; i a[i+1]) { int t; t = a[i]; a[i] = a[i+1]; a[i+1] = t; notstop = 1; } } n--; } }