root/opal/mca/btl/ugni/btl_ugni_atomic.c

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

DEFINITIONS

This source file includes following definitions.
  1. mca_btl_ugni_aop
  2. mca_btl_ugni_afop
  3. mca_btl_ugni_acswap

   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) 2019      Triad National Security, LLC. All rights
   6  *                         reserved.
   7  * Copyright (c) 2019      Google, LLC. All rights reserved.
   8  * $COPYRIGHT$
   9  *
  10  * Additional copyrights may follow
  11  *
  12  * $HEADER$
  13  */
  14 
  15 #include "btl_ugni_rdma.h"
  16 
  17 static gni_fma_cmd_type_t amo_cmds[][MCA_BTL_ATOMIC_LAST] = {
  18     [OPAL_INT32] = {
  19         [MCA_BTL_ATOMIC_ADD] = GNI_FMA_ATOMIC2_IADD_S,
  20         [MCA_BTL_ATOMIC_LAND] = GNI_FMA_ATOMIC2_AND_S,
  21         [MCA_BTL_ATOMIC_LOR] = GNI_FMA_ATOMIC2_OR_S,
  22         [MCA_BTL_ATOMIC_LXOR] = GNI_FMA_ATOMIC2_XOR_S,
  23         [MCA_BTL_ATOMIC_SWAP] = GNI_FMA_ATOMIC2_SWAP_S,
  24         [MCA_BTL_ATOMIC_MIN] = GNI_FMA_ATOMIC2_IMIN_S,
  25         [MCA_BTL_ATOMIC_MAX] = GNI_FMA_ATOMIC2_IMAX_S,
  26     },
  27     [OPAL_INT64] = {
  28         [MCA_BTL_ATOMIC_ADD] = GNI_FMA_ATOMIC_ADD,
  29         [MCA_BTL_ATOMIC_AND] = GNI_FMA_ATOMIC_AND,
  30         [MCA_BTL_ATOMIC_OR] = GNI_FMA_ATOMIC_OR,
  31         [MCA_BTL_ATOMIC_XOR] = GNI_FMA_ATOMIC_XOR,
  32         [MCA_BTL_ATOMIC_SWAP] = GNI_FMA_ATOMIC2_SWAP,
  33         [MCA_BTL_ATOMIC_MIN] = GNI_FMA_ATOMIC2_IMIN,
  34         [MCA_BTL_ATOMIC_MAX] = GNI_FMA_ATOMIC2_IMAX,
  35     },
  36     [OPAL_FLOAT] = {
  37         [MCA_BTL_ATOMIC_ADD] = GNI_FMA_ATOMIC2_FPADD_S,
  38         [MCA_BTL_ATOMIC_MIN] = GNI_FMA_ATOMIC2_FPMIN_S,
  39         [MCA_BTL_ATOMIC_MAX] = GNI_FMA_ATOMIC2_FPMAX_S,
  40     },
  41     [OPAL_DOUBLE] = {
  42         [MCA_BTL_ATOMIC_ADD] = GNI_FMA_ATOMIC2_FPADD,
  43         [MCA_BTL_ATOMIC_MIN] = GNI_FMA_ATOMIC2_FPMIN,
  44         [MCA_BTL_ATOMIC_MAX] = GNI_FMA_ATOMIC2_FPMAX,
  45     },
  46 };
  47 
  48 static gni_fma_cmd_type_t famo_cmds[][MCA_BTL_ATOMIC_LAST] = {
  49     [OPAL_INT32] = {
  50         [MCA_BTL_ATOMIC_ADD] = GNI_FMA_ATOMIC2_FIADD_S,
  51         [MCA_BTL_ATOMIC_LAND] = GNI_FMA_ATOMIC2_FAND_S,
  52         [MCA_BTL_ATOMIC_LOR] = GNI_FMA_ATOMIC2_FOR_S,
  53         [MCA_BTL_ATOMIC_LXOR] = GNI_FMA_ATOMIC2_FXOR_S,
  54         [MCA_BTL_ATOMIC_SWAP] = GNI_FMA_ATOMIC2_FSWAP_S,
  55         [MCA_BTL_ATOMIC_MIN] = GNI_FMA_ATOMIC2_FIMIN_S,
  56         [MCA_BTL_ATOMIC_MAX] = GNI_FMA_ATOMIC2_FIMAX_S,
  57     },
  58     [OPAL_INT64] = {
  59         [MCA_BTL_ATOMIC_ADD] = GNI_FMA_ATOMIC_FADD,
  60         [MCA_BTL_ATOMIC_AND] = GNI_FMA_ATOMIC_FAND,
  61         [MCA_BTL_ATOMIC_OR] = GNI_FMA_ATOMIC_FOR,
  62         [MCA_BTL_ATOMIC_XOR] = GNI_FMA_ATOMIC_FXOR,
  63         [MCA_BTL_ATOMIC_SWAP] = GNI_FMA_ATOMIC2_FSWAP,
  64         [MCA_BTL_ATOMIC_MIN] = GNI_FMA_ATOMIC2_FIMIN,
  65         [MCA_BTL_ATOMIC_MAX] = GNI_FMA_ATOMIC2_FIMAX,
  66     },
  67     [OPAL_FLOAT] = {
  68         [MCA_BTL_ATOMIC_ADD] = GNI_FMA_ATOMIC2_FFPADD_S,
  69         [MCA_BTL_ATOMIC_MIN] = GNI_FMA_ATOMIC2_FFPMIN_S,
  70         [MCA_BTL_ATOMIC_MAX] = GNI_FMA_ATOMIC2_FFPMAX_S,
  71     },
  72     [OPAL_DOUBLE] = {
  73         [MCA_BTL_ATOMIC_ADD] = GNI_FMA_ATOMIC2_FFPADD,
  74         [MCA_BTL_ATOMIC_MIN] = GNI_FMA_ATOMIC2_FFPMIN,
  75         [MCA_BTL_ATOMIC_MAX] = GNI_FMA_ATOMIC2_FFPMAX,
  76     },
  77 };
  78 
  79 int mca_btl_ugni_aop (struct mca_btl_base_module_t *btl, struct mca_btl_base_endpoint_t *endpoint,
  80                       uint64_t remote_address, mca_btl_base_registration_handle_t *remote_handle,
  81                       mca_btl_base_atomic_op_t op, uint64_t operand, int flags, int order,
  82                       mca_btl_base_rdma_completion_fn_t cbfunc, void *cbcontext, void *cbdata)
  83 {
  84     gni_mem_handle_t dummy = {0, 0};
  85     mca_btl_ugni_post_descriptor_t post_desc;
  86     int gni_op, type;
  87     size_t size;
  88 
  89     size = (MCA_BTL_ATOMIC_FLAG_32BIT & flags) ? 4 : 8;
  90     if (MCA_BTL_ATOMIC_FLAG_FLOAT & flags) {
  91         type = (MCA_BTL_ATOMIC_FLAG_32BIT & flags) ? OPAL_FLOAT : OPAL_DOUBLE;
  92     } else {
  93         type = (MCA_BTL_ATOMIC_FLAG_32BIT & flags) ? OPAL_INT32 : OPAL_INT64;
  94     }
  95 
  96     gni_op = amo_cmds[type][op];
  97     if (0 == gni_op) {
  98         return OPAL_ERR_NOT_SUPPORTED;
  99     }
 100 
 101     init_post_desc (&post_desc, endpoint, order, GNI_POST_AMO, 0, dummy, remote_address,
 102                     remote_handle->gni_handle, size, 0, cbfunc, cbcontext, cbdata,
 103                     NULL);
 104     post_desc.gni_desc.amo_cmd = gni_op;
 105     post_desc.gni_desc.first_operand = operand;
 106 
 107     return mca_btl_ugni_endpoint_post_fma (endpoint, &post_desc);
 108 }
 109 
 110 int mca_btl_ugni_afop (struct mca_btl_base_module_t *btl, struct mca_btl_base_endpoint_t *endpoint,
 111                        void *local_address, uint64_t remote_address, mca_btl_base_registration_handle_t *local_handle,
 112                        mca_btl_base_registration_handle_t *remote_handle, mca_btl_base_atomic_op_t op,
 113                        uint64_t operand, int flags, int order, mca_btl_base_rdma_completion_fn_t cbfunc,
 114                        void *cbcontext, void *cbdata)
 115 {
 116     mca_btl_ugni_post_descriptor_t post_desc;
 117     int gni_op, type;
 118     size_t size;
 119 
 120     size = (MCA_BTL_ATOMIC_FLAG_32BIT & flags) ? 4 : 8;
 121     if (MCA_BTL_ATOMIC_FLAG_FLOAT & flags) {
 122         type = (MCA_BTL_ATOMIC_FLAG_32BIT & flags) ? OPAL_FLOAT : OPAL_DOUBLE;
 123     } else {
 124         type = (MCA_BTL_ATOMIC_FLAG_32BIT & flags) ? OPAL_INT32 : OPAL_INT64;
 125     }
 126 
 127     gni_op = famo_cmds[type][op];
 128     if (0 == gni_op) {
 129         return OPAL_ERR_NOT_SUPPORTED;
 130     }
 131 
 132     init_post_desc (&post_desc, endpoint, order, GNI_POST_AMO, (intptr_t) local_address,
 133                     local_handle->gni_handle, remote_address, remote_handle->gni_handle,
 134                     size, 0, cbfunc, cbcontext, cbdata, local_handle);
 135     post_desc.gni_desc.amo_cmd = gni_op;
 136     post_desc.gni_desc.first_operand = operand;
 137 
 138     return mca_btl_ugni_endpoint_post_fma (endpoint, &post_desc);
 139 }
 140 
 141 int mca_btl_ugni_acswap (struct mca_btl_base_module_t *btl, struct mca_btl_base_endpoint_t *endpoint,
 142                          void *local_address, uint64_t remote_address, mca_btl_base_registration_handle_t *local_handle,
 143                          mca_btl_base_registration_handle_t *remote_handle, uint64_t compare, uint64_t value, int flags,
 144                          int order, mca_btl_base_rdma_completion_fn_t cbfunc, void *cbcontext, void *cbdata)
 145 {
 146     mca_btl_ugni_post_descriptor_t post_desc;
 147     size_t size;
 148     int gni_op;
 149 
 150     gni_op = (MCA_BTL_ATOMIC_FLAG_32BIT & flags) ? GNI_FMA_ATOMIC2_FCSWAP_S : GNI_FMA_ATOMIC_CSWAP;
 151     size = (MCA_BTL_ATOMIC_FLAG_32BIT & flags) ? 4 : 8;
 152 
 153     init_post_desc (&post_desc, endpoint, order, GNI_POST_AMO, (intptr_t) local_address,
 154                     local_handle->gni_handle, remote_address, remote_handle->gni_handle, size, 0,
 155                     cbfunc, cbcontext, cbdata, local_handle);
 156     post_desc.gni_desc.amo_cmd = gni_op;
 157     post_desc.gni_desc.first_operand = compare;
 158     post_desc.gni_desc.second_operand = value;
 159 
 160     return mca_btl_ugni_endpoint_post_fma (endpoint, &post_desc);
 161 }

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