[mpich2-commits] r4085 - in mpich2/trunk/src/pm/hydra: include launcher/mpiexec utils/string

balaji at mcs.anl.gov balaji at mcs.anl.gov
Sun Mar 15 23:49:48 CDT 2009


Author: balaji
Date: 2009-03-15 23:49:48 -0500 (Sun, 15 Mar 2009)
New Revision: 4085

Modified:
   mpich2/trunk/src/pm/hydra/include/hydra_utils.h
   mpich2/trunk/src/pm/hydra/launcher/mpiexec/mpiexec.c
   mpich2/trunk/src/pm/hydra/launcher/mpiexec/utils.c
   mpich2/trunk/src/pm/hydra/utils/string/string.c
Log:
Allow mpiexec to take options of the form --bootstrap=ssh.

Modified: mpich2/trunk/src/pm/hydra/include/hydra_utils.h
===================================================================
--- mpich2/trunk/src/pm/hydra/include/hydra_utils.h	2009-03-16 03:32:00 UTC (rev 4084)
+++ mpich2/trunk/src/pm/hydra/include/hydra_utils.h	2009-03-16 04:49:48 UTC (rev 4085)
@@ -101,6 +101,7 @@
     }
 
 HYD_Status HYDU_String_alloc_and_join(char **strlist, char **strjoin);
+HYD_Status HYDU_String_break(char *str, char **str1, char **str2);
 HYD_Status HYDU_String_int_to_str(int x, char **str);
 
 

Modified: mpich2/trunk/src/pm/hydra/launcher/mpiexec/mpiexec.c
===================================================================
--- mpich2/trunk/src/pm/hydra/launcher/mpiexec/mpiexec.c	2009-03-16 03:32:00 UTC (rev 4084)
+++ mpich2/trunk/src/pm/hydra/launcher/mpiexec/mpiexec.c	2009-03-16 04:49:48 UTC (rev 4085)
@@ -19,8 +19,10 @@
 
     printf("Global Options (passed to all executables):\n");
     printf("\t--verbose                        [Verbose mode]\n");
+    printf("\t--version                        [Version information]\n");
     printf("\t--enable-x/--disable-x           [Enable or disable X forwarding]\n");
     printf("\t--proxy-port                     [Port on which proxies can listen]\n");
+    printf("\t--bootstrap                      [Bootstrap server to use]\n");
     printf("\t-genv {name} {value}             [Environment variable name and value]\n");
     printf("\t-genvlist {env1,env2,...}        [Environment variable list to pass]\n");
     printf("\t-genvnone                        [Do not pass any environment variables]\n");

Modified: mpich2/trunk/src/pm/hydra/launcher/mpiexec/utils.c
===================================================================
--- mpich2/trunk/src/pm/hydra/launcher/mpiexec/utils.c	2009-03-16 03:32:00 UTC (rev 4084)
+++ mpich2/trunk/src/pm/hydra/launcher/mpiexec/utils.c	2009-03-16 04:49:48 UTC (rev 4085)
@@ -14,7 +14,7 @@
 
 HYD_Handle handle;
 
