root/opal/mca/btl/ugni/btl_ugni_rdma.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. init_post_desc
  2. mca_btl_ugni_post_fma
  3. mca_btl_ugni_post_bte
  4. mca_btl_ugni_post_cqwrite
  5. mca_btl_ugni_post

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2011-2018 Los Alamos National Security, LLC. All rights
   4  *                         reserved.
   5  * Copyright (c) 2011      UT-Battelle, LLC. All rights reserved.
   6  * $COPYRIGHT$
   7  *
   8  * Additional copyrights may follow
   9  *
  10  * $HEADER$
  11  */
  12 
  13 #if !defined(MCA_BTL_UGNI_RDMA_H)
  14 #define MCA_BTL_UGNI_RDMA_H
  15 
  16 #include "btl_ugni.h"
  17 #include "btl_ugni_frag.h"
  18 #include "btl_ugni_device.h"
  19 
  20 int mca_btl_ugni_start_eager_get (mca_btl_base_endpoint_t *ep,
  21                                   mca_btl_ugni_eager_ex_frag_hdr_t hdr,
  22                                   mca_btl_ugni_base_frag_t *frag);
  23 
  24 static inline void init_post_desc (mca_btl_ugni_post_descriptor_t *post_desc,
  25                                    mca_btl_base_endpoint_t *endpoint, int order,
  26                                    gni_post_type_t op_type, uint64_t lcl_addr,
  27                                    gni_mem_handle_t lcl_mdh, uint64_t rem_addr,
  28                                    gni_mem_handle_t rem_mdh, uint64_t bufsize,
  29                                    gni_cq_handle_t cq_hndl, mca_btl_base_rdma_completion_fn_t cbfunc,
  30                                    void *cbcontext, void *cbdata,
  31                                    mca_btl_base_registration_handle_t *local_handle) {
  32     post_desc->endpoint = endpoint;
  33     post_desc->cbfunc = cbfunc;
  34     post_desc->ctx = cbcontext;
  35     post_desc->cbdata = cbdata;
  36     post_desc->local_handle = local_handle;
  37     post_desc->gni_desc.type            = op_type;
  38     post_desc->gni_desc.cq_mode         = GNI_CQMODE_GLOBAL_EVENT;
  39     if (MCA_BTL_NO_ORDER == order) {
  40         post_desc->gni_desc.dlvr_mode       = GNI_DLVMODE_PERFORMANCE;
  41     } else {
  42         post_desc->gni_desc.dlvr_mode       = GNI_DLVMODE_NO_ADAPT;
  43     }
  44     post_desc->gni_desc.local_addr      = (uint64_t) lcl_addr;
  45     post_desc->gni_desc.local_mem_hndl  = lcl_mdh;
  46     post_desc->gni_desc.remote_addr     = (uint64_t) rem_addr;
  47     post_desc->gni_desc.remote_mem_hndl = rem_mdh;
  48     post_desc->gni_desc.length          = bufsize;
  49     post_desc->gni_desc.rdma_mode       = 0;
  50     post_desc->gni_desc.src_cq_hndl     = cq_hndl;
  51 }
  52 
  53 __opal_attribute_always_inline__
  54 static inline int mca_btl_ugni_post_fma (struct mca_btl_base_endpoint_t *endpoint, gni_post_type_t op_type,
  55                                          size_t size, void *local_address, uint64_t remote_address,
  56                                          mca_btl_base_registration_handle_t *local_handle,
  57                                          mca_btl_base_registration_handle_t *remote_handle,
  58                                          int order, mca_btl_base_rdma_completion_fn_t cbfunc,
  59                                          void *cbcontext, void *cbdata)
  60 {
  61     mca_btl_ugni_post_descriptor_t post_desc;
  62     gni_mem_handle_t local_gni_handle = {0, 0};
  63 
  64     if (local_handle) {
  65         local_gni_handle = local_handle->gni_handle;
  66     }
  67 
  68     /* Post descriptor (CQ is ignored for FMA transactions) -- The CQ associated with the endpoint
  69      * is used. */
  70     init_post_desc (&post_desc, endpoint, order, op_type, (intptr_t) local_address, local_gni_handle,
  71                     remote_address, remote_handle->gni_handle, size, 0, cbfunc, cbcontext, cbdata,
  72                     local_handle);
  73 
  74     return mca_btl_ugni_endpoint_post_fma (endpoint, &post_desc);
  75 }
  76 
  77 static inline int mca_btl_ugni_post_bte (mca_btl_base_endpoint_t *endpoint, gni_post_type_t op_type,
  78                                          size_t size, void *local_address, uint64_t remote_address,
  79                                          mca_btl_base_registration_handle_t *local_handle,
  80                                          mca_btl_base_registration_handle_t *remote_handle,
  81                                          int order, mca_btl_base_rdma_completion_fn_t cbfunc,
  82                                          void *cbcontext, void *cbdata)
  83 {
  84     mca_btl_ugni_module_t *module = mca_btl_ugni_ep_btl (endpoint);
  85     mca_btl_ugni_post_descriptor_t post_desc;
  86     int rc;
  87 
  88     /* There is a performance benefit to throttling the total number of active BTE tranactions. Not sure
  89      * what the optimium is but the limit is inforced as a soft limit. */
  90     if (module->active_rdma_count >= mca_btl_ugni_component.active_rdma_threshold) {
  91         return OPAL_ERR_OUT_OF_RESOURCE;
  92     }
  93 
  94     (void) OPAL_THREAD_FETCH_ADD32 (&module->active_rdma_count, 1);
  95 
  96     /* Post descriptor */
  97     init_post_desc (&post_desc, endpoint, order, op_type, (intptr_t) local_address, local_handle->gni_handle,
  98                     remote_address, remote_handle->gni_handle, size, 0, cbfunc, cbcontext, cbdata,
  99                     local_handle);
 100 
 101     rc = mca_btl_ugni_endpoint_post_rdma (endpoint, &post_desc);
 102     if (OPAL_UNLIKELY(OPAL_SUCCESS != rc)) {
 103         (void) OPAL_THREAD_FETCH_ADD32 (&module->active_rdma_count, -1);
 104     }
 105 
 106     return rc;
 107 }
 108 
 109 static inline int mca_btl_ugni_post_cqwrite (mca_btl_base_endpoint_t *endpoint, mca_btl_ugni_cq_t *cq,
 110                                              gni_mem_handle_t irq_mhndl, uint64_t value,
 111                                              mca_btl_base_rdma_completion_fn_t cbfunc,
 112                                              void *cbcontext, void *cbdata)
 113 {
 114     mca_btl_ugni_post_descriptor_t post_desc;
 115 
 116     post_desc.gni_desc.type = GNI_POST_CQWRITE;
 117     post_desc.gni_desc.cqwrite_value = value;   /* up to 48 bytes here, not used for now */
 118     post_desc.gni_desc.cq_mode = GNI_CQMODE_GLOBAL_EVENT;
 119     post_desc.gni_desc.dlvr_mode = GNI_DLVMODE_IN_ORDER;
 120     post_desc.gni_desc.src_cq_hndl = cq->gni_handle;
 121     post_desc.gni_desc.remote_mem_hndl = irq_mhndl;
 122     post_desc.cq = cq;
 123 
 124     return mca_btl_ugni_endpoint_post_cqwrite (endpoint, &post_desc);
 125 }
 126 
 127 __opal_attribute_always_inline__
 128 static inline int mca_btl_ugni_post (mca_btl_base_endpoint_t *endpoint, int get, size_t size,
 129                                      void *local_address, uint64_t remote_address,
 130                                      mca_btl_base_registration_handle_t *local_handle,
 131                                      mca_btl_base_registration_handle_t *remote_handle,
 132                                      int order, mca_btl_base_rdma_completion_fn_t cbfunc,
 133                                      void *cbcontext, void *cbdata)
 134 {
 135     const gni_post_type_t fma_ops[2] = {GNI_POST_FMA_PUT, GNI_POST_FMA_GET};
 136     const gni_post_type_t rdma_ops[2] = {GNI_POST_RDMA_PUT, GNI_POST_RDMA_GET};
 137     const size_t fma_limit = (size_t) (get ? mca_btl_ugni_component.ugni_fma_get_limit :
 138                                        mca_btl_ugni_component.ugni_fma_put_limit);
 139 
 140     if (size <= fma_limit) {
 141         return mca_btl_ugni_post_fma (endpoint, fma_ops[get], size, local_address, remote_address,
 142                                       local_handle, remote_handle, order, cbfunc, cbcontext, cbdata);
 143     }
 144 
 145     return mca_btl_ugni_post_bte (endpoint, rdma_ops[get], size, local_address, remote_address,
 146                                   local_handle, remote_handle, order, cbfunc, cbcontext, cbdata);
 147 }
 148 
 149 #endif /* MCA_BTL_UGNI_RDMA_H */

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