Skip to content

Commit

Permalink
Merge pull request open-mpi#2 from benmcclelland/master
Browse files Browse the repository at this point in the history
octl util, and scd single select
  • Loading branch information
rhc54 committed Jun 2, 2014
2 parents efa713d + f68403b commit 39d7e3e
Show file tree
Hide file tree
Showing 18 changed files with 480 additions and 457 deletions.
1 change: 1 addition & 0 deletions config/orcm_config_files.m4
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ AC_DEFUN([ORCM_CONFIG_FILES],[
orcm/etc/Makefile
orcm/include/Makefile

orcm/tools/octl/Makefile
orcm/tools/orcmctrld/Makefile
orcm/tools/orcmd/Makefile
orcm/tools/ops/Makefile
Expand Down
2 changes: 1 addition & 1 deletion orcm/mca/rm/basic/rm_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static void basic_request(int sd, short args, void *cbdata)
orcm_session_caddy_t *caddy = (orcm_session_caddy_t*)cbdata;
int i, rc, num_nodes;
char *nodelist = NULL;
char *noderegex;
char *noderegex = NULL;

num_nodes = caddy->session->alloc->min_nodes;

Expand Down
17 changes: 3 additions & 14 deletions orcm/mca/scd/base/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ OBJ_CLASS_DECLARATION(orcm_scheduler_caddy_t);
s->scheduler = (a); \
opal_event_set(orcm_scd_base.ev_base, &s->ev, -1, OPAL_EV_WRITE, \
orcm_scd_base_construct_queues, s); \
opal_event_set_priority(&s->ev, ORCM_SCHED_PRI); \
opal_event_set_priority(&s->ev, ORCM_SCHED_PRI); \
opal_event_active(&s->ev, OPAL_EV_WRITE, 1); \
} while(0);

Expand All @@ -71,26 +71,15 @@ typedef struct {
bool ev_active;
/* state machine */
opal_list_t states;
/* list of active scheduler plugins */
opal_list_t active_modules;
/* selected plugin */
orcm_scd_base_module_t *module;
/* queues for tracking session requests */
opal_list_t queues;
/* node tracking */
opal_pointer_array_t nodes;
} orcm_scd_base_t;
ORCM_DECLSPEC extern orcm_scd_base_t orcm_scd_base;

/**
* Select an scd component / module
*/
typedef struct {
opal_list_item_t super;
int pri;
orcm_scd_base_module_t *module;
mca_base_component_t *component;
} orcm_scd_base_active_module_t;
OBJ_CLASS_DECLARATION(orcm_scd_base_active_module_t);

/* start/stop base receive */
ORCM_DECLSPEC int orcm_scd_base_comm_start(void);
ORCM_DECLSPEC int orcm_scd_base_comm_stop(void);
Expand Down
15 changes: 3 additions & 12 deletions orcm/mca/scd/base/scd_base_frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ static int orcm_scd_base_close(void)
}

/* deconstruct the base objects */
OPAL_LIST_DESTRUCT(&orcm_scd_base.active_modules);
OPAL_LIST_DESTRUCT(&orcm_scd_base.states);
OPAL_LIST_DESTRUCT(&orcm_scd_base.queues);

Expand All @@ -92,7 +91,6 @@ static int orcm_scd_base_open(mca_base_open_flag_t flags)
/* setup the base objects */
orcm_scd_base.ev_active = false;
OBJ_CONSTRUCT(&orcm_scd_base.states, opal_list_t);
OBJ_CONSTRUCT(&orcm_scd_base.active_modules, opal_list_t);
OBJ_CONSTRUCT(&orcm_scd_base.queues, opal_list_t);
OBJ_CONSTRUCT(&orcm_scd_base.nodes, opal_pointer_array_t);
opal_pointer_array_init(&orcm_scd_base.nodes, 8, INT_MAX, 8);
Expand Down Expand Up @@ -155,6 +153,9 @@ const char *orcm_scd_session_state_to_str(orcm_scd_session_state_t state)
case ORCM_SESSION_STATE_TERMINATED:
s = "TERMINATED";
break;
case ORCM_SESSION_STATE_CANCEL:
s = "CANCEL";
break;
default:
s = "UNKNOWN";
}
Expand Down Expand Up @@ -188,16 +189,6 @@ const char *orcm_scd_node_state_to_str(orcm_scd_node_state_t state)
}

/**** CLASS INSTANTIATIONS ****/
static void scd_des(orcm_scd_base_active_module_t *s)
{
if (NULL != s->module->finalize) {
s->module->finalize();
}
}
OBJ_CLASS_INSTANCE(orcm_scd_base_active_module_t,
opal_list_item_t,
NULL, scd_des);

