@@ -57,10 +57,12 @@ static void mca_scoll_ucc_module_destruct(mca_scoll_ucc_module_t *ucc_module)
5757 }
5858
5959 if (0 == mca_scoll_ucc_component .nr_modules ) {
60- if (mca_scoll_ucc_component .libucc_initialized ) {
60+ if (mca_scoll_ucc_component .libucc_initialized ) {
61+ if (mca_scoll_ucc_component .ucc_context ) {
62+ opal_progress_unregister (mca_scoll_ucc_progress );
63+ ucc_context_destroy (mca_scoll_ucc_component .ucc_context );
64+ }
6165 UCC_VERBOSE (1 , "finalizing ucc library" );
62- opal_progress_unregister (mca_scoll_ucc_progress );
63- ucc_context_destroy (mca_scoll_ucc_component .ucc_context );
6466 ucc_finalize (mca_scoll_ucc_component .ucc_lib );
6567 mca_scoll_ucc_component .libucc_initialized = false;
6668 }
@@ -199,17 +201,12 @@ static ucc_status_t oob_allgather_test(void *req)
199201 return oob_probe_test (oob_req );
200202}
201203
202- static int mca_scoll_ucc_init_ctx (oshmem_group_t * osh_group )
204+ static int mca_scoll_ucc_init (oshmem_group_t * osh_group )
203205{
204206 mca_scoll_ucc_component_t * cm = & mca_scoll_ucc_component ;
205- ucc_mem_map_t * maps = NULL ;
206- char str_buf [256 ];
207207 ucc_lib_config_h lib_config ;
208- ucc_context_config_h ctx_config ;
209208 ucc_thread_mode_t tm_requested ;
210209 ucc_lib_params_t lib_params ;
211- ucc_context_params_t ctx_params ;
212- int segment ;
213210
214211 tm_requested = oshmem_mpi_thread_multiple ? UCC_THREAD_MULTIPLE :
215212 UCC_THREAD_SINGLE ;
@@ -247,6 +244,25 @@ static int mca_scoll_ucc_init_ctx(oshmem_group_t *osh_group)
247244 goto cleanup_lib ;
248245 }
249246
247+ cm -> libucc_initialized = true;
248+ return OSHMEM_SUCCESS ;
249+
250+ cleanup_lib :
251+ ucc_finalize (cm -> ucc_lib );
252+ cm -> ucc_enable = 0 ;
253+ cm -> libucc_initialized = false;
254+ return OSHMEM_ERROR ;
255+ }
256+
257+ int mca_scoll_ucc_init_ctx (oshmem_group_t * osh_group )
258+ {
259+ mca_scoll_ucc_component_t * cm = & mca_scoll_ucc_component ;
260+ ucc_mem_map_t * maps = NULL ;
261+ char str_buf [256 ];
262+ ucc_context_config_h ctx_config ;
263+ ucc_context_params_t ctx_params ;
264+ int segment ;
265+
250266 maps = (ucc_mem_map_t * )malloc (sizeof (ucc_mem_map_t ) *
251267 memheap_map -> n_segments );
252268 if (NULL == maps ) {
@@ -398,7 +414,6 @@ static int mca_scoll_ucc_module_enable(mca_scoll_base_module_t *module,
398414 opal_show_help ("help-oshmem-scoll-ucc.txt" ,
399415 "module_enable:fatal" , true,
400416 "UCC module enable failed - aborting to prevent inconsistent application state" );
401-
402417 goto err ;
403418 }
404419 UCC_VERBOSE (1 , "ucc enabled" );
@@ -446,7 +461,7 @@ mca_scoll_ucc_comm_query(oshmem_group_t *osh_group, int *priority)
446461
447462 if (!cm -> libucc_initialized ) {
448463 if (memheap_map && memheap_map -> n_segments > 0 ) {
449- if (OSHMEM_SUCCESS != mca_scoll_ucc_init_ctx (osh_group )) {
464+ if (OSHMEM_SUCCESS != mca_scoll_ucc_init (osh_group )) {
450465 cm -> ucc_enable = 0 ;
451466 return NULL ;
452467 }
0 commit comments