20
MPI_MPROBE is Good For You MPI_MPROBE: It’s Good for You Jeff Squyres

MPI_Mprobe is good for you

Embed Size (px)

Citation preview

Page 1: MPI_Mprobe is good for you

MPI_MPROBE is Good For You 1

MPI_MPROBE: It’s Good for You

Jeff Squyres

Page 2: MPI_Mprobe is good for you

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

Page 3: MPI_Mprobe is good for you

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

Page 4: MPI_Mprobe is good for you

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

Page 5: MPI_Mprobe is good for you

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

Page 6: MPI_Mprobe is good for you

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

Page 7: MPI_Mprobe is good for you

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

Page 8: MPI_Mprobe is good for you

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

Page 9: MPI_Mprobe is good for you

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

Page 10: MPI_Mprobe is good for you

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

Page 11: MPI_Mprobe is good for you

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

Page 12: MPI_Mprobe is good for you

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)

Page 13: MPI_Mprobe is good for you

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

Page 14: MPI_Mprobe is good for you

MPI_MPROBE is Good for You 14

Another Useful Case

Probe to find the size of an

incoming message

MPI_PROBE(…);

Page 15: MPI_Mprobe is good for you

MPI_MPROBE is Good for You 15

Another Useful Case

But malloc takes some time to

complete

MPI_PROBE(…);

buf = malloc(incoming_size);

Malloctakessometime

Page 16: MPI_Mprobe is good for you

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

Page 17: MPI_Mprobe is good for you

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!

Page 18: MPI_Mprobe is good for you

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

Page 19: MPI_Mprobe is good for you

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

Page 20: MPI_Mprobe is good for you

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