2 |
|
#include <stdlib.h> |
3 |
|
#include <stdio.h> |
4 |
|
#include <string.h> |
5 |
+ |
#define __mpiBASSEVENT |
6 |
|
#include "mpiInterface.h" |
7 |
|
|
8 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
< |
mpiEventInit() |
14 |
> |
void mpiEventInit(void) |
15 |
|
{ |
16 |
< |
int blockCounts[4] = {1,3,4,120} |
17 |
< |
MPI_Aint dspls[4]; |
18 |
< |
MPI_Datatype types[4]; |
16 |
> |
int blockCounts[5] = {1,3,4,120,80}; |
17 |
> |
MPI_Aint dspls[5]; |
18 |
> |
MPI_Datatype types[5]; |
19 |
|
mBEvent protoEvent; |
20 |
|
|
21 |
|
int i; |
22 |
|
|
23 |
< |
MPI_Address(&protoEvent.type, dspls[0]); |
24 |
< |
MPI_Address(&protoEvent.d1, dspls[1]); |
25 |
< |
MPI_Address(&protoEvent.i1, dspls[2]); |
26 |
< |
MPI_Address(&protoEvent.cArray, dspls[3]); |
23 |
> |
MPI_Address(&protoEvent.type, &dspls[0]); |
24 |
> |
MPI_Address(&protoEvent.d1, &dspls[1]); |
25 |
> |
MPI_Address(&protoEvent.i1, &dspls[2]); |
26 |
> |
MPI_Address(&protoEvent.cArray, &dspls[3]); |
27 |
> |
MPI_Address(&protoEvent.lhs , &dspls[4]); |
28 |
|
|
29 |
|
|
30 |
|
types[0] = MPI_INT; |
31 |
|
types[1] = MPI_DOUBLE; |
32 |
|
types[2] = MPI_INT; |
33 |
|
types[3] = MPI_CHAR; |
34 |
+ |
types[4] = MPI_CHAR; |
35 |
|
|
36 |
|
|
37 |
< |
for (i =3; i >= 0; i--) dspls[i] -= dspls[0]; |
37 |
> |
for (i =4; i >= 0; i--) dspls[i] -= dspls[0]; |
38 |
|
|
39 |
< |
MPI_Type_struct(4,blockCounts,dspls,types,&mpiBASSEventType); |
39 |
> |
MPI_Type_struct(5,blockCounts,dspls,types,&mpiBASSEventType); |
40 |
|
MPI_Type_commit(&mpiBASSEventType); |
41 |
|
} |
42 |
|
|
43 |
|
|
44 |
< |
throwMPIEvent(event* the_event) |
44 |
> |
void throwMPIEvent(event* the_event) |
45 |
|
{ |
46 |
< |
mBEvent mpiBEventContainer; |
46 |
> |
mBEvent mpiEventContainer; |
47 |
|
int mpiStatus; |
48 |
|
int mpiError; |
49 |
+ |
int mynode; |
50 |
|
|
51 |
|
if (the_event == NULL) mpiStatus = MPI_INTERFACE_DONE; |
52 |
|
else mpiStatus = MPI_INTERFACE_CONTINUE; |
54 |
|
mpiError = MPI_Bcast(&mpiStatus,1,MPI_INT,0,MPI_COMM_WORLD); |
55 |
|
if (mpiError != MPI_SUCCESS){ |
56 |
|
mpiError = MPI_Finalize(); |
57 |
< |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(); |
57 |
> |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
58 |
|
exit (0); |
59 |
|
} |
60 |
|
|
62 |
|
switch (the_event->event_type){ |
63 |
|
case MOLECULE: |
64 |
|
mpiEventContainer.type = mpiMOLECULE; |
65 |
< |
mpiEventContainer.i1 = the_event->evt.block_index; // pack block index into first int |
65 |
> |
mpiEventContainer.i1 = the_event->evt.blk_index; // pack block index into first int |
66 |
|
break; |
67 |
|
|
68 |
|
case ATOM: |
69 |
|
mpiEventContainer.type = mpiATOM; |
70 |
< |
mpiEventContainer.i1 = the_event->evt.block_index; // pack block index into first int |
70 |
> |
mpiEventContainer.i1 = the_event->evt.blk_index; // pack block index into first int |
71 |
|
break; |
72 |
|
|
73 |
|
case BOND: |
74 |
|
mpiEventContainer.type = mpiBOND; |
75 |
< |
mpiEventContainer.i1 = the_event->evt.block_index; // pack block index into first int |
75 |
> |
mpiEventContainer.i1 = the_event->evt.blk_index; // pack block index into first int |
76 |
|
break; |
77 |
|
|
78 |
|
case BEND: |
79 |
|
mpiEventContainer.type = mpiBEND; |
80 |
< |
mpiEventContainer.i1 = the_event->evt.block_index; // pack block index into first int |
80 |
> |
mpiEventContainer.i1 = the_event->evt.blk_index; // pack block index into first int |
81 |
|
break; |
82 |
|
|
83 |
|
case TORSION: |
84 |
|
mpiEventContainer.type = mpiTORSION; |
85 |
< |
mpiEventContainer.i1 = the_event->evt.block_index; // pack block index into first int |
85 |
> |
mpiEventContainer.i1 = the_event->evt.blk_index; // pack block index into first int |
86 |
|
break; |
87 |
|
|
88 |
|
case COMPONENT: |
89 |
|
mpiEventContainer.type = mpiCOMPONENT; |
90 |
< |
mpiEventContainer.i1 = the_event->evt.block_index; // pack block index into first int |
90 |
> |
mpiEventContainer.i1 = the_event->evt.blk_index; // pack block index into first int |
91 |
|
break; |
92 |
|
|
93 |
|
case POSITION: |
118 |
|
break; |
119 |
|
|
120 |
|
case ASSIGNMENT: |
121 |
+ |
|
122 |
+ |
strcpy(mpiEventContainer.lhs,the_event->evt.asmt.lhs); |
123 |
+ |
|
124 |
+ |
#ifdef D_VERBOSE |
125 |
+ |
mpiError = MPI_Comm_rank(MPI_COMM_WORLD,&mynode); |
126 |
+ |
fprintf(stderr, |
127 |
+ |
"mpiDiag at node %d: evt Assignment: \"%s\" = ?\n" |
128 |
+ |
" mpi Assignment: \"%s\" = ?\n", |
129 |
+ |
mynode, |
130 |
+ |
the_event->evt.asmt.lhs, |
131 |
+ |
mpiEventContainer.lhs); |
132 |
+ |
#endif |
133 |
+ |
|
134 |
|
switch (the_event->evt.asmt.asmt_type){ |
135 |
|
case STRING: |
136 |
|
mpiEventContainer.type = mpiASSIGNMENT_s; |
137 |
< |
strcpy(mpiEventContainer.cArray,the_event->evt.asmt.sval); |
137 |
> |
strcpy(mpiEventContainer.cArray,the_event->evt.asmt.rhs.sval); |
138 |
|
break; |
139 |
|
|
140 |
|
case INT: |
141 |
|
mpiEventContainer.type = mpiASSIGNMENT_i; |
142 |
< |
mpiEventContainer.i1 = the_event->evt.asmt.ival; |
142 |
> |
mpiEventContainer.i1 = the_event->evt.asmt.rhs.ival; |
143 |
|
break; |
144 |
|
|
145 |
|
case DOUBLE: |
146 |
|
mpiEventContainer.type = mpiASSIGNMENT_d; |
147 |
< |
mpiEventContainer.d1 = the_event->evt.asmt.dval; |
147 |
> |
mpiEventContainer.d1 = the_event->evt.asmt.rhs.dval; |
148 |
|
break; |
149 |
|
} |
150 |
|
break; |
159 |
|
|
160 |
|
if (mpiError != MPI_SUCCESS){ |
161 |
|
mpiError = MPI_Finalize(); |
162 |
< |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(); |
162 |
> |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
163 |
|
exit (0); |
164 |
|
} |
165 |
|
} |
167 |
|
|
168 |
|
|
169 |
|
// Everybody but node 0 runs this |
170 |
< |
mpiEventLoop() |
170 |
> |
void mpiEventLoop(void) |
171 |
|
{ |
172 |
|
int mpiError; |
173 |
|
int mpiContinue; |
174 |
+ |
int mynode; |
175 |
|
|
176 |
+ |
#ifdef D_VERBOSE |
177 |
+ |
mpiError = MPI_Comm_rank(MPI_COMM_WORLD,&mynode); |
178 |
+ |
fprintf(stderr, |
179 |
+ |
"event key List at node %d:\n" |
180 |
+ |
" MOLECULE %d\n" |
181 |
+ |
" ATOM %d\n" |
182 |
+ |
" BOND %d\n" |
183 |
+ |
" BEND %d\n" |
184 |
+ |
" TORSION %d\n" |
185 |
+ |
" COMPONENT %d\n" |
186 |
+ |
" POSITION %d\n" |
187 |
+ |
" ASSIGNMENT %d\n" |
188 |
+ |
" MEMBER %d\n" |
189 |
+ |
" CONSTRAINT %d\n" |
190 |
+ |
" ORIENTATION %d\n" |
191 |
+ |
" START_INDEX %d\n" |
192 |
+ |
" BLOCK_END %d\n" |
193 |
+ |
"\n", |
194 |
+ |
mynode, |
195 |
+ |
MOLECULE, ATOM, BOND, BEND, TORSION, COMPONENT, |
196 |
+ |
POSITION, ASSIGNMENT, MEMBER, CONSTRAINT, ORIENTATION, |
197 |
+ |
START_INDEX, BLOCK_END ); |
198 |
+ |
#endif |
199 |
+ |
|
200 |
|
mpiError = MPI_Bcast(&mpiContinue,1,MPI_INT,0,MPI_COMM_WORLD); |
201 |
|
if (mpiError != MPI_SUCCESS){ |
202 |
|
mpiError = MPI_Finalize(); |
203 |
< |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(); |
203 |
> |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
204 |
|
exit (0); |
205 |
|
} |
206 |
|
|
212 |
|
mpiError = MPI_Bcast(&mpiContinue,1,MPI_INT,0,MPI_COMM_WORLD); |
213 |
|
if (mpiError != MPI_SUCCESS){ |
214 |
|
mpiError = MPI_Finalize(); |
215 |
< |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(); |
215 |
> |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
216 |
|
exit (0); |
217 |
|
} |
218 |
|
} |
219 |
|
|
220 |
|
if (mpiContinue == MPI_INTERFACE_ABORT){ |
221 |
|
mpiError = MPI_Finalize(); |
222 |
< |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(); |
222 |
> |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
223 |
|
exit (0); |
224 |
|
} |
225 |
|
} |
226 |
|
|
227 |
< |
mpiCatchEvent() |
227 |
> |
void mpiCatchEvent(void) |
228 |
|
{ |
229 |
|
event the_event; |
230 |
< |
mBEvent mpiBEventContainer; |
230 |
> |
mBEvent mpiEventContainer; |
231 |
|
int mpiError; |
232 |
+ |
int mynode; |
233 |
|
|
234 |
|
|
235 |
|
mpiError = MPI_Bcast(&mpiEventContainer,1,mpiBASSEventType,0,MPI_COMM_WORLD); |
236 |
|
|
237 |
|
if (mpiError != MPI_SUCCESS){ |
238 |
|
mpiError = MPI_Finalize(); |
239 |
< |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(); |
239 |
> |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
240 |
|
exit (0); |
241 |
|
} |
242 |
|
|
244 |
|
switch (mpiEventContainer.type){ |
245 |
|
case mpiMOLECULE: |
246 |
|
the_event.event_type = MOLECULE; |
247 |
< |
the_event.evt.block_index = mpiEventContainer.i1; |
247 |
> |
the_event.evt.blk_index = mpiEventContainer.i1; |
248 |
|
break; |
249 |
|
|
250 |
|
case mpiATOM: |
251 |
|
the_event.event_type = ATOM; |
252 |
< |
the_event.evt.block_index = mpiEventContainer.i1; |
252 |
> |
the_event.evt.blk_index = mpiEventContainer.i1; |
253 |
|
break; |
254 |
|
|
255 |
|
case mpiBOND: |
256 |
|
the_event.event_type = BOND; |
257 |
< |
the_event.evt.block_index = mpiEventContainer.i1; |
257 |
> |
the_event.evt.blk_index = mpiEventContainer.i1; |
258 |
|
break; |
259 |
|
|
260 |
|
case mpiBEND: |
261 |
|
the_event.event_type = BEND; |
262 |
< |
the_event.evt.block_index = mpiEventContainer.i1; |
262 |
> |
the_event.evt.blk_index = mpiEventContainer.i1; |
263 |
|
break; |
264 |
|
|
265 |
|
case mpiTORSION: |
266 |
|
the_event.event_type = TORSION; |
267 |
< |
the_event.evt.block_index = mpiEventContainer.i1; |
267 |
> |
the_event.evt.blk_index = mpiEventContainer.i1; |
268 |
|
break; |
269 |
|
|
270 |
|
case mpiCOMPONENT: |
271 |
|
the_event.event_type = COMPONENT; |
272 |
< |
the_event.evt.block_index = mpiEventContainer.i1; |
272 |
> |
the_event.evt.blk_index = mpiEventContainer.i1; |
273 |
|
break; |
274 |
|
|
275 |
|
|
303 |
|
case mpiASSIGNMENT_s: |
304 |
|
the_event.event_type = ASSIGNMENT; |
305 |
|
the_event.evt.asmt.asmt_type = STRING; |
306 |
< |
strcpy(the_event.evt.asmt.sval,mpiEventContainer.cArray); |
306 |
> |
strcpy(the_event.evt.asmt.lhs,mpiEventContainer.lhs); |
307 |
> |
strcpy(the_event.evt.asmt.rhs.sval,mpiEventContainer.cArray); |
308 |
> |
|
309 |
> |
#ifdef D_VERBOSE |
310 |
> |
mpiError = MPI_Comm_rank(MPI_COMM_WORLD,&mynode); |
311 |
> |
fprintf(stderr, "mpiDiag at node %d: Assignment: %s = %s\n", mynode, |
312 |
> |
the_event.evt.asmt.lhs, |
313 |
> |
the_event.evt.asmt.rhs.sval ); |
314 |
> |
#endif |
315 |
> |
|
316 |
|
break; |
317 |
|
|
318 |
|
case mpiASSIGNMENT_i: |
319 |
|
the_event.event_type = ASSIGNMENT; |
320 |
|
the_event.evt.asmt.asmt_type = INT; |
321 |
< |
the_event.evt.asmt.ival = mpiEventContainer.i1; |
321 |
> |
strcpy(the_event.evt.asmt.lhs,mpiEventContainer.lhs); |
322 |
> |
the_event.evt.asmt.rhs.ival = mpiEventContainer.i1; |
323 |
> |
|
324 |
> |
#ifdef D_VERBOSE |
325 |
> |
mpiError = MPI_Comm_rank(MPI_COMM_WORLD,&mynode); |
326 |
> |
fprintf(stderr, "mpiDiag at node %d: Assignment: %s = %d\n", mynode, |
327 |
> |
the_event.evt.asmt.lhs, |
328 |
> |
the_event.evt.asmt.rhs.ival ); |
329 |
> |
#endif |
330 |
> |
|
331 |
|
break; |
332 |
|
|
333 |
|
case mpiASSIGNMENT_d: |
334 |
|
the_event.event_type = ASSIGNMENT; |
335 |
|
the_event.evt.asmt.asmt_type = DOUBLE; |
336 |
< |
the_event.evt.asmt.dval = mpiEventContainer.d1; |
336 |
> |
strcpy(the_event.evt.asmt.lhs,mpiEventContainer.lhs); |
337 |
> |
the_event.evt.asmt.rhs.dval = mpiEventContainer.d1; |
338 |
> |
|
339 |
> |
#ifdef D_VERBOSE |
340 |
> |
mpiError = MPI_Comm_rank(MPI_COMM_WORLD,&mynode); |
341 |
> |
fprintf(stderr, "mpiDiag at node %d: Assignment: %s = %lf\n", mynode, |
342 |
> |
the_event.evt.asmt.lhs, |
343 |
> |
the_event.evt.asmt.rhs.dval ); |
344 |
> |
#endif |
345 |
> |
|
346 |
|
break; |
347 |
|
|
348 |
|
case mpiBLOCK_END: |
350 |
|
break; |
351 |
|
} |
352 |
|
|
353 |
< |
|
354 |
< |
if (!event_handler(&the_event)){ |
355 |
< |
sprintf(stderr,"MPI event handling error => %s\n",the_event.err_msg); |
356 |
< |
mpiError = MPI_Finalize(); |
357 |
< |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(); |
353 |
> |
#ifdef D_VERBOSE |
354 |
> |
mpiError = MPI_Comm_rank(MPI_COMM_WORLD,&mynode); |
355 |
> |
fprintf(stderr, "mpiDiag at node %d: event type is %d\n", mynode, |
356 |
> |
the_event.event_type); |
357 |
> |
#endif |
358 |
> |
|
359 |
> |
if (!event_handler(&the_event)){ |
360 |
> |
mpiError = MPI_Comm_rank(MPI_COMM_WORLD,&mynode); |
361 |
> |
fprintf(stderr,"MPI event handling error at node %d => %s\n",mynode,the_event.err_msg); |
362 |
> |
// mpiError = MPI_Finalize(); |
363 |
> |
// if (mpiError != MPI_SUCCESS) |
364 |
> |
mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
365 |
|
exit (0); |
366 |
|
} |
367 |
|
} |
368 |
+ |
|
369 |
+ |
|
370 |
+ |
void mpiInterfaceExit(void){ |
371 |
+ |
int mpiError; |
372 |
+ |
int mpiStatus = MPI_INTERFACE_ABORT; |
373 |
+ |
|
374 |
+ |
mpiError = MPI_Bcast(&mpiStatus,1,MPI_INT,0,MPI_COMM_WORLD); |
375 |
+ |
if (mpiError != MPI_SUCCESS){ |
376 |
+ |
mpiError = MPI_Finalize(); |
377 |
+ |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
378 |
+ |
exit (0); |
379 |
+ |
} |
380 |
+ |
|
381 |
+ |
mpiError = MPI_Finalize(); |
382 |
+ |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
383 |
+ |
exit (0); |
384 |
+ |
|
385 |
+ |
} |