Friends don't let friends leak MPI_Requests

  • Published on
    12-May-2015

  • View
    1.927

  • Download
    0

Embed Size (px)

DESCRIPTION

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

Transcript

<ul><li>1.Always MPI_TEST orMPI_WAITJeff SquyresThe MPI GuyDecember 2012</li></ul> <p>2. void sender(void) {void receiver(void) {MPI_Request request; int ack;int ack; /* *//* */MPI_Recv(buffer, );MPI_Isend(buffer, , MPI_Send(&amp;ack, ); &amp;request);}MPI_Recv(&amp;ack, );} 3. void sender(void) {void receiver(void) {MPI_Request request; int ack;int ack; /* *//* */MPI_Recv(buffer, );MPI_Isend(buffer, , MPI_Send(&amp;ack, ); &amp;request);}MPI_Recv(&amp;ack, );} 4. void sender(void) {void receiver(void) {MPI_Request request; int ack;int ack; /* *//* */MPI_Recv(buffer, );MPI_Isend(buffer, , MPI_Send(&amp;ack, ); &amp;request);}MPI_Recv(&amp;ack, );} Must (eventually) use an MPI TEST or WAIT operation on the pending request, even if you know that it has already completed 5. ButWHY? 6. A. Because MPI says so. 7. But I dont WANT TO! 8. A. Because MPI says so.Dont fight the Law, son.The Law will always win. 9. B. Because youll leak resources 10. Consider what happens when you IsendMPI_Isend(buffer, , &amp;request); 11. Consider what happens when you IsendMPI_Isend(buffer, , &amp;request);isend_requestMPI allocates a request 12. Consider what happens when you IsendMPI_Isend(buffer, , &amp;request);isend_requestMPI allocates a requestMPI performs the send 13. Consider what happens when you Isend resourcesMPI_Isend(buffer, , &amp;request); isend_requestMPI allocates a requestMPI performs the sendwhich may include allocating additional resources 14. Consider what happens when you IsendMPI_Isend(buffer, , &amp;request); isend_requestresourcesMPI allocates a requestMPI performs the sendwhich may include allocating additional resourcesThose resources are attached to the request 15. Consider what happens when you IsendMPI_Isend(buffer, , &amp;request); isend_requestresourcesThe send eventually done 16. Consider what happens when you IsendMPI_Isend(buffer, , &amp;request); isend_requestresourcesThe send eventually finishesThe request is marked complete 17. Consider what happens when you IsendMPI_Isend(buffer, , &amp;request); isend_requestresourcesbut its still there! 18. Consider what happens when you IsendMPI_Isend(buffer, , &amp;request);isend_request resourcesbut its still there!Eating valuable memory! 19. Consider what happens when you IsendMPI_Isend(buffer, , &amp;request); isend_requestresourcesbut its still there!Eating valuable memory!And possibly still holding on to valuable resources! 20. Consider what happens when you IsendMPI_Isend(buffer, , &amp;request);MPI_Wait(&amp;request, ); isend_requestresourcesuntil you invoke a TESTor WAIT operation thatcompletes the request 21. Consider what happens when you IsendMPI_Isend(buffer, , &amp;request);MPI_Wait(&amp;request, );resourcesThen the request is freed 22. Consider what happens when you IsendMPI_Isend(buffer, , &amp;request);MPI_Wait(&amp;request, );Then the request is freedincluding any resources thatwerent previously released 23. Does it reallyMATTER? 24. Individual MPI_RequestsOne tinyrequestmay be small 25. Particularly compared toOne tinyrequesthow much RAM is available All of RAM 26. but every MPI processis making requestsAll of RAM 27. and they might be making LOTS of requestsAll of RAM 28. You might fill RAM slowlybut youll still fill itAll of RAM 29. Worse: hardware resources might notbe released until the request is completeisend_requestRemember these? resources 30. Meaning: its not just abundant RAM that youre consuming resources 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. Compare: RAM vs.communication hardware resourcesAll of RAM 33. Compare: RAM vs.communication hardware resources Wasting this may be forgivableAll of RAM 34. Compare: RAM vs.communication hardware resources Wasting this may be forgivableWasting this isAll of RAMa terrible idea 35. void sender(void) {void receiver(void) {MPI_Request request; int ack;int ack; /* *//* */MPI_Recv(buffer, );MPI_Isend(buffer, , MPI_Send(&amp;ack, ); &amp;request);}MPI_Recv(&amp;ack, );MPI_Wait(&amp;request, );} 36. void sender(void) { void receiver(void) {MPI_Request request;int ack;int ack;/* *//* */ MPI_Recv(buffer, );MPI_Isend(buffer, ,MPI_Send(&amp;ack, ); &amp;request); }MPI_Recv(&amp;ack, );MPI_Wait(&amp;request, );} If you know the send is already complete, the WAIT will likely be fast 37. Friends dont let friendsleak MPI_Requests 38. Thank you. </p>