Advertisement
Guest User

Untitled

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