@@ -412,6 +412,7 @@ int mca_spml_ucx_ctx_mkey_add(mca_spml_ucx_ctx_t *ucx_ctx, int pe, uint32_t segn
412412{
413413 int rc ;
414414 ucs_status_t err ;
415+ ucp_rkey_h rkey ;
415416
416417 rc = mca_spml_ucx_ctx_mkey_new (ucx_ctx , pe , segno , ucx_mkey );
417418 if (OSHMEM_SUCCESS != rc ) {
@@ -420,11 +421,18 @@ int mca_spml_ucx_ctx_mkey_add(mca_spml_ucx_ctx_t *ucx_ctx, int pe, uint32_t segn
420421 }
421422
422423 if (mkey -> u .data ) {
423- err = ucp_ep_rkey_unpack (ucx_ctx -> ucp_peers [pe ].ucp_conn , mkey -> u .data , & (( * ucx_mkey ) -> rkey ) );
424+ err = ucp_ep_rkey_unpack (ucx_ctx -> ucp_peers [pe ].ucp_conn , mkey -> u .data , & rkey );
424425 if (UCS_OK != err ) {
425426 SPML_UCX_ERROR ("failed to unpack rkey: %s" , ucs_status_string (err ));
426427 return OSHMEM_ERROR ;
427428 }
429+
430+ if (!oshmem_proc_on_local_node (pe )) {
431+ rkey = mca_spml_ucx_rkey_store_get (& ucx_ctx -> rkey_store , ucx_ctx -> ucp_worker [0 ], rkey );
432+ }
433+
434+ (* ucx_mkey )-> rkey = rkey ;
435+
428436 rc = mca_spml_ucx_ctx_mkey_cache (ucx_ctx , mkey , segno , pe );
429437 if (OSHMEM_SUCCESS != rc ) {
430438 SPML_UCX_ERROR ("mca_spml_ucx_ctx_mkey_cache failed" );
@@ -439,7 +447,7 @@ int mca_spml_ucx_ctx_mkey_del(mca_spml_ucx_ctx_t *ucx_ctx, int pe, uint32_t segn
439447 ucp_peer_t * ucp_peer ;
440448 int rc ;
441449 ucp_peer = & (ucx_ctx -> ucp_peers [pe ]);
442- ucp_rkey_destroy ( ucx_mkey -> rkey );
450+ mca_spml_ucx_rkey_store_put ( & ucx_ctx -> rkey_store , ucx_ctx -> ucp_worker [ 0 ], ucx_mkey -> rkey );
443451 ucx_mkey -> rkey = NULL ;
444452 rc = mca_spml_ucx_peer_mkey_cache_del (ucp_peer , segno );
445453 if (OSHMEM_SUCCESS != rc ){
0 commit comments