This source file includes following definitions.
- mca_atomic_mxm_order
- mca_atomic_mxm_req_init
- mca_atomic_mxm_post
1
2
3
4
5
6
7
8
9
10
11 #ifndef MCA_ATOMIC_MXM_H
12 #define MCA_ATOMIC_MXM_H
13
14 #include "oshmem_config.h"
15
16 #include "oshmem/mca/mca.h"
17 #include "oshmem/mca/atomic/atomic.h"
18 #include "oshmem/util/oshmem_util.h"
19
20
21 #include "oshmem/mca/spml/ikrit/spml_ikrit.h"
22 #include "oshmem/runtime/runtime.h"
23
24
25 BEGIN_C_DECLS
26
27
28
29 OSHMEM_MODULE_DECLSPEC extern mca_atomic_base_component_1_0_0_t
30 mca_atomic_mxm_component;
31
32
33 extern mca_spml_ikrit_t *mca_atomic_mxm_spml_self;
34
35 OSHMEM_DECLSPEC void atomic_mxm_lock(int pe);
36 OSHMEM_DECLSPEC void atomic_mxm_unlock(int pe);
37
38
39
40 int mca_atomic_mxm_startup(bool enable_progress_threads, bool enable_threads);
41 int mca_atomic_mxm_finalize(void);
42 mca_atomic_base_module_t*
43 mca_atomic_mxm_query(int *priority);
44
45 int mca_atomic_mxm_add(shmem_ctx_t ctx,
46 void *target,
47 uint64_t value,
48 size_t nlong,
49 int pe);
50 int mca_atomic_mxm_fadd(shmem_ctx_t ctx,
51 void *target,
52 void *prev,
53 uint64_t value,
54 size_t nlong,
55 int pe);
56 int mca_atomic_mxm_swap(shmem_ctx_t ctx,
57 void *target,
58 void *prev,
59 uint64_t value,
60 size_t nlong,
61 int pe);
62 int mca_atomic_mxm_cswap(shmem_ctx_t ctx,
63 void *target,
64 uint64_t *prev,
65 uint64_t cond,
66 uint64_t value,
67 size_t nlong,
68 int pe);
69
70 struct mca_atomic_mxm_module_t {
71 mca_atomic_base_module_t super;
72 };
73 typedef struct mca_atomic_mxm_module_t mca_atomic_mxm_module_t;
74 OBJ_CLASS_DECLARATION(mca_atomic_mxm_module_t);
75
76
77 static inline uint8_t mca_atomic_mxm_order(size_t nlong)
78 {
79 if (OPAL_LIKELY(8 == nlong)) {
80 return 3;
81 }
82
83 if (OPAL_LIKELY(4 == nlong)) {
84 return 2;
85 }
86
87 if (2 == nlong) {
88 return 1;
89 }
90
91 if (1 == nlong) {
92 return 0;
93 }
94
95 ATOMIC_ERROR("Type size must be 1/2/4 or 8 bytes.");
96 oshmem_shmem_abort(-1);
97 return OSHMEM_ERR_BAD_PARAM;
98 }
99
100 static inline void mca_atomic_mxm_req_init(mxm_send_req_t *sreq, int pe, void *target, size_t nlong)
101 {
102 uint8_t nlong_order;
103 void *remote_addr;
104 mxm_mem_key_t *mkey;
105
106 nlong_order = mca_atomic_mxm_order(nlong);
107
108 mkey = mca_spml_ikrit_get_mkey(pe, target, MXM_PTL_RDMA, &remote_addr, mca_atomic_mxm_spml_self);
109
110
111 sreq->base.state = MXM_REQ_NEW;
112 sreq->base.mq = mca_atomic_mxm_spml_self->mxm_mq;
113 sreq->base.conn = mca_atomic_mxm_spml_self->mxm_peers[pe].mxm_hw_rdma_conn;
114 sreq->base.completed_cb = NULL;
115 sreq->base.data_type = MXM_REQ_DATA_BUFFER;
116
117 sreq->base.data.buffer.memh = MXM_INVALID_MEM_HANDLE;
118 sreq->base.data.buffer.length = nlong;
119
120 sreq->op.atomic.remote_vaddr = (uintptr_t) remote_addr;
121 sreq->op.atomic.remote_mkey = mkey;
122 sreq->op.atomic.order = nlong_order;
123
124 sreq->flags = 0;
125 }
126
127 static inline void mca_atomic_mxm_post(mxm_send_req_t *sreq)
128 {
129 mxm_error_t mxm_err;
130
131 mxm_err = mxm_req_send(sreq);
132 if (OPAL_UNLIKELY(MXM_OK != mxm_err)) {
133 ATOMIC_ERROR("mxm_req_send failed, mxm_error = %d",
134 mxm_err);
135 oshmem_shmem_abort(-1);
136 }
137
138 mxm_req_wait(&sreq->base);
139 if (OPAL_UNLIKELY(MXM_OK != sreq->base.error)) {
140 ATOMIC_ERROR("mxm_req_wait got non MXM_OK error: %d",
141 sreq->base.error);
142 oshmem_shmem_abort(-1);
143 }
144 }
145
146 END_C_DECLS
147
148 #endif