diff --git a/contribs/pmi2/pmi2_api.c b/contribs/pmi2/pmi2_api.c index 2789fbcee48f4895b9f1f9a7dcfec8c1c3d52aee..f194ebe33430270de548554479e2e24cd1c64438 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 59bdad6bef698c220b479bb43da04e8bbef1b9e9..e2daf72a96869c7906a1ef18ed8a9899bf741a97 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);