Skip to content

Commit d950651

Browse files
authored
Merge pull request #5081 from ggouaillardet/topic/v3.1.x/pmix_legacy_get
Fix support for external PMIx v2.0 with legacy PMIx_Get()
2 parents 5e894c4 + 7c11011 commit d950651

File tree

12 files changed

+373
-260
lines changed

12 files changed

+373
-260
lines changed

opal/mca/pmix/ext1x/pmix1x.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
3+
* Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
44
* Copyright (c) 2014-2017 Research Organization for Information Science
55
* and Technology (RIST). All rights reserved.
66
* Copyright (c) 2014-2015 Mellanox Technologies, Inc.
@@ -48,8 +48,13 @@
4848

4949
static const char *pmix1_get_nspace(opal_jobid_t jobid);
5050
static void pmix1_register_jobid(opal_jobid_t jobid, const char *nspace);
51+
static bool legacy_get(void)
52+
{
53+
return true;
54+
}
5155

5256
const opal_pmix_base_module_t opal_pmix_ext1x_module = {
57+
.legacy_get = legacy_get,
5358
/* client APIs */
5459
.init = pmix1_client_init,
5560
.finalize = pmix1_client_finalize,

opal/mca/pmix/ext1x/pmix1x_client.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,10 @@ int pmix1_store_local(const opal_process_name_t *proc, opal_value_t *val)
232232
}
233233
}
234234
if (NULL == job) {
235-
OPAL_ERROR_LOG(OPAL_ERR_NOT_FOUND);
236-
return OPAL_ERR_NOT_FOUND;
235+
job = OBJ_NEW(opal_pmix1_jobid_trkr_t);
236+
(void)opal_snprintf_jobid(job->nspace, PMIX_MAX_NSLEN, proc->jobid);
237+
job->jobid = proc->jobid;
238+
opal_list_append(&mca_pmix_ext1x_component.jobids, &job->super);
237239
}
238240
(void)strncpy(p.nspace, job->nspace, PMIX_MAX_NSLEN);
239241
p.rank = proc->vpid;

opal/mca/pmix/pmix.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,10 +867,13 @@ typedef int (*opal_pmix_base_process_monitor_fn_t)(opal_list_t *monitor,
867867
opal_list_t *directives,
868868
opal_pmix_info_cbfunc_t cbfunc, void *cbdata);
869869

