@@ -240,6 +240,7 @@ int mca_spml_ucx_ctx_mkey_add(mca_spml_ucx_ctx_t *ucx_ctx, int pe, uint32_t segn
240240{
241241 int rc ;
242242 ucs_status_t err ;
243+ ucp_rkey_h rkey ;
243244
244245 rc = mca_spml_ucx_ctx_mkey_new (ucx_ctx , pe , segno , ucx_mkey );
245246 if (OSHMEM_SUCCESS != rc ) {
@@ -248,11 +249,14 @@ int mca_spml_ucx_ctx_mkey_add(mca_spml_ucx_ctx_t *ucx_ctx, int pe, uint32_t segn
248249 }
249250
250251 if (mkey -> u .data ) {
251- err = ucp_ep_rkey_unpack (ucx_ctx -> ucp_peers [pe ].ucp_conn , mkey -> u .data , & (( * ucx_mkey ) -> rkey ) );
252+ err = ucp_ep_rkey_unpack (ucx_ctx -> ucp_peers [pe ].ucp_conn , mkey -> u .data , & rkey );
252253 if (UCS_OK != err ) {
253254 SPML_UCX_ERROR ("failed to unpack rkey: %s" , ucs_status_string (err ));
254255 return OSHMEM_ERROR ;
255256 }
257+
258+ (* ucx_mkey )-> rkey = mca_spml_ucx_rkey_store_get (& mca_spml_ucx .rkey_store , rkey );
259+
256260 rc = mca_spml_ucx_ctx_mkey_cache (ucx_ctx , mkey , segno , pe );
257261 if (OSHMEM_SUCCESS != rc ) {
258262 SPML_UCX_ERROR ("mca_spml_ucx_ctx_mkey_cache failed" );
@@ -267,7 +271,7 @@ int mca_spml_ucx_ctx_mkey_del(mca_spml_ucx_ctx_t *ucx_ctx, int pe, uint32_t segn
267271 ucp_peer_t * ucp_peer ;
268272 int rc ;
269273 ucp_peer = & (ucx_ctx -> ucp_peers [pe ]);
270- ucp_rkey_destroy ( ucx_mkey -> rkey );
274+ mca_spml_ucx_rkey_store_put ( & mca_spml_ucx . rkey_store , ucx_mkey -> rkey );
271275 ucx_mkey -> rkey = NULL ;
272276 rc = mca_spml_ucx_peer_mkey_cache_del (ucp_peer , segno );
273277 if (OSHMEM_SUCCESS != rc ){
0 commit comments