Skip to content

Commit 9ae3aa0

Browse files
committed
ompi: Avoid unnecessary PMIx lookups when adding procs.
Signed-off-by: Artem Polyakov <[email protected]> (cherry-picked from 9f4464a)
1 parent 10a0d0f commit 9ae3aa0

File tree

1 file changed

+19
-23
lines changed

1 file changed

+19
-23
lines changed

ompi/proc/proc.c

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Copyright (c) 2013-2015 Intel, Inc. All rights reserved
1717
* Copyright (c) 2014-2016 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
19-
* Copyright (c) 2015 Mellanox Technologies. All rights reserved.
19+
* Copyright (c) 2015-2017 Mellanox Technologies. All rights reserved.
2020
*
2121
* $COPYRIGHT$
2222
*
@@ -38,6 +38,7 @@
3838
#include "opal/util/show_help.h"
3939
#include "opal/mca/hwloc/base/base.h"
4040
#include "opal/mca/pmix/pmix.h"
41+
#include "opal/util/argv.h"
4142

4243
#include "ompi/proc/proc.h"
4344
#include "ompi/datatype/ompi_datatype.h"
@@ -342,29 +343,24 @@ int ompi_proc_complete_init(void)
342343
opal_mutex_unlock (&ompi_proc_lock);
343344

344345
if (ompi_process_info.num_procs >= ompi_add_procs_cutoff) {
345-
uint16_t u16, *u16ptr;
346-
347-
u16ptr = &u16;
348-
349-
/* find and add all local processes */
350-
for (ompi_vpid_t i = 0 ; i < ompi_process_info.num_procs ; ++i ) {
351-
opal_process_name_t proc_name = {.vpid = i, .jobid = OMPI_PROC_MY_NAME->jobid};
352-
uint16_t locality = OPAL_PROC_NON_LOCAL;
353-
354-
if (OMPI_PROC_MY_NAME->vpid == i) {
355-
continue;
356-
}
357-
358-
/* the runtime is required to fill in locality for all local processes by this
359-
* point. only local processes will have locality set */
360-
OPAL_MODEX_RECV_VALUE_OPTIONAL(ret, OPAL_PMIX_LOCALITY, &proc_name, &u16ptr, OPAL_UINT16);
361-
if (OPAL_SUCCESS == ret) {
362-
locality = u16;
363-
}
364-
365-
if (OPAL_PROC_NON_LOCAL != locality) {
366-
(void) ompi_proc_for_name (proc_name);
346+
char *val;
347+
/* retrieve the local peers */
348+
OPAL_MODEX_RECV_VALUE(ret, OPAL_PMIX_LOCAL_PEERS,
349+
ORTE_PROC_MY_NAME, &val, OPAL_STRING);
350+
if (OPAL_SUCCESS == ret && NULL != val) {
351+
char **peers = opal_argv_split(val, ',');
352+
int i;
353+
free(val);
354+
for (i=0; NULL != peers[i]; i++) {
355+
ompi_vpid_t local_rank = strtoul(peers[i], NULL, 10);
356+
opal_process_name_t proc_name = {.vpid = local_rank, .jobid = OMPI_PROC_MY_NAME->jobid};
357+
358+
if (OMPI_PROC_MY_NAME->vpid == local_rank) {
359+
continue;
360+
}
361+
(void) ompi_proc_for_name (proc_name);
367362
}
363+
opal_argv_free(peers);
368364
}
369365
}
370366

0 commit comments

Comments
 (0)