17
17
* Copyright (c) 2015 Mellanox Technologies, Inc. All rights reserved.
18
18
* Copyright (c) 2019-2022 IBM Corporation. All rights reserved.
19
19
* Copyright (c) 2021-2022 Nanook Consulting All rights reserved.
20
- * Copyright (c) 2022 Triad National Security, LLC. All rights reserved.
21
20
* $COPYRIGHT$
22
21
*
23
22
* Additional copyrights may follow
26
25
*
27
26
*/
28
27
29
- #include "examples.h"
30
- #include "src/include/pmix_config.h"
31
- #include "../include/pmix.h"
32
-
33
-
34
28
#include <stdio.h>
35
29
#include <stdlib.h>
36
30
#include <time.h>
37
31
#include <unistd.h>
32
+ #include <pmix.h>
33
+
34
+ #include "examples.h"
38
35
39
36
static uint32_t nprocs ;
40
37
static pmix_proc_t myproc ;
@@ -51,6 +48,8 @@ int main(int argc, char **argv)
51
48
char * * peers ;
52
49
pmix_rank_t * locals = NULL ;
53
50
uint8_t j ;
51
+ pmix_info_t timeout ;
52
+ int tlimit = 10 ;
54
53
55
54
EXAMPLES_HIDE_UNUSED_PARAMS (argc , argv );
56
55
@@ -60,7 +59,6 @@ int main(int argc, char **argv)
60
59
rc );
61
60
exit (0 );
62
61
}
63
- fprintf (stderr , "Client ns %s rank %d: Running\n" , myproc .nspace , myproc .rank );
64
62
65
63
/* get our job size */
66
64
PMIX_LOAD_PROCID (& proc , myproc .nspace , PMIX_RANK_WILDCARD );
@@ -71,7 +69,10 @@ int main(int argc, char **argv)
71
69
}
72
70
nprocs = val -> data .uint32 ;
73
71
PMIX_VALUE_RELEASE (val );
74
- fprintf (stderr , "Client %s:%d job size %d\n" , myproc .nspace , myproc .rank , nprocs );
72
+
73
+ if (0 == myproc .rank ) {
74
+ fprintf (stderr , "Client ns %s rank %d: Running. World size %d\n" , myproc .nspace , myproc .rank , nprocs );
75
+ }
75
76
76
77
/* put a few values */
77
78
(void ) snprintf (tmp , 1024 , "%s-%d-internal" , myproc .nspace , myproc .rank );
@@ -144,9 +145,14 @@ int main(int argc, char **argv)
144
145
PMIX_ARGV_FREE (peers );
145
146
146
147
PMIX_LOAD_NSPACE (proc .nspace , myproc .nspace );
148
+ PMIX_INFO_LOAD (& timeout , PMIX_TIMEOUT , & tlimit , PMIX_INT );
147
149
/* get the committed data - ask for someone who doesn't exist as well */
148
150
for (n = 0 ; n < nprocs ; n ++ ) {
149
- if (all_local ) {
151
+ if (n == myproc .rank ) {
152
+ /* local peers doesn't include us, so check for
153
+ * ourselves separately */
154
+ local = true;
155
+ } else if (all_local ) {
150
156
local = true;
151
157
} else {
152
158
local = false;
@@ -161,70 +167,64 @@ int main(int argc, char **argv)
161
167
proc .rank = n ;
162
168
if (local ) {
163
169
(void )snprintf (tmp , 1024 , "%s-%d-local" , proc .nspace , n );
164
- if (PMIX_SUCCESS != (rc = PMIx_Get (& proc , tmp , NULL , 0 , & val ))) {
165
- fprintf (stderr , "Client ns %s rank %d: PMIx_Get %s failed: %d \n" , myproc .nspace , n ,
166
- tmp , rc );
170
+ if (PMIX_SUCCESS != (rc = PMIx_Get (& proc , tmp , & timeout , 1 , & val ))) {
171
+ fprintf (stderr , "Client ns %s rank %d: PMIx_Get %s failed: %s \n" , myproc .nspace , myproc . rank ,
172
+ tmp , PMIx_Error_string ( rc ) );
167
173
goto done ;
168
174
}
169
175
if (PMIX_UINT64 != val -> type ) {
170
- fprintf (stderr , "%s:%d: PMIx_Get Key %s returned wrong type: %d \n" , myproc .nspace ,
171
- myproc .rank , tmp , val -> type );
176
+ fprintf (stderr , "%s:%d: PMIx_Get Key %s failed - returned wrong type: %s \n" , myproc .nspace ,
177
+ myproc .rank , tmp , PMIx_Data_type_string ( val -> type ) );
172
178
PMIX_VALUE_RELEASE (val );
173
179
goto done ;
174
180
}
175
181
if (1234 != val -> data .uint64 ) {
176
- fprintf (stderr , "%s:%d: PMIx_Get Key %s returned wrong value: %d\n" , myproc .nspace ,
182
+ fprintf (stderr , "%s:%d: PMIx_Get Key %s failed - returned wrong value: %d\n" , myproc .nspace ,
177
183
myproc .rank , tmp , (int ) val -> data .uint64 );
178
184
PMIX_VALUE_RELEASE (val );
179
185
goto done ;
180
186
}
181
- fprintf (stderr , "%s:%d Local value for %s:%d successfully retrieved\n" , myproc .nspace ,
182
- myproc .rank , proc .nspace , proc .rank );
183
187
PMIX_VALUE_RELEASE (val );
184
188
} else {
185
189
(void )snprintf (tmp , 1024 , "%s-%d-remote" , myproc .nspace , n );
186
- if (PMIX_SUCCESS != (rc = PMIx_Get (& proc , tmp , NULL , 0 , & val ))) {
187
- fprintf (stderr , "Client ns %s rank %d: PMIx_Get %s failed: %d \n" , myproc .nspace , n ,
188
- tmp , rc );
190
+ if (PMIX_SUCCESS != (rc = PMIx_Get (& proc , tmp , & timeout , 1 , & val ))) {
191
+ fprintf (stderr , "Client ns %s rank %d: PMIx_Get %s failed: %s \n" , myproc .nspace , myproc . rank ,
192
+ tmp , PMIx_Error_string ( rc ) );
189
193
goto done ;
190
194
}
191
195
if (PMIX_STRING != val -> type ) {
192
- fprintf (stderr , "%s:%d: PMIx_Get Key %s returned wrong type: %d \n" , myproc .nspace ,
193
- myproc .rank , tmp , val -> type );
196
+ fprintf (stderr , "%s:%d: PMIx_Get Key %s failed - returned wrong type: %s \n" , myproc .nspace ,
197
+ myproc .rank , tmp , PMIx_Data_type_string ( val -> type ) );
194
198
PMIX_VALUE_RELEASE (val );
195
199
goto done ;
196
200
}
197
201
if (0 != strcmp (val -> data .string , "1234" )) {
198
- fprintf (stderr , "%s:%d: PMIx_Get Key %s returned wrong value: %s\n" , myproc .nspace ,
202
+ fprintf (stderr , "%s:%d: PMIx_Get Key %s failed - returned wrong value: %s\n" , myproc .nspace ,
199
203
myproc .rank , tmp , val -> data .string );
200
204
PMIX_VALUE_RELEASE (val );
201
205
goto done ;
202
206
}
203
- fprintf (stderr , "%s:%d Remote value for %s:%d successfully retrieved\n" , myproc .nspace ,
204
- myproc .rank , proc .nspace , proc .rank );
205
207
PMIX_VALUE_RELEASE (val );
206
208
}
207
209
/* if this isn't us, then get the ghex key */
208
210
if (n != myproc .rank ) {
209
- if (PMIX_SUCCESS != (rc = PMIx_Get (& proc , "ghex" , NULL , 0 , & val ))) {
210
- fprintf (stderr , "Client ns %s rank %d: PMIx_Get ghex failed: %d \n" , myproc .nspace ,
211
- n , rc );
211
+ if (PMIX_SUCCESS != (rc = PMIx_Get (& proc , "ghex" , & timeout , 1 , & val ))) {
212
+ fprintf (stderr , "Client ns %s rank %d: PMIx_Get ghex failed: %s \n" , myproc .nspace ,
213
+ myproc . rank , PMIx_Error_string ( rc ) );
212
214
goto done ;
213
215
}
214
216
if (PMIX_BYTE_OBJECT != val -> type ) {
215
- fprintf (stderr , "%s:%d: PMIx_Get ghex returned wrong type: %d \n" , myproc .nspace ,
216
- myproc .rank , val -> type );
217
+ fprintf (stderr , "%s:%d: PMIx_Get ghex failed - returned wrong type: %s \n" , myproc .nspace ,
218
+ myproc .rank , PMIx_Data_type_string ( val -> type ) );
217
219
PMIX_VALUE_RELEASE (val );
218
220
goto done ;
219
221
}
220
222
if (128 != val -> data .bo .size ) {
221
- fprintf (stderr , "%s:%d: PMIx_Get ghex returned wrong size: %d\n" , myproc .nspace ,
223
+ fprintf (stderr , "%s:%d: PMIx_Get ghex failed - returned wrong size: %d\n" , myproc .nspace ,
222
224
myproc .rank , (int ) val -> data .bo .size );
223
225
PMIX_VALUE_RELEASE (val );
224
226
goto done ;
225
227
}
226
- fprintf (stderr , "%s:%d Ghex for %s:%d successfully retrieved\n" , myproc .nspace ,
227
- myproc .rank , proc .nspace , proc .rank );
228
228
PMIX_VALUE_RELEASE (val );
229
229
}
230
230
}
@@ -236,16 +236,17 @@ int main(int argc, char **argv)
236
236
if (PMIX_SUCCESS != (rc = PMIx_Fence (NULL , 0 , NULL , 0 ))) {
237
237
fprintf (stderr , "Client ns %s rank %d: PMIx_Fence failed: %d\n" , myproc .nspace , myproc .rank ,
238
238
rc );
239
- goto done ;
239
+ exit ( 1 ) ;
240
240
}
241
241
242
- fprintf (stderr , "Client ns %s rank %d: Finalizing\n" , myproc .nspace , myproc .rank );
243
242
if (PMIX_SUCCESS != (rc = PMIx_Finalize (NULL , 0 ))) {
244
243
fprintf (stderr , "Client ns %s rank %d:PMIx_Finalize failed: %d\n" , myproc .nspace ,
245
244
myproc .rank , rc );
246
245
} else {
247
- fprintf (stderr , "Client ns %s rank %d:PMIx_Finalize successfully completed\n" ,
248
- myproc .nspace , myproc .rank );
246
+ if (0 == myproc .rank ) {
247
+ fprintf (stderr , "Client ns %s rank %d:PMIx_Finalize successfully completed\n" ,
248
+ myproc .nspace , myproc .rank );
249
+ }
249
250
}
250
251
fflush (stderr );
251
252
return (0 );
0 commit comments