/*----------------------------------------------------------- ** ge_p.c -- The program is to solve a linear system Ax = b ** by using Gaussian Elimination. The algorithm on page 101 ** ("Foundations of Parallel Programming") is used. ** The sequential version is ge_s.c. This parallel ** implementation converts three independent for() loops ** into three Fans. Use the data file ge_3.dat to verify ** the correction of the output. ** ** Written by Andreas Kura, 02/15/95 ** Modified by Chong-wei Xu, /04/20/95 **----------------------------------------------------------- */ #include #include int Size, t; float **a, *b; BEGIN_SHARED_DECL float **m; END_SHARED_DECL; FILE *fp; void InitProblemOnce(); void InitPerRun(); void ForwardSub(); void Fan1(); void Fan2(); void Fan3(); void InitMat(); void InitAry(); void PrintMat(); void PrintAry(); main () { InitializeUs(); MakeSharedVariables; /* to make SHARED m */ InitProblemOnce(); InitPerRun(); ForwardSub(); printf("The result of matrix m is: \n"); PrintMat(SHARED m, Size, Size); printf("The result of matrix a is: \n"); PrintMat(a, Size, Size); printf("The result of array b is: \n"); PrintAry(b, Size); } /*------------------------------------------------------ ** InitProblemOnce -- Initialize all of matrices and ** vectors by opening a data file specified by the user. ** ** We used dynamic array **a, *b, and **m to allocate ** the memory storages. **------------------------------------------------------ */ void InitProblemOnce() { char filename[30]; printf("Enter the data file name: "); scanf("%s", filename); printf("The file name is: %s\n", filename); fp = fopen(filename, "r"); fscanf(fp, "%d", &Size); a = (float **) UsAllocScatterMatrix(Size, Size, sizeof(float)); /* a = (float **) malloc(Size * sizeof(float *)); for (i=0; i