root/opal/mca/btl/vader/btl_vader_atomic.c

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

DEFINITIONS

This source file includes following definitions.
  1. mca_btl_vader_sc_emu_aop_complete
  2. mca_btl_vader_emu_aop
  3. mca_btl_vader_sc_emu_afop_complete
  4. mca_btl_vader_emu_afop
  5. mca_btl_vader_emu_acswap

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2010-2017 Los Alamos National Security, LLC. All rights
   4  *                         reserved.
   5  * $COPYRIGHT$
   6  *
   7  * Additional copyrights may follow
   8  *
   9  * $HEADER$
  10  */
  11 
  12 #include "opal_config.h"
  13 
  14 #include "btl_vader.h"
  15 #include "btl_vader_frag.h"
  16 #include "btl_vader_endpoint.h"
  17 #include "btl_vader_xpmem.h"
  18 
  19 static void mca_btl_vader_sc_emu_aop_complete (mca_btl_base_module_t *btl, mca_btl_base_endpoint_t *endpoint,
  20                                                 mca_btl_base_descriptor_t *desc, int status)
  21 {
  22     mca_btl_vader_frag_t *frag = (mca_btl_vader_frag_t *) desc;
  23     void *local_address = frag->rdma.local_address;
  24     void *context = frag->rdma.context;
  25     void *cbdata = frag->rdma.cbdata;
  26     mca_btl_base_rdma_completion_fn_t cbfunc = frag->rdma.cbfunc;
  27 
  28     /* return the fragment first since the callback may call put/get/amo and could use this fragment */
  29     MCA_BTL_VADER_FRAG_RETURN(frag);
  30 
  31     cbfunc (btl, endpoint, local_address, NULL, context, cbdata, status);
  32 }
  33 
  34 int mca_btl_vader_emu_aop (struct mca_btl_base_module_t *btl, struct mca_btl_base_endpoint_t *endpoint,
  35                            uint64_t remote_address, mca_btl_base_registration_handle_t *remote_handle,
  36                            mca_btl_base_atomic_op_t op, uint64_t operand, int flags, int order,
  37                            mca_btl_base_rdma_completion_fn_t cbfunc, void *cbcontext, void *cbdata)
  38 {
  39     mca_btl_vader_frag_t *frag;
  40 
  41     frag = mca_btl_vader_rdma_frag_alloc (btl, endpoint, MCA_BTL_VADER_OP_ATOMIC, operand, 0, op, 0, order, flags, NULL,
  42                                           remote_address, cbfunc, cbcontext, cbdata, mca_btl_vader_sc_emu_aop_complete);
  43     if (OPAL_UNLIKELY(NULL == frag)) {
  44         return OPAL_ERR_OUT_OF_RESOURCE;
  45     }
  46 
  47     /* send is always successful */
  48     (void) mca_btl_vader_send (btl, endpoint, &frag->base, MCA_BTL_TAG_VADER);
  49 
  50     return OPAL_SUCCESS;
  51 }
  52 
  53 static void mca_btl_vader_sc_emu_afop_complete (mca_btl_base_module_t *btl, mca_btl_base_endpoint_t *endpoint,
  54                                                 mca_btl_base_descriptor_t *desc, int status)
  55 {
  56     mca_btl_vader_frag_t *frag = (mca_btl_vader_frag_t *) desc;
  57     mca_btl_vader_sc_emu_hdr_t *hdr;
  58     void *local_address = frag->rdma.local_address;
  59     void *context = frag->rdma.context;
  60     void *cbdata = frag->rdma.cbdata;
  61     mca_btl_base_rdma_completion_fn_t cbfunc = frag->rdma.cbfunc;
  62 
  63     hdr = (mca_btl_vader_sc_emu_hdr_t *) frag->segments[0].seg_addr.pval;
  64 
  65     *((int64_t *) frag->rdma.local_address) = hdr->operand[0];
  66 
  67     /* return the fragment first since the callback may call put/get/amo and could use this fragment */
  68     MCA_BTL_VADER_FRAG_RETURN(frag);
  69 
  70     cbfunc (btl, endpoint, local_address, NULL, context, cbdata, status);
  71 }
  72 
  73 int mca_btl_vader_emu_afop (struct mca_btl_base_module_t *btl, struct mca_btl_base_endpoint_t *endpoint,
  74                             void *local_address, uint64_t remote_address, mca_btl_base_registration_handle_t *local_handle,
  75                             mca_btl_base_registration_handle_t *remote_handle, mca_btl_base_atomic_op_t op,
  76                             uint64_t operand, int flags, int order, mca_btl_base_rdma_completion_fn_t cbfunc,
  77                             void *cbcontext, void *cbdata)
  78 {
  79     mca_btl_vader_frag_t *frag;
  80 
  81     frag = mca_btl_vader_rdma_frag_alloc (btl, endpoint, MCA_BTL_VADER_OP_ATOMIC, operand, 0, op, 0, order, flags,
  82                                           local_address, remote_address, cbfunc, cbcontext, cbdata,
  83                                           mca_btl_vader_sc_emu_afop_complete);
  84     if (OPAL_UNLIKELY(NULL == frag)) {
  85         return OPAL_ERR_OUT_OF_RESOURCE;
  86     }
  87 
  88     /* send is always successful */
  89     (void) mca_btl_vader_send (btl, endpoint, &frag->base, MCA_BTL_TAG_VADER);
  90 
  91     return OPAL_SUCCESS;
  92 }
  93 
  94 int mca_btl_vader_emu_acswap (struct mca_btl_base_module_t *btl, struct mca_btl_base_endpoint_t *endpoint,
  95                               void *local_address, uint64_t remote_address, mca_btl_base_registration_handle_t *local_handle,
  96                               mca_btl_base_registration_handle_t *remote_handle, uint64_t compare, uint64_t value, int flags,
  97                               int order, mca_btl_base_rdma_completion_fn_t cbfunc, void *cbcontext, void *cbdata)
  98 {
  99     mca_btl_vader_frag_t *frag;
 100 
 101     frag = mca_btl_vader_rdma_frag_alloc (btl, endpoint, MCA_BTL_VADER_OP_CSWAP, compare, value, 0, 0, order,
 102                                           flags, local_address, remote_address, cbfunc, cbcontext, cbdata,
 103                                           mca_btl_vader_sc_emu_afop_complete);
 104     if (OPAL_UNLIKELY(NULL == frag)) {
 105         return OPAL_ERR_OUT_OF_RESOURCE;
 106     }
 107 
 108     /* send is always successful */
 109     (void) mca_btl_vader_send (btl, endpoint, &frag->base, MCA_BTL_TAG_VADER);
 110 
 111     return OPAL_SUCCESS;
 112 }

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