@@ -316,7 +316,12 @@ ucs_status_t mca_btl_uct_am_handler (void *arg, void *data, size_t length, unsig
316316 return UCS_OK ;
317317}
318318
319+ #if UCT_API > UCT_VERSION (1 , 7 )
320+ static int mca_btl_uct_component_process_uct_md (uct_component_h component , uct_md_resource_desc_t * md_desc ,
321+ char * * allowed_ifaces )
322+ #else
319323static int mca_btl_uct_component_process_uct_md (uct_md_resource_desc_t * md_desc , char * * allowed_ifaces )
324+ #endif
320325{
321326 mca_rcache_base_resources_t rcache_resources ;
322327 uct_tl_resource_desc_t * tl_desc ;
@@ -350,8 +355,14 @@ static int mca_btl_uct_component_process_uct_md (uct_md_resource_desc_t *md_desc
350355
351356 md = OBJ_NEW (mca_btl_uct_md_t );
352357
358+
359+ #if UCT_API > UCT_VERSION (1 , 7 )
360+ uct_md_config_read (component , NULL , NULL , & uct_config );
361+ uct_md_open (component , md_desc -> md_name , uct_config , & md -> uct_md );
362+ #else
353363 uct_md_config_read (md_desc -> md_name , NULL , NULL , & uct_config );
354364 uct_md_open (md_desc -> md_name , uct_config , & md -> uct_md );
365+ #endif
355366 uct_config_release (uct_config );
356367
357368 uct_md_query (md -> uct_md , & md_attr );
@@ -377,6 +388,10 @@ static int mca_btl_uct_component_process_uct_md (uct_md_resource_desc_t *md_desc
377388 return OPAL_ERR_NOT_AVAILABLE ;
378389 }
379390
391+ #if UCT_API > UCT_VERSION (1 , 7 )
392+ module -> uct_component = component ;
393+ #endif
394+
380395 mca_btl_uct_component .modules [mca_btl_uct_component .module_count ++ ] = module ;
381396
382397 /* NTH: a registration cache shouldn't be necessary when using UCT but there are measurable
@@ -402,6 +417,42 @@ static int mca_btl_uct_component_process_uct_md (uct_md_resource_desc_t *md_desc
402417 return OPAL_SUCCESS ;
403418}
404419
420+ #if UCT_API > UCT_VERSION (1 , 7 )
421+ static int mca_btl_uct_component_process_uct_component (uct_component_h component , char * * allowed_ifaces )
422+ {
423+ uct_component_attr_t attr = {.field_mask = UCT_COMPONENT_ATTR_FIELD_NAME |
424+ UCT_COMPONENT_ATTR_FIELD_MD_RESOURCE_COUNT };
425+ ucs_status_t ucs_status ;
426+ int rc ;
427+
428+ ucs_status = uct_component_query (component , & attr );
429+ if (UCS_OK != ucs_status ) {
430+ return OPAL_ERROR ;
431+ }
432+
433+ BTL_VERBOSE (("processing uct component %s" , attr .name ));
434+
435+ attr .md_resources = calloc (attr .md_resource_count , sizeof (* attr .md_resources ));
436+ attr .field_mask |= UCT_COMPONENT_ATTR_FIELD_MD_RESOURCES ;
437+ ucs_status = uct_component_query (component , & attr );
438+ if (UCS_OK != ucs_status ) {
439+ return OPAL_ERROR ;
440+ }
441+
442+ for (int i = 0 ; i < attr .md_resource_count ; ++ i ) {
443+ rc = mca_btl_uct_component_process_uct_md (component , attr .md_resources + i ,
444+ allowed_ifaces );
445+ if (OPAL_SUCCESS != rc ) {
446+ break ;
447+ }
448+ }
449+
450+ free (attr .md_resources );
451+
452+ return OPAL_SUCCESS ;
453+ }
454+ #endif /* UCT_API > UCT_VERSION(1, 7) */
455+
405456/*
406457 * UCT component initialization:
407458 * (1) read interface list from kernel and compare against component parameters
@@ -417,6 +468,7 @@ static mca_btl_base_module_t **mca_btl_uct_component_init (int *num_btl_modules,
417468 struct mca_btl_base_module_t * * base_modules ;
418469 uct_md_resource_desc_t * resources ;
419470 unsigned resource_count ;
471+ ucs_status_t ucs_status ;
420472 char * * allowed_ifaces ;
421473 int rc ;
422474
@@ -433,10 +485,32 @@ static mca_btl_base_module_t **mca_btl_uct_component_init (int *num_btl_modules,
433485 return NULL ;
434486 }
435487
436- uct_query_md_resources (& resources , & resource_count );
437-
438488 mca_btl_uct_component .module_count = 0 ;
439489
490+ #if UCT_API > UCT_VERSION (1 , 7 )
491+ uct_component_h * components ;
492+ unsigned num_components ;
493+
494+ ucs_status = uct_query_components (& components , & num_components );
495+ if (UCS_OK != ucs_status ) {
496+ BTL_ERROR (("could not query UCT components" ));
497+ return NULL ;
498+ }
499+
500+ /* generate all suitable btl modules */
501+ for (unsigned i = 0 ; i < num_components ; ++ i ) {
502+ rc = mca_btl_uct_component_process_uct_component (components [i ], allowed_ifaces );
503+ if (OPAL_SUCCESS != rc ) {
504+ break ;
505+ }
506+ }
507+
508+ uct_release_component_list (components );
509+
510+ #else /* UCT 1.6 and older */
511+
512+ uct_query_md_resources (& resources , & resource_count );
513+
440514 /* generate all suitable btl modules */
441515 for (unsigned i = 0 ; i < resource_count ; ++ i ) {
442516 rc = mca_btl_uct_component_process_uct_md (resources + i , allowed_ifaces );
@@ -445,9 +519,11 @@ static mca_btl_base_module_t **mca_btl_uct_component_init (int *num_btl_modules,
445519 }
446520 }
447521
448- opal_argv_free (allowed_ifaces );
449522 uct_release_md_resource_list (resources );
450523
524+ #endif /* UCT_API > UCT_VERSION(1, 7) */
525+
526+ opal_argv_free (allowed_ifaces );
451527 mca_btl_uct_modex_send ();
452528
453529 /* pass module array back to caller */
0 commit comments