diff --git a/ompi/instance/instance.c b/ompi/instance/instance.c index 7bd8d3f114f..07a4dd62370 100644 --- a/ompi/instance/instance.c +++ b/ompi/instance/instance.c @@ -96,14 +96,15 @@ static void ompi_instance_destruct(ompi_instance_t *instance) OBJ_CLASS_INSTANCE(ompi_instance_t, opal_infosubscriber_t, ompi_instance_construct, ompi_instance_destruct); -/* NTH: frameworks needed by MPI */ +/* OMPI MCA frameworks needed by MPI. New frameworks need to be added to this list */ static mca_base_framework_t *ompi_framework_dependencies[] = { &ompi_hook_base_framework, &ompi_op_base_framework, &opal_allocator_base_framework, &opal_rcache_base_framework, &opal_mpool_base_framework, &opal_smsc_base_framework, &ompi_bml_base_framework, &ompi_pml_base_framework, &ompi_coll_base_framework, - &ompi_osc_base_framework, NULL, + &ompi_osc_base_framework, &ompi_part_base_framework, NULL, }; +/* OMPI MCA frameworks that can be opened multiple times need to be added to this list */ static mca_base_framework_t *ompi_lazy_frameworks[] = { &ompi_io_base_framework, &ompi_topo_base_framework, NULL, }; @@ -642,11 +643,7 @@ static int ompi_mpi_instance_init_common (int argc, char **argv) return ompi_instance_print_error ("ompi_win_init() failed", ret); } - /* initialize partcomm */ - if (OMPI_SUCCESS != (ret = mca_base_framework_open(&ompi_part_base_framework, 0))) { - return ompi_instance_print_error ("mca_part_base_select() failed", ret); - } - + /* select partcomm */ if (OMPI_SUCCESS != (ret = mca_part_base_select (true, true))) { return ompi_instance_print_error ("mca_part_base_select() failed", ret); } diff --git a/opal/mca/btl/smcuda/btl_smcuda_accelerator.c b/opal/mca/btl/smcuda/btl_smcuda_accelerator.c index d9116cb8340..53974271780 100644 --- a/opal/mca/btl/smcuda/btl_smcuda_accelerator.c +++ b/opal/mca/btl/smcuda/btl_smcuda_accelerator.c @@ -35,6 +35,8 @@ static int accelerator_event_max = 400; static int accelerator_event_ipc_most = 0; static bool smcuda_accelerator_initialized = false; +static void mca_btl_smcuda_accelerator_fini(void); + int mca_btl_smcuda_accelerator_init(void) { int rc = OPAL_SUCCESS; @@ -79,6 +81,7 @@ int mca_btl_smcuda_accelerator_init(void) goto cleanup_and_error; } + opal_finalize_register_cleanup(mca_btl_smcuda_accelerator_fini); smcuda_accelerator_initialized = true; cleanup_and_error: @@ -103,7 +106,7 @@ int mca_btl_smcuda_accelerator_init(void) return rc; } -void mca_btl_smcuda_accelerator_fini(void) +static void mca_btl_smcuda_accelerator_fini(void) { int i; diff --git a/opal/mca/btl/smcuda/btl_smcuda_accelerator.h b/opal/mca/btl/smcuda/btl_smcuda_accelerator.h index 7b039381a2e..bcf26a69ca7 100644 --- a/opal/mca/btl/smcuda/btl_smcuda_accelerator.h +++ b/opal/mca/btl/smcuda/btl_smcuda_accelerator.h @@ -17,7 +17,6 @@ #include "opal/mca/btl/btl.h" OPAL_DECLSPEC int mca_btl_smcuda_accelerator_init(void); -OPAL_DECLSPEC void mca_btl_smcuda_accelerator_fini(void); OPAL_DECLSPEC int mca_btl_smcuda_progress_one_ipc_event(struct mca_btl_base_descriptor_t **frag); OPAL_DECLSPEC int mca_btl_smcuda_memcpy(void *dst, void *src, size_t amount, char *msg, struct mca_btl_base_descriptor_t *frag); diff --git a/opal/mca/btl/smcuda/btl_smcuda_component.c b/opal/mca/btl/smcuda/btl_smcuda_component.c index 92c23286c0c..efe29e3ccb1 100644 --- a/opal/mca/btl/smcuda/btl_smcuda_component.c +++ b/opal/mca/btl/smcuda/btl_smcuda_component.c @@ -18,6 +18,8 @@ * Copyright (c) 2014 Intel, Inc. All rights reserved. * Copyright (c) 2018-2022 Amazon.com, Inc. or its affiliates. All Rights reserved. * Copyright (c) 2022 IBM Corporation. All rights reserved. + * Copyright (c) 2022 Triad National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -68,6 +70,7 @@ static int mca_btl_smcuda_component_close(void); static int smcuda_register(void); static mca_btl_base_module_t ** mca_btl_smcuda_component_init(int *num_btls, bool enable_progress_threads, bool enable_mpi_threads); +static void mca_btl_smcuda_component_fini(void); typedef enum { MCA_BTL_SM_RNDV_MOD_SM = 0, @@ -260,6 +263,9 @@ static int mca_btl_smcuda_component_open(void) OBJ_CONSTRUCT(&mca_btl_smcuda_component.sm_frags_max, opal_free_list_t); OBJ_CONSTRUCT(&mca_btl_smcuda_component.sm_frags_user, opal_free_list_t); OBJ_CONSTRUCT(&mca_btl_smcuda_component.pending_send_fl, opal_free_list_t); + + opal_finalize_register_cleanup(mca_btl_smcuda_component_fini); + return OPAL_SUCCESS; } @@ -269,7 +275,12 @@ static int mca_btl_smcuda_component_open(void) static int mca_btl_smcuda_component_close(void) { - int return_value = OPAL_SUCCESS; + return OPAL_SUCCESS; +} + +static void mca_btl_smcuda_component_fini(void) +{ + int rc; OBJ_DESTRUCT(&mca_btl_smcuda_component.sm_lock); /** @@ -282,11 +293,11 @@ static int mca_btl_smcuda_component_close(void) /* unmap the shared memory control structure */ if (mca_btl_smcuda_component.sm_seg != NULL) { - return_value = mca_common_sm_fini(mca_btl_smcuda_component.sm_seg); - if (OPAL_SUCCESS != return_value) { - return_value = OPAL_ERROR; + rc = mca_common_sm_fini(mca_btl_smcuda_component.sm_seg); + if (OPAL_SUCCESS != rc) { + rc = OPAL_ERROR; opal_output(0, " mca_common_sm_fini failed\n"); - goto CLEANUP; + return; } /* unlink file, so that it will be deleted when all references @@ -311,12 +322,8 @@ static int mca_btl_smcuda_component_close(void) } #endif -CLEANUP: - - mca_btl_smcuda_accelerator_fini(); - /* return */ - return return_value; + return; } /* diff --git a/opal/runtime/opal_init.c b/opal/runtime/opal_init.c index 31339179483..a009af59ce0 100644 --- a/opal/runtime/opal_init.c +++ b/opal/runtime/opal_init.c @@ -22,7 +22,7 @@ * All Rights reserved. * Copyright (c) 2018 Mellanox Technologies, Inc. * All rights reserved. - * Copyright (c) 2018-2019 Triad National Security, LLC. All rights + * Copyright (c) 2018-2022 Triad National Security, LLC. All rights * reserved. * Copyright (c) 2020 FUJITSU LIMITED. All rights reserved. * Copyright (c) 2021 Nanook Consulting. All rights reserved. @@ -120,6 +120,8 @@ int opal_init_psm(void) return OPAL_SUCCESS; } +/* MCA frameworks needed by OPAL. New frameworks need to be added to this list */ + /* the memcpy component should be one of the first who get * loaded in order to make sure we have all the available * versions of memcpy correctly configured. @@ -130,7 +132,7 @@ static mca_base_framework_t *opal_init_frameworks[] = { &opal_memcpy_base_framework, &opal_memchecker_base_framework, &opal_backtrace_base_framework, &opal_timer_base_framework, &opal_shmem_base_framework, &opal_reachable_base_framework, - &opal_pmix_base_framework, + &opal_pmix_base_framework, &opal_accelerator_base_framework, NULL, }; @@ -160,6 +162,11 @@ int opal_init(int *pargc, char ***pargv) return ret; } +/* + * Trap direct usage of mca_base_framework_open through out the rest of this file. + */ +#define mca_base_framework_open "add new frameworks to the opal_init_frameworks list" + OPAL_TIMING_ENV_NEXT(otmng, "opal_if_init"); /* register PMIx cleanup function for output streams */ @@ -194,13 +201,14 @@ int opal_init(int *pargc, char ***pargv) return opal_init_error("opal_init framework open", ret); } - /* Intitialize Accelerator framework + /* select Accelerator framework component * The datatype convertor code has a dependency on the accelerator framework * being initialized. */ - ret = mca_base_framework_open(&opal_accelerator_base_framework, 0); - if (OPAL_SUCCESS == ret && OPAL_SUCCESS != (ret = opal_accelerator_base_select())) { + if (OPAL_SUCCESS != (ret = opal_accelerator_base_select())) { return opal_init_error("opal_accelerator_base_select", ret); } + + /* register accelerator cleanup function */ opal_finalize_register_cleanup(opal_accelerator_base_selected_component.accelerator_finalize); /* initialize the datatype engine */