Advertisement
Guest User

Untitled

a guest
Jul 5th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* returns TRUE iff the request was sent on the vc */
  2. static inline int req_uses_vc(const MPID_Request* req, const MPIDI_VC_t *vc)
  3. {
  4.     MPIDI_VC_t *vc1;
  5.    
  6.     MPIDI_Comm_get_vc(req->comm, req->dev.match.parts.rank, &vc1);
  7.     return vc == vc1;
  8. }
  9.  
  10. /* returns TRUE iff the vc is part of the comm*/
  11. static inline int is_vc_in_comm(const MPIDI_VC_t *vc, const MPID_Comm *comm)
  12. {
  13.     int i;
  14.  
  15.     for (i = 0; i < comm->remote_size; ++i) {
  16.         MPIDI_VC_t *vc1;
  17.         MPIDI_Comm_get_vc(comm, i, &vc1);
  18.         if (vc == vc1)
  19.             return TRUE;
  20.     }
  21.     return FALSE;
  22. }
  23.  
  24. static inline void dequeue_and_set_error(MPID_Request* req,  MPID_Request* prev_req, int error)
  25. {
  26.     /* remove from queue */
  27.     if (recvq_posted_head == req)
  28.         recvq_posted_head = req->dev.next;
  29.     else
  30.         prev_req->dev.next = req->dev.next;
  31.     if (recvq_posted_tail == req)
  32.         recvq_posted_tail = prev_req;
  33.    
  34.     /* set error and complete */
  35.     req->status.MPI_ERROR = error;
  36.     MPIDI_CH3U_Request_complete(req);
  37. }
  38.  
  39.  
  40.  
  41. #undef FUNCNAME
  42. #define FUNCNAME MPIDU_Complete_posted_with_error
  43. #undef FCNAME
  44. #define FCNAME MPIU_QUOTE(FUNCNAME)
  45. int MPIDI_CH3U_Complete_posted_with_error(MPIDI_VC_t *vc)
  46. {
  47.     int mpi_errno = MPI_SUCCESS;
  48.     MPID_Request *req, *prev_req = NULL;
  49.     MPIDI_STATE_DECL(MPID_STATE_MPIDU_COMPLETE_POSTED_WITH_ERROR);
  50.  
  51.     MPIDI_FUNC_ENTER(MPID_STATE_MPIDU_COMPLETE_POSTED_WITH_ERROR);
  52.  
  53.     MPIU_THREAD_CS_ENTER(MSGQUEUE,);
  54.  
  55.     /* check each req to see if the vc is part of that communicator */
  56.     for (req = recvq_posted_head; req; prev_req = prev_req->dev.next, req = prev_req->dev.next) {
  57.        
  58.         if (req->dev.match.parts.rank != MPI_ANY_SOURCE) {
  59.             if (req_uses_vc(req, vc)) {
  60.                 int error = MPI_SUCCESS;
  61.                 MPIU_ERR_SET1(error, MPI_ERR_OTHER, "**comm_fail", "**comm_fail %d", vc->pg_rank);
  62.                 dequeue_and_set_error(req, prev_req, error);
  63.             }
  64.         } else {
  65.             /* We need to dequeue all anysources posted in a
  66.                communicator with a failed VC.  We check whether the vc
  67.                is in the communicator by iterating over the comm's VC
  68.                table.  Since this may be expensive, now that we know
  69.                the vc is in comm, we take the opportunity to scan the
  70.                rest of the posted recv queue for other anysources with
  71.                the same communicator.  Note that in the worst case
  72.                this is O(N*M), where N is the number of posted
  73.                requests and M is the number of communicators.  This
  74.                can happen if every req is an anysource and uses a
  75.                different communicator.  We can possibly conditionally
  76.                execute the optimization based on number of comms,
  77.                number of posted requests and communicator size. */
  78.             if (is_vc_in_comm(vc, req->comm)) {
  79.                 MPID_Comm *comm = req->comm;
  80.                 MPID_Request *as_req, *prev_as_req = prev_req;
  81.  
  82.                 for (as_req = req; as_req; prev_as_req = prev_as_req->dev.next, as_req = prev_as_req->dev.next)
  83.                     if (as_req->comm == comm && as_req->dev.match.parts.rank == MPI_ANY_SOURCE) {
  84.                         int error = MPI_SUCCESS;
  85.                         MPIU_ERR_SET1(error, MPI_ERR_OTHER, "**comm_fail", "**comm_fail %d", vc->pg_rank);
  86.                         dequeue_and_set_error(as_req, prev_as_req, error);
  87.                     }
  88.             }
  89.         }
  90.     }
  91.    
  92.  fn_exit:
  93.     MPIU_THREAD_CS_EXIT(MSGQUEUE,);
  94.  
  95.     MPIDI_FUNC_EXIT(MPID_STATE_MPIDU_COMPLETE_POSTED_WITH_ERROR);
  96.     return mpi_errno;
  97.  fn_fail:
  98.     goto fn_exit;
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement