18
18
* Copyright (c) 2019 Triad National Security, LLC. All rights
19
19
* reserved.
20
20
* Copyright (c) 2019 IBM Corporation. All rights reserved.
21
- * Copyright (c) 2021 Nanook Consulting. All rights reserved.
21
+ * Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
22
22
* $COPYRIGHT$
23
23
*
24
24
* Additional copyrights may follow
@@ -48,7 +48,8 @@ static void notification_fn(size_t evhdlr_registration_id, pmix_status_t status,
48
48
EXAMPLES_HIDE_UNUSED_PARAMS (evhdlr_registration_id , source ,
49
49
info , ninfo , results , nresults );
50
50
51
- fprintf (stderr , "Client %s:%d NOTIFIED with status %d\n" , myproc .nspace , myproc .rank , status );
51
+ fprintf (stderr , "Client %s:%d NOTIFIED with status %s\n" ,
52
+ myproc .nspace , myproc .rank , PMIx_Error_string (status ));
52
53
if (NULL != cbfunc ) {
53
54
cbfunc (PMIX_EVENT_ACTION_COMPLETE , NULL , 0 , NULL , NULL , cbdata );
54
55
}
@@ -72,12 +73,12 @@ static void errhandler_reg_callbk(pmix_status_t status, size_t errhandler_ref, v
72
73
DEBUG_WAKEUP_THREAD (lock );
73
74
}
74
75
75
- static void grpcomplete (pmix_status_t status , pmix_info_t * info , size_t ninfo , void * cbdata ,
76
- pmix_release_cbfunc_t release_fn , void * release_cbdata )
76
+ static void grpcomplete (size_t evhdlr_registration_id , pmix_status_t status , const pmix_proc_t * source ,
77
+ pmix_info_t info [], size_t ninfo , pmix_info_t results [], size_t nresults ,
78
+ pmix_event_notification_cbfunc_fn_t cbfunc , void * cbdata )
77
79
{
78
- EXAMPLES_HIDE_UNUSED_PARAMS (status , info , ninfo , cbdata , release_fn , release_cbdata );
80
+ EXAMPLES_HIDE_UNUSED_PARAMS (evhdlr_registration_id , status , source , info , ninfo , results , nresults , cbfunc , cbdata );
79
81
80
- fprintf (stderr , "%s:%d GRPCOMPLETE\n" , myproc .nspace , myproc .rank );
81
82
DEBUG_WAKEUP_THREAD (& invitedlock );
82
83
}
83
84
@@ -93,7 +94,6 @@ static void invitefn(size_t evhdlr_registration_id, pmix_status_t status, const
93
94
94
95
/* if I am the leader, I can ignore this event */
95
96
if (PMIX_CHECK_PROCID (source , & myproc )) {
96
- fprintf (stderr , "%s:%d INVITED, BUT LEADER\n" , myproc .nspace , myproc .rank );
97
97
/* mark the event chain as complete */
98
98
if (NULL != cbfunc ) {
99
99
cbfunc (PMIX_EVENT_ACTION_COMPLETE , NULL , 0 , NULL , NULL , cbdata );
@@ -108,16 +108,12 @@ static void invitefn(size_t evhdlr_registration_id, pmix_status_t status, const
108
108
break ;
109
109
}
110
110
}
111
- fprintf (stderr , "Client %s:%d INVITED by source %s:%d\n" , myproc .nspace , myproc .rank ,
112
- source -> nspace , source -> rank );
113
111
invitedlock .status = status ;
114
- fprintf (stderr , "%s:%d ACCEPTING INVITE\n" , myproc .nspace , myproc .rank );
115
- rc = PMIx_Group_join_nb (grp , source , PMIX_GROUP_ACCEPT , NULL , 0 , grpcomplete , NULL );
112
+ rc = PMIx_Group_join_nb (grp , source , PMIX_GROUP_ACCEPT , NULL , 0 , NULL , NULL );
116
113
if (PMIX_SUCCESS != rc ) {
117
114
fprintf (stderr , "%s:%d Error in Group_join_nb: %sn" , myproc .nspace , myproc .rank ,
118
115
PMIx_Error_string (rc ));
119
116
}
120
-
121
117
/* mark the event chain as complete */
122
118
if (NULL != cbfunc ) {
123
119
cbfunc (PMIX_EVENT_ACTION_COMPLETE , NULL , 0 , NULL , NULL , cbdata );
@@ -134,25 +130,28 @@ int main(int argc, char **argv)
134
130
pmix_status_t code ;
135
131
pmix_info_t * results ;
136
132
size_t nresults ;
133
+ char hostname [1024 ];
137
134
138
135
EXAMPLES_HIDE_UNUSED_PARAMS (argc , argv );
139
136
137
+ gethostname (hostname , sizeof (hostname ));
138
+
140
139
/* init us */
141
140
if (PMIX_SUCCESS != (rc = PMIx_Init (& myproc , NULL , 0 ))) {
142
141
fprintf (stderr , "Client ns %s rank %d: PMIx_Init failed: %s\n" , myproc .nspace , myproc .rank ,
143
142
PMIx_Error_string (rc ));
144
143
exit (0 );
145
144
}
146
- fprintf (stderr , "[%d] Client ns %s rank %d: Running\n" , ( int ) getpid (), myproc . nspace ,
147
- myproc .rank );
145
+ fprintf (stderr , "[%d] Client ns %s rank %d: Running on %s \n" ,
146
+ ( int ) getpid (), myproc .nspace , myproc . rank , hostname );
148
147
149
148
DEBUG_CONSTRUCT_LOCK (& invitedlock );
150
149
151
150
PMIX_LOAD_PROCID (& proc , myproc .nspace , PMIX_RANK_WILDCARD );
152
151
153
- /* get our universe size */
154
- if (PMIX_SUCCESS != (rc = PMIx_Get (& proc , PMIX_UNIV_SIZE , NULL , 0 , & val ))) {
155
- fprintf (stderr , "Client ns %s rank %d: PMIx_Get universe size failed: %s\n" , myproc .nspace ,
152
+ /* get our job size */
153
+ if (PMIX_SUCCESS != (rc = PMIx_Get (& proc , PMIX_JOB_SIZE , NULL , 0 , & val ))) {
154
+ fprintf (stderr , "Client ns %s rank %d: PMIx_Get job size failed: %s\n" , myproc .nspace ,
156
155
myproc .rank , PMIx_Error_string (rc ));
157
156
goto done ;
158
157
}
@@ -164,7 +163,7 @@ int main(int argc, char **argv)
164
163
}
165
164
goto done ;
166
165
}
167
- fprintf (stderr , "Client %s:%d universe size %d\n" , myproc .nspace , myproc .rank , nprocs );
166
+ fprintf (stderr , "Client %s:%d job size %d\n" , myproc .nspace , myproc .rank , nprocs );
168
167
169
168
/* register our default errhandler */
170
169
DEBUG_CONSTRUCT_LOCK (& lock );
@@ -187,6 +186,18 @@ int main(int argc, char **argv)
187
186
if (PMIX_SUCCESS != rc ) {
188
187
goto done ;
189
188
}
189
+ if (2 == myproc .rank || 3 == myproc .rank ) {
190
+ /* need to register for group complete event */
191
+ DEBUG_CONSTRUCT_LOCK (& lock );
192
+ code = PMIX_GROUP_CONSTRUCT_COMPLETE ;
193
+ PMIx_Register_event_handler (& code , 1 , NULL , 0 , grpcomplete , errhandler_reg_callbk , (void * ) & lock );
194
+ DEBUG_WAIT_THREAD (& lock );
195
+ rc = lock .status ;
196
+ DEBUG_DESTRUCT_LOCK (& lock );
197
+ if (PMIX_SUCCESS != rc ) {
198
+ goto done ;
199
+ }
200
+ }
190
201
191
202
/* call fence to sync */
192
203
PMIX_LOAD_PROCID (& proc , myproc .nspace , PMIX_RANK_WILDCARD );
@@ -205,10 +216,10 @@ int main(int argc, char **argv)
205
216
PMIX_PROC_LOAD (& procs [1 ], myproc .nspace , 2 );
206
217
PMIX_PROC_LOAD (& procs [2 ], myproc .nspace , 3 );
207
218
rc = PMIx_Group_invite ("ourgroup" , procs , nprocs , NULL , 0 , & results , & nresults );
219
+ fprintf (stderr , "Client ns %s rank %d: Group invite complete with status %s!\n" ,
220
+ myproc .nspace , myproc .rank , PMIx_Error_string (rc ));
208
221
if (PMIX_SUCCESS != rc ) {
209
- fprintf (stderr , "Client ns %s rank %d: PMIx_Group_invite failed: %s\n" , myproc .nspace ,
210
- myproc .rank , PMIx_Error_string (rc ));
211
- goto done ;
222
+ exit (1 );
212
223
}
213
224
PMIX_PROC_FREE (procs , nprocs );
214
225
fprintf (stderr , "%s:%d Execute fence across group\n" , myproc .nspace , myproc .rank );
@@ -217,29 +228,30 @@ int main(int argc, char **argv)
217
228
if (PMIX_SUCCESS != rc ) {
218
229
fprintf (stderr , "Client ns %s rank %d: PMIx_Fence across group failed: %d\n" ,
219
230
myproc .nspace , myproc .rank , rc );
220
- goto done ;
231
+ exit ( 1 ) ;
221
232
}
222
- fprintf (stderr , "%d executing Group_destruct\n" , myproc .rank );
233
+ fprintf (stderr , "%d Executing Group_destruct\n" , myproc .rank );
223
234
rc = PMIx_Group_destruct ("ourgroup" , NULL , 0 );
224
235
if (PMIX_SUCCESS != rc ) {
225
- fprintf (stderr , "Client ns %s rank %d: PMIx_Group_destruct failed: %s\n" , myproc . nspace ,
226
- myproc .rank , PMIx_Error_string (rc ));
227
- goto done ;
236
+ fprintf (stderr , "Client ns %s rank %d: PMIx_Group_destruct failed: %s\n" ,
237
+ myproc .nspace , myproc . rank , PMIx_Error_string (rc ));
238
+ exit ( 1 ) ;
228
239
}
229
240
} else if (2 == myproc .rank || 3 == myproc .rank ) {
230
241
/* wait to be invited */
231
- fprintf (stderr , "%s:%d waiting to be invited \n" , myproc .nspace , myproc .rank );
242
+ fprintf (stderr , "%s:%d waiting to join group \n" , myproc .nspace , myproc .rank );
232
243
DEBUG_WAIT_THREAD (& invitedlock );
233
244
DEBUG_DESTRUCT_LOCK (& invitedlock );
234
- fprintf (stderr , "%s:%d Execute fence across group\n" , myproc .nspace , myproc .rank );
245
+ fprintf (stderr , "%s:%d Group complete - executing fence across group\n" ,
246
+ myproc .nspace , myproc .rank );
235
247
PMIX_PROC_LOAD (& proc , "ourgroup" , PMIX_RANK_WILDCARD );
236
248
rc = PMIx_Fence (& proc , 1 , NULL , 0 );
237
249
if (PMIX_SUCCESS != rc ) {
238
250
fprintf (stderr , "Client ns %s rank %d: PMIx_Fence across group failed: %d\n" ,
239
251
myproc .nspace , myproc .rank , rc );
240
252
goto done ;
241
253
}
242
- fprintf (stderr , "%d executing Group_destruct\n" , myproc .rank );
254
+ fprintf (stderr , "%d Executing Group_destruct\n" , myproc .rank );
243
255
rc = PMIx_Group_destruct ("ourgroup" , NULL , 0 );
244
256
if (PMIX_SUCCESS != rc ) {
245
257
fprintf (stderr , "Client ns %s rank %d: PMIx_Group_destruct failed: %s\n" , myproc .nspace ,
0 commit comments