[mpich2-commits] r3967 - in mpich2/trunk/src/pm/hydra: . bootstrap/ssh bootstrap/utils include utils utils/launch

balaji at mcs.anl.gov balaji at mcs.anl.gov
Sat Mar 7 17:22:44 CST 2009


Author: balaji
Date: 2009-03-07 17:22:44 -0600 (Sat, 07 Mar 2009)
New Revision: 3967

Added:
   mpich2/trunk/src/pm/hydra/include/hydra_launch.h
   mpich2/trunk/src/pm/hydra/utils/launch/
   mpich2/trunk/src/pm/hydra/utils/launch/Makefile.sm
   mpich2/trunk/src/pm/hydra/utils/launch/args.c
   mpich2/trunk/src/pm/hydra/utils/launch/launch.c
Removed:
   mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_args.c
   mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_launch.c
Modified:
   mpich2/trunk/src/pm/hydra/bootstrap/ssh/ssh_launch.c
   mpich2/trunk/src/pm/hydra/bootstrap/utils/Makefile.sm
   mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu.h
   mpich2/trunk/src/pm/hydra/configure.in
   mpich2/trunk/src/pm/hydra/utils/Makefile.sm
Log:
Move out common functionality as common utilities.

Modified: mpich2/trunk/src/pm/hydra/bootstrap/ssh/ssh_launch.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/ssh/ssh_launch.c	2009-03-07 21:47:37 UTC (rev 3966)
+++ mpich2/trunk/src/pm/hydra/bootstrap/ssh/ssh_launch.c	2009-03-07 23:22:44 UTC (rev 3967)
@@ -7,6 +7,7 @@
 #include "hydra.h"
 #include "hydra_sock.h"
 #include "hydra_mem.h"
+#include "hydra_launch.h"
 #include "bsci.h"
 #include "bscu.h"
 
@@ -79,10 +80,10 @@
             client_arg[arg++] = MPIU_Strdup("\"");
             client_arg[arg++] = NULL;
 
-            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);
+            HYDU_Append_env(handle.system_env, client_arg, process_id);
+            HYDU_Append_env(proc_params->prop_env, client_arg, process_id);
+            HYDU_Append_wdir(client_arg);
+            HYDU_Append_exec(proc_params->exec, client_arg);
 
             for (arg = 0; client_arg[arg]; arg++);
             client_arg[arg++] = MPIU_Strdup("\"");
