OpenMP + Pthreads problem

General OpenMP discussion

OpenMP + Pthreads problem

Postby hariss » Wed Feb 20, 2008 10:14 am

Hi everybody,

I have a program that uses pthreads for multitasking. I want to use OpenMP for making some of these threads to perform faster (1 OMP parallel section in main(), 1 OMP parallel section in one of the thread's function). However, when I use OpenMP's parallel sections in more than 1 thread, I generally experience deadlocks! Sometimes it works, sometimes the program freezes when entering the parallel section of the thread's function.

- I set OMP_DYNAMIC to TRUE for being able to use omp_set_num_threads() function.
- I am using gcc-4.2.2 with openmp support

If I use OpenMP parallelism just in the main(), it works without any problem. If I also use it in the thread's function in addition to main(), most of the time, deadlock occurs. It seems that if more than one threads uses OpenMP simultaneously deadlock occurs.

Each of these threads will use the same number of OpenMP threads, and they run asynchronously. There is no synchronization between them. What can be the source of the problem?



Re: OpenMP + Pthreads problem

Postby ejd » Wed Feb 20, 2008 10:34 am

There is nothing in the OpenMP spec about whether or not pthreads and OpenMP should work together. Some implementations allow them to - others don't. There was another post (Mixing OpenMP and pthreads) a while back with a similar question (spawning pthreads from OpenMP regions), where the code didn't seem to quite work. I didn't see an answer to whether they could in theory work together. You might want to post this question on a gcc forum since there would most likely be a better chance of a gcc expert knowing the implementation details.
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am

Re: OpenMP + Pthreads problem

Postby Anders Brander » Tue Aug 19, 2008 2:14 pm

I believe this is a known limitation in current gcc :(

Please see
Anders Brander

Return to Using OpenMP

Who is online

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