Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Always MPI_TEST orMPI_WAITJeff SquyresThe MPI GuyDecember 2012
void sender(void) {      void receiver(void) {  MPI_Request request;     int ack;  int ack;                 /* … */  /* … ...
void sender(void) {      void receiver(void) {  MPI_Request request;     int ack;  int ack;                 /* … */  /* … ...
void sender(void) {                      void receiver(void) {  MPI_Request request;                     int ack;  int ack...
ButWHY?
A. Because MPI says so.
But I don’t   WANT TO!
A. Because MPI says so.Don’t fight the Law, son.The Law will always win.
B. Because you’ll leak resources
Consider what happens               when you Isend…MPI_Isend(buffer, …, &request);
Consider what happens               when you Isend…MPI_Isend(buffer, …, &request);                                        ...
Consider what happens               when you Isend…MPI_Isend(buffer, …, &request);                                        ...
Consider what happens               when you Isend…                                                     resourcesMPI_Isend...
Consider what happens               when you Isend…MPI_Isend(buffer, …, &request);                                        ...
Consider what happens               when you Isend…MPI_Isend(buffer, …, &request);                                        ...
Consider what happens               when you Isend…MPI_Isend(buffer, …, &request);                                        ...
Consider what happens               when you Isend…MPI_Isend(buffer, …, &request);                                        ...
Consider what happens               when you Isend…MPI_Isend(buffer, …, &request);                                        ...
Consider what happens               when you Isend…MPI_Isend(buffer, …, &request);                                        ...
Consider what happens               when you Isend…MPI_Isend(buffer, …, &request);MPI_Wait(&request, …);                  ...
Consider what happens               when you Isend…MPI_Isend(buffer, …, &request);MPI_Wait(&request, …);                  ...
Consider what happens               when you Isend…MPI_Isend(buffer, …, &request);MPI_Wait(&request, …);                Th...
Does it reallyMATTER?
Individual MPI_RequestsOne tinyrequest          may be small
Particularly compared toOne tinyrequest    how much RAM is available           All of RAM
…but every MPI process  is making requestsAll of RAM
…and they might be making   LOTS of requestsAll of RAM
You might fill RAM slowly  …but you’ll still fill itAll of RAM
Worse: hardware resources might notbe released until the request is complete                                isend_request ...
Meaning: it’s not just abundant RAM that you’re consuming                           resources
Communication hardware = expensiveTherefore, far less resources available   resources   resources   resources   resources ...
Compare: RAM vs.communication hardware resourcesAll of RAM
Compare: RAM vs.communication hardware resources   Wasting this may be forgivableAll of RAM
Compare: RAM vs.communication hardware resources   Wasting this may be forgivable                                    Wasti...
void sender(void) {        void receiver(void) {  MPI_Request request;       int ack;  int ack;                   /* … */ ...
void sender(void) {                       void receiver(void) {  MPI_Request request;                      int ack;  int a...
Friends don’t let friendsleak MPI_Requests
Thank you.
Friends don't let friends leak MPI_Requests
Upcoming SlideShare
Loading in …5
×

Friends don't let friends leak MPI_Requests

4,066 views

Published on

How leaking MPI MPI_Requests hurts your application. Always be sure to use an MPI TEST or WAIT operation on your pending MPI_Requests!

  • Be the first to comment

Friends don't let friends leak MPI_Requests

  1. 1. Always MPI_TEST orMPI_WAITJeff SquyresThe MPI GuyDecember 2012
  2. 2. void sender(void) { void receiver(void) { MPI_Request request; int ack; int ack; /* … */ /* … */ MPI_Recv(buffer, …); MPI_Isend(buffer, …, MPI_Send(&ack, …); &request); } MPI_Recv(&ack, …);}
  3. 3. void sender(void) { void receiver(void) { MPI_Request request; int ack; int ack; /* … */ /* … */ MPI_Recv(buffer, …); MPI_Isend(buffer, …, MPI_Send(&ack, …); &request); } MPI_Recv(&ack, …);}
  4. 4. void sender(void) { void receiver(void) { MPI_Request request; int ack; int ack; /* … */ /* … */ MPI_Recv(buffer, …); MPI_Isend(buffer, …, MPI_Send(&ack, …); &request); } MPI_Recv(&ack, …);} Must (eventually) use an MPI TEST or WAIT operation on the pending request, even if you “know” that it has already completed
  5. 5. ButWHY?
  6. 6. A. Because MPI says so.
  7. 7. But I don’t WANT TO!
  8. 8. A. Because MPI says so.Don’t fight the Law, son.The Law will always win.
  9. 9. B. Because you’ll leak resources
  10. 10. Consider what happens when you Isend…MPI_Isend(buffer, …, &request);
  11. 11. Consider what happens when you Isend…MPI_Isend(buffer, …, &request); isend_request MPI allocates a request
  12. 12. Consider what happens when you Isend…MPI_Isend(buffer, …, &request); isend_request MPI allocates a request MPI performs the send
  13. 13. Consider what happens when you Isend… resourcesMPI_Isend(buffer, …, &request); isend_request MPI allocates a request MPI performs the send …which may include allocating additional resources
  14. 14. Consider what happens when you Isend…MPI_Isend(buffer, …, &request); isend_request resources MPI allocates a request MPI performs the send …which may include allocating additional resources Those resources are attached to the request
  15. 15. Consider what happens when you Isend…MPI_Isend(buffer, …, &request); isend_request resources The send eventually done
  16. 16. Consider what happens when you Isend…MPI_Isend(buffer, …, &request); isend_request resources The send eventually finishes The request is marked complete
  17. 17. Consider what happens when you Isend…MPI_Isend(buffer, …, &request); isend_request resources …but it’s still there!
  18. 18. Consider what happens when you Isend…MPI_Isend(buffer, …, &request); isend_request resources …but it’s still there! Eating valuable memory!
  19. 19. Consider what happens when you Isend…MPI_Isend(buffer, …, &request); isend_request resources …but it’s still there! Eating valuable memory! And possibly still holding on to valuable resources!
  20. 20. Consider what happens when you Isend…MPI_Isend(buffer, …, &request);MPI_Wait(&request, …); isend_request resources …until you invoke a TEST or WAIT operation that completes the request
  21. 21. Consider what happens when you Isend…MPI_Isend(buffer, …, &request);MPI_Wait(&request, …); resources Then the request is freed
  22. 22. Consider what happens when you Isend…MPI_Isend(buffer, …, &request);MPI_Wait(&request, …); Then the request is freed …including any resources that weren’t previously released
  23. 23. Does it reallyMATTER?
  24. 24. Individual MPI_RequestsOne tinyrequest may be small
  25. 25. Particularly compared toOne tinyrequest how much RAM is available All of RAM
  26. 26. …but every MPI process is making requestsAll of RAM
  27. 27. …and they might be making LOTS of requestsAll of RAM
  28. 28. You might fill RAM slowly …but you’ll still fill itAll of RAM
  29. 29. Worse: hardware resources might notbe released until the request is complete isend_request Remember these? resources
  30. 30. Meaning: it’s not just abundant RAM that you’re consuming resources
  31. 31. Communication hardware = expensiveTherefore, far less resources available resources resources resources resources resources resources resources resources resources resources resources resources resources resources resources resources resources resources resources resources resources resources resources resources resources resources resources resources
  32. 32. Compare: RAM vs.communication hardware resourcesAll of RAM
  33. 33. Compare: RAM vs.communication hardware resources Wasting this may be forgivableAll of RAM
  34. 34. Compare: RAM vs.communication hardware resources Wasting this may be forgivable Wasting this isAll of RAM a terrible idea
  35. 35. void sender(void) { void receiver(void) { MPI_Request request; int ack; int ack; /* … */ /* … */ MPI_Recv(buffer, …); MPI_Isend(buffer, …, MPI_Send(&ack, …); &request); } MPI_Recv(&ack, …); MPI_Wait(&request, …);}
  36. 36. void sender(void) { void receiver(void) { MPI_Request request; int ack; int ack; /* … */ /* … */ MPI_Recv(buffer, …); MPI_Isend(buffer, …, MPI_Send(&ack, …); &request); } MPI_Recv(&ack, …); MPI_Wait(&request, …);} If you “know” the send is already complete, the WAIT will likely be fast
  37. 37. Friends don’t let friendsleak MPI_Requests
  38. 38. Thank you.

×