root/oshmem/mca/atomic/mxm/atomic_mxm_cswap.c

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

DEFINITIONS

This source file includes following definitions.
  1. mca_atomic_mxm_swap
  2. mca_atomic_mxm_cswap

   1 /*
   2  * Copyright (c) 2013      Mellanox Technologies, Inc.
   3  *                         All rights reserved.
   4  * Copyright (c) 2016      Research Organization for Information Science
   5  *                         and Technology (RIST). All rights reserved.
   6  * $COPYRIGHT$
   7  *
   8  * Additional copyrights may follow
   9  *
  10  * $HEADER$
  11  */
  12 
  13 #include "oshmem_config.h"
  14 #include <stdio.h>
  15 #include <stdlib.h>
  16 
  17 #include "oshmem/constants.h"
  18 #include "oshmem/mca/spml/spml.h"
  19 #include "oshmem/mca/atomic/atomic.h"
  20 #include "oshmem/mca/atomic/base/base.h"
  21 #include "oshmem/mca/memheap/memheap.h"
  22 #include "oshmem/mca/memheap/base/base.h"
  23 #include "oshmem/runtime/runtime.h"
  24 
  25 #include "atomic_mxm.h"
  26 
  27 int mca_atomic_mxm_swap(shmem_ctx_t ctx,
  28                         void *target,
  29                         void *prev,
  30                         uint64_t value,
  31                         size_t nlong,
  32                         int pe)
  33 {
  34     mxm_send_req_t sreq;
  35 
  36     mca_atomic_mxm_req_init(&sreq, pe, target, nlong);
  37     memcpy(prev, &value, nlong);
  38 
  39     sreq.base.data.buffer.ptr = prev;
  40     sreq.opcode               = MXM_REQ_OP_ATOMIC_SWAP;
  41 
  42     mca_atomic_mxm_post(&sreq);
  43 
  44     return OSHMEM_SUCCESS;
  45 }
  46 
  47 int mca_atomic_mxm_cswap(shmem_ctx_t ctx,
  48                          void *target,
  49                          uint64_t *prev,
  50                          uint64_t cond,
  51                          uint64_t value,
  52                          size_t nlong,
  53                          int pe)
  54 {
  55     mxm_send_req_t sreq;
  56 
  57     mca_atomic_mxm_req_init(&sreq, pe, target, nlong);
  58 
  59     *prev                     = value;
  60     sreq.op.atomic.value      = cond;
  61     sreq.base.data.buffer.ptr = prev;
  62     sreq.opcode               = MXM_REQ_OP_ATOMIC_CSWAP;
  63 
  64     mca_atomic_mxm_post(&sreq);
  65 
  66     return OSHMEM_SUCCESS;
  67 }
  68 

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