-#define CHECK_NEXT_ARG_VALID(status) \
+#define CHECK_NEXT_ARG_VALID(status)            \
     { \
 	--argc; ++argv; \
 	if (!argc || !argv) { \
@@ -96,7 +96,7 @@
 {
     int argc = t_argc, i;
     char **argv = t_argv;
-    char *env_name, *env_value;
+    char *env_name, *env_value, *str1, *str2;
     HYD_Env_t *env;
     struct HYD_Proc_params *proc_params;
     HYD_Status status = HYD_SUCCESS;
@@ -119,15 +119,21 @@
 
     while (--argc && ++argv) {
 
+        status = HYDU_String_break(*argv, &str1, &str2);
+        if (status != HYD_SUCCESS) {
+            HYDU_Error_printf("string break returned error\n");
+            goto fn_fail;
+        }
+
         /* Help options */
-        if (!strcmp(*argv, "-h") || !strcmp(*argv, "--help") || !strcmp(*argv, "-help")) {
+        if (!strcmp(str1, "-h") || !strcmp(str1, "--help") || !strcmp(str1, "-help")) {
             /* Just return from this function; the main code will show the usage */
             status = HYD_INTERNAL_ERROR;
             goto fn_fail;
         }
 
         /* Check what debug level is requested */
-        if (!strcmp(*argv, "--verbose")) {
+        if (!strcmp(str1, "--verbose")) {
             /* Debug level already set */
             if (handle.debug != -1) {
                 HYDU_Error_printf
@@ -141,7 +147,7 @@
         }
 
         /* Version information */
-        if (!strcmp(*argv, "--version")) {
+        if (!strcmp(str1, "--version")) {
             /* Just show the version information and continue. This
              * option can be used in conjunction with other
              * options. */
@@ -151,8 +157,11 @@
         }
 
         /* Bootstrap server */
-        if (!strcmp(*argv, "--bootstrap")) {
-            CHECK_NEXT_ARG_VALID(status);
+        if (!strcmp(str1, "--bootstrap")) {
+            if (!str2) {
+                CHECK_NEXT_ARG_VALID(status);
+                str2 = *argv;
+            }
 
             if (handle.bootstrap != NULL) {
                 HYDU_Error_printf("Duplicate bootstrap setting; previously set to %s\n",
@@ -161,12 +170,12 @@
                 goto fn_fail;
             }
 
-            handle.bootstrap = MPIU_Strdup(*argv);
+            handle.bootstrap = MPIU_Strdup(str2);
             continue;
         }
 
         /* Check if X forwarding is explicitly set */
-        if (!strcmp(*argv, "--enable-x") || !strcmp(*argv, "--disable-x")) {
+        if (!strcmp(str1, "--enable-x") || !strcmp(str1, "--disable-x")) {
             /* X forwarding already enabled or disabled */
             if (handle.enablex != -1) {
                 HYDU_Error_printf
@@ -175,13 +184,16 @@
                 goto fn_fail;
             }
 
-            handle.enablex = !strcmp(*argv, "--enable-x");
+            handle.enablex = !strcmp(str1, "--enable-x");
             continue;
         }
 
         /* Check if the proxy port is set */
-        if (!strcmp(*argv, "--proxy-port")) {
-            CHECK_NEXT_ARG_VALID(status);
+        if (!strcmp(str1, "--proxy-port")) {
+            if (!str2) {
+                CHECK_NEXT_ARG_VALID(status);
+                str2 = *argv;
+            }
 
             if (handle.proxy_port != -1) {
                 HYDU_Error_printf("Duplicate proxy port setting; previously set to %d\n",
@@ -190,13 +202,13 @@
                 goto fn_fail;
             }
 
-            handle.proxy_port = atoi(*argv);
+            handle.proxy_port = atoi(str2);
             continue;
         }
 
         /* Check what all environment variables need to be propagated */
-        if (!strcmp(*argv, "-genvall") || !strcmp(*argv, "-genvnone") ||
-            !strcmp(*argv, "-genvlist")) {
+        if (!strcmp(str1, "-genvall") || !strcmp(str1, "-genvnone") ||
+            !strcmp(str1, "-genvlist")) {
             /* propagation already set */
             if (handle.prop != HYD_ENV_PROP_UNSET) {
                 HYDU_Error_printf
@@ -205,16 +217,21 @@
                 goto fn_fail;
             }
 
-            if (!strcmp(*argv, "-genvall")) {
+            if (!strcmp(str1, "-genvall")) {
                 handle.prop = HYD_ENV_PROP_ALL;
             }
-            else if (!strcmp(*argv, "-genvnone")) {
+            else if (!strcmp(str1, "-genvnone")) {
                 handle.prop = HYD_ENV_PROP_NONE;
             }
-            else if (!strcmp(*argv, "-genvlist")) {
+            else if (!strcmp(str1, "-genvlist")) {
                 handle.prop = HYD_ENV_PROP_LIST;
-                CHECK_NEXT_ARG_VALID(status);
-                env_name = strtok(*argv, ",");
+
+                if (!str2) {
+                    CHECK_NEXT_ARG_VALID(status);
+                    str2 = *argv;
+                }
+
+                env_name = strtok(str2, ",");
                 do {
                     status = HYDU_Env_create(&env, env_name, NULL);
                     if (status != HYD_SUCCESS) {
@@ -233,8 +250,8 @@
         }
 
         /* Check what all environment variables need to be propagated */
-        if (!strcmp(*argv, "-envall") || !strcmp(*argv, "-envnone") ||
-            !strcmp(*argv, "-envlist")) {
+        if (!strcmp(str1, "-envall") || !strcmp(str1, "-envnone") ||
+            !strcmp(str1, "-envlist")) {
             status = get_current_proc_params(&proc_params);
             if (status != HYD_SUCCESS) {
                 HYDU_Error_printf("get_current_proc_params returned error\n");
@@ -250,17 +267,22 @@
                 goto fn_fail;
             }
 
-            if (!strcmp(*argv, "-envall")) {
+            if (!strcmp(str1, "-envall")) {
                 proc_params->prop = HYD_ENV_PROP_ALL;
             }
-            else if (!strcmp(*argv, "-envnone")) {
+            else if (!strcmp(str1, "-envnone")) {
                 proc_params->prop = HYD_ENV_PROP_NONE;
             }
-            else if (!strcmp(*argv, "-envlist")) {
+            else if (!strcmp(str1, "-envlist")) {
                 proc_params->prop = HYD_ENV_PROP_LIST;
-                CHECK_NEXT_ARG_VALID(status);
+
+                if (!str2) {
+                    CHECK_NEXT_ARG_VALID(status);
+                    str2 = *argv;
+                }
+
                 do {
-                    env_name = strtok(*argv, ",");
+                    env_name = strtok(str2, ",");
                     if (env_name == NULL)
                         break;
 
@@ -281,9 +303,12 @@
         }
 
         /* Add additional environment variables */
-        if (!strcmp(*argv, "-genv") || !strcmp(*argv, "-env")) {
-            CHECK_NEXT_ARG_VALID(status);
-            env_name = MPIU_Strdup(*argv);
+        if (!strcmp(str1, "-genv") || !strcmp(str1, "-env")) {
+            if (!str2) {
+                CHECK_NEXT_ARG_VALID(status);
+                str2 = *argv;
+            }
+            env_name = MPIU_Strdup(str2);
 
             CHECK_NEXT_ARG_VALID(status);
             env_value = MPIU_Strdup(*argv);
@@ -294,7 +319,7 @@
                 goto fn_fail;
             }
 
-            if (!strcmp(*argv, "-genv"))
+            if (!strcmp(str1, "-genv"))
                 HYDU_Env_add_to_list(&handle.user_env, *env);
             else {
                 status = get_current_proc_params(&proc_params);
@@ -310,14 +335,20 @@
             continue;
         }
 
-        if (!strcmp(*argv, "-wdir")) {
-            CHECK_NEXT_ARG_VALID(status);
-            handle.wdir = MPIU_Strdup(*argv);
+        if (!strcmp(str1, "-wdir")) {
+            if (!str2) {
+                CHECK_NEXT_ARG_VALID(status);
+                str2 = *argv;
+            }
+            handle.wdir = MPIU_Strdup(str2);
             continue;
         }
 
-        if (!strcmp(*argv, "-n") || !strcmp(*argv, "-np")) {
-            CHECK_NEXT_ARG_VALID(status);
+        if (!strcmp(str1, "-n") || !strcmp(str1, "-np")) {
+            if (!str2) {
+                CHECK_NEXT_ARG_VALID(status);
+                str2 = *argv;
+            }
 
             status = get_current_proc_params(&proc_params);
             if (status != HYD_SUCCESS) {
@@ -334,14 +365,16 @@
                 goto fn_fail;
             }
 
-            proc_params->exec_proc_count = atoi(*argv);
-
+            proc_params->exec_proc_count = atoi(str2);
             continue;
         }
 
-        if (!strcmp(*argv, "-f")) {
-            CHECK_NEXT_ARG_VALID(status);
-            handle.host_file = MPIU_Strdup(*argv);
+        if (!strcmp(str1, "-f")) {
+            if (!str2) {
+                CHECK_NEXT_ARG_VALID(status);
+                str2 = *argv;
+            }
+            handle.host_file = MPIU_Strdup(str2);
             continue;
         }
 

Modified: mpich2/trunk/src/pm/hydra/utils/string/string.c
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/string/string.c	2009-03-16 03:32:00 UTC (rev 4084)
+++ mpich2/trunk/src/pm/hydra/utils/string/string.c	2009-03-16 04:49:48 UTC (rev 4085)
@@ -34,6 +34,37 @@
 }
 
 
+HYD_Status HYDU_String_break(char *str, char **str1, char **str2)
+{
+    int i;
+    HYD_Status status = HYD_SUCCESS;
+
+    HYDU_FUNC_ENTER();
+
+    if (str == NULL) {
+        str = HYD_INTERNAL_ERROR;
+        goto fn_fail;
+    }
+
+    *str1 = MPIU_Strdup(str);
+    for (i = 0; (*str1)[i] && ((*str1)[i] != '='); i++);
+
+    if ((*str1)[i] == 0) /* End of the string */
+        *str2 = NULL;
+    else {
+        *str2 = &((*str1)[i+1]);
+        (*str1)[i] = 0;
+    }
+
+  fn_exit:
+    HYDU_FUNC_EXIT();
+    return status;
+
+  fn_fail:
+    goto fn_exit;
+}
+
+
 HYD_Status HYDU_String_int_to_str(int x, char **str)
 {
     int len = 1, max = 10, y;



More information about the mpich2-commits mailing list