mpi_mprobe is good for you
TRANSCRIPT
MPI_MPROBE is Good For You 1
MPI_MPROBE: It’s Good for You
Jeff Squyres
MPI_MPROBE is Good for You 2
Regular MPI_PROBE
Checks to see if a matching message has arrived
Inco
min
g m
essa
ge q
ueue
Tim
e
Tag: 3Source: 14Comm. ID: 32
Tag: 9Source: 94Comm. ID: 17
Tag: 9Source: 67Comm. ID: 17
MPI_MPROBE is Good for You 3
Regular MPI_PROBE
Checks to see if a matching message has arrived
MPI_PROBE looking for: Tag 9, ANY_SOURCE, COMM ID 17
Inco
min
g m
essa
ge q
ueue
Tim
e
Tag: 3Source: 14Comm. ID: 32
Tag: 9Source: 94Comm. ID: 17
Tag: 9Source: 67Comm. ID: 17
MPI_MPROBE is Good for You 4
Regular MPI_PROBE
Checks to see if a matching message has arrived
MPI_PROBE looking for: Tag 9, ANY_SOURCE, COMM ID 17
Inco
min
g m
essa
ge q
ueue
Tim
e
Tag: 3Source: 14Comm. ID: 32
Tag: 9Source: 94Comm. ID: 17
Tag: 9Source: 67Comm. ID: 17
Match
MPI_MPROBE is Good for You 5
MPI_PROBE Succeeded
Now issue a receiveto actually get the message
MPI_RECV(…, tag=9, src=94, comm=17, …)
Inco
min
g m
essa
ge q
ueue
Tim
e
Tag: 3Source: 14Comm. ID: 32
Tag: 9Source: 94Comm. ID: 17
Tag: 9Source: 67Comm. ID: 17
Message is removedfrom incoming queue
MPI_MPROBE is Good for You 6
Race Condition
…but what if another MPIthread issues the receive first?
MPI_RECV(…, tag=9, src=ANY_SOURCE, comm=17) In
com
ing
mes
sage
que
ue
Tim
e
Tag: 3Source: 14Comm. ID: 32
Tag: 9Source: 67Comm. ID: 17
Tag: 9Source: 94Comm. ID: 17
MPI_MPROBE is Good for You 7
Race Condition
Inco
min
g m
essa
ge q
ueue
Tim
e
Tag: 3Source: 14Comm. ID: 32
Tag: 9Source: 67Comm. ID: 17
MPI_RECV(…, tag=9, src=94, comm=17, …)
In this case, your receive willend up unexpectedly blocking (!)
Blocked waitingfor a matching message
MPI_MPROBE is Good for You 8
Race Condition
Inco
min
g m
essa
ge q
ueue
Tim
e
Tag: 3Source: 14Comm. ID: 32
Tag: 9Source: 94Comm. ID: 17
MPI_RECV(…, tag=9, src=94, comm=17, …)
If / when the receive finally completes,it’s not the message you probed
Tag: 9Source: 67Comm. ID: 17
MPI_MPROBE is Good for You 9
MPI_MPROBE
Fixes this race condition
When a message is successfully probed,it is removed from the matching queue
MPROBE = Match + probe
MPI_MPROBE is Good for You 10
MPI_MPROBE
Inco
min
g m
essa
ge q
ueue
Tim
e
Tag: 3Source: 14Comm. ID: 32
Tag: 9Source: 94Comm. ID: 17
Tag: 9Source: 67Comm. ID: 17
MPI_MPROBE looking for: Tag 9, ANY_SOURCE, COMM ID 17
MPI_MPROBE is Good for You 11
MPI_MPROBE
When the match occurs, messageis removed from the incoming queue
Inco
min
g m
essa
ge q
ueue
Tim
e
Tag: 3Source: 14Comm. ID: 32
Tag: 9Source: 67Comm. ID: 17
MPI_MPROBE looking for: Tag 9, ANY_SOURCE, COMM ID 17
Tag: 9Source: 94Comm. ID: 17
MPI_MPROBE is Good for You 12
MPI_MPROBE
Other probes / receives will no longermatch this message
Inco
min
g m
essa
ge q
ueue
Tim
e
Tag: 3Source: 14Comm. ID: 32
Tag: 9Source: 67Comm. ID: 17
Tag: 9Source: 94Comm. ID: 17
MPI_RECV(…, tag=9, src=ANY_SOURCE, comm=17)
MPI_MPROBE is Good for You 13
MPI_MRECV
“Matched” receive is used to receivea message that was mprobed
Inco
min
g m
essa
ge q
ueue
Tim
e
Tag: 3Source: 14Comm. ID: 32
Tag: 9Source: 94Comm. ID: 17
MPI_MRECV(…, match_handle, …)
Guarantees that you getexactly the message you mprobed
MPI_MPROBE is Good for You 14
Another Useful Case
Probe to find the size of an
incoming message
MPI_PROBE(…);
MPI_MPROBE is Good for You 15
Another Useful Case
But malloc takes some time to
complete
MPI_PROBE(…);
buf = malloc(incoming_size);
Malloctakessometime
MPI_MPROBE is Good for You 16
Another Useful Case
But malloc takes some time to
complete
MPI_PROBE(…);
buf = malloc(incoming_size);
Malloctakessometime
Vulnerable race condition window
MPI_MPROBE is Good for You 17
Another Useful Case
But malloc takes some time to
complete
MPI_PROBE(…);
buf = malloc(incoming_size);
MPI_RECV(…)
Malloctakessometime
Vulnerable race condition window
Message could be stolen!
MPI_MPROBE is Good for You 18
Another Useful Case
Delays between MPROBE and
MPRECV do not matter
MPI_MPROBE(…);
buf = malloc(incoming_size);
MPI_MRECV(…)
Malloctakessometime
MPI_MPROBE is Good for You 19
Another Useful Case
Delays between MPROBE and
MPRECV do not matter
MPI_MPROBE(…);
buf = malloc(incoming_size);
MPI_MRECV(…)
Malloctakessometime Message cannot
be stolen
MPI_MPROBE is Good for You 20
Summary
• MPI_MPROBE eliminates race condition between probe and corresponding receive
• Good for: Event-based applications Mutli-threaded MPI applications When message lengths are unknown
• Strings, serialized objects, etc.• E.g., bindings for Perl, Python, Boost.mpi