Question: Modify below assignment 2 solution to use FORK instead of FORALL to implement the parallel rank sort. You may use the posted solution to Assign

Modify below assignment 2 solution to use FORK instead of FORALL to implement the parallel rank sort. You may use the posted solution to Assign2 if necessary. If it has not been posted because of late assignments still to be submitted, ask the TA for a copy. Assume that only seven (7) processors (in addition to the main processor) are available and design the solution to run on 7(plus the main) processors. Set the number of processors as a #define value so you can change the number of processors. Also test your code with 5 processors, but submit the 7 processor solution. Count the number of JOIN's that are executed and write them out after the sorted display. For 7 processors, the output should look something like this.
*
TS 5S KH 8H 3H JD 6D AC 9C 4C QS 7S 2S
TH 5H KD 8D 3D JC 6C AS 9S 4S QH 7H 2H
TD 5D KC 8C 3C JS 6S AH 9H 4H QD 7D 2D
TC 5C KS 8S 3S JH 6H AD 9D 4D QC 7C 2C
2C 3C 4C 5C 6C 7C 8C 9C TC JC QC KC AC
2D 3D 4D 5D 6D 7D 8D 9D TD JD QD KD AD
2H 3H 4H 5H 6H 7H 8H 9H TH JH QH KH AH
2S 3S 4S 5S 6S 7S 8S 9S TS JS QS KS AS
52 joins executed
SEQUENTIAL EXECUTION TIME: 743363
PARALLEL EXECUTION TIME: 118080
SPEEDUP: 6.30
NUMBER OF PROCESSORS USED: 8
/* Assignment 2*/
/* Name: sunkara dineshgopi*/
#define DECK 52
#define SUIT_SZ 4
#define RANK_SZ 13
typedef struct
{
char suit;
int suitr;
char rank;
int rankr;
} card;
char suits[SUIT_SZ]={'C','D','H','S'};
int suitr[SUIT_SZ]={1,2,3,4};
char ranks[RANK_SZ]={'2','3','4','5','6','7','8','9','T','J','Q','K','A'};
int rankr[RANK_SZ]={1,2,3,4,5,6,7,8,9,10,11,12,13};
card unsorteddeck[DECK], sorteddeck[DECK];
boolean compare_cards(card cardA, card cardB)
{
if (cardA.suit != cardB.suit)
return cardB.suitr - cardA.suitr <0;
return cardB.rankr - cardA.rankr <0;
}
void deal()
{
int i, m, v, r;
m =47;
v = m;
for (i =0; i < DECK; i++)
{
r = v % DECK;
unsorteddeck[i].suit = suits[r / RANK_SZ];
unsorteddeck[i].suitr = suitr[r / RANK_SZ];
unsorteddeck[i].rank = ranks[r % RANK_SZ];
unsorteddeck[i].rankr = rankr[r % RANK_SZ];
v += m;
}
}
void display(card dk[])
{
int i;
for (i =0; i < DECK; i++)
{
cout<< dk[i].rank<

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!