Results 1 to 2 of 2

Thread: cannot run OPENMP in C language using UBUNTU 12.04

  1. #1
    Join Date
    May 2013
    Beans
    4

    cannot run OPENMP in C language using UBUNTU 12.04

    Below is my code
    # include <stdlib.h>
    # include <stdio.h>
    # include <omp.h>
    main(){
    int i,k,j,a[100][100],b[100][100],c[100][100];
    int nthreads,maxt,procs,tid,inpar,n;
    for(i=0;i<100;i++){
    for(j=0;j<100;j++){
    a[i][j]=rand()%10;
    b[i][j]=rand()%10;
    }
    }
    printf("\n MATRIX A\n\n");
    for(i=0;i<100;i++){
    for(j=0;j<100;j++){
    printf("%d \t",a[i][j]);

    }
    printf("\n");
    }
    printf("\n MATRIX B\n\n");

    for(i=0;i<100;i++){
    for(j=0;j<100;j++){
    printf("%d \t",b[i][j]);

    }
    printf("\n");
    }
    printf("\nENTER THE NUMBER OF THREAD U WANT TO USE:");
    scanf("%d",&n);
    printf("\nMULTIPLICATION OF MATRIX A & MATRIX B\n\n");
    #pragma omp parallel private(nthread,tid,i,j,k){
    omp_set_num_threads(n) ;
    /* Obtain thread number */
    tid= omp_get_thread_num();
    /* Only master thread does this */

    printf("Thread %d getting environment info...\n", tid);
    /* Get environment information */
    procs = omp_get_num_procs();
    nthreads = omp_get_num_threads();
    maxt = omp_get_max_threads();
    inpar = omp_in_parallel();
    /* Print environment information */
    printf("Number of processors = %d\n", procs);
    printf("Number of threads = %d\n", nthreads);
    printf("Max threads = %d\n", maxt);
    printf("In parallel? = %d\n", inpar);



    for(i=0;i<100;i++){
    for(j=0;j<100;j++){
    for (k=0;k<100;k++){
    c[i][j]=a[i][k]*b[k][j];
    }
    }
    }
    printf("\n");


    for( i=0;i<100;i++){
    for(j=0;j<100;j++){
    printf("%d\t",c[i][j]);
    }
    printf("\n");
    }
    }



    EACH TIME I TRY RUNNING IT THE ERROR MESSAGE I KEEP GETTING IS BELOW:
    /tmp/ccKib029.o: In function `main':
    phundred.c:(.text+0x20a): undefined reference to `omp_set_num_threads'
    phundred.c:(.text+0x20f): undefined reference to `omp_get_thread_num'
    phundred.c:(.text+0x233): undefined reference to `omp_get_num_procs'
    phundred.c:(.text+0x23f): undefined reference to `omp_get_num_threads'
    phundred.c:(.text+0x24b): undefined reference to `omp_get_max_threads'
    phundred.c:(.text+0x257): undefined reference to `omp_in_parallel'
    collect2: ld returned 1 exit status


    what do i DO?

  2. #2
    Join Date
    Jul 2007
    Location
    Magic City of the Plains
    Beans
    Hidden!
    Distro
    Xubuntu Development Release

    Re: cannot run OPENMP in C language using UBUNTU 12.04

    Closed, duplicate of http://ubuntuforums.org/showthread.php?t=214872
    Please don't create duplicate threads, it dilutes the community's effort to help you.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •