OpenMP threads 100% cpu usage

General OpenMP discussion

OpenMP threads 100% cpu usage

Postby selu » Mon Jul 02, 2012 5:05 am

Hi guys,

I'm using OpenMP for couple of days ago, so i have a lot of things to learn yet, but it's very easy to use so far.

My only problem is probably more conceptual, cause i'm getting improved results and eveything is working as it should.

Unless in all the tests that i created, even if i set a parallel with single directive, one core (alternatily) will run at (e.g) 30% (the one that is processing my loop) and the others are at 99% ( obviously, processing nothing at all but consuming my other cores).

My question is : When i create a parallel team, the threads in the team will try to run as much they can, like a while(1)??

If not, how can i control that in a way that, non using threads will sleep till they really have something to do?

I want (sort of) to perform the pthread_cond_wait and cond_signal procedures.

Thank you in advance.
Pedro Silva
CoVii - Computer Vision Interaction
selu
 
Posts: 2
Joined: Sat Jun 30, 2012 7:45 am

Re: OpenMP threads 100% cpu usage

Postby ftinetti » Tue Jul 03, 2012 5:08 pm

Hi Pedro,

Unless in all the tests that i created, even if i set a parallel with single directive, one core (alternatily) will run at (e.g) 30% (the one that is processing my loop) and the others are at 99% ( obviously, processing nothing at all but consuming my other cores).

I'm curious, How do you know that the thread processing your loop is the one that uses 30% of a core?

My question is : When i create a parallel team, the threads in the team will try to run as much they can, like a while(1)??

Hmmm... I'm not sure what you are asking about... threads execute the code as defined in the program...

If not, how can i control that in a way that, non using threads will sleep till they really have something to do?

Maybe you can experiment with the environment variable OMP_WAIT_POLICY set to passive. By the way: compiler? computer? OS?

HTH,

Fernando.
ftinetti
 
Posts: 580
Joined: Wed Feb 10, 2010 2:44 pm

Re: OpenMP threads 100% cpu usage

Postby selu » Thu Jul 05, 2012 5:05 am

Hi Fernando,

Thank you very much for your reply.

1 . I'm curious, How do you know that the thread processing your loop is the one that uses 30% of a core?
I just shared my logical thought, which can be wrong. I said that cause if i create more tasks to do, that core will increase from 30 to 50 for instance and the other ones will keep running at 99%. And even worst, if i remove the parallel directive the value will be the same but splitted by the other threads.

2. Hmmm... I'm not sure what you are asking about... threads execute the code as defined in the program...
Sorry, if i'm not explaining it as i should.
I mean that, if you create a thread with a while(1); the thread will run the loop as much as it can, using 100% cpu, which is obvious.
In this case it seams that only one thread is performing something and the other ones are simply pushing cpu usage.
For instance, i created a parallel directive and get the id through omp_get_thread_num. I only do something if the thread number is 0 for instance, if(id == 0) then something. Shouldn't be the other threads "sleeping"? They still use 100% of my cpu. That is the weirdest thing.

3. Maybe you can experiment with the environment variable OMP_WAIT_POLICY set to passive. By the way: compiler? computer? OS?
That is a good thing that i didn't know. I tried to find something about this subject googling but nothing comes with OMP_WAIT_POLICY.
I'll try it and give you the feedback.

I'm using GNU compiler, a Dore 2Duo processor (which means that omp will use 4 threads) and Linux ( Gentoo distro ) OS.

If you see that it could be something else please share your thoughts cause they will be really apprecitated :)
Meanwhile, I'll give a try with the policy rule.

Thanks again,
Pedro
selu
 
Posts: 2
Joined: Sat Jun 30, 2012 7:45 am

Re: OpenMP threads 100% cpu usage

Postby ftinetti » Thu Jul 05, 2012 6:57 am

Hi Pedro,

You can read about OMP_WAIT_POLICY in the Spec and some (brief) comment at

https://computing.llnl.gov/tutorials/op ... tVariables

Fernando.
ftinetti
 
Posts: 580
Joined: Wed Feb 10, 2010 2:44 pm


Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 7 guests