[mpich-commits] [mpich] MPICH primary repository branch, master, updated. v3.0.3-22-gb98c7fd

mysql vizuser noreply at mpich.org
Thu Apr 18 23:50:28 CDT 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "MPICH primary repository".

The branch, master has been updated
       via  b98c7fd361541659d7e8fb6ef7fc76547024ad75 (commit)
       via  30d28c6214cf8e94838e2a726f399e568428c8a4 (commit)
      from  89fb23ebb2ae5af69d75fb75e590c4c57e81d238 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.mpich.org/mpich.git/commitdiff/b98c7fd361541659d7e8fb6ef7fc76547024ad75

commit b98c7fd361541659d7e8fb6ef7fc76547024ad75
Author: Pavan Balaji <balaji at mcs.anl.gov>
Date:   Thu Apr 18 20:29:52 2013 -0500

    Added ability to allgather codes to all the proxies during a PMI
    barrier.  This allows all gets of the keys to occur locally without
    having to communicate with the mpiexec process.
    
    Also, got rid of unscalable parsing code as well as incorrect tmp
    length usage without checking for how many arguments were actually
    passed between the proxy and mpiexec.
    
    No reviewer.

diff --git a/src/pm/hydra/pm/pmiserv/common.c b/src/pm/hydra/pm/pmiserv/common.c
index 20dc433..d8f70ac 100644
--- a/src/pm/hydra/pm/pmiserv/common.c
+++ b/src/pm/hydra/pm/pmiserv/common.c
@@ -23,11 +23,9 @@ void HYD_pmcd_init_header(struct HYD_pmcd_hdr *hdr)
 HYD_status HYD_pmcd_pmi_parse_pmi_cmd(char *obuf, int pmi_version, char **pmi_cmd,
                                       char *args[])
 {
-    char *tbuf = NULL, *seg, *str1 = NULL, *cmd;
-    char *buf;
-    char *tmp[HYD_NUM_TMP_STRINGS], *targs[HYD_NUM_TMP_STRINGS];
+    char *str1 = NULL, *cmd, *buf;
     const char *delim;
-    int i, j, k;
+    int i;
     HYD_status status = HYD_SUCCESS;
 
     HYDU_FUNC_ENTER();
@@ -42,70 +40,17 @@ HYD_status HYD_pmcd_pmi_parse_pmi_cmd(char *obuf, int pmi_version, char **pmi_cm
             delim = " ";
         else
             delim = "\n";
-
-        /* Here we only get PMI-1 commands or backward compatible
-         * PMI-2 commands, so we always explicitly use the PMI-1
-         * delimiter. This allows us to get backward-compatible PMI-2
-         * commands interleaved with regular PMI-2 commands. */
-        tbuf = HYDU_strdup(buf);
-        cmd = strtok(tbuf, delim);
-        for (i = 0; i < HYD_NUM_TMP_STRINGS; i++) {
-            targs[i] = strtok(NULL, delim);
-            if (targs[i] == NULL)
-                break;
-        }
-
-        /* Make a pass through targs and merge space separated
-         * arguments which are actually part of the same key */
-        k = 0;
-        for (i = 0; targs[i]; i++) {
-            if (!strrchr(targs[i], ' ')) {
-                /* no spaces */
-                args[k++] = HYDU_strdup(targs[i]);
-            }
-            else {
-                /* space in the argument; each segment is either a new
-                 * key, or a space-separated part of the previous
-                 * key */
-                j = 0;
-                seg = strtok(targs[i], " ");
-                while (1) {
-                    if (!seg || strrchr(seg, '=')) {
-                        /* segment has an '='; it's a start of a new key */
-                        if (j) {
-                            tmp[j++] = NULL;
-                            status = HYDU_str_alloc_and_join(tmp, &args[k++]);
-                            HYDU_ERR_POP(status, "error while joining strings\n");
-                            HYDU_free_strlist(tmp);
-                        }
-                        j = 0;
-
-                        if (!seg)
-                            break;
-                    }
-                    else {
-                        /* no '='; part of the previous key */
-                        tmp[j++] = HYDU_strdup(" ");
-                    }
-                    tmp[j++] = HYDU_strdup(seg);
-
-                    seg = strtok(NULL, " ");
-                }
-            }
-        }
-        args[k++] = NULL;
     }
     else {      /* PMI-v2 */
         delim = ";";
+    }
 
-        tbuf = HYDU_strdup(buf);
-        cmd = strtok(tbuf, delim);
-        for (i = 0; i < HYD_NUM_TMP_STRINGS; i++) {
-            args[i] = strtok(NULL, delim);
-            if (args[i] == NULL)
-                break;
-            args[i] = HYDU_strdup(args[i]);
-        }
+    cmd = strtok(buf, delim);
+    for (i = 0;; i++) {
+        args[i] = strtok(NULL, delim);
+        if (args[i] == NULL)
+            break;
+        args[i] = HYDU_strdup(args[i]);
     }
 
     /* Search for the PMI command in our table */
@@ -114,8 +59,6 @@ HYD_status HYD_pmcd_pmi_parse_pmi_cmd(char *obuf, int pmi_version, char **pmi_cm
 
   fn_exit:
     HYDU_FREE(buf);
-    if (tbuf)
-        HYDU_FREE(tbuf);
     if (str1)
         HYDU_FREE(str1);
     HYDU_FUNC_EXIT();
diff --git a/src/pm/hydra/pm/pmiserv/common.h b/src/pm/hydra/pm/pmiserv/common.h
index ad1c784..53e4eb8 100644
--- a/src/pm/hydra/pm/pmiserv/common.h
+++ b/src/pm/hydra/pm/pmiserv/common.h
@@ -14,6 +14,9 @@
 #define PMI_MAXVALLEN    (1024) /* max length of value in keyval space */
 #define PMI_MAXKVSLEN    (256)  /* max length of various names */
 
+#define MAX_PMI_ARGS  (1024)  /* number of arguments in a PMI command */
+#define MAX_PMI_INTERNAL_ARGS   (65536)  /* number of arguments in internal communication */
+
 struct HYD_pmcd_pmi_kvs_pair {
     char key[PMI_MAXKEYLEN];
     char val[PMI_MAXVALLEN];
diff --git a/src/pm/hydra/pm/pmiserv/pmip_cb.c b/src/pm/hydra/pm/pmiserv/pmip_cb.c
index 9705926..8b6710d 100644
--- a/src/pm/hydra/pm/pmiserv/pmip_cb.c
+++ b/src/pm/hydra/pm/pmiserv/pmip_cb.c
@@ -208,7 +208,7 @@ static HYD_status check_pmi_cmd(char **buf, int *pmi_version, int *repeat)
 
 static HYD_status pmi_cb(int fd, HYD_event_t events, void *userp)
 {
-    char *buf = NULL, *pmi_cmd = NULL, *args[HYD_NUM_TMP_STRINGS] = { 0 };
+    char *buf = NULL, *pmi_cmd = NULL, *args[MAX_PMI_ARGS] = { 0 };
     int closed, repeat, sent, i = -1, linelen, pid = -1;
     struct HYD_pmcd_hdr hdr;
     struct HYD_pmcd_pmip_pmi_handle *h;
@@ -369,7 +369,7 @@ static HYD_status pmi_cb(int fd, HYD_event_t events, void *userp)
 static HYD_status handle_pmi_response(int fd, struct HYD_pmcd_hdr hdr)
 {
     int count, closed, sent;
-    char *buf = NULL, *pmi_cmd = NULL, *args[HYD_NUM_TMP_STRINGS] = { 0 };
+    char *buf = NULL, *pmi_cmd = NULL, *args[MAX_PMI_INTERNAL_ARGS] = { 0 };
     struct HYD_pmcd_pmip_pmi_handle *h;
     HYD_status status = HYD_SUCCESS;
 
diff --git a/src/pm/hydra/pm/pmiserv/pmip_pmi_v1.c b/src/pm/hydra/pm/pmiserv/pmip_pmi_v1.c
index 8c90936..bfd79a1 100644
--- a/src/pm/hydra/pm/pmiserv/pmip_pmi_v1.c
+++ b/src/pm/hydra/pm/pmiserv/pmip_pmi_v1.c
@@ -11,15 +11,36 @@
 #include "topo.h"
 #include "hydt_ftb.h"
 
-static HYD_status send_cmd_upstream(const char *start, int fd, char *args[])
+#define debug(...)                              \
+    {                                           \
+        if (HYD_pmcd_pmip.user_global.debug)    \
+            HYDU_dump(stdout, __VA_ARGS__);     \
+    }
+
+#define CACHE_PUT_KEYVAL_MAXLEN  (65536)
+
+static struct {
+    char *keyval[CACHE_PUT_KEYVAL_MAXLEN + 1];
+    int keyval_len;
+} cache_put;
+
+static struct {
+    char **key;
+    char **val;
+    int keyval_len;
+} cache_get;
+
+static HYD_status send_cmd_upstream(const char *start, int fd, int num_args, char *args[])
 {
     int i, j, sent, closed;
-    char *tmp[HYD_NUM_TMP_STRINGS], *buf;
+    char **tmp, *buf;
     struct HYD_pmcd_hdr hdr;
     HYD_status status = HYD_SUCCESS;
 
     HYDU_FUNC_ENTER();
 
+    HYDU_MALLOC(tmp, char **, (2 * num_args + 1) * sizeof(char *), status);
+
     j = 0;
     tmp[j++] = HYDU_strdup(start);
     for (i = 0; args[i]; i++) {
@@ -44,9 +65,7 @@ static HYD_status send_cmd_upstream(const char *start, int fd, char *args[])
     HYDU_ERR_POP(status, "unable to send PMI header upstream\n");
     HYDU_ASSERT(!closed, status);
 
-    if (HYD_pmcd_pmip.user_global.debug) {
-        HYDU_dump(stdout, "forwarding command (%s) upstream\n", buf);
-    }
+    debug("forwarding command (%s) upstream\n", buf);
 
     status = HYDU_sock_write(HYD_pmcd_pmip.upstream.control, buf, hdr.buflen, &sent, &closed,
                              HYDU_SOCK_COMM_MSGWAIT);
@@ -70,9 +89,7 @@ static HYD_status send_cmd_downstream(int fd, const char *cmd)
 
     HYDU_FUNC_ENTER();
 
-    if (HYD_pmcd_pmip.user_global.debug) {
-        HYDU_dump(stdout, "PMI response: %s", cmd);
-    }
+    debug("PMI response: %s", cmd);
 
     status = HYDU_sock_write(fd, cmd, strlen(cmd), &sent, &closed, HYDU_SOCK_COMM_MSGWAIT);
     HYDU_ERR_POP(status, "error writing PMI line\n");
@@ -89,10 +106,38 @@ static HYD_status send_cmd_downstream(int fd, const char *cmd)
     goto fn_exit;
 }
 
+static HYD_status cache_put_flush(int fd)
+{
+    int i;
+    HYD_status status = HYD_SUCCESS;
+
+    HYDU_FUNC_ENTER();
+
+    if (cache_put.keyval_len == 0)
+        goto fn_exit;
+
+    debug("flushing %d put command(s) out\n", cache_put.keyval_len);
+
+    status = send_cmd_upstream("cmd=put ", fd, cache_put.keyval_len, cache_put.keyval);
+    HYDU_ERR_POP(status, "error sending command upstream\n");
+
+    for (i = 0; i < cache_put.keyval_len; i++)
+        HYDU_FREE(cache_put.keyval[i]);
+    cache_put.keyval_len = 0;
+
+  fn_exit:
+    HYDU_FUNC_EXIT();
+    return status;
+
+  fn_fail:
+    goto fn_exit;
+}
+
 static HYD_status fn_init(int fd, char *args[])
 {
-    int pmi_version, pmi_subversion;
+    int pmi_version, pmi_subversion, i;
     const char *tmp;
+    static int global_init = 1;
     HYD_status status = HYD_SUCCESS;
 
     HYDU_FUNC_ENTER();
@@ -114,6 +159,16 @@ static HYD_status fn_init(int fd, char *args[])
     HYDU_ERR_POP(status, "error sending PMI response\n");
     HYDU_FREE(tmp);
 
+    /* initialize some structures; these are initialized exactly once,
+     * even if the init command is sent once from each process. */
+    if (global_init) {
+        for (i = 0; i < CACHE_PUT_KEYVAL_MAXLEN + 1; i++)
+            cache_put.keyval[i] = NULL;
+        cache_put.keyval_len = 0;
+        cache_get.keyval_len = 0;
+        global_init = 0;
+    }
+
   fn_exit:
     HYDU_FUNC_EXIT();
     return status;
@@ -327,7 +382,7 @@ static HYD_status fn_get_usize(int fd, char *args[])
 
 static HYD_status fn_get(int fd, char *args[])
 {
-    char *tmp[HYD_NUM_TMP_STRINGS], *cmd, *key;
+    char *tmp[HYD_NUM_TMP_STRINGS], *cmd, *key, *val;
     struct HYD_pmcd_token *tokens;
     int token_count, i;
     HYD_status status = HYD_SUCCESS;
@@ -357,8 +412,114 @@ static HYD_status fn_get(int fd, char *args[])
         HYDU_FREE(cmd);
     }
     else {
-        status = send_cmd_upstream("cmd=get ", fd, args);
-        HYDU_ERR_POP(status, "error sending command upstream\n");
+        val = NULL;
+        for (i = 0; i < cache_get.keyval_len; i++) {
+            if (!strcmp(cache_get.key[i], key)) {
+                val = cache_get.val[i];
+                break;
+            }
+        }
+
+        i = 0;
+        tmp[i++] = HYDU_strdup("cmd=get_result rc=");
+        if (val) {
+            tmp[i++] = HYDU_strdup("0 msg=success value=");
+            tmp[i++] = HYDU_strdup(val);
+        }
+        else {
+            tmp[i++] = HYDU_strdup("-1 msg=key_");
+            tmp[i++] = HYDU_strdup(key);
+            tmp[i++] = HYDU_strdup("_not_found value=unknown");
+        }
+        tmp[i++] = HYDU_strdup("\n");
+        tmp[i++] = NULL;
+
+        status = HYDU_str_alloc_and_join(tmp, &cmd);
+        HYDU_ERR_POP(status, "unable to join strings\n");
+        HYDU_free_strlist(tmp);
+
+        status = send_cmd_downstream(fd, cmd);
+        HYDU_ERR_POP(status, "error sending command downstream\n");
+        HYDU_FREE(cmd);
+    }
+
+  fn_exit:
+    HYD_pmcd_pmi_free_tokens(tokens, token_count);
+    HYDU_FUNC_EXIT();
+    return status;
+
+  fn_fail:
+    goto fn_exit;
+}
+
+static HYD_status fn_put(int fd, char *args[])
+{
+    char *tmp[HYD_NUM_TMP_STRINGS], *cmd;
+    char *key, *val;
+    struct HYD_pmcd_token *tokens;
+    int token_count, i;
+    HYD_status status = HYD_SUCCESS;
+
+    HYDU_FUNC_ENTER();
+
+    status = HYD_pmcd_pmi_args_to_tokens(args, &tokens, &token_count);
+    HYDU_ERR_POP(status, "unable to convert args to tokens\n");
+
+    key = HYD_pmcd_pmi_find_token_keyval(tokens, token_count, "key");
+    HYDU_ERR_CHKANDJUMP(status, key == NULL, HYD_INTERNAL_ERROR,
+                        "unable to find token: key\n");
+
+    val = HYD_pmcd_pmi_find_token_keyval(tokens, token_count, "value");
+    if (val == NULL)
+        val = HYDU_strdup("");
+
+    /* add to the cache */
+    i = 0;
+    tmp[i++] = HYDU_strdup(key);
+    tmp[i++] = HYDU_strdup("=");
+    tmp[i++] = HYDU_strdup(val);
+    tmp[i++] = NULL;
+
+    status = HYDU_str_alloc_and_join(tmp, &cmd);
+    HYDU_ERR_POP(status, "unable to join strings\n");
+    HYDU_free_strlist(tmp);
+
+    cache_put.keyval[cache_put.keyval_len++] = cmd;
+    debug("cached command: %s\n", cmd);
+
+    if (cache_put.keyval_len >= CACHE_PUT_KEYVAL_MAXLEN)
+        cache_put_flush(fd);
+
+    status = send_cmd_downstream(fd, "cmd=put_result rc=0 msg=success\n");
+    HYDU_ERR_POP(status, "error sending PMI response\n");
+
+  fn_exit:
+    HYD_pmcd_pmi_free_tokens(tokens, token_count);
+    HYDU_FUNC_EXIT();
+    return status;
+
+  fn_fail:
+    goto fn_exit;
+}
+
+static HYD_status fn_keyval_cache(int fd, char *args[])
+{
+    struct HYD_pmcd_token *tokens;
+    int token_count, i;
+    HYD_status status = HYD_SUCCESS;
+
+    HYDU_FUNC_ENTER();
+
+    status = HYD_pmcd_pmi_args_to_tokens(args, &tokens, &token_count);
+    HYDU_ERR_POP(status, "unable to convert args to tokens\n");
+
+    cache_get.keyval_len = token_count;
+    HYDU_MALLOC(cache_get.key, char **, cache_get.keyval_len * sizeof(char *), status);
+    HYDU_MALLOC(cache_get.val, char **, cache_get.keyval_len * sizeof(char *), status);
+
+    for (i = 0; i < token_count; i++) {
+        cache_get.key[i] = HYDU_strdup(tokens[i].key);
+        cache_get.val[i] = HYDU_strdup(tokens[i].val);
     }
 
   fn_exit:
@@ -381,7 +542,9 @@ static HYD_status fn_barrier_in(int fd, char *args[])
     if (barrier_count == HYD_pmcd_pmip.local.proxy_process_count) {
         barrier_count = 0;
 
-        status = send_cmd_upstream("cmd=barrier_in", fd, args);
+        cache_put_flush(fd);
+
+        status = send_cmd_upstream("cmd=barrier_in", fd, 0, args);
         HYDU_ERR_POP(status, "error sending command upstream\n");
     }
 
@@ -451,6 +614,8 @@ static struct HYD_pmcd_pmip_pmi_handle pmi_v1_handle_fns_foo[] = {
     {"get_my_kvsname", fn_get_my_kvsname},
     {"get_universe_size", fn_get_usize},
     {"get", fn_get},
+    {"put", fn_put},
+    {"keyval_cache", fn_keyval_cache},
     {"barrier_in", fn_barrier_in},
     {"barrier_out", fn_barrier_out},
     {"finalize", fn_finalize},
diff --git a/src/pm/hydra/pm/pmiserv/pmiserv_cb.c b/src/pm/hydra/pm/pmiserv/pmiserv_cb.c
index 3aa05e3..0328f28 100644
--- a/src/pm/hydra/pm/pmiserv/pmiserv_cb.c
+++ b/src/pm/hydra/pm/pmiserv/pmiserv_cb.c
@@ -15,7 +15,7 @@
 
 static HYD_status handle_pmi_cmd(int fd, int pgid, int pid, char *buf, int pmi_version)
 {
-    char *args[HYD_NUM_TMP_STRINGS], *cmd = NULL;
+    char *args[MAX_PMI_ARGS], *cmd = NULL;
     struct HYD_pmcd_pmi_handle *h;
     HYD_status status = HYD_SUCCESS;
 
diff --git a/src/pm/hydra/pm/pmiserv/pmiserv_pmi_v1.c b/src/pm/hydra/pm/pmiserv/pmiserv_pmi_v1.c
index 47b28ba..a66a306 100644
--- a/src/pm/hydra/pm/pmiserv/pmiserv_pmi_v1.c
+++ b/src/pm/hydra/pm/pmiserv/pmiserv_pmi_v1.c
@@ -47,14 +47,17 @@ static HYD_status cmd_response(int fd, int pid, const char *cmd)
 static HYD_status fn_barrier_in(int fd, int pid, int pgid, char *args[])
 {
     struct HYD_proxy *proxy, *tproxy;
-    const char *cmd;
-    int proxy_count;
+    struct HYD_pmcd_pmi_pg_scratch *pg_scratch;
+    int proxy_count, keyval_count, i, arg_count;
+    struct HYD_pmcd_pmi_kvs_pair *run;
+    char **tmp, *cmd;
     HYD_status status = HYD_SUCCESS;
 
     HYDU_FUNC_ENTER();
 
     proxy = HYD_pmcd_pmi_find_proxy(fd);
     HYDU_ASSERT(proxy, status);
+    pg_scratch = (struct HYD_pmcd_pmi_pg_scratch *) proxy->pg->pg_scratch;
 
     proxy_count = 0;
     for (tproxy = proxy->pg->proxy_list; tproxy; tproxy = tproxy->next)
@@ -63,88 +66,61 @@ static HYD_status fn_barrier_in(int fd, int pid, int pgid, char *args[])
     proxy->pg->barrier_count++;
     if (proxy->pg->barrier_count == proxy_count) {
         proxy->pg->barrier_count = 0;
-        cmd = "cmd=barrier_out\n";
 
         for (tproxy = proxy->pg->proxy_list; tproxy; tproxy = tproxy->next) {
-            status = cmd_response(tproxy->control_fd, pid, cmd);
-            HYDU_ERR_POP(status, "error writing PMI line\n");
-        }
-    }
-
-  fn_exit:
-    HYDU_FUNC_EXIT();
-    return status;
-
-  fn_fail:
-    goto fn_exit;
-}
-
-static HYD_status fn_put(int fd, int pid, int pgid, char *args[])
-{
-    int i, ret;
-    struct HYD_proxy *proxy;
-    struct HYD_pmcd_pmi_pg_scratch *pg_scratch;
-    char *kvsname, *key, *val;
-    char *tmp[HYD_NUM_TMP_STRINGS], *cmd;
-    struct HYD_pmcd_token *tokens;
-    int token_count;
-    HYD_status status = HYD_SUCCESS;
-
-    HYDU_FUNC_ENTER();
-
-    status = HYD_pmcd_pmi_args_to_tokens(args, &tokens, &token_count);
-    HYDU_ERR_POP(status, "unable to convert args to tokens\n");
-
-    kvsname = HYD_pmcd_pmi_find_token_keyval(tokens, token_count, "kvsname");
-    HYDU_ERR_CHKANDJUMP(status, kvsname == NULL, HYD_INTERNAL_ERROR,
-                        "unable to find token: kvsname\n");
-
-    key = HYD_pmcd_pmi_find_token_keyval(tokens, token_count, "key");
-    HYDU_ERR_CHKANDJUMP(status, key == NULL, HYD_INTERNAL_ERROR,
-                        "unable to find token: key\n");
-
-    val = HYD_pmcd_pmi_find_token_keyval(tokens, token_count, "value");
-    if (val == NULL) {
-        /* the user sent an empty string */
-        val = HYDU_strdup("");
-    }
-
-    proxy = HYD_pmcd_pmi_find_proxy(fd);
-    HYDU_ASSERT(proxy, status);
-
-    pg_scratch = (struct HYD_pmcd_pmi_pg_scratch *) proxy->pg->pg_scratch;
+            /* send all available keyvals downstream */
+            keyval_count = 0;
+            for (run = pg_scratch->kvs->key_pair; run; run = run->next)
+                keyval_count++;
+
+            if (keyval_count) {
+                HYDU_MALLOC(tmp, char **, (4 * keyval_count + 2) * sizeof(char *), status);
+
+                arg_count = 1;
+                i = 0;
+                tmp[i++] = HYDU_strdup("cmd=keyval_cache ");
+                for (run = pg_scratch->kvs->key_pair; run; run = run->next) {
+                    tmp[i++] = HYDU_strdup(run->key);
+                    tmp[i++] = HYDU_strdup("=");
+                    tmp[i++] = HYDU_strdup(run->val);
+                    tmp[i++] = HYDU_strdup(" ");
+
+                    arg_count++;
+                    if (arg_count >= MAX_PMI_INTERNAL_ARGS) {
+                        tmp[i++] = NULL;
+
+                        status = HYDU_str_alloc_and_join(tmp, &cmd);
+                        HYDU_ERR_POP(status, "unable to join strings\n");
+                        HYDU_free_strlist(tmp);
+
+                        status = cmd_response(tproxy->control_fd, pid, cmd);
+                        HYDU_ERR_POP(status, "error writing PMI line\n");
+                        HYDU_FREE(cmd);
+
+                        i = 0;
+                        tmp[i++] = HYDU_strdup("cmd=keyval_cache ");
+                    }
+                }
+                tmp[i++] = NULL;
 
-    if (strcmp(pg_scratch->kvs->kvsname, kvsname))
-        HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR,
-                            "kvsname (%s) does not match this group's kvs space (%s)\n",
-                            kvsname, pg_scratch->kvs->kvsname);
+                if (arg_count > 1) {
+                    status = HYDU_str_alloc_and_join(tmp, &cmd);
+                    HYDU_ERR_POP(status, "unable to join strings\n");
+                    HYDU_free_strlist(tmp);
 
-    status = HYD_pmcd_pmi_add_kvs(key, val, pg_scratch->kvs, &ret);
-    HYDU_ERR_POP(status, "unable to add keypair to kvs\n");
+                    status = cmd_response(tproxy->control_fd, pid, cmd);
+                    HYDU_ERR_POP(status, "error writing PMI line\n");
+                    HYDU_FREE(cmd);
+                }
+            }
 
-    i = 0;
-    tmp[i++] = HYDU_strdup("cmd=put_result rc=");
-    tmp[i++] = HYDU_int_to_str(ret);
-    if (ret == 0) {
-        tmp[i++] = HYDU_strdup(" msg=success");
-    }
-    else {
-        tmp[i++] = HYDU_strdup(" msg=duplicate_key");
-        tmp[i++] = HYDU_strdup(key);
+            /* complete barrier */
+            status = cmd_response(tproxy->control_fd, pid, "cmd=barrier_out\n");
+            HYDU_ERR_POP(status, "error writing PMI line\n");
+        }
     }
-    tmp[i++] = HYDU_strdup("\n");
-    tmp[i++] = NULL;
-
-    status = HYDU_str_alloc_and_join(tmp, &cmd);
-    HYDU_ERR_POP(status, "unable to join strings\n");
-    HYDU_free_strlist(tmp);
-
-    status = cmd_response(fd, pid, cmd);
-    HYDU_ERR_POP(status, "error writing PMI line\n");
-    HYDU_FREE(cmd);
 
   fn_exit:
-    HYD_pmcd_pmi_free_tokens(tokens, token_count);
     HYDU_FUNC_EXIT();
     return status;
 
@@ -152,16 +128,12 @@ static HYD_status fn_put(int fd, int pid, int pgid, char *args[])
     goto fn_exit;
 }
 
-static HYD_status fn_get(int fd, int pid, int pgid, char *args[])
+static HYD_status fn_put(int fd, int pid, int pgid, char *args[])
 {
-    int i;
     struct HYD_proxy *proxy;
     struct HYD_pmcd_pmi_pg_scratch *pg_scratch;
-    struct HYD_pmcd_pmi_kvs_pair *run;
-    char *kvsname, *key, *val;
-    char *tmp[HYD_NUM_TMP_STRINGS], *cmd;
     struct HYD_pmcd_token *tokens;
-    int token_count;
+    int token_count, i, ret;
     HYD_status status = HYD_SUCCESS;
 
     HYDU_FUNC_ENTER();
@@ -169,60 +141,14 @@ static HYD_status fn_get(int fd, int pid, int pgid, char *args[])
     status = HYD_pmcd_pmi_args_to_tokens(args, &tokens, &token_count);
     HYDU_ERR_POP(status, "unable to convert args to tokens\n");
 
-    kvsname = HYD_pmcd_pmi_find_token_keyval(tokens, token_count, "kvsname");
-    HYDU_ERR_CHKANDJUMP(status, kvsname == NULL, HYD_INTERNAL_ERROR,
-                        "unable to find token: kvsname\n");
-
-    key = HYD_pmcd_pmi_find_token_keyval(tokens, token_count, "key");
-    HYDU_ERR_CHKANDJUMP(status, key == NULL, HYD_INTERNAL_ERROR,
-                        "unable to find token: key\n");
-
     proxy = HYD_pmcd_pmi_find_proxy(fd);
     HYDU_ASSERT(proxy, status);
-
     pg_scratch = (struct HYD_pmcd_pmi_pg_scratch *) proxy->pg->pg_scratch;
 
-    val = NULL;
-    if (!strcmp(key, "PMI_dead_processes")) {
-        val = pg_scratch->dead_processes;
-        goto found_val;
-    }
-
-    if (strcmp(pg_scratch->kvs->kvsname, kvsname))
-        HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR,
-                            "kvsname (%s) does not match this group's kvs space (%s)\n",
-                            kvsname, pg_scratch->kvs->kvsname);
-
-    /* Try to find the key */
-    for (run = pg_scratch->kvs->key_pair; run; run = run->next) {
-        if (!strcmp(run->key, key)) {
-            val = run->val;
-            break;
-        }
-    }
-
-  found_val:
-    i = 0;
-    tmp[i++] = HYDU_strdup("cmd=get_result rc=");
-    if (val) {
-        tmp[i++] = HYDU_strdup("0 msg=success value=");
-        tmp[i++] = HYDU_strdup(val);
-    }
-    else {
-        tmp[i++] = HYDU_strdup("-1 msg=key_");
-        tmp[i++] = HYDU_strdup(key);
-        tmp[i++] = HYDU_strdup("_not_found value=unknown");
+    for (i = 0; i < token_count; i++) {
+        status = HYD_pmcd_pmi_add_kvs(tokens[i].key, tokens[i].val, pg_scratch->kvs, &ret);
+        HYDU_ERR_POP(status, "unable to add keypair to kvs\n");
     }
-    tmp[i++] = HYDU_strdup("\n");
-    tmp[i++] = NULL;
-
-    status = HYDU_str_alloc_and_join(tmp, &cmd);
-    HYDU_ERR_POP(status, "unable to join strings\n");
-    HYDU_free_strlist(tmp);
-
-    status = cmd_response(fd, pid, cmd);
-    HYDU_ERR_POP(status, "error writing PMI line\n");
-    HYDU_FREE(cmd);
 
   fn_exit:
     HYD_pmcd_pmi_free_tokens(tokens, token_count);
@@ -233,7 +159,7 @@ static HYD_status fn_get(int fd, int pid, int pgid, char *args[])
     goto fn_exit;
 }
 
-static char *mcmd_args[HYD_NUM_TMP_STRINGS] = { NULL };
+static char *mcmd_args[MAX_PMI_ARGS] = { NULL };
 
 static int mcmd_num_args = 0;
 
@@ -715,7 +641,6 @@ static HYD_status fn_lookup_name(int fd, int pid, int pgid, char *args[])
 static struct HYD_pmcd_pmi_handle pmi_v1_handle_fns_foo[] = {
     {"barrier_in", fn_barrier_in},
     {"put", fn_put},
-    {"get", fn_get},
     {"spawn", fn_spawn},
     {"publish_name", fn_publish_name},
     {"unpublish_name", fn_unpublish_name},

http://git.mpich.org/mpich.git/commitdiff/30d28c6214cf8e94838e2a726f399e568428c8a4

commit 30d28c6214cf8e94838e2a726f399e568428c8a4
Author: Pavan Balaji <balaji at mcs.anl.gov>
Date:   Thu Apr 18 19:47:28 2013 -0500

    Make kvs_name and kvsname consistent.
    
    No reviewer.

diff --git a/src/pm/hydra/pm/pmiserv/common.c b/src/pm/hydra/pm/pmiserv/common.c
index 1bee231..20dc433 100644
--- a/src/pm/hydra/pm/pmiserv/common.c
+++ b/src/pm/hydra/pm/pmiserv/common.c
@@ -185,7 +185,7 @@ HYD_status HYD_pmcd_pmi_allocate_kvs(struct HYD_pmcd_pmi_kvs ** kvs, int pgid)
     HYDU_FUNC_ENTER();
 
     HYDU_MALLOC(*kvs, struct HYD_pmcd_pmi_kvs *, sizeof(struct HYD_pmcd_pmi_kvs), status);
-    HYDU_snprintf((*kvs)->kvs_name, PMI_MAXKVSLEN, "kvs_%d_%d", (int) getpid(), pgid);
+    HYDU_snprintf((*kvs)->kvsname, PMI_MAXKVSLEN, "kvs_%d_%d", (int) getpid(), pgid);
     (*kvs)->key_pair = NULL;
 
   fn_exit:
diff --git a/src/pm/hydra/pm/pmiserv/common.h b/src/pm/hydra/pm/pmiserv/common.h
index 492136c..ad1c784 100644
--- a/src/pm/hydra/pm/pmiserv/common.h
+++ b/src/pm/hydra/pm/pmiserv/common.h
@@ -21,7 +21,7 @@ struct HYD_pmcd_pmi_kvs_pair {
 };
 
 struct HYD_pmcd_pmi_kvs {
-    char kvs_name[PMI_MAXKVSLEN];       /* Name of this kvs */
+    char kvsname[PMI_MAXKVSLEN];       /* Name of this kvs */
     struct HYD_pmcd_pmi_kvs_pair *key_pair;
 };
 
diff --git a/src/pm/hydra/pm/pmiserv/pmip.c b/src/pm/hydra/pm/pmiserv/pmip.c
index 2e6f995..047c0fd 100644
--- a/src/pm/hydra/pm/pmiserv/pmip.c
+++ b/src/pm/hydra/pm/pmiserv/pmip.c
@@ -47,7 +47,7 @@ static HYD_status init_params(void)
     HYD_pmcd_pmip.local.pgid = -1;
     HYD_pmcd_pmip.local.iface_ip_env_name = NULL;
     HYD_pmcd_pmip.local.hostname = NULL;
-    HYD_pmcd_pmip.local.spawner_kvs_name = NULL;
+    HYD_pmcd_pmip.local.spawner_kvsname = NULL;
     HYD_pmcd_pmip.local.proxy_core_count = -1;
     HYD_pmcd_pmip.local.proxy_process_count = -1;
     HYD_pmcd_pmip.local.ckpoint_prefix_list = NULL;
@@ -109,8 +109,8 @@ static void cleanup_params(void)
     if (HYD_pmcd_pmip.local.hostname)
         HYDU_FREE(HYD_pmcd_pmip.local.hostname);
 
-    if (HYD_pmcd_pmip.local.spawner_kvs_name)
-        HYDU_FREE(HYD_pmcd_pmip.local.spawner_kvs_name);
+    if (HYD_pmcd_pmip.local.spawner_kvsname)
+        HYDU_FREE(HYD_pmcd_pmip.local.spawner_kvsname);
 
     if (HYD_pmcd_pmip.local.ckpoint_prefix_list) {
         for (i = 0; HYD_pmcd_pmip.local.ckpoint_prefix_list[i]; i++)
diff --git a/src/pm/hydra/pm/pmiserv/pmip.h b/src/pm/hydra/pm/pmiserv/pmip.h
index f3c9ff7..0d2e878 100644
--- a/src/pm/hydra/pm/pmiserv/pmip.h
+++ b/src/pm/hydra/pm/pmiserv/pmip.h
@@ -74,7 +74,7 @@ struct HYD_pmcd_pmip {
         int proxy_core_count;
         int proxy_process_count;
 
-        char *spawner_kvs_name;
+        char *spawner_kvsname;
         struct HYD_pmcd_pmi_kvs *kvs;   /* Node-level KVS space for node attributes */
 
         char **ckpoint_prefix_list;
diff --git a/src/pm/hydra/pm/pmiserv/pmip_pmi_v1.c b/src/pm/hydra/pm/pmiserv/pmip_pmi_v1.c
index b1bee89..8c90936 100644
--- a/src/pm/hydra/pm/pmiserv/pmip_pmi_v1.c
+++ b/src/pm/hydra/pm/pmiserv/pmip_pmi_v1.c
@@ -270,7 +270,7 @@ static HYD_status fn_get_my_kvsname(int fd, char *args[])
 
     i = 0;
     tmp[i++] = HYDU_strdup("cmd=my_kvsname kvsname=");
-    tmp[i++] = HYDU_strdup(HYD_pmcd_pmip.local.kvs->kvs_name);
+    tmp[i++] = HYDU_strdup(HYD_pmcd_pmip.local.kvs->kvsname);
     tmp[i++] = HYDU_strdup("\n");
     tmp[i++] = NULL;
 
diff --git a/src/pm/hydra/pm/pmiserv/pmip_pmi_v2.c b/src/pm/hydra/pm/pmiserv/pmip_pmi_v2.c
index f4d2c29..4246057 100644
--- a/src/pm/hydra/pm/pmiserv/pmip_pmi_v2.c
+++ b/src/pm/hydra/pm/pmiserv/pmip_pmi_v2.c
@@ -185,9 +185,9 @@ static HYD_status fn_fullinit(int fd, char *args[])
     tmp[i++] = HYDU_strdup(";size=");
     tmp[i++] = HYDU_int_to_str(HYD_pmcd_pmip.system_global.global_process_count);
     tmp[i++] = HYDU_strdup(";appnum=0");
-    if (HYD_pmcd_pmip.local.spawner_kvs_name) {
+    if (HYD_pmcd_pmip.local.spawner_kvsname) {
         tmp[i++] = HYDU_strdup(";spawner-jobid=");
-        tmp[i++] = HYDU_strdup(HYD_pmcd_pmip.local.spawner_kvs_name);
+        tmp[i++] = HYDU_strdup(HYD_pmcd_pmip.local.spawner_kvsname);
     }
     if (HYD_pmcd_pmip.user_global.debug) {
         tmp[i++] = HYDU_strdup(";debugged=TRUE;pmiverbose=TRUE");
@@ -237,7 +237,7 @@ static HYD_status fn_job_getid(int fd, char *args[])
         tmp[i++] = HYDU_strdup(";");
     }
     tmp[i++] = HYDU_strdup("jobid=");
-    tmp[i++] = HYDU_strdup(HYD_pmcd_pmip.local.kvs->kvs_name);
+    tmp[i++] = HYDU_strdup(HYD_pmcd_pmip.local.kvs->kvsname);
     tmp[i++] = HYDU_strdup(";rc=0;");
     tmp[i++] = NULL;
 
diff --git a/src/pm/hydra/pm/pmiserv/pmip_utils.c b/src/pm/hydra/pm/pmiserv/pmip_utils.c
index 5770710..876c412 100644
--- a/src/pm/hydra/pm/pmiserv/pmip_utils.c
+++ b/src/pm/hydra/pm/pmiserv/pmip_utils.c
@@ -174,7 +174,7 @@ static HYD_status retries_fn(char *arg, char ***argv)
 
 static HYD_status pmi_kvsname_fn(char *arg, char ***argv)
 {
-    HYDU_snprintf(HYD_pmcd_pmip.local.kvs->kvs_name, PMI_MAXKVSLEN, "%s", **argv);
+    HYDU_snprintf(HYD_pmcd_pmip.local.kvs->kvsname, PMI_MAXKVSLEN, "%s", **argv);
     (*argv)++;
 
     return HYD_SUCCESS;
@@ -184,9 +184,9 @@ static HYD_status pmi_spawner_kvsname_fn(char *arg, char ***argv)
 {
     HYD_status status = HYD_SUCCESS;
 
-    HYDU_MALLOC(HYD_pmcd_pmip.local.spawner_kvs_name, char *, PMI_MAXKVSLEN, status);
+    HYDU_MALLOC(HYD_pmcd_pmip.local.spawner_kvsname, char *, PMI_MAXKVSLEN, status);
 
-    HYDU_snprintf(HYD_pmcd_pmip.local.spawner_kvs_name, PMI_MAXKVSLEN, "%s", **argv);
+    HYDU_snprintf(HYD_pmcd_pmip.local.spawner_kvsname, PMI_MAXKVSLEN, "%s", **argv);
     (*argv)++;
 
   fn_exit:
diff --git a/src/pm/hydra/pm/pmiserv/pmiserv_pmi_v1.c b/src/pm/hydra/pm/pmiserv/pmiserv_pmi_v1.c
index 31c9014..47b28ba 100644
--- a/src/pm/hydra/pm/pmiserv/pmiserv_pmi_v1.c
+++ b/src/pm/hydra/pm/pmiserv/pmiserv_pmi_v1.c
@@ -114,10 +114,10 @@ static HYD_status fn_put(int fd, int pid, int pgid, char *args[])
 
     pg_scratch = (struct HYD_pmcd_pmi_pg_scratch *) proxy->pg->pg_scratch;
 
-    if (strcmp(pg_scratch->kvs->kvs_name, kvsname))
+    if (strcmp(pg_scratch->kvs->kvsname, kvsname))
         HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR,
                             "kvsname (%s) does not match this group's kvs space (%s)\n",
-                            kvsname, pg_scratch->kvs->kvs_name);
+                            kvsname, pg_scratch->kvs->kvsname);
 
     status = HYD_pmcd_pmi_add_kvs(key, val, pg_scratch->kvs, &ret);
     HYDU_ERR_POP(status, "unable to add keypair to kvs\n");
@@ -188,10 +188,10 @@ static HYD_status fn_get(int fd, int pid, int pgid, char *args[])
         goto found_val;
     }
 
-    if (strcmp(pg_scratch->kvs->kvs_name, kvsname))
+    if (strcmp(pg_scratch->kvs->kvsname, kvsname))
         HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR,
                             "kvsname (%s) does not match this group's kvs space (%s)\n",
-                            kvsname, pg_scratch->kvs->kvs_name);
+                            kvsname, pg_scratch->kvs->kvsname);
 
     /* Try to find the key */
     for (run = pg_scratch->kvs->key_pair; run; run = run->next) {
diff --git a/src/pm/hydra/pm/pmiserv/pmiserv_pmi_v2.c b/src/pm/hydra/pm/pmiserv/pmiserv_pmi_v2.c
index 7b6bd0d..87ff14f 100644
--- a/src/pm/hydra/pm/pmiserv/pmiserv_pmi_v2.c
+++ b/src/pm/hydra/pm/pmiserv/pmiserv_pmi_v2.c
@@ -738,7 +738,7 @@ static HYD_status fn_spawn(int fd, int pid, int pgid, char *args[])
         }
         cmd_str[i++] = HYDU_strdup("rc=0;");
         cmd_str[i++] = HYDU_strdup("jobid=");
-        cmd_str[i++] = HYDU_strdup(pg_scratch->kvs->kvs_name);
+        cmd_str[i++] = HYDU_strdup(pg_scratch->kvs->kvsname);
         cmd_str[i++] = HYDU_strdup(";");
         cmd_str[i++] = HYDU_strdup("nerrs=0;");
         cmd_str[i++] = NULL;
diff --git a/src/pm/hydra/pm/pmiserv/pmiserv_utils.c b/src/pm/hydra/pm/pmiserv/pmiserv_utils.c
index 5b941fc..46539da 100644
--- a/src/pm/hydra/pm/pmiserv/pmiserv_utils.c
+++ b/src/pm/hydra/pm/pmiserv/pmiserv_utils.c
@@ -363,12 +363,12 @@ HYD_status HYD_pmcd_pmi_fill_in_exec_launch_info(struct HYD_pg *pg)
 
         pg_scratch = (struct HYD_pmcd_pmi_pg_scratch *) pg->pg_scratch;
         proxy->exec_launch_info[arg++] = HYDU_strdup("--pmi-kvsname");
-        proxy->exec_launch_info[arg++] = HYDU_strdup(pg_scratch->kvs->kvs_name);
+        proxy->exec_launch_info[arg++] = HYDU_strdup(pg_scratch->kvs->kvsname);
 
         if (pg->spawner_pg) {
             pg_scratch = (struct HYD_pmcd_pmi_pg_scratch *) pg->spawner_pg->pg_scratch;
             proxy->exec_launch_info[arg++] = HYDU_strdup("--pmi-spawner-kvsname");
-            proxy->exec_launch_info[arg++] = HYDU_strdup(pg_scratch->kvs->kvs_name);
+            proxy->exec_launch_info[arg++] = HYDU_strdup(pg_scratch->kvs->kvsname);
         }
 
         proxy->exec_launch_info[arg++] = HYDU_strdup("--pmi-process-mapping");

-----------------------------------------------------------------------

Summary of changes:
 src/pm/hydra/pm/pmiserv/common.c         |   77 ++----------
 src/pm/hydra/pm/pmiserv/common.h         |    5 +-
 src/pm/hydra/pm/pmiserv/pmip.c           |    6 +-
 src/pm/hydra/pm/pmiserv/pmip.h           |    2 +-
 src/pm/hydra/pm/pmiserv/pmip_cb.c        |    4 +-
 src/pm/hydra/pm/pmiserv/pmip_pmi_v1.c    |  193 +++++++++++++++++++++++++++--
 src/pm/hydra/pm/pmiserv/pmip_pmi_v2.c    |    6 +-
 src/pm/hydra/pm/pmiserv/pmip_utils.c     |    6 +-
 src/pm/hydra/pm/pmiserv/pmiserv_cb.c     |    2 +-
 src/pm/hydra/pm/pmiserv/pmiserv_pmi_v1.c |  191 +++++++++--------------------
 src/pm/hydra/pm/pmiserv/pmiserv_pmi_v2.c |    2 +-
 src/pm/hydra/pm/pmiserv/pmiserv_utils.c  |    4 +-
 12 files changed, 267 insertions(+), 231 deletions(-)


hooks/post-receive
-- 
MPICH primary repository


More information about the commits mailing list