[mpich2-commits] r7988 - in mpich2/trunk/src/pm/hydra: include ui/mpich utils/args

balaji at mcs.anl.gov balaji at mcs.anl.gov
Thu Feb 17 17:54:10 CST 2011


Author: balaji
Date: 2011-02-17 17:54:10 -0600 (Thu, 17 Feb 2011)
New Revision: 7988

Modified:
   mpich2/trunk/src/pm/hydra/include/hydra.h
   mpich2/trunk/src/pm/hydra/ui/mpich/Makefile.mk
   mpich2/trunk/src/pm/hydra/ui/mpich/utils.c
   mpich2/trunk/src/pm/hydra/utils/args/args.c
Log:
Initial code to check for a default configuration file for Hydra. We
now check for sysconfdir/mpiexec.hydra.conf and ~/.mpiexec.hydra.conf
for any default mpiexec configuration to use.

Reviewed by buntinas.

Modified: mpich2/trunk/src/pm/hydra/include/hydra.h
===================================================================
--- mpich2/trunk/src/pm/hydra/include/hydra.h	2011-02-17 22:48:02 UTC (rev 7987)
+++ mpich2/trunk/src/pm/hydra/include/hydra.h	2011-02-17 23:54:10 UTC (rev 7988)
@@ -441,7 +441,7 @@
 HYD_status HYDU_set_int_and_incr(char *arg, char ***argv, int *var);
 char *HYDU_getcwd(void);
 HYD_status HYDU_process_mfile_token(char *token, int newline, struct HYD_node **node_list);
-HYD_status HYDU_parse_hostfile(char *hostfile, struct HYD_node **node_list,
+HYD_status HYDU_parse_hostfile(const char *hostfile, struct HYD_node **node_list,
                                HYD_status(*process_token) (char *token, int newline,
                                                            struct HYD_node ** node_list));
 char *HYDU_find_full_path(const char *execname);

Modified: mpich2/trunk/src/pm/hydra/ui/mpich/Makefile.mk
===================================================================
--- mpich2/trunk/src/pm/hydra/ui/mpich/Makefile.mk	2011-02-17 22:48:02 UTC (rev 7987)
+++ mpich2/trunk/src/pm/hydra/ui/mpich/Makefile.mk	2011-02-17 23:54:10 UTC (rev 7988)
@@ -4,7 +4,7 @@
 #     See COPYRIGHT in top-level directory.
 #
 
-AM_CPPFLAGS += -I$(top_srcdir)/ui/utils
+AM_CPPFLAGS += -I$(top_srcdir)/ui/utils -DHYDRA_CONF_FILE=\"@sysconfdir@/mpiexec.hydra.conf\"
 
 bin_PROGRAMS += mpiexec.hydra
 

Modified: mpich2/trunk/src/pm/hydra/ui/mpich/utils.c
===================================================================
--- mpich2/trunk/src/pm/hydra/ui/mpich/utils.c	2011-02-17 22:48:02 UTC (rev 7987)
+++ mpich2/trunk/src/pm/hydra/ui/mpich/utils.c	2011-02-17 23:54:10 UTC (rev 7988)
@@ -437,11 +437,11 @@
     printf("    launch, except ':' is replaced with a new line character\n");
 }
 
-static HYD_status config_fn(char *arg, char ***argv)
+static HYD_status parse_config_file(const char *config_file)
 {
     HYD_status status = HYD_SUCCESS;
 
-    status = HYDU_parse_hostfile(**argv, NULL, process_config_token);
+    status = HYDU_parse_hostfile(config_file, NULL, process_config_token);
     HYDU_ERR_POP(status, "error parsing config file\n");
 
     status = parse_config_argv();
@@ -454,6 +454,20 @@
     goto fn_exit;
 }
 
+static HYD_status config_fn(char *arg, char ***argv)
+{
+    HYD_status status = HYD_SUCCESS;
+
+    status = parse_config_file(**argv);
+    HYDU_ERR_POP(status, "unable to parse config file %s\n", **argv);
+
+  fn_exit:
+    return status;
+
+  fn_fail:
+    goto fn_exit;
+}
+
 static void env_help_fn(void)
 {
     printf("\n");
@@ -1114,10 +1128,11 @@
 
 HYD_status HYD_uii_mpx_get_parameters(char **t_argv)
 {
-    int i;
+    int i, ret;
     char **argv = t_argv;
     char *progname = *argv;
-    char *post, *loc, *tmp[HYD_NUM_TMP_STRINGS];
+    char *post, *loc, *tmp[HYD_NUM_TMP_STRINGS], *conf_file;
+    const char *home;
     struct HYD_exec *exec;
     HYD_status status = HYD_SUCCESS;
 
@@ -1157,6 +1172,29 @@
         } while (++argv && *argv);
     } while (1);
 
+    ret = MPL_env2str("HOME", &home);
+    if (ret) {
+        int len = strlen(home) + strlen("/.mpiexec.hydra.conf") + 1;
+
+        HYDU_MALLOC(conf_file, char *, len, status);
+        MPL_snprintf(conf_file, len, "%s/.mpiexec.hydra.conf", home);
+
+        ret = open(conf_file, O_RDONLY);
+        if (ret < 0) {
+            HYDU_FREE(conf_file);
+            conf_file = HYDU_strdup(HYDRA_CONF_FILE);
+            ret = open(conf_file, O_RDONLY);
+        }
+
+        if (ret >= 0) {
+            /* We have successfully opened the file */
+            close(ret);
+            parse_config_file(conf_file);
+        }
+
+        HYDU_FREE(conf_file);
+    }
+
     /* Get the base path */
     /* Find the last '/' in the executable name */
     post = HYDU_strdup(progname);

Modified: mpich2/trunk/src/pm/hydra/utils/args/args.c
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/args/args.c	2011-02-17 22:48:02 UTC (rev 7987)
+++ mpich2/trunk/src/pm/hydra/utils/args/args.c	2011-02-17 23:54:10 UTC (rev 7988)
@@ -310,7 +310,7 @@
     goto fn_exit;
 }
 
-HYD_status HYDU_parse_hostfile(char *hostfile, struct HYD_node **node_list,
+HYD_status HYDU_parse_hostfile(const char *hostfile, struct HYD_node **node_list,
                                HYD_status(*process_token) (char *token, int newline,
                                                            struct HYD_node ** node_list))
 {



More information about the mpich2-commits mailing list