1
1
openmpi/ompi/mca/pml/base/pml_base_select.c

382 строки
14 KiB
C
Исходник Обычный вид История

/* -*- Mode: C; c-basic-offset:4 ; -*- */
/*
* Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2007 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2012 Los Alamos National Security, LLC. All rights
* reserved.
As per the email discussion, revise the sparse handling of hostnames so that we avoid potential infinite loops while allowing large-scale users to improve their startup time: * add a new MCA param orte_hostname_cutoff to specify the number of nodes at which we stop including hostnames. This defaults to INT_MAX => always include hostnames. If a value is given, then we will include hostnames for any allocation smaller than the given limit. * remove ompi_proc_get_hostname. Replace all occurrences with a direct link to ompi_proc_t's proc_hostname, protected by appropriate "if NULL" * modify the OMPI-ORTE integration component so that any call to modex_recv automatically loads the ompi_proc_t->proc_hostname field as well as returning the requested info. Thus, any process whose modex info you retrieve will automatically receive the hostname. Note that on-demand retrieval is still enabled - i.e., if we are running under direct launch with PMI, the hostname will be fetched upon first call to modex_recv, and then the ompi_proc_t->proc_hostname field will be loaded * removed a stale MCA param "mpi_keep_peer_hostnames" that was no longer used anywhere in the code base * added an envar lookup in ess/pmi for the number of nodes in the allocation. Sadly, PMI itself doesn't provide that info, so we have to get it a different way. Currently, we support PBS-based systems and SLURM - for any other, rank0 will emit a warning and we assume max number of daemons so we will always retain hostnames This commit was SVN r29052.
2013-08-20 18:59:36 +00:00
* Copyright (c) 2013 Intel, Inc. All rights reserved
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include "opal/class/opal_list.h"
#include "opal/util/output.h"
#include "opal/util/show_help.h"
#include "opal/runtime/opal_progress.h"
#include "opal/mca/mca.h"
#include "opal/mca/base/base.h"
Enable modex-less launch. Consists of: 1. minor modification to include two new opal MCA params: (a) opal_profile: outputs what components were selected by each framework currently enabled for most, but not all, frameworks (b) opal_profile_file: name of file that contains profile info required for modex 2. introduction of two new tools: (a) ompi-probe: MPI process that simply calls MPI_Init/Finalize with opal_profile set. Also reports back the rml IP address for all interfaces on the node (b) ompi-profiler: uses ompi-probe to create the profile_file, also reports out a summary of what framework components are actually being used to help with configuration options 3. modification of the grpcomm basic component to utilize the profile file in place of the modex where possible 4. modification of orterun so it properly sees opal mca params and handles opal_profile correctly to ensure we don't get its profile 5. similar mod to orted as for orterun 6. addition of new test that calls orte_init followed by calls to grpcomm.barrier This is all completely benign unless actively selected. At the moment, it only supports modex-less launch for openib-based systems. Minor mod to the TCP btl would be required to enable it as well, if people are interested. Similarly, anyone interested in enabling other BTL's for modex-less operation should let me know and I'll give you the magic details. This seems to significantly improve scalability provided the file can be locally located on the nodes. I'm looking at an alternative means of disseminating the info (perhaps in launch message) as an option for removing that constraint. This commit was SVN r20098.
2008-12-09 23:49:02 +00:00
#include "opal/runtime/opal.h"
#include "ompi/constants.h"
#include "ompi/mca/pml/pml.h"
#include "ompi/mca/pml/base/base.h"
#include "ompi/proc/proc.h"
#include "ompi/runtime/ompi_module_exchange.h"
- massive change for module<-->component name fixes throughout the code base. - many (most) mca type names have "component" or "module" in them, as relevant, just to further distinguish the difference between component data/actions and module data/actions. All developers are encouraged to perpetuate this convention when you create types that are specific to a framework, component, or module - did very little to entire framework (just the basics to make it compile) because it's just about to be almost entirely replaced - ditto for io / romio - did not work on elan or ib components; have to commit and then convert those on a different machine with the right libraries and headers - renamed a bunch of *_module.c files to *_component.c and *module*c to *component*c (a few still remain, e.g., ptl/ib, ptl/elan, etc.) - modified autogen/configure/build process to match new filenames (e.g., output static-components.h instead of static-modules.h) - removed DOS-style cr/lf stuff in ns/ns.h - added newline to end of file src/util/numtostr.h - removed some redundant error checking in the top-level topo functions - added a few {} here and there where people "forgot" to put them in for 1 line blocks ;-) - removed a bunch of MPI_* types from mca header files (replaced with corresponding ompi_* types) - all the ptl components had version numbers in their structs; removed - converted a few more elements in the MCA base to use the OBJ interface -- removed some old manual reference counting kruft This commit was SVN r1830.
2004-08-02 00:24:22 +00:00
typedef struct opened_component_t {
opal_list_item_t super;
- massive change for module<-->component name fixes throughout the code base. - many (most) mca type names have "component" or "module" in them, as relevant, just to further distinguish the difference between component data/actions and module data/actions. All developers are encouraged to perpetuate this convention when you create types that are specific to a framework, component, or module - did very little to entire framework (just the basics to make it compile) because it's just about to be almost entirely replaced - ditto for io / romio - did not work on elan or ib components; have to commit and then convert those on a different machine with the right libraries and headers - renamed a bunch of *_module.c files to *_component.c and *module*c to *component*c (a few still remain, e.g., ptl/ib, ptl/elan, etc.) - modified autogen/configure/build process to match new filenames (e.g., output static-components.h instead of static-modules.h) - removed DOS-style cr/lf stuff in ns/ns.h - added newline to end of file src/util/numtostr.h - removed some redundant error checking in the top-level topo functions - added a few {} here and there where people "forgot" to put them in for 1 line blocks ;-) - removed a bunch of MPI_* types from mca header files (replaced with corresponding ompi_* types) - all the ptl components had version numbers in their structs; removed - converted a few more elements in the MCA base to use the OBJ interface -- removed some old manual reference counting kruft This commit was SVN r1830.
2004-08-02 00:24:22 +00:00
mca_pml_base_component_t *om_component;
} opened_component_t;
static bool modex_reqd=false;
/**
- massive change for module<-->component name fixes throughout the code base. - many (most) mca type names have "component" or "module" in them, as relevant, just to further distinguish the difference between component data/actions and module data/actions. All developers are encouraged to perpetuate this convention when you create types that are specific to a framework, component, or module - did very little to entire framework (just the basics to make it compile) because it's just about to be almost entirely replaced - ditto for io / romio - did not work on elan or ib components; have to commit and then convert those on a different machine with the right libraries and headers - renamed a bunch of *_module.c files to *_component.c and *module*c to *component*c (a few still remain, e.g., ptl/ib, ptl/elan, etc.) - modified autogen/configure/build process to match new filenames (e.g., output static-components.h instead of static-modules.h) - removed DOS-style cr/lf stuff in ns/ns.h - added newline to end of file src/util/numtostr.h - removed some redundant error checking in the top-level topo functions - added a few {} here and there where people "forgot" to put them in for 1 line blocks ;-) - removed a bunch of MPI_* types from mca header files (replaced with corresponding ompi_* types) - all the ptl components had version numbers in their structs; removed - converted a few more elements in the MCA base to use the OBJ interface -- removed some old manual reference counting kruft This commit was SVN r1830.
2004-08-02 00:24:22 +00:00
* Function for selecting one component from all those that are
* available.
*
- massive change for module<-->component name fixes throughout the code base. - many (most) mca type names have "component" or "module" in them, as relevant, just to further distinguish the difference between component data/actions and module data/actions. All developers are encouraged to perpetuate this convention when you create types that are specific to a framework, component, or module - did very little to entire framework (just the basics to make it compile) because it's just about to be almost entirely replaced - ditto for io / romio - did not work on elan or ib components; have to commit and then convert those on a different machine with the right libraries and headers - renamed a bunch of *_module.c files to *_component.c and *module*c to *component*c (a few still remain, e.g., ptl/ib, ptl/elan, etc.) - modified autogen/configure/build process to match new filenames (e.g., output static-components.h instead of static-modules.h) - removed DOS-style cr/lf stuff in ns/ns.h - added newline to end of file src/util/numtostr.h - removed some redundant error checking in the top-level topo functions - added a few {} here and there where people "forgot" to put them in for 1 line blocks ;-) - removed a bunch of MPI_* types from mca header files (replaced with corresponding ompi_* types) - all the ptl components had version numbers in their structs; removed - converted a few more elements in the MCA base to use the OBJ interface -- removed some old manual reference counting kruft This commit was SVN r1830.
2004-08-02 00:24:22 +00:00
* Call the init function on all available components and get their
* priorities. Select the component with the highest priority. All
* other components will be closed and unloaded. The selected component
* will have all of its function pointers saved and returned to the
* caller.
*/
int mca_pml_base_select(bool enable_progress_threads,
bool enable_mpi_threads)
{
int i, priority = 0, best_priority = 0, num_pml = 0;
opal_list_item_t *item = NULL;
mca_base_component_list_item_t *cli = NULL;
mca_pml_base_component_t *component = NULL, *best_component = NULL;
mca_pml_base_module_t *module = NULL, *best_module = NULL;
opal_list_t opened;
opened_component_t *om = NULL;
2007-02-03 02:32:00 +00:00
bool found_pml;
#if OPAL_ENABLE_FT_CR == 1
mca_pml_base_component_t *wrapper_component = NULL;
int wrapper_priority = -1;
#endif
/* Traverse the list of available components; call their init
functions. */
best_priority = -1;
best_component = NULL;
module = NULL;
OBJ_CONSTRUCT(&opened, opal_list_t);
OPAL_LIST_FOREACH(cli, &ompi_pml_base_framework.framework_components, mca_base_component_list_item_t) {
component = (mca_pml_base_component_t *) cli->cli_component;
/* if there is an include list - item must be in the list to be included */
2007-02-03 02:32:00 +00:00
found_pml = false;
for( i = 0; i < opal_pointer_array_get_size(&mca_pml_base_pml); i++) {
char * tmp_val = NULL;
tmp_val = (char *) opal_pointer_array_get_item(&mca_pml_base_pml, i);
if( NULL == tmp_val) {
continue;
}
if(0 == strncmp(component->pmlm_version.mca_component_name,
tmp_val, strlen(component->pmlm_version.mca_component_name)) ) {
2007-02-03 02:32:00 +00:00
found_pml = true;
break;
}
}
if(!found_pml && opal_pointer_array_get_size(&mca_pml_base_pml)) {
opal_output_verbose( 10, ompi_pml_base_framework.framework_output,
2007-02-03 02:32:00 +00:00
"select: component %s not in the include list",
component->pmlm_version.mca_component_name );
continue;
}
/* if there is no init function - ignore it */
if (NULL == component->pmlm_init) {
opal_output_verbose( 10, ompi_pml_base_framework.framework_output,
"select: no init function; ignoring component %s",
component->pmlm_version.mca_component_name );
continue;
}
/* this is a pml that could be considered */
num_pml++;
/* Init component to get its priority */
opal_output_verbose( 10, ompi_pml_base_framework.framework_output,
"select: initializing %s component %s",
component->pmlm_version.mca_type_name,
component->pmlm_version.mca_component_name );
priority = best_priority;
module = component->pmlm_init(&priority, enable_progress_threads,
enable_mpi_threads);
if (NULL == module) {
opal_output_verbose( 10, ompi_pml_base_framework.framework_output,
"select: init returned failure for component %s",
component->pmlm_version.mca_component_name );
continue;
}
opal_output_verbose( 10, ompi_pml_base_framework.framework_output,
"select: init returned priority %d", priority );
#if OPAL_ENABLE_FT_CR == 1
/* Determine if this is the wrapper component */
if( priority <= PML_SELECT_WRAPPER_PRIORITY) {
opal_output_verbose( 10, ompi_pml_base_framework.framework_output,
"pml:select: Wrapper Component: Component %s was determined to be a Wrapper PML with priority %d",
component->pmlm_version.mca_component_name, priority );
wrapper_priority = priority;
wrapper_component = component;
continue;
}
/* Otherwise determine if this is the best component */
else
#endif
if (priority > best_priority) {
best_priority = priority;
best_component = component;
best_module = module;
}
om = (opened_component_t*)malloc(sizeof(opened_component_t));
if (NULL == om) {
return OMPI_ERR_OUT_OF_RESOURCE;
}
OBJ_CONSTRUCT(om, opal_list_item_t);
om->om_component = component;
opal_list_append(&opened, (opal_list_item_t*) om);
}
/* Finished querying all components. Check for the bozo case. */
if( NULL == best_component ) {
opal_show_help("help-mca-base.txt", "find-available:none-found", true, "pml");
for( i = 0; i < opal_pointer_array_get_size(&mca_pml_base_pml); i++) {
char * tmp_val = NULL;
tmp_val = (char *) opal_pointer_array_get_item(&mca_pml_base_pml, i);
if( NULL == tmp_val) {
continue;
}
ompi_rte_abort(1, "PML %s cannot be selected", tmp_val);
}
if(0 == i) {
ompi_rte_abort(2, "No pml component available. This shouldn't happen.");
}
}
opal_output_verbose( 10, ompi_pml_base_framework.framework_output,
"selected %s best priority %d\n",
best_component->pmlm_version.mca_component_name, best_priority);
/* if more than one PML could be considered, then we still need the
* modex since we cannot know which one will be selected on all procs
*/
if (1 < num_pml) {
modex_reqd = true;
}
/* Finalize all non-selected components */
for (item = opal_list_remove_first(&opened);
NULL != item;
item = opal_list_remove_first(&opened)) {
om = (opened_component_t *) item;
if (om->om_component != best_component
#if OPAL_ENABLE_FT_CR == 1
&& om->om_component != wrapper_component
#endif
) {
/* Finalize */
if (NULL != om->om_component->pmlm_finalize) {
/* Blatently ignore the return code (what would we do to
recover, anyway? This component is going away, so errors
don't matter anymore) */
om->om_component->pmlm_finalize();
opal_output_verbose(10, ompi_pml_base_framework.framework_output,
"select: component %s not selected / finalized",
om->om_component->pmlm_version.mca_component_name);
}
}
OBJ_DESTRUCT( om );
free(om);
}
OBJ_DESTRUCT( &opened );
#if OPAL_ENABLE_FT_CR == 1
/* Remove the wrapper component from the ompi_pml_base_framework.framework_components list
* so we don't unload it prematurely in the next call
*/
if( NULL != wrapper_component ) {
OPAL_LIST_FOREACH(cli, &ompi_pml_base_framework.framework_components, mca_base_component_list_item_t) {
component = (mca_pml_base_component_t *) cli->cli_component;
if( component == wrapper_component ) {
opal_list_remove_item(&ompi_pml_base_framework.framework_components, item);
}
}
}
#endif
/* Save the winner */
mca_pml_base_selected_component = *best_component;
mca_pml = *best_module;
opal_output_verbose( 10, ompi_pml_base_framework.framework_output,
"select: component %s selected",
mca_pml_base_selected_component.pmlm_version.mca_component_name );
/* This base function closes, unloads, and removes from the
available list all unselected components. The available list will
contain only the selected component. */
mca_base_components_close(ompi_pml_base_framework.framework_output,
&ompi_pml_base_framework.framework_components,
(mca_base_component_t *) best_component);
#if OPAL_ENABLE_FT_CR == 1
/* If we have a wrapper then initalize it */
if( NULL != wrapper_component ) {
priority = PML_SELECT_WRAPPER_PRIORITY;
opal_output_verbose( 10, ompi_pml_base_framework.framework_output,
"pml:select: Wrapping: Component %s [%d] is being wrapped by component %s [%d]",
mca_pml_base_selected_component.pmlm_version.mca_component_name,
best_priority,
wrapper_component->pmlm_version.mca_component_name,
wrapper_priority );
/* Ask the wrapper commponent to wrap around the currently
* selected component. Indicated by the priority value provided
* this will cause the wrapper to do something different this time around
*/
module = wrapper_component->pmlm_init(&priority,
enable_progress_threads,
enable_mpi_threads);
/* Replace with the wrapper */
best_component = wrapper_component;
mca_pml_base_selected_component = *best_component;
best_module = module;
mca_pml = *best_module;
}
#endif
/* register the winner's callback */
if( NULL != mca_pml.pml_progress ) {
opal_progress_register(mca_pml.pml_progress);
}
/* register winner in the modex */
if (modex_reqd && 0 == OMPI_PROC_MY_NAME->vpid) {
mca_pml_base_pml_selected(best_component->pmlm_version.mca_component_name);
}
/* All done */
return OMPI_SUCCESS;
}
/* need a "commonly" named PML structure so everything ends up in the
same modex field */
static mca_base_component_t pml_base_component = {
MCA_BASE_VERSION_2_0_0,
"pml",
MCA_BASE_VERSION_2_0_0,
"base",
MCA_BASE_VERSION_2_0_0,
NULL,
NULL
};
int
mca_pml_base_pml_selected(const char *name)
{
return ompi_modex_send(&pml_base_component, name, strlen(name) + 1);
}
int
mca_pml_base_pml_check_selected(const char *my_pml,
ompi_proc_t **procs,
size_t nprocs)
{
size_t size;
int ret;
char *remote_pml;
/* if no modex was required by the PML, then
* we can assume success
*/
if (!modex_reqd) {
opal_output_verbose( 10, ompi_pml_base_framework.framework_output,
"check:select: modex not reqd");
return OMPI_SUCCESS;
}
/* if we are rank=0, then we can also assume success */
if (0 == OMPI_PROC_MY_NAME->vpid) {
opal_output_verbose( 10, ompi_pml_base_framework.framework_output,
"check:select: rank=0");
return OMPI_SUCCESS;
}
/* get the name of the PML module selected by rank=0 */
ret = ompi_modex_recv(&pml_base_component,
procs[0],
(void**) &remote_pml, &size);
/* if this key wasn't found, then just assume all is well... */
if (OMPI_SUCCESS != ret) {
opal_output_verbose( 10, ompi_pml_base_framework.framework_output,
"check:select: modex data not found");
return OMPI_SUCCESS;
}
/* the remote pml returned should never be NULL if an error
* wasn't returned, but just to be safe, and since the check
* is fast...let's be sure
*/
if (NULL == remote_pml) {
opal_output_verbose( 10, ompi_pml_base_framework.framework_output,
"check:select: got a NULL pml from rank=0");
return OMPI_ERR_UNREACH;
}
opal_output_verbose( 10, ompi_pml_base_framework.framework_output,
"check:select: checking my pml %s against rank=0 pml %s",
my_pml, remote_pml);
/* if that module doesn't match my own, return an error */
if ((size != strlen(my_pml) + 1) ||
(0 != strcmp(my_pml, remote_pml))) {
As per the email discussion, revise the sparse handling of hostnames so that we avoid potential infinite loops while allowing large-scale users to improve their startup time: * add a new MCA param orte_hostname_cutoff to specify the number of nodes at which we stop including hostnames. This defaults to INT_MAX => always include hostnames. If a value is given, then we will include hostnames for any allocation smaller than the given limit. * remove ompi_proc_get_hostname. Replace all occurrences with a direct link to ompi_proc_t's proc_hostname, protected by appropriate "if NULL" * modify the OMPI-ORTE integration component so that any call to modex_recv automatically loads the ompi_proc_t->proc_hostname field as well as returning the requested info. Thus, any process whose modex info you retrieve will automatically receive the hostname. Note that on-demand retrieval is still enabled - i.e., if we are running under direct launch with PMI, the hostname will be fetched upon first call to modex_recv, and then the ompi_proc_t->proc_hostname field will be loaded * removed a stale MCA param "mpi_keep_peer_hostnames" that was no longer used anywhere in the code base * added an envar lookup in ess/pmi for the number of nodes in the allocation. Sadly, PMI itself doesn't provide that info, so we have to get it a different way. Currently, we support PBS-based systems and SLURM - for any other, rank0 will emit a warning and we assume max number of daemons so we will always retain hostnames This commit was SVN r29052.
2013-08-20 18:59:36 +00:00
opal_output(0, "%s selected pml %s, but peer %s on %s selected pml %s",
OMPI_NAME_PRINT(&ompi_proc_local()->proc_name),
my_pml, OMPI_NAME_PRINT(&procs[0]->proc_name),
(NULL == procs[0]->proc_hostname) ? "unknown" : procs[0]->proc_hostname,
remote_pml);
free(remote_pml); /* cleanup before returning */
return OMPI_ERR_UNREACH;
}
free(remote_pml);
return OMPI_SUCCESS;
}