[mpiwg-rma] Fence + threads
Dave Goodell (dgoodell)
dgoodell at cisco.com
Fri Jun 20 12:46:39 CDT 2014
On Jun 20, 2014, at 11:16 AM, "Balaji, Pavan" <balaji at anl.gov> wrote:
> Is the following code correct? Two threads of a process both do the following:
> Collectives are not allowed on the same communicator simultaneously. But we don’t say anything similar for windows.
As I read it, it should be fine according to the standard as long as you haven't specified any assertions that would cause you to be lying to the implementation.
When we don't specifically disallow concurrent multithreaded operations, then the general threading text seems to allow this. See MPI-3, p.483, l.1-11:
The two main requirements for a thread-compliant implementation are listed below.
1. All MPI calls are thread-safe, i.e., two concurrently running threads may make MPI calls and the outcome will be as if the calls executed in some order, even if their execution is interleaved.
2. Blocking MPI calls will block the calling thread only, allowing another thread to execute, if available. The calling thread will be blocked until the event on which it is waiting occurs. Once the blocked communication is enabled and can proceed, then the call will complete and the thread will be marked runnable, within a finite time. A blocked thread will not prevent progress of other runnable threads on the same process, and will not prevent them from executing MPI calls.
So, absent some external inter-thread synchronization, it will be undefined exactly which epoch the MPI_PUTs end up in.
More information about the mpiwg-rma