Friends don't let friends leak MPI_Requests

3,624 views
3,381 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!

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,624
On SlideShare
0
From Embeds
0
Number of Embeds
1,675
Actions
Shares
0
Downloads
11
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

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.

×