Changeset 91 for proiecte


Ignore:
Timestamp:
Jan 11, 2010, 5:16:40 PM (14 years ago)
Author:
(none)
Message:

PPPP - jacobi updated

File:
1 edited

Legend:

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

    r90 r91  
    22#include <math.h>
    33#include <malloc.h>
     4#include <omp.h>
     5
    46#define ROTATE(a,i,j,k,l) g=a[i][j];h=a[k][l];a[i][j]=g-s*(h+g*tau);\
    57a[k][l]=h+s*(g-h*tau);
     
    1921        z = (float *) malloc(n * sizeof(float));
    2022       
    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 */
    2241               
    2342        for (ip=0;ip<n;ip++) {          // Initialize to the identity matrix.
     
    2645                v[ip][ip]=1.0;
    2746        }
    28         printf("in jacobi 2\n");
    2947        for (ip=0;ip<n;ip++) {     // Initialize b and d to the diagonal of a.
    3048                b[ip]=d[ip]=a[ip][ip];                                 
     
    3250        }
    3351       
    34         printf("in jacobi 2\n");
    3552        *nrot=0;
    3653        for (i=1;i<=50;i++) {
     
    103120}
    104121
    105 int main(int argc, char * argv)
     122int main(int argc, char * argv[])
    106123{
    107124        int n, i, j;
     
    110127        float **v;
    111128        int nrot = 0;
    112        
    113         FILE * f = fopen("mat.in", "r");
     129
     130        char * filename = argv[1];     
     131        FILE * f = fopen(filename, "r");
    114132        fscanf(f,"%d", &n);
    115133       
     
    149167                printf("%f ", d[i]);
    150168        }
     169        printf("\n");
    151170
    152171        return 0;
Note: See TracChangeset for help on using the changeset viewer.