OBJ_CLASS_INSTANCE(orcm_scheduler_caddy_t,
opal_object_t,
NULL, NULL);
Expand Down
17 changes: 15 additions & 2 deletions orcm/mca/scd/base/scd_base_recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static void orcm_scd_base_recv(int status, orte_process_name_t* sender,
void* cbdata)
{
orcm_scd_cmd_flag_t command;
int rc, i, j, cnt;
int rc, i, j, cnt, result;
orcm_alloc_t *alloc, **allocs;
opal_buffer_t *ans;
orcm_session_t *session;
Expand Down Expand Up @@ -202,6 +202,20 @@ static void orcm_scd_base_recv(int status, orte_process_name_t* sender,
/* pass it to the scheduler */
ORCM_ACTIVATE_SCD_STATE(session, ORCM_SESSION_STATE_CANCEL);

/* send confirmation back to sender */
result = 0;
if (OPAL_SUCCESS != (rc = opal_dss.pack(ans, &result, 1, OPAL_INT))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(ans);
return;
}
if (ORTE_SUCCESS != (rc = orte_rml.send_buffer_nb(sender, ans,
ORCM_RML_TAG_SCD,
orte_rml_send_callback, NULL))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(ans);
return;
}
return;
} else if (ORCM_NODE_INFO_COMMAND == command) {
/* pack the number of nodes we have */
Expand All @@ -220,7 +234,6 @@ static void orcm_scd_base_recv(int status, orte_process_name_t* sender,
return;
}
i = 0;
fprintf(stdout, "lowestfree: %i, size: %i\n", (int)orcm_scd_base.nodes.lowest_free, (int)orcm_scd_base.nodes.size);
for (j = 0; j < orcm_scd_base.nodes.lowest_free; j++) {
if (NULL == (nodes[i] = (orcm_node_t*)opal_pointer_array_get_item(&orcm_scd_base.nodes, j))) {
continue;
Expand Down
115 changes: 22 additions & 93 deletions orcm/mca/scd/base/scd_base_select.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,103 +17,32 @@

#include "orcm/mca/scd/base/base.h"

static bool selected = false;

/**
* Function for selecting multiple components from all those that are
* available.
/*
* Function for selecting one component from all those that are available.
*/

int orcm_scd_base_select(void)
{
mca_base_component_list_item_t *cli = NULL;
mca_base_component_t *component = NULL;
mca_base_module_t *module = NULL;
orcm_scd_base_module_t *nmodule;
orcm_scd_base_active_module_t *newmodule, *mod;
int rc, priority;
bool inserted;

if (selected) {
/* ensure we don't do this twice */
return ORCM_SUCCESS;
}
selected = true;

/* Query all available components and ask if they have a module */
OPAL_LIST_FOREACH(cli, &orcm_scd_base_framework.framework_components, mca_base_component_list_item_t) {
component = (mca_base_component_t *) cli->cli_component;

opal_output_verbose(5, orcm_scd_base_framework.framework_output,
"mca:scd:select: checking available component %s", component->mca_component_name);

/* If there's no query function, skip it */
if (NULL == component->mca_query_component) {
opal_output_verbose(5, orcm_scd_base_framework.framework_output,
"mca:scd:select: Skipping component [%s]. It does not implement a query function",
component->mca_component_name);
continue;
}

/* Query the component */
opal_output_verbose(5, orcm_scd_base_framework.framework_output,
"mca:scd:select: Querying component [%s]",
component->mca_component_name);
rc = component->mca_query_component(&module, &priority);

/* If no module was returned, then skip component */
if (ORCM_SUCCESS != rc || NULL == module) {
opal_output_verbose(5, orcm_scd_base_framework.framework_output,
"mca:scd:select: Skipping component [%s]. Query failed to return a module",
component->mca_component_name);
continue;
}

/* If we got a module, keep it */
nmodule = (orcm_scd_base_module_t*) module;
/* give the module a chance to init */
if (NULL != nmodule->init) {
if (ORCM_SUCCESS != (rc = nmodule->init())) {
opal_output_verbose(5, orcm_scd_base_framework.framework_output,
"mca:scd:select: Skipping component [%s]. Init returned error %s",
component->mca_component_name, ORTE_ERROR_NAME(rc));
continue;
}
}

/* add to the list of selected modules */
newmodule = OBJ_NEW(orcm_scd_base_active_module_t);
newmodule->pri = priority;
newmodule->module = nmodule;
newmodule->component = component;

/* maintain priority order */
inserted = false;
OPAL_LIST_FOREACH(mod, &orcm_scd_base.active_modules, orcm_scd_base_active_module_t) {
if (priority > mod->pri) {
opal_list_insert_pos(&orcm_scd_base.active_modules,
(opal_list_item_t*)mod, &newmodule->super);
inserted = true;
break;
}
}
if (!inserted) {
/* must be lowest priority - add to end */
opal_list_append(&orcm_scd_base.active_modules, &newmodule->super);
}
}

/* if we didn't get any plugins, that's an error */
if (0 == opal_list_get_size(&orcm_scd_base.active_modules)) {
orcm_scd_base_component_t *best_component = NULL;
orcm_scd_base_module_t *best_module = NULL;

/*
* Select the best component
*/
if(OPAL_SUCCESS != mca_base_select("scd",
orcm_scd_base_framework.framework_output,
&orcm_scd_base_framework.framework_components,
(mca_base_module_t **) &best_module,
(mca_base_component_t **) &best_component)) {
/* This will only happen if no component was selected */
return ORCM_ERR_NOT_FOUND;
}

if (4 < opal_output_get_verbosity(orcm_scd_base_framework.framework_output)) {
opal_output(0, "%s: Final scheduler priorities", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME));
/* show the prioritized list */
OPAL_LIST_FOREACH(mod, &orcm_scd_base.active_modules, orcm_scd_base_active_module_t) {
opal_output(0, "\tScheduler: %s Priority: %d", mod->component->mca_component_name, mod->pri);
}

/* Save the winner */
orcm_scd_base.module = best_module;

if (NULL != orcm_scd_base.module->init) {
return orcm_scd_base.module->init();
}

return ORCM_SUCCESS;;
return ORCM_SUCCESS;
}
34 changes: 0 additions & 34 deletions orcm/mca/scd/basic/Makefile.am

This file was deleted.

Loading

0 comments on commit 39d7e3e

Please sign in to comment.