static int mca_pml_v_component_close(void) { int ret; /* Save original PML before making any changes */ mca_pml_v.host_pml_component = mca_pml_base_selected_component; mca_pml_v.host_pml = mca_pml; mca_pml_v.host_request_fns = ompi_request_functions; /* Do not load anything if no FT protocol is selected */ if(! mca_vprotocol_base_include_list[0]) return mca_pml_v_component_parasite_close(); V_OUTPUT_VERBOSE(500, "component_close: I don't want to be unloaded now."); ret = mca_base_component_repository_retain_component("pml", "v"); if(OPAL_SUCCESS != ret) { V_OUTPUT_ERR("pml_v: component_close: can't retain myself. If Open MPI is build static you can ignore this error. Otherwise it should crash soon."); } /* Mark that we have changed something */ snprintf(mca_pml_base_selected_component.pmlm_version.mca_component_name, MCA_BASE_MAX_TYPE_NAME_LEN, "%s]v%s", mca_pml_v.host_pml_component.pmlm_version.mca_component_name, mca_vprotocol_component.pmlm_version.mca_component_name); /* Replace finalize */ mca_pml_base_selected_component.pmlm_finalize = mca_pml_v_component_parasite_finalize; /* Make sure we get initialized if some Vprotocol is enabled */ mca_pml.pml_enable = mca_pml_v_enable; return OMPI_SUCCESS; }
static int mca_pml_monitoring_component_close(void) { if( NULL != mca_pml_monitoring_current_filename ) { free(mca_pml_monitoring_current_filename); mca_pml_monitoring_current_filename = NULL; } if( !mca_pml_monitoring_enabled ) return OMPI_SUCCESS; /** * If this component is already active, then we are currently monitoring the execution * and this close if the one from MPI_Finalize. Do the clean up and release the extra * reference on ourselves. */ if( mca_pml_monitoring_active ) { /* Already active, turn off */ pml_selected_component.pmlm_version.mca_close_component(); memset(&pml_selected_component, 0, sizeof(mca_pml_base_component_t)); memset(&pml_selected_module, 0, sizeof(mca_pml_base_module_t)); mca_base_component_repository_release((mca_base_component_t*)&mca_pml_monitoring_component); mca_pml_monitoring_active = 0; return OMPI_SUCCESS; } /** * We are supposed to monitor the execution. Save the winner PML component and * module, and swap it with ourselves. Increase our refcount so that we are * not dlclose. */ if( OPAL_SUCCESS != mca_base_component_repository_retain_component(mca_pml_monitoring_component.pmlm_version.mca_type_name, mca_pml_monitoring_component.pmlm_version.mca_component_name) ) { return OMPI_ERROR; } /* Save a copy of the selected PML */ pml_selected_component = mca_pml_base_selected_component; pml_selected_module = mca_pml; /* Install our interception layer */ mca_pml_base_selected_component = mca_pml_monitoring_component; mca_pml = mca_pml_monitoring; /* Restore some of the original valued: progress, flags, tags and context id */ mca_pml.pml_progress = pml_selected_module.pml_progress; mca_pml.pml_max_contextid = pml_selected_module.pml_max_contextid; mca_pml.pml_max_tag = pml_selected_module.pml_max_tag; mca_pml.pml_flags = pml_selected_module.pml_flags; mca_pml_monitoring_active = 1; return OMPI_SUCCESS; }