870+
typedef bool (*opal_pmix_base_legacy_get_fn_t)(void);
871+
870872
/*
871873
* the standard public API data structure
872874
*/
873875
typedef struct {
876+
opal_pmix_base_legacy_get_fn_t legacy_get;
874877
/* client APIs */
875878
opal_pmix_base_module_init_fn_t init;
876879
opal_pmix_base_module_fini_fn_t finalize;

opal/mca/pmix/pmix2x/pmix2x.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
3+
* Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
44
* Copyright (c) 2014-2017 Research Organization for Information Science
55
* and Technology (RIST). All rights reserved.
66
* Copyright (c) 2014-2015 Mellanox Technologies, Inc.
@@ -50,7 +50,7 @@
5050

5151
/* These are functions used by both client and server to
5252
* access common functions in the embedded PMIx library */
53-
53+
static bool legacy_get(void);
5454
static const char *pmix2x_get_nspace(opal_jobid_t jobid);
5555
static void pmix2x_register_jobid(opal_jobid_t jobid, const char *nspace);
5656
static void register_handler(opal_list_t *event_codes,
@@ -72,6 +72,7 @@ static void pmix2x_log(opal_list_t *info,
7272
opal_pmix_op_cbfunc_t cbfunc, void *cbdata);
7373

7474
const opal_pmix_base_module_t opal_pmix_pmix2x_module = {
75+
.legacy_get = legacy_get,
7576
/* client APIs */
7677
.init = pmix2x_client_init,
7778
.finalize = pmix2x_client_finalize,
@@ -126,6 +127,11 @@ const opal_pmix_base_module_t opal_pmix_pmix2x_module = {
126127
.register_jobid = pmix2x_register_jobid
127128
};
128129

130+
static bool legacy_get(void)
131+
{
132+
return mca_pmix_pmix2x_component.legacy_get;
133+
}
134+
129135
static void opcbfunc(pmix_status_t status, void *cbdata)
130136
{
131137
pmix2x_opcaddy_t *op = (pmix2x_opcaddy_t*)cbdata;

opal/mca/pmix/pmix2x/pmix2x.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ BEGIN_C_DECLS
4848

4949
typedef struct {
5050
opal_pmix_base_component_t super;
51+
bool legacy_get;
5152
opal_list_t jobids;
5253
bool native_launch;
5354
size_t evindex;

opal/mca/pmix/pmix2x/pmix2x_client.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
3+
* Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
44
* Copyright (c) 2014-2017 Research Organization for Information Science
55
* and Technology (RIST). All rights reserved.
66
* Copyright (c) 2014-2017 Mellanox Technologies, Inc.
@@ -400,7 +400,6 @@ int pmix2x_store_local(const opal_process_name_t *proc, opal_value_t *val)
400400

401401
PMIX_VALUE_CONSTRUCT(&kv);
402402
pmix2x_value_load(&kv, val);
403-
404403
/* call the library - this is a blocking call */
405404
rc = PMIx_Store_internal(&p, val->key, &kv);
406405
PMIX_VALUE_DESTRUCT(&kv);
@@ -596,10 +595,11 @@ int pmix2x_get(const opal_process_name_t *proc, const char *key,
596595
return OPAL_ERR_NOT_INITIALIZED;
597596
}
598597

599-
if (NULL == proc) {
598+
if (NULL == proc && NULL != key) {
600599
/* if they are asking for our jobid, then return it */
601600
if (0 == strcmp(key, OPAL_PMIX_JOBID)) {
602601
(*val) = OBJ_NEW(opal_value_t);
602+
(*val)->key = strdup(key);
603603
(*val)->type = OPAL_UINT32;
604604
(*val)->data.uint32 = OPAL_PROC_MY_NAME.jobid;
605605
OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock);
@@ -608,6 +608,7 @@ int pmix2x_get(const opal_process_name_t *proc, const char *key,
608608
/* if they are asking for our rank, return it */
609609
if (0 == strcmp(key, OPAL_PMIX_RANK)) {
610610
(*val) = OBJ_NEW(opal_value_t);
611+
(*val)->key = strdup(key);
611612
(*val)->type = OPAL_INT;
612613
(*val)->data.integer = pmix2x_convert_rank(my_proc.rank);
613614
OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock);
@@ -642,6 +643,9 @@ int pmix2x_get(const opal_process_name_t *proc, const char *key,
642643
rc = PMIx_Get(&p, key, pinfo, sz, &pval);
643644
if (PMIX_SUCCESS == rc) {
644645
ival = OBJ_NEW(opal_value_t);
646+
if (NULL != key) {
647+
ival->key = strdup(key);
648+
}
645649
if (OPAL_SUCCESS != (ret = pmix2x_value_unload(ival, pval))) {
646650
rc = pmix2x_convert_opalrc(ret);
647651
} else {
@@ -663,6 +667,9 @@ static void val_cbfunc(pmix_status_t status,
663667

664668
OPAL_ACQUIRE_OBJECT(op);
665669
OBJ_CONSTRUCT(&val, opal_value_t);
670+
if (NULL != op->nspace) {
671+
val.key = strdup(op->nspace);
672+
}
666673
rc = pmix2x_convert_opalrc(status);
667674
if (PMIX_SUCCESS == status && NULL != kv) {
668675
rc = pmix2x_value_unload(&val, kv);
@@ -702,6 +709,7 @@ int pmix2x_getnb(const opal_process_name_t *proc, const char *key,
702709
if (0 == strcmp(key, OPAL_PMIX_JOBID)) {
703710
if (NULL != cbfunc) {
704711
val = OBJ_NEW(opal_value_t);
712+
val->key = strdup(key);
705713
val->type = OPAL_UINT32;
706714
val->data.uint32 = OPAL_PROC_MY_NAME.jobid;
707715
cbfunc(OPAL_SUCCESS, val, cbdata);
@@ -713,6 +721,7 @@ int pmix2x_getnb(const opal_process_name_t *proc, const char *key,
713721
if (0 == strcmp(key, OPAL_PMIX_RANK)) {
714722
if (NULL != cbfunc) {
715723
val = OBJ_NEW(opal_value_t);
724+
val->key = strdup(key);
716725
val->type = OPAL_INT;
717726
val->data.integer = pmix2x_convert_rank(my_proc.rank);
718727
cbfunc(OPAL_SUCCESS, val, cbdata);
@@ -726,7 +735,9 @@ int pmix2x_getnb(const opal_process_name_t *proc, const char *key,
726735
op = OBJ_NEW(pmix2x_opcaddy_t);
727736
op->valcbfunc = cbfunc;
728737
op->cbdata = cbdata;
729-
738+
if (NULL != key) {
739+
op->nspace = strdup(key);
740+
}
730741
if (NULL == proc) {
731742
(void)strncpy(op->p.nspace, my_proc.nspace, PMIX_MAX_NSLEN);
732743
op->p.rank = pmix2x_convert_rank(PMIX_RANK_WILDCARD);

opal/mca/pmix/pmix2x/pmix2x_component.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
2+
* Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
33
* Copyright (c) 2014-2015 Research Organization for Information Science
44
* and Technology (RIST). All rights reserved.
55
* Copyright (c) 2016 Cisco Systems, Inc. All rights reserved.
@@ -21,6 +21,7 @@
2121
#include "opal/constants.h"
2222
#include "opal/class/opal_list.h"
2323
#include "opal/util/proc.h"
24+
#include "opal/util/show_help.h"
2425
#include "opal/mca/pmix/pmix.h"
2526
#include "pmix2x.h"
2627

@@ -74,6 +75,7 @@ mca_pmix_pmix2x_component_t mca_pmix_pmix2x_component = {
7475
MCA_BASE_METADATA_PARAM_CHECKPOINT
7576
}
7677
},
78+
.legacy_get = true,
7779
.native_launch = false
7880
};
7981

orte/mca/grpcomm/direct/grpcomm_direct.c

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ static void xcast_recv(int status, orte_process_name_t* sender,
275275
size_t inlen, cmplen;
276276
uint8_t *packed_data, *cmpdata;
277277
int32_t nvals, i;
278-
opal_value_t *kv;
278+
opal_value_t kv, *kval;
279279
orte_process_name_t dmn;
280280

281281
OPAL_OUTPUT_VERBOSE((1, orte_grpcomm_base_framework.framework_output,
@@ -461,33 +461,57 @@ static void xcast_recv(int status, orte_process_name_t* sender,
461461
OBJ_CONSTRUCT(&wireup, opal_buffer_t);
462462
opal_dss.load(&wireup, bo->bytes, bo->size);
463463
/* decode it, pushing the info into our database */
464-
cnt=1;
465-
while (OPAL_SUCCESS == (ret = opal_dss.unpack(&wireup, &dmn, &cnt, ORTE_NAME))) {
466-
cnt = 1;
467-
if (ORTE_SUCCESS != (ret = opal_dss.unpack(&wireup, &nvals, &cnt, OPAL_INT32))) {
464+
if (opal_pmix.legacy_get()) {
465+
OBJ_CONSTRUCT(&kv, opal_value_t);
466+
kv.key = OPAL_PMIX_PROC_URI;
467+
kv.type = OPAL_STRING;
468+
cnt=1;
469+
while (OPAL_SUCCESS == (ret = opal_dss.unpack(&wireup, &dmn, &cnt, ORTE_NAME))) {
470+
cnt = 1;
471+
if (ORTE_SUCCESS != (ret = opal_dss.unpack(&wireup, &kv.data.string, &cnt, OPAL_STRING))) {
472+
ORTE_ERROR_LOG(ret);
473+
break;
474+
}
475+
if (OPAL_SUCCESS != (ret = opal_pmix.store_local(&dmn, &kv))) {
476+
ORTE_ERROR_LOG(ret);
477+
free(kv.data.string);
478+
break;
479+
}
480+
free(kv.data.string);
481+
kv.data.string = NULL;
482+
}
483+
if (ORTE_ERR_UNPACK_READ_PAST_END_OF_BUFFER != ret) {
468484
ORTE_ERROR_LOG(ret);
469-
break;
470485
}
471-
for (i=0; i < nvals; i++) {
486+
} else {
487+
cnt=1;
488+
while (OPAL_SUCCESS == (ret = opal_dss.unpack(&wireup, &dmn, &cnt, ORTE_NAME))) {
489+
cnt = 1;
490+
if (ORTE_SUCCESS != (ret = opal_dss.unpack(&wireup, &nvals, &cnt, OPAL_INT32))) {
491+
ORTE_ERROR_LOG(ret);
492+
break;
493+
}
494+
for (i=0; i < nvals; i++) {
472495
cnt = 1;
473-
if (ORTE_SUCCESS != (ret = opal_dss.unpack(&wireup, &kv, &cnt, OPAL_VALUE))) {
496+
if (ORTE_SUCCESS != (ret = opal_dss.unpack(&wireup, &kval, &cnt, OPAL_VALUE))) {
474497
ORTE_ERROR_LOG(ret);
475498
break;
476499
}
477500
OPAL_OUTPUT_VERBOSE((5, orte_grpcomm_base_framework.framework_output,
478-
"%s STORING MODEX DATA FOR PROC %s KEY %s",
479-
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
480-
ORTE_NAME_PRINT(&dmn), kv->key));
481-
if (OPAL_SUCCESS != (ret = opal_pmix.store_local(&dmn, kv))) {
501+
"%s STORING MODEX DATA FOR PROC %s KEY %s",
502+
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
503+
ORTE_NAME_PRINT(&dmn), kval->key));
504+
if (OPAL_SUCCESS != (ret = opal_pmix.store_local(&dmn, kval))) {
482505
ORTE_ERROR_LOG(ret);
483-
OBJ_RELEASE(kv);
506+
OBJ_RELEASE(kval);
484507
break;
485508
}
486-
OBJ_RELEASE(kv);
509+
OBJ_RELEASE(kval);
510+
}
511+
}
512+
if (ORTE_ERR_UNPACK_READ_PAST_END_OF_BUFFER != ret) {
513+
ORTE_ERROR_LOG(ret);
487514
}
488-
}
489-
if (ORTE_ERR_UNPACK_READ_PAST_END_OF_BUFFER != ret) {
490-
ORTE_ERROR_LOG(ret);
491515
}
492516
/* done with the wireup buffer - dump it */
493517
OBJ_DESTRUCT(&wireup);

0 commit comments

Comments
 (0)