32
32
#include "opal/datatype/opal_convertor.h"
33
33
#include "ompi/mca/mpool/base/base.h"
34
34
#include "ompi/mca/mpool/mpool.h"
35
- #include "ompi/proc/proc.h"
35
+ #include "btl_tcp.h"
36
+ #include "btl_tcp_frag.h"
37
+ #include "btl_tcp_proc.h"
38
+ #include "btl_tcp_endpoint.h"
36
39
37
40
mca_btl_tcp2_module_t mca_btl_tcp2_module = {
38
41
{
@@ -57,9 +60,9 @@ mca_btl_tcp2_module_t mca_btl_tcp2_module = {
57
60
mca_btl_tcp2_prepare_dst ,
58
61
mca_btl_tcp2_send ,
59
62
NULL , /* send immediate */
60
- mca_btl_tcp2_put ,
61
- NULL , /* get */
62
- mca_btl_base_dump ,
63
+ mca_btl_tcp_put ,
64
+ NULL , /* get */
65
+ mca_btl_tcp_dump ,
63
66
NULL , /* mpool */
64
67
NULL , /* register error */
65
68
mca_btl_tcp2_ft_event
@@ -134,7 +137,9 @@ int mca_btl_tcp2_add_procs( struct mca_btl_base_module_t* btl,
134
137
/* we increase the count of MPI users of the event library
135
138
once per peer, so that we are used until we aren't
136
139
connected to a peer */
140
+ #if !MCA_BTL_TCP_USES_PROGRESS_THREAD
137
141
opal_progress_event_users_increment ();
142
+ #endif /* !MCA_BTL_TCP_USES_PROGRESS_THREAD */
138
143
}
139
144
140
145
return OMPI_SUCCESS ;
@@ -153,7 +158,9 @@ int mca_btl_tcp2_del_procs(struct mca_btl_base_module_t* btl,
153
158
opal_list_remove_item (& tcp_btl -> tcp_endpoints , (opal_list_item_t * )tcp_endpoint );
154
159
OBJ_RELEASE (tcp_endpoint );
155
160
}
161
+ #if !MCA_BTL_TCP_USES_PROGRESS_THREAD
156
162
opal_progress_event_users_decrement ();
163
+ #endif /* !MCA_BTL_TCP_USES_PROGRESS_THREAD */
157
164
}
158
165
return OMPI_SUCCESS ;
159
166
}
@@ -183,7 +190,11 @@ mca_btl_base_descriptor_t* mca_btl_tcp2_alloc(
183
190
if ( OPAL_UNLIKELY (NULL == frag ) ) {
184
191
return NULL ;
185
192
}
186
-
193
+
194
+ #define GB_DEFINED 0
195
+ #if GB_DEFINED
196
+ opal_output (0 , "alloc_frag( size = %lu )\n" , size );
197
+ #endif /* GB_DEFINED */
187
198
frag -> segments [0 ].seg_len = size ;
188
199
frag -> segments [0 ].seg_addr .pval = frag + 1 ;
189
200
@@ -193,7 +204,8 @@ mca_btl_base_descriptor_t* mca_btl_tcp2_alloc(
193
204
frag -> base .des_dst_cnt = 0 ;
194
205
frag -> base .des_flags = flags ;
195
206
frag -> base .order = MCA_BTL_NO_ORDER ;
196
- frag -> btl = (mca_btl_tcp2_module_t * )btl ;
207
+ frag -> btl = (mca_btl_tcp_module_t * )btl ;
208
+ frag -> endpoint = endpoint ;
197
209
return (mca_btl_base_descriptor_t * )frag ;
198
210
}
199
211
@@ -296,6 +308,10 @@ mca_btl_base_descriptor_t* mca_btl_tcp2_prepare_src(
296
308
frag -> base .des_flags = flags ;
297
309
frag -> base .order = MCA_BTL_NO_ORDER ;
298
310
* size = max_data ;
311
+ #if GB_DEFINED
312
+ opal_output (0 , "prepare_src( bConverted = %lu, size = %lu\n" ,
313
+ convertor -> bConverted , * size );
314
+ #endif /* GB_DEFINED */
299
315
return & frag -> base ;
300
316
}
301
317
@@ -343,6 +359,10 @@ mca_btl_base_descriptor_t* mca_btl_tcp2_prepare_dst(
343
359
frag -> base .des_dst_cnt = 1 ;
344
360
frag -> base .des_flags = flags ;
345
361
frag -> base .order = MCA_BTL_NO_ORDER ;
362
+ #if GB_DEFINED
363
+ opal_output (0 , " prepare_dst( bConverted = %lu, size = %lu\n" ,
364
+ convertor -> bConverted , * size );
365
+ #endif /* GB_DEFINED */
346
366
return & frag -> base ;
347
367
}
348
368
@@ -384,7 +404,10 @@ int mca_btl_tcp2_send( struct mca_btl_base_module_t* btl,
384
404
frag -> hdr .type = MCA_BTL_TCP_HDR_TYPE_SEND ;
385
405
frag -> hdr .count = 0 ;
386
406
if (endpoint -> endpoint_nbo ) MCA_BTL_TCP_HDR_HTON (frag -> hdr );
387
- return mca_btl_tcp2_endpoint_send (endpoint ,frag );
407
+ #if GB_DEFINED
408
+ opal_output (0 , "frag_send( size = %u )\n" , frag -> hdr .size );
409
+ #endif /* GB_DEFINED */
410
+ return mca_btl_tcp_endpoint_send (endpoint ,frag );
388
411
}
389
412
390
413
@@ -425,7 +448,10 @@ int mca_btl_tcp2_put( mca_btl_base_module_t* btl,
425
448
frag -> hdr .type = MCA_BTL_TCP_HDR_TYPE_PUT ;
426
449
frag -> hdr .count = frag -> base .des_dst_cnt ;
427
450
if (endpoint -> endpoint_nbo ) MCA_BTL_TCP_HDR_HTON (frag -> hdr );
428
- return ((i = mca_btl_tcp2_endpoint_send (endpoint ,frag )) >= 0 ? OMPI_SUCCESS : i );
451
+ #if GB_DEFINED
452
+ opal_output (0 , "frag_put( size = %u )\n" , frag -> hdr .size );
453
+ #endif /* GB_DEFINED */
454
+ return ((i = mca_btl_tcp_endpoint_send (endpoint ,frag )) >= 0 ? OMPI_SUCCESS : i );
429
455
}
430
456
431
457
@@ -462,12 +488,16 @@ int mca_btl_tcp2_get(
462
488
frag -> hdr .type = MCA_BTL_TCP_HDR_TYPE_GET ;
463
489
frag -> hdr .count = frag -> base .des_src_cnt ;
464
490
if (endpoint -> endpoint_nbo ) MCA_BTL_TCP_HDR_HTON (frag -> hdr );
465
- return ((rc = mca_btl_tcp2_endpoint_send (endpoint ,frag )) >= 0 ? OMPI_SUCCESS : rc );
491
+ #if GB_DEFINED
492
+ opal_output (0 , "frag_get( size = %u )\n" , frag -> hdr .size );
493
+ #endif /* GB_DEFINED */
494
+ return ((rc = mca_btl_tcp_endpoint_send (endpoint ,frag )) >= 0 ? OMPI_SUCCESS : rc );
466
495
}
467
496
468
497
469
498
/*
470
- * Cleanup/release module resources.
499
+ * Cleanup/release module resources. This function should only be called once,
500
+ * there is no need to protect it.
471
501
*/
472
502
473
503
int mca_btl_tcp2_finalize (struct mca_btl_base_module_t * btl )
@@ -479,8 +509,42 @@ int mca_btl_tcp2_finalize(struct mca_btl_base_module_t* btl)
479
509
item = opal_list_remove_first (& tcp_btl -> tcp_endpoints )) {
480
510
mca_btl_tcp2_endpoint_t * endpoint = (mca_btl_tcp2_endpoint_t * )item ;
481
511
OBJ_RELEASE (endpoint );
512
+ #if !MCA_BTL_TCP_USES_PROGRESS_THREAD
482
513
opal_progress_event_users_decrement ();
514
+ #endif /* !MCA_BTL_TCP_USES_PROGRESS_THREAD */
483
515
}
484
516
free (tcp_btl );
485
517
return OMPI_SUCCESS ;
486
518
}
519
+
520
+ /**
521
+ *
522
+ */
523
+ void mca_btl_tcp_dump (struct mca_btl_base_module_t * base_btl ,
524
+ struct mca_btl_base_endpoint_t * endpoint ,
525
+ int verbose )
526
+ {
527
+ mca_btl_tcp_module_t * btl = (mca_btl_tcp_module_t * )base_btl ;
528
+ mca_btl_base_err ("%s TCP %p kernel_id %d\n"
529
+ #if MCA_BTL_TCP_STATISTICS
530
+ " | statistics: sent %lu recv %lu\n"
531
+ #endif /* MCA_BTL_TCP_STATISTICS */
532
+ " | latency %u bandwidth %u\n" ,
533
+ ORTE_NAME_PRINT (ORTE_PROC_MY_NAME ), (void * )btl , btl -> tcp_ifkindex ,
534
+ #if MCA_BTL_TCP_STATISTICS
535
+ btl -> tcp_bytes_sent , btl -> btl_bytes_recv ,
536
+ #endif /* MCA_BTL_TCP_STATISTICS */
537
+ btl -> super .btl_latency , btl -> super .btl_bandwidth );
538
+ if ( NULL != endpoint ) {
539
+ mca_btl_tcp_endpoint_dump ( endpoint , "TCP" );
540
+ } else if ( verbose ) {
541
+ opal_list_item_t * item ;
542
+
543
+ for (item = opal_list_get_first (& btl -> tcp_endpoints );
544
+ item != opal_list_get_end (& btl -> tcp_endpoints );
545
+ item = opal_list_get_next (item )) {
546
+ mca_btl_tcp_endpoint_dump ( (mca_btl_base_endpoint_t * )item , "TCP" );
547
+ }
548
+ }
549
+ }
550
+
0 commit comments