
such, the commit message back to the master SVN repository is fairly long. = ORTE Job-Level Output Messages = Add two new interfaces that should be used for all new code throughout the ORTE and OMPI layers (we already make the search-and-replace on the existing ORTE / OMPI layers): * orte_output(): (and corresponding friends ORTE_OUTPUT, orte_output_verbose, etc.) This function sends the output directly to the HNP for processing as part of a job-specific output channel. It supports all the same outputs as opal_output() (syslog, file, stdout, stderr), but for stdout/stderr, the output is sent to the HNP for processing and output. More on this below. * orte_show_help(): This function is a drop-in-replacement for opal_show_help(), with two differences in functionality: 1. the rendered text help message output is sent to the HNP for display (rather than outputting directly into the process' stderr stream) 1. the HNP detects duplicate help messages and does not display them (so that you don't see the same error message N times, once from each of your N MPI processes); instead, it counts "new" instances of the help message and displays a message every ~5 seconds when there are new ones ("I got X new copies of the help message...") opal_show_help and opal_output still exist, but they only output in the current process. The intent for the new orte_* functions is that they can apply job-level intelligence to the output. As such, we recommend that all new ORTE and OMPI code use the new orte_* functions, not thei opal_* functions. === New code === For ORTE and OMPI programmers, here's what you need to do differently in new code: * Do not include opal/util/show_help.h or opal/util/output.h. Instead, include orte/util/output.h (this one header file has declarations for both the orte_output() series of functions and orte_show_help()). * Effectively s/opal_output/orte_output/gi throughout your code. Note that orte_output_open() takes a slightly different argument list (as a way to pass data to the filtering stream -- see below), so you if explicitly call opal_output_open(), you'll need to slightly adapt to the new signature of orte_output_open(). * Literally s/opal_show_help/orte_show_help/. The function signature is identical. === Notes === * orte_output'ing to stream 0 will do similar to what opal_output'ing did, so leaving a hard-coded "0" as the first argument is safe. * For systems that do not use ORTE's RML or the HNP, the effect of orte_output_* and orte_show_help will be identical to their opal counterparts (the additional information passed to orte_output_open() will be lost!). Indeed, the orte_* functions simply become trivial wrappers to their opal_* counterparts. Note that we have not tested this; the code is simple but it is quite possible that we mucked something up. = Filter Framework = Messages sent view the new orte_* functions described above and messages output via the IOF on the HNP will now optionally be passed through a new "filter" framework before being output to stdout/stderr. The "filter" OPAL MCA framework is intended to allow preprocessing to messages before they are sent to their final destinations. The first component that was written in the filter framework was to create an XML stream, segregating all the messages into different XML tags, etc. This will allow 3rd party tools to read the stdout/stderr from the HNP and be able to know exactly what each text message is (e.g., a help message, another OMPI infrastructure message, stdout from the user process, stderr from the user process, etc.). Filtering is not active by default. Filter components must be specifically requested, such as: {{{ $ mpirun --mca filter xml ... }}} There can only be one filter component active. = New MCA Parameters = The new functionality described above introduces two new MCA parameters: * '''orte_base_help_aggregate''': Defaults to 1 (true), meaning that help messages will be aggregated, as described above. If set to 0, all help messages will be displayed, even if they are duplicates (i.e., the original behavior). * '''orte_base_show_output_recursions''': An MCA parameter to help debug one of the known issues, described below. It is likely that this MCA parameter will disappear before v1.3 final. = Known Issues = * The XML filter component is not complete. The current output from this component is preliminary and not real XML. A bit more work needs to be done to configure.m4 search for an appropriate XML library/link it in/use it at run time. * There are possible recursion loops in the orte_output() and orte_show_help() functions -- e.g., if RML send calls orte_output() or orte_show_help(). We have some ideas how to fix these, but figured that it was ok to commit before feature freeze with known issues. The code currently contains sub-optimal workarounds so that this will not be a problem, but it would be good to actually solve the problem rather than have hackish workarounds before v1.3 final. This commit was SVN r18434.
416 строки
16 KiB
C
416 строки
16 KiB
C
/*
|
|
* Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
|
|
* University Research and Technology
|
|
* Corporation. All rights reserved.
|
|
* Copyright (c) 2004-2005 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) 2006 Cisco Systems, Inc. All rights reserved.
|
|
* $COPYRIGHT$
|
|
*
|
|
* Additional copyrights may follow
|
|
*
|
|
* $HEADER$
|
|
*/
|
|
/* Much of the code in this file is taken from the file ll_get_machine_list.c,
|
|
* which is provided by IBM as part of their sample programs for LoadLeveler
|
|
* in the samples/llmpich directory. The documentation has the following license:
|
|
* COPYRIGHT LICENSE:
|
|
* This information contains sample application programs in source language, which
|
|
* illustrate programming techniques on various operating platforms. You may copy,
|
|
* modify, and distribute these sample programs in any form without payment to
|
|
* IBM, for the purposes of developing, using, marketing or distributing
|
|
* application programs conforming to the application programming interface for
|
|
* the operating platform for which the sample programs are written. These
|
|
* examples have not been thoroughly tested under all conditions. IBM,
|
|
* therefore, cannot guarantee or imply reliability, serviceability, or
|
|
* function of these programs.
|
|
*/
|
|
|
|
#include "orte_config.h"
|
|
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
|
|
#include <llapi.h>
|
|
|
|
#include "opal/util/argv.h"
|
|
#include "orte/util/output.h"
|
|
|
|
#include "orte/mca/errmgr/errmgr.h"
|
|
#include "orte/runtime/orte_globals.h"
|
|
#include "orte/constants.h"
|
|
|
|
#include "orte/mca/ras/base/ras_private.h"
|
|
#include "ras_loadleveler.h"
|
|
|
|
|
|
/*
|
|
* Local functions
|
|
*/
|
|
static int orte_ras_loadleveler_allocate(opal_list_t *nodes);
|
|
static int orte_ras_loadleveler_finalize(void);
|
|
static int orte_ras_loadleveler_get_hostlist(int * num_hosts, char*** hostlist);
|
|
|
|
|
|
/*
|
|
* Global variable
|
|
*/
|
|
orte_ras_base_module_t orte_ras_loadleveler_module = {
|
|
orte_ras_loadleveler_allocate,
|
|
orte_ras_loadleveler_finalize
|
|
};
|
|
|
|
|
|
/*
|
|
* Discover available (pre-allocated) nodes. Allocate the
|
|
* requested number of nodes/process slots to the job.
|
|
*/
|
|
static int orte_ras_loadleveler_allocate(opal_list_t *nodes)
|
|
{
|
|
int i, ret=ORTE_SUCCESS;
|
|
opal_list_item_t* item;
|
|
orte_node_t* node;
|
|
char ** hostlist = NULL;
|
|
int num_hosts = 0;
|
|
|
|
ret = orte_ras_loadleveler_get_hostlist(&num_hosts, &hostlist);
|
|
if(ORTE_SUCCESS != ret) {
|
|
ORTE_ERROR_LOG(ret);
|
|
return ret;
|
|
}
|
|
|
|
for (i = 0; i < num_hosts; i++) {
|
|
/* check for duplicated nodes */
|
|
for (item = opal_list_get_first(nodes);
|
|
opal_list_get_end(nodes) != item;
|
|
item = opal_list_get_next(item)) {
|
|
node = (orte_node_t*) item;
|
|
if (0 == strcmp(node->name, hostlist[i])) {
|
|
++node->slots;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if(opal_list_get_end(nodes) == item) {
|
|
/* we did not find a duplicate, so add a new item to the list */
|
|
node = OBJ_NEW(orte_node_t);
|
|
if (NULL == node) {
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
ret = ORTE_ERR_OUT_OF_RESOURCE;
|
|
goto cleanup;
|
|
}
|
|
node->name = strdup(hostlist[i]);
|
|
node->state = ORTE_NODE_STATE_UP;
|
|
node->slots_inuse = 0;
|
|
node->slots_max = 0;
|
|
node->slots = 1;
|
|
opal_list_append(nodes, &node->super);
|
|
}
|
|
}
|
|
|
|
cleanup:
|
|
opal_argv_free(hostlist);
|
|
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* There's really nothing to do here
|
|
*/
|
|
static int orte_ras_loadleveler_finalize(void)
|
|
{
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:finalize: success (nothing to do)");
|
|
return ORTE_SUCCESS;
|
|
}
|
|
|
|
/*
|
|
* get the hostlist from LoadLeveler
|
|
* *hostlist should either by NULL or a valid argv and *num_hosts
|
|
* should be 0 or the number of elements in the hostlist argv
|
|
*/
|
|
static int orte_ras_loadleveler_get_hostlist(int* num_hosts, char*** hostlist)
|
|
{
|
|
LL_element *queryObject = NULL, *job = NULL, *step = NULL;
|
|
LL_element *node = NULL, *task = NULL, *task_instance = NULL;
|
|
int rc, obj_count, err_code, ll_master_task, job_step_count;
|
|
char *ll_step_id= NULL, *job_step_list[2], *task_machine_name = NULL;
|
|
char *schedd_host_name = NULL;
|
|
int step_mode;
|
|
|
|
/* Get the step ID from LOADL_STEP_ID environment variable. */
|
|
if(NULL == (ll_step_id = getenv("LOADL_STEP_ID"))) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: could not get LOADL_STEP_ID "
|
|
"from environment!");
|
|
return ORTE_ERROR;
|
|
}
|
|
|
|
job_step_list[0] = ll_step_id;
|
|
job_step_list[1] = NULL;
|
|
|
|
/* STEP 1: Get Job object from Central Manager to find out the name of the
|
|
* Schedd daemon that handles this job. In a Multicluster environment we
|
|
* can not get the schedd name from the job step id. */
|
|
|
|
/* Initialize the LL API. Specify that query type is JOBS. */
|
|
if(NULL == (queryObject = ll_query(JOBS))) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_query faild on JOBS!");
|
|
return ORTE_ERROR;
|
|
}
|
|
|
|
/* Specify that this is a QUERY_STEPID type of query. */
|
|
rc = ll_set_request(queryObject, QUERY_STEPID, job_step_list, ALL_DATA);
|
|
if(0 > rc) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_set request failed: error "
|
|
"%d!", rc);
|
|
return ORTE_ERROR;
|
|
}
|
|
|
|
/* Get a Job object from LoadL_schedd that contains the relevant job step */
|
|
job = ll_get_objs(queryObject, LL_CM, NULL, &obj_count, &err_code);
|
|
if(NULL == job) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_get_objs faild!");
|
|
return ORTE_ERROR;
|
|
}
|
|
|
|
if (obj_count != 1) { /* Only 1 Job object is expected. */
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_get_objs: expected one job "
|
|
"to match, got %d!", obj_count);
|
|
return ORTE_ERROR;
|
|
}
|
|
|
|
if(0 != (rc = ll_get_data(job, LL_JobSchedd, &schedd_host_name))) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_get_data: failure. RC= %d!",
|
|
rc);
|
|
return ORTE_ERROR;
|
|
}
|
|
if (schedd_host_name != NULL) {
|
|
job_step_list[0] = ll_step_id;
|
|
job_step_list[1] = NULL;
|
|
} else {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_get_objs() Error: Could not "
|
|
"determine managing schedd for job %s.\n",
|
|
job_step_list[0]);
|
|
return ORTE_ERROR;
|
|
}
|
|
ll_free_objs(queryObject);
|
|
ll_deallocate(queryObject);
|
|
|
|
/* STEP 2: Get Job object from Schedd that manages this job step. */
|
|
/* Only schedd query gives us all the relevant task instance info. */
|
|
|
|
/* Initialize the LL API. Specify that query type is JOBS. */
|
|
if(NULL == (queryObject = ll_query(JOBS))) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_query faild on JOBS!");
|
|
return ORTE_ERROR;
|
|
}
|
|
|
|
/* Specify that this is a QUERY_STEPID type of query. */
|
|
rc = ll_set_request(queryObject, QUERY_STEPID, job_step_list, ALL_DATA);
|
|
if(0 != rc) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_set request failed: error "
|
|
"%d!", rc);
|
|
return ORTE_ERROR;
|
|
}
|
|
|
|
/* Get a Job object from LoadL_schedd that contains the relevant job step */
|
|
job = ll_get_objs(queryObject, LL_SCHEDD, schedd_host_name, &obj_count,
|
|
&err_code);
|
|
if(NULL == job) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_set request failed: error "
|
|
"%d!", rc);
|
|
return ORTE_ERROR;
|
|
}
|
|
|
|
if (obj_count != 1) { /* Only 1 Job object is expected. */
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_get_objs: expected one job "
|
|
"to match, got %d!", obj_count);
|
|
return ORTE_ERROR;
|
|
}
|
|
|
|
if(0 != (rc = ll_get_data(job, LL_JobStepCount, &job_step_count))) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_get_data: failure. RC= %d!",
|
|
rc);
|
|
return ORTE_ERROR;
|
|
}
|
|
if (job_step_count != 1) { /* Only 1 Job Step object is expected. */
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_get_objs: expected one job "
|
|
"step to match, got %d!", obj_count);
|
|
return ORTE_ERROR;
|
|
}
|
|
|
|
step = NULL;
|
|
if(0 != (rc = ll_get_data(job, LL_JobGetFirstStep, &step))) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_get_data: failure. RC= %d!",
|
|
rc);
|
|
return ORTE_ERROR;
|
|
}
|
|
if(NULL == step) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ll_get_data() Error: Unable to obtain Job Step "
|
|
"information.\n");
|
|
return ORTE_ERROR;
|
|
}
|
|
|
|
step_mode = -1;
|
|
if(0 != (rc = ll_get_data(step, LL_StepParallelMode, &step_mode))) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_get_data: failure on "
|
|
"LL_StepParallelMode. RC= %d!", rc);
|
|
return ORTE_ERROR;
|
|
}
|
|
|
|
/* Serial job step: step_mode==0; Parallel: step_mode==1; Others:2,3,4. */
|
|
if ((step_mode != 0) && (step_mode != 1)) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: We support only Serial and "
|
|
"Parallel LoadLeveler job types. PVM, NQS, and Blue Gene"
|
|
"jobs are not supported by the LoadLeveler RAS!");
|
|
return ORTE_ERROR;
|
|
}
|
|
|
|
if(step_mode == 0) { /* serial job */
|
|
node = NULL;
|
|
if(0 != (rc = ll_get_data(step, LL_StepGetFirstNode, &node))) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_get_data: failure on "
|
|
"LL_StepGetFirstNode. RC= %d!", rc);
|
|
return ORTE_ERROR;
|
|
}
|
|
task = NULL;
|
|
if(0 != (rc = ll_get_data(node, LL_NodeGetFirstTask, &task))) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_get_data: failure on "
|
|
"LL_NodeGetFirstTask. RC= %d!", rc);
|
|
return ORTE_ERROR;
|
|
}
|
|
task_instance = NULL;
|
|
rc = ll_get_data(task, LL_TaskGetFirstTaskInstance, &task_instance);
|
|
if(0 != rc) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_get_data: failure on "
|
|
"LL_TaskGetFirstInstance. RC= %d!", rc);
|
|
return ORTE_ERROR;
|
|
}
|
|
task_machine_name = NULL;
|
|
if(0 != (rc = ll_get_data(task_instance, LL_TaskInstanceMachineName,
|
|
&task_machine_name))) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_get_data: failure on "
|
|
"LL_TaskInstanceMachineName. RC= %d!", rc);
|
|
return ORTE_ERROR;
|
|
}
|
|
opal_argv_append(num_hosts, hostlist, task_machine_name);
|
|
|
|
} else { /* parallel job */
|
|
|
|
node = NULL;
|
|
if(0 != (rc = ll_get_data(step, LL_StepGetFirstNode, &node))) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_get_data: failure on "
|
|
"LL_StepGetFirstNode. RC= %d!", rc);
|
|
return ORTE_ERROR;
|
|
}
|
|
|
|
while(NULL != node) { /* Loop through the "Node" objects. */
|
|
task = NULL;
|
|
if(0 != (rc = ll_get_data(node, LL_NodeGetFirstTask, &task))) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_get_data: failure on "
|
|
"LL_NodeGetFirstTask. RC= %d!", rc);
|
|
return ORTE_ERROR;
|
|
}
|
|
|
|
while(task) { /* Loop through the "Task" objects. */
|
|
ll_master_task = 0;
|
|
rc = ll_get_data(task, LL_TaskIsMaster, &ll_master_task);
|
|
if(0 != rc) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_get_data: failure"
|
|
" on LL_TaskIsMaster. RC= %d!", rc);
|
|
return ORTE_ERROR;
|
|
}
|
|
|
|
/* The "master task" Task object is a LoadLeveler abstraction
|
|
* and is not relevant here. Look at only Task objects that
|
|
* are not "master".*/
|
|
if (!ll_master_task) {
|
|
task_instance = NULL;
|
|
if(0 != (rc = ll_get_data(task, LL_TaskGetFirstTaskInstance,
|
|
&task_instance))) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_get_data: "
|
|
"failure on LL_TaskGetFirstTaskInstance. "
|
|
" RC= %d!", rc);
|
|
return ORTE_ERROR;
|
|
}
|
|
|
|
/* Loop through the "Task Instance" objects. */
|
|
while (task_instance) {
|
|
task_machine_name = NULL;
|
|
rc = ll_get_data(task_instance,
|
|
LL_TaskInstanceMachineName,
|
|
&task_machine_name);
|
|
if(0 != rc) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_get_data:"
|
|
" failure on LL_TaskInstanceMachineName"
|
|
"RC= %d!", rc);
|
|
return ORTE_ERROR;
|
|
}
|
|
opal_argv_append(num_hosts, hostlist, task_machine_name);
|
|
task_instance = NULL;
|
|
rc = ll_get_data(task, LL_TaskGetNextTaskInstance,
|
|
&task_instance);
|
|
if(0 != rc) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_get_data:"
|
|
" failure on LL_TaskGetNextInstance. "
|
|
"RC= %d!", rc);
|
|
return ORTE_ERROR;
|
|
}
|
|
}
|
|
}
|
|
task = NULL;
|
|
if(0 != (rc = ll_get_data(node, LL_NodeGetNextTask, &task))) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_get_data: "
|
|
"failure on LL_NodeGetNextTask. RC= %d!", rc);
|
|
return ORTE_ERROR;
|
|
}
|
|
}
|
|
node = NULL;
|
|
if(0 != (rc = ll_get_data(step, LL_StepGetNextNode, &node))) {
|
|
orte_output(orte_ras_base.ras_output,
|
|
"ras:loadleveler:allocate: ll_get_data: failure "
|
|
"on LL_StepGetNextNode. RC= %d!", rc);
|
|
return ORTE_ERROR;
|
|
}
|
|
}
|
|
}
|
|
ll_free_objs(queryObject);
|
|
ll_deallocate(queryObject);
|
|
|
|
return ORTE_SUCCESS;
|
|
}
|