This source file includes following definitions.
- mca_btl_template_add_procs
- mca_btl_template_del_procs
- mca_btl_template_register
- mca_btl_template_alloc
- mca_btl_template_free
- mca_btl_template_prepare_src
- mca_btl_template_send
- mca_btl_template_put
- mca_btl_template_get
- mca_btl_template_register_mem
- mca_btl_template_deregister_mem
- mca_btl_template_finalize
- mca_btl_template_ft_event
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 #include "opal_config.h"
23 #include <string.h>
24 #include "opal/class/opal_bitmap.h"
25 #include "opal/mca/btl/btl.h"
26 #include "opal/datatype/opal_convertor.h"
27 #include "opal/mca/mpool/base/base.h"
28 #include "opal/mca/mpool/mpool.h"
29
30 #include "btl_template.h"
31 #include "btl_template_frag.h"
32 #include "btl_template_proc.h"
33 #include "btl_template_endpoint.h"
34
35
36 mca_btl_template_module_t mca_btl_template_module = {
37 .super = {
38 .btl_component = &mca_btl_template_component.super,
39 .btl_add_procs = mca_btl_template_add_procs,
40 .btl_del_procs = mca_btl_template_del_procs,
41 .btl_register = mca_btl_template_register,
42 .btl_finalize = mca_btl_template_finalize,
43 .btl_alloc = mca_btl_template_alloc,
44 .btl_free = mca_btl_template_free,
45 .btl_prepare_src = mca_btl_template_prepare_src,
46 .btl_send = mca_btl_template_send,
47 .btl_put = mca_btl_template_put,
48 .btl_get = mca_btl_template_get,
49 .btl_register_mem = mca_btl_template_register_mem,
50 .btl_deregister_mem = mca_btl_template_deregister_mem,
51 .btl_ft_event = mca_btl_template_ft_event
52 }
53 };
54
55
56
57
58
59 int mca_btl_template_add_procs(
60 struct mca_btl_base_module_t* btl,
61 size_t nprocs,
62 struct opal_proc_t **opal_procs,
63 struct mca_btl_base_endpoint_t** peers,
64 opal_bitmap_t* reachable)
65 {
66 mca_btl_template_module_t* template_btl = (mca_btl_template_module_t*)btl;
67 int i, rc;
68
69 for(i = 0; i < (int) nprocs; i++) {
70
71 struct opal_proc_t* opal_proc = opal_procs[i];
72 mca_btl_template_proc_t* template_proc;
73 mca_btl_base_endpoint_t* template_endpoint;
74
75 #if 0
76
77
78 if (opal_proc_local()->proc_arch != opal_proc->proc_arch) {
79 continue;
80 }
81 #endif
82
83 if(NULL == (template_proc = mca_btl_template_proc_create(opal_proc))) {
84 return OPAL_ERR_OUT_OF_RESOURCE;
85 }
86
87
88
89
90
91
92
93 OPAL_THREAD_LOCK(&template_proc->proc_lock);
94
95
96
97
98
99 template_endpoint = OBJ_NEW(mca_btl_template_endpoint_t);
100 if(NULL == template_endpoint) {
101 OPAL_THREAD_UNLOCK(&template_proc->proc_lock);
102 return OPAL_ERR_OUT_OF_RESOURCE;
103 }
104
105 template_endpoint->endpoint_btl = template_btl;
106 rc = mca_btl_template_proc_insert(template_proc, template_endpoint);
107 if(rc != OPAL_SUCCESS) {
108 OBJ_RELEASE(template_endpoint);
109 OPAL_THREAD_UNLOCK(&template_proc->proc_lock);
110 continue;
111 }
112
113 opal_bitmap_set_bit(reachable, i);
114 OPAL_THREAD_UNLOCK(&template_proc->proc_lock);
115 peers[i] = template_endpoint;
116 }
117
118 return OPAL_SUCCESS;
119 }
120
121 int mca_btl_template_del_procs(struct mca_btl_base_module_t* btl,
122 size_t nprocs,
123 struct opal_proc_t **procs,
124 struct mca_btl_base_endpoint_t ** peers)
125 {
126
127 return OPAL_SUCCESS;
128 }
129
130
131
132
133
134
135 int mca_btl_template_register(
136 struct mca_btl_base_module_t* btl,
137 mca_btl_base_tag_t tag,
138 mca_btl_base_module_recv_cb_fn_t cbfunc,
139 void* cbdata)
140 {
141 return OPAL_SUCCESS;
142 }
143
144
145
146
147
148
149
150
151
152 mca_btl_base_descriptor_t* mca_btl_template_alloc(
153 struct mca_btl_base_module_t* btl,
154 struct mca_btl_base_endpoint_t* endpoint,
155 uint8_t order,
156 size_t size,
157 uint32_t flags)
158 {
159 mca_btl_template_module_t* template_btl = (mca_btl_template_module_t*) btl;
160 mca_btl_template_frag_t* frag = NULL;
161
162 if(size <= btl->btl_eager_limit){
163 MCA_BTL_TEMPLATE_FRAG_ALLOC_EAGER(template_btl, frag);
164 } else {
165 MCA_BTL_TEMPLATE_FRAG_ALLOC_MAX(template_btl, frag);
166 }
167 if( OPAL_UNLIKELY(NULL != frag) ) {
168 return NULL;
169 }
170
171 frag->segment.seg_len = size;
172 frag->base.des_flags = 0;
173 return (mca_btl_base_descriptor_t*)frag;
174 }
175
176
177
178
179
180
181 int mca_btl_template_free(
182 struct mca_btl_base_module_t* btl,
183 mca_btl_base_descriptor_t* des)
184 {
185 mca_btl_template_frag_t* frag = (mca_btl_template_frag_t*)des;
186 if(frag->size == 0) {
187 #if MCA_BTL_HAS_MPOOL
188 OBJ_RELEASE(frag->registration);
189 #endif
190 MCA_BTL_TEMPLATE_FRAG_RETURN_USER(btl, frag);
191 } else if(frag->size == btl->btl_eager_limit){
192 MCA_BTL_TEMPLATE_FRAG_RETURN_EAGER(btl, frag);
193 } else if(frag->size == btl->btl_max_send_size) {
194 MCA_BTL_TEMPLATE_FRAG_RETURN_EAGER(btl, frag);
195 } else {
196 return OPAL_ERR_BAD_PARAM;
197 }
198 return OPAL_SUCCESS;
199 }
200
201
202
203
204
205
206
207
208 mca_btl_base_descriptor_t* mca_btl_template_prepare_src(
209 struct mca_btl_base_module_t* btl,
210 struct mca_btl_base_endpoint_t* endpoint,
211 struct opal_convertor_t* convertor,
212 uint8_t order,
213 size_t reserve,
214 size_t* size,
215 uint32_t flags
216 )
217 {
218 mca_btl_template_frag_t* frag;
219 struct iovec iov;
220 uint32_t iov_count = 1;
221 size_t max_data = *size;
222 int rc;
223
224
225
226
227
228
229 if (max_data+reserve <= btl->btl_eager_limit) {
230
231 MCA_BTL_TEMPLATE_FRAG_ALLOC_EAGER(btl, frag);
232 if(OPAL_UNLIKELY(NULL == frag)) {
233 return NULL;
234 }
235
236 iov.iov_len = max_data;
237 iov.iov_base = (unsigned char*) frag->segment.seg_addr.pval + reserve;
238
239 rc = opal_convertor_pack(convertor, &iov, &iov_count, &max_data );
240 *size = max_data;
241 if( rc < 0 ) {
242 MCA_BTL_TEMPLATE_FRAG_RETURN_EAGER(btl, frag);
243 return NULL;
244 }
245 frag->segment.seg_len = max_data + reserve;
246 }
247
248
249
250
251
252 else {
253
254 MCA_BTL_TEMPLATE_FRAG_ALLOC_MAX(btl, frag);
255 if(OPAL_UNLIKELY(NULL == frag)) {
256 return NULL;
257 }
258 if(max_data + reserve > frag->size){
259 max_data = frag->size - reserve;
260 }
261 iov.iov_len = max_data;
262 iov.iov_base = (unsigned char*) frag->segment.seg_addr.pval + reserve;
263
264 rc = opal_convertor_pack(convertor, &iov, &iov_count, &max_data );
265 *size = max_data;
266
267 if( rc < 0 ) {
268 MCA_BTL_TEMPLATE_FRAG_RETURN_MAX(btl, frag);
269 return NULL;
270 }
271 frag->segment.seg_len = max_data + reserve;
272 }
273
274 frag->base.des_segments = &frag->segment;
275 frag->base.des_segment_count = 1;
276 frag->base.des_flags = 0;
277 return &frag->base;
278 }
279
280
281
282
283
284
285
286
287
288
289
290 int mca_btl_template_send(
291 struct mca_btl_base_module_t* btl,
292 struct mca_btl_base_endpoint_t* endpoint,
293 struct mca_btl_base_descriptor_t* descriptor,
294 mca_btl_base_tag_t tag)
295
296 {
297
298 mca_btl_template_frag_t* frag = (mca_btl_template_frag_t*)descriptor;
299 frag->endpoint = endpoint;
300
301 return OPAL_ERR_NOT_IMPLEMENTED;
302 }
303
304
305
306
307
308
309
310
311
312
313 int mca_btl_template_put (struct mca_btl_base_module_t *btl,
314 struct mca_btl_base_endpoint_t *endpoint, void *local_address,
315 uint64_t remote_address, struct mca_btl_base_registration_handle_t *local_handle,
316 struct mca_btl_base_registration_handle_t *remote_handle, size_t size, int flags,
317 int order, mca_btl_base_rdma_completion_fn_t cbfunc, void *cbcontext, void *cbdata)
318 {
319
320
321 return OPAL_ERR_NOT_IMPLEMENTED;
322 }
323
324
325
326
327
328
329
330
331
332
333
334 int mca_btl_template_get (struct mca_btl_base_module_t *btl,
335 struct mca_btl_base_endpoint_t *endpoint, void *local_address,
336 uint64_t remote_address, struct mca_btl_base_registration_handle_t *local_handle,
337 struct mca_btl_base_registration_handle_t *remote_handle, size_t size, int flags,
338 int order, mca_btl_base_rdma_completion_fn_t cbfunc, void *cbcontext, void *cbdata)
339 {
340
341
342 return OPAL_ERR_NOT_IMPLEMENTED;
343 }
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364 struct mca_btl_base_registration_handle_t *mca_btl_template_register_mem (
365 struct mca_btl_base_module_t* btl, struct mca_btl_base_endpoint_t *endpoint, void *base,
366 size_t size, uint32_t flags)
367 {
368
369
370 return NULL;
371 }
372
373
374
375
376
377
378
379
380
381
382
383
384 int mca_btl_template_deregister_mem (struct mca_btl_base_module_t* btl,
385 struct mca_btl_base_registration_handle_t *handle)
386 {
387
388
389 return OPAL_ERR_NOT_IMPLEMENTED;
390 }
391
392
393
394
395
396
397 int mca_btl_template_finalize(struct mca_btl_base_module_t* btl)
398 {
399 mca_btl_template_module_t* template_btl = (mca_btl_template_module_t*) btl;
400 OBJ_DESTRUCT(&template_btl->template_lock);
401 OBJ_DESTRUCT(&template_btl->template_frag_eager);
402 OBJ_DESTRUCT(&template_btl->template_frag_max);
403 OBJ_DESTRUCT(&template_btl->template_frag_user);
404 free(template_btl);
405 return OPAL_SUCCESS;
406 }
407
408 int mca_btl_template_ft_event(int state) {
409 if(OPAL_CRS_CHECKPOINT == state) {
410 ;
411 }
412 else if(OPAL_CRS_CONTINUE == state) {
413 ;
414 }
415 else if(OPAL_CRS_RESTART == state) {
416 ;
417 }
418 else if(OPAL_CRS_TERM == state ) {
419 ;
420 }
421 else {
422 ;
423 }
424
425 return OPAL_SUCCESS;
426 }