@@ -90,9 +91,9 @@
 
             /* 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 ? &handle.in : NULL),
-                                             &proc_params->out[i], &proc_params->err[i],
-                                             &proc_params->pid[i]);
+            status = HYDU_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) {
                 HYDU_Error_printf("bootstrap spawn process returned error\n");
                 goto fn_fail;
@@ -151,7 +152,7 @@
             client_arg[arg++] = MPIU_Strdup(hostname);
             client_arg[arg++] = NULL;
 
-            HYD_BSCU_Append_wdir(client_arg);
+            HYDU_Append_wdir(client_arg);
 
             for (arg = 0; client_arg[arg]; arg++);
             client_arg[arg++] = MPIU_Strdup("killall");
@@ -165,7 +166,7 @@
             client_arg[arg++] = MPIU_Strdup(execname);
             client_arg[arg++] = NULL;
 
-            status = HYD_BSCU_Create_process(client_arg, NULL, NULL, NULL, NULL);
+            status = HYDU_Create_process(client_arg, NULL, NULL, NULL, NULL);
             if (status != HYD_SUCCESS) {
                 HYDU_Error_printf("bootstrap spawn process returned error\n");
                 goto fn_fail;

Modified: mpich2/trunk/src/pm/hydra/bootstrap/utils/Makefile.sm
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/utils/Makefile.sm	2009-03-07 21:47:37 UTC (rev 3966)
+++ mpich2/trunk/src/pm/hydra/bootstrap/utils/Makefile.sm	2009-03-07 23:22:44 UTC (rev 3967)
@@ -6,7 +6,7 @@
 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
+libhydra_a_SOURCES = bscu_init.c bscu_finalize.c bscu_wait.c bscu_signal.c
 INCLUDES = -I${abs_srcdir}/../../include \
 	-I${abs_srcdir}/../../../../include \
 	-I../../include \

Modified: mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu.h
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu.h	2009-03-07 21:47:37 UTC (rev 3966)
+++ mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu.h	2009-03-07 23:22:44 UTC (rev 3967)
@@ -15,11 +15,7 @@
 HYD_Status HYD_BSCU_Finalize_exit_status(void);
 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(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));
 void HYD_BSCU_Signal_handler(int signal);
 

Deleted: mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_args.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_args.c	2009-03-07 21:47:37 UTC (rev 3966)
+++ mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_args.c	2009-03-07 23:22:44 UTC (rev 3967)
@@ -1,97 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- *  (C) 2008 by Argonne National Laboratory.
- *      See COPYRIGHT in top-level directory.
- */
-
-#include "hydra.h"
-#include "hydra_mem.h"
-#include "bsci.h"
-#include "bscu.h"
-
-HYD_Handle handle;
-
-HYD_Status HYD_BSCU_Append_env(HYD_Env_t * env_list, char **client_arg, int id)
-{
-    int i, j, csh_format;
-    HYD_Env_t *env;
-    char *envstr, *tmp[HYDU_NUM_JOIN_STR], *inc;
-    HYD_Status status = HYD_SUCCESS;
-
-    HYDU_FUNC_ENTER();
-
-    for (i = 0; client_arg[i]; i++);
-    env = env_list;
-    while (env) {
-        j = 0;
-
-        tmp[j++] = MPIU_Strdup(env->env_name);
-        tmp[j++] = MPIU_Strdup("=");
-
-        if (env->env_type == HYD_ENV_STATIC)
-            tmp[j++] = MPIU_Strdup(env->env_value);
-        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);
-        }
-
-        tmp[j++] = NULL;
-        HYDU_STR_ALLOC_AND_JOIN(tmp, envstr, status);
-        client_arg[i++] = MPIU_Strdup(envstr);
-        HYDU_FREE(envstr);
-        for (j = 0; tmp[j]; j++)
-            HYDU_FREE(tmp[j]);
-
-        client_arg[i++] = MPIU_Strdup(";");
-
-        client_arg[i++] = MPIU_Strdup("export");
-        client_arg[i++] = MPIU_Strdup(env->env_name);
-        client_arg[i++] = MPIU_Strdup(";");
-
-        env = env->next;
-    }
-    client_arg[i++] = NULL;
-
-  fn_exit:
-    HYDU_FUNC_EXIT();
-    return status;
-
-  fn_fail:
-    goto fn_exit;
-}
-
-
-HYD_Status HYD_BSCU_Append_exec(char **exec, char **client_arg)
-{
-    int i, j;
-    HYD_Status status = HYD_SUCCESS;
-
-    HYDU_FUNC_ENTER();
-
-    for (i = 0; client_arg[i]; i++);
-    for (j = 0; exec[j]; j++)
-        client_arg[i++] = MPIU_Strdup(exec[j]);
-    client_arg[i++] = NULL;
-
-    HYDU_FUNC_EXIT();
-    return status;
-}
-
-
-HYD_Status HYD_BSCU_Append_wdir(char **client_arg)
-{
-    int arg;
-    HYD_Status status = HYD_SUCCESS;
-
-    HYDU_FUNC_ENTER();
-
-    for (arg = 0; client_arg[arg]; arg++);
-    client_arg[arg++] = MPIU_Strdup("cd");
-    client_arg[arg++] = MPIU_Strdup(handle.wdir);
-    client_arg[arg++] = MPIU_Strdup(";");
-    client_arg[arg++] = NULL;
-
-    HYDU_FUNC_EXIT();
-    return status;
-}

