3232#include "opal/datatype/opal_convertor.h"
3333#include "ompi/mca/mpool/base/base.h"
3434#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"
3639
3740mca_btl_tcp2_module_t mca_btl_tcp2_module = {
3841 {
@@ -57,9 +60,9 @@ mca_btl_tcp2_module_t mca_btl_tcp2_module = {
5760 mca_btl_tcp2_prepare_dst ,
5861 mca_btl_tcp2_send ,
5962 NULL , /* send immediate */
60- mca_btl_tcp2_put ,
63+ mca_btl_tcp_put ,
6164 NULL , /* get */
62- mca_btl_base_dump ,
65+ mca_btl_tcp_dump ,
6366 NULL , /* mpool */
6467 NULL , /* register error */
6568 mca_btl_tcp2_ft_event
@@ -134,7 +137,9 @@ int mca_btl_tcp2_add_procs( struct mca_btl_base_module_t* btl,
134137 /* we increase the count of MPI users of the event library
135138 once per peer, so that we are used until we aren't
136139 connected to a peer */
140+ #if !MCA_BTL_TCP_USES_PROGRESS_THREAD
137141 opal_progress_event_users_increment ();
142+ #endif /* !MCA_BTL_TCP_USES_PROGRESS_THREAD */
138143 }
139144
140145 return OMPI_SUCCESS ;
@@ -153,7 +158,9 @@ int mca_btl_tcp2_del_procs(struct mca_btl_base_module_t* btl,
153158 opal_list_remove_item (& tcp_btl -> tcp_endpoints , (opal_list_item_t * )tcp_endpoint );
154159 OBJ_RELEASE (tcp_endpoint );
155160 }
161+ #if !MCA_BTL_TCP_USES_PROGRESS_THREAD
156162 opal_progress_event_users_decrement ();
163+ #endif /* !MCA_BTL_TCP_USES_PROGRESS_THREAD */
157164 }
158165 return OMPI_SUCCESS ;
159166}
@@ -193,7 +200,8 @@ mca_btl_base_descriptor_t* mca_btl_tcp2_alloc(
193200 frag -> base .des_dst_cnt = 0 ;
194201 frag -> base .des_flags = flags ;
195202 frag -> base .order = MCA_BTL_NO_ORDER ;
196- frag -> btl = (mca_btl_tcp2_module_t * )btl ;
203+ frag -> btl = (mca_btl_tcp_module_t * )btl ;
204+ frag -> endpoint = endpoint ;
197205 return (mca_btl_base_descriptor_t * )frag ;
198206}
199207
@@ -384,7 +392,7 @@ int mca_btl_tcp2_send( struct mca_btl_base_module_t* btl,
384392 frag -> hdr .type = MCA_BTL_TCP_HDR_TYPE_SEND ;
385393 frag -> hdr .count = 0 ;
386394 if (endpoint -> endpoint_nbo ) MCA_BTL_TCP_HDR_HTON (frag -> hdr );
387- return mca_btl_tcp2_endpoint_send (endpoint ,frag );
395+ return mca_btl_tcp_endpoint_send (endpoint ,frag );
388396}
389397
390398
@@ -425,7 +433,7 @@ int mca_btl_tcp2_put( mca_btl_base_module_t* btl,
425433 frag -> hdr .type = MCA_BTL_TCP_HDR_TYPE_PUT ;
426434 frag -> hdr .count = frag -> base .des_dst_cnt ;
427435 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 );
436+ return ((i = mca_btl_tcp_endpoint_send (endpoint ,frag )) >= 0 ? OMPI_SUCCESS : i );
429437}
430438
431439
@@ -462,12 +470,13 @@ int mca_btl_tcp2_get(
462470 frag -> hdr .type = MCA_BTL_TCP_HDR_TYPE_GET ;
463471 frag -> hdr .count = frag -> base .des_src_cnt ;
464472 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 );
473+ return ((rc = mca_btl_tcp_endpoint_send (endpoint ,frag )) >= 0 ? OMPI_SUCCESS : rc );
466474}
467475
468476
469477/*
470- * Cleanup/release module resources.
478+ * Cleanup/release module resources. This function should only be called once,
479+ * there is no need to protect it.
471480 */
472481
473482int mca_btl_tcp2_finalize (struct mca_btl_base_module_t * btl )
@@ -479,8 +488,42 @@ int mca_btl_tcp2_finalize(struct mca_btl_base_module_t* btl)
479488 item = opal_list_remove_first (& tcp_btl -> tcp_endpoints )) {
480489 mca_btl_tcp2_endpoint_t * endpoint = (mca_btl_tcp2_endpoint_t * )item ;
481490 OBJ_RELEASE (endpoint );
491+ #if !MCA_BTL_TCP_USES_PROGRESS_THREAD
482492 opal_progress_event_users_decrement ();
493+ #endif /* !MCA_BTL_TCP_USES_PROGRESS_THREAD */
483494 }
484495 free (tcp_btl );
485496 return OMPI_SUCCESS ;
486497}
498+
499+ /**
500+ *
501+ */
502+ void mca_btl_tcp_dump (struct mca_btl_base_module_t * base_btl ,
503+ struct mca_btl_base_endpoint_t * endpoint ,
504+ int verbose )
505+ {
506+ mca_btl_tcp_module_t * btl = (mca_btl_tcp_module_t * )base_btl ;
507+ mca_btl_base_err ("%s TCP %p kernel_id %d\n"
508+ #if MCA_BTL_TCP_STATISTICS
509+ " | statistics: sent %lu recv %lu\n"
510+ #endif /* MCA_BTL_TCP_STATISTICS */
511+ " | latency %u bandwidth %u\n" ,
512+ ORTE_NAME_PRINT (ORTE_PROC_MY_NAME ), (void * )btl , btl -> tcp_ifkindex ,
513+ #if MCA_BTL_TCP_STATISTICS
514+ btl -> tcp_bytes_sent , btl -> btl_bytes_recv ,
515+ #endif /* MCA_BTL_TCP_STATISTICS */
516+ btl -> super .btl_latency , btl -> super .btl_bandwidth );
517+ if ( NULL != endpoint ) {
518+ mca_btl_tcp_endpoint_dump ( endpoint , "TCP" );
519+ } else if ( verbose ) {
520+ opal_list_item_t * item ;
521+
522+ for (item = opal_list_get_first (& btl -> tcp_endpoints );
523+ item != opal_list_get_end (& btl -> tcp_endpoints );
524+ item = opal_list_get_next (item )) {
525+ mca_btl_tcp_endpoint_dump ( (mca_btl_base_endpoint_t * )item , "TCP" );
526+ }
527+ }
528+ }
529+
0 commit comments