OpenMP thread stops

General OpenMP discussion

OpenMP thread stops

Postby guyColumbus » Wed Oct 10, 2012 3:16 pm

Hi - I am using OpenMP to parallelize a Do loop

If the Do loop extends from s=1 to s=50 iterations, and there are two threads, Fortran automatically divides the iterations into two blocks s=1 to s=25 for one thread and s=26 to s=50 for another thread.

Due to race condition, one thread finishes faster than the other thread. So lets say 1st thread finishes s=25 , when the other thread is at s = 43, both the threads just stop. The second thread should have continued on till it reaches s=50. But it doesnt, it stops completely. It looks like the unfinished thread is waiting for something.. Not sure what.

Can you please help me out ?

Thanks
guyColumbus
 
Posts: 5
Joined: Wed Oct 10, 2012 3:04 pm

Re: OpenMP thread stops

Postby baddylover » Wed Oct 10, 2012 6:22 pm

I'm not an expert on openmp but just a user with very little experience.

In my programs parallel do loops work as expected. I also use
!$OMP CRITICAL
......
!$OMP FLUSH(......)
......
!$OMP END CRITICAL
within parallel do loop without a problem.
baddylover
 
Posts: 25
Joined: Thu Apr 07, 2011 6:17 am

Re: OpenMP thread stops

Postby guyColumbus » Wed Oct 10, 2012 8:12 pm

Thanks.. Just an update - The issue I notice is to do with 'Pardiso'. For some reason pardiso stops running when one of the thread has completed its set of iterations. The other thread reaches the part of the code where pardiso is called upon and just stops without giving any error.
guyColumbus
 
Posts: 5
Joined: Wed Oct 10, 2012 3:04 pm

Re: OpenMP thread stops

Postby ftinetti » Thu Oct 11, 2012 5:18 am

Hi,

Due to race condition, one thread finishes faster than the other thread. So lets say 1st thread finishes s=25 , when the other thread is at s = 43, both the threads just stop. The second thread should have continued on till it reaches s=50. But it doesnt, it stops completely. It looks like the unfinished thread is waiting for something.. Not sure what.


I'd suggest:
  • 1- Fix the code so you do not have race condition/s.
  • 2- Use the environment variable OMP_WAIT_POLICY (set to passive)
Without fixing the race condition/s is hard to say anything else for sure.

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

Re: OpenMP thread stops

Postby guyColumbus » Thu Oct 11, 2012 7:31 am

hmm.. I must have used the wrong phrase there, there is no error from the 'race condition'. I just meant that some iterations will run faster than the other ones so that the first thread completes its quota of iterations faster than the second thread.
guyColumbus
 
Posts: 5
Joined: Wed Oct 10, 2012 3:04 pm

Re: OpenMP thread stops

Postby __Sayan__ » Thu Oct 11, 2012 8:36 am

Hello,

Since your iterations are non-uniform, you could check the scheduling policies (dynamic, static, runtime, guided, auto[some compilers]), since that could make an impact to your performance. Also, not knowing about your code, I think it is kind of an unbalanced parallel one, so you could look into
Code: Select all
!$OMP TASK
clauses (https://iwomp.zih.tu-dresden.de/downloa ... -tasks.pdf).

Regards,
Sayan
__Sayan__
 
Posts: 18
Joined: Fri Jun 18, 2010 9:34 am

Re: OpenMP thread stops

Postby ftinetti » Thu Oct 11, 2012 11:51 am

Hi,,

hmm.. I must have used the wrong phrase there, there is no error from the 'race condition'.


I see, "race condition" in the context of concurrent processing is basically a bug. As for different worksharing scheduling among threads you can take a look at several schedule clause options.

Does any thing change when you set OMP_WAIT_POLICY to passive?

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

Re: OpenMP thread stops

Postby MarkB » Thu Oct 11, 2012 12:55 pm

Are you calling PARDISO from inside the parallel loop? It is not entirely clear from the manual, but I suspect that, since PARDISO uses OpenMP internally, this type of usage is not supported.
MarkB
 
Posts: 481
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh

Re: OpenMP thread stops

Postby MarkB » Thu Oct 11, 2012 12:57 pm

MarkB wrote:It is not entirely clear from the manual, but I suspect that, since PARDISO uses OpenMP internally, this type of usage is not supported.


Or at least, you need to take care that the arguments passed to PARDISO are not shared between threads.....
MarkB
 
Posts: 481
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh

Re: OpenMP thread stops

Postby __Sayan__ » Fri Oct 12, 2012 7:34 am

As MarkB commented, Pardiso uses OpenMP (or mixed OpenMP+MPI) internally. You could re-check your passed arguments to Pardiso routines. If you are just calling Pardiso routines in a loop, then perhaps there is no need to parallelize the loop, plus as far as I know nested parallelism might be disabled in a compiler, in that case the inner loop would execute in a serial fashion.

Regards,
Sayan
__Sayan__
 
Posts: 18
Joined: Fri Jun 18, 2010 9:34 am

Next

Return to Using OpenMP

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot], Yahoo [Bot] and 19 guests