38
38
#include <stdlib.h>
39
39
#include <string.h>
40
40
41
- # include <stdint.h>
41
+ #include <stdint.h>
42
42
#ifdef HAVE_SCHED_H
43
- # include <sched.h>
44
- #endif /* HAVE_SCHED_H */
43
+ # include <sched.h>
44
+ #endif /* HAVE_SCHED_H */
45
45
#ifdef HAVE_UNISTD_H
46
- # include <unistd.h>
46
+ # include <unistd.h>
47
47
#endif /* HAVE_UNISTD_H */
48
48
49
49
#include "opal/mca/shmem/base/base.h"
50
50
51
- #include "opal/class/opal_free_list.h"
52
- #include "opal/sys/atomic.h"
53
- #include "opal/mca/btl/btl.h"
54
- #include "opal/mca/rcache/rcache.h"
55
- #include "opal/mca/rcache/base/rcache_base_vma.h"
56
51
#include "opal/mca/btl/base/base.h"
57
- #include "opal/mca/rcache/rcache.h"
58
- #include "opal/mca/rcache/base/base.h"
59
52
#include "opal/mca/btl/base/btl_base_error.h"
53
+ #include "opal/mca/btl/btl.h"
54
+ #include "opal/mca/btl/sm/btl_sm_types.h"
60
55
#include "opal/mca/mpool/base/base.h"
56
+ #include "opal/mca/rcache/base/base.h"
57
+ #include "opal/mca/rcache/base/rcache_base_vma.h"
58
+ #include "opal/mca/rcache/rcache.h"
59
+ #include "opal/sys/atomic.h"
61
60
#include "opal/util/proc.h"
62
- #include "btl_sm_endpoint.h"
63
61
64
62
#include "opal/mca/pmix/pmix-internal.h"
65
63
66
- #include "btl_sm_xpmem.h"
67
64
#include "btl_sm_knem.h"
65
+ #include "btl_sm_xpmem.h"
68
66
69
67
BEGIN_C_DECLS
70
68
71
- #define min (a ,b ) ((a) < (b) ? (a) : (b))
69
+ #define min (a , b ) ((a) < (b) ? (a) : (b))
72
70
73
71
/*
74
72
* Shared Memory resource managment
75
73
*/
76
74
77
75
struct sm_fifo_t ;
78
76
79
- /*
80
- * Modex data
81
- */
82
- union sm_modex_t {
83
- #if OPAL_BTL_SM_HAVE_XPMEM
84
- struct sm_modex_xpmem_t {
85
- xpmem_segid_t seg_id ;
86
- void * segment_base ;
87
- uintptr_t address_max ;
88
- } xpmem ;
89
- #endif
90
- struct sm_modex_other_t {
91
- ino_t user_ns_id ;
92
- int seg_ds_size ;
93
- /* seg_ds needs to be the last element */
94
- opal_shmem_ds_t seg_ds ;
95
- } other ;
96
- };
97
-
98
- /**
99
- * Single copy mechanisms
100
- */
101
- enum {
102
- MCA_BTL_SM_XPMEM = 0 ,
103
- MCA_BTL_SM_CMA = 1 ,
104
- MCA_BTL_SM_KNEM = 2 ,
105
- MCA_BTL_SM_NONE = 3 ,
106
- };
107
-
108
- /**
109
- * Shared Memory (SM) BTL module.
110
- */
111
- struct mca_btl_sm_component_t {
112
- mca_btl_base_component_3_0_0_t super ; /**< base BTL component */
113
- int sm_free_list_num ; /**< initial size of free lists */
114
- int sm_free_list_max ; /**< maximum size of free lists */
115
- int sm_free_list_inc ; /**< number of elements to alloc when growing free lists */
116
- #if OPAL_BTL_SM_HAVE_XPMEM
117
- xpmem_segid_t my_seg_id ; /**< this rank's xpmem segment id */
118
- uintptr_t my_address_max ; /**< largest address */
119
- mca_rcache_base_vma_module_t * vma_module ; /**< registration cache for xpmem segments */
120
- #endif
121
- opal_shmem_ds_t seg_ds ; /**< this rank's shared memory segment (when not using xpmem) */
122
-
123
- opal_mutex_t lock ; /**< lock to protect concurrent updates to this structure's members */
124
- char * my_segment ; /**< this rank's base pointer */
125
- size_t segment_size ; /**< size of my_segment */
126
- int32_t num_smp_procs ; /**< current number of smp procs on this host */
127
- opal_free_list_t sm_frags_eager ; /**< free list of sm send frags */
128
- opal_free_list_t sm_frags_max_send ; /**< free list of sm max send frags (large fragments) */
129
- opal_free_list_t sm_frags_user ; /**< free list of small inline frags */
130
- opal_free_list_t sm_fboxes ; /**< free list of available fast-boxes */
131
-
132
- unsigned int fbox_threshold ; /**< number of sends required before we setup a send fast box for a peer */
133
- unsigned int fbox_max ; /**< maximum number of send fast boxes to allocate */
134
- unsigned int fbox_size ; /**< size of each peer fast box allocation */
135
-
136
- int single_copy_mechanism ; /**< single copy mechanism to use */
137
-
138
- int memcpy_limit ; /**< Limit where we switch from memmove to memcpy */
139
- int log_attach_align ; /**< Log of the alignment for xpmem segments */
140
- unsigned int max_inline_send ; /**< Limit for copy-in-copy-out fragments */
141
-
142
- mca_btl_base_endpoint_t * endpoints ; /**< array of local endpoints (one for each local peer including myself) */
143
- mca_btl_base_endpoint_t * * fbox_in_endpoints ; /**< array of fast box in endpoints */
144
- unsigned int num_fbox_in_endpoints ; /**< number of fast boxes to poll */
145
- struct sm_fifo_t * my_fifo ; /**< pointer to the local fifo */
146
-
147
- opal_list_t pending_endpoints ; /**< list of endpoints with pending fragments */
148
- opal_list_t pending_fragments ; /**< fragments pending remote completion */
149
-
150
- char * backing_directory ; /**< directory to place shared memory backing files */
151
-
152
- /* knem stuff */
153
- #if OPAL_BTL_SM_HAVE_KNEM
154
- unsigned int knem_dma_min ; /**< minimum size to enable DMA for knem transfers (0 disables) */
155
- #endif
156
- mca_mpool_base_module_t * mpool ;
157
- };
158
- typedef struct mca_btl_sm_component_t mca_btl_sm_component_t ;
159
77
OPAL_MODULE_DECLSPEC extern mca_btl_sm_component_t mca_btl_sm_component ;
160
-
161
- /**
162
- * SM BTL Interface
163
- */
164
- struct mca_btl_sm_t {
165
- mca_btl_base_module_t super ; /**< base BTL interface */
166
- bool btl_inited ; /**< flag indicating if btl has been inited */
167
- mca_btl_base_module_error_cb_fn_t error_cb ;
168
- #if OPAL_BTL_SM_HAVE_KNEM
169
- int knem_fd ;
170
-
171
- /* registration cache */
172
- mca_rcache_base_module_t * knem_rcache ;
173
- #endif
174
- };
175
- typedef struct mca_btl_sm_t mca_btl_sm_t ;
176
78
OPAL_MODULE_DECLSPEC extern mca_btl_sm_t mca_btl_sm ;
177
79
178
80
/* number of peers on the node (not including self) */
@@ -183,12 +85,12 @@ OPAL_MODULE_DECLSPEC extern mca_btl_sm_t mca_btl_sm;
183
85
184
86
/* memcpy is faster at larger sizes but is undefined if the
185
87
pointers are aliased (TODO -- readd alias check) */
186
- static inline void sm_memmove (void * dst , void * src , size_t size )
88
+ static inline void sm_memmove (void * dst , void * src , size_t size )
187
89
{
188
90
if (size >= (size_t ) mca_btl_sm_component .memcpy_limit ) {
189
- memcpy (dst , src , size );
91
+ memcpy (dst , src , size );
190
92
} else {
191
- memmove (dst , src , size );
93
+ memmove (dst , src , size );
192
94
}
193
95
}
194
96
@@ -198,24 +100,19 @@ static inline void sm_memmove (void *dst, void *src, size_t size)
198
100
* @param btl (IN) BTL module
199
101
* @param peer (IN) BTL peer addressing
200
102
*/
201
- int mca_btl_sm_send (struct mca_btl_base_module_t * btl ,
202
- struct mca_btl_base_endpoint_t * endpoint ,
203
- struct mca_btl_base_descriptor_t * descriptor ,
204
- mca_btl_base_tag_t tag );
103
+ int mca_btl_sm_send (struct mca_btl_base_module_t * btl , struct mca_btl_base_endpoint_t * endpoint ,
104
+ struct mca_btl_base_descriptor_t * descriptor , mca_btl_base_tag_t tag );
205
105
206
106
/**
207
107
* Initiate an inline send to the peer.
208
108
*
209
109
* @param btl (IN) BTL module
210
110
* @param peer (IN) BTL peer addressing
211
111
*/
212
- int mca_btl_sm_sendi (struct mca_btl_base_module_t * btl ,
213
- struct mca_btl_base_endpoint_t * endpoint ,
214
- struct opal_convertor_t * convertor ,
215
- void * header , size_t header_size ,
216
- size_t payload_size , uint8_t order ,
217
- uint32_t flags , mca_btl_base_tag_t tag ,
218
- mca_btl_base_descriptor_t * * descriptor );
112
+ int mca_btl_sm_sendi (struct mca_btl_base_module_t * btl , struct mca_btl_base_endpoint_t * endpoint ,
113
+ struct opal_convertor_t * convertor , void * header , size_t header_size ,
114
+ size_t payload_size , uint8_t order , uint32_t flags , mca_btl_base_tag_t tag ,
115
+ mca_btl_base_descriptor_t * * descriptor );
219
116
220
117
/**
221
118
* Initiate an synchronous put.
@@ -225,24 +122,30 @@ int mca_btl_sm_sendi (struct mca_btl_base_module_t *btl,
225
122
* @param descriptor (IN) Description of the data to be transferred
226
123
*/
227
124
#if OPAL_BTL_SM_HAVE_XPMEM
228
- int mca_btl_sm_put_xpmem (mca_btl_base_module_t * btl , mca_btl_base_endpoint_t * endpoint , void * local_address ,
229
- uint64_t remote_address , mca_btl_base_registration_handle_t * local_handle ,
230
- mca_btl_base_registration_handle_t * remote_handle , size_t size , int flags ,
231
- int order , mca_btl_base_rdma_completion_fn_t cbfunc , void * cbcontext , void * cbdata );
125
+ int mca_btl_sm_put_xpmem (mca_btl_base_module_t * btl , mca_btl_base_endpoint_t * endpoint ,
126
+ void * local_address , uint64_t remote_address ,
127
+ mca_btl_base_registration_handle_t * local_handle ,
128
+ mca_btl_base_registration_handle_t * remote_handle , size_t size , int flags ,
129
+ int order , mca_btl_base_rdma_completion_fn_t cbfunc , void * cbcontext ,
130
+ void * cbdata );
232
131
#endif
233
132
234
133
#if OPAL_BTL_SM_HAVE_CMA
235
- int mca_btl_sm_put_cma (mca_btl_base_module_t * btl , mca_btl_base_endpoint_t * endpoint , void * local_address ,
236
- uint64_t remote_address , mca_btl_base_registration_handle_t * local_handle ,
237
- mca_btl_base_registration_handle_t * remote_handle , size_t size , int flags ,
238
- int order , mca_btl_base_rdma_completion_fn_t cbfunc , void * cbcontext , void * cbdata );
134
+ int mca_btl_sm_put_cma (mca_btl_base_module_t * btl , mca_btl_base_endpoint_t * endpoint ,
135
+ void * local_address , uint64_t remote_address ,
136
+ mca_btl_base_registration_handle_t * local_handle ,
137
+ mca_btl_base_registration_handle_t * remote_handle , size_t size , int flags ,
138
+ int order , mca_btl_base_rdma_completion_fn_t cbfunc , void * cbcontext ,
139
+ void * cbdata );
239
140
#endif
240
141
241
142
#if OPAL_BTL_SM_HAVE_KNEM
242
- int mca_btl_sm_put_knem (mca_btl_base_module_t * btl , mca_btl_base_endpoint_t * endpoint , void * local_address ,
243
- uint64_t remote_address , mca_btl_base_registration_handle_t * local_handle ,
244
- mca_btl_base_registration_handle_t * remote_handle , size_t size , int flags ,
245
- int order , mca_btl_base_rdma_completion_fn_t cbfunc , void * cbcontext , void * cbdata );
143
+ int mca_btl_sm_put_knem (mca_btl_base_module_t * btl , mca_btl_base_endpoint_t * endpoint ,
144
+ void * local_address , uint64_t remote_address ,
145
+ mca_btl_base_registration_handle_t * local_handle ,
146
+ mca_btl_base_registration_handle_t * remote_handle , size_t size , int flags ,
147
+ int order , mca_btl_base_rdma_completion_fn_t cbfunc , void * cbcontext ,
148
+ void * cbdata );
246
149
#endif
247
150
248
151
/**
@@ -253,24 +156,30 @@ int mca_btl_sm_put_knem (mca_btl_base_module_t *btl, mca_btl_base_endpoint_t *en
253
156
* @param descriptor (IN) Description of the data to be transferred
254
157
*/
255
158
#if OPAL_BTL_SM_HAVE_XPMEM
256
- int mca_btl_sm_get_xpmem (mca_btl_base_module_t * btl , mca_btl_base_endpoint_t * endpoint , void * local_address ,
257
- uint64_t remote_address , mca_btl_base_registration_handle_t * local_handle ,
258
- mca_btl_base_registration_handle_t * remote_handle , size_t size , int flags ,
259
- int order , mca_btl_base_rdma_completion_fn_t cbfunc , void * cbcontext , void * cbdata );
159
+ int mca_btl_sm_get_xpmem (mca_btl_base_module_t * btl , mca_btl_base_endpoint_t * endpoint ,
160
+ void * local_address , uint64_t remote_address ,
161
+ mca_btl_base_registration_handle_t * local_handle ,
162
+ mca_btl_base_registration_handle_t * remote_handle , size_t size , int flags ,
163
+ int order , mca_btl_base_rdma_completion_fn_t cbfunc , void * cbcontext ,
164
+ void * cbdata );
260
165
#endif
261
166
262
167
#if OPAL_BTL_SM_HAVE_CMA
263
- int mca_btl_sm_get_cma (mca_btl_base_module_t * btl , mca_btl_base_endpoint_t * endpoint , void * local_address ,
264
- uint64_t remote_address , mca_btl_base_registration_handle_t * local_handle ,
265
- mca_btl_base_registration_handle_t * remote_handle , size_t size , int flags ,
266
- int order , mca_btl_base_rdma_completion_fn_t cbfunc , void * cbcontext , void * cbdata );
168
+ int mca_btl_sm_get_cma (mca_btl_base_module_t * btl , mca_btl_base_endpoint_t * endpoint ,
169
+ void * local_address , uint64_t remote_address ,
170
+ mca_btl_base_registration_handle_t * local_handle ,
171
+ mca_btl_base_registration_handle_t * remote_handle , size_t size , int flags ,
172
+ int order , mca_btl_base_rdma_completion_fn_t cbfunc , void * cbcontext ,
173
+ void * cbdata );
267
174
#endif
268
175
269
176
#if OPAL_BTL_SM_HAVE_KNEM
270
- int mca_btl_sm_get_knem (mca_btl_base_module_t * btl , mca_btl_base_endpoint_t * endpoint , void * local_address ,
271
- uint64_t remote_address , mca_btl_base_registration_handle_t * local_handle ,
272
- mca_btl_base_registration_handle_t * remote_handle , size_t size , int flags ,
273
- int order , mca_btl_base_rdma_completion_fn_t cbfunc , void * cbcontext , void * cbdata );
177
+ int mca_btl_sm_get_knem (mca_btl_base_module_t * btl , mca_btl_base_endpoint_t * endpoint ,
178
+ void * local_address , uint64_t remote_address ,
179
+ mca_btl_base_registration_handle_t * local_handle ,
180
+ mca_btl_base_registration_handle_t * remote_handle , size_t size , int flags ,
181
+ int order , mca_btl_base_rdma_completion_fn_t cbfunc , void * cbcontext ,
182
+ void * cbdata );
274
183
#endif
275
184
276
185
ino_t mca_btl_sm_get_user_ns_id (void );
@@ -281,18 +190,17 @@ ino_t mca_btl_sm_get_user_ns_id(void);
281
190
* @param btl (IN) BTL module
282
191
* @param size (IN) Request segment size.
283
192
*/
284
- mca_btl_base_descriptor_t * mca_btl_sm_alloc (struct mca_btl_base_module_t * btl ,
285
- struct mca_btl_base_endpoint_t * endpoint ,
286
- uint8_t order , size_t size , uint32_t flags );
193
+ mca_btl_base_descriptor_t * mca_btl_sm_alloc (struct mca_btl_base_module_t * btl ,
194
+ struct mca_btl_base_endpoint_t * endpoint , uint8_t order ,
195
+ size_t size , uint32_t flags );
287
196
288
197
/**
289
198
* Return a segment allocated by this BTL.
290
199
*
291
200
* @param btl (IN) BTL module
292
201
* @param segment (IN) Allocated segment.
293
202
*/
294
- int mca_btl_sm_free (struct mca_btl_base_module_t * btl , mca_btl_base_descriptor_t * des );
295
-
203
+ int mca_btl_sm_free (struct mca_btl_base_module_t * btl , mca_btl_base_descriptor_t * des );
296
204
297
205
END_C_DECLS
298
206
0 commit comments