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/op/op.h"
19 #include "oshmem/mca/spml/spml.h"
20 #include "oshmem/mca/atomic/atomic.h"
21 #include "oshmem/mca/atomic/base/base.h"
22 #include "oshmem/mca/memheap/memheap.h"
23 #include "oshmem/mca/memheap/base/base.h"
24 #include "oshmem/runtime/runtime.h"
25 
26 #include "atomic_mxm.h"
27 
mca_atomic_mxm_fadd(void * target,void * prev,const void * value,size_t nlong,int pe,struct oshmem_op_t * op)28 int mca_atomic_mxm_fadd(void *target,
29                         void *prev,
30                         const void *value,
31                         size_t nlong,
32                         int pe,
33                         struct oshmem_op_t *op)
34 {
35     mxm_send_req_t sreq;
36     static char dummy_buf[8];
37 
38     mca_atomic_mxm_req_init(&sreq, pe, target, nlong);
39 
40     memcpy(&sreq.op.atomic.value, value, nlong);
41     sreq.opcode = MXM_REQ_OP_ATOMIC_FADD;
42     if (NULL == prev) {
43         sreq.base.data.buffer.ptr = dummy_buf;
44     } else {
45         sreq.base.data.buffer.ptr = prev;
46     }
47 
48     mca_atomic_mxm_post(&sreq);
49 
50     return OSHMEM_SUCCESS;
51 }
52