Author Topic: pragma omp parallel  (Read 14832 times)

geospir87

  • Guest
pragma omp parallel
« on: October 22, 2008, 03:28:04 pm »
Hy. I need a little help. I installed codeblok on my ubuntu 8.04 and i tryed to compile a simple parallel program that uses 2 threads. It compiles but it shows an warning.

The code is:

#include <omp.h>
#include <stdio.h>

void main ()  {

int nthreads, tid;

#pragma omp parallel private(nthreads, tid)
  {

  tid = omp_get_thread_num();
  printf("Hello World from thread = %d\n", tid);
   if (tid == 0)
    {
          nthreads = omp_get_num_threads();
          printf("Number of threads = %d\n", nthreads);
    }

  }
}

By default it shuld say hello from 2 threads.

The warning is:

warning: ignoring #pragma omp parallel


It always uses only one thread. I tried to set a difrent numbre of threads using omp_set_num_thread(10) but still the same warning.
I set the compiler to add -fopenmp when comileing but the warning persist and the result is the same.

I compiled and runned the source code in the command line and it all works perfectly.

Can anybody tell me how to setup codebloks so that it doesn't ingore #pragma omp paralle.

Thanks George!


Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: pragma omp parallel
« Reply #1 on: October 22, 2008, 03:45:49 pm »
Has little, if anything to do with Code::Blocks. This is a message coming from the compiler.

You may want to ask on the Ubuntu forums how to set up OMP so it works, maybe there's a different flavour of gcc you have to install, or something.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline dpu

  • Single posting newcomer
  • *
  • Posts: 3
Re: pragma omp parallel
« Reply #2 on: October 22, 2008, 04:07:14 pm »
Double check the compiler flags Code::Block is setting by default.  If you set Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line" the log screen will give you the exact command line Code::Blocks is using to build your code.

geospir87

  • Guest
Re: pragma omp parallel
« Reply #3 on: October 22, 2008, 11:13:28 pm »
Solved it. When comileing in Code::Block the -fopenmp option whas not present in the command line. In builder option->other i added -fopenmp and all is well. Thx for all your help. Topic Closed