This source file includes following definitions.
- cbfunc
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 #include <src/include/pmix_config.h>
27 #include <pmix_tool.h>
28
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <unistd.h>
32 #include <time.h>
33
34 #include "src/class/pmix_object.h"
35 #include "src/util/argv.h"
36 #include "src/util/output.h"
37 #include "src/util/printf.h"
38
39 static pmix_proc_t myproc;
40
41 static void cbfunc(pmix_status_t status,
42 pmix_info_t *info, size_t ninfo,
43 void *cbdata,
44 pmix_release_cbfunc_t release_fn,
45 void *release_cbdata)
46 {
47 volatile bool *active = (volatile bool*)cbdata;
48
49 if (0 != strncmp(info[0].key, "foobar", PMIX_MAX_KEYLEN)) {
50 pmix_output(0, "Client ns %s rank %d: PMIx_Query_info[0] key wrong: %s vs foobar",
51 myproc.nspace, myproc.rank, info[0].key);
52 }
53 if (0 != strncmp(info[1].key, "spastic", PMIX_MAX_KEYLEN)) {
54 pmix_output(0, "Client ns %s rank %d: PMIx_Query_info[1] key wrong: %s vs spastic",
55 myproc.nspace, myproc.rank, info[1].key);
56 }
57 if (PMIX_STRING != info[0].value.type) {
58 pmix_output(0, "Client ns %s rank %d: PMIx_Query_info key[0] wrong type: %d vs %d",
59 myproc.nspace, myproc.rank, info[0].value.type, PMIX_STRING);
60 }
61 if (PMIX_STRING != info[1].value.type) {
62 pmix_output(0, "Client ns %s rank %d: PMIx_Query_info key[1] wrong type: %d vs %d",
63 myproc.nspace, myproc.rank, info[1].value.type, PMIX_STRING);
64 }
65 if (0 != strcmp(info[0].value.data.string, "0")) {
66 pmix_output(0, "Client ns %s rank %d: PMIx_Query_info key[0] wrong value: %s vs 0",
67 myproc.nspace, myproc.rank, info[1].value.data.string);
68 }
69 if (0 != strcmp(info[1].value.data.string, "1")) {
70 pmix_output(0, "Client ns %s rank %d: PMIx_Query_info key[1] wrong value: %s vs 1",
71 myproc.nspace, myproc.rank, info[1].value.data.string);
72 }
73
74 if (NULL != release_fn) {
75 release_fn(release_cbdata);
76 }
77 *active = false;
78 }
79
80 int main(int argc, char **argv)
81 {
82 pmix_status_t rc;
83 pmix_query_t *query;
84 size_t nq;
85 volatile bool active;
86
87 if (PMIX_SUCCESS != (rc = PMIx_tool_init(&myproc, NULL, 0))) {
88 fprintf(stderr, "PMIx_tool_init failed: %d\n", rc);
89 exit(rc);
90 }
91 pmix_output(0, "Tool ns %s rank %d: Running", myproc.nspace, myproc.rank);
92
93
94 nq = 2;
95 PMIX_QUERY_CREATE(query, nq);
96 pmix_argv_append_nosize(&query[0].keys, "foobar");
97 pmix_argv_append_nosize(&query[1].keys, "spastic");
98 pmix_argv_append_nosize(&query[1].keys, PMIX_SERVER_URI);
99 active = true;
100 if (PMIX_SUCCESS != (rc = PMIx_Query_info_nb(query, nq, cbfunc, (void*)&active))) {
101 pmix_output(0, "Client ns %s rank %d: PMIx_Query_info failed: %d", myproc.nspace, myproc.rank, rc);
102 goto done;
103 }
104 while(active) {
105 usleep(10);
106 }
107 done:
108
109 pmix_output(0, "Client ns %s rank %d: Finalizing", myproc.nspace, myproc.rank);
110 if (PMIX_SUCCESS != (rc = PMIx_Finalize(NULL, 0))) {
111 fprintf(stderr, "Client ns %s rank %d:PMIx_Finalize failed: %d\n", myproc.nspace, myproc.rank, rc);
112 } else {
113 fprintf(stderr, "Client ns %s rank %d:PMIx_Finalize successfully completed\n", myproc.nspace, myproc.rank);
114 }
115 fflush(stderr);
116 return(rc);
117 }