Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

mtl: add query method to mtl components #409

Merged
merged 1 commit into from
Jul 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 31 additions & 45 deletions ompi/mca/mtl/base/mtl_base_frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,64 +49,50 @@ int
ompi_mtl_base_select(bool enable_progress_threads,
bool enable_mpi_threads)
{
opal_list_item_t *item = NULL;
mca_base_component_list_item_t *cli = NULL;
mca_mtl_base_component_t *component = NULL;
mca_mtl_base_module_t *module = NULL;

/* Traverse the list of available components; call their init
functions. */
for (item = opal_list_get_first(&ompi_mtl_base_framework.framework_components);
opal_list_get_end(&ompi_mtl_base_framework.framework_components) != item;
item = opal_list_get_next(item) ) {
cli = (mca_base_component_list_item_t *) item;
component = (mca_mtl_base_component_t *) cli->cli_component;

if (NULL == component->mtl_init) {
opal_output_verbose( 10, ompi_mtl_base_framework.framework_output,
"select: no init function; ignoring component %s",
component->mtl_version.mca_component_name );
continue;
}
opal_output_verbose( 10, ompi_mtl_base_framework.framework_output,
"select: initializing %s component %s",
component->mtl_version.mca_type_name,
component->mtl_version.mca_component_name );
module = component->mtl_init(enable_progress_threads,
enable_mpi_threads);
if (NULL == module) {
opal_output_verbose( 10, ompi_mtl_base_framework.framework_output,
"select: init returned failure for component %s",
component->mtl_version.mca_component_name );
continue;
}
opal_output_verbose( 10, ompi_mtl_base_framework.framework_output,
"select: init returned success");

ompi_mtl_base_selected_component = component;
ompi_mtl = module;
int ret = OMPI_ERR_NOT_FOUND;
mca_mtl_base_component_t *best_component = NULL;
mca_mtl_base_module_t *best_module = NULL;

/*
* Select the best component
*/
if( OPAL_SUCCESS != mca_base_select("mtl", ompi_mtl_base_framework.framework_output,
&ompi_mtl_base_framework.framework_components,
(mca_base_module_t **) &best_module,
(mca_base_component_t **) &best_component) ) {
/* notify caller that no available component found */
return ret;
}

/* This base function closes, unloads, and removes from the
available list all unselected components. The available list will
contain only the selected component. */
if (ompi_mtl_base_selected_component) {
(void) mca_base_framework_components_close(&ompi_mtl_base_framework,
(mca_base_component_t *) ompi_mtl_base_selected_component);
opal_output_verbose( 10, ompi_mtl_base_framework.framework_output,
"select: initializing %s component %s",
best_component->mtl_version.mca_type_name,
best_component->mtl_version.mca_component_name );

if (NULL == best_component->mtl_init(enable_progress_threads,
enable_mpi_threads)) {
opal_output_verbose( 10, ompi_mtl_base_framework.framework_output,
"select: init returned failure for component %s",
best_component->mtl_version.mca_component_name );
} else {
opal_output_verbose( 10, ompi_mtl_base_framework.framework_output,
"select: init returned success");
ompi_mtl_base_selected_component = best_component;
ompi_mtl = best_module;
ret = OMPI_SUCCESS;
}

/* All done */
if (NULL == module) {
if (NULL == ompi_mtl) {
opal_output_verbose( 10, ompi_mtl_base_framework.framework_output,
"select: no component selected");
return OMPI_ERR_NOT_FOUND;
} else {
opal_output_verbose( 10, ompi_mtl_base_framework.framework_output,
"select: component %s selected",
ompi_mtl_base_selected_component->
mtl_version.mca_component_name );
return OMPI_SUCCESS;
}
return ret;
}


Expand Down
40 changes: 32 additions & 8 deletions ompi/mca/mtl/mxm/mtl_mxm_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
#include <unistd.h>

static int ompi_mtl_mxm_component_open(void);
static int ompi_mtl_mxm_component_query(mca_base_module_t **module, int *priority);
static int ompi_mtl_mxm_component_close(void);
static int ompi_mtl_mxm_component_register(void);

static int param_priority;

int mca_mtl_mxm_output = -1;


Expand All @@ -42,14 +45,14 @@ mca_mtl_mxm_component_t mca_mtl_mxm_component = {
*/
{
MCA_MTL_BASE_VERSION_2_0_0,
"mxm", /* MCA component name */
OMPI_MAJOR_VERSION, /* MCA component major version */
OMPI_MINOR_VERSION, /* MCA component minor version */
OMPI_RELEASE_VERSION, /* MCA component release version */
ompi_mtl_mxm_component_open, /* component open */
ompi_mtl_mxm_component_close, /* component close */
NULL,
ompi_mtl_mxm_component_register
.mca_component_name = "mxm",
.mca_component_major_version = OMPI_MAJOR_VERSION,
.mca_component_minor_version = OMPI_MINOR_VERSION,
.mca_component_release_version = OMPI_RELEASE_VERSION,
.mca_open_component = ompi_mtl_mxm_component_open,
.mca_close_component = ompi_mtl_mxm_component_close,
.mca_query_component = ompi_mtl_mxm_component_query,
.mca_register_component_params = ompi_mtl_mxm_component_register,
},
{
/* The component is not checkpoint ready */
Expand Down Expand Up @@ -86,6 +89,15 @@ static int ompi_mtl_mxm_component_register(void)
MCA_BASE_VAR_SCOPE_READONLY,
&ompi_mtl_mxm.mxm_np);

param_priority = 100;
(void) mca_base_component_var_register (c,
"priority", "Priority of the MXM MTL component",
MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&param_priority);


#if MXM_API >= MXM_VERSION(3,1)
{
unsigned long cur_ver = mxm_get_version();
Expand Down Expand Up @@ -206,6 +218,18 @@ static int ompi_mtl_mxm_component_open(void)
return OMPI_SUCCESS;
}

static int ompi_mtl_mxm_component_query(mca_base_module_t **module, int *priority)
{

/*
* if we get here it means that mxm is available so give high priority
*/

*priority = param_priority;
*module = (mca_base_module_t *)&ompi_mtl_mxm.super;
return OMPI_SUCCESS;
}

static int ompi_mtl_mxm_component_close(void)
{
if (ompi_mtl_mxm.mxm_context != NULL) {
Expand Down
39 changes: 31 additions & 8 deletions ompi/mca/mtl/portals4/mtl_portals4_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@
#include "mtl_portals4_recv_short.h"
#include "mtl_portals4_message.h"

static int param_priority;

static int ompi_mtl_portals4_component_register(void);
static int ompi_mtl_portals4_component_open(void);
static int ompi_mtl_portals4_component_close(void);
static int ompi_mtl_portals4_component_query(mca_base_module_t **module, int *priority);
static mca_mtl_base_module_t*
ompi_mtl_portals4_component_init(bool enable_progress_threads,
bool enable_mpi_threads);
Expand All @@ -45,14 +48,14 @@ mca_mtl_base_component_2_0_0_t mca_mtl_portals4_component = {
{
MCA_MTL_BASE_VERSION_2_0_0,

"portals4", /* MCA component name */
OMPI_MAJOR_VERSION, /* MCA component major version */
OMPI_MINOR_VERSION, /* MCA component minor version */
OMPI_RELEASE_VERSION, /* MCA component release version */
ompi_mtl_portals4_component_open, /* component open */
ompi_mtl_portals4_component_close, /* component close */
NULL,
ompi_mtl_portals4_component_register
.mca_component_name = "portals4",
.mca_component_major_version = OMPI_MAJOR_VERSION,
.mca_component_minor_version = OMPI_MINOR_VERSION,
.mca_component_release_version = OMPI_RELEASE_VERSION,
.mca_open_component = ompi_mtl_portals4_component_open,
.mca_close_component = ompi_mtl_portals4_component_close,
.mca_query_component = ompi_mtl_portals4_component_query,
.mca_register_component_params = ompi_mtl_portals4_component_register,
},
{
/* The component is not checkpoint ready */
Expand All @@ -74,6 +77,14 @@ ompi_mtl_portals4_component_register(void)
mca_base_var_enum_t *new_enum;
int ret;

param_priority = 10;
(void) mca_base_component_var_register (&mca_mtl_portals4_component.mtl_version,
"priority", "Priority of the Portals4 MTL component",
MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&param_priority);

ompi_mtl_portals4.eager_limit = 2 * 1024;
(void) mca_base_component_var_register(&mca_mtl_portals4_component.mtl_version,
"eager_limit",
Expand Down Expand Up @@ -210,6 +221,18 @@ ompi_mtl_portals4_component_open(void)
return OMPI_SUCCESS;
}

static int
ompi_mtl_portals4_component_query(mca_base_module_t **module, int *priority)
{
/*
* assume if portals4 MTL was compiled, the user wants it
*/

*priority = param_priority;
*module = (mca_base_module_t *)&ompi_mtl_portals4.base;
return OMPI_SUCCESS;
}


static int
ompi_mtl_portals4_component_close(void)
Expand Down
41 changes: 33 additions & 8 deletions ompi/mca/mtl/psm/mtl_psm_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@
#include <sys/stat.h>
#include <unistd.h>

static int param_priority;

static int ompi_mtl_psm_component_open(void);
static int ompi_mtl_psm_component_close(void);
static int ompi_mtl_psm_component_query(mca_base_module_t **module, int *priority);
static int ompi_mtl_psm_component_register(void);

static mca_mtl_base_module_t* ompi_mtl_psm_component_init( bool enable_progress_threads,
Expand All @@ -53,14 +56,14 @@ mca_mtl_psm_component_t mca_mtl_psm_component = {
{
MCA_MTL_BASE_VERSION_2_0_0,

"psm", /* MCA component name */
OMPI_MAJOR_VERSION, /* MCA component major version */
OMPI_MINOR_VERSION, /* MCA component minor version */
OMPI_RELEASE_VERSION, /* MCA component release version */
ompi_mtl_psm_component_open, /* component open */
ompi_mtl_psm_component_close, /* component close */
NULL,
ompi_mtl_psm_component_register
.mca_component_name = "psm",
.mca_component_major_version = OMPI_MAJOR_VERSION,
.mca_component_minor_version = OMPI_MINOR_VERSION,
.mca_component_release_version = OMPI_RELEASE_VERSION,
.mca_open_component = ompi_mtl_psm_component_open,
.mca_close_component = ompi_mtl_psm_component_close,
.mca_query_component = ompi_mtl_psm_component_query,
.mca_register_component_params = ompi_mtl_psm_component_register,
},
{
/* The component is not checkpoint ready */
Expand All @@ -86,6 +89,15 @@ ompi_mtl_psm_component_register(void)
mca_base_var_enum_t *new_enum;
#endif


param_priority = 100;
(void) mca_base_component_var_register (&mca_mtl_psm_component.super.mtl_version,
"priority", "Priority of the PSM MTL component",
MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&param_priority);

ompi_mtl_psm.connect_timeout = 180;
(void) mca_base_component_var_register(&mca_mtl_psm_component.super.mtl_version,
"connect_timeout",
Expand Down Expand Up @@ -180,6 +192,19 @@ ompi_mtl_psm_component_open(void)
}
}

static int
ompi_mtl_psm_component_query(mca_base_module_t **module, int *priority)
{
/*
* if we get here it means that PSM is available so give high priority
*/

*priority = param_priority;
*module = (mca_base_module_t *)&ompi_mtl_psm.super;
return OMPI_SUCCESS;
}


static int
ompi_mtl_psm_component_close(void)
{
Expand Down