My problem is that I get no parallelization with openMP.
My system: ubuntu 11.4 Intel(R) Core(TM) i5 CPU M 430 @ 2.27GHz
Compiler: g++ Version: 4.5.2 with flag -fopenmp
With this code I see that there is only one thread:
int nthreads, tid, procs, maxt, inpar, dynamic, nested;
// Start parallel region
#pragma omp parallel private(nthreads, tid) {
// Obtain thread number
tid = omp_get_thread_num();
// Only master thread does this
if (tid == 0)
{
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();
dynamic = omp_get_dynamic();
nested = omp_get_nested();
// 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);
printf("Dynamic threads enabled? = %d\n", dynamic);
printf("Nested parallelism supported? = %d\n", nested);
}
}
because I see the following output:
Number of processors = 4
Number of threads = 1
Max threads = 4
In parallel? = 0
Dynamic threads enabled? = 0
Nested parallelism supported? = 0
What is the problem?
Can some one help, please?
Your code works for me on Ubuntu 11.04 with the g++ compiler version 4.5.2 however I had to change
#pragma omp parallel private(nthreads, tid) {
to
#pragma omp parallel private(nthreads, tid)
{
for it to compile successfully.
EDIT: If fixing the syntax doesn't work my next idea would be to ask what is the exact command that you are using to compile code?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With