This source file includes following definitions.
- notification_fn
- errhandler_reg_callbk
- 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.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/output.h"
36 #include "src/util/printf.h"
37
38 #define MAXCNT 1
39
40 static volatile bool completed = false;
41 static pmix_proc_t myproc;
42
43 static void notification_fn(size_t evhdlr_registration_id,
44 pmix_status_t status,
45 const pmix_proc_t *source,
46 pmix_info_t info[], size_t ninfo,
47 pmix_info_t results[], size_t nresults,
48 pmix_event_notification_cbfunc_fn_t cbfunc,
49 void *cbdata)
50 {
51 pmix_output(0, "Client %s:%d NOTIFIED with status %s", myproc.nspace, myproc.rank, PMIx_Error_string(status));
52 if (NULL != cbfunc) {
53 cbfunc(PMIX_SUCCESS, NULL, 0, NULL, NULL, cbdata);
54 }
55 completed = true;
56 }
57
58 static void errhandler_reg_callbk(pmix_status_t status,
59 size_t errhandler_ref,
60 void *cbdata)
61 {
62 volatile bool *active = (volatile bool*)cbdata;
63
64 pmix_output(0, "Client: ERRHANDLER REGISTRATION CALLBACK CALLED WITH STATUS %d, ref=%lu",
65 status, (unsigned long)errhandler_ref);
66 *active = false;
67 }
68
69
70 int main(int argc, char **argv)
71 {
72 int rc;
73 pmix_value_t value;
74 pmix_value_t *val = &value;
75 pmix_proc_t proc;
76 uint32_t nprocs, n;
77 volatile bool active;
78 pmix_info_t info;
79
80
81 if (PMIX_SUCCESS != (rc = PMIx_Init(&myproc, NULL, 0))) {
82 pmix_output(0, "Client ns %s rank %d: PMIx_Init failed: %s",
83 myproc.nspace, myproc.rank, PMIx_Error_string(rc));
84 exit(rc);
85 }
86 pmix_output(0, "Client ns %s rank %d: Running", myproc.nspace, myproc.rank);
87
88
89 (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN);
90 proc.rank = PMIX_RANK_WILDCARD;
91 if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_JOB_SIZE, NULL, 0, &val))) {
92 pmix_output(0, "Client ns %s rank %d: PMIx_Get failed: %s",
93 myproc.nspace, myproc.rank, PMIx_Error_string(rc));
94 exit(rc);
95 }
96 PMIX_VALUE_RELEASE(val);
97
98
99 active = true;
100 PMIx_Register_event_handler(NULL, 0, NULL, 0,
101 notification_fn, errhandler_reg_callbk, (void*)&active);
102 while (active) {
103 usleep(10);
104 }
105
106
107 (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN);
108 proc.rank = PMIX_RANK_WILDCARD;
109 if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_UNIV_SIZE, NULL, 0, &val))) {
110 pmix_output(0, "Client ns %s rank %d: PMIx_Get universe size failed: %s",
111 myproc.nspace, myproc.rank, PMIx_Error_string(rc));
112 goto done;
113 }
114 nprocs = val->data.uint32;
115 PMIX_VALUE_RELEASE(val);
116 pmix_output(0, "Client %s:%d universe size %d", myproc.nspace, myproc.rank, nprocs);
117
118
119 if (0 == myproc.rank) {
120 PMIX_INFO_CONSTRUCT(&info);
121 n = 1;
122 PMIX_INFO_LOAD(&info, PMIX_TIMEOUT, &n, PMIX_UINT32);
123 PMIX_PROC_CONSTRUCT(&proc);
124 (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN);
125 proc.rank = PMIX_RANK_WILDCARD;
126 pmix_output(0, "TEST FENCE TIMEOUT");
127 if (PMIX_ERR_TIMEOUT != (rc = PMIx_Fence(&proc, 1, &info, 1))) {
128 pmix_output(0, "Client ns %s rank %d: PMIx_Fence did not timeout: %s",
129 myproc.nspace, myproc.rank, PMIx_Error_string(rc));
130 goto done;
131 }
132 pmix_output(0, "FENCE TIMEOUT SUCCEEDED");
133
134
135 pmix_output(0, "TEST CONNECT TIMEOUT");
136 if (PMIX_ERR_TIMEOUT != (rc = PMIx_Connect(&proc, 1, &info, 1))) {
137 pmix_output(0, "Client ns %s rank %d: PMIx_Connect did not timeout: %s",
138 myproc.nspace, myproc.rank, PMIx_Error_string(rc));
139 goto done;
140 }
141 pmix_output(0, "CONNECT TIMEOUT SUCCEEDED");
142
143
144 proc.rank = 1;
145 pmix_output(0, "TEST GET TIMEOUT");
146 if (PMIX_ERR_TIMEOUT == (rc = PMIx_Get(&proc, "1234", &info, 1, &val))) {
147 pmix_output(0, "Client ns %s rank %d: PMIx_Get did not timeout: %s",
148 myproc.nspace, myproc.rank, PMIx_Error_string(rc));
149 goto done;
150 }
151 pmix_output(0, "GET TIMEOUT SUCCEEDED");
152
153 } else {
154 sleep(5);
155 }
156
157 done:
158
159 pmix_output(0, "Client ns %s rank %d: Finalizing", myproc.nspace, myproc.rank);
160 if (PMIX_SUCCESS != (rc = PMIx_Finalize(NULL, 0))) {
161 fprintf(stderr, "Client ns %s rank %d:PMIx_Finalize failed: %s\n",
162 myproc.nspace, myproc.rank, PMIx_Error_string(rc));
163 } else {
164 fprintf(stderr, "Client ns %s rank %d:PMIx_Finalize successfully completed\n", myproc.nspace, myproc.rank);
165 }
166 fflush(stderr);
167 return(rc);
168 }