[mpiwg-sessions] [EXTERNAL] Question on MPI_THREAD_FUNNELED

Pritchard Jr., Howard howardp at lanl.gov
Fri Feb 19 09:17:12 CST 2021


HI Martin,

Open MPI internally behaves as if there are only either MPI_THREAD_SERIALIZED or MPI_THREAD_MULTIPLE.
Except for odds and ends like supporting the MPI_Is_thread_main, it doesn’t behave differently whether the application
requests for MPI_THREAD_SINGLE, MPI_THREAD_FUNNELED, or MPI_THREAD_SERIALIZED.

Now as for the prototype, there is a block of common resources used by all MPI “instances” – what the developer of the prototype was calling “sessions”, and it is initialized either for thread safety or not.  So its whoever makes the first call to MPI_Session_init of MPI_Init/MPI_Init_thread which determines the thread support provided for subsequent calls to either MPI_Session_init or MPI_Init_thread, etc.

I suspect other MPI implementations would have a similar set of common resources that would have to be shared by all MPI sessions.

In some ways from the implementor’s point of view this is not that important as the only sane thing from a software engineering point of view is if you know your code may be operating in a multi-threaded environment, you should code it that way from the start.  In the Open MPI code there are many places where, for example, counters are incremented/decremented using atomic ops irrespective of what the application asked for in terms of thread support.  Indeed, we several major releases ago removed the option to build Open MPI for thread serial only, as much of the plumbing code now assumes it can be invoked concurrently from multiple threads.

Here's my thoughts on the suggestions:


·         We actually deprecate funneled and serialized  - this would be my preferred option but I thought Jim Dinan already fought that battle and lost for MPI 4 – but maybe I’m not remembering right

·         We don’t deprecate, but state that they should no longer be returned in the session model – that would be easy enough for 4.1

·         We isolate sessions against each other – not sure I understand this one


Howard

From: mpiwg-sessions <mpiwg-sessions-bounces at lists.mpi-forum.org> on behalf of MPI Sessions working group <mpiwg-sessions at lists.mpi-forum.org>
Reply-To: MPI Sessions working group <mpiwg-sessions at lists.mpi-forum.org>
Date: Thursday, February 18, 2021 at 3:43 PM
To: Daniel Holmes <danholmes at chi.scot>
Cc: Martin Schulz <schulzm at in.tum.de>, MPI Sessions working group <mpiwg-sessions at lists.mpi-forum.org>
Subject: Re: [mpiwg-sessions] [EXTERNAL] Question on MPI_THREAD_FUNNELED

Agreed – not sure this comes across in the text, though. We may want to think about clarifying this in 4.1.

Howard, is this how the Open MPI works already or what impact do you expect?

Thanks,

Martin


--
Prof. Dr. Martin Schulz, Chair of Computer Architecture and Parallel Systems
Department of Informatics, TU-Munich, Boltzmannstraße 3, D-85748 Garching
Member of the Board of Directors at the Leibniz Supercomputing Centre (LRZ)
Email: schulzm at in.tum.de



From: Daniel Holmes <danholmes at chi.scot>
Date: Thursday, 18. February 2021 at 23:13
To: Martin Schulz <schulzm at in.tum.de>
Cc: MPI Sessions working group <mpiwg-sessions at lists.mpi-forum.org>
Subject: Re: [mpiwg-sessions] [EXTERNAL] Question on MPI_THREAD_FUNNELED

Hi Martin,

Your third option, isolation, is (and has been for years) the intent of sessions.

Cheers,
Dan.


18 Feb 2021 22:04:51 Martin Schulz <schulzm at in.tum.de>:
Hi Dan,


I agree – single has a good reason and I think would be fine – in this case the clause that the first init anywhere may dictate thread mode anymore else would indicate to other session inits later on that only single is now supported.


I am wondering about serialized and funneled, though: for funneled, it kind of leads to a requirement that session_init can only be called on the same thread again. If not, it should actually fail, as nothing else makes sense (if two session inits on different threads return funneled). For serialized, it requires threads know of each other so they can synchronize, which is against what we wanted to achieve.


I actually only see three options (perhaps there are more):

·         We actually deprecate funneled and serialized

