Only uses 2 processors?

General OpenMP discussion

Only uses 2 processors?

Postby daviddoria » Fri May 23, 2008 11:03 am

I have an 8 core server that I am trying to run this loop on:

omp_set_num_threads(8);
#pragma omp parallel for
for(int testcol = 0; testcol < TestScan.getThetaPoints(); testcol++)

However, it seems to only ever get to 199% of the cpu, which means it's only using 2 of them. Why will it not use them all?

Thanks,

Dave
daviddoria
 

Re: Only uses 2 processors?

Postby daviddoria » Fri May 23, 2008 11:05 am

I forgot to mention it says this when I compile:

Estimation.cpp(85): warning #1433: OpenMP for-test may not conform
for(int testcol = 0; testcol < TestScan.getThetaPoints(); testcol++)
^

Estimation.cpp(84) : (col. 2) remark: OpenMP DEFINED LOOP WAS PARALLELIZED.
daviddoria
 
Posts: 21
Joined: Fri May 23, 2008 11:03 am

Re: Only uses 2 processors?

Postby ejd » Fri May 23, 2008 11:27 am

One possible reason is that you might have OMP_DYNAMIC set to "true". This would mean that the implementation is free to change the number of processors being used. Try calling OMP_SET_DYNAMIC(0) before the call to OMP_SET_NUM_THREADS and see what happens. Or you could set the enviornment variable OMP_DYNAMIC to "FALSE".
ejd
 
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am

Re: Only uses 2 processors?

Postby daviddoria » Fri May 23, 2008 11:30 am

ok i'll try that - what about that warning though? I changed something slightly and now it still gives the warning but then doesnt actually say
remark: OpenMP DEFINED LOOP WAS PARALLELIZED.

anymore.

Any clues?
daviddoria
 
Posts: 21
Joined: Fri May 23, 2008 11:03 am

Re: Only uses 2 processors?

Postby ejd » Fri May 23, 2008 11:51 am

It was only a warning and I believe that it was okay (though I am not an Intel compiler expert). If you look at Section 2.5.1 Loop Construct (in the version 3.0 spec - though the restriction is also in the previous specs), you will see listed under restrictions:

• The values of the loop control expressions of the loops associated with the loop directive must be the same for all the threads in the team.

The warning is most likely being generated because the end condition ( < TestScan.getThetaPoints) can not be verified at compile time to be the same for all threads. You can verify this by changing the program to something like:

Code: Select all
endCond = TestScan.getThetaPoints();
#pragma omp parallel for
for(int testcol = 0; testcol < endCond; testcol++)

If you are not seeing the remark about the OpenMP defined loop being parallelized, then there is a good chance it wasn't. That is a problem.
Last edited by ejd on Fri May 23, 2008 12:16 pm, edited 1 time in total.
ejd
 
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am

Re: Only uses 2 processors?

Postby daviddoria » Wed Aug 13, 2008 11:35 pm

excellent!

int NumCols = GoodCols.size();
#pragma omp parallel for num_threads(8)
for(int testcol = 0; testcol < NumCols; testcol++)


works SO fast haha and also now that it works doesn't give that warning and it DOES say that it parallelized the loop when I compile.

Thanks!!
daviddoria
 
Posts: 21
Joined: Fri May 23, 2008 11:03 am


Return to Using OpenMP

Who is online

Users browsing this forum: Google [Bot] and 2 guests