Skip to content

Commit 717f3fe

Browse files
committed
ompi: Avoid unnecessary PMIx lookups when adding procs.
Signed-off-by: Artem Polyakov <[email protected]>
1 parent 4184c01 commit 717f3fe

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

ompi/proc/proc.c

Lines changed: 21 additions & 21 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-2017 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"
@@ -343,28 +344,27 @@ int ompi_proc_complete_init(void)
343344
opal_mutex_unlock (&ompi_proc_lock);
344345

345346
if (ompi_process_info.num_procs >= ompi_add_procs_cutoff) {
346-
uint16_t u16, *u16ptr;
347-
348-
/* find and add all local processes */
349-
for (ompi_vpid_t i = 0 ; i < ompi_process_info.num_procs ; ++i ) {
350-
opal_process_name_t proc_name = {.vpid = i, .jobid = OMPI_PROC_MY_NAME->jobid};
351-
uint16_t locality = OPAL_PROC_NON_LOCAL;
352-
353-
if (OMPI_PROC_MY_NAME->vpid == i) {
354-
continue;
355-
}
356-
357-
/* the runtime is required to fill in locality for all local processes by this
358-
* point. only local processes will have locality set */
359-
u16ptr = &u16;
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) {
347+
char *val = NULL;
348+
opal_process_name_t wildcard_rank;
349+
wildcard_rank.jobid = OMPI_PROC_MY_NAME->jobid;
350+
wildcard_rank.vpid = OMPI_NAME_WILDCARD->vpid;
351+
/* retrieve the local peers */
352+
OPAL_MODEX_RECV_VALUE(ret, OPAL_PMIX_LOCAL_PEERS,
353+
&wildcard_rank, &val, OPAL_STRING);
354+
if (OPAL_SUCCESS == ret && NULL != val) {
355+
char **peers = opal_argv_split(val, ',');
356+
int i;
357+
free(val);
358+
for (i=0; NULL != peers[i]; i++) {
359+
ompi_vpid_t local_rank = strtoul(peers[i], NULL, 10);
360+
opal_process_name_t proc_name = {.vpid = local_rank, .jobid = OMPI_PROC_MY_NAME->jobid};
361+
362+
if (OMPI_PROC_MY_NAME->vpid == local_rank) {
363+
continue;
364+
}
366365
(void) ompi_proc_for_name (proc_name);
367366
}
367+
opal_argv_free(peers);
368368
}
369369
}
370370

0 commit comments

Comments
 (0)