·         We don’t deprecate, but state that they should no longer be returned in the session model

·         We isolate sessions against each other


In the latter case, returning thread funneled means that MPI calls associated with objects derived from that session have to be called from that thread. For serialized it would disallow two MPI calls at the same time from two threads, if they both use an object derived from the same session. Across sessions there would be no restrictions.


I kind of like the latter one, as it goes with the spirit of session, but I wonder what implementers say to that.


Martin








--
Prof. Dr. Martin Schulz, Chair of Computer Architecture and Parallel Systems
Department of Informatics, TU-Munich, Boltzmannstraße 3, D-85748 Garching
Member of the Board of Directors at the Leibniz Supercomputing Centre (LRZ)
Email: schulzm at in.tum.de






From: mpiwg-sessions <mpiwg-sessions-bounces at lists.mpi-forum.org> on behalf of Dan Holmes via mpiwg-sessions <mpiwg-sessions at lists.mpi-forum.org>
Reply-To: MPI Sessions working group <mpiwg-sessions at lists.mpi-forum.org>
Date: Thursday, 18. February 2021 at 21:07
To: mpiwg-sessions <mpiwg-sessions at lists.mpi-forum.org>
Cc: Dan Holmes <danholmes at chi.scot>
Subject: [mpiwg-sessions] [EXTERNAL] Question on MPI_THREAD_FUNNELED


Hi Martin,


This is an interesting argument for disallowing use of MPI_THREAD_SINGLE and MPI_THREAD_FUNNELED with the sessions model (and with the world model in combination with the sessions model).


Modern MPI libraries effectively only have MPI_THREAD_SERIALIZED and MPI_THREAD_MULTIPLE anyway.


However, a single thread could create a bunch of sessions and initialise the world model and comply with MPI_THREAD_SINGLE and/or MPI_THREAD_FUNNELED.


Two libraries might be called by a single thread and thereby be thread compliant.


So, prohibiting these thread support levels seems too severe.

Library writers need to document the restrictions they place on the main application and all the other libraries that it uses. If a library tells MPI it will only use a particular thread then the caller into that library must comply, etc.

An MPI library is free to upgrade later (if it is capable of that) without telling already-initialised sessions (because superset) - except for MPI_THREAD_SINGLE (there can be only one). It is also free to return a lower provided than the requested.

The only problem occurs if two distinct threads ask for MPI_THREAD_FUNNELED concurrently and MPI provides MPI_THREAD_FUNNELED to one of them but is not able to upgrade internally - it is then stuck for when the second thread makes its request.

One of the main points of the isolation between threads was that no cross-session protection was needed. Thus, session S1 funnelled onto thread T1 and S2 funnelled onto T2 should be easy to implement, even though that scenario is not currently possible with MPI-3.1 and no-one has actually coded it yet.

Cheers,
Dan.
—
Dr Daniel Holmes PhD
Executive Director
Chief Technology Officer
CHI Ltd
danholmes at chi.scot<mailto:danholmes at chi.scot>



Hi Howard,



>>    I recall we decided to leave the behavior of thread support level when using multiple sessions/world model up to the implementation.   However, in the case of MPI_THREAD_FUNNELED we should probably add a blurb about not doing this in the advice to users in the Session Creation and Destruction Methods.



I think the problem also appears if the original MPI_Init_thread uses FUNNELED. We probably need to add something there as well.



>>    My first guess based on the openmpi prototype is that if one session is initialized with funneled, then all subsequent created sessions or mpi init thread will be supported at funnel level.



That kind of makes sense - but what happens if the second Session_Init is then on another thread? The funneled refers to a different thread.



>>    For your thread serialized question I would say the answer is no, unless under the covers the implementation is always working in effectively thread multiple mode.



Hmm, I understand the motivation and implementation implications, but this would kill the isolation then, which is also not good. Also, if two libraries have separate sessions, it is often not even possible to avoid this.



Almost seems like we should deprecate funneled and serialized.



Another item to cover next Monday __.



Martin


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mpi-forum.org/pipermail/mpiwg-sessions/attachments/20210219/ee1e8532/attachment-0001.html>


More information about the mpiwg-sessions mailing list