Skip to content

Commit a53cb25

Browse files
committed
Provide proc data in cases where host does not
Enough information is in the node and proc maps to compute most (if not all) of the data usually provided in the PMIX_PROC_DATA entries. In the case where those entries are not provided by the host, compute and store the information based on the node and proc map data. Signed-off-by: Ralph Castain <[email protected]> (cherry picked from commit 2156e7f)
1 parent 466ef34 commit a53cb25

File tree

1 file changed

+57
-17
lines changed

1 file changed

+57
-17
lines changed

src/mca/gds/hash/gds_hash.c

Lines changed: 57 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ static pmix_status_t hash_assign_module(pmix_info_t *info, size_t ninfo,
202202
}
203203

204204
static pmix_status_t store_map(pmix_hash_table_t *ht,
205-
char **nodes, char **ppn)
205+
char **nodes, char **ppn,
206+
bool procdataprovided)
206207
{
207208
pmix_status_t rc;
208209
pmix_value_t *val;
@@ -341,6 +342,48 @@ static pmix_status_t store_map(pmix_hash_table_t *ht,
341342
return rc;
342343
}
343344
PMIX_RELEASE(kp2); // maintain acctg
345+
if (!procdataprovided) {
346+
/* add an entry for the nodeid */
347+
kp2 = PMIX_NEW(pmix_kval_t);
348+
kp2->key = strdup(PMIX_NODEID);
349+
kp2->value = (pmix_value_t*)malloc(sizeof(pmix_value_t));
350+
kp2->value->type = PMIX_UINT32;
351+
kp2->value->data.uint32 = n;
352+
if (PMIX_SUCCESS != (rc = pmix_hash_store(ht, rank, kp2))) {
353+
PMIX_ERROR_LOG(rc);
354+
PMIX_RELEASE(kp2);
355+
pmix_argv_free(procs);
356+
return rc;
357+
}
358+
PMIX_RELEASE(kp2); // maintain acctg
359+
/* add an entry for the local rank */
360+
kp2 = PMIX_NEW(pmix_kval_t);
361+
kp2->key = strdup(PMIX_LOCAL_RANK);
362+
kp2->value = (pmix_value_t*)malloc(sizeof(pmix_value_t));
363+
kp2->value->type = PMIX_UINT16;
364+
kp2->value->data.uint16 = m;
365+
if (PMIX_SUCCESS != (rc = pmix_hash_store(ht, rank, kp2))) {
366+
PMIX_ERROR_LOG(rc);
367+
PMIX_RELEASE(kp2);
368+
pmix_argv_free(procs);
369+
return rc;
370+
}
371+
PMIX_RELEASE(kp2); // maintain acctg
372+
/* add an entry for the node rank - for now, we assume
373+
* only the one job is running */
374+
kp2 = PMIX_NEW(pmix_kval_t);
375+
kp2->key = strdup(PMIX_NODE_RANK);
376+
kp2->value = (pmix_value_t*)malloc(sizeof(pmix_value_t));
377+
kp2->value->type = PMIX_UINT16;
378+
kp2->value->data.uint16 = m;
379+
if (PMIX_SUCCESS != (rc = pmix_hash_store(ht, rank, kp2))) {
380+
PMIX_ERROR_LOG(rc);
381+
PMIX_RELEASE(kp2);
382+
pmix_argv_free(procs);
383+
return rc;
384+
}
385+
PMIX_RELEASE(kp2); // maintain acctg
386+
}
344387
}
345388
pmix_argv_free(procs);
346389
}
@@ -376,6 +419,7 @@ pmix_status_t hash_cache_job_info(struct pmix_namespace_t *ns,
376419
pmix_rank_t rank;
377420
pmix_status_t rc=PMIX_SUCCESS;
378421
size_t n, j, size, len;
422+
bool procdataprovided = false;
379423

380424
pmix_output_verbose(2, pmix_gds_base_framework.framework_output,
381425
"[%s:%d] gds:hash:cache_job_info for nspace %s",
@@ -431,29 +475,14 @@ pmix_status_t hash_cache_job_info(struct pmix_namespace_t *ns,
431475
PMIX_ERROR_LOG(rc);
432476
goto release;
433477
}
434-
/* if we have already found the proc map, then parse
435-
* and store the detailed map */
436-
if (NULL != procs) {
437-
if (PMIX_SUCCESS != (rc = store_map(ht, nodes, procs))) {
438-
PMIX_ERROR_LOG(rc);
439-
goto release;
440-
}
441-
}
442478
} else if (0 == strcmp(info[n].key, PMIX_PROC_MAP)) {
443479
/* parse the regex to get the argv array containing proc ranks on each node */
444480
if (PMIX_SUCCESS != (rc = pmix_preg.parse_procs(info[n].value.data.string, &procs))) {
445481
PMIX_ERROR_LOG(rc);
446482
goto release;
447483
}
448-
/* if we have already recv'd the node map, then parse
449-
* and store the detailed map */
450-
if (NULL != nodes) {
451-
if (PMIX_SUCCESS != (rc = store_map(ht, nodes, procs))) {
452-
PMIX_ERROR_LOG(rc);
453-
goto release;
454-
}
455-
}
456484
} else if (0 == strcmp(info[n].key, PMIX_PROC_DATA)) {
485+
procdataprovided = true;
457486
/* an array of data pertaining to a specific proc */
458487
if (PMIX_DATA_ARRAY != info[n].value.type) {
459488
PMIX_ERROR_LOG(PMIX_ERR_BAD_PARAM);
@@ -577,6 +606,17 @@ pmix_status_t hash_cache_job_info(struct pmix_namespace_t *ns,
577606
trk->gdata_added = true;
578607
}
579608

609+
/* we must have the proc AND node maps */
610+
if (NULL == procs || NULL == nodes) {
611+
rc = PMIX_ERR_NOT_FOUND;
612+
goto release;
613+
}
614+
615+
if (PMIX_SUCCESS != (rc = store_map(ht, nodes, procs, procdataprovided))) {
616+
PMIX_ERROR_LOG(rc);
617+
goto release;
618+
}
619+
580620
release:
581621
if (NULL != nodes) {
582622
pmix_argv_free(nodes);

0 commit comments

Comments
 (0)