1
1

Improvements in bproc support:

- we now properly support multiple application contexts
 - much improved error messages, using opal_show_help
 - fix some small bugs in the way the processes were discovering their names
 - better searching for orted
 - use the new mca parameter interface

These changes still need some testing, but they seem stable.

This commit was SVN r6719.
Этот коммит содержится в:
Tim Prins 2005-08-02 22:22:55 +00:00
родитель 44ae604451
Коммит aa0525da98
10 изменённых файлов: 427 добавлений и 274 удалений

Просмотреть файл

@ -16,7 +16,10 @@
include $(top_ompi_srcdir)/config/Makefile.options
AM_CPPFLAGS = -I$(top_ompi_builddir)/src/include $(pls_bproc_CPPFLAGS)
EXTRA_DIST = $(pkgdata_DATA)
pkgdata_DATA = help-pls-bproc.txt
AM_CPPFLAGS = -I$(top_ompi_builddir)/src/include $(pls_bproc_CPPFLAGS) -DORTE_BINDIR="\"$(bindir)\""
# Make the output library in this directory, and name it either
# mca_<type>_<name>.la (for DSO builds) or libmca_<type>_<name>.la

87
orte/mca/pls/bproc/help-pls-bproc.txt Обычный файл
Просмотреть файл

@ -0,0 +1,87 @@
# -*- text -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University.
# All rights reserved.
# Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
# 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$
#
# Additional copyrights may follow
#
# $HEADER$
#
# This is the US/English general help file for Open RTE's orterun.
#
[bproc-vexecmove-launch]
The bproc PLS component was not able to launch %s on node %d and therefore
cannot continue. Errno was set to %d.
[bproc-vexecmove-fork]
The bproc PLS component was not able to fork and therefore cannot continue.
Errno was set to %d.
[no-orted]
The bproc PLS component was not able to find the executable "%s" in the
current directory, your PATH, or in the directory where Open MPI was
initially installed, and therefore cannot continue.
For reference, we looked for
%s
Your current PATH is:
%s
We also looked for orted in the following directory:
%s
You may need to set your PATH properly, or set the MCA parameter
pls_bproc_orted to be the path to "orted".
[daemon-launch-number]
The bproc PLS component was not able to launch all the daemons on the remote
nodes and therefore cannot continue.
We attempted to launch %d daemons but only %d were actually launched.
For reference, we tried to launch %s
[daemon-launch-bad-pid]
The bproc PLS component was not able to launch all the daemons on the remote
nodes and therefore cannot continue.
On node %d the daemon pid was %d and errno was set to %d.
For reference, we tried to launch %s
[daemon-died-no-signal]
A daemon (pid %d) launched by the bproc PLS component on node %d died
unexpectedly so we are aborting.
This may be because the daemon was unable to find all the needed shared
libraries on the remote node. You may set your LD_LIBRARY_PATH to have the
location of the shared libraries on the remote nodes and this will
automatically be forwarded to the remote nodes.
[daemon-died-signal]
A daemon (pid %d) launched by the bproc PLS component on node %d died
unexpectedly on signal %d so we are aborting.
This may be because the daemon was unable to find all the needed shared
libraries on the remote node. You may set your LD_LIBRARY_PATH to have the
location of the shared libraries on the remote nodes and this will
automatically be forwarded to the remote nodes.
[proc-launch-number]
The bproc PLS component was not able to launch all the processes on the remote
nodes and therefore cannot continue.
We attempted to launch %d processes but only %d were actually launched.
For reference, we tried to launch %s
[proc-launch-bad-pid]
The bproc PLS component was not able to launch all the processes on the remote
nodes and therefore cannot continue.
On node %d the process pid was %d and errno was set to %d.
For reference, we tried to launch %s

Просмотреть файл

