Changeset 99 for proiecte/PPPP/eigenface
- Timestamp:
- Jan 12, 2010, 1:14:48 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
proiecte/PPPP/eigenface/new/jacobi.c
r92 r99 24 24 25 25 /* Fork a team of threads giving them their own copies of variables */ 26 #pragma omp parallel private(nthreads, tid )26 #pragma omp parallel private(nthreads, tid, i, j, ip, iq) shared(tresh, theta, tau, sm, s, h, g, c, b, z, a, n, d, v, nrot) 27 27 { 28 28 … … 38 38 } 39 39 40 } /* All threads join master thread and disband */ 41 40 41 #pragma omp parallel for 42 42 for (ip=0;ip<n;ip++) { // Initialize to the identity matrix. 43 43 for (iq=0;iq<n;iq++) … … 45 45 v[ip][ip]=1.0; 46 46 } 47 48 #pragma omp parallel for 47 49 for (ip=0;ip<n;ip++) { // Initialize b and d to the diagonal of a. 48 50 b[ip]=d[ip]=a[ip][ip]; … … 50 52 } 51 53 54 } /* All threads join master thread and disband */ 55 52 56 *nrot=0; 53 57 for (i=1;i<=50;i++) { 54 sm=0.0; 58 59 sm = 0.0; 60 55 61 for (ip=0;ip<n-1;ip++) { // Sum off-diagonal elements. 56 for (iq=ip+1;iq<n;iq++) 57 sm += fabs(a[ip][iq]); 62 #pragma omp parallel for reduction(+:sm) 63 for (iq=ip+1;iq<n;iq++) { 64 sm += fabs(a[ip][iq]); 65 printf("Hello World from thread = %d\n", omp_get_thread_num()); 66 } 58 67 } 59 68 if (sm == 0.0) { // The normal return, which relies on quadratic convergence to machine underflow. … … 66 75 else 67 76 tresh=0.0; // ...thereafter. 77 68 78 for (ip=0;ip<n-1;ip++) { 69 79 for (iq=ip+1;iq<n;iq++) { … … 91 101 d[iq] += h; 92 102 a[ip][iq]=0.0; 93 103 104 #pragma omp parallel for 94 105 for (j=0;j<=ip-1;j++) { // Case of rotations 1 <= j < p. 95 106 ROTATE(a,j,ip,j,iq) 96 107 } 108 #pragma omp parallel for 97 109 for (j=ip+1;j<=iq-1;j++) { // Case of rotations p < j < q. 98 110 ROTATE(a,ip,j,j,iq) 99 111 } 112 #pragma omp parallel for 100 113 for (j=iq+1;j<n;j++) { // Case of rotations q < j <= n. 101 114 ROTATE(a,ip,j,iq,j) 102 115 } 116 #pragma omp parallel for 103 117 for (j=0;j<n;j++) { 104 118 ROTATE(v,j,ip,j,iq) … … 110 124 } 111 125 126 #pragma omp parallel for 112 127 for (ip=0;ip<n;ip++) { 113 128 b[ip] += z[ip];
Note: See TracChangeset
for help on using the changeset viewer.