4343#define SPML_UCX_PUT_DEBUG 0
4444#endif
4545
46-
4746mca_spml_ucx_t mca_spml_ucx = {
4847 {
4948 /* Init mca_spml_base_module_t */
@@ -65,6 +64,7 @@ mca_spml_ucx_t mca_spml_ucx = {
6564 every spml */
6665 mca_spml_ucx_rmkey_unpack ,
6766 mca_spml_ucx_rmkey_free ,
67+ mca_spml_ucx_memuse_hook ,
6868 (void * )& mca_spml_ucx
6969 },
7070
@@ -288,7 +288,7 @@ int mca_spml_ucx_add_procs(ompi_proc_t **procs, size_t nprocs)
288288 & ep_params ,
289289 & mca_spml_ucx .ucp_peers [i ].ucp_conn );
290290 if (UCS_OK != err ) {
291- SPML_ERROR ("ucp_ep_create failed!!!\n" );
291+ SPML_ERROR ("ucp_ep_create failed: %s" , ucs_status_string ( err ) );
292292 goto error2 ;
293293 }
294294 OSHMEM_PROC_DATA (procs [i ])-> num_transports = 1 ;
@@ -371,7 +371,7 @@ void mca_spml_ucx_rmkey_unpack(sshmem_mkey_t *mkey, uint32_t segno, int pe, int
371371 mkey -> u .data ,
372372 & ucx_mkey -> rkey );
373373 if (UCS_OK != err ) {
374- SPML_ERROR ("failed to unpack rkey" );
374+ SPML_ERROR ("failed to unpack rkey: %s" , ucs_status_string ( err ) );
375375 goto error_fatal ;
376376 }
377377
@@ -384,6 +384,35 @@ void mca_spml_ucx_rmkey_unpack(sshmem_mkey_t *mkey, uint32_t segno, int pe, int
384384 return ;
385385}
386386
387+ void mca_spml_ucx_memuse_hook (void * addr , size_t length )
388+ {
389+ int my_pe ;
390+ spml_ucx_mkey_t * ucx_mkey ;
391+ ucp_mem_advise_params_t params ;
392+ ucs_status_t status ;
393+
394+ if (!(mca_spml_ucx .heap_reg_nb && memheap_is_va_in_segment (addr , HEAP_SEG_INDEX ))) {
395+ return ;
396+ }
397+
398+ my_pe = oshmem_my_proc_id ();
399+ ucx_mkey = & mca_spml_ucx .ucp_peers [my_pe ].mkeys [HEAP_SEG_INDEX ].key ;
400+
401+ params .field_mask = UCP_MEM_ADVISE_PARAM_FIELD_ADDRESS |
402+ UCP_MEM_ADVISE_PARAM_FIELD_LENGTH |
403+ UCP_MEM_ADVISE_PARAM_FIELD_ADVICE ;
404+
405+ params .address = addr ;
406+ params .length = length ;
407+ params .advice = UCP_MADV_WILLNEED ;
408+
409+ status = ucp_mem_advise (mca_spml_ucx .ucp_context , ucx_mkey -> mem_h , & params );
410+ if (UCS_OK != status ) {
411+ SPML_ERROR ("ucp_mem_advise failed addr %p len %llu : %s" ,
412+ addr , (unsigned long long )length , ucs_status_string (status ));
413+ }
414+ }
415+
387416sshmem_mkey_t * mca_spml_ucx_register (void * addr ,
388417 size_t size ,
389418 uint64_t shmid ,
@@ -539,7 +568,7 @@ int mca_spml_ucx_fence(void)
539568
540569 err = ucp_worker_flush (mca_spml_ucx .ucp_worker );
541570 if (UCS_OK != err ) {
542- SPML_ERROR ("fence failed" );
571+ SPML_ERROR ("fence failed: %s" , ucs_status_string ( err ) );
543572 oshmem_shmem_abort (-1 );
544573 return OSHMEM_ERROR ;
545574 }
@@ -552,7 +581,7 @@ int mca_spml_ucx_quiet(void)
552581
553582 err = ucp_worker_flush (mca_spml_ucx .ucp_worker );
554583 if (UCS_OK != err ) {
555- SPML_ERROR ("fence failed" );
584+ SPML_ERROR ("fence failed: %s" , ucs_status_string ( err ) );
556585 oshmem_shmem_abort (-1 );
557586 return OSHMEM_ERROR ;
558587 }
0 commit comments