@ -31,6 +31,7 @@
#include "opal/util/output.h"
#include "opal/util/opal_environ.h"
#include "opal/util/path.h"
#include "opal/util/show_help.h"
#include "opal/util/sys_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/iof/iof.h"
@ -62,11 +63,7 @@ static int orte_pls_bproc_node_list(int * node_array, int node_array_len,
int ** node_list, int * num_nodes,
int num_procs);
static int orte_pls_bproc_setup_io(orte_jobid_t jobid, struct bproc_io_t * io,
int node_rank, size_t app_context);
static int orte_pls_bproc_launch_app(orte_cellid_t cellid, orte_jobid_t jobid,
orte_rmaps_base_map_t* map,
orte_vpid_t vpid_start,
orte_vpid_t vpid_range, size_t app_context);
int node_rank, int app_context);
static void orte_pls_bproc_waitpid_cb(pid_t wpid, int status, void *data);
static void orte_pls_bproc_waitpid_daemon_cb(pid_t wpid, int status, void *data);
#ifdef MCA_pls_bproc_scyld
@ -77,6 +74,18 @@ static int bproc_vexecmove_io(int nnodes, int *nodes, int *pids,
static int bproc_vexecmove(int nnodes, int *nodes, int *pids, const char *cmd,
char * const argv[], char * envp[]);
#endif
static void orte_pls_bproc_setup_env(char *** env, size_t * num_env);
static int orte_pls_bproc_launch_daemons(orte_cellid_t cellid, char *** envp,
int ** node_arrays, int * node_array_lens,
int num_contexts, int num_procs,
orte_vpid_t global_vpid_start,
orte_jobid_t jobid);
static int orte_pls_bproc_launch_app(orte_cellid_t cellid, orte_jobid_t jobid,
orte_rmaps_base_map_t* map, int num_processes,
orte_vpid_t vpid_start,
orte_vpid_t global_vpid_start,
int app_context,
int * node_array, int node_array_len);
/**
* creates an array that is indexed by the node number and each entry contains the
@ -158,9 +167,12 @@ static int orte_pls_bproc_node_list(int * node_array, int node_array_len,
* @param jobid
* @param io A pointer to an array of 3 bproc_io_t structs
* @param node_rank the rank on the node we are setting up the structs for
* @param app_context the application context number
* @retval ORTE_SUCCESS
* @retval error
*/
static int orte_pls_bproc_setup_io(orte_jobid_t jobid, struct bproc_io_t * io,
int node_rank, size_t app_context) {
int node_rank, int app_context) {
char *frontend = NULL, *path = NULL, *job = NULL;
int rc, i;
@ -183,7 +195,7 @@ static int orte_pls_bproc_setup_io(orte_jobid_t jobid, struct bproc_io_t * io,
orte_system_info.path_sep, orte_system_info.path_sep,
orte_system_info.user, orte_system_info.path_sep,
orte_universe_info.name, orte_system_info.path_sep, job,
(int) app_context, orte_system_info.path_sep, node_rank)) {
app_context, orte_system_info.path_sep, node_rank)) {
rc = ORTE_ERR_OUT_OF_RESOURCE;
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
goto cleanup;
@ -228,7 +240,11 @@ static int orte_pls_bproc_setup_io(orte_jobid_t jobid, struct bproc_io_t * io,
/**
* Callback for orte_wait_cb. This function decrements the number of currently
* running processes, and when this hits 0 it kills all the daemons */
* running processes, and when this hits 0 it kills all the daemons
* @param wpid the process's pid
* @param status tells why the process died
* @param data a pointer to the process's name
*/
static void orte_pls_bproc_waitpid_cb(pid_t wpid, int status, void *data) {
orte_process_name_t * proc = (orte_process_name_t*) data;
int rc;
@ -284,7 +300,11 @@ static void orte_pls_bproc_waitpid_cb(pid_t wpid, int status, void *data) {
/**
* Callback for orte_wait_cb for the daemons. If a daemon unexpectedly dies
* before we are done launching, we abort the job. */
* before we are done launching, we abort the job.
* @param wpid the daemons's pid
* @param status tells why the daemon died
* @param data a pointer to the node the daemon was on
*/
static void orte_pls_bproc_waitpid_daemon_cb(pid_t wpid, int status, void *data) {
if(!mca_pls_bproc_component.done_launching) {
/* if a daemon exits before we are done launching the user apps we send a
@ -320,7 +340,10 @@ static void orte_pls_bproc_waitpid_daemon_cb(pid_t wpid, int status, void *data)
}
#ifdef MCA_pls_bproc_scyld
/* compatibility functions for scyld bproc and pre 3.2.0 LANL bproc */
/**
* compatibility functions for scyld bproc and pre 3.2.0 LANL bproc. See the
* bproc documentation for details
*/
static int bproc_vexecmove_io(int nnodes, int *nodes, int *pids,
struct bproc_io_t *io, int iolen, const char *cmd,
char * const argv[], char * envp[]) {
@ -337,11 +360,13 @@ static int bproc_vexecmove_io(int nnodes, int *nodes, int *pids,
opal_setenv("BPROC_RANK", rank, true, &envp);
bproc_execmove_io(nodes[i], io, iolen, cmd, argv, envp);
/* if we get here, there was an error */
opal_output(0, "Error launching %s on node %d\n", cmd, nodes[i]);
opal_show_help("help-pls-bproc.txt", "bproc-vexecmove-launch", true,
cmd, nodes[i], errno);
ORTE_ERROR_LOG(ORTE_ERROR);
exit(-1);
} else if(-1 == pids[i]) {
opal_output(0, "Error launching processes: could not fork\n");
opal_show_help("help-pls-bproc.txt", "bproc-vexecmove-fork", true,
errno);
ORTE_ERROR_LOG(ORTE_ERROR);
return -1;
}
@ -354,122 +379,56 @@ static int bproc_vexecmove(int nnodes, int *nodes, int *pids, const char *cmd,
return bproc_vexecmove_io(nnodes, nodes, pids, NULL, 0, cmd, argv, envp);
}
#endif
/**
* 1. Launch the deamons on the backend nodes.
* 2. The daemons setup files for io forwarding then connect back to us to
* tells us they are ready for the actual apps.
* 3. Launch the apps on the backend nodes
* Sets up the passed environment for processes launched by the bproc launcher.
* @param evn a pointer to the environment to setup
* @param num_env a pointer to where the size f the environment is stored
*/
static int orte_pls_bproc_launch_app(orte_cellid_t cellid, orte_jobid_t jobid,
orte_rmaps_base_map_t* map,
orte_vpid_t vpid_start,
orte_vpid_t vpid_range, size_t app_context) {
int * node_list = NULL;
int * node_array = NULL;
int node_array_len;
int num_nodes;
int num_processes = 0;
int num_daemons;
int rc, i, j;
int * pids = NULL;
int argc;
int src[4];
char ** argv = NULL;
char * var, * param;
char * orted_path;
orte_buffer_t ack;
orte_jobid_t daemon_jobid;
orte_process_name_t * proc_name;
orte_vpid_t daemon_vpid_start = 0;
orte_vpid_t global_vpid_start = vpid_start;
size_t idx;
struct stat buf;
struct bproc_io_t bproc_io[3];
OBJ_CONSTRUCT(&ack, orte_buffer_t);
/* convert node names to a node array */
num_processes = orte_pls_bproc_node_array(map, &node_array, &node_array_len);
if(0 > num_processes) {
ORTE_ERROR_LOG(rc);
goto cleanup;
}
/* create a list of all the nodes that need daemons, which is all the nodes
* that will have at least 1 process */
rc = orte_pls_bproc_node_list(node_array, node_array_len, &node_list,
&num_daemons, 1);
if(ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
goto cleanup;
}
if(NULL == (pids = (int*)malloc(sizeof(int) * num_daemons))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
goto cleanup;
}
static void orte_pls_bproc_setup_env(char *** env, size_t * num_env) {
char * var;
char * param;
int rc;
/* append mca parameters to our environment */
i = map->app->num_env;
if(ORTE_SUCCESS != (rc = mca_base_param_build_env(&map->app->env, &i, true))) {
if(ORTE_SUCCESS != (rc = mca_base_param_build_env(env, (int*)num_env, true))) {
ORTE_ERROR_LOG(rc);
goto cleanup;
}
/* set name discovery mode */
var = mca_base_param_environ_variable("ns","nds",NULL);
opal_setenv(var, "bproc", true, &map->app->env);
free(var);
/* ns replica contact info */
if(NULL == orte_process_info.ns_replica) {
rc = orte_ns.copy_process_name(&orte_process_info.ns_replica,
orte_ns.copy_process_name(&orte_process_info.ns_replica,
orte_process_info.my_name);
if(ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
goto cleanup;
}
orte_process_info.ns_replica_uri = orte_rml.get_uri();
}
var = mca_base_param_environ_variable("ns","replica","uri");
opal_setenv(var,orte_process_info.ns_replica_uri, true, &map->app->env);
opal_setenv(var,orte_process_info.ns_replica_uri, true, env);
free(var);
/* make sure the frontend hostname does not get pushed out to the backend */
var = mca_base_param_environ_variable("orte", "base", "nodename");
opal_unsetenv(var, &map->app->env);
opal_unsetenv(var, env);
free(var);
opal_unsetenv("HOSTNAME", &map->app->env);
opal_unsetenv("HOSTNAME", env);
/* make sure the username used to create the bproc directory is the same on
* the backend as the frontend */
var = mca_base_param_environ_variable("pls","bproc","username");
opal_setenv(var, orte_system_info.user, true, &map->app->env);
opal_setenv(var, orte_system_info.user, true, env);
free(var);
/* tell the bootproxy to use the bproc_orted pls */
var = mca_base_param_environ_variable("rmgr", "bootproxy", "pls");
opal_setenv(var, "bproc_orted", true, &map->app->env);
opal_setenv(var, "bproc_orted", true, env);
free(var);
/* gpr replica contact info */
if(NULL == orte_process_info.gpr_replica) {
rc = orte_ns.copy_process_name(&orte_process_info.gpr_replica,
orte_ns.copy_process_name(&orte_process_info.gpr_replica,
orte_process_info.my_name);
if(ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
goto cleanup;
}
orte_process_info.gpr_replica_uri = orte_rml.get_uri();
}
var = mca_base_param_environ_variable("gpr","replica","uri");
opal_setenv(var,orte_process_info.gpr_replica_uri, true, &map->app->env);
free(var);
asprintf(&param, "%d", (int) app_context);
var = mca_base_param_environ_variable("pls", "bproc", "app_context");
opal_setenv(var, param, true, &map->app->env);
free(param);
opal_setenv(var,orte_process_info.gpr_replica_uri, true, env);
free(var);
/* because this is bproc, we the user might have had to place some libraries
@ -477,11 +436,69 @@ static int orte_pls_bproc_launch_app(orte_cellid_t cellid, orte_jobid_t jobid,
* send along their LD_LIBRARY_PATH */
param = getenv("LD_LIBRARY_PATH");
if(NULL != param) {
opal_setenv("LD_LIBRARY_PATH", param, true, &map->app->env);
opal_setenv("LD_LIBRARY_PATH", param, true, env);
}
/* overwrite previously specified values with the above settings */
map->app->num_env = opal_argv_count(map->app->env);
*num_env = opal_argv_count(*env);
}
/**
* Launches the daemons
* @param cellid the cellid of the job
* @param envp a pointer to the environment to use for the daemons
* @param node_arrays an array that holds the node arrays for each app context
* @param node_array_lens an array of lengths of the node arrays
* @param num_contexts the number of application contexts
* @param global_vpid_start the starting vpid for the user's processes
* @param jobid the jobid for the user processes
* @retval ORTE_SUCCESS
* @retval error
*/
static int orte_pls_bproc_launch_daemons(orte_cellid_t cellid, char *** envp,
int ** node_arrays, int * node_array_lens,
int num_contexts, int num_procs,
orte_vpid_t global_vpid_start,
orte_jobid_t jobid) {
int * daemon_list = NULL;
int num_nodes = 0;
int num_daemons = 0;
int rc, i, j;
int * pids = NULL;
int argc;
char ** argv = NULL;
char * param;
char * orted_path;
orte_jobid_t daemon_jobid;
orte_process_name_t * proc_name;
orte_vpid_t daemon_vpid_start = 0;
size_t idx;
struct stat buf;
/* find the length of the longest node array */
for(i = 0; i < num_contexts; i++) {
if(node_array_lens[i] > num_nodes) {
num_nodes = node_array_lens[i];
}
}
if(NULL == (daemon_list = (int*)malloc(sizeof(int) * num_nodes))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
goto cleanup;
}
/* create a list of all the nodes that need daemons, which is all the nodes
* that will have at least 1 process */
for(i = 0; i < num_nodes; i++) {
for(j = 0; j < num_contexts; j++) {
if(i < node_array_lens[j] && 0 < *(node_arrays[j] + i)) {
daemon_list[num_daemons++] = i;
break;
}
}
}
if(NULL == (pids = (int*)malloc(sizeof(int) * num_daemons))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
goto cleanup;
}
/* allocate a range of vpids for the daemons */
rc = orte_ns_base_get_jobid(&daemon_jobid, orte_process_info.my_name);
@ -497,7 +514,7 @@ static int orte_pls_bproc_launch_app(orte_cellid_t cellid, orte_jobid_t jobid,
/* set up the environment so the daemons can get their names once launched */
rc = orte_ns_nds_bproc_put(cellid, daemon_jobid, daemon_vpid_start,
global_vpid_start, num_processes, &map->app->env);
global_vpid_start, num_procs, envp);
if(ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
goto cleanup;
@ -532,10 +549,20 @@ static int orte_pls_bproc_launch_app(orte_cellid_t cellid, orte_jobid_t jobid,
} else {
orted_path = opal_path_findv(mca_pls_bproc_component.orted, 0, environ, NULL);
if(NULL == orted_path) {
opal_output(0, "pls_bproc: Unable to find orted\n");
rc = ORTE_ERROR;
ORTE_ERROR_LOG(rc);
goto cleanup;
asprintf(&orted_path, "%s/%s", ORTE_BINDIR,
mca_pls_bproc_component.orted);
if (0 != stat(orted_path, &buf)) {
char *path = getenv("PATH");
if (NULL == path) {
path = ("PATH is empty!");
}
opal_show_help("help-pls-bproc.txt", "no-orted", true,
mca_pls_bproc_component.orted,
mca_pls_bproc_component.orted, path, ORTE_BINDIR);
rc = ORTE_ERROR;
ORTE_ERROR_LOG(rc);
goto cleanup;
}
}
}
@ -545,10 +572,10 @@ static int orte_pls_bproc_launch_app(orte_cellid_t cellid, orte_jobid_t jobid,
}
/* launch the daemons */
rc = bproc_vexecmove(num_daemons, node_list, pids, orted_path, argv,
map->app->env);
rc = bproc_vexecmove(num_daemons, daemon_list, pids, orted_path, argv, *envp);
if(rc != num_daemons) {
opal_output(0, "Failed to launch proper number of daemons.");
opal_show_help("help-pls-bproc.txt", "daemon-launch-number", true,
num_daemons, rc, orted_path);
rc = ORTE_ERROR;
goto cleanup;
}
@ -559,11 +586,8 @@ static int orte_pls_bproc_launch_app(orte_cellid_t cellid, orte_jobid_t jobid,
for(i = 0; i < num_daemons; i++) {
if(0 >= pids[i]) {
opal_output(0, "pls_bproc: failed to launch all daemons. "
"Daemon pid was %d on node %d and errno %d\n"
"You may need to set the pls_bproc_orted paramater to "
"point to where orted is installed",
pids[i], node_list[i], errno);
opal_show_help("help-pls-bproc.txt", "daemon-launch-bad-pid", true,
daemon_list[i], pids[i], errno, orted_path);
rc = ORTE_ERROR;
ORTE_ERROR_LOG(rc);
goto cleanup;
@ -580,53 +604,68 @@ static int orte_pls_bproc_launch_app(orte_cellid_t cellid, orte_jobid_t jobid,
ORTE_ERROR_LOG(rc);
goto cleanup;
}
if (0 > asprintf(&var, "%d", node_list[i])) {
if (0 > asprintf(&param, "%d", daemon_list[i])) {
rc = ORTE_ERR_OUT_OF_RESOURCE;
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
goto cleanup;
}
rc = orte_pls_base_set_node_pid(cellid, var, daemon_jobid, pids[i]);
rc = orte_pls_base_set_node_pid(cellid, param, jobid, pids[i]);
if(ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
goto cleanup;
}
free(var);
free(param);
rc = orte_wait_cb(pids[i], orte_pls_bproc_waitpid_daemon_cb,
&node_list[i]);
&daemon_list[i]);
if(ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
goto cleanup;
}
}
}
mca_pls_bproc_component.num_daemons += num_daemons;
mca_pls_bproc_component.num_daemons = num_daemons;
/* wait for communication back */
for(i = 0; i < num_daemons; i++) {
rc = mca_oob_recv_packed(MCA_OOB_NAME_ANY, &ack, MCA_OOB_TAG_BPROC);
if(0 > rc) {
ORTE_ERROR_LOG(rc);
goto cleanup;
}
idx = 4;
rc = orte_dps.unpack(&ack, &src, &idx, ORTE_INT);
if(ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
}
if(-1 == src[0]) {
if(-1 == src[1]) {
opal_output(0, "pls_bproc: daemon pid %d exited unexpectedly on "
"node %d\n",src[2], src[3]);
} else {
opal_output(0, "pls_bproc: daemon pid %d exited unexpectedly on "
"node %d on signal %d\n",src[2], src[3], src[1]);
}
rc = ORTE_ERROR;
ORTE_ERROR_LOG(rc);
orte_pls_bproc_terminate_job(daemon_jobid);
goto cleanup;
}
cleanup:
if(NULL != argv) {
opal_argv_free(argv);
}
if(NULL != pids) {
free(pids);
}
if(NULL != orted_path) {
free(orted_path);
}
return rc;
}
static int orte_pls_bproc_launch_app(orte_cellid_t cellid, orte_jobid_t jobid,
orte_rmaps_base_map_t* map, int num_processes,
orte_vpid_t vpid_start,
orte_vpid_t global_vpid_start,
int app_context, int * node_array,
int node_array_len) {
int * node_list = NULL;
int num_nodes;
int rc, i, j;
int * pids = NULL;
char * var, * param;
orte_process_name_t * proc_name;
struct bproc_io_t bproc_io[3];
if(NULL == (pids = (int*)malloc(sizeof(int) * node_array_len))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
goto cleanup;
}
/* set out app context */
asprintf(&param, "%d", app_context);
var = mca_base_param_environ_variable("pls", "bproc", "app_context");
opal_setenv(var, param, true, &map->app->env);
free(param);
free(var);
/* overwrite previously specified values with the above settings */
map->app->num_env = opal_argv_count(map->app->env);
/* launch the processes */
i = 1;
@ -660,15 +699,15 @@ static int orte_pls_bproc_launch_app(orte_cellid_t cellid, orte_jobid_t jobid,
rc, *pids);
}
if(rc != num_nodes) {
opal_output(0, "pls_bproc: Failed to launch proper number of processes.");
opal_show_help("help-pls-bproc.txt", "proc-launch-number", true,
num_nodes, rc, map->app->app);
rc = ORTE_ERROR;
goto cleanup;
}
for(j = 0; j < num_nodes; j++) {
if(0 >= pids[j]) {
opal_output(0, "pls_bproc: failed to launch all processes. Process"
" pid was %d on node %d trying to launch %s\n",
pids[j], node_list[j], map->app->app);
opal_show_help("help-pls-bproc.txt", "proc-launch-bad-pid", true,
node_list[j], pids[j], errno, map->app->app);
rc = ORTE_ERROR;
ORTE_ERROR_LOG(rc);
goto cleanup;
@ -695,11 +734,7 @@ static int orte_pls_bproc_launch_app(orte_cellid_t cellid, orte_jobid_t jobid,
free(node_list);
node_list = NULL;
i++;
rc = orte_ns.derive_vpid(&vpid_start, vpid_start, num_nodes);
if(ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
goto cleanup;
}
vpid_start += num_nodes;
rc = orte_pls_bproc_node_list(node_array, node_array_len, &node_list,
&num_nodes, i);
if(ORTE_SUCCESS != rc) {
@ -712,33 +747,36 @@ cleanup:
if(NULL != node_list) {
free(node_list);
}
if(NULL != node_array) {
free(node_array);
}
if(NULL != argv) {
opal_argv_free(argv);
}
if(NULL != pids) {
free(pids);
}
if(NULL != orted_path) {
free(orted_path);
}
OBJ_DESTRUCT(&ack);
return rc;
}
/**
* Query for the default mapping. Launch each application context
* w/ a distinct set of daemons.
* 1. Launch the deamons on the backend nodes.
* 2. The daemons setup files for io forwarding then connect back to us to
* tells us they are ready for the actual apps.
* 3. Launch the apps on the backend nodes
*/
int orte_pls_bproc_launch(orte_jobid_t jobid) {
opal_list_item_t* item;
opal_list_t mapping;
orte_buffer_t ack;
orte_cellid_t cellid;
orte_vpid_t vpid_start;
orte_rmaps_base_map_t* map;
orte_vpid_t vpid_launch;
orte_vpid_t vpid_range;
orte_vpid_t vpid_start;
int rc;
int src[4];
int ** node_array;
int * node_array_len;
int num_processes = 0;
int context = 0;
size_t idx, j;
OBJ_CONSTRUCT(&ack, orte_buffer_t);
/* query for the application context and allocated nodes */
OBJ_CONSTRUCT(&mapping, opal_list_t);
@ -746,7 +784,7 @@ int orte_pls_bproc_launch(orte_jobid_t jobid) {
ORTE_ERROR_LOG(rc);
return rc;
}
if(ORTE_SUCCESS != (rc = orte_rmaps_base_get_vpid_range(jobid, &vpid_start,
if(ORTE_SUCCESS != (rc = orte_rmaps_base_get_vpid_range(jobid, &vpid_start,
&vpid_range))) {
ORTE_ERROR_LOG(rc);
goto cleanup;
@ -763,24 +801,86 @@ int orte_pls_bproc_launch(orte_jobid_t jobid) {
* until we are done launching */
OPAL_THREAD_LOCK(&mca_pls_bproc_component.lock);
/* for each application context - launch across the first n nodes required */
/* create an array to hold the pointers to the node arrays for each app
* context. Also, create an array to hold the lengths of the node arrays */
node_array = malloc(opal_list_get_size(&mapping) * sizeof(int *));
node_array_len = malloc(opal_list_get_size(&mapping) * sizeof(int *));
/* for each application context - create a node array and setup its env */
for(item = opal_list_get_first(&mapping);
item != opal_list_get_end(&mapping);
item = opal_list_get_next(item)) {
orte_rmaps_base_map_t* map = (orte_rmaps_base_map_t*)item;
rc = orte_pls_bproc_launch_app(cellid, jobid, map, vpid_start, vpid_range,
map->app->idx);
if(rc != ORTE_SUCCESS) {
map = (orte_rmaps_base_map_t*)item;
rc = orte_pls_bproc_node_array(map, &node_array[context],
&node_array_len[context]);
if(0 > rc) {
ORTE_ERROR_LOG(rc);
goto cleanup;
}
orte_pls_bproc_setup_env(&map->app->env, &map->app->num_env);
num_processes += rc;
context++;
}
rc = orte_pls_bproc_launch_daemons(cellid, &map->app->env, node_array,
node_array_len, context, num_processes,
vpid_start, jobid);
if(ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
goto cleanup;
}
/* wait for communication back from the daemons */
for(j = 0; j < mca_pls_bproc_component.num_daemons; j++) {
rc = mca_oob_recv_packed(MCA_OOB_NAME_ANY, &ack, MCA_OOB_TAG_BPROC);
if(0 > rc) {
ORTE_ERROR_LOG(rc);
goto cleanup;
}
idx = 4;
rc = orte_dps.unpack(&ack, &src, &idx, ORTE_INT);
if(ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
}
if(-1 == src[0]) {
if(-1 == src[1]) {
opal_show_help("help-pls-bproc.txt", "daemon-died-no-signal", true,
src[2], src[3]);
} else {
opal_show_help("help-pls-bproc.txt", "daemon-died-signal", true,
src[2], src[3], src[1]);
}
rc = ORTE_ERROR;
ORTE_ERROR_LOG(rc);
orte_pls_bproc_terminate_job(jobid);
goto cleanup;
}
}
context = 0;
vpid_launch = vpid_start;
/* for each application context launch the app */
for(item = opal_list_get_first(&mapping);
item != opal_list_get_end(&mapping);
item = opal_list_get_next(item)) {
map = (orte_rmaps_base_map_t*)item;
rc = orte_pls_bproc_launch_app(cellid, jobid, map, num_processes,
vpid_launch, vpid_start, map->app->idx,
node_array[context], node_array_len[context]);
if(ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
goto cleanup;
}
context++;
vpid_launch = vpid_start + mca_pls_bproc_component.num_procs;
}
mca_pls_bproc_component.done_launching = true;
cleanup:
OPAL_THREAD_UNLOCK(&mca_pls_bproc_component.lock);
while(NULL != (item = opal_list_remove_first(&mapping)))
OBJ_RELEASE(item);
OBJ_DESTRUCT(&mapping);
OBJ_DESTRUCT(&ack);
return rc;
}

Просмотреть файл

@ -75,9 +75,9 @@ struct orte_pls_bproc_component_t {
char * orted;
int debug;
int num_procs;
size_t num_daemons;
int priority;
int terminate_sig;
size_t num_daemons;
opal_mutex_t lock;
opal_condition_t condition;
orte_pointer_array_t * daemon_names;

Просмотреть файл

@ -43,37 +43,22 @@ orte_pls_bproc_component_t mca_pls_bproc_component = {
}
};
/**
* Convience functions to lookup MCA parameter values.
*/
static int orte_pls_bproc_param_register_int(const char* param_name,
int default_value) {
int id = mca_base_param_register_int("pls", "bproc", param_name, NULL,
default_value);
int param_value = default_value;
mca_base_param_lookup_int(id, &param_value);
return param_value;
}
static char* orte_pls_bproc_param_register_string(const char* param_name,
const char* default_value) {
char *param_value;
int id = mca_base_param_register_string("pls", "bproc", param_name, NULL,
default_value);
mca_base_param_lookup_string(id, &param_value);
return param_value;
}
int orte_pls_bproc_component_open(void) {
int rc;
/* init parameters */
mca_pls_bproc_component.debug = orte_pls_bproc_param_register_int("debug", 0);
mca_pls_bproc_component.priority =
orte_pls_bproc_param_register_int("priority", 100);
mca_pls_bproc_component.orted =
orte_pls_bproc_param_register_string("orted", "orted");
mca_pls_bproc_component.terminate_sig =
orte_pls_bproc_param_register_int("terminate_sig", 9);
mca_base_param_reg_int(&mca_pls_bproc_component.super.pls_version, "priority",
NULL, false, false, 100,
&mca_pls_bproc_component.priority);
mca_base_param_reg_int(&mca_pls_bproc_component.super.pls_version, "debug",
"If > 0 prints library debugging information",
false, false, 0, &mca_pls_bproc_component.debug);
mca_base_param_reg_int(&mca_pls_bproc_component.super.pls_version,
"terminate_sig",
"Signal sent to processes to terminate them", false,
false, 9, &mca_pls_bproc_component.terminate_sig);
mca_base_param_reg_string(&mca_pls_bproc_component.super.pls_version,
"orted", "Path to where orted is installed", false,
false, "orted", &mca_pls_bproc_component.orted);
mca_pls_bproc_component.num_procs = 0;
mca_pls_bproc_component.num_daemons = 0;

Просмотреть файл

@ -161,8 +161,7 @@ static int pls_bproc_orted_link_pty(int proc_rank, char * pty_path,
goto cleanup;
}
for(i = 0; i < 3; i++)
{
for(i = 0; i < 3; i++) {
if(0 > asprintf(&link_path, "%s%s%d", frontend,
orte_system_info.path_sep, i)) {
rc = ORTE_ERROR;
@ -230,8 +229,7 @@ static int pls_bproc_orted_link_pipes(int proc_rank, orte_jobid_t jobid, int * f
goto cleanup;
}
for(i = 0; i < 3; i++)
{
for(i = 0; i < 3; i++) {
if(0 > asprintf(&link_path, "%s%s%d", frontend,
orte_system_info.path_sep, i)) {
rc = ORTE_ERROR;
@ -369,21 +367,18 @@ int orte_pls_bproc_orted_launch(orte_jobid_t jobid) {
int master[3];
int num_procs = 0;
size_t i;
size_t app_context;
int src = 0;
orte_buffer_t ack;
char * param;
bool connect_stdin;
char * pty_name = NULL;
#if defined(HAVE_OPENPTY) && (OMPI_ENABLE_PTY_SUPPORT != 0)
int slave;
bool pty_error_thrown = false;
if (NULL == (pty_name = malloc(256))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
goto cleanup;
}
#endif
OBJ_CONSTRUCT(&ack, orte_buffer_t);
rc = bproc_currnode();
@ -404,20 +399,12 @@ int orte_pls_bproc_orted_launch(orte_jobid_t jobid) {
goto cleanup;
}
/* look up the app context number. This is necessary since the user
* can launch multiple apps on the same node, we have to have a way
* to keep them seperate */
id = mca_base_param_register_int("pls", "bproc", "app_context", NULL, 0);
mca_base_param_lookup_int(id, (int *) &app_context);
/* figure out what processes will be on this node and set up the io files */
for(item = opal_list_get_first(&map);
item != opal_list_get_end(&map);
item = opal_list_get_next(item)) {
mapping = (orte_rmaps_base_map_t *) item;
if(mapping->app->idx != app_context) {
continue;
}
num_procs = 0;
for(i = mapping->num_procs; i > 0; i--) {
proc = mapping->procs[i - 1];
if(0 < mca_pls_bproc_orted_component.debug) {
@ -439,16 +426,16 @@ int orte_pls_bproc_orted_launch(orte_jobid_t jobid) {
* warning message then fall back on pipes. */
#if (! defined(HAVE_OPENPTY)) || (OMPI_ENABLE_PTY_SUPPORT == 0)
rc = pls_bproc_orted_link_pipes(num_procs, jobid, master,
connect_stdin, app_context);
connect_stdin, mapping->app->idx);
if(ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
goto cleanup;
}
#else /* the user wants to use ptys */
if(0 == openpty(&master[0], &slave, pty_name, NULL, NULL)) {
if(0 == openpty(&master[0], &id, pty_name, NULL, NULL)) {
master[2] = master[1] = master[0];
rc = pls_bproc_orted_link_pty(num_procs, pty_name, jobid,
connect_stdin, app_context);
connect_stdin, mapping->app->idx);
if(ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
goto cleanup;
@ -460,7 +447,7 @@ int orte_pls_bproc_orted_launch(orte_jobid_t jobid) {
pty_error_thrown = true;
}
rc = pls_bproc_orted_link_pipes(num_procs, jobid, master,
connect_stdin, app_context);
connect_stdin, mapping->app->idx);
if(ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
goto cleanup;
@ -480,7 +467,6 @@ int orte_pls_bproc_orted_launch(orte_jobid_t jobid) {
num_procs++;
}
}
mca_pls_bproc_orted_component.num_procs = num_procs;
/* post recieve for termination signal */
rc = mca_oob_recv_packed_nb(MCA_OOB_NAME_SEED, MCA_OOB_TAG_BPROC, 0,

Просмотреть файл

@ -53,7 +53,6 @@ struct orte_pls_bproc_orted_component_t {
orte_pls_base_component_t super;
int debug;
int priority;
int num_procs;
opal_mutex_t lock;
opal_condition_t condition;

Просмотреть файл

@ -57,20 +57,6 @@ orte_pls_bproc_orted_component_t mca_pls_bproc_orted_component = {
}
};
/**
* Convience functions to lookup MCA parameter values.
*/
static int orte_pls_bproc_orted_param_register_int(const char* param_name,
int default_value)
{
int id = mca_base_param_register_int("pls","bproc_orted",param_name,NULL,
default_value);
int param_value = default_value;
mca_base_param_lookup_int(id,&param_value);
return param_value;
}
/**
* Component open function.
*/
@ -81,10 +67,12 @@ int orte_pls_bproc_orted_component_open(void)
OBJ_CONSTRUCT(&mca_pls_bproc_orted_component.condition, opal_condition_t);
/* lookup parameters */
mca_pls_bproc_orted_component.priority =
orte_pls_bproc_orted_param_register_int("priority",100);
mca_pls_bproc_orted_component.debug =
orte_pls_bproc_orted_param_register_int("debug",0);
mca_base_param_reg_int(&mca_pls_bproc_orted_component.super.pls_version,
"priority", NULL, false, false, 100,
&mca_pls_bproc_orted_component.priority);
mca_base_param_reg_int(&mca_pls_bproc_orted_component.super.pls_version,
"debug", "If > 0 prints library debugging information",
false, false, 0, &mca_pls_bproc_orted_component.debug);
return ORTE_SUCCESS;
}

Просмотреть файл

@ -131,20 +131,9 @@ int orte_ns_nds_bproc_put(orte_cellid_t cell, orte_jobid_t job,
orte_vpid_t vpid_start, orte_vpid_t global_vpid_start,
int num_procs, char ***env) {
char* param;
char* cellid;
char* jobid;
char* value;
int rc;
if(ORTE_SUCCESS != (rc = orte_ns.convert_cellid_to_string(&cellid, cell))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if(ORTE_SUCCESS != (rc = orte_ns.convert_jobid_to_string(&jobid, job))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* set the mode to bproc */
if(NULL == (param = mca_base_param_environ_variable("ns","nds",NULL))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
@ -172,21 +161,29 @@ int orte_ns_nds_bproc_put(orte_cellid_t cell, orte_jobid_t job,
free(param);
/* setup the name */
if(ORTE_SUCCESS != (rc = orte_ns.convert_cellid_to_string(&value, cell))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if(NULL == (param = mca_base_param_environ_variable("ns","nds","cellid"))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
opal_setenv(param, cellid, true, env);
opal_setenv(param, value, true, env);
free(param);
free(cellid);
free(value);
if(ORTE_SUCCESS != (rc = orte_ns.convert_jobid_to_string(&value, job))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if(NULL == (param = mca_base_param_environ_variable("ns","nds","jobid"))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
opal_setenv(param, jobid, true, env);
opal_setenv(param, value, true, env);
free(param);
free(jobid);
free(value);
rc = orte_ns.convert_vpid_to_string(&value, vpid_start);
if (ORTE_SUCCESS != rc) {

Просмотреть файл

@ -38,10 +38,8 @@ orte_sds_bproc_set_name(void)
{
int rc;
int id;
int vpid_start;
int global_vpid_start;
int num_procs;
char* name_string = NULL;
id = mca_base_param_register_string("ns", "nds", "name", NULL, NULL);
mca_base_param_lookup_string(id, &name_string);
if(name_string != NULL) {
@ -60,9 +58,11 @@ orte_sds_bproc_set_name(void)
orte_jobid_t jobid;
orte_vpid_t vpid;
orte_vpid_t vpid_offset;
orte_vpid_t vpid_start;
char* cellid_string;
char* jobid_string;
char* vpid_string;
int num_procs;
id = mca_base_param_register_string("ns", "nds", "cellid", NULL, NULL);
mca_base_param_lookup_string(id, &cellid_string);
@ -98,12 +98,17 @@ orte_sds_bproc_set_name(void)
ORTE_ERROR_LOG(rc);
return(rc);
}
id = mca_base_param_register_int("ns", "nds", "vpid_start", NULL, -1);
mca_base_param_lookup_int(id, &vpid_start);
if (vpid_start < 0) {
id = mca_base_param_register_string("ns", "nds", "vpid_start", NULL, NULL);
mca_base_param_lookup_string(id, &vpid_string);
if (NULL == vpid_string) {
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
return ORTE_ERR_NOT_FOUND;
}
rc = orte_ns.convert_string_to_vpid(&vpid_start, vpid_string);
if (ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
return(rc);
}
rc = orte_ns.derive_vpid(&vpid, vpid_offset, vpid_start);
if (ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
@ -118,24 +123,27 @@ orte_sds_bproc_set_name(void)
ORTE_ERROR_LOG(rc);
return rc;
}
}
id = mca_base_param_register_int("ns", "nds", "num_procs", NULL, -1);
mca_base_param_lookup_int(id, &num_procs);
if (num_procs < 0) {
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
return ORTE_ERR_NOT_FOUND;
}
orte_process_info.num_procs = (size_t)num_procs;
id = mca_base_param_register_int("ns", "nds", "num_procs", NULL, -1);
mca_base_param_lookup_int(id, &num_procs);
if (num_procs < 0) {
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
return ORTE_ERR_NOT_FOUND;
}
orte_process_info.num_procs = (size_t)num_procs;
id = mca_base_param_register_int("ns", "nds", "global_vpid_start", NULL, -1);
mca_base_param_lookup_int(id, &global_vpid_start);
if (global_vpid_start < 0) {
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
return ORTE_ERR_NOT_FOUND;
id = mca_base_param_register_string("ns", "nds", "global_vpid_start", NULL, NULL);
mca_base_param_lookup_string(id, &vpid_string);
if (NULL == vpid_string) {
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
return ORTE_ERR_NOT_FOUND;
}
rc = orte_ns.convert_string_to_vpid(&orte_process_info.vpid_start, vpid_string);
if (ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
return(rc);
}
}
orte_process_info.vpid_start = (orte_vpid_t)global_vpid_start;
return ORTE_SUCCESS;
}