1818 * Copyright (c) 2014 Intel, Inc. All rights reserved.
1919 * Copyright (c) 2018-2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
2020 * Copyright (c) 2022 IBM Corporation. All rights reserved.
21+ * Copyright (c) 2023 Triad National Security, LLC. All rights
22+ * reserved.
2123 * $COPYRIGHT$
2224 *
2325 * Additional copyrights may follow
@@ -69,6 +71,8 @@ static int smcuda_register(void);
6971static mca_btl_base_module_t * *
7072mca_btl_smcuda_component_init (int * num_btls , bool enable_progress_threads , bool enable_mpi_threads );
7173
74+ static void mca_btl_smcuda_component_fini (void );
75+
7276typedef enum {
7377 MCA_BTL_SM_RNDV_MOD_SM = 0 ,
7478 MCA_BTL_SM_RNDV_MOD_MPOOL
@@ -214,7 +218,7 @@ static int smcuda_register(void)
214218 if (0 == mca_btl_smcuda .super .btl_accelerator_eager_limit ) {
215219 mca_btl_smcuda .super .btl_accelerator_eager_limit = SIZE_MAX ; /* magic number */
216220 }
217- #endif
221+ #endif /* OPAL_CUDA_SUPPORT */
218222 return mca_btl_smcuda_component_verify ();
219223}
220224
@@ -260,16 +264,24 @@ static int mca_btl_smcuda_component_open(void)
260264 OBJ_CONSTRUCT (& mca_btl_smcuda_component .sm_frags_max , opal_free_list_t );
261265 OBJ_CONSTRUCT (& mca_btl_smcuda_component .sm_frags_user , opal_free_list_t );
262266 OBJ_CONSTRUCT (& mca_btl_smcuda_component .pending_send_fl , opal_free_list_t );
267+
268+ opal_finalize_register_cleanup (mca_btl_smcuda_component_fini );
269+
270+ return OPAL_SUCCESS ;
271+ }
272+
273+ static int mca_btl_smcuda_component_close (void )
274+ {
263275 return OPAL_SUCCESS ;
264276}
265277
266278/*
267279 * component cleanup - sanity checking of queue lengths
268280 */
269281
270- static int mca_btl_smcuda_component_close (void )
282+ static void mca_btl_smcuda_component_fini (void )
271283{
272- int return_value = OPAL_SUCCESS ;
284+ int rc ;
273285
274286 OBJ_DESTRUCT (& mca_btl_smcuda_component .sm_lock );
275287 /**
@@ -282,11 +294,10 @@ static int mca_btl_smcuda_component_close(void)
282294
283295 /* unmap the shared memory control structure */
284296 if (mca_btl_smcuda_component .sm_seg != NULL ) {
285- return_value = mca_common_sm_fini (mca_btl_smcuda_component .sm_seg );
286- if (OPAL_SUCCESS != return_value ) {
287- return_value = OPAL_ERROR ;
297+ rc = mca_common_sm_fini (mca_btl_smcuda_component .sm_seg );
298+ if (OPAL_SUCCESS != rc ) {
288299 opal_output (0 , " mca_common_sm_fini failed\n" );
289- goto CLEANUP ;
300+ return ;
290301 }
291302
292303 /* unlink file, so that it will be deleted when all references
@@ -310,13 +321,7 @@ static int mca_btl_smcuda_component_close(void)
310321 unlink (mca_btl_smcuda_component .sm_fifo_path );
311322 }
312323#endif
313-
314- CLEANUP :
315-
316- mca_btl_smcuda_accelerator_fini ();
317-
318- /* return */
319- return return_value ;
324+ return ;
320325}
321326
322327/*
0 commit comments