Messages in OpenMP

General OpenMP discussion

Messages in OpenMP

Postby Ibai Arrizabalaga » Mon Mar 31, 2008 2:58 am

Hi all,
I'm new on OpenMp and i would like to know if it's possible to make a communication between threads using messages in OpenMP. I've been reading many manuals but didn't find anything.
Thanks for help.

Ibai
Ibai Arrizabalaga
 

Re: Messages in OpenMP

Postby ejd » Mon Mar 31, 2008 7:58 am

I am not sure what you mean by "messages" - except in an MPI context. I am assuming that you want to do something like a "producer-consumer" program. With OpenMP, since memory is shared, you can pass information between threads using shared memory. You have to use flush, which is the tricky part. Not many people really understand how to use it correctly. Even the OpenMP experts have problems doing it correctly - though it can be done.
ejd
 
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am

Re: Messages in OpenMP

Postby Ibai Arrizabalaga » Mon Mar 31, 2008 8:17 am

First of all thanks for the answer.
The thing is, that i need to have a master thread and some slave threads in a specific part of my code. I know that I shouldn't use threads and UI all together but in this case I need to show a modal window in the middle of all those slave threads. To do that, i need those threads to send a message to the master so it can show the window making the other slave threads wait until this window is close to avoid any error. I have solved it using windows PostThreadMessage() and WaitMessage() functions and it works correctly, but I would like to know if OpenMP has any specific function to do this.

I have another question too: If I want a part of code been executed only by master thread I have to use #pragma omp master{ code } , but is there any directive for making the master thread NOT to execute that part?

Thanks again, and sorry for my English.

Ibai Arrizabalaga
Ibai Arrizabalaga
 

Re: Messages in OpenMP

Postby aksh_pai » Tue Apr 01, 2008 5:28 am

Hi
even am new to openmp n have some doubts regarding it......may i know incwhich platform your working....

thanks

akshatha
aksh_pai
 
Posts: 2
Joined: Sat Mar 29, 2008 10:58 pm

Re: Messages in OpenMP

Postby Ibai Arrizabalaga » Tue Apr 01, 2008 5:58 am

I am working with Visual Studio 2005 C++
Ibai Arrizabalaga
 

Re: Messages in OpenMP

Postby ejd » Tue Apr 01, 2008 8:48 am

Ibai -

OpenMP doesn't have a facility to have multiple threads wait for some condition in a "nice" manner. You can use a shared variable and see if the value has changed, but it requires the threads to be active (and waste resource). You can also use locks, but then not all threads will restart immediately. This is a case where some functionality is really missing from OpenMP for it to really do what you want in a "nice" manner. You have to remember though, that OpenMP was originally designed to allow a user to add parallelism incrementally to their "workshared" program. Personally, I would say that this really meant loop based. With each release of a new spec, the types of programs that OpenMP can handle is increasing - but it still isn't the right thing for all types of parallel programs.

As for your second question, if you want a section of a program to be executed by all threads except the master thread then you have to do it with an if statement and a call to omp_get_thread_num().

Code: Select all
if (omp_get_thread_num() != 0) {
  ...
}
ejd
 
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am

Re: Messages in OpenMP

Postby aksh_pai » Tue Apr 01, 2008 10:13 pm

Hi
Can i know from whehe cai i get openmp download to load in eclipse.........

thanks
akshatha
aksh_pai
 
Posts: 2
Joined: Sat Mar 29, 2008 10:58 pm

Re: Messages in OpenMP

Postby Ibai Arrizabalaga » Sun Aug 17, 2008 12:29 am

ejd wrote:Ibai -

OpenMP doesn't have a facility to have multiple threads wait for some condition in a "nice" manner. You can use a shared variable and see if the value has changed, but it requires the threads to be active (and waste resource). You can also use locks, but then not all threads will restart immediately. This is a case where some functionality is really missing from OpenMP for it to really do what you want in a "nice" manner. You have to remember though, that OpenMP was originally designed to allow a user to add parallelism incrementally to their "workshared" program. Personally, I would say that this really meant loop based. With each release of a new spec, the types of programs that OpenMP can handle is increasing - but it still isn't the right thing for all types of parallel programs.


Thanks ejd, that's just what i wanted to know, if it was posible or no. After seeing this I think I'll have to continue using windows threads messages with OpenMP, it may not be the best solution but it works for me.
Thanks for the help.

Ibai


Last bumped by Anonymous on Sun Aug 17, 2008 12:29 am.
Ibai Arrizabalaga
 


Return to Using OpenMP

Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests