Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: Re: [OMPI users] meaning of MPI_THREAD_*
From: Tim Prince (n8tm_at_[hidden])
Date: 2010-12-06 08:37:36

On 12/6/2010 3:16 AM, Hicham Mouline wrote:
> Hello,
> 1. MPI_THREAD_SINGLE: Only one thread will execute.
> Does this really mean the process cannot have any other threads at all, even if they doen't deal with MPI at all?
> I'm curious as to how this case affects the openmpi implementation?
> Essentially, what is the difference between MPI_THREAD_SINGLE and MPI_THREAD_FUNNELED?
> 2. In my case, I'm interested in MPI_THREAD_SERIALIZED. However if it's available, I can use MPI_THREAD_FUNNELED.
> What cmake flags do I need to enable to allow this mode?
> 3. Assume I assign only 1 thread in my program to deal with MPI. What is the difference between
> int MPI::Init_thread(MPI_THREAD_SINGLE)
> int MPI::Init_thread(MPI_THREAD_FUNNELED)
> int MPI::Init()
You're question is too broad; perhaps you didn't intend it that way.
Are you trying to do something which may work only with a specific
version of openmpi, or are you willing to adhere to portable practice?
I tend to believe what it says at

A call to MPI_INIT has the same effect as a call to MPI_INIT_THREAD with
a required = MPI_THREAD_SINGLE

You would likely use one of those if all your MPI calls are from a
single thread, and you don't perform any threading inside MPI. MPI
implementations vary on the extent to which a higher level of threading
than what is declared can be used successfully (there's no guarantee of
bad results if you exceed what was set by MPI_INIT). There shouldn't
be any bad effect from setting a higher level of thread support which
you never use.

I would think your question about cmake flags would apply only once you
chose a compiler. I have never seen anyone try mixing
auto-parallelization with MPI; that would require MPI_THREAD_MULTIPLE
but still appears unpredictable. MPI_THREAD_FUNNELED is used often with
OpenMP parallelization inside MPI.

Tim Prince