Skip to content

Commit 92d2842

Browse files
committed
Protect against non-standard environment
Environments are supposed to provide the PMIX_NODE_RANK - if they don't, we can probably safely assume the same as local rank. Protect against a few other values that might not be provided. Signed-off-by: Ralph Castain <[email protected]>
1 parent 14a7283 commit 92d2842

File tree

1 file changed

+25
-28
lines changed

1 file changed

+25
-28
lines changed

ompi/runtime/ompi_rte.c

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,11 @@ int ompi_rte_init(int *pargc, char ***pargv)
585585
/* just assume 0 */
586586
u16 = 0;
587587
} else {
588-
ret = opal_pmix_convert_status(rc);
589-
error = "node rank";
590-
goto error;
588+
/* we may be in an environment that doesn't quite adhere
589+
* to the Standard - we can safely assume it is the same
590+
* as the local rank as such environments probably aren't
591+
* going to care */
592+
u16 = opal_process_info.my_local_rank;
591593
}
592594
}
593595
opal_process_info.my_node_rank = u16;
@@ -704,10 +706,6 @@ int ompi_rte_init(int *pargc, char ***pargv)
704706
&pname, &u32ptr, PMIX_UINT32);
705707
if (PMIX_SUCCESS == rc) {
706708
opal_process_info.num_local_peers = u32 - 1; // want number besides ourselves
707-
} else {
708-
ret = opal_pmix_convert_status(rc);
709-
error = "local size";
710-
goto error;
711709
}
712710

713711
/* retrieve temp directories info */
@@ -777,28 +775,27 @@ int ompi_rte_init(int *pargc, char ***pargv)
777775
opal_process_info.proc_is_bound = false;
778776
}
779777

780-
/* get our local peers */
781-
if (0 < opal_process_info.num_local_peers) {
782-
/* if my local rank if too high, then that's an error */
783-
if (opal_process_info.num_local_peers < opal_process_info.my_local_rank) {
784-
ret = OPAL_ERR_BAD_PARAM;
785-
error = "num local peers";
786-
goto error;
787-
}
788-
/* retrieve the local peers - defaults to local node */
789-
val = NULL;
790-
OPAL_MODEX_RECV_VALUE(rc, PMIX_LOCAL_PEERS,
791-
&pname, &val, PMIX_STRING);
792-
if (PMIX_SUCCESS == rc && NULL != val) {
793-
peers = opal_argv_split(val, ',');
794-
free(val);
795-
} else {
796-
ret = opal_pmix_convert_status(rc);
797-
error = "local peers";
798-
goto error;
799-
}
778+
/* retrieve the local peers - defaults to local node */
779+
val = NULL;
780+
OPAL_MODEX_RECV_VALUE(rc, PMIX_LOCAL_PEERS,
781+
&pname, &val, PMIX_STRING);
782+
if (PMIX_SUCCESS == rc && NULL != val) {
783+
peers = opal_argv_split(val, ',');
784+
free(val);
800785
} else {
801-
peers = NULL;
786+
ret = opal_pmix_convert_status(rc);
787+
error = "local peers";
788+
goto error;
789+
}
790+
/* if we were unable to retrieve the #local peers, set it here */
791+
if (0 == opal_process_info.num_local_peers) {
792+
opal_process_info.num_local_peers = opal_argv_count(peers) - 1;
793+
}
794+
/* if my local rank if too high, then that's an error */
795+
if (opal_process_info.num_local_peers < opal_process_info.my_local_rank) {
796+
ret = OPAL_ERR_BAD_PARAM;
797+
error = "num local peers";
798+
goto error;
802799
}
803800

804801
/* set the locality */

0 commit comments

Comments
 (0)