2008-04-02 00:03:49 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2006 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$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "orte_config.h"
|
|
|
|
#include "orte/constants.h"
|
|
|
|
#include "orte/types.h"
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif /* HAVE_UNISTD_H */
|
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
#include <string.h>
|
|
|
|
#endif /* HAVE_STRING_H */
|
|
|
|
|
|
|
|
#include "opal/mca/base/mca_base_param.h"
|
2008-07-25 17:35:12 +04:00
|
|
|
#include "opal/util/if.h"
|
2008-04-02 00:03:49 +04:00
|
|
|
|
2008-06-09 18:53:58 +04:00
|
|
|
#include "orte/util/show_help.h"
|
2008-04-02 00:03:49 +04:00
|
|
|
#include "orte/mca/errmgr/errmgr.h"
|
2008-04-17 17:50:59 +04:00
|
|
|
#include "orte/util/hostfile/hostfile.h"
|
|
|
|
#include "orte/util/name_fns.h"
|
|
|
|
#include "orte/runtime/orte_globals.h"
|
2008-04-02 00:03:49 +04:00
|
|
|
|
|
|
|
#include "orte/mca/rmaps/base/rmaps_private.h"
|
|
|
|
#include "orte/mca/rmaps/base/base.h"
|
|
|
|
#include "rmaps_seq.h"
|
|
|
|
|
2008-04-17 17:50:59 +04:00
|
|
|
static int orte_rmaps_seq_map(orte_job_t *jdata);
|
|
|
|
|
|
|
|
/* define the module */
|
|
|
|
orte_rmaps_base_module_t orte_rmaps_seq_module = {
|
|
|
|
orte_rmaps_seq_map
|
|
|
|
};
|
2008-04-02 00:03:49 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sequentially map the ranks according to the placement in the
|
|
|
|
* specified hostfile
|
|
|
|
*/
|
|
|
|
static int orte_rmaps_seq_map(orte_job_t *jdata)
|
|
|
|
{
|
|
|
|
orte_job_map_t *map;
|
2009-06-12 21:52:17 +04:00
|
|
|
orte_app_context_t *app;
|
2008-04-17 17:50:59 +04:00
|
|
|
orte_std_cntr_t i, j;
|
2009-08-11 06:51:27 +04:00
|
|
|
opal_list_item_t *item;
|
2009-08-26 05:56:11 +04:00
|
|
|
orte_node_t *node, *nd, *save=NULL;
|
2008-04-17 17:50:59 +04:00
|
|
|
orte_vpid_t vpid;
|
|
|
|
orte_std_cntr_t num_nodes;
|
2008-04-02 00:03:49 +04:00
|
|
|
int rc;
|
2008-04-17 17:50:59 +04:00
|
|
|
opal_list_t *default_node_list=NULL;
|
|
|
|
opal_list_t *node_list=NULL;
|
2009-08-11 06:51:27 +04:00
|
|
|
orte_proc_t *proc;
|
|
|
|
|
2008-06-09 18:53:58 +04:00
|
|
|
OPAL_OUTPUT_VERBOSE((1, orte_rmaps_base.rmaps_output,
|
2008-04-17 17:50:59 +04:00
|
|
|
"%s rmaps:seq mapping job %s",
|
2009-03-06 00:50:47 +03:00
|
|
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
|
|
|
ORTE_JOBID_PRINT(jdata->jobid)));
|
2008-04-02 00:03:49 +04:00
|
|
|
|
|
|
|
/* conveniece def */
|
|
|
|
map = jdata->map;
|
2008-04-17 17:50:59 +04:00
|
|
|
|
|
|
|
/* if there is a default hostfile, go and get its ordered list of nodes */
|
|
|
|
if (NULL != orte_default_hostfile) {
|
|
|
|
default_node_list = OBJ_NEW(opal_list_t);
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_util_get_ordered_host_list(default_node_list, orte_default_hostfile))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
}
|
2008-04-02 00:03:49 +04:00
|
|
|
|
|
|
|
/* start at the beginning... */
|
2008-04-17 17:50:59 +04:00
|
|
|
vpid = 0;
|
2009-05-16 08:15:55 +04:00
|
|
|
jdata->num_procs = 0;
|
2009-08-11 06:51:27 +04:00
|
|
|
if (NULL != default_node_list) {
|
|
|
|
save = (orte_node_t*)opal_list_get_first(default_node_list);
|
|
|
|
}
|
2008-04-17 17:50:59 +04:00
|
|
|
|
2008-04-02 00:03:49 +04:00
|
|
|
/* cycle through the app_contexts, mapping them sequentially */
|
|
|
|
for(i=0; i < jdata->num_apps; i++) {
|
2009-06-12 21:52:17 +04:00
|
|
|
if (NULL == (app = (orte_app_context_t*)opal_pointer_array_get_item(jdata->apps, i))) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-04-17 17:50:59 +04:00
|
|
|
/* for each app_context, if a hostfile was specified, then we let it
|
|
|
|
* override what we may have obtained from the default hostfile
|
2008-04-02 00:03:49 +04:00
|
|
|
*/
|
2008-04-17 17:50:59 +04:00
|
|
|
if (NULL != app->hostfile) {
|
|
|
|
node_list = OBJ_NEW(opal_list_t);
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_util_get_ordered_host_list(node_list, app->hostfile))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
goto error;
|
|
|
|
}
|
2009-08-11 06:51:27 +04:00
|
|
|
nd = (orte_node_t*)opal_list_get_first(node_list);
|
2008-04-17 17:50:59 +04:00
|
|
|
} else {
|
|
|
|
node_list = default_node_list;
|
2009-08-11 06:51:27 +04:00
|
|
|
nd = save;
|
2008-04-02 00:03:49 +04:00
|
|
|
}
|
2008-07-25 17:35:12 +04:00
|
|
|
|
|
|
|
/* check for nolocal and remove the head node, if required */
|
2009-08-11 06:51:27 +04:00
|
|
|
if (map->policy & ORTE_MAPPING_NO_USE_LOCAL) {
|
2008-07-25 17:35:12 +04:00
|
|
|
for (item = opal_list_get_first(node_list);
|
|
|
|
item != opal_list_get_end(node_list);
|
|
|
|
item = opal_list_get_next(item) ) {
|
|
|
|
node = (orte_node_t*)item;
|
|
|
|
/* need to check ifislocal because the name in the
|
|
|
|
* hostfile may not have been FQDN, while name returned
|
|
|
|
* by gethostname may have been (or vice versa)
|
|
|
|
*/
|
2008-07-28 19:10:40 +04:00
|
|
|
if (opal_ifislocal(node->name)) {
|
2008-07-25 17:35:12 +04:00
|
|
|
opal_list_remove_item(node_list, item);
|
|
|
|
OBJ_RELEASE(item); /* "un-retain" it */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-17 17:50:59 +04:00
|
|
|
if (NULL == node_list || 0 == (num_nodes = (orte_std_cntr_t)opal_list_get_size(node_list))) {
|
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-14 00:00:55 +04:00
|
|
|
orte_show_help("help-orte-rmaps-base.txt",
|
2008-04-17 17:50:59 +04:00
|
|
|
"orte-rmaps-base:no-available-resources",
|
|
|
|
true);
|
|
|
|
return ORTE_ERR_SILENT;
|
2008-04-02 00:03:49 +04:00
|
|
|
}
|
|
|
|
|
2008-04-17 17:50:59 +04:00
|
|
|
/* if num_procs wasn't specified, set it now */
|
|
|
|
if (0 == app->num_procs) {
|
|
|
|
app->num_procs = num_nodes;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i < app->num_procs; i++) {
|
|
|
|
/* find this node on the global array - this is necessary so
|
|
|
|
* that our mapping gets saved on that array as the objects
|
|
|
|
* returned by the hostfile function are -not- on the array
|
|
|
|
*/
|
|
|
|
node = NULL;
|
|
|
|
for (j=0; j < orte_node_pool->size; j++) {
|
2009-06-12 21:52:17 +04:00
|
|
|
if (NULL == (node = (orte_node_t*)opal_pointer_array_get_item(orte_node_pool, j))) {
|
|
|
|
continue;
|
2008-04-17 17:50:59 +04:00
|
|
|
}
|
2009-06-12 21:52:17 +04:00
|
|
|
if (0 == strcmp(nd->name, node->name)) {
|
2008-04-17 17:50:59 +04:00
|
|
|
break;
|
|
|
|
}
|
2008-04-02 00:03:49 +04:00
|
|
|
}
|
2008-04-17 17:50:59 +04:00
|
|
|
if (NULL == node) {
|
|
|
|
/* wasn't found - that is an error */
|
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-14 00:00:55 +04:00
|
|
|
orte_show_help("help-orte-rmaps-seq.txt",
|
2008-04-17 17:50:59 +04:00
|
|
|
"orte-rmaps-seq:resource-not-found",
|
2008-04-17 18:43:15 +04:00
|
|
|
true, nd->name);
|
2008-04-02 00:03:49 +04:00
|
|
|
rc = ORTE_ERR_SILENT;
|
|
|
|
goto error;
|
|
|
|
}
|
2008-04-17 17:50:59 +04:00
|
|
|
|
2009-08-11 06:51:27 +04:00
|
|
|
/* assign proc to this node - do NOT allow claim_slot to remove
|
2008-04-17 17:50:59 +04:00
|
|
|
* an oversubscribed node from the list!
|
|
|
|
*/
|
2009-09-17 09:18:37 +04:00
|
|
|
proc = NULL;
|
2008-04-17 17:50:59 +04:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_rmaps_base_claim_slot(jdata, node,
|
2009-08-11 06:51:27 +04:00
|
|
|
jdata->map->cpus_per_rank, app->idx,
|
2008-04-17 17:50:59 +04:00
|
|
|
node_list,
|
|
|
|
jdata->map->oversubscribe,
|
2009-08-11 06:51:27 +04:00
|
|
|
false, &proc))) {
|
2008-04-17 17:50:59 +04:00
|
|
|
if (ORTE_ERR_NODE_FULLY_USED != rc) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
}
|
2009-08-11 06:51:27 +04:00
|
|
|
/* assign the vpid */
|
|
|
|
proc->name.vpid = vpid++;
|
|
|
|
/* add to the jdata proc array */
|
|
|
|
if (ORTE_SUCCESS != (rc = opal_pointer_array_set_item(jdata->procs, proc->name.vpid, proc))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
goto error;
|
|
|
|
}
|
2008-04-17 17:50:59 +04:00
|
|
|
/* move to next node */
|
2009-08-11 06:51:27 +04:00
|
|
|
nd = (orte_node_t*)opal_list_get_next((opal_list_item_t*)nd);
|
2008-04-02 00:03:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** track the total number of processes we mapped */
|
|
|
|
jdata->num_procs += app->num_procs;
|
|
|
|
|
2008-04-17 17:50:59 +04:00
|
|
|
/* cleanup the node list if it came from this app_context */
|
|
|
|
if (node_list != default_node_list) {
|
2009-08-11 06:51:27 +04:00
|
|
|
while (NULL != (item = opal_list_remove_first(node_list))) {
|
2008-04-17 17:50:59 +04:00
|
|
|
OBJ_RELEASE(item);
|
|
|
|
}
|
|
|
|
OBJ_RELEASE(node_list);
|
2009-08-11 06:51:27 +04:00
|
|
|
} else {
|
|
|
|
save = nd;
|
2008-04-02 00:03:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-11 06:51:27 +04:00
|
|
|
/* compute and save local ranks */
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_rmaps_base_compute_local_ranks(jdata))) {
|
2008-04-02 00:03:49 +04:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* define the daemons that we will use for this job */
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_rmaps_base_define_daemons(map))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
|
2008-04-17 17:50:59 +04:00
|
|
|
error:
|
|
|
|
if (NULL != default_node_list) {
|
|
|
|
while (NULL != (item = opal_list_remove_first(default_node_list))) {
|
|
|
|
OBJ_RELEASE(item);
|
2008-04-02 00:03:49 +04:00
|
|
|
}
|
2008-04-17 17:50:59 +04:00
|
|
|
OBJ_RELEASE(default_node_list);
|
2008-04-02 00:03:49 +04:00
|
|
|
}
|
2008-04-17 17:50:59 +04:00
|
|
|
if (NULL != node_list) {
|
|
|
|
while (NULL != (item = opal_list_remove_first(node_list))) {
|
|
|
|
OBJ_RELEASE(item);
|
|
|
|
}
|
|
|
|
OBJ_RELEASE(node_list);
|
2008-04-02 00:03:49 +04:00
|
|
|
}
|
2008-04-17 17:50:59 +04:00
|
|
|
|
2008-04-02 00:03:49 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|