@@ -405,6 +405,7 @@ int mca_spml_ucx_ctx_mkey_add(mca_spml_ucx_ctx_t *ucx_ctx, int pe, uint32_t segn
405405{
406406 int rc ;
407407 ucs_status_t err ;
408+ ucp_rkey_h rkey ;
408409
409410 rc = mca_spml_ucx_ctx_mkey_new (ucx_ctx , pe , segno , ucx_mkey );
410411 if (OSHMEM_SUCCESS != rc ) {
@@ -413,11 +414,18 @@ int mca_spml_ucx_ctx_mkey_add(mca_spml_ucx_ctx_t *ucx_ctx, int pe, uint32_t segn
413414 }
414415
415416 if (mkey -> u .data ) {
416- err = ucp_ep_rkey_unpack (ucx_ctx -> ucp_peers [pe ].ucp_conn , mkey -> u .data , & (( * ucx_mkey ) -> rkey ) );
417+ err = ucp_ep_rkey_unpack (ucx_ctx -> ucp_peers [pe ].ucp_conn , mkey -> u .data , & rkey );
417418 if (UCS_OK != err ) {
418419 SPML_UCX_ERROR ("failed to unpack rkey: %s" , ucs_status_string (err ));
419420 return OSHMEM_ERROR ;
420421 }
422+
423+ if (!oshmem_proc_on_local_node (pe )) {
424+ rkey = mca_spml_ucx_rkey_store_get (& ucx_ctx -> rkey_store , ucx_ctx -> ucp_worker [0 ], rkey );
425+ }
426+
427+ (* ucx_mkey )-> rkey = rkey ;
428+
421429 rc = mca_spml_ucx_ctx_mkey_cache (ucx_ctx , mkey , segno , pe );
422430 if (OSHMEM_SUCCESS != rc ) {
423431 SPML_UCX_ERROR ("mca_spml_ucx_ctx_mkey_cache failed" );
@@ -432,7 +440,7 @@ int mca_spml_ucx_ctx_mkey_del(mca_spml_ucx_ctx_t *ucx_ctx, int pe, uint32_t segn
432440 ucp_peer_t * ucp_peer ;
433441 int rc ;
434442 ucp_peer = & (ucx_ctx -> ucp_peers [pe ]);
435- ucp_rkey_destroy ( ucx_mkey -> rkey );
443+ mca_spml_ucx_rkey_store_put ( & ucx_ctx -> rkey_store , ucx_ctx -> ucp_worker [ 0 ], ucx_mkey -> rkey );
436444 ucx_mkey -> rkey = NULL ;
437445 rc = mca_spml_ucx_peer_mkey_cache_del (ucp_peer , segno );
438446 if (OSHMEM_SUCCESS != rc ){
0 commit comments