#include #include #include #include #define ABS(x) (x < 0 ? -(x) : (x)) #define EPS 0.00001 #define TRUE 1 #define FALSE 0 #define DEBUG 1 shared[1001] double a[1000][1001]; shared double x[1000]; shared int size; shared int maxrow; /* Solve a system of n equations in n unknowns using Gaussian Elimination Solve an equation in matrix form Ax = b The 2D array a is the matrix A with an additional column b. This is often written (A:b) A0,0 A1,0 A2,0 .... An-1,0 b0 A0,1 A1,1 A2,1 .... An-1,1 b1 A0,2 A1,2 A2,2 .... An-1,2 b2 : : : : : : : : : : A0,n-1 A1,n-1 A2,n-1 .... An-1,n-1 bn-1 The result is returned in x, otherwise the function returns FALSE if the system of equations is singular. */ void WriteSolution() { int j,k; for (j=0;j ABS(a[maxrow][i])){ // printf("Seting maxrow to %d\n",maxrow); maxrow = j; } // printf("GOT HERE blabla\n"); fflush(stdout); } printf("Found maxrow : %d\n",maxrow); fflush(stdout); /* Swap the maxrow and ith row */ for (k=i;k=i;k--) { a[j][k] -= a[i][k] * a[j][i] / a[i][i]; } } } upc_barrier(b++); //WriteSolution(a,n,x); } /* Do the back substitution */ if(MYTHREAD == 0){ for (j=size-1;j>=0;j--) { tmpa = 0; for (k=j+1;k