@@ -314,7 +314,12 @@ ucs_status_t mca_btl_uct_am_handler (void *arg, void *data, size_t length, unsig
314314 return UCS_OK ;
315315}
316316
317+ #if UCT_API >= UCT_VERSION (1 , 7 )
318+ static int mca_btl_uct_component_process_uct_md (uct_component_h component , uct_md_resource_desc_t * md_desc ,
319+ char * * allowed_ifaces )
320+ #else
317321static int mca_btl_uct_component_process_uct_md (uct_md_resource_desc_t * md_desc , char * * allowed_ifaces )
322+ #endif
318323{
319324 mca_rcache_base_resources_t rcache_resources ;
320325 uct_tl_resource_desc_t * tl_desc ;
@@ -348,8 +353,14 @@ static int mca_btl_uct_component_process_uct_md (uct_md_resource_desc_t *md_desc
348353
349354 md = OBJ_NEW (mca_btl_uct_md_t );
350355
356+
357+ #if UCT_API >= UCT_VERSION (1 , 7 )
358+ uct_md_config_read (component , NULL , NULL , & uct_config );
359+ uct_md_open (component , md_desc -> md_name , uct_config , & md -> uct_md );
360+ #else
351361 uct_md_config_read (md_desc -> md_name , NULL , NULL , & uct_config );
352362 uct_md_open (md_desc -> md_name , uct_config , & md -> uct_md );
363+ #endif
353364 uct_config_release (uct_config );
354365
355366 uct_md_query (md -> uct_md , & md_attr );
@@ -375,6 +386,10 @@ static int mca_btl_uct_component_process_uct_md (uct_md_resource_desc_t *md_desc
375386 return OPAL_ERR_NOT_AVAILABLE ;
376387 }
377388
389+ #if UCT_API >= UCT_VERSION (1 , 7 )
390+ module -> uct_component = component ;
391+ #endif
392+
378393 mca_btl_uct_component .modules [mca_btl_uct_component .module_count ++ ] = module ;
379394
380395 /* NTH: a registration cache shouldn't be necessary when using UCT but there are measurable
@@ -400,6 +415,42 @@ static int mca_btl_uct_component_process_uct_md (uct_md_resource_desc_t *md_desc
400415 return OPAL_SUCCESS ;
401416}
402417
418+ #if UCT_API >= UCT_VERSION (1 , 7 )
419+ static int mca_btl_uct_component_process_uct_component (uct_component_h component , char * * allowed_ifaces )
420+ {
421+ uct_component_attr_t attr = {.field_mask = UCT_COMPONENT_ATTR_FIELD_NAME |
422+ UCT_COMPONENT_ATTR_FIELD_MD_RESOURCE_COUNT };
423+ ucs_status_t ucs_status ;
424+ int rc ;
425+
426+ ucs_status = uct_component_query (component , & attr );
427+ if (UCS_OK != ucs_status ) {
428+ return OPAL_ERROR ;
429+ }
430+
431+ BTL_VERBOSE (("processing uct component %s" , attr .name ));
432+
433+ attr .md_resources = calloc (attr .md_resource_count , sizeof (* attr .md_resources ));
434+ attr .field_mask |= UCT_COMPONENT_ATTR_FIELD_MD_RESOURCES ;
435+ ucs_status = uct_component_query (component , & attr );
436+ if (UCS_OK != ucs_status ) {
437+ return OPAL_ERROR ;
438+ }
439+
440+ for (int i = 0 ; i < attr .md_resource_count ; ++ i ) {
441+ rc = mca_btl_uct_component_process_uct_md (component , attr .md_resources + i ,
442+ allowed_ifaces );
443+ if (OPAL_SUCCESS != rc ) {
444+ break ;
445+ }
446+ }
447+
448+ free (attr .md_resources );
449+
450+ return OPAL_SUCCESS ;
451+ }
452+ #endif /* UCT_API >= UCT_VERSION(1, 7) */
453+
403454/*
404455 * UCT component initialization:
405456 * (1) read interface list from kernel and compare against component parameters
@@ -415,6 +466,7 @@ static mca_btl_base_module_t **mca_btl_uct_component_init (int *num_btl_modules,
415466 struct mca_btl_base_module_t * * base_modules ;
416467 uct_md_resource_desc_t * resources ;
417468 unsigned resource_count ;
469+ ucs_status_t ucs_status ;
418470 char * * allowed_ifaces ;
419471 int rc ;
420472
@@ -431,10 +483,32 @@ static mca_btl_base_module_t **mca_btl_uct_component_init (int *num_btl_modules,
431483 return NULL ;
432484 }
433485
434- uct_query_md_resources (& resources , & resource_count );
435-
436486 mca_btl_uct_component .module_count = 0 ;
437487
488+ #if UCT_API >= UCT_VERSION (1 , 7 )
489+ uct_component_h * components ;
490+ unsigned num_components ;
491+
492+ ucs_status = uct_query_components (& components , & num_components );
493+ if (UCS_OK != ucs_status ) {
494+ BTL_ERROR (("could not query UCT components" ));
495+ return NULL ;
496+ }
497+
498+ /* generate all suitable btl modules */
499+ for (unsigned i = 0 ; i < num_components ; ++ i ) {
500+ rc = mca_btl_uct_component_process_uct_component (components [i ], allowed_ifaces );
501+ if (OPAL_SUCCESS != rc ) {
502+ break ;
503+ }
504+ }
505+
506+ uct_release_component_list (components );
507+
508+ #else /* UCT 1.6 and older */
509+
510+ uct_query_md_resources (& resources , & resource_count );
511+
438512 /* generate all suitable btl modules */
439513 for (unsigned i = 0 ; i < resource_count ; ++ i ) {
440514 rc = mca_btl_uct_component_process_uct_md (resources + i , allowed_ifaces );
@@ -443,9 +517,11 @@ static mca_btl_base_module_t **mca_btl_uct_component_init (int *num_btl_modules,
443517 }
444518 }
445519
446- opal_argv_free (allowed_ifaces );
447520 uct_release_md_resource_list (resources );
448521
522+ #endif /* UCT_API >= UCT_VERSION(1, 7) */
523+
524+ opal_argv_free (allowed_ifaces );
449525 mca_btl_uct_modex_send ();
450526
451527 /* pass module array back to caller */
0 commit comments