root/opal/mca/btl/ofi/btl_ofi_rdma.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. mca_btl_ofi_rdma_completion_alloc
  2. mca_btl_ofi_get
  3. mca_btl_ofi_put
  4. mca_btl_ofi_flush

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2014-2018 Los Alamos National Security, LLC. All rights
   4  *                         reserved.
   5  * Copyright (c) 2018      Intel, Inc, All rights reserved
   6  *
   7  * $COPYRIGHT$
   8  *
   9  * Additional copyrights may follow
  10  *
  11  * $HEADER$
  12  */
  13 
  14 #include "btl_ofi_rdma.h"
  15 
  16 OBJ_CLASS_INSTANCE(mca_btl_ofi_rdma_completion_t,
  17                    opal_free_list_item_t,
  18                    NULL,
  19                    NULL);
  20 
  21 mca_btl_ofi_rdma_completion_t *mca_btl_ofi_rdma_completion_alloc (
  22                                          mca_btl_base_module_t *btl,
  23                                          mca_btl_base_endpoint_t *endpoint,
  24                                          mca_btl_ofi_context_t *ofi_context,
  25                                          void *local_address,
  26                                          mca_btl_base_registration_handle_t *local_handle,
  27                                          mca_btl_base_rdma_completion_fn_t cbfunc,
  28                                          void *cbcontext, void *cbdata,
  29                                          int type)
  30 {
  31     assert(btl);
  32     assert(endpoint);
  33     assert(ofi_context);
  34 
  35     mca_btl_ofi_rdma_completion_t *comp;
  36 
  37     comp = (mca_btl_ofi_rdma_completion_t*) opal_free_list_get(&ofi_context->rdma_comp_list);
  38     assert(comp);
  39 
  40     comp->base.btl = btl;
  41     comp->base.endpoint = endpoint;
  42     comp->base.my_context = ofi_context;
  43     comp->base.my_list = &ofi_context->rdma_comp_list;
  44     comp->base.type = type;
  45 
  46     comp->local_address = local_address;
  47     comp->local_handle = local_handle;
  48     comp->cbfunc = cbfunc;
  49     comp->cbcontext = cbcontext;
  50     comp->cbdata = cbdata;
  51 
  52     comp->comp_ctx.comp = comp;
  53 
  54     return comp;
  55 }
  56 
  57 int mca_btl_ofi_get (mca_btl_base_module_t *btl, mca_btl_base_endpoint_t *endpoint, void *local_address,
  58                       uint64_t remote_address, mca_btl_base_registration_handle_t *local_handle,
  59                       mca_btl_base_registration_handle_t *remote_handle, size_t size, int flags,
  60                       int order, mca_btl_base_rdma_completion_fn_t cbfunc, void *cbcontext, void *cbdata)
  61 {
  62 
  63     int rc;
  64     mca_btl_ofi_rdma_completion_t *comp;
  65 
  66     mca_btl_ofi_module_t *ofi_btl = (mca_btl_ofi_module_t *) btl;
  67     mca_btl_ofi_endpoint_t *btl_endpoint = (mca_btl_ofi_endpoint_t*) endpoint;
  68     mca_btl_ofi_context_t *ofi_context;
  69 
  70     ofi_context = get_ofi_context(ofi_btl);
  71 
  72     /* create completion context */
  73     comp = mca_btl_ofi_rdma_completion_alloc(btl, endpoint,
  74                                              ofi_context,
  75                                              local_address,
  76                                              local_handle,
  77                                              cbfunc, cbcontext, cbdata,
  78                                              MCA_BTL_OFI_TYPE_GET);
  79 
  80     remote_address = (remote_address - (uint64_t) remote_handle->base_addr);
  81 
  82     /* Remote write data across the wire */
  83     rc = fi_read(ofi_context->tx_ctx,
  84                 local_address, size,   /* payload */
  85                 local_handle->desc,
  86                 btl_endpoint->peer_addr,
  87                 remote_address, remote_handle->rkey,
  88                 &comp->comp_ctx);       /* completion context */
  89 
  90     if (-FI_EAGAIN == rc) {
  91         return OPAL_ERR_OUT_OF_RESOURCE;
  92     }
  93 
  94     if (0 != rc) {
  95         BTL_ERROR(("fi_read failed with %d:%s", rc, fi_strerror(-rc)));
  96         MCA_BTL_OFI_ABORT();
  97     }
  98 
  99     MCA_BTL_OFI_NUM_RDMA_INC(ofi_btl);
 100 
 101     return OPAL_SUCCESS;
 102 }
 103 
 104 int mca_btl_ofi_put (mca_btl_base_module_t *btl, mca_btl_base_endpoint_t *endpoint, void *local_address,
 105                       uint64_t remote_address, mca_btl_base_registration_handle_t *local_handle,
 106                       mca_btl_base_registration_handle_t *remote_handle, size_t size, int flags,
 107                       int order, mca_btl_base_rdma_completion_fn_t cbfunc, void *cbcontext, void *cbdata)
 108 {
 109     int rc;
 110     mca_btl_ofi_module_t *ofi_btl = (mca_btl_ofi_module_t *) btl;
 111     mca_btl_ofi_endpoint_t *btl_endpoint = (mca_btl_ofi_endpoint_t*) endpoint;
 112     mca_btl_ofi_context_t *ofi_context;
 113 
 114     ofi_context = get_ofi_context(ofi_btl);
 115 
 116     /* create completion context */
 117     mca_btl_ofi_rdma_completion_t *comp;
 118     comp = mca_btl_ofi_rdma_completion_alloc(btl, endpoint,
 119                                              ofi_context,
 120                                              local_address,
 121                                              local_handle,
 122                                              cbfunc, cbcontext, cbdata,
 123                                              MCA_BTL_OFI_TYPE_PUT);
 124 
 125     remote_address = (remote_address - (uint64_t) remote_handle->base_addr);
 126 
 127     /* Remote write data across the wire */
 128     rc = fi_write(ofi_context->tx_ctx,
 129                   local_address, size,   /* payload */
 130                   local_handle->desc,
 131                   btl_endpoint->peer_addr,
 132                   remote_address, remote_handle->rkey,
 133                   &comp->comp_ctx);       /* completion context */
 134 
 135     if (-FI_EAGAIN == rc) {
 136         return OPAL_ERR_OUT_OF_RESOURCE;
 137     }
 138 
 139     if (0 != rc) {
 140         BTL_ERROR(("fi_write failed with %d:%s", rc, fi_strerror(-rc)));
 141         MCA_BTL_OFI_ABORT();
 142     }
 143 
 144     MCA_BTL_OFI_NUM_RDMA_INC(ofi_btl);
 145 
 146     return OPAL_SUCCESS;
 147 
 148 }
 149 
 150 int mca_btl_ofi_flush (mca_btl_base_module_t *btl, mca_btl_base_endpoint_t *endpoint)
 151 {
 152     mca_btl_ofi_module_t *ofi_btl = (mca_btl_ofi_module_t *) btl;
 153 
 154     while(ofi_btl->outstanding_rdma > 0) {
 155         (void) mca_btl_ofi_component.super.btl_progress();
 156     }
 157 
 158     return OPAL_SUCCESS;
 159 }

/* [<][>][^][v][top][bottom][index][help] */