Skip to content

Commit b5a39f4

Browse files
authored
Merge pull request #3742 from rhc54/cmr30/query
Fix the pmix_query API when it asks for something that returns an arr…
2 parents 7fcc175 + 68de0c1 commit b5a39f4

File tree

3 files changed

+28
-23
lines changed

3 files changed

+28
-23
lines changed

contrib/scaling/mpi_memprobe.c

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <stdio.h>
1111
#include "mpi.h"
1212
#include "opal/mca/pmix/pmix.h"
13+
#include "opal/util/argv.h"
1314
#include "orte/runtime/runtime.h"
1415
#include "orte/util/proc_info.h"
1516
#include "orte/util/name_fns.h"
@@ -117,17 +118,19 @@ static void sample(void)
117118
free(tmp);
118119
OPAL_LIST_FOREACH(kv, &response, opal_value_t) {
119120
lt = (opal_list_t*)kv->data.ptr;
120-
OPAL_LIST_FOREACH(ival, lt, opal_value_t) {
121-
if (0 == strcmp(ival->key, OPAL_PMIX_DAEMON_MEMORY)) {
122-
asprintf(&tmp, "\tDaemon: %f", ival->data.fval);
123-
opal_argv_append_nosize(&answer, tmp);
124-
free(tmp);
125-
} else if (0 == strcmp(ival->key, OPAL_PMIX_CLIENT_AVG_MEMORY)) {
126-
asprintf(&tmp, "\tClient: %f", ival->data.fval);
127-
opal_argv_append_nosize(&answer, tmp);
128-
free(tmp);
129-
} else {
130-
fprintf(stderr, "\tUnknown key: %s", ival->key);
121+
if (NULL != lt) {
122+
OPAL_LIST_FOREACH(ival, lt, opal_value_t) {
123+
if (0 == strcmp(ival->key, OPAL_PMIX_DAEMON_MEMORY)) {
124+
asprintf(&tmp, "\tDaemon: %f", ival->data.fval);
125+
opal_argv_append_nosize(&answer, tmp);
126+
free(tmp);
127+
} else if (0 == strcmp(ival->key, OPAL_PMIX_CLIENT_AVG_MEMORY)) {
128+
asprintf(&tmp, "\tClient: %f", ival->data.fval);
129+
opal_argv_append_nosize(&answer, tmp);
130+
free(tmp);
131+
} else {
132+
fprintf(stderr, "\tUnknown key: %s", ival->key);
133+
}
131134
}
132135
}
133136
}
@@ -149,7 +152,6 @@ static void sample(void)
149152
}
150153
OPAL_LIST_DESTRUCT(&response);
151154

152-
153155
if (0 == rank) {
154156
/* send the notification to release the other procs */
155157
wait_for_release = true;
@@ -162,19 +164,15 @@ static void sample(void)
162164
active = -1;
163165
if (OPAL_SUCCESS != opal_pmix.notify_event(MEMPROBE_RELEASE, NULL,
164166
OPAL_PMIX_RANGE_GLOBAL, &response,
165-
notifycbfunc, (void*)&active)) {
167+
NULL, NULL)) {
166168
fprintf(stderr, "Notify event failed\n");
167169
exit(1);
168170
}
169-
while (-1 == active) {
171+
} else {
172+
/* now wait for notification */
173+
while (wait_for_release) {
170174
usleep(10);
171175
}
172-
OPAL_LIST_DESTRUCT(&response);
173-
}
174-
175-
/* now wait for notification */
176-
while (wait_for_release) {
177-
usleep(10);
178176
}
179177
}
180178

opal/mca/pmix/pmix2x/pmix/include/pmix_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ typedef struct pmix_value {
907907
free((m)->data.bo.bytes); \
908908
} \
909909
} else if (PMIX_DATA_ARRAY == (m)->type) { \
910-
if (NULL != (m)->data.darray) { \
910+
if (NULL != (m)->data.darray && NULL != (m)->data.darray->array) { \
911911
if (PMIX_STRING == (m)->data.darray->type) { \
912912
char **_str = (char**)(m)->data.darray->array; \
913913
for (_n=0; _n < (m)->data.darray->size; _n++) { \

opal/mca/pmix/pmix2x/pmix/src/buffer_ops/unpack.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,8 +714,8 @@ pmix_status_t pmix_bfrop_unpack_status(pmix_buffer_t *buffer, void *dest,
714714
break;
715715
/********************/
716716
default:
717-
pmix_output(0, "UNPACK-PMIX-VALUE: UNSUPPORTED TYPE %d", (int)val->type);
718-
return PMIX_ERROR;
717+
pmix_output(0, "UNPACK-PMIX-VALUE: UNSUPPORTED TYPE %d", (int)val->type);
718+
return PMIX_ERROR;
719719
}
720720

721721
return PMIX_SUCCESS;
@@ -765,6 +765,7 @@ pmix_status_t pmix_bfrop_unpack_info(pmix_buffer_t *buffer, void *dest,
765765
m=1;
766766
tmp = NULL;
767767
if (PMIX_SUCCESS != (ret = pmix_bfrop_unpack_string(buffer, &tmp, &m, PMIX_STRING))) {
768+
PMIX_ERROR_LOG(ret);
768769
return ret;
769770
}
770771
if (NULL == tmp) {
@@ -776,19 +777,22 @@ pmix_status_t pmix_bfrop_unpack_info(pmix_buffer_t *buffer, void *dest,
776777
/* unpack the flags */
777778
m=1;
778779
if (PMIX_SUCCESS != (ret = pmix_bfrop_unpack_infodirs(buffer, &ptr[i].flags, &m, PMIX_INFO_DIRECTIVES))) {
780+
PMIX_ERROR_LOG(ret);
779781
return ret;
780782
}
781783
/* unpack value - since the value structure is statically-defined
782784
* instead of a pointer in this struct, we directly unpack it to
783785
* avoid the malloc */
784786
m=1;
785787
if (PMIX_SUCCESS != (ret = pmix_bfrop_unpack_int(buffer, &ptr[i].value.type, &m, PMIX_INT))) {
788+
PMIX_ERROR_LOG(ret);
786789
return ret;
787790
}
788791
pmix_output_verbose(20, pmix_globals.debug_output,
789792
"pmix_bfrop_unpack: info type %d", ptr[i].value.type);
790793
m=1;
791794
if (PMIX_SUCCESS != (ret = unpack_val(buffer, &ptr[i].value))) {
795+
PMIX_ERROR_LOG(ret);
792796
return ret;
793797
}
794798
}
@@ -1273,6 +1277,9 @@ pmix_status_t pmix_bfrop_unpack_darray(pmix_buffer_t *buffer, void *dest,
12731277
case PMIX_STATUS:
12741278
nbytes = sizeof(pmix_status_t);
12751279
break;
1280+
case PMIX_INFO:
1281+
nbytes = sizeof(pmix_info_t);
1282+
break;
12761283
case PMIX_PROC:
12771284
nbytes = sizeof(pmix_proc_t);
12781285
break;

0 commit comments

Comments
 (0)