Skip to content

[v5.0.x] ompi/dpm: make procs consistent before calling PMIx_Connect() #10564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions ompi/dpm/dpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ int ompi_dpm_init(void)
return OMPI_SUCCESS;
}

static int compare_pmix_proc(const void *a, const void *b)
{
const pmix_proc_t *proc_a = (pmix_proc_t *)a;
const pmix_proc_t *proc_b = (pmix_proc_t *)b;

int nspace_dif = strncmp(proc_a->nspace, proc_b->nspace, PMIX_MAX_NSLEN);
if (nspace_dif != 0)
return nspace_dif;

return proc_a->rank - proc_b->rank;
}

int ompi_dpm_connect_accept(ompi_communicator_t *comm, int root,
const char *port_string, bool send_first,
ompi_communicator_t **newcomm)
Expand Down Expand Up @@ -378,6 +390,11 @@ int ompi_dpm_connect_accept(ompi_communicator_t *comm, int root,
* so that add_procs will not result in a slew of lookups */
PMIX_INFO_CONSTRUCT(&tinfo);
PMIX_INFO_LOAD(&tinfo, PMIX_TIMEOUT, &ompi_pmix_connect_timeout, PMIX_UINT32);

/*
* sort procs so that all ranks call PMIx_Connect() with the processes in same order
*/
qsort(procs, nprocs, sizeof(pmix_proc_t), compare_pmix_proc);
pret = PMIx_Connect(procs, nprocs, &tinfo, 1);
PMIX_INFO_DESTRUCT(&tinfo);
PMIX_PROC_FREE(procs, nprocs);
Expand Down