Description
In this Assignment, you will write parallel codes using mpi |
[100 marks] |
programming. In the earlier assignment, you have setup mpi on the |
|
system and made sure that it is working. |
|
Language Constraint: C/C++ |
|
Include a bash script to run each of the code in your submission. |
|
Name them q1.sh, q2.sh, q3.sh, q4.sh |
|
Q 1) Parallel QuickSort. |
[25 marks] |
Given an array of numbers, your task is to return the array in sorted |
|
order by implementing parallel quick sort. |
|
Input Format: |
|
-> bash q1.sh `num_process` `num_elements` `elements separated |
|
by spaces` |
|
Output Format : |
|
-> `elements in sorted order` |
|
Q 2) Stable Marriage Problem |
[25 marks] |
Let men and women each be array of n processes. Each man ranks |
|
the women from 0 to n-1 and each woman ranks the men from 0 to |
|
n-1. A pairing is a one-to-one correspondence of men and women. A |
|
pairing is stable if, for two men m1 and m2 and their paired women |
|
w1 and w2, both of the following conditions are satisfied: |
-
m1 ranks w1 higher than w2 or w2 ranks m2 higher than m1; and
-
m2 ranks w2 higher than w1 or w1 ranks m1 higher than m2.
Expressed differently, a pairing is unstable if a man and woman would both prefer each other to their current pair. A solution to the stable marriage problem is a set of n pairings, all of which are stable. Write a distributed program to solve the stable marriage problem. The processes should communicate using asynchronous message passing . The men should send proposal and the women should listen. A woman has to accept the first proposal she gets, because a better one might not come along; however, she can dump the first man if she later gets a better proposal. Write the program using MPI. Log the trace of events (pairing, breaking), as they happen, in a text file named as Log.txt .
The number of slave processes will be 2n.
Input Format :
-> bash q1.sh `num_processes`
First line of input contains the integer n, denoting the number of men and women. The following 2n lines are the preferences of each
line is for an edge between 2 nodes in G.
Output Format:
Output the number of colors used in the first line followed by T (number of color) lines printing the color of nodes from 0 to T – 1.
Note:Your output may be different but ensure that it follows the mentioned Constraints.
Sample:
Input:
-
7
0 1
0 2
1 3
2 3
3 4
3 5
4 5
Output:
3
0
1
1
0
1
2
Note:Submitting a serial code for any problem instead of a parallel code will result in negative marking (-10).
Note: Strict actions would be taken against anyone found involved in any kind of plagiarism either from the internet or from other students.