Changeset 99 for proiecte


Ignore:
Timestamp:
Jan 12, 2010, 1:14:48 PM (14 years ago)
Author:
(none)
Message:

PPPP - jacobi for parallel

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proiecte/PPPP/eigenface/new/jacobi.c

    r92 r99  
    2424
    2525        /* 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)
    2727        {
    2828
     
    3838    }
    3939
    40         }  /* All threads join master thread and disband */
    41                
     40
     41        #pragma omp parallel for
    4242        for (ip=0;ip<n;ip++) {          // Initialize to the identity matrix.
    4343                for (iq=0;iq<n;iq++)
     
    4545                v[ip][ip]=1.0;
    4646        }
     47       
     48        #pragma omp parallel for
    4749        for (ip=0;ip<n;ip++) {     // Initialize b and d to the diagonal of a.
    4850                b[ip]=d[ip]=a[ip][ip];                                 
     
    5052        }
    5153       
     54        }  /* All threads join master thread and disband */
     55       
    5256        *nrot=0;
    5357        for (i=1;i<=50;i++) {
    54                 sm=0.0;
     58
     59                sm = 0.0;
     60
    5561                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                        }
    5867                }
    5968                if (sm == 0.0) {                                // The normal return, which relies on quadratic convergence to machine underflow.
     
    6675                else
    6776                        tresh=0.0;                                      // ...thereafter.
     77       
    6878                for (ip=0;ip<n-1;ip++) {
    6979                        for (iq=ip+1;iq<n;iq++) {
     
    91101                                        d[iq] += h;
    92102                                        a[ip][iq]=0.0;
    93                                        
     103                               
     104                                        #pragma omp parallel for
    94105                                        for (j=0;j<=ip-1;j++) { // Case of rotations 1 <= j < p.
    95106                                                ROTATE(a,j,ip,j,iq)
    96107                                        }
     108                                        #pragma omp parallel for
    97109                                        for (j=ip+1;j<=iq-1;j++) { // Case of rotations p < j < q.
    98110                                                ROTATE(a,ip,j,j,iq)
    99111                                        }
     112                                        #pragma omp parallel for
    100113                                        for (j=iq+1;j<n;j++) {  // Case of rotations q < j <= n.
    101114                                                ROTATE(a,ip,j,iq,j)
    102115                                        }
     116                                        #pragma omp parallel for
    103117                                        for (j=0;j<n;j++) {
    104118                                                ROTATE(v,j,ip,j,iq)
     
    110124                }
    111125               
     126                #pragma omp parallel for
    112127                for (ip=0;ip<n;ip++) {
    113128                        b[ip] += z[ip];
Note: See TracChangeset for help on using the changeset viewer.