User forums > Help

pragma omp parallel

(1/1)

geospir87:
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!

thomas:
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.

dpu:
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:
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

Navigation

[0] Message Index

Go to full version