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
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
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
Get step-by-step solutions from verified subject matter experts