Deleted: mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_launch.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_launch.c	2009-03-07 21:47:37 UTC (rev 3966)
+++ mpich2/trunk/src/pm/hydra/bootstrap/utils/bscu_launch.c	2009-03-07 23:22:44 UTC (rev 3967)
@@ -1,105 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; -*- */
-/*
- *  (C) 2008 by Argonne National Laboratory.
- *      See COPYRIGHT in top-level directory.
- */
-
-#include "hydra.h"
-#include "hydra_mem.h"
-#include "bsci.h"
-#include "bscu.h"
-
-HYD_Handle handle;
-
-HYD_Status HYD_BSCU_Create_process(char **client_arg, int *in, int *out, int *err, int *pid)
-{
-    int inpipe[2], outpipe[2], errpipe[2], arg, tpid;
-    HYD_Status status = HYD_SUCCESS;
-
-    HYDU_FUNC_ENTER();
-
-    if (in != NULL) {
-        if (pipe(inpipe) < 0) {
-            HYDU_Error_printf("pipe error (errno: %d)\n", errno);
-            status = HYD_SOCK_ERROR;
-            goto fn_fail;
-        }
-    }
-
-    if (pipe(outpipe) < 0) {
-        HYDU_Error_printf("pipe error (errno: %d)\n", errno);
-        status = HYD_SOCK_ERROR;
-        goto fn_fail;
-    }
-
-    if (pipe(errpipe) < 0) {
-        HYDU_Error_printf("pipe error (errno: %d)\n", errno);
-        status = HYD_SOCK_ERROR;
-        goto fn_fail;
-    }
-
-    /* Fork off the process */
-    tpid = fork();
-    if (tpid == 0) {    /* Child process */
-        close(outpipe[0]);
-        close(1);
-        if (dup2(outpipe[1], 1) < 0) {
-            HYDU_Error_printf("dup2 error (errno: %d)\n", errno);
-            status = HYD_SOCK_ERROR;
-            goto fn_fail;
-        }
-
-        close(errpipe[0]);
-        close(2);
-        if (dup2(errpipe[1], 2) < 0) {
-            HYDU_Error_printf("dup2 error (errno: %d)\n", errno);
-            status = HYD_SOCK_ERROR;
-            goto fn_fail;
-        }
-
-        if (in != NULL) {
-            close(inpipe[1]);
-            close(0);
-            if (dup2(inpipe[0], 0) < 0) {
-                HYDU_Error_printf("dup2 error (errno: %d)\n", errno);
-                status = HYD_SOCK_ERROR;
-                goto fn_fail;
-            }
-        }
-
-        if (chdir(handle.wdir) < 0) {
-            if (chdir(getenv("HOME")) < 0) {
-                HYDU_Error_printf("unable to set working directory to %s\n", handle.wdir);
-                status = HYD_INTERNAL_ERROR;
-                goto fn_fail;
-            }
-        }
-
-        /* execvp the process */
-        if (execvp(client_arg[0], client_arg) < 0) {
-            HYDU_Error_printf("execvp error\n");
-            status = HYD_INTERNAL_ERROR;
-            goto fn_fail;
-        }
-    }
-    else {      /* Parent process */
-        close(outpipe[1]);
-        close(errpipe[1]);
-        if (in)
-            *in = inpipe[1];
-        if (out)
-            *out = outpipe[0];
-        if (err)
-            *err = errpipe[0];
-    }
-
-    if (pid)
-        *pid = tpid;
-
-  fn_exit:
-    HYDU_FUNC_EXIT();
-    return status;
-
-  fn_fail:
-    goto fn_exit;
-}

Modified: mpich2/trunk/src/pm/hydra/configure.in
===================================================================
--- mpich2/trunk/src/pm/hydra/configure.in	2009-03-07 21:47:37 UTC (rev 3966)
+++ mpich2/trunk/src/pm/hydra/configure.in	2009-03-07 23:22:44 UTC (rev 3967)
@@ -260,6 +260,7 @@
 	utils/env/Makefile \
 	utils/sock/Makefile \
 	utils/signals/Makefile \
+	utils/launch/Makefile \
 	launcher/Makefile \
 	launcher/utils/Makefile \
 	launcher/${HYDRA_LAUNCHER}/Makefile \

Added: mpich2/trunk/src/pm/hydra/include/hydra_launch.h
===================================================================
--- mpich2/trunk/src/pm/hydra/include/hydra_launch.h	                        (rev 0)
+++ mpich2/trunk/src/pm/hydra/include/hydra_launch.h	2009-03-07 23:22:44 UTC (rev 3967)
@@ -0,0 +1,17 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ *  (C) 2008 by Argonne National Laboratory.
+ *      See COPYRIGHT in top-level directory.
+ */
+
+#ifndef HYDRA_LAUNCH_H_INCLUDED
+#define HYDRA_LAUNCH_H_INCLUDED
+
+#include "hydra.h"
+
+HYD_Status HYDU_Append_env(HYD_Env_t * env_list, char **client_arg, int id);
+HYD_Status HYDU_Append_exec(char **exec, char **client_arg);
+HYD_Status HYDU_Append_wdir(char **client_arg);
+HYD_Status HYDU_Create_process(char **client_arg, int *in, int *out, int *err, int *pid);
+
+#endif /* HYDRA_LAUNCH_H_INCLUDED */

