From a4155bbdeef3e19c04d5276d25105de29cf3334b Mon Sep 17 00:00:00 2001 From: Adam Moody <moody20@llnl.gov> Date: Thu, 22 Sep 2016 09:30:20 -0600 Subject: [PATCH] [PATCH 1/2] define PMIX_Ring behavior in singleton mode --- contribs/pmi2/pmi2_api.c | 10 ++++++++++ contribs/pmi2/slurm/pmi2.h | 12 ++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/contribs/pmi2/pmi2_api.c b/contribs/pmi2/pmi2_api.c index 2789fbcee48..f194ebe3343 100644 --- a/contribs/pmi2/pmi2_api.c +++ b/contribs/pmi2/pmi2_api.c @@ -656,6 +656,15 @@ int PMIX_Ring(const char value[], int *rank, int *ranks, char left[], char right PMI2U_printf("[BEGIN PMI2_Ring]"); + /* for singleton mode, set rank and ranks, copy input to output buffers */ + if (PMI2_initialized == SINGLETON_INIT_BUT_NO_PM) { + *rank = 0; + *ranks = 1; + MPIU_Strncpy(left, value, maxvalue); + MPIU_Strncpy(right, value, maxvalue); + goto fn_exit_singleton; + } + /* send message: cmd=ring_in, count=1, left=value, right=value */ pmi2_errno = PMIi_WriteSimpleCommandStr(PMI2_fd, &cmd, RING_CMD, RING_COUNT_KEY, "1", @@ -689,6 +698,7 @@ int PMIX_Ring(const char value[], int *rank, int *ranks, char left[], char right fn_exit: free(cmd.command); freepairs(cmd.pairs, cmd.nPairs); +fn_exit_singleton: PMI2U_printf("[END PMI2_Ring]"); return pmi2_errno; fn_fail: diff --git a/contribs/pmi2/slurm/pmi2.h b/contribs/pmi2/slurm/pmi2.h index 59bdad6bef6..e2daf72a968 100644 --- a/contribs/pmi2/slurm/pmi2.h +++ b/contribs/pmi2/slurm/pmi2.h @@ -426,8 +426,8 @@ int PMI2_Job_Disconnect(const char jobid[]); Output Parameters: + rank - returns caller's rank within ring - - ranks - returns number of procs within ring - - left - buffer to receive value provided by (rank - 1) % ranks + . ranks - returns number of procs within ring + . left - buffer to receive value provided by (rank - 1) % ranks - right - buffer to receive value provided by (rank + 1) % ranks Return values: @@ -440,6 +440,14 @@ int PMI2_Job_Disconnect(const char jobid[]); function, but a process may return before all processes have called the function. + The rank of a process within the ring may not be the same as its + rank returned by PMI2_Init. + + For a process group consisting of a single process, this function + returns rank=0, ranks=1, and the input string in the value buffer + shall be copied to the left and right output buffers. This same + behavior holds when the function is called in singleton mode. + @*/ #define HAVE_PMIX_RING 1 /* so one can conditionally compile with this funciton */ int PMIX_Ring(const char value[], int *rank, int *ranks, char left[], char right[], int maxvalue); -- GitLab