Changeset 100


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

PPPP - jacobi_vector for parallel

File:
1 edited

Legend:

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

    r95 r100  
    1919        z = (float *) malloc(n * sizeof(float));
    2020       
     21        /* Fork a team of threads giving them their own copies of variables */
     22        #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)
     23        {
     24
     25        /* Obtain thread number */
     26        tid = omp_get_thread_num();
     27        printf("Hello World from thread = %d\n", tid);
     28
     29        /* Only master thread does this */
     30        if (tid == 0)
     31    {
     32        nthreads = omp_get_num_threads();
     33        printf("Number of threads = %d\n", nthreads);
     34    }
     35
     36       
     37        #pragma omp parallel for
    2138        for (ip=0;ip<n;ip++) {                                                                                                                  // Initialize to the identity matrix.
    2239                for (iq=0;iq<n;iq++) v[ip*n + iq]=0.0;
    2340                        v[ip*n + ip]=1.0;
    2441        }
     42        #pragma omp parallel for
    2543        for (ip=0;ip<n;ip++) {                                                                                                                  // Initialize b and d to the diagonal of a.
    2644                b[ip]=d[ip]=a[ip*n + ip];                                                                                                               
    2745                z[ip]=0.0;                                                                                                                              // This vector will accumulate terms of the form t*a[pq] as in equation (11.1.14).
    2846        }
    29        
     47        }       
    3048        *nrot=0;
    3149        for (i=1;i<=50;i++) {
    3250                sm=0.0;
     51        #pragma omp parallel for reduction(+:sm)
    3352                for (ip=0;ip<n-1;ip++) {                                                                                                                // Sum off-diagonal elements.
    3453                        for (iq=ip+1;iq<n;iq++)
     
    7089                                        a[ip*n + iq]=0.0;
    7190                                       
     91                                        #pragma omp parallel for
    7292                                        for (j=0;j<=ip-1;j++) {                                                                                         // Case of rotations 1 <= j < p.
    7393                                                ROTATE(a,j,ip,j,iq)
    7494                                        }
     95                                        #pragma omp parallel for
    7596                                        for (j=ip+1;j<=iq-1;j++) {                                                                              // Case of rotations p < j < q.
    7697                                                ROTATE(a,ip,j,j,iq)
    7798                                        }
     99                                        #pragma omp parallel for
    78100                                        for (j=iq+1;j<n;j++) {                                                                                  // Case of rotations q < j <= n.
    79101                                                ROTATE(a,ip,j,iq,j)
    80102                                        }
     103                                        #pragma omp parallel for
    81104                                        for (j=0;j<n;j++) {
    82105                                                ROTATE(v,j,ip,j,iq)
Note: See TracChangeset for help on using the changeset viewer.