Modified: mpich2/trunk/src/pm/hydra/utils/Makefile.sm
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/Makefile.sm	2009-03-07 21:47:37 UTC (rev 3966)
+++ mpich2/trunk/src/pm/hydra/utils/Makefile.sm	2009-03-07 23:22:44 UTC (rev 3967)
@@ -3,4 +3,4 @@
 #     See COPYRIGHT in top-level directory.
 #
 
-SUBDIRS = dbg env sock signals .
+SUBDIRS = dbg env sock signals launch .


Property changes on: mpich2/trunk/src/pm/hydra/utils/launch
___________________________________________________________________
Name: svn:ignore
   + Makefile
Makefile.in


Added: mpich2/trunk/src/pm/hydra/utils/launch/Makefile.sm
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/launch/Makefile.sm	                        (rev 0)
+++ mpich2/trunk/src/pm/hydra/utils/launch/Makefile.sm	2009-03-07 23:22:44 UTC (rev 3967)
@@ -0,0 +1,13 @@
+#
+# (C) 2008 by Argonne National Laboratory.
+#     See COPYRIGHT in top-level directory.
+#
+
+HYDRA_LIB_PATH = ../../lib
+
+libhydra_a_DIR = ${HYDRA_LIB_PATH}
+libhydra_a_SOURCES = args.c launch.c
+INCLUDES = -I${abs_srcdir}/../../include \
+	-I${abs_srcdir}/../../../../include \
+	-I../../include \
+	-I../../../../include

Added: mpich2/trunk/src/pm/hydra/utils/launch/args.c
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/launch/args.c	                        (rev 0)
+++ mpich2/trunk/src/pm/hydra/utils/launch/args.c	2009-03-07 23:22:44 UTC (rev 3967)
@@ -0,0 +1,96 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ *  (C) 2008 by Argonne National Laboratory.
+ *      See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra.h"
+#include "hydra_mem.h"
+#include "hydra_launch.h"
+
+HYD_Handle handle;
+
+HYD_Status HYDU_Append_env(HYD_Env_t * env_list, char **client_arg, int id)
+{
+    int i, j, csh_format;
+    HYD_Env_t *env;
+    char *envstr, *tmp[HYDU_NUM_JOIN_STR], *inc;
+    HYD_Status status = HYD_SUCCESS;
+
+    HYDU_FUNC_ENTER();
+
+    for (i = 0; client_arg[i]; i++);
+    env = env_list;
+    while (env) {
+        j = 0;
+
+        tmp[j++] = MPIU_Strdup(env->env_name);
+        tmp[j++] = MPIU_Strdup("=");
+
+        if (env->env_type == HYD_ENV_STATIC)
+            tmp[j++] = MPIU_Strdup(env->env_value);
+        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);
+        }
+
+        tmp[j++] = NULL;
+        HYDU_STR_ALLOC_AND_JOIN(tmp, envstr, status);
+        client_arg[i++] = MPIU_Strdup(envstr);
+        HYDU_FREE(envstr);
+        for (j = 0; tmp[j]; j++)
+            HYDU_FREE(tmp[j]);
+
+        client_arg[i++] = MPIU_Strdup(";");
+
+        client_arg[i++] = MPIU_Strdup("export");
+        client_arg[i++] = MPIU_Strdup(env->env_name);
+        client_arg[i++] = MPIU_Strdup(";");
+
+        env = env->next;
+    }
+    client_arg[i++] = NULL;
+
+  fn_exit:
+    HYDU_FUNC_EXIT();
+    return status;
+
+  fn_fail:
+    goto fn_exit;
+}
+
+
+HYD_Status HYDU_Append_exec(char **exec, char **client_arg)
+{
+    int i, j;
+    HYD_Status status = HYD_SUCCESS;
+
+    HYDU_FUNC_ENTER();
+
+    for (i = 0; client_arg[i]; i++);
+    for (j = 0; exec[j]; j++)
+        client_arg[i++] = MPIU_Strdup(exec[j]);
+    client_arg[i++] = NULL;
+
+    HYDU_FUNC_EXIT();
+    return status;
+}
+
+
+HYD_Status HYDU_Append_wdir(char **client_arg)
+{
+    int arg;
+    HYD_Status status = HYD_SUCCESS;
+
+    HYDU_FUNC_ENTER();
+
+    for (arg = 0; client_arg[arg]; arg++);
+    client_arg[arg++] = MPIU_Strdup("cd");
+    client_arg[arg++] = MPIU_Strdup(handle.wdir);
+    client_arg[arg++] = MPIU_Strdup(";");
+    client_arg[arg++] = NULL;
+
+    HYDU_FUNC_EXIT();
+    return status;
+}

