Skip to content

Commit 64c9e23

Browse files
author
Ralph Castain
authored
Merge pull request #37 from rhc54/topic/proctable
Implement support for proctable queries
2 parents 4dc43ae + c1bab0d commit 64c9e23

25 files changed

+1851
-874
lines changed

examples/debugger.c

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ typedef struct {
7474
* info from a query */
7575
typedef struct {
7676
mylock_t lock;
77+
pmix_status_t status;
7778
pmix_info_t *info;
7879
size_t ninfo;
7980
} myquery_data_t;
@@ -105,14 +106,14 @@ static void cbfunc(pmix_status_t status,
105106
myquery_data_t *mq = (myquery_data_t*)cbdata;
106107
size_t n;
107108

109+
mq->status = status;
108110
/* save the returned info - the PMIx library "owns" it
109111
* and will release it and perform other cleanup actions
110112
* when release_fn is called */
111113
if (0 < ninfo) {
112114
PMIX_INFO_CREATE(mq->info, ninfo);
113115
mq->ninfo = ninfo;
114116
for (n=0; n < ninfo; n++) {
115-
fprintf(stderr, "Transferring %s\n", info[n].key);
116117
PMIX_INFO_XFER(&mq->info[n], &info[n]);
117118
}
118119
}
@@ -337,9 +338,11 @@ int main(int argc, char **argv)
337338
/* check to see if we are using an intermediate launcher - we only
338339
* support those we recognize */
339340
found = false;
340-
for (n=0; NULL != launchers[n]; n++) {
341-
if (0 == strcmp(argv[1], launchers[n])) {
342-
found = true;
341+
if (1 < argc) {
342+
for (n=0; NULL != launchers[n]; n++) {
343+
if (0 == strcmp(argv[1], launchers[n])) {
344+
found = true;
345+
}
343346
}
344347
}
345348
if (found) {
@@ -507,6 +510,61 @@ int main(int argc, char **argv)
507510
PMIX_INFO_FREE(info, ninfo);
508511
PMIX_APP_FREE(app, napps);
509512

513+
/* get the proctable for this nspace */
514+
PMIX_QUERY_CREATE(query, 1);
515+
PMIX_ARGV_APPEND(rc, query[0].keys, PMIX_QUERY_PROC_TABLE);
516+
query[0].nqual = 1;
517+
PMIX_INFO_CREATE(query->qualifiers, query[0].nqual);
518+
PMIX_INFO_LOAD(&query->qualifiers[0], PMIX_NSPACE, clientspace, PMIX_STRING);
519+
520+
DEBUG_CONSTRUCT_LOCK(&myquery_data.lock);
521+
myquery_data.info = NULL;
522+
myquery_data.ninfo = 0;
523+
524+
if (PMIX_SUCCESS != (rc = PMIx_Query_info_nb(query, 1, cbfunc, (void*)&myquery_data))) {
525+
fprintf(stderr, "Debugger[%s:%d] Proctable query failed: %d\n", myproc.nspace, myproc.rank, rc);
526+
goto done;
527+
}
528+
/* wait to get a response */
529+
DEBUG_WAIT_THREAD(&myquery_data.lock);
530+
DEBUG_DESTRUCT_LOCK(&myquery_data.lock);
531+
532+
/* we should have gotten a response */
533+
if (PMIX_SUCCESS != myquery_data.status) {
534+
fprintf(stderr, "Debugger[%s:%d] Proctable query failed: %s\n",
535+
myproc.nspace, myproc.rank, PMIx_Error_string(myquery_data.status));
536+
goto done;
537+
}
538+
/* there should hvae been data */
539+
if (NULL == myquery_data.info || 0 == myquery_data.ninfo) {
540+
fprintf(stderr, "Debugger[%s:%d] Proctable query return no results\n",
541+
myproc.nspace, myproc.rank);
542+
goto done;
543+
}
544+
/* the query should have returned a data_array */
545+
if (PMIX_DATA_ARRAY != myquery_data.info[0].value.type) {
546+
fprintf(stderr, "Debugger[%s:%d] Query returned incorrect data type: %s\n", PMIx_Data_type_string(myquery_data.info[0].value.type));
547+
return -1;
548+
}
549+
if (NULL == myquery_data.info[0].value.data.darray->array) {
550+
fprintf(stderr, "Debugger[%s:%d] Query returned no proctable info\n");
551+
goto done;
552+
}
553+
/* the data array consists of a struct:
554+
* size_t size;
555+
* void* array;
556+
*
557+
* In this case, the array is composed of pmix_proc_info_t structs:
558+
* pmix_proc_t proc; // contains the nspace,rank of this proc
559+
* char* hostname;
560+
* char* executable_name;
561+
* pid_t pid;
562+
* int exit_code;
563+
* pmix_proc_state_t state;
564+
*/
565+
fprintf(stderr, "Received %d array elements\n", (int)myquery_data.info[0].value.data.darray->size);
566+
goto done;
567+
510568
/* now launch the debugger daemons */
511569
if (PMIX_SUCCESS != (rc = spawn_debugger(clientspace))) {
512570
goto done;

opal/class/Makefile.am

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
# Copyright (c) 2004-2005 The Regents of the University of California.
1212
# All rights reserved.
1313
# Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
14-
# Copyright (c) 2014-2015 Los Alamos National Security, LLC. All rights
14+
# Copyright (c) 2014-2018 Los Alamos National Security, LLC. All rights
1515
# reserved.
16+
# Copyright (c) 2018 Intel, Inc. All rights reserved.
1617
# $COPYRIGHT$
1718
#
1819
# Additional copyrights may follow
@@ -38,7 +39,8 @@ headers += \
3839
class/opal_pointer_array.h \
3940
class/opal_value_array.h \
4041
class/opal_ring_buffer.h \
41-
class/opal_rb_tree.h
42+
class/opal_rb_tree.h \
43+
class/opal_interval_tree.h
4244

4345
lib@OPAL_LIB_PREFIX@open_pal_la_SOURCES += \
4446
class/opal_bitmap.c \
@@ -54,4 +56,5 @@ lib@OPAL_LIB_PREFIX@open_pal_la_SOURCES += \
5456
class/opal_pointer_array.c \
5557
class/opal_value_array.c \
5658
class/opal_ring_buffer.c \
57-
class/opal_rb_tree.c
59+
class/opal_rb_tree.c \
60+
class/opal_interval_tree.c

0 commit comments

Comments
 (0)