This source file includes following definitions.
- mca_pml_ob1_process_pending_cuda_async_copies
- mca_pml_ob1_enable_progress
- mca_pml_ob1_progress
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 
  19 
  20 
  21 
  22 #include "ompi_config.h"
  23 
  24 #include "pml_ob1.h"
  25 #include "pml_ob1_sendreq.h"
  26 #include "ompi/mca/bml/base/base.h"
  27 #if OPAL_CUDA_SUPPORT
  28 #include "opal/mca/common/cuda/common_cuda.h"
  29 #include "pml_ob1_recvreq.h"
  30 #include "opal/runtime/opal_params.h"
  31 
  32 
  33 
  34 
  35 
  36 
  37 static inline int mca_pml_ob1_process_pending_cuda_async_copies(void)
  38 {
  39     mca_btl_base_descriptor_t *frag;
  40     int progress, count = 0;
  41 
  42     do {
  43         progress = progress_one_cuda_htod_event(&frag);
  44         if (1 == progress) {
  45             
  46             mca_pml_ob1_recv_request_frag_copy_finished(NULL, NULL, frag, 0);
  47             count++;
  48         }
  49     } while (progress > 0);
  50     
  51 
  52     return count;
  53 }
  54 #endif 
  55 
  56 static opal_atomic_int32_t mca_pml_ob1_progress_needed = 0;
  57 int mca_pml_ob1_enable_progress(int32_t count)
  58 {
  59     int32_t progress_count = OPAL_ATOMIC_ADD_FETCH32(&mca_pml_ob1_progress_needed, count);
  60     if( 1 < progress_count )
  61         return 0;  
  62 
  63     opal_progress_register(mca_pml_ob1_progress);
  64     return 1;
  65 }
  66 
  67 int mca_pml_ob1_progress(void)
  68 {
  69     int i, queue_length = opal_list_get_size(&mca_pml_ob1.send_pending);
  70     int j, completed_requests = 0;
  71     bool send_succedded;
  72 
  73 #if OPAL_CUDA_SUPPORT
  74     if (opal_cuda_support)
  75         completed_requests += mca_pml_ob1_process_pending_cuda_async_copies();
  76 #endif 
  77 
  78     for( i = 0; i < queue_length; i++ ) {
  79         mca_pml_ob1_send_pending_t pending_type = MCA_PML_OB1_SEND_PENDING_NONE;
  80         mca_pml_ob1_send_request_t* sendreq;
  81         mca_bml_base_endpoint_t* endpoint;
  82 
  83         sendreq = get_request_from_send_pending(&pending_type);
  84         if(OPAL_UNLIKELY(NULL == sendreq))
  85             break;
  86 
  87         switch(pending_type) {
  88         case MCA_PML_OB1_SEND_PENDING_NONE:
  89             assert(0);
  90             return 0;
  91         case MCA_PML_OB1_SEND_PENDING_SCHEDULE:
  92             if( mca_pml_ob1_send_request_schedule_exclusive(sendreq) ==
  93                 OMPI_ERR_OUT_OF_RESOURCE ) {
  94                 return 0;
  95             }
  96             completed_requests++;
  97             break;
  98         case MCA_PML_OB1_SEND_PENDING_START:
  99             MCA_PML_OB1_SEND_REQUEST_RESET(sendreq);
 100             endpoint = sendreq->req_endpoint;
 101             send_succedded = false;
 102             for(j = 0; j < (int)mca_bml_base_btl_array_get_size(&endpoint->btl_eager); j++) {
 103                 mca_bml_base_btl_t* bml_btl;
 104                 int rc;
 105 
 106                 
 107                 bml_btl = mca_bml_base_btl_array_get_next(&endpoint->btl_eager);
 108                 rc = mca_pml_ob1_send_request_start_btl(sendreq, bml_btl);
 109                 if( OPAL_LIKELY(OMPI_SUCCESS == rc) ) {
 110                     send_succedded = true;
 111                     completed_requests++;
 112                     break;
 113                 }
 114             }
 115             if( false == send_succedded ) {
 116                 add_request_to_send_pending(sendreq, MCA_PML_OB1_SEND_PENDING_START, true);
 117             }
 118         }
 119     }
 120 
 121     if( 0 != completed_requests ) {
 122         j = OPAL_ATOMIC_ADD_FETCH32(&mca_pml_ob1_progress_needed, -completed_requests);
 123         if( 0 == j ) {
 124             opal_progress_unregister(mca_pml_ob1_progress);
 125         }
 126     }
 127 
 128     return completed_requests;
 129 }