Added: mpich2/trunk/src/pm/hydra/utils/launch/launch.c
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/launch/launch.c	                        (rev 0)
+++ mpich2/trunk/src/pm/hydra/utils/launch/launch.c	2009-03-07 23:22:44 UTC (rev 3967)
@@ -0,0 +1,104 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ *  (C) 2008 by Argonne National Laboratory.
+ *      See COPYRIGHT in top-level directory.
+ */
+
+#include "hydra.h"
+#include "hydra_mem.h"
+#include "hydra_launch.h"
+
+HYD_Handle handle;
+
+HYD_Status HYDU_Create_process(char **client_arg, int *in, int *out, int *err, int *pid)
+{
+    int inpipe[2], outpipe[2], errpipe[2], arg, tpid;
+    HYD_Status status = HYD_SUCCESS;
+
+    HYDU_FUNC_ENTER();
+
+    if (in != NULL) {
+        if (pipe(inpipe) < 0) {
+            HYDU_Error_printf("pipe error (errno: %d)\n", errno);
+            status = HYD_SOCK_ERROR;
+            goto fn_fail;
+        }
+    }
+
+    if (pipe(outpipe) < 0) {
+        HYDU_Error_printf("pipe error (errno: %d)\n", errno);
+        status = HYD_SOCK_ERROR;
+        goto fn_fail;
+    }
+
+    if (pipe(errpipe) < 0) {
+        HYDU_Error_printf("pipe error (errno: %d)\n", errno);
+        status = HYD_SOCK_ERROR;
+        goto fn_fail;
+    }
+
+    /* Fork off the process */
+    tpid = fork();
+    if (tpid == 0) {    /* Child process */
+        close(outpipe[0]);
+        close(1);
+        if (dup2(outpipe[1], 1) < 0) {
+            HYDU_Error_printf("dup2 error (errno: %d)\n", errno);
+            status = HYD_SOCK_ERROR;
+            goto fn_fail;
+        }
+
+        close(errpipe[0]);
+        close(2);
+        if (dup2(errpipe[1], 2) < 0) {
+            HYDU_Error_printf("dup2 error (errno: %d)\n", errno);
+            status = HYD_SOCK_ERROR;
+            goto fn_fail;
+        }
+
+        if (in != NULL) {
+            close(inpipe[1]);
+            close(0);
+            if (dup2(inpipe[0], 0) < 0) {
+                HYDU_Error_printf("dup2 error (errno: %d)\n", errno);
+                status = HYD_SOCK_ERROR;
+                goto fn_fail;
+            }
+        }
+
+        if (chdir(handle.wdir) < 0) {
+            if (chdir(getenv("HOME")) < 0) {
+                HYDU_Error_printf("unable to set working directory to %s\n", handle.wdir);
+                status = HYD_INTERNAL_ERROR;
+                goto fn_fail;
+            }
+        }
+
+        /* execvp the process */
+        if (execvp(client_arg[0], client_arg) < 0) {
+            HYDU_Error_printf("execvp error\n");
+            status = HYD_INTERNAL_ERROR;
+            goto fn_fail;
+        }
+    }
+    else {      /* Parent process */
+        close(outpipe[1]);
+        close(errpipe[1]);
+        if (in)
+            *in = inpipe[1];
+        if (out)
+            *out = outpipe[0];
+        if (err)
+            *err = errpipe[0];
+    }
+
+    if (pid)
+        *pid = tpid;
+
+  fn_exit:
+    HYDU_FUNC_EXIT();
+    return status;
+
+  fn_fail:
+    goto fn_exit;
+}



More information about the mpich2-commits mailing list