Question: This program uses Jacobi algorithm. I need to run this algorithm in parallel with variable number of threads using OpenMP. What should be changed to

This program uses Jacobi algorithm. I need to run this algorithm in parallel with variable number of threads using OpenMP. What should be changed to improve the performance of the program? Please add descriptive comments

#include #include #include #include #include

int main(int argc, char *argv[]) { int i,j,m,n,l; int thread_count; double **A, *b, *x, *c; clock_t time; // used to get the execution time double timeMeasured; // used to store typecasted result of time converted int\ o milliseconds

if (argc != 4) { fprintf(stderr, "Usage: %s ", argv[0]); exit(0); } thread_count = atoi(argv[1]); n = atoi(argv[2]); l = atoi(argv[3]);

A = (double **)malloc(n*sizeof(double*)); /* coefficients */ for (i=0; i

/* init A, b, x */ for (i=0; i

for (i=0; i

//memset(x, 0, n*sizeof(double)); /* done init */

m = 1; time = clock(); line: for(i=0;i

}

}

for(i=0;i

m++; if(m<=l) { goto line; } else { time = clock() - time; timeMeasured = (((double)time)/CLOCKS_PER_SEC)*1000; //time in milliseconds

printf(" The Solution is : "); for(i=0;i

free(A); free(b); free(x); free(c);

}

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!