2005-08-24 19:15:11 +00:00
|
|
|
/*
|
2007-01-24 14:45:42 +00:00
|
|
|
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
|
2005-11-05 19:57:48 +00:00
|
|
|
* 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.
|
2005-08-24 19:15:11 +00:00
|
|
|
* 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$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
#include "orte_config.h"
|
2008-02-28 01:57:57 +00:00
|
|
|
#include "orte/constants.h"
|
|
|
|
#include "orte/types.h"
|
2005-08-24 19:15:11 +00:00
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
#include "opal/util/argv.h"
|
2008-02-28 01:57:57 +00:00
|
|
|
|
2008-06-09 14:53:58 +00:00
|
|
|
#include "orte/util/show_help.h"
|
2006-10-17 17:28:02 +00:00
|
|
|
#include "orte/mca/errmgr/errmgr.h"
|
2008-02-28 01:57:57 +00:00
|
|
|
#include "orte/util/name_fns.h"
|
|
|
|
#include "orte/runtime/orte_globals.h"
|
2006-10-17 16:06:17 +00:00
|
|
|
|
2006-09-14 21:29:51 +00:00
|
|
|
#include "orte/mca/ras/base/ras_private.h"
|
2005-08-24 19:15:11 +00:00
|
|
|
#include "ras_slurm.h"
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local functions
|
|
|
|
*/
|
2008-02-28 01:57:57 +00:00
|
|
|
static int orte_ras_slurm_allocate(opal_list_t *nodes);
|
2006-10-19 23:33:51 +00:00
|
|
|
static int orte_ras_slurm_finalize(void);
|
2005-08-24 19:15:11 +00:00
|
|
|
|
2007-01-24 14:45:42 +00:00
|
|
|
static int orte_ras_slurm_discover(char *regexp, char* tasks_per_node,
|
2008-02-28 01:57:57 +00:00
|
|
|
int cpus_per_task, opal_list_t *nodelist);
|
2006-10-19 23:33:51 +00:00
|
|
|
static int orte_ras_slurm_parse_ranges(char *base, char *ranges, char ***nodelist);
|
|
|
|
static int orte_ras_slurm_parse_range(char *base, char *range, char ***nodelist);
|
2005-08-24 19:15:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Global variable
|
|
|
|
*/
|
|
|
|
orte_ras_base_module_t orte_ras_slurm_module = {
|
2006-10-19 23:33:51 +00:00
|
|
|
orte_ras_slurm_allocate,
|
|
|
|
orte_ras_slurm_finalize
|
2005-08-24 19:15:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Discover available (pre-allocated) nodes. Allocate the
|
|
|
|
* requested number of nodes/process slots to the job.
|
|
|
|
*
|
|
|
|
*/
|
2008-02-28 01:57:57 +00:00
|
|
|
static int orte_ras_slurm_allocate(opal_list_t *nodes)
|
2005-08-24 19:15:11 +00:00
|
|
|
{
|
2008-02-28 01:57:57 +00:00
|
|
|
int ret, cpus_per_task;
|
2007-01-24 14:45:42 +00:00
|
|
|
char *slurm_node_str, *regexp;
|
|
|
|
char *tasks_per_node, *node_tasks;
|
2008-02-28 01:57:57 +00:00
|
|
|
char * tmp;
|
2006-10-19 23:33:51 +00:00
|
|
|
|
2005-08-24 19:15:11 +00:00
|
|
|
slurm_node_str = getenv("SLURM_NODELIST");
|
|
|
|
if (NULL == slurm_node_str) {
|
This commit represents a bunch of work on a Mercurial side branch. As
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.
2008-05-13 20:00:55 +00:00
|
|
|
orte_show_help("help-ras-slurm.txt", "slurm-env-var-not-found", 1,
|
2005-08-24 19:15:11 +00:00
|
|
|
"SLURM_NODELIST");
|
|
|
|
return ORTE_ERR_NOT_FOUND;
|
|
|
|
}
|
2007-01-24 14:45:42 +00:00
|
|
|
regexp = strdup(slurm_node_str);
|
|
|
|
|
|
|
|
tasks_per_node = getenv("SLURM_TASKS_PER_NODE");
|
|
|
|
if (NULL == tasks_per_node) {
|
This commit represents a bunch of work on a Mercurial side branch. As
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.
2008-05-13 20:00:55 +00:00
|
|
|
orte_show_help("help-ras-slurm.txt", "slurm-env-var-not-found", 1,
|
2007-01-24 14:45:42 +00:00
|
|
|
"SLURM_TASKS_PER_NODE");
|
|
|
|
return ORTE_ERR_NOT_FOUND;
|
|
|
|
}
|
|
|
|
node_tasks = strdup(tasks_per_node);
|
|
|
|
|
|
|
|
if(NULL == regexp || NULL == node_tasks) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
2005-08-24 19:15:11 +00:00
|
|
|
|
2008-02-28 01:57:57 +00:00
|
|
|
/* get the number of CPUs per task that the user provided to slurm */
|
|
|
|
tmp = getenv("SLURM_CPUS_PER_TASK");
|
|
|
|
if(NULL != tmp) {
|
|
|
|
cpus_per_task = atoi(tmp);
|
|
|
|
if(0 >= cpus_per_task) {
|
2008-06-09 14:53:58 +00:00
|
|
|
opal_output(0, "ras:slurm:allocate: Got bad value from SLURM_CPUS_PER_TASK. "
|
2008-02-28 01:57:57 +00:00
|
|
|
"Variable was: %s\n", tmp);
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERROR);
|
|
|
|
return ORTE_ERROR;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
cpus_per_task = 1;
|
|
|
|
}
|
2007-01-24 14:45:42 +00:00
|
|
|
|
2008-02-28 01:57:57 +00:00
|
|
|
ret = orte_ras_slurm_discover(regexp, node_tasks, cpus_per_task, nodes);
|
2007-01-24 14:45:42 +00:00
|
|
|
free(regexp);
|
|
|
|
free(node_tasks);
|
|
|
|
if (ORTE_SUCCESS != ret) {
|
2008-06-09 14:53:58 +00:00
|
|
|
OPAL_OUTPUT_VERBOSE((1, orte_ras_base.ras_output,
|
2008-02-28 01:57:57 +00:00
|
|
|
"%s ras:slurm:allocate: discover failed!",
|
|
|
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)));
|
2005-08-24 19:15:11 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2005-10-07 22:24:52 +00:00
|
|
|
|
2005-08-24 19:15:11 +00:00
|
|
|
/* All done */
|
|
|
|
|
|
|
|
if (ORTE_SUCCESS == ret) {
|
2008-06-09 14:53:58 +00:00
|
|
|
OPAL_OUTPUT_VERBOSE((1, orte_ras_base.ras_output,
|
2008-02-28 01:57:57 +00:00
|
|
|
"%s ras:slurm:allocate: success",
|
|
|
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)));
|
2005-08-24 19:15:11 +00:00
|
|
|
} else {
|
2008-06-09 14:53:58 +00:00
|
|
|
OPAL_OUTPUT_VERBOSE((1, orte_ras_base.ras_output,
|
2008-02-28 01:57:57 +00:00
|
|
|
"%s ras:slurm:allocate: failure (base_allocate_nodes=%d)",
|
|
|
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), ret));
|
2005-08-24 19:15:11 +00:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* There's really nothing to do here
|
|
|
|
*/
|
2006-10-19 23:33:51 +00:00
|
|
|
static int orte_ras_slurm_finalize(void)
|
2005-08-24 19:15:11 +00:00
|
|
|
{
|
2008-02-28 01:57:57 +00:00
|
|
|
|
2008-06-09 14:53:58 +00:00
|
|
|
OPAL_OUTPUT_VERBOSE((1, orte_ras_base.ras_output,
|
2008-02-28 01:57:57 +00:00
|
|
|
"%s ras:slurm:finalize: success (nothing to do)",
|
|
|
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)));
|
2005-08-24 19:15:11 +00:00
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2007-01-24 14:45:42 +00:00
|
|
|
* Discover the available resources.
|
|
|
|
*
|
|
|
|
* In order to fully support slurm, we need to be able to handle
|
|
|
|
* node regexp/task_per_node strings such as:
|
|
|
|
* foo,bar 5,3
|
|
|
|
* foo 5
|
|
|
|
* foo[2-10,12,99-105],bar,foobar[3-11] 2(x10),5,100(x16)
|
2005-08-24 19:15:11 +00:00
|
|
|
*
|
2007-01-24 14:45:42 +00:00
|
|
|
* @param *regexp A node regular expression from SLURM (i.e. SLURM_NODELIST)
|
|
|
|
* @param *tasks_per_node A tasks per node expression from SLURM
|
|
|
|
* (i.e. SLURM_TASKS_PER_NODE)
|
|
|
|
* @param *nodelist A list which has already been constucted to return
|
|
|
|
* the found nodes in
|
2005-08-24 19:15:11 +00:00
|
|
|
*/
|
2007-01-24 14:45:42 +00:00
|
|
|
static int orte_ras_slurm_discover(char *regexp, char *tasks_per_node,
|
2008-02-28 01:57:57 +00:00
|
|
|
int cpus_per_task, opal_list_t* nodelist)
|
2005-08-24 19:15:11 +00:00
|
|
|
{
|
2007-01-24 14:45:42 +00:00
|
|
|
int i, j, len, ret, count, reps, num_nodes;
|
2007-03-29 00:50:56 +00:00
|
|
|
char *base, **names = NULL;
|
2007-01-24 14:45:42 +00:00
|
|
|
char *begptr, *endptr, *orig;
|
2005-08-25 15:51:58 +00:00
|
|
|
int *slots;
|
2007-01-24 14:45:42 +00:00
|
|
|
bool found_range = false;
|
2007-01-25 16:12:05 +00:00
|
|
|
bool more_to_come = false;
|
2005-08-24 19:15:11 +00:00
|
|
|
|
2007-01-24 14:45:42 +00:00
|
|
|
orig = base = strdup(regexp);
|
2005-08-24 19:15:11 +00:00
|
|
|
if (NULL == base) {
|
2007-01-24 14:45:42 +00:00
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
2005-08-24 19:15:11 +00:00
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
2008-02-28 01:57:57 +00:00
|
|
|
|
2008-06-09 14:53:58 +00:00
|
|
|
OPAL_OUTPUT_VERBOSE((1, orte_ras_base.ras_output,
|
2008-02-28 01:57:57 +00:00
|
|
|
"%s ras:slurm:allocate:discover: checking nodelist: %s",
|
|
|
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
|
|
|
regexp));
|
2005-08-24 19:15:11 +00:00
|
|
|
|
2007-01-24 14:45:42 +00:00
|
|
|
do {
|
|
|
|
/* Find the base */
|
|
|
|
len = strlen(base);
|
|
|
|
for (i = 0; i <= len; ++i) {
|
|
|
|
if (base[i] == '[') {
|
|
|
|
/* we found a range. this gets dealt with below */
|
|
|
|
base[i] = '\0';
|
|
|
|
found_range = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (base[i] == ',') {
|
|
|
|
/* we found a singleton node, and there are more to come */
|
|
|
|
base[i] = '\0';
|
|
|
|
found_range = false;
|
|
|
|
more_to_come = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (base[i] == '\0') {
|
|
|
|
/* we found a singleton node */
|
|
|
|
found_range = false;
|
|
|
|
more_to_come = false;
|
2005-08-24 19:15:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-01-24 14:45:42 +00:00
|
|
|
if(i == 0) {
|
|
|
|
/* we found a special character at the beginning of the string */
|
This commit represents a bunch of work on a Mercurial side branch. As
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.
2008-05-13 20:00:55 +00:00
|
|
|
orte_show_help("help-ras-slurm.txt", "slurm-env-var-bad-value",
|
2007-01-24 14:45:42 +00:00
|
|
|
1, regexp, tasks_per_node, "SLURM_NODELIST");
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
|
|
|
|
free(orig);
|
|
|
|
return ORTE_ERR_BAD_PARAM;
|
2005-08-24 19:15:11 +00:00
|
|
|
}
|
|
|
|
|
2007-01-24 14:45:42 +00:00
|
|
|
if (found_range) {
|
|
|
|
/* If we found a range, now find the end of the range */
|
|
|
|
for (j = i; j < len; ++j) {
|
|
|
|
if (base[j] == ']') {
|
|
|
|
base[j] = '\0';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (j >= len) {
|
|
|
|
/* we didn't find the end of the range */
|
This commit represents a bunch of work on a Mercurial side branch. As
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.
2008-05-13 20:00:55 +00:00
|
|
|
orte_show_help("help-ras-slurm.txt", "slurm-env-var-bad-value",
|
2007-01-24 14:45:42 +00:00
|
|
|
1, regexp, tasks_per_node, "SLURM_NODELIST");
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
|
|
|
|
free(orig);
|
|
|
|
return ORTE_ERR_BAD_PARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = orte_ras_slurm_parse_ranges(base, base + i + 1, &names);
|
|
|
|
if(ORTE_SUCCESS != ret) {
|
This commit represents a bunch of work on a Mercurial side branch. As
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.
2008-05-13 20:00:55 +00:00
|
|
|
orte_show_help("help-ras-slurm.txt", "slurm-env-var-bad-value",
|
2007-01-24 14:45:42 +00:00
|
|
|
1, regexp, tasks_per_node, "SLURM_NODELIST");
|
|
|
|
ORTE_ERROR_LOG(ret);
|
|
|
|
free(orig);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
if(base[j + 1] == ',') {
|
|
|
|
more_to_come = true;
|
|
|
|
base = &base[j + 2];
|
|
|
|
} else {
|
|
|
|
more_to_come = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* If we didn't find a range, just add the node */
|
2008-02-28 01:57:57 +00:00
|
|
|
|
2008-06-09 14:53:58 +00:00
|
|
|
OPAL_OUTPUT_VERBOSE((1, orte_ras_base.ras_output,
|
2008-02-28 01:57:57 +00:00
|
|
|
"%s ras:slurm:allocate:discover: found node %s",
|
|
|
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
|
|
|
base));
|
|
|
|
|
2007-03-29 00:50:56 +00:00
|
|
|
if(ORTE_SUCCESS != (ret = opal_argv_append_nosize(&names, base))) {
|
2007-01-24 14:45:42 +00:00
|
|
|
ORTE_ERROR_LOG(ret);
|
|
|
|
free(orig);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
/* set base equal to the (possible) next base to look at */
|
|
|
|
base = &base[i + 1];
|
|
|
|
}
|
|
|
|
} while(more_to_come);
|
|
|
|
|
|
|
|
free(orig);
|
|
|
|
|
|
|
|
num_nodes = opal_argv_count(names);
|
2005-08-24 19:15:11 +00:00
|
|
|
|
2005-08-25 15:51:58 +00:00
|
|
|
/* Find the number of slots per node */
|
|
|
|
|
2007-01-24 14:45:42 +00:00
|
|
|
slots = malloc(sizeof(int) * num_nodes);
|
2005-08-25 15:51:58 +00:00
|
|
|
if (NULL == slots) {
|
2007-01-24 14:45:42 +00:00
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
2005-08-25 15:51:58 +00:00
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
2007-01-24 14:45:42 +00:00
|
|
|
memset(slots, 0, sizeof(int) * num_nodes);
|
|
|
|
|
|
|
|
orig = begptr = strdup(tasks_per_node);
|
|
|
|
if (NULL == begptr) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
free(slots);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
2005-08-25 15:51:58 +00:00
|
|
|
}
|
2007-01-24 14:45:42 +00:00
|
|
|
|
2005-08-25 15:51:58 +00:00
|
|
|
j = 0;
|
|
|
|
while (begptr) {
|
|
|
|
count = strtol(begptr, &endptr, 10);
|
|
|
|
if ((endptr[0] == '(') && (endptr[1] == 'x')) {
|
|
|
|
reps = strtol((endptr+2), &endptr, 10);
|
|
|
|
if (endptr[0] == ')') {
|
|
|
|
endptr++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
reps = 1;
|
|
|
|
}
|
2007-01-24 14:45:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* TBP: it seems like it would be an error to have more slot
|
|
|
|
* descriptions than nodes. Turns out that this valid, and SLURM will
|
|
|
|
* return such a thing. For instance, if I did:
|
|
|
|
* srun -A -N 30 -w odin001
|
|
|
|
* I would get SLURM_NODELIST=odin001 SLURM_TASKS_PER_NODE=4(x30)
|
|
|
|
* That is, I am allocated 30 nodes, but since I only requested
|
|
|
|
* one specific node, that's what is in the nodelist.
|
|
|
|
* I'm not sure this is what users would expect, but I think it is
|
|
|
|
* more of a SLURM issue than a orte issue, since SLURM is OK with it,
|
|
|
|
* I'm ok with it
|
|
|
|
*/
|
|
|
|
for (i = 0; i < reps && j < num_nodes; i++) {
|
2005-08-25 15:51:58 +00:00
|
|
|
slots[j++] = count;
|
|
|
|
}
|
2007-01-24 14:45:42 +00:00
|
|
|
|
2005-08-25 15:51:58 +00:00
|
|
|
if (*endptr == ',') {
|
|
|
|
begptr = endptr + 1;
|
2007-01-24 14:45:42 +00:00
|
|
|
} else if (*endptr == '\0' || j >= num_nodes) {
|
2005-08-25 15:51:58 +00:00
|
|
|
break;
|
|
|
|
} else {
|
This commit represents a bunch of work on a Mercurial side branch. As
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.
2008-05-13 20:00:55 +00:00
|
|
|
orte_show_help("help-ras-slurm.txt", "slurm-env-var-bad-value", 1,
|
2007-01-24 14:45:42 +00:00
|
|
|
regexp, tasks_per_node, "SLURM_TASKS_PER_NODE");
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
|
|
|
|
free(slots);
|
|
|
|
free(orig);
|
|
|
|
return ORTE_ERR_BAD_PARAM;
|
2005-08-25 15:51:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-24 14:45:42 +00:00
|
|
|
free(orig);
|
|
|
|
|
2008-02-28 01:57:57 +00:00
|
|
|
/* Convert the argv of node names to a list of node_t's */
|
2005-08-24 19:15:11 +00:00
|
|
|
|
2007-01-24 14:45:42 +00:00
|
|
|
for (i = 0; NULL != names && NULL != names[i]; ++i) {
|
2008-02-28 01:57:57 +00:00
|
|
|
orte_node_t *node;
|
2007-01-24 14:45:42 +00:00
|
|
|
|
2008-06-09 14:53:58 +00:00
|
|
|
OPAL_OUTPUT_VERBOSE((1, orte_ras_base.ras_output,
|
2008-02-28 01:57:57 +00:00
|
|
|
"%s ras:slurm:allocate:discover: adding node %s (%d slot%s)",
|
|
|
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
|
|
|
names[i], slots[i], (1 == slots[i]) ? "" : "s"));
|
|
|
|
|
|
|
|
node = OBJ_NEW(orte_node_t);
|
2007-01-24 14:45:42 +00:00
|
|
|
if (NULL == node) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
free(slots);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
2005-08-24 19:15:11 +00:00
|
|
|
}
|
2008-02-28 01:57:57 +00:00
|
|
|
node->name = strdup(names[i]);
|
|
|
|
node->state = ORTE_NODE_STATE_UP;
|
|
|
|
node->slots_inuse = 0;
|
|
|
|
node->slots_max = 0;
|
|
|
|
node->slots = slots[i] / cpus_per_task;
|
2007-01-24 14:45:42 +00:00
|
|
|
opal_list_append(nodelist, &node->super);
|
|
|
|
}
|
|
|
|
free(slots);
|
|
|
|
opal_argv_free(names);
|
2005-08-25 02:59:55 +00:00
|
|
|
|
2005-08-24 19:15:11 +00:00
|
|
|
/* All done */
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Parse one or more ranges in a set
|
2007-01-24 14:45:42 +00:00
|
|
|
*
|
|
|
|
* @param base The base text of the node name
|
|
|
|
* @param *ranges A pointer to a range. This can contain multiple ranges
|
|
|
|
* (i.e. "1-3,10" or "5" or "9,0100-0130,250")
|
|
|
|
* @param ***names An argv array to add the newly discovered nodes to
|
2005-08-24 19:15:11 +00:00
|
|
|
*/
|
2006-10-19 23:33:51 +00:00
|
|
|
static int orte_ras_slurm_parse_ranges(char *base, char *ranges, char ***names)
|
2005-08-24 19:15:11 +00:00
|
|
|
{
|
|
|
|
int i, len, ret;
|
|
|
|
char *start, *orig;
|
|
|
|
|
|
|
|
/* Look for commas, the separator between ranges */
|
|
|
|
|
|
|
|
len = strlen(ranges);
|
|
|
|
for (orig = start = ranges, i = 0; i < len; ++i) {
|
|
|
|
if (',' == ranges[i]) {
|
|
|
|
ranges[i] = '\0';
|
2007-01-24 14:45:42 +00:00
|
|
|
ret = orte_ras_slurm_parse_range(base, start, names);
|
|
|
|
if (ORTE_SUCCESS != ret) {
|
|
|
|
ORTE_ERROR_LOG(ret);
|
2005-08-24 19:15:11 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
start = ranges + i + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Pick up the last range, if it exists */
|
|
|
|
|
|
|
|
if (start < orig + len) {
|
2008-02-28 01:57:57 +00:00
|
|
|
|
2008-06-09 14:53:58 +00:00
|
|
|
OPAL_OUTPUT_VERBOSE((1, orte_ras_base.ras_output,
|
2008-02-28 01:57:57 +00:00
|
|
|
"%s ras:slurm:allocate:discover: parse range %s (2)",
|
|
|
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
|
|
|
start));
|
|
|
|
|
2007-01-24 14:45:42 +00:00
|
|
|
ret = orte_ras_slurm_parse_range(base, start, names);
|
|
|
|
if (ORTE_SUCCESS != ret) {
|
|
|
|
ORTE_ERROR_LOG(ret);
|
2005-08-24 19:15:11 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* All done */
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2007-01-24 14:45:42 +00:00
|
|
|
* Parse a single range in a set and add the full names of the nodes
|
|
|
|
* found to the names argv
|
|
|
|
*
|
|
|
|
* @param base The base text of the node name
|
|
|
|
* @param *ranges A pointer to a single range. (i.e. "1-3" or "5")
|
|
|
|
* @param ***names An argv array to add the newly discovered nodes to
|
2005-08-24 19:15:11 +00:00
|
|
|
*/
|
2006-10-19 23:33:51 +00:00
|
|
|
static int orte_ras_slurm_parse_range(char *base, char *range, char ***names)
|
2005-08-24 19:15:11 +00:00
|
|
|
{
|
2007-03-29 00:50:56 +00:00
|
|
|
char *str, temp1[BUFSIZ];
|
2005-08-24 19:15:11 +00:00
|
|
|
size_t i, j, start, end;
|
2007-03-29 00:50:56 +00:00
|
|
|
size_t base_len, len, num_len;
|
2005-08-24 19:15:11 +00:00
|
|
|
size_t str_start, str_end;
|
|
|
|
size_t num_str_len;
|
|
|
|
bool found;
|
2007-01-24 14:45:42 +00:00
|
|
|
int ret;
|
2005-08-24 19:15:11 +00:00
|
|
|
|
|
|
|
len = strlen(range);
|
|
|
|
base_len = strlen(base);
|
2005-09-02 10:27:23 +00:00
|
|
|
/* Silence compiler warnings; start and end are always assigned
|
|
|
|
properly, below */
|
2005-09-02 10:26:41 +00:00
|
|
|
start = end = 0;
|
2005-08-24 19:15:11 +00:00
|
|
|
|
|
|
|
/* Look for the beginning of the first number */
|
|
|
|
|
|
|
|
for (found = false, i = 0; i < len; ++i) {
|
|
|
|
if (isdigit((int) range[i])) {
|
|
|
|
if (!found) {
|
|
|
|
str_start = i;
|
|
|
|
start = atoi(range + i);
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) {
|
2007-01-24 14:45:42 +00:00
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
|
2005-08-24 19:15:11 +00:00
|
|
|
return ORTE_ERR_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Look for the end of the first number */
|
|
|
|
|
|
|
|
for (found = false, num_str_len = 0; i < len; ++i, ++num_str_len) {
|
|
|
|
if (!isdigit((int) range[i])) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Was there no range, just a single number? */
|
|
|
|
|
|
|
|
if (i >= len) {
|
|
|
|
str_end = len;
|
|
|
|
end = start;
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Nope, there was a range. Look for the beginning of the second
|
|
|
|
number */
|
|
|
|
|
|
|
|
else {
|
|
|
|
str_end = i - 1;
|
|
|
|
for (; i < len; ++i) {
|
|
|
|
if (isdigit((int) range[i])) {
|
|
|
|
end = atoi(range + i);
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) {
|
2007-01-24 14:45:42 +00:00
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
|
2005-08-24 19:15:11 +00:00
|
|
|
return ORTE_ERR_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make strings for all values in the range */
|
|
|
|
|
2007-03-29 00:50:56 +00:00
|
|
|
len = base_len + num_str_len + 32;
|
|
|
|
str = malloc(len);
|
|
|
|
if (NULL == str) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
strcpy(str, base);
|
2005-08-24 19:15:11 +00:00
|
|
|
for (i = start; i <= end; ++i) {
|
2007-03-29 00:50:56 +00:00
|
|
|
str[base_len] = '\0';
|
|
|
|
snprintf(temp1, BUFSIZ - 1, "%lu", (long) i);
|
2005-08-24 19:15:11 +00:00
|
|
|
|
|
|
|
/* Do we need zero pading? */
|
|
|
|
|
2007-03-29 00:50:56 +00:00
|
|
|
if ((num_len = strlen(temp1)) < num_str_len) {
|
|
|
|
for (j = base_len; j < base_len + (num_str_len - num_len); ++j) {
|
|
|
|
str[j] = '0';
|
2005-08-24 19:15:11 +00:00
|
|
|
}
|
2007-03-29 00:50:56 +00:00
|
|
|
str[j] = '\0';
|
2005-08-24 19:15:11 +00:00
|
|
|
}
|
2007-03-29 00:50:56 +00:00
|
|
|
strcat(str, temp1);
|
2007-01-24 14:45:42 +00:00
|
|
|
ret = opal_argv_append_nosize(names, str);
|
|
|
|
if(ORTE_SUCCESS != ret) {
|
|
|
|
ORTE_ERROR_LOG(ret);
|
2007-03-29 00:50:56 +00:00
|
|
|
free(str);
|
2007-01-24 14:45:42 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2005-08-24 19:15:11 +00:00
|
|
|
}
|
2007-03-29 00:50:56 +00:00
|
|
|
free(str);
|
2005-08-24 19:15:11 +00:00
|
|
|
|
|
|
|
/* All done */
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
2007-01-24 14:45:42 +00:00
|
|
|
|