Commit 311dee8f authored by Pavan Balaji's avatar Pavan Balaji
Browse files

[svn-r3560] Move the handle structure from the control system to the top-level...

[svn-r3560] Move the handle structure from the control system to the top-level hydra code. This commit only contains structural changes, i.e., moving data structures and functions to different layers (with appropriate renaming to match the layer naming convention).
parent 0037cbb8
......@@ -8,7 +8,6 @@
#define BSCI_H_INCLUDED
#include "hydra.h"
#include "csi.h"
HYD_Status HYD_BSCI_Launch_procs(void);
HYD_Status HYD_BSCI_Cleanup_procs(void);
......
......@@ -7,4 +7,12 @@ HYDRA_LIB_PATH = ../../lib
libhydra_a_DIR = ${HYDRA_LIB_PATH}
libhydra_a_SOURCES = ssh_launch.c ssh_wait.c ssh_finalize.c ssh_usize.c
INCLUDES = -I${abs_srcdir}/../../demux -I${abs_srcdir}/../../control/include/ -I${abs_srcdir}/../../include -I../../include -I${abs_srcdir}/../include -I${abs_srcdir}/../utils -I${abs_srcdir}/../../utils -I${abs_srcdir}/../../../../include -I../../../../include
INCLUDES = -I${abs_srcdir}/../../include \
-I${abs_srcdir}/../../../../include \
-I../../include \
-I../../../../include \
-I${abs_srcdir}/../../launcher/utils \
-I${abs_srcdir}/../../pm/utils \
-I${abs_srcdir}/../include \
-I${abs_srcdir}/../utils \
-I${abs_srcdir}/../../demux
......@@ -6,13 +6,12 @@
#include "hydra.h"
#include "hydra_mem.h"
#include "csi.h"
#include "bsci.h"
#include "bscu.h"
HYD_Status HYD_BSCI_Finalize(void)
{
struct HYD_CSI_Proc_params *proc_params;
struct HYD_Proc_params *proc_params;
HYD_Status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
......
......@@ -6,13 +6,11 @@
#include "hydra.h"
#include "hydra_sock.h"
#include "hydra_dbg.h"
#include "hydra_mem.h"
#include "csi.h"
#include "bsci.h"
#include "bscu.h"
HYD_CSI_Handle csi_handle;
HYD_Handle handle;
/*
* HYD_BSCI_Launch_procs: For each process, we create an executable
......@@ -22,8 +20,8 @@ HYD_CSI_Handle csi_handle;
*/
HYD_Status HYD_BSCI_Launch_procs(void)
{
struct HYD_CSI_Proc_params *proc_params;
char *client_arg[HYD_CSI_EXEC_ARGS], *hostname = NULL, **proc_list = NULL;
struct HYD_Proc_params *proc_params;
char *client_arg[HYD_EXEC_ARGS], *hostname = NULL, **proc_list = NULL;
int i, arg, process_id, host_id, host_id_max;
HYD_Status status = HYD_SUCCESS;
......@@ -47,7 +45,7 @@ HYD_Status HYD_BSCI_Launch_procs(void)
goto fn_fail;
}
proc_params = csi_handle.proc_params;
proc_params = handle.proc_params;
process_id = 0;
while (proc_params) {
if (proc_params->host_file != NULL) { /* We got a new host file */
......@@ -62,9 +60,9 @@ HYD_Status HYD_BSCI_Launch_procs(void)
client_arg[arg++] = MPIU_Strdup("/usr/bin/ssh");
/* Allow X forwarding only if explicitly requested */
if (csi_handle.enablex == 1)
if (handle.enablex == 1)
client_arg[arg++] = MPIU_Strdup("-X");
else if (csi_handle.enablex == 0)
else if (handle.enablex == 0)
client_arg[arg++] = MPIU_Strdup("-x");
else /* default mode is disable X */
client_arg[arg++] = MPIU_Strdup("-x");
......@@ -81,7 +79,7 @@ HYD_Status HYD_BSCI_Launch_procs(void)
client_arg[arg++] = MPIU_Strdup("\"");
client_arg[arg++] = NULL;
HYD_BSCU_Append_env(csi_handle.system_env, client_arg, process_id);
HYD_BSCU_Append_env(handle.system_env, client_arg, process_id);
HYD_BSCU_Append_env(proc_params->prop_env, client_arg, process_id);
HYD_BSCU_Append_wdir(client_arg);
HYD_BSCU_Append_exec(proc_params->exec, client_arg);
......@@ -92,7 +90,7 @@ HYD_Status HYD_BSCI_Launch_procs(void)
/* The stdin pointer will be some value for process_id 0;
* for everyone else, it's NULL. */
status = HYD_BSCU_Create_process(client_arg, (process_id == 0 ? &csi_handle.in : NULL),
status = HYD_BSCU_Create_process(client_arg, (process_id == 0 ? &handle.in : NULL),
&proc_params->out[i], &proc_params->err[i],
&proc_params->pid[i]);
if (status != HYD_SUCCESS) {
......@@ -105,7 +103,7 @@ HYD_Status HYD_BSCI_Launch_procs(void)
/* For the remaining processes, set the stdin fd to -1 */
if (process_id != 0)
csi_handle.in = -1;
handle.in = -1;
process_id++;
}
......@@ -124,14 +122,14 @@ HYD_Status HYD_BSCI_Launch_procs(void)
HYD_Status HYD_BSCI_Cleanup_procs(void)
{
struct HYD_CSI_Proc_params *proc_params;
char *client_arg[HYD_CSI_EXEC_ARGS], *hostname, **proc_list, *execname;
struct HYD_Proc_params *proc_params;
char *client_arg[HYD_EXEC_ARGS], *hostname, **proc_list, *execname;
int i, arg, host_id, host_id_max;
HYD_Status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
proc_params = csi_handle.proc_params;
proc_params = handle.proc_params;
while (proc_params) {
for (i = 0; i < proc_params->user_num_procs; i++) {
/* Setup the executable arguments */
......
......@@ -7,4 +7,11 @@ HYDRA_LIB_PATH = ../../lib
libhydra_a_DIR = ${HYDRA_LIB_PATH}
libhydra_a_SOURCES = bscu_init.c bscu_finalize.c bscu_args.c bscu_wait.c bscu_launch.c bscu_signal.c
INCLUDES = -I${abs_srcdir}/../../utils -I${abs_srcdir}/../../include -I../../include -I${abs_srcdir}/../include -I${abs_srcdir}/../../bootstrap/include -I${abs_srcdir} -I${abs_srcdir}/../../control/include -I${abs_srcdir}/../../control/utils -I${abs_srcdir}/../../demux -I${abs_srcdir}/../../pm/include -I${abs_srcdir}/../../launch/mpiexec -I${abs_srcdir}/../../../../include -I../../../../include
INCLUDES = -I${abs_srcdir}/../../include \
-I${abs_srcdir}/../../../../include \
-I../../include \
-I../../../../include \
-I${abs_srcdir}/../../launcher/utils \
-I${abs_srcdir}/../../pm/utils \
-I${abs_srcdir}/../include \
-I${abs_srcdir}/../../demux
......@@ -9,7 +9,6 @@
#include "hydra.h"
#include "hydra_sig.h"
#include "csi.h"
#include "bsci.h"
HYD_Status HYD_BSCU_Init_exit_status(void);
......@@ -18,7 +17,7 @@ HYD_Status HYD_BSCU_Init_io_fds(void);
HYD_Status HYD_BSCU_Finalize_io_fds(void);
HYD_Status HYD_BSCU_Create_process(char **client_arg, int *in, int *out, int *err, int *pid);
HYD_Status HYD_BSCU_Wait_for_completion(void);
HYD_Status HYD_BSCU_Append_env(HYDU_Env_t * env_list, char **client_arg, int id);
HYD_Status HYD_BSCU_Append_env(HYD_Env_t * env_list, char **client_arg, int id);
HYD_Status HYD_BSCU_Append_exec(char **exec, char **client_arg);
HYD_Status HYD_BSCU_Append_wdir(char **client_arg);
HYD_Status HYD_BSCU_Set_common_signals(void (*handler) (int));
......
......@@ -5,18 +5,16 @@
*/
#include "hydra.h"
#include "hydra_dbg.h"
#include "hydra_mem.h"
#include "csi.h"
#include "bsci.h"
#include "bscu.h"
HYD_CSI_Handle csi_handle;
HYD_Handle handle;
HYD_Status HYD_BSCU_Append_env(HYDU_Env_t * env_list, char **client_arg, int id)
HYD_Status HYD_BSCU_Append_env(HYD_Env_t * env_list, char **client_arg, int id)
{
int i, j, csh_format;
HYDU_Env_t *env;
HYD_Env_t *env;
char *envstr, *tmp[HYDU_NUM_JOIN_STR], *inc;
HYD_Status status = HYD_SUCCESS;
......@@ -30,9 +28,9 @@ HYD_Status HYD_BSCU_Append_env(HYDU_Env_t * env_list, char **client_arg, int id)
tmp[j++] = MPIU_Strdup(env->env_name);
tmp[j++] = MPIU_Strdup("=");
if (env->env_type == HYDU_ENV_STATIC)
if (env->env_type == HYD_ENV_STATIC)
tmp[j++] = MPIU_Strdup(env->env_value);
else if (env->env_type == HYDU_ENV_AUTOINC) {
else if (env->env_type == HYD_ENV_AUTOINC) {
HYDU_Int_to_str(env->start_val + id, inc, status);
tmp[j++] = MPIU_Strdup(inc);
HYDU_FREE(inc);
......@@ -90,7 +88,7 @@ HYD_Status HYD_BSCU_Append_wdir(char **client_arg)
for (arg = 0; client_arg[arg]; arg++);
client_arg[arg++] = MPIU_Strdup("cd");
client_arg[arg++] = MPIU_Strdup(csi_handle.wdir);
client_arg[arg++] = MPIU_Strdup(handle.wdir);
client_arg[arg++] = MPIU_Strdup(";");
client_arg[arg++] = NULL;
......
......@@ -5,23 +5,21 @@
*/
#include "hydra.h"
#include "hydra_dbg.h"
#include "hydra_mem.h"
#include "csi.h"
#include "bsci.h"
#include "bscu.h"
HYD_CSI_Handle csi_handle;
HYD_Handle handle;
HYD_Status HYD_BSCU_Finalize_exit_status(void)
{
struct HYD_CSI_Proc_params *proc_params;
struct HYD_Proc_params *proc_params;
int i;
HYD_Status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
proc_params = csi_handle.proc_params;
proc_params = handle.proc_params;
while (proc_params) {
HYDU_FREE(proc_params->pid);
HYDU_FREE(proc_params->exit_status);
......@@ -36,12 +34,12 @@ HYD_Status HYD_BSCU_Finalize_exit_status(void)
HYD_Status HYD_BSCU_Finalize_io_fds(void)
{
struct HYD_CSI_Proc_params *proc_params;
struct HYD_Proc_params *proc_params;
HYD_Status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
proc_params = csi_handle.proc_params;
proc_params = handle.proc_params;
while (proc_params) {
HYDU_FREE(proc_params->out);
HYDU_FREE(proc_params->err);
......
......@@ -5,17 +5,15 @@
*/
#include "hydra.h"
#include "hydra_dbg.h"
#include "hydra_mem.h"
#include "csi.h"
#include "bsci.h"
#include "bscu.h"
HYD_CSI_Handle csi_handle;
HYD_Handle handle;
HYD_Status HYD_BSCU_Init_exit_status(void)
{
struct HYD_CSI_Proc_params *proc_params;
struct HYD_Proc_params *proc_params;
int i;
HYD_Status status = HYD_SUCCESS;
......@@ -24,7 +22,7 @@ HYD_Status HYD_BSCU_Init_exit_status(void)
/* Set the exit status of all processes to 1 (> 0 means that the
* status is not set yet). Also count the number of processes in
* the same loop. */
proc_params = csi_handle.proc_params;
proc_params = handle.proc_params;
while (proc_params) {
HYDU_MALLOC(proc_params->pid, int *, proc_params->user_num_procs * sizeof(int), status);
HYDU_MALLOC(proc_params->exit_status, int *, proc_params->user_num_procs * sizeof(int), status);
......@@ -46,12 +44,12 @@ HYD_Status HYD_BSCU_Init_exit_status(void)
HYD_Status HYD_BSCU_Init_io_fds(void)
{
struct HYD_CSI_Proc_params *proc_params;
struct HYD_Proc_params *proc_params;
HYD_Status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
proc_params = csi_handle.proc_params;
proc_params = handle.proc_params;
while (proc_params) {
HYDU_MALLOC(proc_params->out, int *, proc_params->user_num_procs * sizeof(int), status);
HYDU_MALLOC(proc_params->err, int *, proc_params->user_num_procs * sizeof(int), status);
......
......@@ -5,13 +5,11 @@
*/
#include "hydra.h"
#include "hydra_dbg.h"
#include "hydra_mem.h"
#include "csi.h"
#include "bsci.h"
#include "bscu.h"
HYD_CSI_Handle csi_handle;
HYD_Handle handle;
HYD_Status HYD_BSCU_Create_process(char **client_arg, int *in, int *out, int *err, int *pid)
{
......@@ -69,9 +67,9 @@ HYD_Status HYD_BSCU_Create_process(char **client_arg, int *in, int *out, int *er
}
}
if (chdir(csi_handle.wdir) < 0) {
if (chdir(handle.wdir) < 0) {
if (chdir(getenv("HOME")) < 0) {
HYDU_Error_printf("unable to set working directory to %s\n", csi_handle.wdir);
HYDU_Error_printf("unable to set working directory to %s\n", handle.wdir);
status = HYD_INTERNAL_ERROR;
goto fn_fail;
}
......
......@@ -5,9 +5,7 @@
*/
#include "hydra.h"
#include "hydra_dbg.h"
#include "hydra_sig.h"
#include "csi.h"
#include "bsci.h"
#include "bscu.h"
......
......@@ -5,14 +5,11 @@
*/
#include "hydra.h"
#include "hydra_dbg.h"
#include "hydra_mem.h"
#include "csi.h"
#include "csiu.h"
#include "bsci.h"
#include "bscu.h"
HYD_CSI_Handle csi_handle;
HYD_Handle handle;
/*
* HYD_BSCU_Wait_for_completion: We first wait for communication
......@@ -23,13 +20,13 @@ HYD_CSI_Handle csi_handle;
HYD_Status HYD_BSCU_Wait_for_completion(void)
{
int pid, ret_status, i, not_completed;
struct HYD_CSI_Proc_params *proc_params;
struct HYD_Proc_params *proc_params;
HYD_Status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
not_completed = 0;
proc_params = csi_handle.proc_params;
proc_params = handle.proc_params;
while (proc_params) {
for (i = 0; i < proc_params->user_num_procs; i++)
if (proc_params->exit_status_valid[i] == 0)
......@@ -46,7 +43,7 @@ HYD_Status HYD_BSCU_Wait_for_completion(void)
pid = waitpid(-1, &ret_status, WNOHANG);
if (pid > 0) {
/* Find the pid and mark it as complete. */
proc_params = csi_handle.proc_params;
proc_params = handle.proc_params;
while (proc_params) {
for (i = 0; i < proc_params->user_num_procs; i++) {
if (proc_params->pid[i] == pid) {
......
......@@ -107,7 +107,6 @@ fi
AC_SUBST(HYDRA_CSS)
dnl Debugging support
dnl FIXME: Inherit this from the above configure
AC_ARG_ENABLE(g, [ --enable-g Enable Debugging],
[ DEBUG=$enableval ],
[ DEBUG=no ])
......@@ -115,6 +114,7 @@ AC_MSG_CHECKING(debugging support)
AC_MSG_RESULT($DEBUG)
if test "$DEBUG" = "yes"; then
EXTRA_CFLAGS="$EXTRA_CFLAGS -g"
AC_DEFINE(ENABLE_DEBUG,1,[Define if debugging support is enabled])
fi
AC_SUBST(EXTRA_CFLAGS)
......
......@@ -7,4 +7,13 @@ HYDRA_LIB_PATH = ../../lib
libhydra_a_DIR = ${HYDRA_LIB_PATH}
libhydra_a_SOURCES = consys_launch.c consys_wait.c consys_close.c consys_finalize.c
INCLUDES = -I${abs_srcdir}/../utils -I${abs_srcdir}/../../utils -I${abs_srcdir}/../../include -I../../include -I${abs_srcdir}/../include -I${abs_srcdir}/../../bootstrap/include -I${abs_srcdir}/../../demux -I${abs_srcdir}/../../pm/include -I${abs_srcdir}/../../launch/mpiexec -I${abs_srcdir}/../../../../include -I../../../../include
INCLUDES = -I${abs_srcdir}/../../include \
-I${abs_srcdir}/../../../../include \
-I../../include \
-I../../../../include \
-I${abs_srcdir}/../../launcher/utils \
-I${abs_srcdir}/../include \
-I${abs_srcdir}/../utils \
-I${abs_srcdir}/../../pm/include \
-I${abs_srcdir}/../../bootstrap/include \
-I${abs_srcdir}/../../demux
......@@ -11,12 +11,12 @@
#include "bsci.h"
#include "demux.h"
HYD_CSI_Handle csi_handle;
HYD_Handle handle;
HYD_Status HYD_CSI_Close_fd(int fd)
{
int i;
struct HYD_CSI_Proc_params *proc_params;
struct HYD_Proc_params *proc_params;
HYD_Status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
......@@ -31,7 +31,7 @@ HYD_Status HYD_CSI_Close_fd(int fd)
close(fd);
/* Find the FD in the handle and remove it. */
proc_params = csi_handle.proc_params;
proc_params = handle.proc_params;
while (proc_params) {
for (i = 0; i < proc_params->user_num_procs; i++) {
if (proc_params->out[i] == fd) {
......
......@@ -5,8 +5,6 @@
*/
#include "hydra.h"
#include "hydra_dbg.h"
#include "hydra_mem.h"
#include "csi.h"
#include "pmci.h"
#include "bsci.h"
......@@ -14,8 +12,6 @@
HYD_Status HYD_CSI_Finalize(void)
{
struct HYD_CSI_Proc_params *proc_params, *p;
int i;
HYD_Status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
......
......@@ -5,19 +5,16 @@
*/
#include "hydra.h"
#include "hydra_dbg.h"
#include "hydra_mem.h"
#include "hydra_sock.h"
#include "csi.h"
#include "pmci.h"
#include "bsci.h"
#include "demux.h"
HYD_CSI_Handle csi_handle;
HYD_Handle handle;
HYD_Status HYD_CSI_Launch_procs(void)
{
struct HYD_CSI_Proc_params *proc_params;
struct HYD_Proc_params *proc_params;
int stdin_fd, flags, count;
HYD_Status status = HYD_SUCCESS;
......@@ -29,17 +26,17 @@ HYD_Status HYD_CSI_Launch_procs(void)
goto fn_fail;
}
proc_params = csi_handle.proc_params;
proc_params = handle.proc_params;
while (proc_params) {
status = HYD_DMX_Register_fd(proc_params->user_num_procs, proc_params->out,
HYD_CSI_OUT, proc_params->stdout_cb);
HYD_STDOUT, proc_params->stdout_cb);
if (status != HYD_SUCCESS) {
HYDU_Error_printf("demux engine returned error when registering fd\n");
goto fn_fail;
}
status = HYD_DMX_Register_fd(proc_params->user_num_procs, proc_params->err,
HYD_CSI_OUT, proc_params->stderr_cb);
HYD_STDOUT, proc_params->stderr_cb);
if (status != HYD_SUCCESS) {
HYDU_Error_printf("demux engine returned error when registering fd\n");
goto fn_fail;
......@@ -48,8 +45,8 @@ HYD_Status HYD_CSI_Launch_procs(void)
proc_params = proc_params->next;
}
if (csi_handle.in != -1) { /* Only process_id 0 */
status = HYDU_Sock_set_nonblock(csi_handle.in);
if (handle.in != -1) { /* Only process_id 0 */
status = HYDU_Sock_set_nonblock(handle.in);
if (status != HYD_SUCCESS) {
HYDU_Error_printf("Unable to set socket as non-blocking\n");
status = HYD_SOCK_ERROR;
......@@ -64,10 +61,10 @@ HYD_Status HYD_CSI_Launch_procs(void)
goto fn_fail;
}
csi_handle.stdin_buf_count = 0;
csi_handle.stdin_buf_offset = 0;
handle.stdin_buf_count = 0;
handle.stdin_buf_offset = 0;
status = HYD_DMX_Register_fd(1, &stdin_fd, HYD_CSI_OUT, csi_handle.stdin_cb);
status = HYD_DMX_Register_fd(1, &stdin_fd, HYD_STDOUT, handle.stdin_cb);
if (status != HYD_SUCCESS) {
HYDU_Error_printf("demux engine returned error when registering fd\n");
goto fn_fail;
......
......@@ -5,19 +5,17 @@
*/
#include "hydra.h"
#include "hydra_dbg.h"
#include "csi.h"
#include "csiu.h"
#include "pmci.h"
#include "bsci.h"
#include "demux.h"
HYD_CSI_Handle csi_handle;
HYD_Handle handle;
HYD_Status HYD_CSI_Wait_for_completion(void)
{
int sockets_open, i;
struct HYD_CSI_Proc_params *proc_params;
struct HYD_Proc_params *proc_params;
HYD_Status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
......@@ -32,7 +30,7 @@ HYD_Status HYD_CSI_Wait_for_completion(void)
/* Check to see if there's any open read socket left; if there
* are, we will just wait for more events. */
proc_params = csi_handle.proc_params;
proc_params = handle.proc_params;
sockets_open = 0;
while (proc_params) {
for (i = 0; i < proc_params->user_num_procs; i++) {
......
......@@ -7,97 +7,7 @@
#ifndef CSI_H_INCLUDED
#define CSI_H_INCLUDED
#include <sys/time.h>
#include "hydra.h"
#include "hydra_env.h"
#define HYD_CSI_OUT (1)
#define HYD_CSI_IN (2)
typedef unsigned short HYD_CSI_Event_t;
#define HYD_CSI_TMPBUF_SIZE (64 * 1024)
#define HYD_CSI_EXEC_ARGS 200
struct HYD_CSI_Handle_ {
int debug;
int enablex;
char *wdir;
HYDU_Env_t *global_env;
HYDU_Env_t *system_env;
HYDU_Env_t *user_env;
HYDU_Env_prop_t prop;
HYDU_Env_t *prop_env;
int in;
HYD_Status(*stdin_cb) (int fd, HYD_CSI_Event_t events);
char stdin_tmp_buf[HYD_CSI_TMPBUF_SIZE];
int stdin_buf_offset;
int stdin_buf_count;
/* Start time and timeout. These are filled in by the launcher,
* but are utilized by the demux engine and the boot-strap server
* to decide how long we need to wait for. */
struct timeval start;
struct timeval timeout;
/* Each structure will contain all hosts/cores that use the same
* executable and environment. */
struct HYD_CSI_Proc_params {
int user_num_procs;
int total_num_procs;
char **total_proc_list;
int *total_core_list;
char *host_file;
char *exec[HYD_CSI_EXEC_ARGS];
HYDU_Env_t *user_env;
HYDU_Env_prop_t prop;
HYDU_Env_t *prop_env;
/* These output FDs are filled in by the lower layers */
int *out;
int *err;
/* Callback functions for the stdout/stderr events. These can
* be the same. */
HYD_Status(*stdout_cb) (int fd, HYD_CSI_Event_t events);
HYD_Status(*stderr_cb) (int fd, HYD_CSI_Event_t events);
/* Status > 0 means that it is not set yet. Successful
* completion of a process will set the status to 0. An error
* will set this to a negative value corresponding to the
* error. Depending on the bootstrap server, these values
* might correspond to per-process status, or can be a common
* value for all processes. */
int *pid;
int *exit_status;
int *exit_status_valid;