@@ -80,7 +80,8 @@ mca_spml_ucx_t mca_spml_ucx = {
8080 .num_disconnect = 1 ,
8181 .heap_reg_nb = 0 ,
8282 .enabled = 0 ,
83- .get_mkey_slow = NULL
83+ .get_mkey_slow = NULL ,
84+ .synchronized_quiet = false
8485};
8586
8687mca_spml_ucx_ctx_t mca_spml_ucx_ctx_default = {
@@ -216,6 +217,40 @@ static void dump_address(int pe, char *addr, size_t len)
216217
217218static char spml_ucx_transport_ids [1 ] = { 0 };
218219
220+ int mca_spml_ucx_init_put_op_mask (mca_spml_ucx_ctx_t * ctx , size_t nprocs )
221+ {
222+ int res ;
223+
224+ if (mca_spml_ucx .synchronized_quiet ) {
225+ ctx -> put_proc_indexes = malloc (nprocs * sizeof (* ctx -> put_proc_indexes ));
226+ if (NULL == ctx -> put_proc_indexes ) {
227+ return OSHMEM_ERR_OUT_OF_RESOURCE ;
228+ }
229+
230+ OBJ_CONSTRUCT (& ctx -> put_op_bitmap , opal_bitmap_t );
231+ res = opal_bitmap_init (& ctx -> put_op_bitmap , nprocs );
232+ if (OPAL_SUCCESS != res ) {
233+ free (ctx -> put_proc_indexes );
234+ ctx -> put_proc_indexes = NULL ;
235+ return res ;
236+ }
237+
238+ ctx -> put_proc_count = 0 ;
239+ }
240+
241+ return OSHMEM_SUCCESS ;
242+ }
243+
244+ int mca_spml_ucx_clear_put_op_mask (mca_spml_ucx_ctx_t * ctx )
245+ {
246+ if (mca_spml_ucx .synchronized_quiet && ctx -> put_proc_indexes ) {
247+ OBJ_DESTRUCT (& ctx -> put_op_bitmap );
248+ free (ctx -> put_proc_indexes );
249+ }
250+
251+ return OSHMEM_SUCCESS ;
252+ }
253+
219254int mca_spml_ucx_add_procs (ompi_proc_t * * procs , size_t nprocs )
220255{
221256 size_t i , j , n ;
@@ -235,6 +270,11 @@ int mca_spml_ucx_add_procs(ompi_proc_t** procs, size_t nprocs)
235270 goto error ;
236271 }
237272
273+ rc = mca_spml_ucx_init_put_op_mask (& mca_spml_ucx_ctx_default , nprocs );
274+ if (OSHMEM_SUCCESS != rc ) {
275+ goto error ;
276+ }
277+
238278 err = ucp_worker_get_address (mca_spml_ucx_ctx_default .ucp_worker , & wk_local_addr , & wk_addr_len );
239279 if (err != UCS_OK ) {
240280 goto error ;
@@ -297,6 +337,8 @@ int mca_spml_ucx_add_procs(ompi_proc_t** procs, size_t nprocs)
297337 free (mca_spml_ucx .remote_addrs_tbl [i ]);
298338 }
299339 }
340+
341+ mca_spml_ucx_clear_put_op_mask (& mca_spml_ucx_ctx_default );
300342 if (mca_spml_ucx_ctx_default .ucp_peers )
301343 free (mca_spml_ucx_ctx_default .ucp_peers );
302344 if (mca_spml_ucx .remote_addrs_tbl )
@@ -583,6 +625,11 @@ static int mca_spml_ucx_ctx_create_common(long options, mca_spml_ucx_ctx_t **ucx
583625 goto error ;
584626 }
585627
628+ rc = mca_spml_ucx_init_put_op_mask (ucx_ctx , nprocs );
629+ if (OSHMEM_SUCCESS != rc ) {
630+ goto error2 ;
631+ }
632+
586633 for (i = 0 ; i < nprocs ; i ++ ) {
587634 ep_params .field_mask = UCP_EP_PARAM_FIELD_REMOTE_ADDRESS ;
588635 ep_params .address = (ucp_address_t * )(mca_spml_ucx .remote_addrs_tbl [i ]);
@@ -621,6 +668,8 @@ static int mca_spml_ucx_ctx_create_common(long options, mca_spml_ucx_ctx_t **ucx
621668 }
622669 }
623670
671+ mca_spml_ucx_clear_put_op_mask (ucx_ctx );
672+
624673 if (ucx_ctx -> ucp_peers )
625674 free (ucx_ctx -> ucp_peers );
626675
@@ -715,6 +764,7 @@ int mca_spml_ucx_put(shmem_ctx_t ctx, void* dst_addr, size_t size, void* src_add
715764 void * rva ;
716765 spml_ucx_mkey_t * ucx_mkey ;
717766 mca_spml_ucx_ctx_t * ucx_ctx = (mca_spml_ucx_ctx_t * )ctx ;
767+ int res ;
718768#if HAVE_DECL_UCP_PUT_NB
719769 ucs_status_ptr_t request ;
720770#else
@@ -725,12 +775,18 @@ int mca_spml_ucx_put(shmem_ctx_t ctx, void* dst_addr, size_t size, void* src_add
725775#if HAVE_DECL_UCP_PUT_NB
726776 request = ucp_put_nb (ucx_ctx -> ucp_peers [dst ].ucp_conn , src_addr , size ,
727777 (uint64_t )rva , ucx_mkey -> rkey , opal_common_ucx_empty_complete_cb );
728- return opal_common_ucx_wait_request (request , ucx_ctx -> ucp_worker , "ucp_put_nb" );
778+ res = opal_common_ucx_wait_request (request , ucx_ctx -> ucp_worker , "ucp_put_nb" );
729779#else
730780 status = ucp_put (ucx_ctx -> ucp_peers [dst ].ucp_conn , src_addr , size ,
731781 (uint64_t )rva , ucx_mkey -> rkey );
732- return ucx_status_to_oshmem (status );
782+ res = ucx_status_to_oshmem (status );
733783#endif
784+
785+ if (OPAL_LIKELY (OSHMEM_SUCCESS == res )) {
786+ mca_spml_ucx_remote_op_posted (ucx_ctx , dst );
787+ }
788+
789+ return res ;
734790}
735791
736792int mca_spml_ucx_put_nb (shmem_ctx_t ctx , void * dst_addr , size_t size , void * src_addr , int dst , void * * handle )
@@ -744,6 +800,10 @@ int mca_spml_ucx_put_nb(shmem_ctx_t ctx, void* dst_addr, size_t size, void* src_
744800 status = ucp_put_nbi (ucx_ctx -> ucp_peers [dst ].ucp_conn , src_addr , size ,
745801 (uint64_t )rva , ucx_mkey -> rkey );
746802
803+ if (OPAL_LIKELY (status >= 0 )) {
804+ mca_spml_ucx_remote_op_posted (ucx_ctx , dst );
805+ }
806+
747807 return ucx_status_to_oshmem_nb (status );
748808}
749809
@@ -767,9 +827,28 @@ int mca_spml_ucx_fence(shmem_ctx_t ctx)
767827
768828int mca_spml_ucx_quiet (shmem_ctx_t ctx )
769829{
830+ int flush_get_data ;
770831 int ret ;
832+ unsigned i ;
833+ int idx ;
771834 mca_spml_ucx_ctx_t * ucx_ctx = (mca_spml_ucx_ctx_t * )ctx ;
772835
836+ if (mca_spml_ucx .synchronized_quiet ) {
837+ for (i = 0 ; i < ucx_ctx -> put_proc_count ; i ++ ) {
838+ idx = ucx_ctx -> put_proc_indexes [i ];
839+ ret = mca_spml_ucx_get_nb (ctx ,
840+ ucx_ctx -> ucp_peers [idx ].mkeys -> super .super .va_base ,
841+ sizeof (flush_get_data ), & flush_get_data , idx , NULL );
842+ if (OMPI_SUCCESS != ret ) {
843+ oshmem_shmem_abort (-1 );
844+ return ret ;
845+ }
846+
847+ opal_bitmap_clear_bit (& ucx_ctx -> put_op_bitmap , idx );
848+ }
849+ ucx_ctx -> put_proc_count = 0 ;
850+ }
851+
773852 opal_atomic_wmb ();
774853
775854 ret = opal_common_ucx_worker_flush (ucx_ctx -> ucp_worker );
0 commit comments