@@ -406,6 +406,7 @@ int mca_spml_ucx_ctx_mkey_add(mca_spml_ucx_ctx_t *ucx_ctx, int pe, uint32_t segn
406406{
407407 int rc ;
408408 ucs_status_t err ;
409+ ucp_rkey_h rkey ;
409410
410411 rc = mca_spml_ucx_ctx_mkey_new (ucx_ctx , pe , segno , ucx_mkey );
411412 if (OSHMEM_SUCCESS != rc ) {
@@ -414,11 +415,18 @@ int mca_spml_ucx_ctx_mkey_add(mca_spml_ucx_ctx_t *ucx_ctx, int pe, uint32_t segn
414415 }
415416
416417 if (mkey -> u .data ) {
417- err = ucp_ep_rkey_unpack (ucx_ctx -> ucp_peers [pe ].ucp_conn , mkey -> u .data , & (( * ucx_mkey ) -> rkey ) );
418+ err = ucp_ep_rkey_unpack (ucx_ctx -> ucp_peers [pe ].ucp_conn , mkey -> u .data , & rkey );
418419 if (UCS_OK != err ) {
419420 SPML_UCX_ERROR ("failed to unpack rkey: %s" , ucs_status_string (err ));
420421 return OSHMEM_ERROR ;
421422 }
423+
424+ if (!oshmem_proc_on_local_node (pe )) {
425+ rkey = mca_spml_ucx_rkey_store_get (& ucx_ctx -> rkey_store , ucx_ctx -> ucp_worker [0 ], rkey );
426+ }
427+
428+ (* ucx_mkey )-> rkey = rkey ;
429+
422430 rc = mca_spml_ucx_ctx_mkey_cache (ucx_ctx , mkey , segno , pe );
423431 if (OSHMEM_SUCCESS != rc ) {
424432 SPML_UCX_ERROR ("mca_spml_ucx_ctx_mkey_cache failed" );
@@ -433,7 +441,7 @@ int mca_spml_ucx_ctx_mkey_del(mca_spml_ucx_ctx_t *ucx_ctx, int pe, uint32_t segn
433441 ucp_peer_t * ucp_peer ;
434442 int rc ;
435443 ucp_peer = & (ucx_ctx -> ucp_peers [pe ]);
436- ucp_rkey_destroy ( ucx_mkey -> rkey );
444+ mca_spml_ucx_rkey_store_put ( & ucx_ctx -> rkey_store , ucx_ctx -> ucp_worker [ 0 ], ucx_mkey -> rkey );
437445 ucx_mkey -> rkey = NULL ;
438446 rc = mca_spml_ucx_peer_mkey_cache_del (ucp_peer , segno );
439447 if (OSHMEM_SUCCESS != rc ){
0 commit comments