Changeset 91
- Timestamp:
- Jan 11, 2010, 5:16:40 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
proiecte/PPPP/eigenface/new/jacobi.c
r90 r91 2 2 #include <math.h> 3 3 #include <malloc.h> 4 #include <omp.h> 5 4 6 #define ROTATE(a,i,j,k,l) g=a[i][j];h=a[k][l];a[i][j]=g-s*(h+g*tau);\ 5 7 a[k][l]=h+s*(g-h*tau); … … 19 21 z = (float *) malloc(n * sizeof(float)); 20 22 21 printf("in jacobi\n"); 23 int nthreads, tid; 24 25 /* Fork a team of threads giving them their own copies of variables */ 26 #pragma omp parallel private(nthreads, tid) 27 { 28 29 /* Obtain thread number */ 30 tid = omp_get_thread_num(); 31 printf("Hello World from thread = %d\n", tid); 32 33 /* Only master thread does this */ 34 if (tid == 0) 35 { 36 nthreads = omp_get_num_threads(); 37 printf("Number of threads = %d\n", nthreads); 38 } 39 40 } /* All threads join master thread and disband */ 22 41 23 42 for (ip=0;ip<n;ip++) { // Initialize to the identity matrix. … … 26 45 v[ip][ip]=1.0; 27 46 } 28 printf("in jacobi 2\n");29 47 for (ip=0;ip<n;ip++) { // Initialize b and d to the diagonal of a. 30 48 b[ip]=d[ip]=a[ip][ip]; … … 32 50 } 33 51 34 printf("in jacobi 2\n");35 52 *nrot=0; 36 53 for (i=1;i<=50;i++) { … … 103 120 } 104 121 105 int main(int argc, char * argv )122 int main(int argc, char * argv[]) 106 123 { 107 124 int n, i, j; … … 110 127 float **v; 111 128 int nrot = 0; 112 113 FILE * f = fopen("mat.in", "r"); 129 130 char * filename = argv[1]; 131 FILE * f = fopen(filename, "r"); 114 132 fscanf(f,"%d", &n); 115 133 … … 149 167 printf("%f ", d[i]); 150 168 } 169 printf("\n"); 151 170 152 171 return 0;
Note: See TracChangeset
for help on using the changeset viewer.