Can you write a program for paralllel programming I am doing mine also right now
ID: 3865620 • Letter: C
Question
Can you write a program for paralllel programming I am doing mine also right now I will what I got wrong This exercise is from Question 6-5 of the textbook at page 194 Implement the butterfly barrier described in Section 6.1.4, assume the number of processes is a power of 2, e.g.2,4, 8, 16, etc. Investigate the time taken by your butterfly barrier by using the code such as: t1 = MP1wtime(); butterfly barrierO;//call to your butterfly barrier t2 MPIwtime(); printf Elapsed time %d secondsin", 12-tl); - Demonstrate your program in the class on the due date.Explanation / Answer
typedef struct {
bool isMine;
bool *partner;
} flags_t;
typedef struct {
flags_t flags[2][WORKER_LOG2];
bool canSense;
unsigned int parityBit;
} thread_t;
t1 = MPI_Wtime();
t = &thread[0];
for (unsigned int i = 0; i < log2 (P); i++) {
flags_t * const flags = &t->flags[t->parityBit][i];
*flags->partner = t->canSense;
while (flags->isMine != t->canSense);
}
if (t->parityBit == 1) {
t->canSense = !t->canSense;
}
t->parityBit ^= 0x1;
t2 = MPI_Wtime();
printf("Elapsed time = %d seconds ",t2-t1);
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.