Skip to content
Snippets Groups Projects
Commit 03dc1994 authored by Sonja Happ's avatar Sonja Happ
Browse files

vendor/mpir_pmi: Introduce util function pmix_build_nodelist.

parent a79ba96b
No related branches found
No related tags found
No related merge requests found
...@@ -1646,46 +1646,67 @@ static int build_nodemap_pmi2(int *nodemap, int sz) ...@@ -1646,46 +1646,67 @@ static int build_nodemap_pmi2(int *nodemap, int sz)
#elif defined USE_PMIX_API #elif defined USE_PMIX_API
/* build nodemap using PMIx_Resolve_nodes */ static
int build_nodemap_pmix(int *nodemap, int sz) int pmix_build_nodelist(char **nspaces, int nnspaces, UT_array ** nodelist)
{ {
int mpi_errno = MPI_SUCCESS; int mpi_errno = MPI_SUCCESS;
int pmi_errno; pmix_status_t pmi_errno = PMIX_SUCCESS;
char *nodelist = NULL, *node = NULL; UT_array *list = NULL;
pmix_proc_t *procs = NULL; char *node = NULL;
size_t nprocs, node_id = 0; char *pmix_nodelist = NULL;
#if PMIX_NUMERIC_VERSION >= 0x00040204
UT_array *pmix_nodelist = NULL;
if (pmix_group_members != NULL) { utarray_new(list, &ut_str_icd, MPL_MEM_OTHER);
utarray_new(pmix_nodelist, &ut_str_icd, MPL_MEM_OTHER);
for (int i = 0; i < pmix_nnamespaces; i++) { for (int i = 0; i < nnspaces; i++) {
/* Get nodes of this namespace */ /* Get nodes of this namespace */
pmi_errno = PMIx_Resolve_nodes(pmix_namespaces[i], &nodelist); pmi_errno = PMIx_Resolve_nodes(nspaces[i], &pmix_nodelist);
MPIR_ERR_CHKANDJUMP1(pmi_errno != PMIX_SUCCESS, mpi_errno, MPI_ERR_OTHER, MPIR_ERR_CHKANDJUMP1(pmi_errno != PMIX_SUCCESS, mpi_errno, MPI_ERR_OTHER,
"**pmix_resolve_nodes", "**pmix_resolve_nodes %d", pmi_errno); "**pmix_resolve_nodes", "**pmix_resolve_nodes %d", pmi_errno);
MPIR_Assert(nodelist); MPIR_Assert(pmix_nodelist);
/* Add non-duplicate nodes to global pmix_nodelist */ /* Add non-duplicate nodes to list */
node = strtok(nodelist, ","); node = strtok(pmix_nodelist, ",");
while (node) { while (node) {
bool is_duplicate = false; bool is_duplicate = false;
for (unsigned u = 0; u < utarray_len(pmix_nodelist); u++) { for (unsigned u = 0; u < utarray_len(list); u++) {
char *n = (char *) utarray_eltptr(pmix_nodelist, u); char *n = *(char **) utarray_eltptr(list, u);
if (strncmp(node, n, MAX(strlen(node), strlen(n))) == 0) { if (strncmp(node, n, MIN(strlen(node), strlen(n))) == 0) {
is_duplicate = true; is_duplicate = true;
break; break;
} }
} }
if (!is_duplicate) { if (!is_duplicate) {
utarray_push_back(pmix_nodelist, &node, MPL_MEM_OTHER); utarray_push_back(list, &node, MPL_MEM_OTHER);
} }
node = strtok(NULL, ","); node = strtok(NULL, ",");
} }
pmix_free(nodelist); pmix_free(pmix_nodelist);
} }
*nodelist = list;
fn_exit:
return mpi_errno;
fn_fail:
goto fn_exit;
}
/* build nodemap using PMIx_Resolve_nodes */
int build_nodemap_pmix(int *nodemap, int sz)
{
int mpi_errno = MPI_SUCCESS;
int pmi_errno;
char *nodelist = NULL, *node = NULL;
pmix_proc_t *procs = NULL;
size_t nprocs, node_id = 0;
#if PMIX_NUMERIC_VERSION >= 0x00040204
UT_array *pmix_nodelist = NULL;
if (pmix_group_members != NULL) {
mpi_errno = pmix_build_nodelist(pmix_namespaces, pmix_nnamespaces, &pmix_nodelist);
MPIR_ERR_CHECK(mpi_errno);
/* Resolve nodes for each namespace */ /* Resolve nodes for each namespace */
for (int i = 0; i < pmix_nnamespaces; i++) { for (int i = 0; i < pmix_nnamespaces; i++) {
pmi_errno = PMIx_Resolve_nodes(pmix_namespaces[i], &nodelist); pmi_errno = PMIx_Resolve_nodes(pmix_namespaces[i], &nodelist);
...@@ -1708,7 +1729,7 @@ int build_nodemap_pmix(int *nodemap, int sz) ...@@ -1708,7 +1729,7 @@ int build_nodemap_pmix(int *nodemap, int sz)
node_id = -1; node_id = -1;
for (unsigned k = 0; k < utarray_len(pmix_nodelist); k++) { for (unsigned k = 0; k < utarray_len(pmix_nodelist); k++) {
char **n = (char **) utarray_eltptr(pmix_nodelist, k); char **n = (char **) utarray_eltptr(pmix_nodelist, k);
if (strncmp(node, *n, MAX(strlen(node), strlen(*n))) == 0) { if (strncmp(node, *n, MIN(strlen(node), strlen(*n))) == 0) {
node_id = (int) k; node_id = (int) k;
break; break;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment